silphscope 1.2.10 → 1.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/rom-configs/firered.js +4 -1
- package/src/graphics/mons/render-mon-icon.js +7 -8
- package/src/graphics/mons/render-mons.js +1 -3
- package/src/graphics/mons/resolvers/mon-icon-palette-resolver.js +9 -0
- package/src/graphics/mons/resolvers/mon-icon-resolver.js +8 -0
- package/src/rom-reader.js +4 -1
package/package.json
CHANGED
package/rom-configs/firered.js
CHANGED
|
@@ -6,6 +6,9 @@ export const firered = {
|
|
|
6
6
|
monFrontSprites: 0x2350AC,
|
|
7
7
|
monBackSprites: 0x23654C,
|
|
8
8
|
monPalettes: 0x23730C,
|
|
9
|
-
monShinyPalettes: 0x2380CC
|
|
9
|
+
monShinyPalettes: 0x2380CC,
|
|
10
|
+
monIconTable: 0x3D37A0,
|
|
11
|
+
monIconPaletteIndices: 0x3D3E80,
|
|
12
|
+
monIconPaletteTable: 0x3D4038,
|
|
10
13
|
} // if this works out... well hehe... :D
|
|
11
14
|
}
|
|
@@ -5,6 +5,8 @@ import { extract } from "../extract.js";
|
|
|
5
5
|
import { PNG } from "pngjs";
|
|
6
6
|
import fs from "fs";
|
|
7
7
|
import { render4bppImage } from "../render-4bpp-image.js";
|
|
8
|
+
import { resolveMonIcon } from "./resolvers/mon-icon-resolver.js";
|
|
9
|
+
import { resolveMonIconPalette } from "./resolvers/mon-icon-palette-resolver.js";
|
|
8
10
|
|
|
9
11
|
const streamToBuffer = (stream) => new Promise((resolve, reject) => {
|
|
10
12
|
const chunks = [];
|
|
@@ -13,7 +15,7 @@ const streamToBuffer = (stream) => new Promise((resolve, reject) => {
|
|
|
13
15
|
stream.on("error", reject);
|
|
14
16
|
});
|
|
15
17
|
|
|
16
|
-
export async function renderMonIcon(monName, mons,
|
|
18
|
+
export async function renderMonIcon(monName, mons, reader, rom, options = {}) {
|
|
17
19
|
const { outputDir = null } = options;
|
|
18
20
|
|
|
19
21
|
if (!rom || !(rom instanceof Uint8Array || Buffer.isBuffer(rom))) {
|
|
@@ -25,13 +27,12 @@ export async function renderMonIcon(monName, mons, assets, iconPalettes, rom, op
|
|
|
25
27
|
throw new Error(`Missing mon entry for ${monName}`);
|
|
26
28
|
}
|
|
27
29
|
|
|
28
|
-
const iconAsset =
|
|
29
|
-
|
|
30
|
+
const iconAsset = resolveMonIcon(mon, reader);
|
|
31
|
+
const iconPalette = resolveMonIconPalette(mon, reader);
|
|
32
|
+
if (!iconAsset || !iconPalette) throw new Error(`Missing icon asset for ${monName}`);
|
|
30
33
|
|
|
31
34
|
const iconData = extract(iconAsset, rom);
|
|
32
|
-
const
|
|
33
|
-
const palSize = 32;
|
|
34
|
-
const rawIconPalData = extract(iconPalettes, rom);
|
|
35
|
+
const rawIconPalData = extract(iconPalette, rom);
|
|
35
36
|
const width = 32;
|
|
36
37
|
const height = 64;
|
|
37
38
|
|
|
@@ -40,8 +41,6 @@ export async function renderMonIcon(monName, mons, assets, iconPalettes, rom, op
|
|
|
40
41
|
paletteData: rawIconPalData.data,
|
|
41
42
|
width,
|
|
42
43
|
height,
|
|
43
|
-
paletteOffset: palIndex * palSize,
|
|
44
|
-
paletteSize: palSize
|
|
45
44
|
});
|
|
46
45
|
|
|
47
46
|
const frameHeight = 32;
|
|
@@ -31,9 +31,7 @@ export async function renderMon(monName, mons, assets, reader, rom, options = {}
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
if (icon === true) {
|
|
34
|
-
|
|
35
|
-
if (!comboPal) throw new Error("Missing gMonIconPalettes asset");
|
|
36
|
-
await renderMonIcon(monName, mons, assets, comboPal, rom, { outputDir });
|
|
34
|
+
await renderMonIcon(monName, mons, reader, rom, { outputDir });
|
|
37
35
|
}
|
|
38
36
|
if (footprint === true) {
|
|
39
37
|
await renderMonFoot(monName, mons, assets, rom, { outputDir });
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function resolveMonIconPalette(mon, reader) { // I kinda think this might be wrong... but erm who knows :o maybe I got it right first try lol
|
|
2
|
+
const indexTable = reader.getTable("monIconPaletteIndices");
|
|
3
|
+
const paletteIndex = reader.readU8(indexTable + mon.index);
|
|
4
|
+
const paletteTable = reader.getTable("monIconPaletteTable");
|
|
5
|
+
const palettePtr = reader.readPointer(paletteTable + paletteIndex * 4);
|
|
6
|
+
return {
|
|
7
|
+
offset: palettePtr
|
|
8
|
+
};
|
|
9
|
+
}
|
package/src/rom-reader.js
CHANGED
|
@@ -10,7 +10,10 @@ export class RomReader {
|
|
|
10
10
|
(rom[offset + 1] << 8) |
|
|
11
11
|
(rom[offset + 2] << 16) |
|
|
12
12
|
(rom[offset + 3] << 24)
|
|
13
|
-
);
|
|
13
|
+
) >>> 0; // this should also prevent a bug for the numbers becoming negative due to unsigned and signed numbers canoodling :o
|
|
14
|
+
}
|
|
15
|
+
readU8(offset) { // how did I forget this T-T
|
|
16
|
+
return this.rom[offset];
|
|
14
17
|
}
|
|
15
18
|
readPointer(offset) {
|
|
16
19
|
return this.readU32(offset) - 0x08000000;
|