Most importantly is that I found out how to differ between a cold start and pressing the RESET button. It turns out the Z flag in the 6502 is set when the RESET button is pressed, and the BIOS routine at $F808 begins with checking that flag. If it is set, it quickly jumps to the indirect pointer as specified by the cartridge. Only in case Z=0, the Creativision message is displayed, and thanks to how the loops work, the Z flag will remain cleared after exiting that routine.
It means the very first thing to do in the game code, perhaps after any SEI to disable interrupts, is to store the value of the Z flag or even the whole status register. Once we start doing things with the accumulator, any other register or memory address, the Z flag will be changed so in order to determine demo or game mode this is how the code should begin:
Code: Select all
realgame eqm $xxxx ; variable of your choice, I'm using $80-$ff and $0300-$03ff
org $A000 ; for an 8K game
Start:
php
pla
and #2
sta realgame ; will be 2 if RESET was pushed, 0 otherwise
...
lda realgame
bne selectmode ; NOT EQUAL value != 0, EQUAL value == 0
demogame:
...
jmp demogame
selectmode:
...