From cd1820d834c3c58e836470f8a26a6182f8b6aa51 Mon Sep 17 00:00:00 2001 From: giomba Date: Wed, 8 Apr 2020 09:15:25 +0200 Subject: [PATCH] level introduction screen --- res.org/levels.txt | 12 ++++----- src/data.asm | 4 +++ src/gameover.asm | 6 +++-- src/gamereset.asm | 18 ------------- src/initdata.asm | 17 +++++++----- src/introreset.asm | 12 +-------- src/levels.asm | 63 ++++++++++++++++++++++++++++++++++++++++++++- src/outro.asm | 17 +++++------- src/program.asm | 26 ++++++++++--------- src/subroutines.asm | 21 +++++++++++++++ util/rlevel.cpp | 2 +- 11 files changed, 130 insertions(+), 68 deletions(-) diff --git a/res.org/levels.txt b/res.org/levels.txt index ec81285..76e7a83 100644 --- a/res.org/levels.txt +++ b/res.org/levels.txt @@ -1,20 +1,20 @@ -TITLE +TRAINING xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -x fffffffffff x x x x x x x x x x x x x +x x +..................fff................... +........................................ +........................................ +........................................ ........................................ ........................................ ........................................ ........................................ -x x -x x -x x -x x x x x x x x diff --git a/src/data.asm b/src/data.asm index 906dd6b..9908ac8 100644 --- a/src/data.asm +++ b/src/data.asm @@ -42,3 +42,7 @@ levelT: levelN: BYTE +; next status after delay +delayStatus: + BYTE + diff --git a/src/gameover.asm b/src/gameover.asm index a68cf87..bff40c2 100644 --- a/src/gameover.asm +++ b/src/gameover.asm @@ -9,8 +9,10 @@ gameover: ; Set gameover and outro status lda #$ff - sta outroDelay - lda #ST_OUTRO + sta delay + lda #ST_END + sta delayStatus + lda #ST_DELAY sta status rts diff --git a/src/gamereset.asm b/src/gamereset.asm index b34a7a7..350fe4e 100644 --- a/src/gamereset.asm +++ b/src/gamereset.asm @@ -4,24 +4,6 @@ gamereset: ; Turn MultiColor mode on jsr multicolorOn - ; Upper bar -- fill with spaces, color yellow - ldx #39 -upperbarLoop: - lda #$0 - sta $400,x - lda #7 - sta $d800,x - dex - cpx #$ff - bne upperbarLoop - - ; Set upper bar text - lda #scoreString - sta printStatusString + 1 - jsr printStatus - ; Init game variables lda #4 sta irqn ; Initialize interrupt divider diff --git a/src/initdata.asm b/src/initdata.asm index 2ea22e0..1b3213c 100644 --- a/src/initdata.asm +++ b/src/initdata.asm @@ -11,21 +11,21 @@ introX: introXinc: BYTE #$1 -; Outro delay -outroDelay +; Delay +delay: BYTE #$ff - ; Costants ; ---------------------------------------------------------------------- ; Status of the game (costants pre-processor defined, sort of enum) ST_INTRO0 = 0 ST_INTRO1 = 1 -ST_LEVELSELECT = 2 -ST_PLAY = 3 -ST_OUTRO = 4 -ST_END = 5 +ST_LEVEL_TITLE = 2 +ST_LEVEL_LOAD = 3 +ST_PLAY = 4 +ST_DELAY = 5 +ST_END = 6 ST_PAUSE = 255 ; Screen features @@ -78,6 +78,9 @@ intro3string: BYTE "(C) 2018" #endif BYTE #0 +levelIntroString: + BYTE "NEXT LEVEL" + BYTE #0 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: diff --git a/src/introreset.asm b/src/introreset.asm index af66956..ca374cf 100644 --- a/src/introreset.asm +++ b/src/introreset.asm @@ -3,17 +3,7 @@ introreset: jsr multicolorOff - ; Clear screen - ldx #$ff - lda #$00 -introresetCLS: - sta $400,x - sta $500,x - sta $600,x - sta $700,x - dex - cpx #$ff - bne introresetCLS + jsr clearScreen ; Copy shade colors from costant table to color RAM for 2nd and 4th line of text ldx #39 diff --git a/src/levels.asm b/src/levels.asm index 3743610..bcd2958 100644 --- a/src/levels.asm +++ b/src/levels.asm @@ -1,5 +1,66 @@ ; load new level on the screen -statusLevelSelect: +statusLevelTitle SUBROUTINE + jsr clearScreen + +.back: + ; Print "Next Level" + lda #levelIntroString + sta printIntroString + 1 + + lda #$00 + sta introScreenStart + lda #$04 + sta introScreenStart + 1 + jsr printIntro + + ; Print level Title + lda levelPointer + sta printIntroString + lda levelPointer + 1 + sta printIntroString + 1 + + lda #$e2 + sta introScreenStart + lda #$05 + sta introScreenStart + 1 + jsr printIntro + + ; advance level pointer, based on title string length + iny + tya + tax + lda #levelPointer + sta nextPointerPointer + jsr nextPointer + + ; wait + lda #ST_LEVEL_LOAD + sta delayStatus + lda #ST_DELAY + sta status + rts + +statusLevelLoad SUBROUTINE + ; Upper bar -- fill with spaces, color yellow + ldx #39 +upperbarLoop: + lda #$0 + sta $400,x + lda #7 + sta $d800,x + dex + cpx #$ff + bne upperbarLoop + + ; Set upper bar text + lda #scoreString + sta printStatusString + 1 + jsr printStatus + ; initialize video pointer with first video memory address ; (skip first line, used for the status bar) ldy #39 diff --git a/src/outro.asm b/src/outro.asm index 5c9df74..d283c2b 100644 --- a/src/outro.asm +++ b/src/outro.asm @@ -1,16 +1,13 @@ -; Decrement outroDelay, just to let player see her/his end screen -; with score -statusOutro: - ldy outroDelay ; load outroDelay and decrement +; Wait for some delay +statusDelay SUBROUTINE + ldy delay ; load outroDelay and decrement dey - sty outroDelay + sty delay cpy #0 - beq statusOutroEnd + beq .end rts -statusOutroEnd: - ; Set status as ST_END: this way, the loop out of this interrupt, - ; will know that we finished, and will play the intro again - lda #ST_END +.end: + lda delayStatus sta status rts diff --git a/src/program.asm b/src/program.asm index af60580..84adf94 100644 --- a/src/program.asm +++ b/src/program.asm @@ -69,15 +69,12 @@ intro0running: ; Cycle here until SPACE or `Q` is pressed ; Intro is finished, now it's time to start the proper game intro0end: - ; Pause everything in interrupt - lda #ST_PAUSE - sta status ; Set init variables of the game jsr gamereset ; Set status as level select ; (then it will enter in status play) - lda #ST_LEVELSELECT + lda #ST_LEVEL_TITLE sta status endless: @@ -126,18 +123,23 @@ checkStatusIntro1: jmp checkEndStatus checkStatusPlay: cmp #ST_PLAY - bne checkStatusOutro + bne checkStatusDelay jsr statusPlay jmp checkEndStatus -checkStatusOutro: - cmp #ST_OUTRO - bne checkStatusLevelSelect - jsr statusOutro +checkStatusDelay: + cmp #ST_DELAY + bne checkStatusLevelTitle + jsr statusDelay jmp checkEndStatus -checkStatusLevelSelect: - cmp #ST_LEVELSELECT +checkStatusLevelTitle: + cmp #ST_LEVEL_TITLE + bne checkStatusLevelLoad + jsr statusLevelTitle + jmp checkEndStatus +checkStatusLevelLoad: + cmp #ST_LEVEL_LOAD bne checkEndStatus - jsr statusLevelSelect + jsr statusLevelLoad jmp checkEndStatus checkEndStatus: diff --git a/src/subroutines.asm b/src/subroutines.asm index dc0ab0a..046eb77 100644 --- a/src/subroutines.asm +++ b/src/subroutines.asm @@ -1,5 +1,24 @@ ; Subroutines ; ---------------------------------------------------------------------- + +; Clear screen -- easy +clearScreen SUBROUTINE + ldx #$ff +.loop: + lda #$00 + sta $400,x + sta $500,x + sta $600,x + sta $700,x + lda #$05 + sta $d800,x + sta $d900,x + sta $da00,x + sta $db00,x + dex + cpx #$ff + bne .loop + ; Do some math to calculate tile address in video memory ; using x,y coordinates ; Formula: addr = $400 + y * SCREEN_W + x @@ -92,6 +111,8 @@ printIntro SUBROUTINE ; Input parameters: ; printIntroString pointer to string to be printed (source) ; introScreenStart pointer to text video memory on screen where to print (dest) +; Output results: +; Y leaves string length in reg Y ldy #0 .loop: lda (printIntroString),y ; get char from string diff --git a/util/rlevel.cpp b/util/rlevel.cpp index b1a17c9..f9f0793 100644 --- a/util/rlevel.cpp +++ b/util/rlevel.cpp @@ -23,7 +23,7 @@ int main(int argc, char** argv) { while (true) { cin.getline(line, MAXLEN); if (line[0] == 'Z') break; - // cout << line << '\0'; /* the title */ + cout << line << '\0'; /* the title */ int count = 0; char last = '\0';