; Atari 5200 "how long to show the picture" epilogue (no OS, pure hardware). ; Selected at assembly time by WAITMODE (set by a5200/viewer/assemble.py): ; 0 forever -- just loop ; 1 until a button -- poll the keypad (POKEY) and triggers (GTIA), then reset ; 2 WAITSECS secs -- count frames via ANTIC VCOUNT, then reset ; "Exit" jumps through the BIOS reset vector, which re-runs the cartridge and so ; re-displays the picture (a cartridge console has no OS to return to). #if WAITMODE == 0 awloop: jmp awloop #endif #if WAITMODE == 1 lda #$03 sta $e80f ; POKEY SKCTL -- enable keypad scanning awloop: lda $c010 ; GTIA TRIG0 (fire button); 0 = pressed and #$01 beq awexit lda $e80f ; POKEY SKSTAT; bit2 = 0 while a keypad key is down and #$04 bne awloop awexit: jmp ($fffc) ; BIOS reset -> re-display #endif #if WAITMODE == 2 lda #<(WAITSECS*RATE) sta $80 lda #>(WAITSECS*RATE) sta $81 awloop: lda $80 ora $81 beq awexit ; counted all the frames vw1: lda $d40b ; ANTIC VCOUNT bne vw1 ; wait for top of frame (VCOUNT = 0) vw2: lda $d40b beq vw2 ; wait until it leaves the top -> one frame elapsed lda $80 sec sbc #$01 sta $80 lda $81 sbc #$00 sta $81 jmp awloop awexit: jmp ($fffc) ; BIOS reset -> re-display #endif