silphscope 1.2.19 → 1.2.21
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/item-data/itemData.json +376 -0
- package/package.json +1 -1
- package/rom-configs/firered.js +5 -0
- package/src/graphics/graphics-extractor-main.js +8 -6
- package/src/graphics/icons/render-icons.js +4 -3
- package/src/graphics/icons/resolvers/item-icons-resolver.js +22 -0
- package/src/graphics/mons/render-mons.js +2 -2
- package/src/icon-data-parser.js +5 -0
- package/src/trainer-data-parser.js +5 -0
- package/trainer-data/trainerData.json +613 -613
package/package.json
CHANGED
package/rom-configs/firered.js
CHANGED
|
@@ -11,5 +11,10 @@ export const firered = {
|
|
|
11
11
|
monIconPaletteIndices: 0x3D3E80,
|
|
12
12
|
monIconPaletteTable: 0x3D4038,
|
|
13
13
|
monFootprintTable: 0x43FAB0,
|
|
14
|
+
trainerFrontPicTable: 0x23957C,
|
|
15
|
+
trainerFrontPicPaletteTable: 0x239a1C,
|
|
16
|
+
trainerBackPicTable: 0x239FA4,
|
|
17
|
+
trainerBackPicPaletteTable: 0x239FD4,
|
|
18
|
+
itemIconTable: 0x09899C, // so this was very hard to find since it isn't labeled in the .map of ROMs... luckily Ghidra and the ROM decomps exist so that helped a ton... issue is I believe this contains both the palette and gfx in each listing (should probably double check pokefirered to confirm...) so it will be interesting to extract assets I suppose...
|
|
14
19
|
} // if this works out... well hehe... :D
|
|
15
20
|
}
|
|
@@ -28,7 +28,6 @@ export async function renderAllMons(rom, options = {}) {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
const {
|
|
31
|
-
assets: providedAssets = assets,
|
|
32
31
|
mons: providedMons = mons,
|
|
33
32
|
outputDir = "./out",
|
|
34
33
|
icon = true,
|
|
@@ -41,28 +40,28 @@ export async function renderAllMons(rom, options = {}) {
|
|
|
41
40
|
const reader = new RomReader(rom, config);
|
|
42
41
|
|
|
43
42
|
for (const monName of Object.keys(providedMons)) {
|
|
44
|
-
await renderMon(monName, providedMons,
|
|
43
|
+
await renderMon(monName, providedMons, reader, rom, {
|
|
45
44
|
side: "front",
|
|
46
45
|
variant: "normal",
|
|
47
46
|
icon,
|
|
48
47
|
footprint,
|
|
49
48
|
outputDir,
|
|
50
49
|
});
|
|
51
|
-
await renderMon(monName, providedMons,
|
|
50
|
+
await renderMon(monName, providedMons, reader, rom, {
|
|
52
51
|
side: "front",
|
|
53
52
|
variant: "shiny",
|
|
54
53
|
icon: false,
|
|
55
54
|
footprint: false,
|
|
56
55
|
outputDir,
|
|
57
56
|
});
|
|
58
|
-
await renderMon(monName, providedMons,
|
|
57
|
+
await renderMon(monName, providedMons, reader, rom, {
|
|
59
58
|
side: "back",
|
|
60
59
|
variant: "normal",
|
|
61
60
|
icon: false,
|
|
62
61
|
footprint: false,
|
|
63
62
|
outputDir,
|
|
64
63
|
});
|
|
65
|
-
await renderMon(monName, providedMons,
|
|
64
|
+
await renderMon(monName, providedMons, reader, rom, {
|
|
66
65
|
side: "back",
|
|
67
66
|
variant: "shiny",
|
|
68
67
|
icon: false,
|
|
@@ -86,8 +85,11 @@ export async function renderAllIcons(rom, options = {}) {
|
|
|
86
85
|
|
|
87
86
|
fs.mkdirSync(outputDir, { recursive: true });
|
|
88
87
|
|
|
88
|
+
const config = getRomConfig(rom);
|
|
89
|
+
const reader = new RomReader(rom, config);
|
|
90
|
+
|
|
89
91
|
for (const itemName of Object.keys(providedIcons)) {
|
|
90
|
-
await renderIcon(itemName, providedIcons, providedAssets, rom, { outputDir });
|
|
92
|
+
await renderIcon(itemName, providedIcons, providedAssets, reader, rom, { outputDir });
|
|
91
93
|
console.log(`Done: ${itemName}`);
|
|
92
94
|
}
|
|
93
95
|
}
|
|
@@ -5,6 +5,7 @@ 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 { resolveItemIconObject } from "./resolvers/item-icons-resolver.js";
|
|
8
9
|
|
|
9
10
|
const streamToBuffer = (stream) => new Promise((resolve, reject) => {
|
|
10
11
|
const chunks = [];
|
|
@@ -13,7 +14,7 @@ const streamToBuffer = (stream) => new Promise((resolve, reject) => {
|
|
|
13
14
|
stream.on("error", reject);
|
|
14
15
|
});
|
|
15
16
|
|
|
16
|
-
export async function renderIcon(itemName, items, assets, rom, options = {}) {
|
|
17
|
+
export async function renderIcon(itemName, items, assets, reader, rom, options = {}) {
|
|
17
18
|
const { outputDir = null } = options;
|
|
18
19
|
|
|
19
20
|
if (!rom || !(rom instanceof Uint8Array || Buffer.isBuffer(rom))) {
|
|
@@ -25,8 +26,8 @@ export async function renderIcon(itemName, items, assets, rom, options = {}) {
|
|
|
25
26
|
throw new Error(`Missing Item: ${itemName}`);
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
const iconPal =
|
|
29
|
-
const iconPic =
|
|
29
|
+
const iconPal = resolveItemIconObject(item, reader, "gfx");
|
|
30
|
+
const iconPic = resolveItemIconObject(item, reader, "pal");
|
|
30
31
|
if (!iconPal || !iconPic) {
|
|
31
32
|
throw new Error(`Missing assets for: ${itemName}`);
|
|
32
33
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export function resolveItemIconObject(item, reader, gfxOrPal) {
|
|
2
|
+
const table = reader.getTable("itemIconTable");
|
|
3
|
+
const entrySize = 8; // why did I make this variable... hmmm... I really can't remember... eh it doesn't do any harm other than being kinda useless since we could just pass 8 as is...
|
|
4
|
+
const entryOffset = table + item.index * entrySize;
|
|
5
|
+
const iconPtr = reader.readPointer(entryOffset);
|
|
6
|
+
const palettePtr = reader.readPointer(entryOffset + 4);
|
|
7
|
+
let finalPtr;
|
|
8
|
+
if (gfxOrPal === "gfx") {
|
|
9
|
+
finalPtr = iconPtr;
|
|
10
|
+
return {
|
|
11
|
+
name: `item_${item.name}_${gfxOrPal}`,
|
|
12
|
+
offset: finalPtr,
|
|
13
|
+
}
|
|
14
|
+
} else if (gfxOrPal === "pal") {
|
|
15
|
+
finalPtr = palettePtr;
|
|
16
|
+
return {
|
|
17
|
+
name: `item_${item.name}_${gfxOrPal}`,
|
|
18
|
+
offset: finalPtr,
|
|
19
|
+
size: 40, // this might be extremely dumb... or! It might just work... idk lol (I mean its worked so far so...)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -17,7 +17,7 @@ const streamToBuffer = (stream) => new Promise((resolve, reject) => {
|
|
|
17
17
|
stream.on("error", reject);
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
-
export async function renderMon(monName, mons,
|
|
20
|
+
export async function renderMon(monName, mons, reader, rom, options = {}) {
|
|
21
21
|
const {
|
|
22
22
|
side = "front",
|
|
23
23
|
variant = "normal",
|
|
@@ -34,7 +34,7 @@ export async function renderMon(monName, mons, assets, reader, rom, options = {}
|
|
|
34
34
|
await renderMonIcon(monName, mons, reader, rom, { outputDir });
|
|
35
35
|
}
|
|
36
36
|
if (footprint === true) {
|
|
37
|
-
await renderMonFoot(monName, mons,
|
|
37
|
+
await renderMonFoot(monName, mons, reader, rom, { outputDir });
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
const mon = mons[monName];
|
package/src/icon-data-parser.js
CHANGED
|
@@ -5,6 +5,7 @@ const itemIconDataMap = path.resolve("../item_graphics/item_icon_table.h");
|
|
|
5
5
|
const iconDataLines = fs.readFileSync(itemIconDataMap, "utf-8").split("\n");
|
|
6
6
|
|
|
7
7
|
const itemData = {};
|
|
8
|
+
let itemIndex = 0;
|
|
8
9
|
|
|
9
10
|
for (let i = 0; i < iconDataLines.length; i++) {
|
|
10
11
|
const match = iconDataLines[i].match(/\[(ITEMS?_[A-Z0-9_]+)\]\s*=\s*\{\s*([^,]+),\s*([^}]+)\}/);
|
|
@@ -17,6 +18,10 @@ for (let i = 0; i < iconDataLines.length; i++) {
|
|
|
17
18
|
if (!itemData[itemName]) {
|
|
18
19
|
itemData[itemName] = {};
|
|
19
20
|
}
|
|
21
|
+
if (!itemData[itemName]["index"]) {
|
|
22
|
+
itemData[itemName]["index"] = itemIndex;
|
|
23
|
+
itemIndex++;
|
|
24
|
+
}
|
|
20
25
|
itemData[itemName]["icon"] = icon;
|
|
21
26
|
itemData[itemName]["palette"] = palette;
|
|
22
27
|
}
|
|
@@ -5,6 +5,7 @@ const trainerFrontPicMap = path.resolve("../trainer_graphics/front_pic_tables.h"
|
|
|
5
5
|
const frontPicLines = fs.readFileSync(trainerFrontPicMap, "utf-8").split("\n");
|
|
6
6
|
|
|
7
7
|
const trainerData = {};
|
|
8
|
+
let trainerIndex = 0;
|
|
8
9
|
|
|
9
10
|
for (let i = 0; i < frontPicLines.length; i++) {
|
|
10
11
|
const match = frontPicLines[i].match(/TRAINER_(SPRITE|PAL)\(\s*([A-Z0-9_]+)\s*,\s*(gTrainer(?:FrontPic|Palette)_[A-Za-z0-9_]+)/);
|
|
@@ -18,6 +19,10 @@ for (let i = 0; i < frontPicLines.length; i++) {
|
|
|
18
19
|
} else {
|
|
19
20
|
trainerData[trainerName]["Palette"] = match[3];
|
|
20
21
|
}
|
|
22
|
+
if (!trainerData[trainerName]["index"]) {
|
|
23
|
+
trainerData[trainerName]["index"] = trainerIndex;
|
|
24
|
+
trainerIndex++;
|
|
25
|
+
}
|
|
21
26
|
}
|
|
22
27
|
}
|
|
23
28
|
|