From b0212bc6078547d28e23c334c9e16dcf33d69c2b Mon Sep 17 00:00:00 2001 From: yellows111 Date: Thu, 15 Feb 2024 00:14:08 +0000 Subject: [PATCH] 0.8.2: It's a bitmask. I knew writing that as a test would be worth it. --- icon.js | 21 +-- tests/iconwriter.js | 309 +++++++++++++++++++++++++++++++++----------- 2 files changed, 246 insertions(+), 84 deletions(-) diff --git a/icon.js b/icon.js index 29036ed..ab5a577 100644 --- a/icon.js +++ b/icon.js @@ -7,7 +7,7 @@ var ICONJS_STRICT = true; * @constant {string} * @default */ -const ICONJS_VERSION = "0.8.1"; +const ICONJS_VERSION = "0.8.2"; /** * The RC4 key used for ciphering CodeBreaker Saves. @@ -162,15 +162,18 @@ function setStrictness(value) { * @access protected */ function getTextureFormat(i) { - if (i<8) { - if(i==3) { - return 'N'; + if(ICONJS_DEBUG) { + console.debug("Texture format: %i", i); + } + // bit 1: enable smooth shading (TODO) + // bit 2: ??? something weird with colours, check iconwriter.js output... + if(!!(i & 4)) { // if bit 3 (textured)... + if(!!(i & 8)) { // if bit 4 (compressed)... + return "C"; // Compressed. } - return 'U'; - } else if (i>=8) { - return 'C'; - } else { - return void(0); + return "U"; // Uncompressed. + } else { // if bit 3 isn't set... + return "N"; // No texture. } } diff --git a/tests/iconwriter.js b/tests/iconwriter.js index e6501fc..583883f 100644 --- a/tests/iconwriter.js +++ b/tests/iconwriter.js @@ -7,163 +7,163 @@ const iconHeader = new Uint8Array([ // format: [xxyyzzaa][xxyyzzaa][uuvv][rgba], (8 + 8 + 4 + 4) (position.xyzw, normal.xyzw, texcoords.st, colour.rgba) // 0x1000 = 4096 (1.0f), 0xf000 = -4096 (-1.0f) -// color is lime green (0, 255, 0, 127) +// color is lime green (64, 255, 64, 127) const iconData = new Uint8Array([ // 1/36, [-1, -1, -1], [0.25, 0.25] poly 1.1 z-1 0x00, 0xf0, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0x04, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0x04, - 0x00, 0x04, 0x00, 0x04, 0x40, 0xff, 0x00, 0x7f, + 0x00, 0x04, 0x00, 0x04, 0x40, 0xff, 0x40, 0x7f, // 2/36, [-1, 1, -1], [0.25, 0.75] poly 1.2 z-1 0x00, 0xf0, 0x00, 0x10, 0x00, 0xf0, 0x00, 0x04, 0x00, 0xf0, 0x00, 0x10, 0x00, 0xf0, 0x00, 0x04, - 0x00, 0x04, 0x00, 0x0c, 0x40, 0xff, 0x00, 0x7f, + 0x00, 0x04, 0x00, 0x0c, 0x40, 0xff, 0x40, 0x7f, // 3/36, [ 1, -1, -1], [0.75, 0.75] poly 1.3 z-1 0x00, 0x10, 0x00, 0x10, 0x00, 0xf0, 0x00, 0x04, 0x00, 0x10, 0x00, 0x10, 0x00, 0xf0, 0x00, 0x04, - 0x00, 0x0c, 0x00, 0x0c, 0x40, 0xff, 0x00, 0x7f, + 0x00, 0x0c, 0x00, 0x0c, 0x40, 0xff, 0x40, 0x7f, // 4/36, [ 1, 1, -1] poly 2.1 z-1 0x00, 0x10, 0x00, 0x10, 0x00, 0xf0, 0x00, 0x04, 0x00, 0x10, 0x00, 0x10, 0x00, 0xf0, 0x00, 0x04, - 0x00, 0x04, 0x00, 0x0c, 0x40, 0xff, 0x00, 0x7f, + 0x00, 0x04, 0x00, 0x0c, 0x40, 0xff, 0x40, 0x7f, // 5/36, [ 1, -1, -1] poly 2.2 z-1 0x00, 0x10, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0x04, 0x00, 0x10, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0x04, - 0x00, 0x04, 0x00, 0x04, 0x40, 0xff, 0x00, 0x7f, + 0x00, 0x04, 0x00, 0x04, 0x40, 0xff, 0x40, 0x7f, // 6/36, [-1, 1, -1] poly 2.3 z-1 0x00, 0xf0, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0x04, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0x04, - 0x00, 0x0c, 0x00, 0x0c, 0x40, 0xff, 0x00, 0x7f, + 0x00, 0x0c, 0x00, 0x0c, 0x40, 0xff, 0x40, 0x7f, // 7/36, [-1, -1, -1] poly 3.1 x-1 0x00, 0xf0, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0x04, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0x04, - 0x00, 0x04, 0x00, 0x04, 0x40, 0xff, 0x00, 0x7f, + 0x00, 0x04, 0x00, 0x04, 0x40, 0xff, 0x40, 0x7f, // 8/36, [-1, -1, 1] poly 3.2 x-1 0x00, 0xf0, 0x00, 0x10, 0x00, 0x10, 0x00, 0x04, 0x00, 0xf0, 0x00, 0x10, 0x00, 0x10, 0x00, 0x04, - 0x00, 0x0c, 0x00, 0x0c, 0x40, 0xff, 0x00, 0x7f, + 0x00, 0x0c, 0x00, 0x0c, 0x40, 0xff, 0x40, 0x7f, // 9/36, [-1, 1, -1] poly 3.3 x-1 0x00, 0xf0, 0x00, 0x10, 0x00, 0xf0, 0x00, 0x04, 0x00, 0xf0, 0x00, 0x10, 0x00, 0xf0, 0x00, 0x04, - 0x00, 0x04, 0x00, 0x0c, 0x40, 0xff, 0x00, 0x7f, + 0x00, 0x04, 0x00, 0x0c, 0x40, 0xff, 0x40, 0x7f, //10/36, [-1, -1, -1] poly 4.1 x-1 0x00, 0xf0, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0x04, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0x04, - 0x00, 0x04, 0x00, 0x04, 0x40, 0xff, 0x00, 0x7f, + 0x00, 0x04, 0x00, 0x04, 0x40, 0xff, 0x40, 0x7f, //11/36, [-1, -1, 1] poly 4.2 x-1 0x00, 0xf0, 0x00, 0xf0, 0x00, 0x10, 0x00, 0x04, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0x10, 0x00, 0x04, - 0x00, 0x04, 0x00, 0x0c, 0x40, 0xff, 0x00, 0x7f, + 0x00, 0x04, 0x00, 0x0c, 0x40, 0xff, 0x40, 0x7f, //12/36, [-1, 1, 1] poly 4.3 x-1 0x00, 0xf0, 0x00, 0x10, 0x00, 0x10, 0x00, 0x04, 0x00, 0xf0, 0x00, 0x10, 0x00, 0x10, 0x00, 0x04, - 0x00, 0x0c, 0x00, 0x0c, 0x40, 0xff, 0x00, 0x7f, + 0x00, 0x0c, 0x00, 0x0c, 0x40, 0xff, 0x40, 0x7f, //13/36, [-1, 1, -1] poly 5.1 y+1 0x00, 0xf0, 0x00, 0x10, 0x00, 0xf0, 0x00, 0x04, 0x00, 0xf0, 0x00, 0x10, 0x00, 0xf0, 0x00, 0x04, - 0x00, 0x04, 0x00, 0x04, 0x40, 0xff, 0x00, 0x7f, + 0x00, 0x04, 0x00, 0x04, 0x40, 0xff, 0x40, 0x7f, //14/36, [-1, 1, 1] poly 5.2 y+1 0x00, 0xf0, 0x00, 0x10, 0x00, 0x10, 0x00, 0x04, 0x00, 0xf0, 0x00, 0x10, 0x00, 0x10, 0x00, 0x04, - 0x00, 0x04, 0x00, 0x0c, 0x40, 0xff, 0x00, 0x7f, + 0x00, 0x04, 0x00, 0x0c, 0x40, 0xff, 0x40, 0x7f, //15/36, [ 1, 1, -1] poly 5.3 y+1 0x00, 0x10, 0x00, 0x10, 0x00, 0xf0, 0x00, 0x04, 0x00, 0x10, 0x00, 0x10, 0x00, 0xf0, 0x00, 0x04, - 0x00, 0x0c, 0x00, 0x0c, 0x40, 0xff, 0x00, 0x7f, + 0x00, 0x0c, 0x00, 0x0c, 0x40, 0xff, 0x40, 0x7f, //16/36, [ 1, 1, -1] poly 6.1 y+1 0x00, 0x10, 0x00, 0x10, 0x00, 0xf0, 0x00, 0x04, 0x00, 0x10, 0x00, 0x10, 0x00, 0xf0, 0x00, 0x04, - 0x00, 0x04, 0x00, 0x04, 0x40, 0xff, 0x00, 0x7f, + 0x00, 0x04, 0x00, 0x04, 0x40, 0xff, 0x40, 0x7f, //17/36, [-1, 1, 1] poly 6.2 y+1 0x00, 0xf0, 0x00, 0x10, 0x00, 0x10, 0x00, 0x04, 0x00, 0xf0, 0x00, 0x10, 0x00, 0x10, 0x00, 0x04, - 0x00, 0x04, 0x00, 0x0c, 0x40, 0xff, 0x00, 0x7f, + 0x00, 0x04, 0x00, 0x0c, 0x40, 0xff, 0x40, 0x7f, //18/36, [ 1, 1, 1] poly 6.3 y+1 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x04, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x04, - 0x00, 0x0c, 0x00, 0x0c, 0x40, 0xff, 0x00, 0x7f, + 0x00, 0x0c, 0x00, 0x0c, 0x40, 0xff, 0x40, 0x7f, //19/36, [ 1, 1, -1] poly 7.1 x+1 0x00, 0x10, 0x00, 0x10, 0x00, 0xf0, 0x00, 0x04, 0x00, 0x10, 0x00, 0x10, 0x00, 0xf0, 0x00, 0x04, - 0x00, 0x04, 0x00, 0x04, 0x40, 0xff, 0x00, 0x7f, + 0x00, 0x04, 0x00, 0x04, 0x40, 0xff, 0x40, 0x7f, //20/36, [ 1, 1, 1] poly 7.2 x+1 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x04, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x04, - 0x00, 0x04, 0x00, 0x0c, 0x40, 0xff, 0x00, 0x7f, + 0x00, 0x04, 0x00, 0x0c, 0x40, 0xff, 0x40, 0x7f, //21/36, [ 1, -1, -1] poly 7.3 x+1 0x00, 0x10, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0x04, 0x00, 0x10, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0x04, - 0x00, 0x0c, 0x00, 0x0c, 0x40, 0xff, 0x00, 0x7f, + 0x00, 0x0c, 0x00, 0x0c, 0x40, 0xff, 0x40, 0x7f, //22/36, [ 1, 1, 1] poly 8.1 x+1 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x04, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x04, - 0x00, 0x04, 0x00, 0x04, 0x40, 0xff, 0x00, 0x7f, + 0x00, 0x04, 0x00, 0x04, 0x40, 0xff, 0x40, 0x7f, //23/36, [ 1, -1, 1] poly 8.2 x+1 0x00, 0x10, 0x00, 0xf0, 0x00, 0x10, 0x00, 0x04, 0x00, 0x10, 0x00, 0xf0, 0x00, 0x10, 0x00, 0x04, - 0x00, 0x04, 0x00, 0x0c, 0x40, 0xff, 0x00, 0x7f, + 0x00, 0x04, 0x00, 0x0c, 0x40, 0xff, 0x40, 0x7f, //24/36, [ 1, -1, -1] poly 8.3 x+1 0x00, 0x10, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0x04, 0x00, 0x10, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0x04, - 0x00, 0x0c, 0x00, 0x0c, 0x40, 0xff, 0x00, 0x7f, + 0x00, 0x0c, 0x00, 0x0c, 0x40, 0xff, 0x40, 0x7f, //25/36, [-1, -1, -1] poly 9.1 y-1 0x00, 0xf0, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0x04, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0x04, - 0x00, 0x04, 0x00, 0x04, 0x40, 0xff, 0x00, 0x7f, + 0x00, 0x04, 0x00, 0x04, 0x40, 0xff, 0x40, 0x7f, //26/36, [ 1, -1, -1] poly 9.2 y-1 0x00, 0x10, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0x04, 0x00, 0x10, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0x04, - 0x00, 0x04, 0x00, 0x0c, 0x40, 0xff, 0x00, 0x7f, + 0x00, 0x04, 0x00, 0x0c, 0x40, 0xff, 0x40, 0x7f, //27/36, [-1, -1, 1] poly 9.3 y-1 0x00, 0xf0, 0x00, 0xf0, 0x00, 0x10, 0x00, 0x04, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0x10, 0x00, 0x04, - 0x00, 0x0c, 0x00, 0x0c, 0x40, 0xff, 0x00, 0x7f, + 0x00, 0x0c, 0x00, 0x0c, 0x40, 0xff, 0x40, 0x7f, //28/36, [-1, -1, 1] poly 10.1 y-1 0x00, 0xf0, 0x00, 0xf0, 0x00, 0x10, 0x00, 0x04, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0x10, 0x00, 0x04, - 0x00, 0x04, 0x00, 0x04, 0x40, 0xff, 0x00, 0x7f, + 0x00, 0x04, 0x00, 0x04, 0x40, 0xff, 0x40, 0x7f, //29/36, [ 1, -1, -1] poly 10.2 y-1 0x00, 0x10, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0x04, 0x00, 0x10, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0x04, - 0x00, 0x04, 0x00, 0x0c, 0x40, 0xff, 0x00, 0x7f, + 0x00, 0x04, 0x00, 0x0c, 0x40, 0xff, 0x40, 0x7f, //30/36, [ 1, -1, 1] poly 10.3 y-1 0x00, 0x10, 0x00, 0xf0, 0x00, 0x10, 0x00, 0x04, 0x00, 0x10, 0x00, 0xf0, 0x00, 0x10, 0x00, 0x04, - 0x00, 0x0c, 0x00, 0x0c, 0x40, 0xff, 0x00, 0x7f, + 0x00, 0x0c, 0x00, 0x0c, 0x40, 0xff, 0x40, 0x7f, //31/36, [-1, 1, 1] poly 11.1 z+1 0x00, 0xf0, 0x00, 0x10, 0x00, 0x10, 0x00, 0x04, 0x00, 0xf0, 0x00, 0x10, 0x00, 0x10, 0x00, 0x04, - 0x00, 0x04, 0x00, 0x04, 0x40, 0xff, 0x00, 0x7f, + 0x00, 0x04, 0x00, 0x04, 0x40, 0xff, 0x40, 0x7f, //32/36, [-1, -1, 1] poly 11.2 z+1 0x00, 0xf0, 0x00, 0xf0, 0x00, 0x10, 0x00, 0x04, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0x10, 0x00, 0x04, - 0x00, 0x04, 0x00, 0x0c, 0x40, 0xff, 0x00, 0x7f, + 0x00, 0x04, 0x00, 0x0c, 0x40, 0xff, 0x40, 0x7f, //33/36, [ 1, 1, 1] poly 11.3 z+1 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x04, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x04, - 0x00, 0x0c, 0x00, 0x0c, 0x40, 0xff, 0x00, 0x7f, + 0x00, 0x0c, 0x00, 0x0c, 0x40, 0xff, 0x40, 0x7f, //35/36, [ 1, -1, 1] poly 12.2 z+1 0x00, 0x10, 0x00, 0xf0, 0x00, 0x10, 0x00, 0x04, 0x00, 0x10, 0x00, 0xf0, 0x00, 0x10, 0x00, 0x04, - 0x00, 0x04, 0x00, 0x0c, 0x40, 0xff, 0x00, 0x7f, + 0x00, 0x04, 0x00, 0x0c, 0x40, 0xff, 0x40, 0x7f, //34/36, [ 1, 1, 1] poly 12.1 z+1 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x04, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x04, - 0x00, 0x04, 0x00, 0x04, 0x40, 0xff, 0x00, 0x7f, + 0x00, 0x04, 0x00, 0x04, 0x40, 0xff, 0x40, 0x7f, //36/36, [-1, -1, 1] poly 12.3 z+1 0x00, 0xf0, 0x00, 0xf0, 0x00, 0x10, 0x00, 0x04, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0x10, 0x00, 0x04, - 0x00, 0x0c, 0x00, 0x0c, 0x40, 0xff, 0x00, 0x7f, + 0x00, 0x0c, 0x00, 0x0c, 0x40, 0xff, 0x40, 0x7f, ]); // 864 bytes const animData = new Uint8Array([ @@ -177,49 +177,208 @@ const animData = new Uint8Array([ /** generate texture data **/ const texture_ = new Uint16Array(16384); for (let indice = 0; indice < 16384; indice++) { - //texture_[indice] = 0b11111_00000_00000_1; //RGB5A1 texture_[indice] = 0b1_00000_00000_11111; //A1BGR5 - //texture_[indice] = 0b00000_00000_11111_0; // BGR5A1 - //texture_[indice] = 0xffff; // does this even texture vro } // 32768 bytes +/** for compressed textures **/ +const compressTexture_ = new Uint16Array(4); +compressTexture_[0] = 0x0004; +compressTexture_[1] = 0x0000; +compressTexture_[2] = 0x4000; +compressTexture_[3] = 0b1_11111_00000_00000; const textureData = new Uint8Array(texture_.buffer); +const compressedTextureData = new Uint8Array(compressTexture_.buffer); -const IconFileArray = new Array(8); - -/** make icons **/ -for (let iconIndice = 0; iconIndice < 8; iconIndice++) { - // actual test goes here! - // combine data together (header+data+animData+texture) - const combined = new Uint8Array(20+864+36+32768); - combined.set(iconHeader, 0); - combined.set(iconData, 20); - combined.set(animData, 20+864); - combined.set(textureData, 20+864+36); - - combined[8] = iconIndice; // set texture type - - IconFileArray[iconIndice] = combined; - if(typeof require !== "undefined") { - require("fs").writeFileSync(`${iconIndice}_generated.icn`, combined); - } -} - - -/** make ps2d's **/ +/** ps2d data **/ const metadataSkeleton = new Uint8Array(Array.from({...[ - 0x50, 0x53, 0x32, 0x44, 0x00, 0x00, 0x00, 0x00, // todo: don't sleep on this, it's the byte where we split the title -], length:964})); + 0x50, 0x53, 0x32, 0x44, 0x00, 0x00, + 0x20, 0x00, 0x00, 0x00, // PS2D files have a max limit of 16 characters per line + 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, + // color1.rgba + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + // color2.rgba + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + // color3.rgba + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + // color4.rgba + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + // pos1.xyzw + 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, + 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, + // pos2.xyzw + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbf, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + // pos3.xyzw + 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, + 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x00, + // light1.rgba + 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0x3f, + 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x00, + // light2.rgba + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + // light3.rgba + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + // amblight.rgba + 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0x3f, + 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x00, + // title + 0x82, 0x89, 0x82, 0x83, 0x82, 0x8f, 0x82, 0x8e, // icon + 0x82, 0x84, 0x82, 0x95, 0x82, 0x8d, 0x82, 0x90, // dump + 0x82, 0x85, 0x82, 0x92, 0x82, 0x51, 0x81, 0x40, // er2 + 0x82, 0x73, 0x82, 0x85, 0x82, 0x93, 0x82, 0x94, // Test + 0x82, 0x73, 0x82, 0x85, 0x82, 0x98, 0x82, 0x94, // Text + 0x82, 0x95, 0x82, 0x92, 0x82, 0x85, 0x81, 0x40, // ure + 0x82, 0x73, 0x82, 0x99, 0x82, 0x90, 0x82, 0x85, // Type + 0x81, 0x40, 0x82, 0x58, // 9 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + // file - normal + 0x74, 0x65, 0x78, 0x74, 0x79, 0x70, 0x65, 0x31, + 0x2E, 0x69, 0x63, 0x6E, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + // file - copying + 0x74, 0x65, 0x78, 0x74, 0x79, 0x70, 0x65, 0x31, + 0x2E, 0x69, 0x63, 0x6E, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + // file - deleting + 0x74, 0x65, 0x78, 0x74, 0x79, 0x70, 0x65, 0x31, + 0x2E, 0x69, 0x63, 0x6E, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +//], length:964})); +], length:1024})); // psu want block size -/** - 0x82, 0x89, 0x82, 0x83, 0x82, 0x8f, 0x82, 0x8e, // icon - 0x82, 0x84, 0x82, 0x95, 0x82, 0x8d, 0x82, 0x90, // dump - 0x82, 0x85, 0x82, 0x92, 0x82, 0x51, 0x81, 0x40, // er2 - 0x82, 0x73, 0x82, 0x85, 0x82, 0x93, 0x82, 0x94, // Test - 0x81, 0x46, 0x82, 0x73, 0x82, 0x85, 0x82, 0x98, // :Tex - 0x82, 0x94, 0x82, 0x95, 0x82, 0x92, 0x82, 0x85, // ture - 0x81, 0x40, 0x82, 0x73, 0x82, 0x99, 0x82, 0x90, // Typ - 0x82, 0x85, 0x81, 0x40, 0x82, 0x58, 0x00, 0x00, // e 9 -**/ +const CombinedIconData = new Uint8Array(33792/*20+864+36+32768*/); // psu still want block size +CombinedIconData.set(iconHeader, 0); +CombinedIconData.set(iconData, 20); +CombinedIconData.set(animData, 20+864); +CombinedIconData.set(textureData, 20+864+36); -//automatic psu generator? \ No newline at end of file +const CombinedCompressedIconData = new Uint8Array(1024/*20+864+36+16*/); // psu still want block size +CombinedCompressedIconData.set(iconHeader, 0); +CombinedCompressedIconData.set(iconData, 20); +CombinedCompressedIconData.set(animData, 20+864); +CombinedCompressedIconData.set(compressedTextureData, 20+864+36); + +/** root directory **/ +const psuHeader1 = new Uint8Array(Array.from({...[ + 0x27, 0x84, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x00, 0x16, 0x25, 0x12, 0x02, 0x05, 0xd2, 0x07, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x16, 0x16, 0x16, 0x16, 0x16, 0xd2, 0x16, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x69, 0x64, 0x32, 0x5f, 0x74, 0x65, 0x78, 0x74, + 0x65, 0x73, 0x74, 0x39 +], length:512})); + +/** . **/ +const psuHeader2 = new Uint8Array(Array.from({...[ + 0x27, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x16, 0x25, 0x12, 0x02, 0x05, 0xd2, 0x07, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x16, 0x16, 0x16, 0x16, 0x16, 0xd2, 0x16, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x2e +], length:512})); + +/** .. **/ +const psuHeader3 = new Uint8Array(Array.from({...[ + 0x27, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x16, 0x25, 0x12, 0x02, 0x05, 0xd2, 0x07, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x16, 0x16, 0x16, 0x16, 0x16, 0xd2, 0x16, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x2e, 0x2e +], length:512})); + +/** icon.sys **/ +const psuHeader4 = new Uint8Array(Array.from({...[ + 0x17, 0x84, 0x00, 0x00, 0xc4, 0x03, 0x00, 0x00, + 0x00, 0x16, 0x25, 0x12, 0x02, 0x05, 0xd2, 0x07, + 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x16, 0x16, 0x16, 0x16, 0x16, 0xd2, 0x16, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x69, 0x63, 0x6f, 0x6e, 0x2e, 0x73, 0x79, 0x73 +], length:512})); + +/** textypeX.icn **/ +const psuHeader5 = new Uint8Array(Array.from({...[ + 0x17, 0x84, 0x00, 0x00, 0x98, 0x83, 0x00, 0x00, + 0x00, 0x16, 0x25, 0x12, 0x02, 0x05, 0xd2, 0x07, + 0x0a, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x16, 0x16, 0x16, 0x16, 0x16, 0xd2, 0x16, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x74, 0x65, 0x78, 0x74, 0x79, 0x70, 0x65, 0x39, + 0x2E, 0x69, 0x63, 0x6E +], length:512})); + +/** write psus **/ +for (let iconIndice = 0; iconIndice < 16; iconIndice++) { + let needsAlpha = 0; + let needsCompression = false; + if(iconIndice > 9) { + needsAlpha = 7; // if we're past 9, offset to start at A instead + } + if(iconIndice > 8) { + needsCompression = true; + } + const PsuFileOutput = new Uint8Array(needsCompression ? 5120 : 37888); // 6 compressed, 37 uncompressed blocks + if(needsCompression) { + psuHeader5[4] = 0xa8; + psuHeader5[5] = 0x03; + } + CombinedIconData[8] = iconIndice; // set texture type for uncompressed + CombinedCompressedIconData[8] = iconIndice; // set texture type for compressed + psuHeader1[75] = 0x30 + iconIndice+needsAlpha; // set folder name + psuHeader5[71] = 0x30 + iconIndice+needsAlpha; // set file name + metadataSkeleton[251] = 0x4f + iconIndice+needsAlpha; // set display name + metadataSkeleton[267] = 0x30 + iconIndice+needsAlpha; // set normal file name + metadataSkeleton[331] = 0x30 + iconIndice+needsAlpha; // set copy file name + metadataSkeleton[395] = 0x30 + iconIndice+needsAlpha; // set deleting file name + + PsuFileOutput.set(psuHeader1,0); + PsuFileOutput.set(psuHeader2,512); + PsuFileOutput.set(psuHeader3,1024); + PsuFileOutput.set(psuHeader4,1536); + PsuFileOutput.set(metadataSkeleton,2048); + PsuFileOutput.set(psuHeader5,3072); + PsuFileOutput.set(needsCompression ? CombinedCompressedIconData : CombinedIconData, 3584); + // and then 512 bytes of padding since we don't reach a block yet + if(typeof require !== "undefined") { + require("fs").writeFileSync(`${iconIndice.toString(16)}_file.psu`, PsuFileOutput); + } +} \ No newline at end of file