diff --git a/src/data.asm b/src/data.asm index 9908ac8..e644466 100644 --- a/src/data.asm +++ b/src/data.asm @@ -46,3 +46,7 @@ levelN: delayStatus: BYTE +; Total score of the game +score: + WORD + diff --git a/src/game.asm b/src/game.asm index dbaa478..e433baf 100644 --- a/src/game.asm +++ b/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 diff --git a/src/gameover.asm b/src/gameover.asm index bff40c2..674518d 100644 --- a/src/gameover.asm +++ b/src/gameover.asm @@ -2,10 +2,15 @@ ; ---------------------------------------------------------------------- gameover: 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 diff --git a/src/initdata.asm b/src/initdata.asm index 1b3213c..c57b7c1 100644 --- a/src/initdata.asm +++ b/src/initdata.asm @@ -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 diff --git a/src/gamereset.asm b/src/levelreset.asm similarity index 81% rename from src/gamereset.asm rename to src/levelreset.asm index 350fe4e..73be5ef 100644 --- a/src/gamereset.asm +++ b/src/levelreset.asm @@ -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 + 1 - rts diff --git a/src/levels.asm b/src/levels.asm index bcd2958..6462f54 100644 --- a/src/levels.asm +++ b/src/levels.asm @@ -2,7 +2,6 @@ statusLevelTitle SUBROUTINE jsr clearScreen -.back: ; Print "Next Level" 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) diff --git a/src/main.asm b/src/main.asm index a878648..1776923 100644 --- a/src/main.asm +++ b/src/main.asm @@ -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" diff --git a/src/program.asm b/src/program.asm index 84adf94..9b8387e 100644 --- a/src/program.asm +++ b/src/program.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 + 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) diff --git a/src/subroutines.asm b/src/subroutines.asm index 046eb77..bbfc5f1 100644 --- a/src/subroutines.asm +++ b/src/subroutines.asm @@ -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: diff --git a/src/zeropage.asm b/src/zeropage.asm index 0d277bc..ef7f56e 100644 --- a/src/zeropage.asm +++ b/src/zeropage.asm @@ -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