Moved gamereset routine to external file

This commit is contained in:
giomba 2018-09-16 18:20:48 +02:00
parent fcc479eaed
commit 868d1e6253
2 changed files with 72 additions and 69 deletions

69
gamereset.asm Normal file
View File

@ -0,0 +1,69 @@
; Full game reset
; ----------------------------------------------------------------------
gamereset:
; Turn MultiColor mode on
jsr multicolorOn
; Clear screen
ldx #$00
lda #$20
fullresetCLS:
dex
sta $400,x
sta $500,x
sta $600,x
sta $700,x
cpx #$00
bne fullresetCLS
; Set overscan
lda #11
sta $d020
; Upper bar -- fill with reversed spaces, color yellow
ldx #39
upperbarLoop:
lda #$a0 ; reversed color space
sta $400,x
lda #7
sta $d800,x
dex
cpx #$ff
bne upperbarLoop
; Set upper bar text
lda #<scoreString
sta printStatusString
lda #>scoreString
sta printStatusString + 1
jsr printStatus
; Init game variables
lda #FOOD_TILE
sta $500 ; Put first piece of food
lda #4
sta irqn ; Initialize interrupt divider
lda #6
sta direction ; Snake must go right
; Note: these values depends on following list initialization
lda #19
sta snakeX ; Snake is at screen center width...
lda #12
sta snakeY ; ... and height
lda #5
sta listStart ; Beginning of snake tiles list
lda #5
sta length ; Length of the list
; Clear snake lists X and Y
ldx #$00
clearListLoop:
dex
lda #19
sta listX,x
lda #12
sta listY,x
cpx #$00
bne clearListLoop
rts

View File

@ -190,7 +190,8 @@ intro0end:
lda #ST_PAUSE
sta status
; Set init variables of the game
jsr fullreset
jsr gamereset
; Set status as game playing
lda #ST_PLAY
sta status
@ -206,74 +207,7 @@ endless:
sta status ; put machine into play intro status
jmp intro0running ; and go there waiting for keypress
; Full game reset
; ----------------------------------------------------------------------
fullreset:
; Turn MultiColor mode on
jsr multicolorOn
; Clear screen
ldx #$00
lda #$20
fullresetCLS:
dex
sta $400,x
sta $500,x
sta $600,x
sta $700,x
cpx #$00
bne fullresetCLS
; Set overscan
lda #11
sta $d020
; Upper bar -- fill with reversed spaces, color yellow
ldx #39
upperbarLoop:
lda #$a0 ; reversed color space
sta $400,x
lda #7
sta $d800,x
dex
cpx #$ff
bne upperbarLoop
; Set upper bar text
lda #<scoreString
sta printStatusString
lda #>scoreString
sta printStatusString + 1
jsr printStatus
; Init game variables
lda #FOOD_TILE
sta $500 ; Put first piece of food
lda #4
sta irqn ; Initialize interrupt divider
lda #6
sta direction ; Snake must go right
; Note: these values depends on following list initialization
lda #19
sta snakeX ; Snake is at screen center width...
lda #12
sta snakeY ; ... and height
lda #5
sta listStart ; Beginning of snake tiles list
lda #5
sta length ; Length of the list
; Clear snake lists X and Y
ldx #$00
clearListLoop:
dex
lda #19
sta listX,x
lda #12
sta listY,x
cpx #$00
bne clearListLoop
rts
INCLUDE "gamereset.asm"
; Intro reset
; ----------------------------------------------------------------------