Skip to content

Commit 8894210

Browse files
authored
Merge pull request #67 from kion-dgl/60-nino-island-textures
60 nino island textures
2 parents 023a57e + 96c4fed commit 8894210

File tree

15 files changed

+855
-6
lines changed

15 files changed

+855
-6
lines changed

bin/nino-ST1AT.BIN

448 KB
Binary file not shown.

bin/nino-ST1BT.BIN

580 KB
Binary file not shown.

index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ import { updateFlutterPaintings } from "./src/ST05T";
2727
import { updateYosyonkePaintings } from "./src/ST47T";
2828
import { updateYosyonkePaintings2 } from "./src/ST0AT";
2929
import { updateYosyonkePaintings3 } from "./src/ST0CT";
30+
import { updateNinoGiftShop } from "./src/ST1AT";
31+
import { updateNinoPigRoom } from "./src/ST1BT";
3032

3133
encodeTitle("miku/title.png");
3234
// process.exit();
@@ -226,11 +228,19 @@ updateYosyonkePaintings(
226228
"miku/paintings/room-203.png",
227229
"miku/paintings/room-203-poster.png",
228230
);
231+
229232
updateYosyonkePaintings2(
230233
"miku/paintings/comic-hero.png",
231234
"miku/paintings/bar-room.png",
235+
"miku/paintings/yosyonke-junk.png",
232236
);
233237
updateYosyonkePaintings3("miku/paintings/tiger-room.png");
238+
updateNinoGiftShop("miku/paintings/gift-room.png");
239+
updateNinoPigRoom(
240+
"miku/paintings/sumigumi.png",
241+
"miku/paintings/suitntie2.png",
242+
"miku/paintings/ribby2.png",
243+
);
234244

235245
/**
236246
Encode Rom

miku/paintings/gift-room.png

1.63 KB
Loading

miku/paintings/ribby.png

1.52 KB
Loading

miku/paintings/ribby2.png

1.95 KB
Loading

miku/paintings/suitntie.png

1.85 KB
Loading

miku/paintings/suitntie2.png

1023 Bytes
Loading

miku/paintings/sumigumi.png

1.35 KB
Loading

miku/paintings/yosyonke-junk.png

1.58 KB
Loading

src/EncodeRom.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,8 @@ const encodeRom = () => {
577577
"yosyonke-ST47T.BIN",
578578
"yosyonke-ST0AT.BIN",
579579
"yosyonke-ST0CT.BIN",
580+
"nino-ST1AT.BIN",
581+
"nino-ST1BT.BIN",
580582
];
581583

582584
console.log("--- Replacing Cut Scene Textures ---");

src/ST0AT.ts

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,10 +311,94 @@ const updateBar = (bin: Buffer, pngPath: string) => {
311311
bin.writeInt16LE(bodyBitField.length, 0x11024);
312312
};
313313

314-
const updateYosyonkePaintings2 = (comicHero: string, barPainting: string) => {
314+
const updateAirship = (bin: Buffer, pngPath: string) => {
315+
const pngData = readFileSync(pngPath);
316+
317+
const imgOfs = 0x24000;
318+
const pal: number[] = [];
319+
320+
const encodedLogo = encodeCutSceneTexture(pal, pngData);
321+
const mpTexture = decompress(Buffer.from(bin.subarray(imgOfs)));
322+
323+
const includedPal = Buffer.from(mpTexture.subarray(0, 0x20));
324+
const encodedTexture = Buffer.from(mpTexture.subarray(0x20));
325+
326+
// Update Palette
327+
const palOfs = 0x2c800;
328+
const red = encodeTexel(255, 0, 0, 255);
329+
for (let i = 0; i < pal.length; i++) {
330+
bin.writeUInt16LE(pal[i], palOfs + 0x30 + i * 2);
331+
// bin.writeUInt16LE(red, palOfs + 0x30 + i * 2);
332+
}
333+
334+
const ROW_LEN = 0x80;
335+
const X_START = 192;
336+
const Y_START = 0;
337+
let texOfs = ROW_LEN * Y_START; // + PAL_OFS;
338+
let logoOfs = 0;
339+
const HEIGHT = 64;
340+
const WIDTH = 48;
341+
for (let y = 0; y < HEIGHT; y++) {
342+
texOfs += X_START / 2;
343+
for (let x = 0; x < WIDTH / 2; x++) {
344+
encodedTexture[texOfs++] = encodedLogo[logoOfs++];
345+
}
346+
texOfs += (256 - X_START - WIDTH) / 2;
347+
}
348+
349+
// console.log("Logo Pos: 0x%s", logoOfs.toString(16));
350+
351+
const imageData: number[] = new Array();
352+
for (let ofs = 0; ofs < encodedTexture.length; ofs++) {
353+
const byte = encodedTexture.readUInt8(ofs);
354+
355+
imageData.push(byte & 0xf);
356+
imageData.push(byte >> 4);
357+
}
358+
359+
const [bodyBitField, compressedBody] = compressNewTexture(
360+
includedPal,
361+
encodedTexture,
362+
1,
363+
);
364+
const len = bodyBitField.length + compressedBody.length;
365+
366+
for (let i = 0x24030; i < 0x273e0; i++) {
367+
bin[i] = 0;
368+
}
369+
370+
let ofs = 0x24030;
371+
for (let i = 0; i < bodyBitField.length; i++) {
372+
bin[ofs++] = bodyBitField[i];
373+
}
374+
375+
for (let i = 0; i < compressedBody.length; i++) {
376+
bin[ofs++] = compressedBody[i];
377+
}
378+
379+
if (ofs <= 0x27000) {
380+
console.log("too short!!!");
381+
throw new Error("airship painting too short");
382+
} else if (len > 0x27800) {
383+
console.log("too long");
384+
throw new Error("airship painting too long");
385+
} else {
386+
console.log("yaya!!!");
387+
}
388+
389+
console.log("End: 0x%s", ofs.toString(16));
390+
bin.writeInt16LE(bodyBitField.length, 0x24024);
391+
};
392+
393+
const updateYosyonkePaintings2 = (
394+
comicHero: string,
395+
barPainting: string,
396+
airship: string,
397+
) => {
315398
const bin = readFileSync("bin/yosyonke-ST0AT.BIN");
316399
updateComicHero(bin, comicHero);
317400
updateBar(bin, barPainting);
401+
updateAirship(bin, airship);
318402
writeFileSync("out/yosyonke-ST0AT.BIN", bin);
319403
};
320404

0 commit comments

Comments
 (0)