So I finally figured out the problem after hours of debugging and writing special visual debug feedback. Seems there’s something really strange about the CD base ram. I’ll explain…
In the NES emulator, the NES has ZP and ram mapped to $0000-1fff address range. It’s only 2k, but it’s mirrored. The space right above it isn’t used (open bus I think or possible more mirrored ram). So on the PCE to get the NES code to run natively, you make the *same* ram bank to both pages: $0000 and $2000. The $2000 covers the ZP address and the stack pointer address of the PCE’s processor, but the NES code doesn’t see it as any different. The $0000 area acts as it should. Normally, PCE games map in the hardware bank into MPR 0 or page $0000. But I map bank $ff into page $6000 range. At least for the NES games that don’t use extra onbard sram (I can’t do that for dragon warrior, so I used self modifying code and ST0/ST1/ST2 opcodes for writes. Vram reads are a little slower because I have to swap the bank in and out of some page area).
Anyway, this isn’t a problem for system ram bank $f8. Why don’t I just use that? I could, but I had plans… plans for adding adpcm, loading, cdda playback. For that, there are special address ranges that are reserved for the system card functions. The emulation core would completely destroy them. So I swap in that $f8 when I call a sys card function, but otherwise I use some other ram bank.
So this is where I got into trouble. Apparently (apparently now!) there’s something amidst about that bank of ram. Normally, there’s nothing to think about. I mean, it’s mapped all over the place like normal rom. Nothing is different. And Charles has stated they he’s used the bank $80-87 as page $2000 ram without problems. I on the other hand was getting corruptions in ram. It upgraded a number of games to figure out why. SMB really got my attention. The game actually played, but was really corrupt (raining coins! turtles coming out of the power blocks when you hit them!). Assuming what charles recalls is true, the only difference between his scenario and mine, is that I also have the CD base banks mapped to page $0000 range and was directly accessing them.
wtf? So I mapped in ‘card’ ram. Ram the normally resided on the upgrade card (although on my SuperCDROM 2 it’s just in the unit itself). Voila. Corruption went away in SMB and the other games didn’t crash before the title screen.
Let me tell you, I NEVER saw that coming. Not in a million years. Take heed if you’re a PCE coder. That really is some bullshit.
Also… these CDRs I just bought… are totally shitty. And my new Blu-ray burner is a piece of crap for burning CDRs too.