new demo/intro draft

This commit is contained in:
giomba 2021-04-13 23:19:47 +02:00
parent 2c4130899c
commit 05ed319d93
8 changed files with 662 additions and 310 deletions

View File

@ -54,6 +54,14 @@ delayStatus:
score:
WORD
; vertical scroll intro
introYscroll:
BYTE
; raster line for interrupt
rasterLineInt:
BYTE
#if VERBOSE = 1
ECHO "data.asm @ ",LASTINIT,"len:",(. - LASTINIT)
#endif

File diff suppressed because it is too large Load Diff

View File

@ -25,11 +25,16 @@ delay:
; Status of the game (costants pre-processor defined, sort of enum)
ST_INTRO0 = 0
ST_INTRO1 = 1
ST_LEVEL_TITLE = 2
ST_LEVEL_LOAD = 3
ST_PLAY = 4
ST_DELAY = 5
ST_END = 6
ST_INTRO2 = 2
ST_INTRO3 = 3
ST_INTRO4 = 4
ST_MENURESET = 64
ST_MENU = 65
ST_LEVEL_TITLE = 128
ST_LEVEL_LOAD = 129
ST_PLAY = 130
ST_DELAY = 131
ST_END = 132
ST_PAUSE = 255
; Screen features
@ -79,7 +84,7 @@ intro3string:
#if DEBUG = 1
BYTE "DBG RELS"
#else
BYTE "(C) 2018"
BYTE "2017 (C) 2021"
#endif
BYTE #0
levelIntroString:
@ -93,6 +98,15 @@ scoreString:
noMoreLevelsString:
BYTE "NO MORE LEVELS"
BYTE #0
introStringA1:
BYTE "RETROFFICINA"
BYTE #$0
introStringA2:
BYTE "AND"
BYTE #$0
introStringA3:
BYTE "GIOMBA"
BYTE #$0
; Levels
; ----------------------------------------------------------------------

View File

@ -4,8 +4,301 @@ LASTINIT SET .
; Currently statusIntro0 is the same as statusIntro1
; statusIntro1 has just been reserved for future use
statusIntro0:
statusIntro1:
statusIntro0 SUBROUTINE
lda introYscroll
.enter:
inc rasterLineInt
lda $d011
and #$07
cmp #$07
beq .nextline
inc $d011
jsr setupMagicInterrupt
rts
.nextline:
lda $d011
and #$f8
sta $d011
ldy #0
lda #$80
.clearLineLoop:
sta (dstPointer),y
iny
cpy #40
bne .clearLineLoop
clc
lda dstPointer
adc #40
sta dstPointer
lda dstPointer + 1
adc #0
sta dstPointer + 1
ldy #$00
.glgLoop:
lda GLGProgramsText,y
sta (dstPointer),y
iny
cpy #200
bne .glgLoop
dec introYscroll
beq .next
jsr setupMagicInterrupt
rts
.next:
lda #ST_INTRO1
sta status
rts
setupMagicInterrupt SUBROUTINE
; Store in $314 address of our custom interrupt handler
ldx #<.magicInterruptH
ldy #>.magicInterruptH
stx $314
sty $315
; Set raster beam to trigger interrupt at row
lda rasterLineInt
sta $d012
rts
.magicInterruptH:
; +36
dec $d019 ; +42, EOI
inc $d020 ; +48, white
bit $02 ; +51, timing
nop ; +53, timing
nop ; +55, timing
nop ; +57, timing
dec $d020 ; +63, black
; second line, +0
inc $0800 ; + 6, timing
inc $0800 ; +12, timing
inc $0800 ; +18, timing
inc $0800 ; +24, timing
inc $0800 ; +30, timing
inc $0800 ; +36, timing
inc $0800 ; +42, timing
inc $d020 ; +54, white
inc $0800 ; +60, timing
bit $02 ; +60, timing
dec $d020 ; +63, black
; set raster beam low
ldx #<.magicInterruptL
ldy #>.magicInterruptL
stx $314
sty $315
clc
lda rasterLineInt
adc #23
sta $d012
jmp $ea31
.magicInterruptL:
; +36
dec $d019 ; +42, EOI
inc $0800 ; +48, timing
inc $0800 ; +54, timing
inc $0800 ; +60, timing
bit $02 ; +63, timing
; newline
inc $d020 ; + 6, white
inc $0800 ; +12, timing
inc $0800 ; +18, timing
dec $d020 ; +24, black
inc $0800 ; +30, timing
inc $0800 ; +36, timing
inc $0800 ; +42, timing
inc $0800 ; +48, timing
inc $0800 ; +54, timing
inc $0800 ; +60, timing
bit $02 ; +63, timing
; newline
inc $d020 ; +6, white
inc $0800 ; +12, timing
inc $0800 ; +18, timing
dec $d020 ; +24, black
ldx #<irq
ldy #>irq
stx $314
sty $315
lda #$00
sta $d012
jmp $ea31
GLGProgramsText:
BYTE #$80,#$80,#$80,#$80,#$80,#$80,#$80,#$f0,#$f4,#$80,#$80,#$80,#$f0,#$f4,#$80,#$80,#$f0,#$f4,#$f1,#$80,#$80,#$80,#$80,#$80,#$80,#$80,#$80,#$80,#$80,#$80,#$80,#$80,#$80,#$80,#$80,#$80,#$80,#$80,#$80,#$80
BYTE #$80,#$80,#$80,#$80,#$80,#$80,#$80,#$f5,#$80,#$80,#$f5,#$80,#$f5,#$80,#$80,#$80,#$f5,#$80,#$f5,#$80,#$80,#$80,#$80,#$80,#$80,#$80,#$f1,#$80,#$80,#$80,#$f0,#$f4,#$f4,#$f4,#$f4,#$f4,#$f4,#$f4,#$f4,#$f4
BYTE #$80,#$80,#$80,#$80,#$80,#$80,#$80,#$f5,#$80,#$f5,#$f5,#$80,#$f5,#$80,#$f5,#$80,#$fd,#$f4,#$f3,#$f0,#$f0,#$f1,#$f0,#$f1,#$f0,#$f0,#$fc,#$f0,#$fb,#$f1,#$f2,#$f1,#$80,#$80,#$80,#$80,#$80,#$80,#$80,#$80
BYTE #$80,#$80,#$80,#$80,#$80,#$80,#$80,#$f2,#$f4,#$fc,#$f2,#$f4,#$f2,#$f4,#$fc,#$80,#$f5,#$80,#$80,#$f5,#$f2,#$f3,#$f2,#$fc,#$f5,#$f2,#$f3,#$f5,#$f5,#$f5,#$f4,#$f3,#$80,#$80,#$80,#$80,#$80,#$80,#$80,#$80
BYTE #$f4,#$f4,#$f4,#$f4,#$f4,#$f4,#$f4,#$f4,#$f4,#$fa,#$f4,#$f4,#$f4,#$f4,#$f3,#$80,#$80,#$80,#$80,#$80,#$80,#$80,#$80,#$f3,#$80,#$80,#$80,#$80,#$80,#$80,#$80,#$80,#$80,#$80,#$80,#$80,#$80,#$80,#$80,#$80
statusIntro1 SUBROUTINE
lda $d011
and #$07
cmp #$04
beq .next
inc $d011
inc rasterLineInt
jsr setupMagicInterrupt
rts
.next:
jsr setupMagicInterrupt
lda counter
cmp #$80
bne .end
lda counter + 1
cmp #$00
bne .end
; lda #ST_MENURESET
lda #ST_INTRO2
sta status
.end:
rts
statusIntro2 SUBROUTINE
jsr setupMagicInterrupt
; "RETROFFICINA"
lda #<introStringA1
sta srcStringPointer
lda #>introStringA1
sta srcStringPointer + 1
lda #$4e
sta dstScreenPointer
lda #$05
sta dstScreenPointer + 1
jsr printString
lda counter
cmp #$08
bne .end
lda counter + 1
cmp #$01
bne .end
lda #ST_INTRO3
sta status
.end:
rts
statusIntro3 SUBROUTINE
jsr setupMagicInterrupt
; "AND"
lda #<introStringA2
sta srcStringPointer
lda #>introStringA2
sta srcStringPointer + 1
lda #$a3
sta dstScreenPointer
lda #$05
sta dstScreenPointer + 1
jsr printString
lda counter
cmp #$86
bne .end
lda counter + 1
cmp #$01
bne .end
lda #ST_INTRO4
sta status
.end:
rts
statusIntro4 SUBROUTINE
jsr setupMagicInterrupt
; "GIOMBA"
lda #<introStringA3
sta srcStringPointer
lda #>introStringA3
sta srcStringPointer + 1
lda #$f1
sta dstScreenPointer
lda #$05
sta dstScreenPointer + 1
jsr printString
lda counter
cmp #$86
bne .end
lda counter + 1
cmp #$01
bne .end
lda #ST_INTRO4
sta status
.end:
rts
statusMenuReset SUBROUTINE
jsr multicolorOff
; Copy shade colors from costant table to color RAM for 2nd and 4th line of text
ldx #39
.colorShadeLoop:
lda colorshade,x
sta $d828,x ; 2nd line
sta $d878,x ; 4th line
dex
cpx #$ff
bne .colorShadeLoop
; Print website
lda #<intro2string ; lsb of string address
sta srcStringPointer ; put into lsb of source pointer
lda #>intro2string ; do the same for msb of string address
sta srcStringPointer + 1 ; put into msb of source pointer
lda #$9e ; this is lsb of address of 23th line
sta dstScreenPointer ; put into lsb of dest pointer
lda #$07 ; do the same for msb of adress of 20th line
sta dstScreenPointer + 1 ; put into msb of dest pointer
jsr printString ; print
; Print Copyright
lda #<intro3string ; the assembly is the same as above,
sta srcStringPointer ; just change string to be printed
lda #>intro3string ; and line (24th line)
sta srcStringPointer + 1
lda #$ce
sta dstScreenPointer
lda #$07
sta dstScreenPointer + 1
jsr printString
jsr setupMagicInterrupt ; never forget the magic
lda #ST_MENU
sta status
rts
statusMenu SUBROUTINE
jsr setupMagicInterrupt ; never forget to draw the lines
; Decrement interrupt divider for the intro
ldx introCounter
dex

View File

@ -4,50 +4,36 @@ LASTINIT SET .
; Intro reset
; ----------------------------------------------------------------------
introreset:
introreset SUBROUTINE
jsr multicolorOff
jsr clearScreen
; Copy shade colors from costant table to color RAM for 2nd and 4th line of text
ldx #39
introresetColorShade
lda colorshade,x
sta $d828,x ; 2nd line
sta $d878,x ; 4th line
dex
cpx #$ff
bne introresetColorShade
; Set screen colors
lda #0
sta $d020 ; overscan
sta $d021 ; center
; Print website
lda #<intro2string ; lsb of string address
sta srcStringPointer ; put into lsb of source pointer
lda #>intro2string ; do the same for msb of string address
sta srcStringPointer + 1 ; put into msb of source pointer
lda #$26 ; this is lsb of address of 20th line
sta dstScreenPointer ; put into lsb of dest pointer
lda #$07 ; do the same for msb of adress of 20th line
sta dstScreenPointer + 1 ; put into msb of dest pointer
jsr printString ; print
lda #14
sta introYscroll
; Print Copyright
lda #<intro3string ; the assembly is the same as above,
sta srcStringPointer ; just change string to be printed
lda #>intro3string ; and line (21th line)
sta srcStringPointer + 1
lda #$58
sta dstScreenPointer
lda #$07
sta dstScreenPointer + 1
jsr printString
ldx #$78
stx dstPointer
ldy #$04
sty dstPointer + 1
rts
lda #68+19
sta rasterLineInt
#if DEBUG = 1
ldy #$00
.charsetLoop:
tya
sta $4c8,y
iny
bne .charsetLoop
#endif
#if VERBOSE = 1
ECHO "introreset.asm @ ",LASTINIT,"len:",(. - LASTINIT)
#endif
#endif

View File

@ -63,16 +63,32 @@ zeroFillZeroPage:
; Reset screen (and other parameters) to play intro
jsr introreset
intro0running: ; Cycle here until SPACE or `Q` is pressed
menu SUBROUTINE
.menu: ; Cycle here until SPACE or `Q` is pressed
jsr $ffe4 ; GETIN
cmp #$20 ; Is it SPACE?
beq intro0end ; if yes, go to intro0end and start game (see)
beq .intro0end ; if yes, go to intro0end and start game (see)
#if DEBUG = 1
cmp #$41 ; Is it A?
beq .printCounter ; if yes, print current counter
#endif
cmp #$51 ; Is it Q?
bne intro0running ; If not, keep looping here,
bne .menu ; If not, keep looping here,
jmp $fce2 ; else, reset the computer
#if DEBUG = 1
.printCounter
lda counter + 1
ldy #2
jsr printByte
lda counter
ldy #4
jsr printByte
jmp .menu
#endif
; Intro is finished, now it's time to start the proper game
intro0end:
.intro0end:
; Set current level pointer to list start
lda #<levelsList
sta levelPointer
@ -92,20 +108,21 @@ intro0end:
lda #ST_LEVEL_TITLE
sta status
endless:
.endless:
; Loop waiting for gameover
lda status
cmp #ST_END ; is status equal to end ?
bne endless ; if not, just wait looping here, else...
bne .endless ; if not, just wait looping here, else...
jsr introreset ; reset variables for intro
lda #ST_INTRO0
sta status ; put machine into play intro status
jmp intro0running ; and go there waiting for keypress
jsr clearScreen
lda #ST_MENURESET
sta status ; put machine into menu status
jmp .menu ; and go there waiting for keypress
; Interrupt Handler
; ----------------------------------------------------------------------
irq:
irq SUBROUTINE
; Things that must be done every interrupt (50Hz)
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Acknoweledge IRQ
@ -118,24 +135,68 @@ irq:
tya
pha
#if DEBUG = 1
; Change background to show how much time does music take for each interrupt
lda #1
sta $d020
#endif
; if interrupt raster line is not 0, then someone is doing some magic elsewhere
lda $d012
;bne .noPlay
; Play music first -> no skew if computations are slow
jsr sidtune + 3
.noPlay:
#if DEBUG = 1
; Change background to visually see the ISR timing
lda #2
sta $d020
#endif
inc counter
bne .noIncCounter
inc counter + 1
.noIncCounter
; Check status and call appropriate sub-routine
; Sort of switch-case
lda status
checkStatusIntro0:
cmp #ST_INTRO0
bne checkStatusIntro1
jsr statusIntro0
jmp checkEndStatus
checkStatusIntro1:
cmp #ST_INTRO1
bne checkStatusPlay
bne checkStatusIntro2
jsr statusIntro1
jmp checkEndStatus
checkStatusIntro2:
cmp #ST_INTRO2
bne checkStatusIntro3
jsr statusIntro2
jmp checkEndStatus
checkStatusIntro3:
cmp #ST_INTRO3
bne checkStatusIntro4
jsr statusIntro3
jmp checkEndStatus
checkStatusIntro4:
cmp #ST_INTRO4
bne checkStatusMenuReset
jsr statusIntro4
jmp checkEndStatus
checkStatusMenuReset:
cmp #ST_MENURESET
bne checkStatusMenu
jsr statusMenuReset
jmp checkEndStatus
checkStatusMenu:
cmp #ST_MENU
bne checkStatusPlay
jsr statusMenu
jmp checkEndStatus
checkStatusPlay:
cmp #ST_PLAY
bne checkStatusDelay
@ -158,19 +219,6 @@ checkStatusLevelLoad:
jmp checkEndStatus
checkEndStatus:
#if DEBUG = 1
; Change background to show how much time does music take for each interrupt
lda #1
sta $d020
#endif
; Play music
jsr sidtune + 3
; jsr sidtune + 3
; jsr sidtune + 3
; jsr sidtune + 3
; jsr sidtune + 3
; Increase random value
inc random

View File

@ -14,7 +14,7 @@ clearScreen SUBROUTINE
sta $500,x
sta $600,x
sta $700,x
lda #$05
lda #$0f
sta $d800,x
sta $d900,x
sta $da00,x

View File

@ -26,6 +26,9 @@ strlenString DS 2
srcPointer DS 2
dstPointer DS 2
; Interrupt counter
counter DS 2
; Note: Locations $90-$FF in zeropage are used by kernal