The GB version of Tetris is my all time favorite version, and it's always bugged me that it won't save high scores. I know that Tetris DX does this, but I just love the music and feel of the original Tetris better, so here is my idea: Modify the Tetris ROM so that it reads and writes scores to an SRAM chip. Write the modified ROM to an EPROM and modify a cart with battery backed SRAM to use the modified program data. If this works, I would even go so far as to make a repro PCB that others can buy, because I bet lots of people would love to get a GB version of Tetris with score saves. I've only done very simple rom hacks, so before I go nuts and try to learn how to do this, I just wondered if someone smart could just say, no that's not possible. If it's not possible, is there another way to make this work?
I loved that game too, but I never really thought about score, I just kept playing until i could beat it on the hardest level, I think that's when you get the space-shuttle ending? If I was you I would just get one of the new Everdrive GB units, a lot less hassle than the hardware mod you're considering.
Good point!! I'd still need to mod the rom to read/write scores to the SRAM, but keeps me from having to fiddle with soldering and EPROMS. I've already ordered mine, but got to wait until another batch is made.
Well I have SRAM saving working in emulators, now I just have to wait until my Everdrive gets in to test it on there.
Try it on different emulators such as BGB and Gambatte and make sure it works there too. There is the possibility of various emulators and devices not managing the disable/enable correctly. When you are sure it works, you could publish it on a site like romhacking.net
Thank you, sure enough, it doesnt work on BGB, all FFFF's in the SRAM. Is there a specific asm command to enable it? Basically I got it to work in another emulator by setting the cart type to 0x03 (MBC1+RAM+BATTERY), then modifying the point where it reads/writes to WRAM to read/write from SRAM. For the other emulator, I had to provide a zero'd out .sav file, so it's not quite intelligent enough to initialize the SRAM itself. Anyway, let me know if you know a place that has a good walkthrough on the enable for the SRAM. Thanks!
Enabling SRAM on MBC1 is done by writing #$0A to anywhere between $0000-$1FFF I believe. Write anything else to disable the RAM. On real hardware, it may be that you should only enable RAM while accessing it (reading or writing) and disabling it after copying the contents somewhere else or reading them directly. This way when the player powers down, the RAM will not be enabled and cannot be corrupted.
You'd want to program the game so that it only writes to the save SRAM when a new high score is achieved. This will be often, since each time a piece is placed after the high score is initially achieved will be a new high score. Since this is SRAM and not flash, frequent writes are not a problem. You should make a checksum algorithm so that you know a save is corrupted - and when the data is blank to begin with at first boot. This could set the high score to 10,000 or whatever it's supposed to be. Additionally, you will want to have at least two save "files" that you rotate among as you save. Have a byte in each file that means "this file is valid" that is separate from the checksum. When you save, write that byte to mark the save as "invalid" as the first thing you do. Save the score and whatever other data to the slot/file, write the checksum, then finally set the valid flag to "valid". If power is lost, look through all save files for the file with the highest score that has "valid" set. (An alternate solution to this is to save twice to separate locations each time, which is what Breath of Fire 1 did.) All this is about is reliability. You are up against unpredictable hostile forces known as the "system battery" and the "power switch" =). Literally at any instruction or even in the middle of executing part of an instruction, your program can cease to exist, so you have to code save routines under this assumption.