Game delay based on rendering, render Willy twice

This commit is contained in:
StewBC 2021-04-30 14:14:12 -07:00
parent 68e9db4f51
commit 7909d6e051

View File

@ -24,11 +24,11 @@ playLoop:
lda demoMode ; check for demo mode
beq :+ ; if not demo, move willy
jsr gameDemoTick ; tick the demo if demo mode
jmp :++ ; skip moving willy
jsr gameDemoTick ; demo mode so run demo
jmp ai ; skip moving willy
:
jsr willyMove ; move the main character based on user input (or conveyor or gravity)
:
ai:
jsr gameAI ; run all the monster AI
ldx fullScreenClearCount ; get the flag for what level of screen clear is needed
@ -40,15 +40,21 @@ playLoop:
jsr screenDrawSprites ; draw all the enemies
lda demoMode ; get the event state
bne :+ ; if so skip showing willy
beq :+ ; 0 - not demo, full flow
jsr screenDrawLevel ; show all the tiles in demo mode
jmp ui
:
lda #$ff ; Enable Collision detection
jsr screenDrawWilly ; not demo - draw willy with collision detection
bcc :+ ; carry set is a collision, clear is no problem
bcc level ; carry set is a collision, clear is no problem
lda eventState ; on collision, set the die event
ora #EVENT_DIED
sta eventState
:
level:
jsr screenDrawLevel ; show all the tiles
lda #0 ; No collision detection
jsr screenDrawWilly ; Now draw willy over self and level, no collision
ui:
lda updateUICount ; see if the UI needs an update
beq :+
jsr uiUpdate ; if needed, update the appropriate UI components
@ -59,6 +65,7 @@ playLoop:
jsr screenSwap ; swap to the newly rendered screen
jsr audioPlayNote ; play in-game music if needed
jsr gameDelay ; waste time to get all screens to run at same rate
lda eventState ; see if any events fired
beq playLoop ; keep looping while no events
@ -79,6 +86,26 @@ playLoop:
.endproc
;-----------------------------------------------------------------------------
.proc gameDelay
lda #$80 ; max tiles ever visible is $CD, but delay only up to $80
sec
sbc tilesRendered ; how many were shown
bcc done
tax ; delta in x
:
ldy #49 ; delay 246 cycles per non-rendered tile
:
dey
bne :-
dex ; and do it for all tiles not rendered (<$80)
bne :--
done:
rts
.endproc
;-----------------------------------------------------------------------------
.proc gameNewGame