Skip to content

Commit

Permalink
NTSC sound fix
Browse files Browse the repository at this point in the history
  • Loading branch information
laoo committed May 23, 2018
1 parent 5c6b417 commit 88b2548
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 20 deletions.
8 changes: 6 additions & 2 deletions common/gameInit.asm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
ldx #$80
@ sta $00,x
inx
cpx #$3f
cpx #$3e
bne @-
;A=0
Expand All @@ -26,7 +26,6 @@
sta player.animationDelay
sta playerShotDelay
sta playerFrameDraw
sta gameSFXAllow
sta extraLifeValue ; first extra life after 10.000 (value 1 = 10.000 points)
sta firstRun
sta gameCurrentLevel
Expand All @@ -42,6 +41,9 @@

lda levelInformation.levelBackgroundColor ; first transition color
sta playfieldTransition.color+1
lda ntsc
sta ntsc_counter
rts

.endp
Expand All @@ -54,6 +56,8 @@
beq @+
jsr prepareForRapidus
@ jsr setFakeDlist
lda $f600 ; determined in loadGameGraphic
sta ntsc
jmp enableNMI
.endp

Expand Down
4 changes: 3 additions & 1 deletion common/memoryLayout.asm
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ playerFrameDraw equ zeroPage+7 ; 1 byte flag if we have to draw new player fra
.endl
gamePaused equ zeropage+12 ; 1 byte 0 - game is running | 1 - game is paused
gamePauseDelay equ zeropage+13 ; 1 byte delay before we can unpause/pause the game
gameSFXAllow equ zeroPage+14 ; 1 byte
gameSFXAllow equ zeroPage+14 ; 1 byte [NOT USED ANYMORE]
playerMovementAllow equ zeroPage+15 ; 1 byte
bufScreenNr equ zeroPage+16 ; 1 byte | high byte of screen address
OLPCounter equ zeroPage+17 ; 1 byte | temporal counter for object list (OLP) used in various logic
Expand Down Expand Up @@ -61,6 +61,8 @@ enemyBombCounter equ zeropage+53 ; 1 byte enemy bombs counter
rapidusDetected equ zeropage+54 ; 1 byte 0 - running on 6502, $80 - running on 65c816.
fntAlloc equ zeroPage+55 ; 4 bytes fonts for enemies

ntsc equ zeropage+$3e ; 0 = PAL; other value = NTSC counter for VBL skip
ntsc_counter equ zeropage+$3f ; skip VBL sound by this frames; 0 to disable NTSC (during gameplay, FX)
globalVelocityBuffer equ zeropage+$40 ; -$7f ($3f bytes) fast global velocity buffer
.local levelCurrent ; information about current level
Expand Down
10 changes: 8 additions & 2 deletions common/nmi/inc/playfieldSoundVBL.asm
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@
beq @+
rts
@
lda gameSFXAllow
beq skipSFX
lda ntsc_counter
beq @+
dec ntsc_counter
bne @+
lda #7
sta ntsc_counter
rts
@
sfxStart
ldx #3
Expand Down
4 changes: 3 additions & 1 deletion common/titleScreen.asm
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
lda SCORE.doHighScoreFlag
beq titleLoop
lda ntsc
sta ntsc_counter
jmp SCORE.doHighScore
titleLoop
Expand All @@ -44,7 +46,7 @@ mode0
jmp skip
mode1
jsr titleScreenMode1
jmp skip
bne skip
mode2
jsr titleScreenMode2
jmp skip
Expand Down
32 changes: 19 additions & 13 deletions engine/levelProcedures.asm
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
; Level Procedures

.proc level
init jmp levelInit ; X = level number
mainLoop jmp levelMainLoop
killEnemy jmp levelKillEnemy
nextLevelPrepare jmp levelNextLevelPrepare
nextLevelTeleport jmp levelNextLevelTeleport
nextLevel jmp levelNextLevel
; init - inits level ; X = level number
; mainLoop - main level loop
; killEnemy - progress bar
; nextLevelPrepare - preparation for next level
; nextLevelTeleport - teleport
; nextLevel - sets all needed stuff for next level

; ---------------------------------------------
; LEVEL MAIN LOOP - jump here every gameLoop
; ---------------------------------------------

.proc levelMainLoop
.proc mainLoop

lda playerGameOver
beq playLevel
Expand All @@ -34,6 +34,9 @@ playLevel
bne @+
inc levelCurrent.allowSpawns ; 0 -> 1
lda #0
sta ntsc_counter
; dli mode for level gameplay | setup once after spawns are allowed
jsr waitFrameNormal
jsr clearLevelName
Expand Down Expand Up @@ -80,7 +83,7 @@ noHiScore
sta DLIDispatch.mode+1
jmp level.showGameOver
@
jmp level.levelInit.levelReset
jmp level.init.levelReset
playerNotDestroyed
; next level?
Expand All @@ -104,7 +107,7 @@ nextLevelLoop
; NEXT LEVEL PREPARE
; --------------------

levelNextLevelPrepare
nextLevelPrepare
inc nextLevelInited
lda #0
Expand All @@ -124,7 +127,7 @@ nextLevelInited dta b(0)
; X = level number
; ---------------------

.proc levelNextLevelTeleport
.proc nextLevelTeleport

lda RMT.trackn_idx ; synchronize teleport main animation with RMT subsong
cmp #101
Expand Down Expand Up @@ -398,7 +401,7 @@ fnt .he 00 00 00 00 00 00 00 ff
; X = level number
; ----------------

.proc levelNextLevel
.proc nextLevel
jsr hidePlayer
jsr initPlayfieldPMColors
Expand Down Expand Up @@ -449,7 +452,7 @@ finish
; INIT LEVEL
; X = level number
; ----------------
.proc levelInit
.proc init
dex
stx levelNumber
txa
Expand Down Expand Up @@ -681,6 +684,9 @@ skipLevelName
lda #1
sta levelFullyInited
lda ntsc
sta ntsc_counter
jmp showPlayer
; local data for routines
Expand Down Expand Up @@ -892,7 +898,7 @@ counter dta b(0)
; KILL ENEMY
; X = enemy number
; ----------------
.proc levelKillEnemy
.proc killEnemy
lda levelCurrent.tokill
beq @+
dec levelCurrent.tokill
Expand Down
10 changes: 9 additions & 1 deletion loader/loadGameGraphic.asm
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,15 @@ copyFm4 equ $5400 ; $200
.endr
inx
bne @-

; determines PAL or NTSC
ldx $d014
dex
beq @+
ldx #7
@
stx $f600 ; game reads it and store information on zero page
; finish
jmp loader.enableOS

Expand Down

0 comments on commit 88b2548

Please sign in to comment.