silphscope 1.2.17 → 1.2.19

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "silphscope",
3
- "version": "1.2.17",
3
+ "version": "1.2.19",
4
4
  "description": "A firered/leafgreen ROM asset extractor for use in web applications",
5
5
  "main": "main.js",
6
6
  "exports": {
@@ -10,5 +10,6 @@ export const firered = {
10
10
  monIconTable: 0x3D37A0,
11
11
  monIconPaletteIndices: 0x3D3E80,
12
12
  monIconPaletteTable: 0x3D4038,
13
+ monFootprintTable: 0x43FAB0,
13
14
  } // if this works out... well hehe... :D
14
15
  }
@@ -18,7 +18,9 @@ export function extract(asset, rom) {
18
18
  console.warn(`lz77 failed for ${asset.name}... treating as raw :p`);
19
19
  }
20
20
  }
21
-
21
+ if (!asset.size) {
22
+ throw new Error(`Attempted to read ${asset.name} however it is missing a size attribute`);
23
+ }
22
24
  const slice = rom.slice(start, start + asset.size);
23
25
  return { ...asset, data: slice, compressed: false };
24
26
  }
@@ -5,6 +5,7 @@ import { PNG } from "pngjs";
5
5
  import { extract } from "../extract.js";
6
6
  import { decode1bppTile } from "../decode-1bpp.js";
7
7
  import fs from "fs";
8
+ import { resolveMonFootprint } from "./resolvers/mon-footprint-sprite-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 renderMonFoot(monName, mons, assets, rom, options = {}) {
17
+ export async function renderMonFoot(monName, mons, reader, rom, options = {}) {
17
18
  const { outputDir = null } = options;
18
19
 
19
20
  if (!rom || !(rom instanceof Uint8Array || Buffer.isBuffer(rom))) {
@@ -25,9 +26,9 @@ export async function renderMonFoot(monName, mons, assets, rom, options = {}) {
25
26
  throw new Error(`Missing mon entry for ${monName}`);
26
27
  }
27
28
 
28
- if (!mon.footprintPics && monName.includes("UNOWN")) return;
29
+ if (monName.includes("UNOWN")) return;
29
30
 
30
- const footAsset = assets.find(a => a.name === mon.footprintPics);
31
+ const footAsset = resolveMonFootprint(mon, reader); // possibly the easiest change ive had to do if it works first try :o
31
32
  if (!footAsset) {
32
33
  throw new Error(`Missing foot asset for ${monName}`);
33
34
  }
@@ -0,0 +1,10 @@
1
+ export function resolveMonFootprint(mon, reader) {
2
+ const table = reader.getTable("monFootprintTable");
3
+ const entryOffset = table + mon.index * 4;
4
+ const ptr = reader.readPointer(entryOffset);
5
+ return {
6
+ name: `mon_${mon.name}_footprint`,
7
+ offset: ptr,
8
+ size: 32,
9
+ };
10
+ }
@@ -5,6 +5,7 @@ export function resolveMonIconPalette(mon, reader) { // I kinda think this might
5
5
  const entryOffset = paletteTable + paletteIndex * 8;
6
6
  const palettePtr = reader.readPointer(entryOffset);
7
7
  return {
8
+ name: `mon_${mon.name}_icon_palette`,
8
9
  offset: palettePtr,
9
10
  size: 32,
10
11
  };
@@ -1,8 +1,9 @@
1
1
  export function resolveMonIcon(mon, reader) {
2
2
  const table = reader.getTable("monIconTable");
3
- const entryOffset = table + mon.index * 8;
3
+ const entryOffset = table + mon.index * 4;
4
4
  const ptr = reader.readPointer(entryOffset);
5
5
  return {
6
+ name: `mon_${mon.name}_icon`,
6
7
  offset: ptr,
7
8
  size: 1024 // idk anymore :o
8
9
  };