level change + score management
This commit is contained in:
parent
cd1820d834
commit
4498d045de
@ -46,3 +46,7 @@ levelN:
|
||||
delayStatus:
|
||||
BYTE
|
||||
|
||||
; Total score of the game
|
||||
score:
|
||||
WORD
|
||||
|
||||
|
25
src/game.asm
25
src/game.asm
@ -203,9 +203,24 @@ overEndCheck:
|
||||
beq foodEaten ; if memory does contain food, then perform foodEaten actions,
|
||||
jmp checkSelfEat ; else just loooong jump to test if I ate myself
|
||||
foodEaten:
|
||||
ldx length ; else, increment snake length,
|
||||
ldx length ; else, increment snake length
|
||||
inx
|
||||
stx length
|
||||
|
||||
cpx #$10 ; check if level is finished
|
||||
bne genFood ; if not, skip
|
||||
clc
|
||||
lda score ; else increment total score
|
||||
adc length
|
||||
sta score
|
||||
lda score + 1
|
||||
adc #$0
|
||||
sta score + 1
|
||||
jsr levelresetvar ; reset vars and go to next level
|
||||
lda #ST_LEVEL_TITLE
|
||||
sta status
|
||||
rts
|
||||
|
||||
genFood:
|
||||
ldx random
|
||||
inx
|
||||
@ -241,10 +256,10 @@ genFoodY: ; calculate `random` modulo 22 (22 = SCREEN_H - 1)
|
||||
foodOK:
|
||||
#if DEBUG = 1
|
||||
; print choosen X,Y for food
|
||||
ldy #$18
|
||||
ldy #14
|
||||
lda calcTileX
|
||||
jsr printByte
|
||||
ldy #$1b
|
||||
ldy #17
|
||||
lda calcTileY
|
||||
jsr printByte
|
||||
#endif
|
||||
@ -264,8 +279,8 @@ foodOK:
|
||||
lda FOOD_COLOR
|
||||
sta (tileMem),y
|
||||
|
||||
; print score at $10th column
|
||||
ldy #$10
|
||||
; print partial
|
||||
ldy #36
|
||||
lda length
|
||||
jsr printByte
|
||||
|
||||
|
@ -2,10 +2,15 @@
|
||||
; ----------------------------------------------------------------------
|
||||
gameover:
|
||||
lda #<gameoverString
|
||||
sta printStatusString
|
||||
sta printIntroString
|
||||
lda #>gameoverString
|
||||
sta printStatusString + 1
|
||||
jsr printStatus
|
||||
sta printIntroString + 1
|
||||
|
||||
lda #$00
|
||||
sta introScreenStart
|
||||
lda #$04
|
||||
sta introScreenStart + 1
|
||||
jsr printIntro
|
||||
|
||||
; Set gameover and outro status
|
||||
lda #$ff
|
||||
|
@ -84,7 +84,7 @@ levelIntroString:
|
||||
colorshade: ; a gradient of dark-bright-dark (40 columns)
|
||||
HEX 0b 0b 0b 0b 0b 0c 0c 0c 0c 0c 05 05 05 0d 0d 0d 0d 07 07 07 07 07 07 0d 0d 0d 0d 05 05 05 0c 0c 0c 0c 0c 0b 0b 0b 0b 0b
|
||||
scoreString:
|
||||
BYTE "POINTS"
|
||||
BYTE "SCORE PART"
|
||||
BYTE #0
|
||||
|
||||
; Levels
|
||||
|
@ -1,6 +1,6 @@
|
||||
; Full game reset
|
||||
; Reset variables for a new level
|
||||
; ----------------------------------------------------------------------
|
||||
gamereset:
|
||||
levelresetvar:
|
||||
; Turn MultiColor mode on
|
||||
jsr multicolorOn
|
||||
|
||||
@ -30,11 +30,5 @@ clearListLoop:
|
||||
cpx #$00
|
||||
bne clearListLoop
|
||||
|
||||
; Set current level pointer to list start
|
||||
lda #<levelsList
|
||||
sta levelPointer
|
||||
lda #>levelsList
|
||||
sta levelPointer + 1
|
||||
|
||||
rts
|
||||
|
@ -2,7 +2,6 @@
|
||||
statusLevelTitle SUBROUTINE
|
||||
jsr clearScreen
|
||||
|
||||
.back:
|
||||
; Print "Next Level"
|
||||
lda #<levelIntroString
|
||||
sta printIntroString
|
||||
@ -45,21 +44,33 @@ statusLevelTitle SUBROUTINE
|
||||
statusLevelLoad SUBROUTINE
|
||||
; Upper bar -- fill with spaces, color yellow
|
||||
ldx #39
|
||||
upperbarLoop:
|
||||
.loop:
|
||||
lda #$0
|
||||
sta $400,x
|
||||
lda #7
|
||||
sta $d800,x
|
||||
dex
|
||||
cpx #$ff
|
||||
bne upperbarLoop
|
||||
bne .loop
|
||||
|
||||
; Set upper bar text
|
||||
; Set upper bar score/part text
|
||||
lda #<scoreString
|
||||
sta printStatusString
|
||||
sta printIntroString
|
||||
lda #>scoreString
|
||||
sta printStatusString + 1
|
||||
jsr printStatus
|
||||
sta printIntroString + 1
|
||||
lda #$14
|
||||
sta introScreenStart
|
||||
lda #$04
|
||||
sta introScreenStart + 1
|
||||
jsr printIntro
|
||||
|
||||
; Set score
|
||||
ldy #26
|
||||
lda score + 1
|
||||
jsr printByte
|
||||
ldy #28
|
||||
lda score
|
||||
jsr printByte
|
||||
|
||||
; initialize video pointer with first video memory address
|
||||
; (skip first line, used for the status bar)
|
||||
|
@ -57,7 +57,7 @@ tggsFont:
|
||||
|
||||
INCLUDE "game.asm"
|
||||
INCLUDE "gameover.asm"
|
||||
INCLUDE "gamereset.asm"
|
||||
INCLUDE "levelreset.asm"
|
||||
INCLUDE "introreset.asm"
|
||||
INCLUDE "intro1.asm"
|
||||
INCLUDE "multicolor.asm"
|
||||
|
@ -69,8 +69,19 @@ intro0running: ; Cycle here until SPACE or `Q` is pressed
|
||||
|
||||
; Intro is finished, now it's time to start the proper game
|
||||
intro0end:
|
||||
; Set init variables of the game
|
||||
jsr gamereset
|
||||
; Set current level pointer to list start
|
||||
lda #<levelsList
|
||||
sta levelPointer
|
||||
lda #>levelsList
|
||||
sta levelPointer + 1
|
||||
|
||||
; clear score
|
||||
lda #$00
|
||||
sta score
|
||||
sta score + 1
|
||||
|
||||
; Set init variables of the level
|
||||
jsr levelresetvar
|
||||
|
||||
; Set status as level select
|
||||
; (then it will enter in status play)
|
||||
|
@ -87,25 +87,6 @@ printByte SUBROUTINE
|
||||
|
||||
rts
|
||||
|
||||
; Print null-terminated string on status bar
|
||||
; address of string is given in input using memory location printStatusString
|
||||
printStatus SUBROUTINE
|
||||
ldy #0
|
||||
printStatusLoop:
|
||||
lda (printStatusString),y
|
||||
beq printStatusEnd
|
||||
cmp #$20
|
||||
bne printStatusSkipSpace
|
||||
lda #$40 ; space + $40
|
||||
printStatusSkipSpace:
|
||||
sec
|
||||
sbc #$40 ; convert from standard ASCII to Commodore screen code
|
||||
sta $413,y
|
||||
iny
|
||||
jmp printStatusLoop
|
||||
printStatusEnd:
|
||||
rts
|
||||
|
||||
printIntro SUBROUTINE
|
||||
; Print string for intro
|
||||
; Input parameters:
|
||||
|
@ -4,10 +4,7 @@
|
||||
; using pointer at tileMem,tileMem+1
|
||||
tileMem DS 2
|
||||
|
||||
; Pointer to status string
|
||||
printStatusString DS 2
|
||||
|
||||
; Pointer to intro string
|
||||
; Pointer to string
|
||||
printIntroString DS 2
|
||||
; Pointer to screen position where to print intro string
|
||||
introScreenStart DS 2
|
||||
|
Loading…
Reference in New Issue
Block a user