; SPDX-License-Identifier: MIT ; Bank 2: the title and attract screen. 4 set-up lines (VBLANK on) and 192 ; visible lines, like the play kernel. Section line numbers are visible lines. ; 0-7 last game's score (dp, prepared by bank 0) ; 10-33 the tent roof (12 rows, 2 lines each) ; 38-53 BIG TOP (two colours, double height) ; 58-73 BOUNCE ; 80-94 a row of balloons sliding (P0 and P1, three copies each) ; 104-119 the clown ; 132-139 GAME n ; 150-173 the ring .segment "BANK2" .org $B000 .scope title .include "gen/font.inc" .include "gen/title.inc" ; PosObj: as in shared.s (two lines, x - POS_K in 0..149). PosObj: sta WSYNC SLEEP 14 sec @div: sbc #15 bcs @div sta RESP0,x sta WSYNC eor #7 asl asl asl asl sta HMP0,x rts ; TEXTPTRS str: copy six glyph offsets into dp's low bytes (35 cycles + 6). .macro TEXTPTRS str .repeat 6, i lda str+i sta dp+i*2 .endrepeat .endmacro ; The 48-pixel text loop (as the HUD's), each row drawn on two lines. .macro TEXT2 .local loop ldy #7 sty row GUARD 110 loop: lda (dp+0),y sta GRP0 sta WSYNC lda (dp+2),y ; 5 sta GRP1 ; 8 lda (dp+4),y ; 13 sta GRP0 ; 16 lda (dp+6),y ; 21 sta tmp ; 24 lda (dp+8),y ; 29 tax ; 31 lda (dp+10),y ; 36 tay ; 38 lda tmp ; 41 sta GRP1 ; 44 stx GRP0 ; 47 sty GRP1 ; 50 sta GRP0 ; 53 ldy row ; 56 lda (dp+0),y ; 61 sta GRP0 ; 64 sta WSYNC ; 67 lda (dp+2),y ; 5 sta GRP1 ; 8 lda (dp+4),y ; 13 sta GRP0 ; 16 lda (dp+6),y ; 21 sta tmp ; 24 lda (dp+8),y ; 29 tax ; 31 lda (dp+10),y ; 36 tay ; 38 lda tmp ; 41 sta GRP1 ; 44 stx GRP0 ; 47 sty GRP1 ; 50 sta GRP0 ; 53 dec row ; 58 ldy row ; 61 bpl loop ; 64 .assert >loop = >*, error, "text loop crosses a page" .endmacro ; The same, one line per row. .macro TEXT1 .local loop ldy #7 sty row GUARD 56 loop: lda (dp+0),y sta GRP0 sta WSYNC lda (dp+2),y sta GRP1 lda (dp+4),y sta GRP0 lda (dp+6),y sta tmp lda (dp+8),y tax lda (dp+10),y tay lda tmp sta GRP1 stx GRP0 sty GRP1 sta GRP0 dec row ldy row bpl loop .assert >loop = >*, error, "text loop crosses a page" .endmacro ; Text players at the score's fixed position: ends the current line, strobes on ; the next, ends it. .macro TEXTPOS sta WSYNC SLEEP ::SCORE_SLEEP sta RESP0 sta RESP1 lda #SCORE_HM0 sta HMP0 lda #SCORE_HM1 sta HMP1 sta WSYNC .endmacro ; WAITLINES n: end n lines doing nothing. .macro WAITLINES n .local l ldx #n l: sta WSYNC dex bne l .endmacro Entry: ; set-up lines 36-39 sta WSYNC ; ends 36 WAITLINES 1 ; ends 37 TEXTPOS ; ends 38, strobes on 39, ends 39 ; visible 0 (40) sta HMOVE lda #$82 sta VBLANK ; still blank on this first line; capacitors dumped lda #3 sta NUSIZ0 sta NUSIZ1 lda #1 sta VDELP0 sta VDELP1 lda scoreCol sta COLUP0 sta COLUP1 lda #0 sta COLUBK sta PF0 sta PF1 sta PF2 sta ENABL sta CTRLPF sta HMCLR sta WSYNC ; ends 0 lda #$80 sta VBLANK ; visible from line 1 on ; lines 1-8: score (the loop's first WSYNC ends line 0... see count) TEXT1 ; 8 lines: 1-8 sta WSYNC ; ends 8 lda #0 ; 9 sta GRP0 sta GRP1 sta GRP0 lda #CTRL_REF sta CTRLPF lda #$F0 sta PF0 ldx #11 lda #0 sta row ; row = line parity for the roof sta WSYNC ; ends 9 ; roof: 24 lines (10-33), each table row twice GUARD 40 TT_roof: lda TRoofCol,x ; 4 sta COLUPF ; 7 lda TRoofPF1,x ; 11 sta PF1 ; 14 lda TRoofPF2,x ; 18 sta PF2 ; 21 sta WSYNC lda TRoofCol,x sta COLUPF lda TRoofPF1,x sta PF1 lda TRoofPF2,x sta PF2 dex sta WSYNC bpl TT_roof ; line 34 lda #0 sta PF0 sta PF1 sta PF2 lda #>Font .repeat 6, i sta dp+i*2+1 .endrepeat lda #C_TITLE1 sta COLUP0 lda #C_TITLE2 sta COLUP1 sta WSYNC ; ends 34 TEXTPTRS StrBig ; line 35 sta WSYNC ; ends 35 WAITLINES 1 ; ends 36 ; 37: the loop's first WSYNC ends it TEXT2 ; 38-53 sta WSYNC ; ends 53 lda #0 ; 54 sta GRP0 sta GRP1 sta GRP0 lda #C_TITLE3 sta COLUP0 lda #C_TITLE4 sta COLUP1 sta WSYNC ; ends 54 TEXTPTRS StrBounce ; 55 sta WSYNC ; ends 55 WAITLINES 1 ; ends 56 TEXT2 ; 58-73 (57 ended by the loop) sta WSYNC ; ends 73 lda #0 ; 74 sta GRP0 sta GRP1 sta GRP0 sta VDELP0 sta VDELP1 lda #6 sta NUSIZ0 sta NUSIZ1 lda #C_BAL0A sta COLUP0 lda #C_BAL1B sta COLUP1 lda titleX ldx #0 jsr PosObj ; ends 74, strobes 75, ends 75 lda titleX clc adc #16 ldx #1 jsr PosObj ; ends 76, strobes 77, ends 77 sta WSYNC ; ends 78 sta HMOVE ; 79 SLEEP 24 ; HMCLR no sooner than 24 cycles after HMOVE sta HMCLR ldx #14 ; all 15 rows of the balloon (the first build sta WSYNC ; ends 79 drew only the lower 11: a heart shape) GUARD 16 TT_bal: lda TBalloonGfx,x ; 80-94 sta GRP0 sta GRP1 sta WSYNC dex bpl TT_bal lda #0 ; 95 sta GRP0 sta GRP1 sta NUSIZ1 lda #5 sta NUSIZ0 lda #(72 - POS_KP) ldx #0 jsr PosObj ; ends 95, strobes 96, ends 96 sta WSYNC ; ends 97 sta HMOVE ; 98 WAITLINES 5 ; ends 98-102 ldx #15 sta HMCLR sta WSYNC ; ends 103 GUARD 20 TT_clown: lda TClownGfx,x ; 104-119 sta GRP0 lda TClownCol,x sta COLUP0 sta WSYNC dex bpl TT_clown lda #0 ; 120 sta GRP0 lda #3 sta NUSIZ0 sta NUSIZ1 lda #1 sta VDELP0 sta VDELP1 lda #C_TEXT sta COLUP0 sta COLUP1 TEXTPOS ; ends 120, strobes 121, ends 121 sta HMOVE ; 122 sta WSYNC ; ends 122 sta HMCLR ; 123 TEXTPTRS StrGame lda gameNum ; the game number's digit clc adc #1 asl asl asl sta dp+10 sta WSYNC ; ends 123 WAITLINES 7 ; ends 124-130 TEXT1 ; 132-139 (131 ended by the loop) sta WSYNC ; ends 139 lda #0 ; 140 sta GRP0 sta GRP1 sta GRP0 sta VDELP0 sta VDELP1 lda #C_TITLE1 sta COLUPF WAITLINES 10 ; ends 140-149 ldx #23 GUARD 24 TT_ring: lda TRingPF0,x ; 150-173 sta PF0 lda TRingPF1,x sta PF1 lda TRingPF2,x sta PF2 sta WSYNC dex bpl TT_ring lda #0 ; 174 sta PF0 sta PF1 sta PF2 WAITLINES 16 KEXIT ToLogic2 ; ends the last visible line StrBig: .byte CH_B, CH_I, CH_G, CH_T, CH_O, CH_P StrBounce: .byte CH_B, CH_O, CH_U, CH_N, CH_C, CH_E StrGame: .byte CH_G, CH_A, CH_M, CH_E, CH_SP, CH_0 .endscope TitleKernel = title::Entry .assert title::Font = $B000, error, "Font must start bank 2"