Skip to content

Commit

Permalink
Merge pull request #67 from kion-dgl/60-nino-island-textures
Browse files Browse the repository at this point in the history
60 nino island textures
  • Loading branch information
kion-dgl authored Sep 30, 2024
2 parents 023a57e + 96c4fed commit 8894210
Show file tree
Hide file tree
Showing 15 changed files with 855 additions and 6 deletions.
Binary file added bin/nino-ST1AT.BIN
Binary file not shown.
Binary file added bin/nino-ST1BT.BIN
Binary file not shown.
10 changes: 10 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import { updateFlutterPaintings } from "./src/ST05T";
import { updateYosyonkePaintings } from "./src/ST47T";
import { updateYosyonkePaintings2 } from "./src/ST0AT";
import { updateYosyonkePaintings3 } from "./src/ST0CT";
import { updateNinoGiftShop } from "./src/ST1AT";
import { updateNinoPigRoom } from "./src/ST1BT";

encodeTitle("miku/title.png");
// process.exit();
Expand Down Expand Up @@ -226,11 +228,19 @@ updateYosyonkePaintings(
"miku/paintings/room-203.png",
"miku/paintings/room-203-poster.png",
);

updateYosyonkePaintings2(
"miku/paintings/comic-hero.png",
"miku/paintings/bar-room.png",
"miku/paintings/yosyonke-junk.png",
);
updateYosyonkePaintings3("miku/paintings/tiger-room.png");
updateNinoGiftShop("miku/paintings/gift-room.png");
updateNinoPigRoom(
"miku/paintings/sumigumi.png",
"miku/paintings/suitntie2.png",
"miku/paintings/ribby2.png",
);

/**
Encode Rom
Expand Down
Binary file added miku/paintings/gift-room.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added miku/paintings/ribby.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added miku/paintings/ribby2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added miku/paintings/suitntie.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added miku/paintings/suitntie2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added miku/paintings/sumigumi.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added miku/paintings/yosyonke-junk.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/EncodeRom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,8 @@ const encodeRom = () => {
"yosyonke-ST47T.BIN",
"yosyonke-ST0AT.BIN",
"yosyonke-ST0CT.BIN",
"nino-ST1AT.BIN",
"nino-ST1BT.BIN",
];

console.log("--- Replacing Cut Scene Textures ---");
Expand Down
86 changes: 85 additions & 1 deletion src/ST0AT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,94 @@ const updateBar = (bin: Buffer, pngPath: string) => {
bin.writeInt16LE(bodyBitField.length, 0x11024);
};

const updateYosyonkePaintings2 = (comicHero: string, barPainting: string) => {
const updateAirship = (bin: Buffer, pngPath: string) => {
const pngData = readFileSync(pngPath);

const imgOfs = 0x24000;
const pal: number[] = [];

const encodedLogo = encodeCutSceneTexture(pal, pngData);
const mpTexture = decompress(Buffer.from(bin.subarray(imgOfs)));

const includedPal = Buffer.from(mpTexture.subarray(0, 0x20));
const encodedTexture = Buffer.from(mpTexture.subarray(0x20));

// Update Palette
const palOfs = 0x2c800;
const red = encodeTexel(255, 0, 0, 255);
for (let i = 0; i < pal.length; i++) {
bin.writeUInt16LE(pal[i], palOfs + 0x30 + i * 2);
// bin.writeUInt16LE(red, palOfs + 0x30 + i * 2);
}

const ROW_LEN = 0x80;
const X_START = 192;
const Y_START = 0;
let texOfs = ROW_LEN * Y_START; // + PAL_OFS;
let logoOfs = 0;
const HEIGHT = 64;
const WIDTH = 48;
for (let y = 0; y < HEIGHT; y++) {
texOfs += X_START / 2;
for (let x = 0; x < WIDTH / 2; x++) {
encodedTexture[texOfs++] = encodedLogo[logoOfs++];
}
texOfs += (256 - X_START - WIDTH) / 2;
}

// console.log("Logo Pos: 0x%s", logoOfs.toString(16));

const imageData: number[] = new Array();
for (let ofs = 0; ofs < encodedTexture.length; ofs++) {
const byte = encodedTexture.readUInt8(ofs);

imageData.push(byte & 0xf);
imageData.push(byte >> 4);
}

const [bodyBitField, compressedBody] = compressNewTexture(
includedPal,
encodedTexture,
1,
);
const len = bodyBitField.length + compressedBody.length;

for (let i = 0x24030; i < 0x273e0; i++) {
bin[i] = 0;
}

let ofs = 0x24030;
for (let i = 0; i < bodyBitField.length; i++) {
bin[ofs++] = bodyBitField[i];
}

for (let i = 0; i < compressedBody.length; i++) {
bin[ofs++] = compressedBody[i];
}

if (ofs <= 0x27000) {
console.log("too short!!!");
throw new Error("airship painting too short");
} else if (len > 0x27800) {
console.log("too long");
throw new Error("airship painting too long");
} else {
console.log("yaya!!!");
}

console.log("End: 0x%s", ofs.toString(16));
bin.writeInt16LE(bodyBitField.length, 0x24024);
};

const updateYosyonkePaintings2 = (
comicHero: string,
barPainting: string,
airship: string,
) => {
const bin = readFileSync("bin/yosyonke-ST0AT.BIN");
updateComicHero(bin, comicHero);
updateBar(bin, barPainting);
updateAirship(bin, airship);
writeFileSync("out/yosyonke-ST0AT.BIN", bin);
};

Expand Down
Loading

0 comments on commit 8894210

Please sign in to comment.