macabeus / react-gbajs

🕹 GBA emulator on your React project - easy and powerful to use!
https://www.npmjs.com/package/react-gbajs
BSD 2-Clause "Simplified" License
71 stars 14 forks source link

Uncaught ReferenceError: FlashSavedata is not defined #16

Closed Flowrome closed 1 year ago

Flowrome commented 2 years ago

Hi

Sorry to bother you again, but from the issue 14 now i'm getting this error, i don't know if it is a problem with the .gba file but i've tried multiple and i'm getting the same error:

Uncaught (in promise) ReferenceError: FlashSavedata is not defined
    at window.GameBoyAdvanceMMU.GameBoyAdvanceMMU.loadRom (react-gbajs.js?323e:10)
    at G.setRom (react-gbajs.js?323e:10)
    at G.loadRomFromFile (react-gbajs.js?323e:10)
    at H (react-gbajs.js?323e:10)
    at play (react-gbajs.js?323e:10)
    at _callee$ (emulator.js?a22c:33)
    at tryCatch (runtime.js?c56e:45)
    at Generator.invoke [as _invoke] (runtime.js?c56e:274)
    at Generator.prototype.<computed> [as next] (runtime.js?c56e:97)
    at asyncGeneratorStep (emulator.js?a22c:1)
    at _next (emulator.js?a22c:1)

I've also cloned your example and it seems that it gives me the same error

Let me know if i can provide more information

Thank you

macabeus commented 2 years ago

Please, try loading the same ROM on http://endrift.github.io/gbajs/ and say here if it worked or not.

Flowrome commented 2 years ago

Hi @macabeus yes it is working on gbajs, but i think i've found the issue, there is no window.FlashSavedata exported inside the .js files, i've changed the savedata.js file like that:


window.FlashSavedata = function FlashSavedata(size) {
  MemoryView.call(this, new ArrayBuffer(size), 0);

  this.COMMAND_WIPE = 0x10;
  this.COMMAND_ERASE_SECTOR = 0x30;
  this.COMMAND_ERASE = 0x80;
  this.COMMAND_ID = 0x90;
  this.COMMAND_WRITE = 0xa0;
  this.COMMAND_SWITCH_BANK = 0xb0;
  this.COMMAND_TERMINATE_ID = 0xf0;

  this.ID_PANASONIC = 0x1b32;
  this.ID_SANYO = 0x1362;
...

also in the mmu.js i've exported memoryview:

window.MemoryView = function MemoryView(memory, offset) {
  this.buffer = memory;
  this.view = new DataView(
    this.buffer,
    typeof offset === "number" ? offset : 0,
  );
  this.mask = memory.byteLength - 1;
  this.resetMask();
};

and in the util.js i've exported the hex function:

window.hex = function hex(number, leading, usePrefix) {
  if (typeof usePrefix === "undefined") {
    usePrefix = true;
  }
  if (typeof leading === "undefined") {
    leading = 8;
  }
  var string = (number >>> 0).toString(16).toUpperCase();
  leading -= string.length;
  if (leading < 0) return string;
  return (usePrefix ? "0x" : "") + new Array(leading + 1).join("0") + string;
};

Now it seems to work fine

macabeus commented 2 years ago

Nice that you fixed it!

Can you open a PR, please?

Flowrome commented 2 years ago

Can't do it right now hopefully at the end of the day 😁

iOrchK commented 2 years ago

Hi

Sorry to bother you again, but from the issue 14 now i'm getting this error, i don't know if it is a problem with the .gba file but i've tried multiple and i'm getting the same error:

Uncaught (in promise) ReferenceError: FlashSavedata is not defined
    at window.GameBoyAdvanceMMU.GameBoyAdvanceMMU.loadRom (react-gbajs.js?323e:10)
    at G.setRom (react-gbajs.js?323e:10)
    at G.loadRomFromFile (react-gbajs.js?323e:10)
    at H (react-gbajs.js?323e:10)
    at play (react-gbajs.js?323e:10)
    at _callee$ (emulator.js?a22c:33)
    at tryCatch (runtime.js?c56e:45)
    at Generator.invoke [as _invoke] (runtime.js?c56e:274)
    at Generator.prototype.<computed> [as next] (runtime.js?c56e:97)
    at asyncGeneratorStep (emulator.js?a22c:1)
    at _next (emulator.js?a22c:1)

I've also cloned your example and it seems that it gives me the same error

Let me know if i can provide more information

Thank you

I'm getting the same error

macabeus commented 2 years ago

@Flowrome do you have any news?

macabeus commented 1 year ago

Fixed on 1.0.3