Had an idea in the car on the way to work this morning - high score load/save.
At lunchtime I did more of the transcode audit; up to all the object routines now. They should be pretty quick to audit, except for the few which have known bugs.
Tonight at home I read up on the Neo Geo memory card routines. Fortunately they're pretty straightforward to understand and easy to use - it was harder working out how to use them with MAME.
Anyway the load/save has been implemented and tested! On startup the high scores will be read from the memory card (if the card is inserted and there is Xevious data on there of course). And whenever a new high score has been entered on the table, the table is written back to memory card. Easy as!
That's fine if you have a memory card, but some MVS systems supported battery-backed RAM instead. I can see MAME has automatically created it. I'll look at falling back to NVRAM if there is no memory card present.
There's a pointer and length in the cart header that will have the BIOS automatically load that memory with data from the battery backed RAM on startup. I don't know how it gets saved back but presumably there's some BIOS call to do so.
ReplyDeleteThe BIOS will load data from NVRAM (automatically) as per the header information you mention when the player starts a game and the system enters 'game mode', and then save back to NVRAM (automatically) when the player exits the game and the system is executing in 'system mode'.
DeleteThat works for native Neo Geo games that have been written 'properly' to integrate with the select, title, demo and game modes defined in the BIOS.
Because Xevious is a transcoded arcade game, it grabs control of the system in demo mode, and never returns. FWIW I followed the lead of some other homebrew Neo Geo games in this regard. Otherwise I'd have to restructure the entire top level of the arcade code...
I have identified the routines in the BIOS that do the actual read/write to NVRAM. I am yet to understand how the NVRAM block is first allocated to a game; once I look at that I'm sure it'll be trivial to add support for it.
Interesting; thanks for the info. Makes sense to avoid the Neo Geo system structure in a port. Just extra complication for no real benefit.
DeleteTurns out I was half right about when the BIOS will load from BRAM. It actually loads at several different points, including when a new slot is selected on a multi-slot board. On a single slot, it gets loaded when the BIOS first initialises.
DeleteThis means I can set the header info and have it load automatically for Xevious, even though it takes over demo mode and never returns. I just need to save it explicitly, whenever the high sore table is updated.