Open C3RV1 opened 1 year ago
Which homebrew games use EEPROM?
Mine for example: https://github.com/C3RV1/UndertaleNDS
That's an issue I've encountered on my project, but still, I think Homebrew games should be able to save savefile data without needing to set up DLDI and an SD image. I know of some other developers who right now are setting up their games to work in a similar fashion.
Saving savefiles this way is easier, both for the player (it generates a .sav file) and for developers, who don't have to add instructions for users to setup a DLDI and SD image on emulators.
On hardware, twilight menu, flashcards... I make sure to use a fat file system for saving the file instead, because I know whatever loaded the game is compatible with DLDI and has an SD image.
I think Homebrew games should be able to save savefile data without needing to set up DLDI and an SD image.
That is not, in my opinion, a good idea. An emulator should mimic environments which actually exist in the real world; people should not be writing code for emulators specifically. As there is no real world homebrew execution environment which uses EEPROM, I think adding such a feature in an emulator-exclusive manner is unwise.
Rather, it might be a good idea to, say, automatically prompt the user to generate an SD image as soon as a homebrew program tries to perform a DLDI access.
As there is no real world homebrew execution environment which uses EEPROM,
Well, Godmode9i (a homebrew app) runs on hardware (an execution environment) and utilizes dkp EEPROM calls for dumping save files from cartridges. Obviously this use case is pointless on melon, but I think C3RVI (and my) use cases (supporting EEPROM calls as a fallback in non-DLDI environments) isn't unreasonable particularly, and is supported & works great on DESMUME (which has lacklustre DLDI support from my experience).
I agree with your point of principle though, but think homebrew games that want to use EEPROM should be able to, particularly given how unreliable DLDI/libfat can be.
Godmode9i (a homebrew app) runs on hardware (an execution environment) and utilizes dkp EEPROM calls for dumping save files from cartridges
you can run it from unlaunch in melonDS DSi mode with a cartridge inserted and it should already work in melonDS.
I just realized...if this were implemented, it would considerably simplify the test suite. You wouldn't need to include a retail ROM in the test pipeline.
From MelonDS 0.9.2 onward homebrew games cannot simulate saving savefiles to an EEPROM. The reason for this is found in NDSCart.cpp line 1675:
Also the
CartHomebrew
class utilizes the defaultCartCommon::SPIWrite
implementation:causing homebrew games to only read 0xFF when reading REG_AUXSPIDATA, even after a command. This isn't correct, as after issuing a SPI_EEPROM_RDSR (read status register) the cart shouldn't return 0xFF. CartRetail instead implements it as:
Some homebrew games expect bit 0 of RDSR to not be set before continuing to write data. From gbatek, bit 0 represents:
So waiting for bit 0 to not be set, if it always reads 0xFF, the game hangs in an infinite loop. For example, in a function like:
All of this doesn't allow homebrew to use an EEPROM for savefiles. Thus, homebrew games cannot save data unless DLDI is enabled, and the save file is saved to the SD image.
Could it be possible to add the option for Homebrew games to save savefile data to an EEPROM maybe by assuming its size? Alternatively, it would be better to make Homebrew games not hang by returning 0x0 when a RDSR command is issued (and returning valid responses to other commands too), although that would still cause the games to be unable to save.