mirror of
https://github.com/EmulatorJS/EmulatorJS.git
synced 2026-02-06 11:17:36 +00:00
Read state from memory instead of saving to disk
This commit is contained in:
parent
627fba2f9c
commit
5d54014ce3
@ -5,7 +5,7 @@ class EJS_GameManager {
|
||||
this.FS = this.Module.FS;
|
||||
this.functions = {
|
||||
restart: this.Module.cwrap('system_restart', '', []),
|
||||
saveStateInfo: this.Module.cwrap('save_state_info', 'null', []),
|
||||
saveStateInfo: this.Module.cwrap('save_state_info', 'string', []),
|
||||
loadState: this.Module.cwrap('load_state', 'number', ['string', 'number']),
|
||||
screenshot: this.Module.cwrap('cmd_take_screenshot', '', []),
|
||||
simulateInput: this.Module.cwrap('simulate_input', 'null', ['number', 'number', 'number']),
|
||||
@ -172,8 +172,15 @@ class EJS_GameManager {
|
||||
this.functions.restart();
|
||||
}
|
||||
getState() {
|
||||
this.functions.saveStateInfo();
|
||||
return this.FS.readFile("/current.state");
|
||||
const state = this.functions.saveStateInfo().split("|");
|
||||
if (state[2] !== "1") {
|
||||
console.error(state[0]);
|
||||
return state[0];
|
||||
}
|
||||
const size = parseInt(state[0]);
|
||||
const dataStart = parseInt(state[1]);
|
||||
const data = this.Module.HEAPU8.subarray(dataStart, dataStart + size);
|
||||
return new Uint8Array(data);
|
||||
}
|
||||
loadState(state) {
|
||||
try {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user