RyanPattison / Gearboy

Game Boy / Gameboy Color emulator for Ubuntu Touch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Game Not Saving on Close

RyanPattison opened this issue · comments

Component.onDestruction is not getting triggered when the app closes, resulting in missed saves. For now, saves can only be triggered by changing games before closing.

I came to comment on this.
A quick (but dirty) solution is to have a save-state button... but the game needs to be saved in the game

I was thinking the same thing. It shouldn't be necessary and I don't want to add any more to the UI if it can be done in code, I'm aiming for "just works". But if I can't detect the app closing, or the right texture to use, the right button sizes etc., a menu may be necessary so users have control and a functioning app.

I agree. I thought it had detected the closing event in a previous version (but I was doing different tests and my memory is nothing to rely on :) ).
I have dreamt about something I don't if it's factible but it might: in the emulation, the saving trigger should be a precise instruction... right? Adding a saving outside the emulation might be possible...

Some info:
http://marc.rawer.de/Gameboy/Docs/GBCPUman.pdf
http://www.devrs.com/gb/

Mmm?
http://www.pastraiser.com/cpu/gameboy/gameboy_opcodes.html
http://meseec.ce.rit.edu/551-projects/fall2013/1-1.pdf

That sounds perfect! There's a flag to disable/enable that area of memory and Gearboy already has a c-style callback put in place after writes for RAM changes.

The callback is just for that, so you can detect when the game is writing to RAM and then save its contents to file, just in case you are not able to know when the App is closed 😉

But some games write a lot to RAM by enabling and disabling RAM in short bursts. This may raise the callback multiple times in a second so take this into account.

@drhelius Ah, you've anticipated this! Thank you. I have noticed some games toggle the enable during a save around 4 times in my limited testing. Does it get much worse than that?

solved by ec022d0

Some games doesn't offer a save option but they save your progress anyway (SML2, F1 Race, etc.). Some of them are constantly writing to RAM so I would cache the RAM callbacks and write to file every second or two, so you don't kill the performance by writing too much.