Otherwise I figured I would add a hidden self-test into the program, that's easy enough too.
Any ideas on how to build a self-test program for CHR RAM? I could probably bind it to Select+Reset. I wrote "memtestARM", which applies the modulo X algorithm of
memtest86 to test a RAM pak plugged into a DS. The methodology I can think of makes 39 passes over CHR RAM:
- Test each bit in each byte. For each byte in $00, $FF, $5A, $A5, $01, $02, $04, $08, $10, $20, $40, $80, $FE, $FD, $FB, $F7, $EF, $DF, $BF, $7F: Fill RAM and then read it all back.
- Modulo X test. For each offset from 0 to 18, fill RAM with $AA where address MOD 19 = the offset and $55 otherwise, then read it back.
Umm, sounds good to me
You'll certainly need to disable rendering so this doesn't take an eternity.
Sounds good, I coded one before that does WRAM and CHR-RAM, if you'd rather adapt a pre-made one let me know and I'll upload it. I just looked at the date on it, from 2003, I wrote it then because I was trying to help Ronen Habot make his NES MaxiCart - after that, I started getting serious about learning hardware design.
No graphics are needed, just a beep and/or changing the monochrome bit or palette would be enough, I think.
It would be nice too to have it check that the banks are all selectable, if there are graphic routines in place already, printing a checksum of the entire ROM would be cool (ROM will already be verified of course, but people can watch for bit-rot or something, heheh). But having something like $00-$0F at the same address in every bank and checking that would be useful. That would be a lot better than having to test every game on every cart before shipping. Bad parts and bad boards are unlikely, but possible.
I've got the constant test (for bad data connections) and the mod 19 test (for bad address connections) working. They change the background color while working and play a tone when they finish or fail.
My next step is to add code that computes a
simple 16-bit hash of each PRG bank. That'll have to run from RAM due to no fixed bank, but by that time, we can load tiles because we know the CHR RAM works, and that way it will have access to display hex digits on the screen.
A day later, I've got them running on my PowerPak. Select+Reset in the multicart performs VRAM check (with rendering disabled and the background color slowly cycling during the 39 passes) and ROM check (display CRC-16 of each bank) before the title screen. I used a debugger to force some errors in the VRAM check and it correctly froze on a red screen of death and "disappointing" tone.