silphscope 1.3.1 → 1.3.2
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/README.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
still a WIP however hopefully with some more work I can get this into a workable state...
|
|
2
2
|
|
|
3
|
+
(Even Newer!) Update:
|
|
4
|
+
|
|
5
|
+
moves now work... kinda... still working on getting it all the way done but it mostly works!
|
|
6
|
+
|
|
3
7
|
(Newer!) Update:
|
|
4
8
|
|
|
5
9
|
still a WIP :p but erm you can extract more graphics!
|
|
@@ -21,10 +25,11 @@ await renderAllGraphics(rom, {
|
|
|
21
25
|
outputMonDir: "./Assets/monImages", // must I explain?
|
|
22
26
|
outputIconDir: "./Assets/Icons", // same thing here :p
|
|
23
27
|
outputTrainerDir: "./Assets/Trainers", // ...
|
|
28
|
+
outputMoveDir: "./Assets/Moves"
|
|
24
29
|
});
|
|
25
30
|
```
|
|
26
31
|
|
|
27
|
-
Of course though the above is for extracting all graphics (which is kinda a lie... In reality it only extracts mon images, item icons, and
|
|
32
|
+
Of course though the above is for extracting all graphics (which is kinda a lie... In reality it only extracts mon images, item icons, trainer images, and move images... but like I said this is a WIP :p so wait a bit please!).
|
|
28
33
|
|
|
29
34
|
But if you want say just the mon images or item icons refer below:
|
|
30
35
|
|
|
@@ -62,4 +67,15 @@ await renderAllTrainers(rom, {
|
|
|
62
67
|
outputDir: "./Assets/trainers", // more stuff
|
|
63
68
|
trainerBackPics: true, // renders the like 8 trainer back pics
|
|
64
69
|
})
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
move image extraction:
|
|
73
|
+
```JavaScript
|
|
74
|
+
import fs from "fs";
|
|
75
|
+
import { renderAllMoves } from "silphscope" // :O
|
|
76
|
+
|
|
77
|
+
const rom = fs.readFileSync("pokefirered.gba") // stuff stuff stuff (more stuff!)
|
|
78
|
+
await renderAllMoves(rom, {
|
|
79
|
+
outputDir: "./Assets/trainers", // (incredibly) more stuff
|
|
80
|
+
})
|
|
65
81
|
```
|
package/package.json
CHANGED
|
@@ -104,6 +104,7 @@ export async function renderAllMoves(rom, options = {}) {
|
|
|
104
104
|
const {
|
|
105
105
|
moves: providedMoves = moves,
|
|
106
106
|
outputDir = "./out",
|
|
107
|
+
renderMasterImage = true,
|
|
107
108
|
} = options;
|
|
108
109
|
|
|
109
110
|
fs.mkdirSync(outputDir, { recursive: true });
|
|
@@ -112,7 +113,10 @@ export async function renderAllMoves(rom, options = {}) {
|
|
|
112
113
|
const reader = new RomReader(rom, config);
|
|
113
114
|
|
|
114
115
|
for (const moveName of Object.keys(providedMoves)) {
|
|
115
|
-
await renderMove(moveName, providedMoves, reader, rom, {
|
|
116
|
+
await renderMove(moveName, providedMoves, reader, rom, {
|
|
117
|
+
outputDir,
|
|
118
|
+
renderMasterImage,
|
|
119
|
+
});
|
|
116
120
|
console.log(`Done: ${moveName}`);
|
|
117
121
|
}
|
|
118
122
|
}
|
|
@@ -146,6 +150,7 @@ export async function renderAllGraphics(rom, options = {}) { // eventually I wil
|
|
|
146
150
|
|
|
147
151
|
await renderAllMoves(rom, {
|
|
148
152
|
outputDir: outputMoveDir,
|
|
153
|
+
renderMasterImage: true,
|
|
149
154
|
})
|
|
150
155
|
}
|
|
151
156
|
|
|
@@ -37,7 +37,8 @@ const extractFrameFromImage = (imageData, fullWidth, frameData) => { // in theor
|
|
|
37
37
|
|
|
38
38
|
export async function renderMove(moveName, moves, reader, rom, options = {}) {
|
|
39
39
|
const {
|
|
40
|
-
outputDir = null
|
|
40
|
+
outputDir = null,
|
|
41
|
+
renderMasterImage = false,
|
|
41
42
|
} = options;
|
|
42
43
|
if (!rom || !(rom instanceof Uint8Array || Buffer.isBuffer(rom))) {
|
|
43
44
|
throw new TypeError("renderMove(..., rom) requires a ROM Buffer/Uint8Array");
|
|
@@ -69,7 +70,12 @@ export async function renderMove(moveName, moves, reader, rom, options = {}) {
|
|
|
69
70
|
if (outputDir) { // I will update this later but in theory it should also work... eventually though it will need a split inside to handle full image generation :p
|
|
70
71
|
const dir = `${outputDir}/${moveName}`;
|
|
71
72
|
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
|
72
|
-
|
|
73
|
+
if (renderMasterImage) {
|
|
74
|
+
const png = new PNG({ width, height });
|
|
75
|
+
png.data = image;
|
|
76
|
+
const pngBuffer = await streamToBuffer(png.pack());
|
|
77
|
+
fs.writeFileSync(`${dir}/master.png`, pngBuffer);
|
|
78
|
+
}
|
|
73
79
|
for (let i = 0; i < move.frames.length; i++) {
|
|
74
80
|
const frame = move.frames[i];
|
|
75
81
|
const frameImageData = extractFrameFromImage(image, width, frame);
|