; This is the main loop. ; Of course it could be done without a buffer, but now we ; are building the scroll element the way it will look in the ; finished game.... mloop halt ; start main loop with vblank. ; Update vdp right when vblank begins! ld a,(scroll) ; 1-byte scroll reg. buffer in ram. ld b,9 ; target VDP register 9 (v-scroll). call setreg ; now vdp register = buffer, and the ; screen scrolls accordingly. ; Blah blah ... in the game, lots of stuff goes on here.... ; and then, towards the end... ; Scroll background - update the vertical scroll buffer. ld a,(scroll) ; get scroll buffer value. sub vspeed ; subtract vertical speed. ld (scroll),a ; update scroll buffer. jp mloop ; jump back for another round. ; -------------------------------------------------------------- ; SET VDP REGISTER. ; Write to target register. ; A = byte to be loaded into vdp register. ; B = target register 0-10. setreg out ($bf),a ; output command word 1/2. ld a,$80 or b out ($bf),a ; output command word 2/2. ret