Improved intro.

Improved introPrint.

Adjusted gameover routine to work with the new intro.
This needs to be further improved anyway to give a sensible delay before
clearing the screen (to allow player to see her/his score)
This commit is contained in:
giomba 2017-12-24 15:57:37 +01:00
parent 1d7226df45
commit c81b92c960

154
snake.asm
View File

@ -67,7 +67,13 @@ status:
; Intro counter ; Intro counter
introCounter: introCounter:
BYTE BYTE #$4
; Intro string x position, and next increment
introX:
BYTE #$0
introXinc:
BYTE #$1
; Costants ; Costants
; ---------------------------------------------------------------------- ; ----------------------------------------------------------------------
@ -90,8 +96,18 @@ gameoverString:
BYTE "GAME IS OVER" BYTE "GAME IS OVER"
BYTE #0 BYTE #0
intro0string: intro0string:
BYTE "SNAKE BY GIOMBA" BYTE " SNAKE BY GIOMBA "
BYTE #0 BYTE #0
intro1string:
BYTE " PRESS SPACE TO PLAY "
BYTE #0
intro2string:
BYTE "RETROFFICINA.GLGPROGRAMS.IT"
BYTE 0
colorshade:
BYTE #11,#11,#11,#11,#11,#12,#12,#12,#12,#12,#5,#5,#5
BYTE #13,#13,#13,#13,#7,#7,#7,#7,#7,#7
BYTE #13,#13,#13,#13,#5,#5,#5,#12,#12,#12,#12,#12,#11,#11,#11,#11,#11
; List ; List
; ---------------------------------------------------------------------- ; ----------------------------------------------------------------------
@ -148,6 +164,8 @@ start:
; Enable interrupts ; Enable interrupts
cli cli
jsr introreset
intro0running: intro0running:
jsr $ffe4 jsr $ffe4
cmp #$20 cmp #$20
@ -164,9 +182,17 @@ endless:
ldx $400 ldx $400
inx inx
stx $400 stx $400
jmp endless
; Full reset lda status
cmp #3
bne endless
jsr introreset
lda #0
sta status
jmp intro0running
; Full game reset
; ---------------------------------------------------------------------- ; ----------------------------------------------------------------------
fullreset: fullreset:
; Clear screen ; Clear screen
@ -215,6 +241,48 @@ upperbarLoop:
rts rts
; Intro reset
; ----------------------------------------------------------------------
introreset:
; Clear screen
ldx #$ff
lda #$20
introresetCLS:
sta $400,x
sta $500,x
sta $600,x
sta $700,x
dex
cpx #$ff
bne introresetCLS
ldx #39
introresetColorShade
lda colorshade,x
sta $d828,x
sta $d878,x
dex
cpx #$ff
bne introresetColorShade
; Set screen colors
lda #0
sta $d020 ; overscan
lda #0
sta $d021 ; center
lda #<intro2string
sta printIntroString
lda #>intro2string
sta printIntroString + 1
lda #$26
sta introScreenStart
lda #$07
sta introScreenStart + 1
jsr printIntro
rts
; Interrupt Handler ; Interrupt Handler
; ---------------------------------------------------------------------- ; ----------------------------------------------------------------------
irq: irq:
@ -267,20 +335,63 @@ checkEndStatus:
jmp $ea31 jmp $ea31
status0: status0:
status1: status1:
ldx introCounter
dex
stx introCounter
cpx #0
beq status1do
rts
status1do:
ldx #5
stx introCounter
lda introX
clc
adc introXinc
sta introX
cmp #19
beq status1setSX
cmp #0
beq status1setDX
jmp status1okset
status1setDX:
lda #$01
sta introXinc
jmp status1okset
status1setSX:
lda #$ff
sta introXinc
jmp status1okset
status1okset:
lda #<intro0string lda #<intro0string
sta printIntroString sta printIntroString
lda #>intro0string lda #>intro0string
sta printIntroString + 1 sta printIntroString + 1
lda #$00 lda #$28
clc
adc introX
sta introScreenStart sta introScreenStart
lda #$05 lda #$04
sta introScreenStart + 1
jsr printIntro
lda #<intro1string
sta printIntroString
lda #>intro1string
sta printIntroString + 1
lda #$78
clc
adc #19
sec
sbc introX
sta introScreenStart
lda #$04
sta introScreenStart + 1 sta introScreenStart + 1
jsr printIntro jsr printIntro
ldx $401
inx
stx $401
rts rts
status2: ; do Game status2: ; do Game
@ -546,21 +657,10 @@ gameover:
lda #>gameoverString lda #>gameoverString
sta printStatusString + 1 sta printStatusString + 1
jsr printStatus jsr printStatus
jsr sidtune
sei lda #3
ldx #$ff sta status
ldy #$ff rts
gameoverLoop:
nop
nop
nop
nop
dex
bne gameoverLoop
dey
bne gameoverLoop
jmp 64738
; Subroutines ; Subroutines
; ---------------------------------------------------------------------- ; ----------------------------------------------------------------------
@ -675,12 +775,12 @@ printIntro:
printIntroLoop: printIntroLoop:
lda (printIntroString),y lda (printIntroString),y
beq printIntroEnd beq printIntroEnd
cmp #$20 cmp #$40
bne printIntroSkipSpace bcc printIntroEndCheck
lda #$60
printIntroSkipSpace:
sec sec
sbc #$40 sbc #$40
printIntroEndCheck:
sta (introScreenStart),y sta (introScreenStart),y
iny iny
jmp printIntroLoop jmp printIntroLoop