Comments (6)
That helped! Thanks!
WasmBoy.config(WasmBoyOptions, canvas).then(() => {
console.log('WasmBoy is configured!');
WasmBoy.loadROM(rom).then(function() {
console.log("ROM loaded!");
WasmBoy.play().then(function() {
console.log("Playing!");
setTimeout(async function() {
try {
let state = JSON.parse(fs.readFileSync("./latest.sav"));
let nwIS = Uint8Array.from(state.wasmboyMemory.wasmBoyInternalState);
state.wasmboyMemory.wasmBoyInternalState = nwIS;
let nwPM = Uint8Array.from(state.wasmboyMemory.wasmBoyPaletteMemory);
state.wasmboyMemory.wasmBoyPaletteMemory = nwPM;
let ngBM = Uint8Array.from(state.wasmboyMemory.gameBoyMemory);
state.wasmboyMemory.gameBoyMemory = ngBM;
let ncR = Uint8Array.from(state.wasmboyMemory.cartridgeRam);
state.wasmboyMemory.cartridgeRam = ncR;
await WasmBoy.loadState(state);
} catch(e) {
console.error(e);
}
WasmBoy.saveState().then(function(state) {
let nwIS = Array.from(state.wasmboyMemory.wasmBoyInternalState);
state.wasmboyMemory.wasmBoyInternalState = nwIS;
let nwPM = Array.from(state.wasmboyMemory.wasmBoyPaletteMemory);
state.wasmboyMemory.wasmBoyPaletteMemory = nwPM;
let ngBM = Array.from(state.wasmboyMemory.gameBoyMemory);
state.wasmboyMemory.gameBoyMemory = ngBM;
let ncR = Array.from(state.wasmboyMemory.cartridgeRam);
state.wasmboyMemory.cartridgeRam = ncR;
fs.writeFileSync("./latest.sav", JSON.stringify(state));
WasmBoy.play();
});
from wasmboy.
@TheBlackParrot Ah oops! Yep that is a bug, IndexedDB wouldn't be available in Node, and it's a bug on my end, I'll try and fix it real quick
from wasmboy.
@TheBlackParrot This should now be published with a fix in version 0.5.1
from wasmboy.
Not getting the error anymore, but I can't load states as well it seems. Dunno if I'm not saving it correctly or what.
(node:18927) UnhandledPromiseRejectionWarning: TypeError: Found invalid object in transferList
at Worker.postMessage (internal/worker.js:379:23)
at SmartWorker.postMessage (/home/theblackparrot/Games/Blockland/Add-Ons/Gamemode_BL_Plays_Pokemon/node_modules/wasmboy/dist/wasmboy.wasm.cjs.js:3529:17)
at loadStateTask (/home/theblackparrot/Games/Blockland/Add-Ons/Gamemode_BL_Plays_Pokemon/node_modules/wasmboy/dist/wasmboy.wasm.cjs.js:3158:25)
at WasmBoyMemoryService.loadState (/home/theblackparrot/Games/Blockland/Add-Ons/Gamemode_BL_Plays_Pokemon/node_modules/wasmboy/dist/wasmboy.wasm.cjs.js:3173:12)
at loadStateTask (/home/theblackparrot/Games/Blockland/Add-Ons/Gamemode_BL_Plays_Pokemon/node_modules/wasmboy/dist/wasmboy.wasm.cjs.js:5769:27)
WasmBoy.loadROM(rom).then(function() {
console.log("ROM loaded!");
WasmBoy.play().then(function() {
console.log("Playing!");
try {
WasmBoy.loadState(JSON.parse(fs.readFileSync("./latest.sav")));
} catch(e) {
console.error(e);
}
latest.json.txt (Pokemon Red is the game I'm running if this is of any use to you (filenames are different, Github was being difficult about file types))
from wasmboy.
Ah so this is totally because I'm using WebWorker Transferables which needs to be a typed array. But since you are doing a JSON.parse()
on a file, it's going to become a stringified array.
Ideally, I should detect and fix that. And I opened an issue at #314
In the meantime, can you convert the arrays in the object returned by JSON.parse() to a Uint8Array? That should fix it 😄
Also, since you are JSON.stringify-ing the typed Uint8Arrays, you may want to also convert those to normal arrays first, that way it isn't stringified a an object?
Let me know if that helps! Thankss!
from wasmboy.
Awesome! I'm glad it helped! @TheBlackParrot
from wasmboy.
Related Issues (20)
- Refactor Workers to use Comlink
- Firefox Benchmark TypeScript FPS wrong / halved? HOT 3
- Save States in QR Codes?
- Rewrite the core
- Check if arrays are typed for the Transferable when loading states
- Create an easy to embed iframe from other sites HOT 1
- Implement FullScreen & Mobile Controls for the Iframe Embed HOT 2
- Look into adding SIMD Support
- OAM not rendering at all HOT 3
- No Audio output on Linux (pulseaudio) HOT 1
- setJoypadState not working HOT 2
- TypeError: failed to fetch HOT 2
- More debugging / hacking functionality HOT 4
- Larger canvas sizes with same aspect ratio HOT 2
- Serialize classes for save states using ason
- LCDC should be initialised with BG on HOT 3
- useGbcWhenAvailable / useGbcWhenOptional is not working HOT 1
- Multiple instances HOT 2
- SRAM HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wasmboy.