Skip to content
Snippets Groups Projects
Verified Commit 1430790a authored by João Magalhães's avatar João Magalhães :rocket:
Browse files

fet: new ram structure

parent 6965009f
No related branches found
No related tags found
No related merge requests found
Pipeline #1546 passed
......@@ -199,11 +199,21 @@ export class GameboyEmulator extends EmulatorBase implements Emulator {
this.gameBoy?.ppu_mode() === PpuMode.VBlank &&
this.gameBoy?.ppu_frame() !== lastFrame
) {
// updates the reference to the last frame index
// to be used for comparison in the next tick
lastFrame = this.gameBoy?.ppu_frame();
// triggers the frame event indicating that
// a new frame is now available for drawing
this.trigger("frame");
// @todo this has to be structureed in a better way
if (this.cartridge && this.cartridge.has_battery()) {
const ramData = this.cartridge.ram_data_eager();
const decoder = new TextDecoder("utf8");
const ramDataB64 = btoa(decoder.decode(ramData));
localStorage.setItem(this.cartridge.title(), ramDataB64)
}
}
}
......@@ -289,6 +299,10 @@ export class GameboyEmulator extends EmulatorBase implements Emulator {
this.gameBoy.load_boot_default();
const cartridge = this.gameBoy.load_rom_ws(romData!);
// in case there's a battery involved tries to obtain
if (cartridge.has_battery()) {
}
// updates the ROM name in case there's extra information
// coming from the cartridge
romName = cartridge.title() ? cartridge.title() : romName;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment