silphscope 1.2.8 → 1.2.10
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/main.js +1 -1
- package/package.json +3 -2
- package/rom-configs/firered.js +11 -0
- package/src/graphics/mons/render-mons.js +4 -10
- package/src/graphics/mons/resolvers/mon-sprite-palette-resolver.js +13 -0
- package/src/graphics/mons/resolvers/mon-sprite-resolver.js +19 -0
- package/src/graphics/mons/resolvers/mon-front-sprite-resolver.js +0 -15
package/main.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { renderMon } from "./src/graphics/mons/render-mons.js";
|
|
2
2
|
import { renderMonIcon } from "./src/graphics/mons/render-mon-icon.js";
|
|
3
3
|
import { renderMonFoot } from "./src/graphics/mons/render-mon-foot.js";
|
|
4
|
-
import { extract } from "./src/graphics/extract.js";
|
|
4
|
+
import { extract } from "./src/graphics/extract.js"; // random message for a commit lol
|
|
5
5
|
|
|
6
6
|
export { renderMon, renderMonIcon, renderMonFoot, extract };
|
|
7
7
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "silphscope",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.10",
|
|
4
4
|
"description": "A firered/leafgreen ROM asset extractor for use in web applications",
|
|
5
5
|
"main": "main.js",
|
|
6
6
|
"exports": {
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
"mon-data/",
|
|
17
17
|
"rom-maps/",
|
|
18
18
|
"item-data/",
|
|
19
|
-
"trainer-data"
|
|
19
|
+
"trainer-data",
|
|
20
|
+
"rom-configs/"
|
|
20
21
|
],
|
|
21
22
|
"keywords": [],
|
|
22
23
|
"author": "chickenPoo",
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// I have an idea but it needs math D:
|
|
2
|
+
|
|
3
|
+
export const firered = {
|
|
4
|
+
code: "BPRE", // I find this weird... like what does BP stand for? is it: "Battle Pokemon"? no idea :o
|
|
5
|
+
tables: { // so the idea is essentially instead of a big JSON like we have now we instead just view the table graphics and build from that... it in theory could be slower because more lookups instead of direct references but it should be more maintainable...
|
|
6
|
+
monFrontSprites: 0x2350AC,
|
|
7
|
+
monBackSprites: 0x23654C,
|
|
8
|
+
monPalettes: 0x23730C,
|
|
9
|
+
monShinyPalettes: 0x2380CC
|
|
10
|
+
} // if this works out... well hehe... :D
|
|
11
|
+
}
|
|
@@ -7,7 +7,8 @@ import { extract } from "../extract.js";
|
|
|
7
7
|
import { renderMonIcon } from "./render-mon-icon.js";
|
|
8
8
|
import { renderMonFoot } from "./render-mon-foot.js";
|
|
9
9
|
import { render4bppImage } from "../render-4bpp-image.js";
|
|
10
|
-
import {
|
|
10
|
+
import { resolveMonSprite } from "./resolvers/mon-sprite-resolver.js";
|
|
11
|
+
import { resolveMonPalette } from "./resolvers/mon-sprite-palette-resolver.js";
|
|
11
12
|
|
|
12
13
|
const streamToBuffer = (stream) => new Promise((resolve, reject) => {
|
|
13
14
|
const chunks = [];
|
|
@@ -43,15 +44,8 @@ export async function renderMon(monName, mons, assets, reader, rom, options = {}
|
|
|
43
44
|
throw new Error(`Missing mon: ${monName}`);
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
monPic = resolveMonFrontSprite(mon, reader); // I wonder if this will work :O
|
|
49
|
-
} else {
|
|
50
|
-
const picName = mon.backPics;
|
|
51
|
-
monPic = assets.find(a => a.name === picName);
|
|
52
|
-
}
|
|
53
|
-
const palType = variant === "shiny" ? mon.shinyPalette : mon.normPalette;
|
|
54
|
-
const monPal = assets.find(a => a.name === palType);
|
|
47
|
+
const monPic = resolveMonSprite(mon, reader, side); // I wonder if this will work :O
|
|
48
|
+
const monPal = resolveMonPalette(mon, reader, variant);
|
|
55
49
|
|
|
56
50
|
if (!monPic || !monPal) {
|
|
57
51
|
throw new Error(`Missing assets for: ${monName}`);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function resolveMonPalette(mon, romReader, variant) {
|
|
2
|
+
const tableName = variant === "shiny"
|
|
3
|
+
? "monShinyPalettes"
|
|
4
|
+
: "monPalettes";
|
|
5
|
+
const table = romReader.getTable(tableName);
|
|
6
|
+
const entryOffset = table + mon.index * 8;
|
|
7
|
+
const ptr = romReader.readPointer(entryOffset);
|
|
8
|
+
return {
|
|
9
|
+
name: `mon_${mon.name}_${variant}_palette`,
|
|
10
|
+
offset: ptr,
|
|
11
|
+
size: 40 // I hope thats right... from what I can tell all front/back pal's are 40 in size...
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// so the idea of "resolvers" is to essentially replace this line in the asset extraction:
|
|
2
|
+
// const monPic = assets.find(a => a.name === picName);
|
|
3
|
+
// of course though thats for the mon stuff specifically however!
|
|
4
|
+
// this time instead of needing a giant lookup table we use this thingy
|
|
5
|
+
// plus our rom-config to just infer all of this from the table in the ROM itself... in theory..
|
|
6
|
+
|
|
7
|
+
export function resolveMonSprite(mon, romReader, side) {
|
|
8
|
+
const tableName = side === "back"
|
|
9
|
+
? "monBackSprites"
|
|
10
|
+
: "monFrontSprites";
|
|
11
|
+
const table = romReader.getTable(tableName);
|
|
12
|
+
const entryOffset = table + mon.index * 8;
|
|
13
|
+
const ptr = romReader.readPointer(entryOffset);
|
|
14
|
+
return {
|
|
15
|
+
name: `mon_${mon.name}_${side}`, // really not needed anymore lol this was just for testing... but erm its ok for now I guess :p
|
|
16
|
+
offset: ptr
|
|
17
|
+
// just realized something... later resolvers will need a size value for assets not in need of lz77 decompressing... luckily these don't but erm... yea.. this could get slightly complicated...
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
// so the idea of "resolvers" is to essentially replace this line in the asset extraction:
|
|
2
|
-
// const monPic = assets.find(a => a.name === picName);
|
|
3
|
-
// of course though thats for the mon stuff specifically however!
|
|
4
|
-
// this time instead of needing a giant lookup table we use this thingy
|
|
5
|
-
// plus our rom-config to just infer all of this from the table in the ROM itself... in theory..
|
|
6
|
-
|
|
7
|
-
export function resolveMonFrontSprite(mon, romReader) {
|
|
8
|
-
const table = romReader.getTable("monFrontSprites");
|
|
9
|
-
const entryOffset = table + mon.index * 8;
|
|
10
|
-
const ptr = romReader.readPointer(entryOffset);
|
|
11
|
-
return {
|
|
12
|
-
name: `mon_${mon.name}_front`,
|
|
13
|
-
offset: ptr
|
|
14
|
-
};
|
|
15
|
-
}
|