level introduction screen

This commit is contained in:
giomba 2020-04-08 09:15:25 +02:00
parent 22a5feb2a1
commit cd1820d834
11 changed files with 130 additions and 68 deletions

View File

@ -1,20 +1,20 @@
TITLE TRAINING
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
x fffffffffff x
x x x x
x x x x
x x x 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 x x
x x x x

View File

@ -42,3 +42,7 @@ levelT:
levelN: levelN:
BYTE BYTE
; next status after delay
delayStatus:
BYTE

View File

@ -9,8 +9,10 @@ gameover:
; Set gameover and outro status ; Set gameover and outro status
lda #$ff lda #$ff
sta outroDelay sta delay
lda #ST_OUTRO lda #ST_END
sta delayStatus
lda #ST_DELAY
sta status sta status
rts rts

View File

@ -4,24 +4,6 @@ gamereset:
; Turn MultiColor mode on ; Turn MultiColor mode on
jsr multicolorOn 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
lda #>scoreString
sta printStatusString + 1
jsr printStatus
; Init game variables ; Init game variables
lda #4 lda #4
sta irqn ; Initialize interrupt divider sta irqn ; Initialize interrupt divider

View File

@ -11,21 +11,21 @@ introX:
introXinc: introXinc:
BYTE #$1 BYTE #$1
; Outro delay ; Delay
outroDelay delay:
BYTE #$ff BYTE #$ff
; Costants ; Costants
; ---------------------------------------------------------------------- ; ----------------------------------------------------------------------
; Status of the game (costants pre-processor defined, sort of enum) ; Status of the game (costants pre-processor defined, sort of enum)
ST_INTRO0 = 0 ST_INTRO0 = 0
ST_INTRO1 = 1 ST_INTRO1 = 1
ST_LEVELSELECT = 2 ST_LEVEL_TITLE = 2
ST_PLAY = 3 ST_LEVEL_LOAD = 3
ST_OUTRO = 4 ST_PLAY = 4
ST_END = 5 ST_DELAY = 5
ST_END = 6
ST_PAUSE = 255 ST_PAUSE = 255
; Screen features ; Screen features
@ -78,6 +78,9 @@ intro3string:
BYTE "(C) 2018" BYTE "(C) 2018"
#endif #endif
BYTE #0 BYTE #0
levelIntroString:
BYTE "NEXT LEVEL"
BYTE #0
colorshade: ; a gradient of dark-bright-dark (40 columns) 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 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: scoreString:

View File

@ -3,17 +3,7 @@
introreset: introreset:
jsr multicolorOff jsr multicolorOff
; Clear screen jsr clearScreen
ldx #$ff
lda #$00
introresetCLS:
sta $400,x
sta $500,x
sta $600,x
sta $700,x
dex
cpx #$ff
bne introresetCLS
; Copy shade colors from costant table to color RAM for 2nd and 4th line of text ; Copy shade colors from costant table to color RAM for 2nd and 4th line of text
ldx #39 ldx #39

View File

@ -1,5 +1,66 @@
; load new level on the screen ; load new level on the screen
statusLevelSelect: statusLevelTitle SUBROUTINE
jsr clearScreen
.back:
; Print "Next Level"
lda #<levelIntroString
sta printIntroString
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
lda #>scoreString
sta printStatusString + 1
jsr printStatus
; initialize video pointer with first video memory address ; initialize video pointer with first video memory address
; (skip first line, used for the status bar) ; (skip first line, used for the status bar)
ldy #39 ldy #39

View File

@ -1,16 +1,13 @@
; Decrement outroDelay, just to let player see her/his end screen ; Wait for some delay
; with score statusDelay SUBROUTINE
statusOutro: ldy delay ; load outroDelay and decrement
ldy outroDelay ; load outroDelay and decrement
dey dey
sty outroDelay sty delay
cpy #0 cpy #0
beq statusOutroEnd beq .end
rts rts
statusOutroEnd: .end:
; Set status as ST_END: this way, the loop out of this interrupt, lda delayStatus
; will know that we finished, and will play the intro again
lda #ST_END
sta status sta status
rts rts

View File

@ -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 ; Intro is finished, now it's time to start the proper game
intro0end: intro0end:
; Pause everything in interrupt
lda #ST_PAUSE
sta status
; Set init variables of the game ; Set init variables of the game
jsr gamereset jsr gamereset
; Set status as level select ; Set status as level select
; (then it will enter in status play) ; (then it will enter in status play)
lda #ST_LEVELSELECT lda #ST_LEVEL_TITLE
sta status sta status
endless: endless:
@ -126,18 +123,23 @@ checkStatusIntro1:
jmp checkEndStatus jmp checkEndStatus
checkStatusPlay: checkStatusPlay:
cmp #ST_PLAY cmp #ST_PLAY
bne checkStatusOutro bne checkStatusDelay
jsr statusPlay jsr statusPlay
jmp checkEndStatus jmp checkEndStatus
checkStatusOutro: checkStatusDelay:
cmp #ST_OUTRO cmp #ST_DELAY
bne checkStatusLevelSelect bne checkStatusLevelTitle
jsr statusOutro jsr statusDelay
jmp checkEndStatus jmp checkEndStatus
checkStatusLevelSelect: checkStatusLevelTitle:
cmp #ST_LEVELSELECT cmp #ST_LEVEL_TITLE
bne checkStatusLevelLoad
jsr statusLevelTitle
jmp checkEndStatus
checkStatusLevelLoad:
cmp #ST_LEVEL_LOAD
bne checkEndStatus bne checkEndStatus
jsr statusLevelSelect jsr statusLevelLoad
jmp checkEndStatus jmp checkEndStatus
checkEndStatus: checkEndStatus:

View File

@ -1,5 +1,24 @@
; Subroutines ; 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 ; Do some math to calculate tile address in video memory
; using x,y coordinates ; using x,y coordinates
; Formula: addr = $400 + y * SCREEN_W + x ; Formula: addr = $400 + y * SCREEN_W + x
@ -92,6 +111,8 @@ printIntro SUBROUTINE
; Input parameters: ; Input parameters:
; printIntroString pointer to string to be printed (source) ; printIntroString pointer to string to be printed (source)
; introScreenStart pointer to text video memory on screen where to print (dest) ; introScreenStart pointer to text video memory on screen where to print (dest)
; Output results:
; Y leaves string length in reg Y
ldy #0 ldy #0
.loop: .loop:
lda (printIntroString),y ; get char from string lda (printIntroString),y ; get char from string

View File

@ -23,7 +23,7 @@ int main(int argc, char** argv) {
while (true) { while (true) {
cin.getline(line, MAXLEN); cin.getline(line, MAXLEN);
if (line[0] == 'Z') break; if (line[0] == 'Z') break;
// cout << line << '\0'; /* the title */ cout << line << '\0'; /* the title */
int count = 0; int count = 0;
char last = '\0'; char last = '\0';