silphscope 1.4.3 → 1.4.4
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 +3 -2
- package/rom-configs/fireredRev0.js +2 -0
- package/src/graphics/graphics-extractor-main.js +12 -0
- package/src/graphics/mons/render-mon-foot.js +2 -2
- package/src/graphics/mons/render-mon-icon.js +3 -3
- package/src/graphics/mons/render-mons.js +4 -2
- package/src/map-limit.js +25 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "silphscope",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.4",
|
|
4
4
|
"description": "A firered/leafgreen ROM asset extractor for use in web applications",
|
|
5
5
|
"main": "main.js",
|
|
6
6
|
"exports": {
|
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
"!src/rom-map-parser.js",
|
|
27
27
|
"!rom-maps/",
|
|
28
28
|
"!graphics-maps/",
|
|
29
|
-
"ball-data/"
|
|
29
|
+
"ball-data/",
|
|
30
|
+
"!src/object-event-data-parser.js"
|
|
30
31
|
],
|
|
31
32
|
"keywords": [
|
|
32
33
|
"gba",
|
|
@@ -26,5 +26,7 @@ export const fireredRev0 = {
|
|
|
26
26
|
ballParticlePalTable: 0x40BFA8,
|
|
27
27
|
ballAnimPicTable: 0x26056C,
|
|
28
28
|
ballAnimPalTable: 0x2605CC, // any idea what I am doing next?
|
|
29
|
+
objectEventPicTable: 0x39FDB0,
|
|
30
|
+
objectEventPalTable: 0x3A5158, // so these tables... technically aren't tables (except for the palette one kinda...) they are actually pointers to objects which then contain children who actually contain another object which finally contains a pointer to the actual graphics... this will be fun... (anyway will work on this eventually...)
|
|
29
31
|
} // if this works out... well hehe... :D
|
|
30
32
|
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import fs from "fs";
|
|
5
5
|
import path from "path";
|
|
6
6
|
import { fileURLToPath } from "url";
|
|
7
|
+
import { mapLimit } from "../map-limit.js";
|
|
7
8
|
import { renderMon } from "./mons/render-mons.js";
|
|
8
9
|
import { renderIcon } from "./icons/render-icons.js";
|
|
9
10
|
import { renderTrainer } from "./trainers/render-trainers.js";
|
|
@@ -43,6 +44,16 @@ export async function renderAllMons(rom, options = {}) {
|
|
|
43
44
|
const config = getRomConfig(rom);
|
|
44
45
|
const reader = new RomReader(rom, config);
|
|
45
46
|
|
|
47
|
+
await mapLimit(Object.keys(providedMons), 4, async (monName) => { // so in theory we should be running the function 4 times concurrently now...
|
|
48
|
+
await renderMon(monName, providedMons, reader, rom, {
|
|
49
|
+
variant: ["normal", "shiny"],
|
|
50
|
+
icon,
|
|
51
|
+
footprint,
|
|
52
|
+
outputDir,
|
|
53
|
+
});
|
|
54
|
+
console.log(`Done: ${monName}`);
|
|
55
|
+
});
|
|
56
|
+
/* just going to leave this here for now in case I decide to make it so that you can toggle between concurrent usage and I suppose synchronous would be the correct term for this down here...
|
|
46
57
|
for (const monName of Object.keys(providedMons)) {
|
|
47
58
|
await renderMon(monName, providedMons, reader, rom, { // hopefully this is faster since we are no longer calling the function 4 times lol
|
|
48
59
|
side: ["front", "back"],
|
|
@@ -53,6 +64,7 @@ export async function renderAllMons(rom, options = {}) {
|
|
|
53
64
|
});
|
|
54
65
|
console.log(`Done: ${monName}`);
|
|
55
66
|
}
|
|
67
|
+
*/
|
|
56
68
|
}
|
|
57
69
|
|
|
58
70
|
export async function renderAllIcons(rom, options = {}) {
|
|
@@ -74,9 +74,9 @@ export async function renderMonFoot(monName, mons, reader, rom, options = {}) {
|
|
|
74
74
|
|
|
75
75
|
if (outputDir) {
|
|
76
76
|
const dir = `${outputDir}/${monName}`;
|
|
77
|
-
|
|
77
|
+
await fs.promises.mkdir(dir, { recursive: true });
|
|
78
78
|
const fileName = `${dir}/footprint.png`;
|
|
79
|
-
fs.
|
|
79
|
+
await fs.promises.writeFile(fileName, pngBuffer);
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
return pngBuffer;
|
|
@@ -56,9 +56,9 @@ export async function renderMonIcon(monName, mons, reader, rom, options = {}) {
|
|
|
56
56
|
|
|
57
57
|
if (outputDir) {
|
|
58
58
|
const dir = `${outputDir}/${monName}`;
|
|
59
|
-
|
|
60
|
-
fs.
|
|
61
|
-
fs.
|
|
59
|
+
await fs.promises.mkdir(dir, { recursive: true });
|
|
60
|
+
await fs.promises.writeFile(`${dir}/icon_frame1.png`, buffer1);
|
|
61
|
+
await fs.promises.writeFile(`${dir}/icon_frame2.png`, buffer2);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
return {
|
|
@@ -61,6 +61,9 @@ export async function renderMon(monName, mons, reader, rom, options = {}) {
|
|
|
61
61
|
const results = [];
|
|
62
62
|
const width = 64;
|
|
63
63
|
const height = 64;
|
|
64
|
+
if (outputDir) {
|
|
65
|
+
await fs.promises.mkdir(dir, { recursive: true }); // why was I using existsSync... eh well "fixed?" now I guess... also I moved this out of the loop as you can see so it only has to run... 440 times now... instead of 4x that number :p
|
|
66
|
+
}
|
|
64
67
|
for (const side of sides) {
|
|
65
68
|
for (const variant of variants) {
|
|
66
69
|
const image = render4bppImage({
|
|
@@ -76,9 +79,8 @@ export async function renderMon(monName, mons, reader, rom, options = {}) {
|
|
|
76
79
|
|
|
77
80
|
if (outputDir) {
|
|
78
81
|
const dir = `${outputDir}/${monName}`;
|
|
79
|
-
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true }); // I suppose it is better to have this out of the loop for performance but erm I would say its fine for now :p
|
|
80
82
|
const fileName = `${dir}/${side}${variant === "shiny" ? "_shiny" : ""}.png`;
|
|
81
|
-
fs.
|
|
83
|
+
await fs.promises.writeFile(fileName, pngBuffer);
|
|
82
84
|
}
|
|
83
85
|
|
|
84
86
|
results.push(pngBuffer);
|
package/src/map-limit.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Copyright (c) 2026 chickenPoo
|
|
2
|
+
// Licensed under the MIT License. See LICENSE file in project root.
|
|
3
|
+
|
|
4
|
+
export async function mapLimit(items, limit, mapper) { // I hope this works... in theory it should and it seems quite simple... it's just that I am garbage at async thingies...
|
|
5
|
+
const results = new Array(items.length);
|
|
6
|
+
let index = 0;
|
|
7
|
+
|
|
8
|
+
async function worker() {
|
|
9
|
+
while (true) {
|
|
10
|
+
const current = index++;
|
|
11
|
+
|
|
12
|
+
if (index >= items.length) return;
|
|
13
|
+
|
|
14
|
+
results[current] = await mapper(items[current], current);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
await Promise.all(
|
|
18
|
+
Array.from(
|
|
19
|
+
{ length: Math.min(limit, items.length) },
|
|
20
|
+
worker
|
|
21
|
+
)
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
return results;
|
|
25
|
+
}
|