From 54a2df5eea4803ebaf635de35a4683cb8248c786 Mon Sep 17 00:00:00 2001 From: kion Date: Mon, 30 Sep 2024 17:57:37 +0900 Subject: [PATCH] lofi roll in barrel room --- index.ts | 2 + miku/paintings/roll-lofi.png | Bin 0 -> 1605 bytes src/ST05T.ts | 86 ++++++++++++++++++++++- test/{yosyonke.skip => yosyonke.test.ts} | 6 +- 4 files changed, 90 insertions(+), 4 deletions(-) create mode 100644 miku/paintings/roll-lofi.png rename test/{yosyonke.skip => yosyonke.test.ts} (98%) diff --git a/index.ts b/index.ts index b409106..8358118 100644 --- a/index.ts +++ b/index.ts @@ -220,9 +220,11 @@ encodeApronMegaman(); updateST03T("miku/apron/body-01.png", "miku/faces/ST03T.png"); updateSceneModel(); updateDemoLogo("miku/title-smol.png"); + updateFlutterPaintings( "miku/paintings/megaman-room.png", "miku/paintings/roll-room.png", + "miku/paintings/roll-lofi.png", ); updateYosyonkePaintings( "miku/paintings/room-203.png", diff --git a/miku/paintings/roll-lofi.png b/miku/paintings/roll-lofi.png new file mode 100644 index 0000000000000000000000000000000000000000..eb3a07b1fe6ae995c38bc4d555fcacbfd4143814 GIT binary patch literal 1605 zcmV-L2DEX>4Tx04R}tkv&MmKpe$iQ^gM|4i*tn$WWc^q9Ts93Pq?8YK2xEOfLO`CJjl7 zi=*ILaPVWX>fqw6tAnc`2!4P#J2)x2NQwVT3N2zhIPS;0dyl(!fKV?p&FY8&nr@q^ zL|n{dSH-SZ^k5W&2qP#n%b1g-Bz(u$Jpz2ai}Ec0bAOILHD@s(AQH!zVcNtS#50?= z!FiuJ%!;x~d`>)J(glehxvqHp#<}3Kz%#>UIyFxmCKd~Ath6yJni}ymaYWU0$`>*o ztDLtuYvn3y-jlyDl+#z1xlVHg2`pj>5=1DdqJ%PRL}}GYv5=zuxQ~C>^-JVZ$W;O( z#{w$QAiI9>Klt6Pm7kjQl0tEy^TlyK#(=I}piy(2?_(i|qi@Or1Ghl$n%7%%AEysMnz~Bf00)P_ zc!9Flecs*O-rK)tn*IF%ZK!gj$5wdo58A@pep7D19 z%M^(zsB?D+ym}*iZa0@GAW_&jjDY^Na6i~iWYZ}q>M;a3cO~$66y`yK;~z+1m7owfMBsc*lVMptu2fr;03VHdOyfu>n8oLhg4m4POZ)@Kc_sOK^&ZJ-=raDoY(=5xD%~@|HANx*DxXct1 zSf$Ekc}`>L&v5vTitSpy=a`=0p6?n{2q>2&Q^Vmfaei&ynhZC;vxNvO*PMc4A|ZiA zQ)A2+%PFV1UVZ1bjb&RF_9Ruh0w^O4FEZy%r+xspo6gg~RA(!-WNOq%>f;tir%t_b z0A;6XUs#1`f}mz;#yHi-nPt0er|IlKxgl-LUIDF&Hcpv7DRXQ&j&lHOdwAep@NgLa z;k=^hMv~lQR+Y1MQvw)A1&?!a%fS@)#8AF$LLvX+ftF;6G_TlL zLv72M#gW0~I1}R065QR+zsPEaPHqN_w;N9L>E#tf3I{ZMM$00000NkvXXu0mjf DcZtuj literal 0 HcmV?d00001 diff --git a/src/ST05T.ts b/src/ST05T.ts index 52d80ce..bb883f4 100644 --- a/src/ST05T.ts +++ b/src/ST05T.ts @@ -290,10 +290,94 @@ const updateRoll = (bin: Buffer, pngPath: string) => { bin.writeInt16LE(bodyBitField.length, 0x10024); }; -const updateFlutterPaintings = (megamanPath: string, rollPath: string) => { +const updateBarrel = (bin: Buffer, pngPath: string) => { + const pngData = readFileSync(pngPath); + + const imgOfs = 0x37800; + 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 = 0x3f800; + 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 = 208; + let texOfs = ROW_LEN * Y_START; // + PAL_OFS; + let logoOfs = 0; + const HEIGHT = 48; + const WIDTH = 64; + 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 = 0x37830; i < 0x3cd30; i++) { + bin[i] = 0; + } + + let ofs = 0x37830; + 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 <= 0x3c800) { + console.log("too short!!!"); + throw new Error("barell painting too short"); + } else if (len > 0x3d000) { + console.log("too long"); + throw new Error("barell painting too long"); + } else { + console.log("yaya!!!"); + } + + console.log("End: 0x%s", ofs.toString(16)); + bin.writeInt16LE(bodyBitField.length, 0x37824); +}; + +const updateFlutterPaintings = ( + megamanPath: string, + rollPath: string, + barPath: string, +) => { const bin = readFileSync("bin/flutter-ST05T.BIN"); updateMegaman(bin, megamanPath); updateRoll(bin, rollPath); + updateBarrel(bin, barPath); writeFileSync("out/flutter-ST05T.BIN", bin); }; diff --git a/test/yosyonke.skip b/test/yosyonke.test.ts similarity index 98% rename from test/yosyonke.skip rename to test/yosyonke.test.ts index af498a0..81db55f 100644 --- a/test/yosyonke.skip +++ b/test/yosyonke.test.ts @@ -175,7 +175,7 @@ const renderImage = ( }; test("it should search for textures in the yosyonke", () => { - const src = readFileSync("bin/yosyonke-ST0AT.BIN"); + const src = readFileSync("bin/flutter-ST05T.BIN"); const pals: Pixel[][] = [ [ { r: 0, g: 0, b: 0, a: 0 }, @@ -229,8 +229,8 @@ test("it should search for textures in the yosyonke", () => { }); test("it should search for room203 palette", () => { - const src = readFileSync("bin/nino-ST1BT.BIN"); - const img = src.subarray(0x4d800); + const src = readFileSync("bin/flutter-ST05T.BIN"); + const img = src.subarray(0x37800); for (let i = 0; i < src.length; i += 0x800) { const tim = {