[Tuxnes-devel] saving the "state" of the game
Brought to you by:
tmmm
|
From: Jason D. S. <jas...@ya...> - 2001-08-09 04:29:21
|
I recently started using tuxnes again (good work with the recent improvements, BTW), and it looks like TuxNES has no "save state" feature like many other emulators do. (It's possible I missed it, in which case please correct me.) So, I set out to implement this. I created two functions, savestate() and restorestate(). I arbitrarily picked keys F11 and F12 to link to them. (These were obviously unused, while most other logical keys to use for this were in use. I only have bindings for X11 at the moment.) Currently, the "state" that is saved includes only the program counter, stack pointer, and the first (only?) 32k of RAM. Amazingly enough, this more-or-less works! I had thought that additional registers (which I saw reference to in the dyn-rec file) would have to be saved as well, but I guess they're placed somewhere in the RAM pages when not in use (?). All this took very little time (~20 minutes). I can now save and restore the state, and everything works fine (except as below). (I quickly racked up tokens in the Dragon Warrior 4 casino using it. Ahh, cheating...) A somewhat major problem is that graphics are not immediately updated after the restore. At first I thought this could be solved by forcing a refresh, so I set the "needsredraw", "redrawall", and "redrawbackground" flags to force a redraw. When this didn't work, I immediately realized my error - of course the graphics are drawn by the game's code, so the graphical frontend (X11) has no way of knowing what to draw until the game chooses to redraw. This suggests that the image on the screen must also be a part of the saved state. However, this presents a problem because it is frontend-specific: the code for creating a digital segment for the image will be different between different graphical systems. More importantly, the data format itself will most likely be different (unless pains are taken to convert it to a standard format) - this is already the case with screen shots. I don't have a patch to give you right now, since my computer is currently disconnected from the internet (a DSL problem); this is the same reason why I'm posting from this random Yahoo account (for which I apologize, especially if it kills the formatting). In a few days I should have it fixed. Another goal of this subproject would be to be compatible with other emulator saved-state files. However, a cursory web search won't tell me what the format for NESticle saved state files is. jason short __________________________________________________ Do You Yahoo!? Make international calls for as low as $.04/minute with Yahoo! Messenger http://phonecard.yahoo.com/ |