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
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

View File

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

View File

@ -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

View File

@ -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
lda #>scoreString
sta printStatusString + 1
jsr printStatus
; Init game variables
lda #4
sta irqn ; Initialize interrupt divider

View File

@ -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:

View File

@ -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

View File

@ -1,5 +1,66 @@
; 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
; (skip first line, used for the status bar)
ldy #39

View File

@ -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

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
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:

View File

@ -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

View File

@ -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';