Fixed Game Speed

This commit is contained in:
StewBC 2021-07-13 17:42:29 -07:00
parent 4ab8bdd6aa
commit e9802e906e
2 changed files with 17 additions and 28 deletions

View File

@ -95,24 +95,7 @@ reset:
lda audioMask ; see if the music is on
and #AUDIO_MUSIC
bne play
ldx #0 ; kill approx 6800 cycles (average cycles for playNote when on)
:
nop ; 2 cycles
nop ; 4
nop ; 6
nop ; 8
nop ; 10
nop ; 12
nop ; 14
nop ; 16
nop ; 18
nop ; 20
nop ; 22
dex ; 24 cycles
bne :- ; 26 cycles * 256 = 6656 cycles - close enough
rts
beq done
play:
ldx musicL ; get the index into the in-game music
@ -120,7 +103,7 @@ play:
lda inGameMusic, x ; get the note at the index
bne :+ ; if non-zero it's a valid note
sta musicL ; reset the index to the start of the song
beq :-
beq play
:
ldy #$08 ; fixed number of iterations
@ -128,8 +111,7 @@ freq: ; external entry point for custo
sta delayTime ; store it in a delay counter
lda audioMask ; see if
and #AUDIO_SOUND ; audio is enabled
bne loop ; and play or ignore audio accordingly
rts
beq done ; and play or ignore audio accordingly
loop:
lda SPEAKER ; toggle the speaker
@ -140,6 +122,7 @@ loop:
dey ; then repeat
bne loop ; for the fixed iterations
done:
rts ; and return
.endproc

View File

@ -89,13 +89,19 @@ ui:
;-----------------------------------------------------------------------------
.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
delayTime = tmpBot + 0
lda #$10
sta delayTime
delayCalc:
sec
lda #$D0
sbc tilesRendered
bcc done
tax
:
ldy #49 ; delay 246 cycles per non-rendered tile
ldy delayTime
:
dey
bne :-
@ -104,7 +110,7 @@ ui:
done:
rts
.endproc
.endproc
;-----------------------------------------------------------------------------
.proc gameNewGame