MiSTer-devel / C64_MiSTer

111 stars 57 forks source link

Feature request: Easyflash save feature #137

Open mambrino opened 1 year ago

mambrino commented 1 year ago

Easyflash specifications allows to save data on the cartridge (has 1KB SRAM with 256 bytes available and mapped to I/O $DF00-$DFFFF). This is used more and more in new releases, so, it would be great to support the feature.

These are some games and apps that make use of save functionality, p.e:

https://csdb.dk/release/?id=156948 https://csdb.dk/release/?id=98674

sorgelig commented 1 year ago

i can try to add. Just need more technical info. I believe it's not mapped all the time and requires some register to enable/disable

sorgelig commented 1 year ago

image are you talking about this RAM? It's 256 bytes only. No mention about 1KB paged RAM. There is no mention it's battery backed RAM.

mambrino commented 1 year ago

are you talking about this RAM? It's 256 bytes only. No mention about 1KB paged RAM. There is no mention it's battery backed RAM.

the c64 wiki (https://www.c64-wiki.com/wiki/EasyFlash) says that it has an 8 KiB SRAM installed but only 256 bytes are available.
It doesn't mention anything about battery backed either, and on the pcb you can't see the battery anywhere, but it must have to keep content when disconnected, no?

mambrino commented 1 year ago

i can try to add. Just need more technical info. I believe it's not mapped all the time and requires some register to enable/disable

Here is the complete repository for EasyFlash with hardware folder including schematics and components bom list (here however says that it's a 64Kbits 6264 SRAM for EasyFlash v1 and 256kbits AS6C62256-55STC SRAM for EasyFlash v3, both cartridges has power pin connected to vdd, nothing about battery backed anywhere):

https://bitbucket.org/skoe/easyflash/downloads/

sorgelig commented 1 year ago

I don't think this RAM is used for saves. It's rather RAM extension.

mambrino commented 1 year ago

Easyflash programmer's guide clearly indicates "it can be used to save small portions of code or data", in addition, it's a fact that games like Caren and the Tangled Tentacles, Zak McKracken and Sam's Journey, have an option or key to save the game to cartridge. There are others like Epyx Game Collection that use this memory to save records, but also in the main menu there is a tool to dump data from EF to disk and vice versa. (https://csdb.dk/release/?id=107705) Since there isn't battery that can keep the data when the computer is turned off, probably, what the original hard does is to dump the cartridge content back to the filesystem (just the sram i guess). I think that's what other fpga like ultimate II/64 does to save the data.

paich64 commented 1 year ago

as stated on https://skoe.de/easyflash/efintro/ :
"HOW DOES EASYFLASH WORK? EasyFlash is an 1 MByte Flash EPROM cartridge with multiple configurations and banks possible. It does not use traditional UV-EPROMs, but Flash memory. This makes it possible to “burn” the cartridge using your C64, no EPROM programmer is needed." and on http://skoe.de/easyflash/recommended/ :

"Saving features mentioned here means saving to flash. If a game has e.g. a high score saving, the game saves the scores directly to the cartridge flash.

A Backup/Restore feature means that the saved data can be exported to disk and imported back to EasyFlash cartridge. This is very useful if you have a cartridge with e.g. saved high scores. You are then able to rewrite the EasyFlash cartridge, and restore the saved data later on."

here is the programmer guide https://skoe.de/easyflash/files/devdocs/EasyFlash-ProgRef.pdf

theenemy-thd commented 1 year ago

+1 for this option .... more and more games are being released on easyflash these days and my group will be releasing more versions of old games converted to run on easyflash with save support for high scores etc. If more info is required on the tech side of saving then please ask and I can ask Mike/knight rider who does the easyflash conversions

mambrino commented 1 year ago

A Pig Quest

Another game released (a big one) in CRT Easyflash format where progress needs to be saved to the cartridge in order to continue.

There are more and more releases of this type, because due to the size of the game it is not possible to distribute it in floppy disk format.

Please, it would be appreciated if this functionality is added to the core.

Schermobianco commented 1 year ago

+1 for this option, thanks guys

sorgelig commented 1 year ago

saving is not trivial as it needs emulation of flash memory erase/write cycles.

theenemy-thd commented 1 year ago

saving is not trivial as it needs emulation of flash memory erase/write cycles.

I think how the ultimate 64 gets around it is it allows you in the menu to resave the whole easyflash file in memory, which then includes the highscores etc when reloaded.

Kungfu flash does something different for saving easyflash I think or maybe the same but just overwrites the original file

mambrino commented 1 year ago

it could even be an automatic process, just like saving sram on console cores. When the menu opens it could automatically dump the entire easyflash area back into the crt file, wouldn't that be possible?

sorgelig commented 1 year ago

it has nothing to do how much of cart will be saved.

theenemy-thd commented 1 year ago

So it can't be done then?

jedcooper commented 1 year ago

+1 for this option, thanks

sorgelig commented 1 year ago

there are 2 issues: 1) need to emulate flash erase/write commands - should be no problem 2) since there is no dedicated storage for saves, any part of cart can contain saves. Thus entire cart must be saved. With size of 1MB it can take a lot of time...

mambrino commented 1 year ago

can't be updated only the part of the crt file that corresponds to the 1kb sram area (mapped at $DF00-$DFFFF)? from what i understood, saves will be always in this memory bank.

sorgelig commented 1 year ago

SRAM on easyflash is not battery powered as i know. So it cannot hold saves between power cycles.

mambrino commented 1 year ago

of course, that's why I tell you to dump that memory area to the crt file when a change occurs, which I suspect is what the original hardware does, since it doesn't have a battery to store between power cycles. Maybe I'm not getting it right, but it seems the only way to do it.

sorgelig commented 1 year ago

Original HW has no CPU/MCU on cart and cannot copy anything internally.

theenemy-thd commented 1 year ago

When you say "takes a lot of time", I dont think anyone who wants this feature would mind a 5 to 15 second delay on exiting back to menu and it saving.

couldnt it be done as a on/off option for easyflash save for those who dont care for save .. then it wouldnt effect those individuals.

there are 2 issues:

  1. need to emulate flash erase/write commands - should be no problem
  2. since there is no dedicated storage for saves, any part of cart can contain saves. Thus entire cart must be saved. With size of 1MB it can take a lot of time...
sparkysanxion commented 11 months ago

+1 for this feature if it's possible.

it's kinda the only thing holding me back fromn the mister being my main c64 machine at the mo. Also +1 for not particularly caring for the save write times too.

Great core tho. brilliant stuff.

theenemy-thd commented 11 months ago

Totally agree sanxion, this feature would basically make the mister my goto for c64 ... until then I have to boot my u64 up

theenemy-thd commented 5 months ago

Sorry to bang on about this ... but more easyflash games have now been released with saving of progress in game.

Briley witch chronicles 2, space station 23 and yeti mountain

Not having the saving is becoming more of an issue as more easyflash saving games get released.

mambrino commented 3 months ago

Original HW has no CPU/MCU on cart and cannot copy anything internally.

There is no RAM or battery to keep the data, nor does it need a CPU to do so, what the original cartridge does is flashing the eeprom to update the save data area (256 bytes mapped to I/O $DF00-$DFFFF).

as stated by paich64 this howto has info about the process: https://skoe.de/easyflash/efintro/

"HOW DOES EASYFLASH WORK? EasyFlash is an 1 MByte Flash EPROM cartridge with multiple configurations and banks possible. It does not use traditional UV-EPROMs, but Flash memory. This makes it possible to “burn” the cartridge using your C64, no EPROM programmer is needed."

"Saving features mentioned here means saving to flash. If a game has e.g. a high score saving, the game saves the scores directly to the cartridge flash.

A Backup/Restore feature means that the saved data can be exported to disk and imported back to EasyFlash cartridge. This is very useful if you have a cartridge with e.g. saved high scores. You are then able to rewrite the EasyFlash cartridge, and restore the saved data later on."

theenemy-thd commented 3 months ago

The above is not actually correct as the save can be in any 64kb sector of the file hence why a full copy from memory to file would be needed. People don't adhere to keeping the saves to a particular part of the easyflash

sparkysanxion commented 3 months ago

Was just going to add (and I know nothing of the technicalities of why/how).... but the way it works on an kung-fu flash on real harware (for those that have not used one) is, when you hit the menu button to go back, if 'something' has changed, it prompts you to overwrites the full .crt file on the sd card, or not.

sorgelig commented 3 months ago

I keep in my mind this feature. So i will implement it when i'll find some good ideas of implementation.

xdarkwombatx commented 1 month ago

Yeah this would be huge if implemented. There are a couple of Ultima remastered games which are on Easyflash but you cant save.

More and more EasyFlash games that require saving are being added.