ca65 V2.18 - Git 5552824 Main file : src/bigtop.s Current file: src/bigtop.s 000000r 1 ; SPDX-License-Identifier: MIT 000000r 1 ; Big Top Bounce: an original paddle game for the Atari 2600. 000000r 1 ; Copyright (c) 2026 alewman (see LICENSE). 000000r 1 ; 000000r 1 ; Assembled with ca65/ld65 (cc65 V2.18 - Git 5552824, as the binaries report; 000000r 1 ; installed in a directory misnamed cc65-2.19). 16K F6 cartridge: 000000r 1 ; bank 0 ($D000 link) game logic, sound, tables the logic uses 000000r 1 ; bank 1 ($F000 link) the play kernel (HUD and the three floors) and its graphics 000000r 1 ; bank 2 ($B000 link) the title kernel and its graphics 000000r 1 ; bank 3 ($9000 link) unused 000000r 1 ; Every bank ends with the same stubs (bank switching, vectors). 000000r 1 ; Build flags: -D PAL50 (312-line PAL), -D PAL60 (262 lines, PAL colours), neither = NTSC. 000000r 1 000000r 1 .setcpu "6502" 000000r 1 .include "vcs.inc" 000000r 2 ; SPDX-License-Identifier: MIT 000000r 2 ; TIA and RIOT register addresses. DOC: Atari, "Stella Programmer's Guide" 000000r 2 ; (Steve Wright, 1979), TIA write/read address summaries and the 6532 map. 000000r 2 ; Written out here rather than taken from another include file. 000000r 2 000000r 2 ; TIA, write 000000r 2 VSYNC = $00 000000r 2 VBLANK = $01 000000r 2 WSYNC = $02 000000r 2 RSYNC = $03 000000r 2 NUSIZ0 = $04 000000r 2 NUSIZ1 = $05 000000r 2 COLUP0 = $06 000000r 2 COLUP1 = $07 000000r 2 COLUPF = $08 000000r 2 COLUBK = $09 000000r 2 CTRLPF = $0A 000000r 2 REFP0 = $0B 000000r 2 REFP1 = $0C 000000r 2 PF0 = $0D 000000r 2 PF1 = $0E 000000r 2 PF2 = $0F 000000r 2 RESP0 = $10 000000r 2 RESP1 = $11 000000r 2 RESM0 = $12 000000r 2 RESM1 = $13 000000r 2 RESBL = $14 000000r 2 AUDC0 = $15 000000r 2 AUDC1 = $16 000000r 2 AUDF0 = $17 000000r 2 AUDF1 = $18 000000r 2 AUDV0 = $19 000000r 2 AUDV1 = $1A 000000r 2 GRP0 = $1B 000000r 2 GRP1 = $1C 000000r 2 ENAM0 = $1D 000000r 2 ENAM1 = $1E 000000r 2 ENABL = $1F 000000r 2 HMP0 = $20 000000r 2 HMP1 = $21 000000r 2 HMM0 = $22 000000r 2 HMM1 = $23 000000r 2 HMBL = $24 000000r 2 VDELP0 = $25 000000r 2 VDELP1 = $26 000000r 2 VDELBL = $27 000000r 2 RESMP0 = $28 000000r 2 RESMP1 = $29 000000r 2 HMOVE = $2A 000000r 2 HMCLR = $2B 000000r 2 CXCLR = $2C 000000r 2 000000r 2 ; TIA, read (D7, and D6 for collisions) 000000r 2 CXM0P = $00 000000r 2 CXM1P = $01 000000r 2 CXP0FB = $02 000000r 2 CXP1FB = $03 000000r 2 CXM0FB = $04 000000r 2 CXM1FB = $05 000000r 2 CXBLPF = $06 000000r 2 CXPPMM = $07 000000r 2 INPT0 = $08 000000r 2 INPT1 = $09 000000r 2 INPT2 = $0A 000000r 2 INPT3 = $0B 000000r 2 INPT4 = $0C 000000r 2 INPT5 = $0D 000000r 2 000000r 2 ; RIOT (6532) 000000r 2 SWCHA = $0280 000000r 2 SWACNT = $0281 000000r 2 SWCHB = $0282 000000r 2 SWBCNT = $0283 000000r 2 INTIM = $0284 000000r 2 TIMINT = $0285 000000r 2 TIM1T = $0294 000000r 2 TIM8T = $0295 000000r 2 TIM64T = $0296 000000r 2 T1024T = $0297 000000r 2 000000r 1 000000r 1 ; --------------------------------------------------------------------------- 000000r 1 ; Video timing. NTSC and PAL60: 3 VSYNC + 33 VBLANK + 196 kernel (4 set-up lines 000000r 1 ; with VBLANK on, then 192 visible) + 30 overscan = 262 lines. PAL50 adds 25 lines 000000r 1 ; of VBLANK and 25 of overscan: 312. The waits poll TIMINT D7 (set when the 000000r 1 ; counter passes zero), so a late finish costs one line, which the line check 000000r 1 ; catches, instead of a missed zero. MEASURED with tools/harness (`run`, every 000000r 1 ; frame's line count): with the NTSC values the timer expiry can move from about 000000r 1 ; 20 cycles earlier to 38 later (VBLANK) and 38 either way (overscan) before a 000000r 1 ; frame changes length; the delays put the expiry in the middle of its line. 000000r 1 ; PAL50 adds 1900 cycles to each section (25 lines). 000000r 1 .ifndef VBTIM ; (-D overrides, for tuning) 000000r 1 .ifdef PAL50 000000r 1 VBTIM = 67 000000r 1 VBDELAY = 62 000000r 1 OSTIM = 63 000000r 1 OSDELAY = 50 000000r 1 .else 000000r 1 VBTIM = 38 000000r 1 VBDELAY = 18 000000r 1 OSTIM = 34 000000r 1 OSDELAY = 6 000000r 1 .endif 000000r 1 .endif 000000r 1 000000r 1 .include "colours.inc" 000000r 2 ; SPDX-License-Identifier: MIT 000000r 2 ; Generated by scripts/colours.py: do not edit. NTSC by eye; PAL nearest in RGB 000000r 2 ; within the board's palettes (MAME 0.285 tables via a2600-python, BSD-3). 000000r 2 .ifdef PALCOL 000000r 2 C_BLACK = $00 000000r 2 C_SCORE1 = $4E 000000r 2 C_SCORE2 = $BE 000000r 2 C_PIPS = $0E 000000r 2 C_FLOORMK = $6C 000000r 2 C_BG0 = $D0 000000r 2 C_BG1 = $A0 000000r 2 C_BG2 = $62 000000r 2 C_WALL0 = $0C 000000r 2 C_WALL1 = $0C 000000r 2 C_WALL2 = $0C 000000r 2 C_ROW0 = $86 000000r 2 C_ROW1 = $4A 000000r 2 C_ROW2 = $4C 000000r 2 C_ROW3 = $5A 000000r 2 C_ROW4 = $DA 000000r 2 C_ROW5 = $8C 000000r 2 C_DROP = $4E 000000r 2 C_BUMP = $BC 000000r 2 C_FLASH = $0E 000000r 2 C_BAT = $0E 000000r 2 C_BATK = $4E 000000r 2 C_BAL0A = $86 000000r 2 C_BAL0B = $4E 000000r 2 C_BAL1A = $B8 000000r 2 C_BAL1B = $5A 000000r 2 C_BAL2A = $8E 000000r 2 C_BAL2B = $4A 000000r 2 C_POW1 = $4C 000000r 2 C_POW2 = $6C 000000r 2 C_POW3 = $BE 000000r 2 C_ROOFA = $84 000000r 2 C_ROOFB = $0E 000000r 2 C_CL_RED = $84 000000r 2 C_CL_YELLOW = $4C 000000r 2 C_CL_SKIN = $6C 000000r 2 C_CL_WHITE = $0E 000000r 2 C_CL_BLUE = $B8 000000r 2 C_CL_GREEN = $58 000000r 2 C_TITLE1 = $86 000000r 2 C_TITLE2 = $4E 000000r 2 C_TITLE3 = $BC 000000r 2 C_TITLE4 = $8E 000000r 2 C_TBG = $00 000000r 2 C_TEXT = $0E 000000r 2 .else 000000r 2 C_BLACK = $00 000000r 2 C_SCORE1 = $1E 000000r 2 C_SCORE2 = $9E 000000r 2 C_PIPS = $0E 000000r 2 C_FLOORMK = $3A 000000r 2 C_BG0 = $80 000000r 2 C_BG1 = $50 000000r 2 C_BG2 = $40 000000r 2 C_WALL0 = $0C 000000r 2 C_WALL1 = $0C 000000r 2 C_WALL2 = $0C 000000r 2 C_ROW0 = $46 000000r 2 C_ROW1 = $38 000000r 2 C_ROW2 = $1C 000000r 2 C_ROW3 = $C8 000000r 2 C_ROW4 = $8A 000000r 2 C_ROW5 = $5A 000000r 2 C_DROP = $1E 000000r 2 C_BUMP = $9C 000000r 2 C_FLASH = $0E 000000r 2 C_BAT = $0E 000000r 2 C_BATK = $1E 000000r 2 C_BAL0A = $46 000000r 2 C_BAL0B = $1E 000000r 2 C_BAL1A = $86 000000r 2 C_BAL1B = $C8 000000r 2 C_BAL2A = $5C 000000r 2 C_BAL2B = $2A 000000r 2 C_POW1 = $1C 000000r 2 C_POW2 = $3C 000000r 2 C_POW3 = $9E 000000r 2 C_ROOFA = $44 000000r 2 C_ROOFB = $0E 000000r 2 C_CL_RED = $44 000000r 2 C_CL_YELLOW = $1C 000000r 2 C_CL_SKIN = $3C 000000r 2 C_CL_WHITE = $0E 000000r 2 C_CL_BLUE = $86 000000r 2 C_CL_GREEN = $C6 000000r 2 C_TITLE1 = $46 000000r 2 C_TITLE2 = $1E 000000r 2 C_TITLE3 = $9C 000000r 2 C_TITLE4 = $5C 000000r 2 C_TBG = $00 000000r 2 C_TEXT = $0E 000000r 2 .endif 000000r 2 000000r 1 .include "gen/chars.inc" 000000r 2 ; SPDX-License-Identifier: MIT 000000r 2 ; Generated by scripts/gen_tables.py: do not edit. 000000r 2 CH_0 = 0 000000r 2 CH_1 = 8 000000r 2 CH_2 = 16 000000r 2 CH_3 = 24 000000r 2 CH_4 = 32 000000r 2 CH_5 = 40 000000r 2 CH_6 = 48 000000r 2 CH_7 = 56 000000r 2 CH_8 = 64 000000r 2 CH_9 = 72 000000r 2 CH_SP = 80 000000r 2 CH_A = 88 000000r 2 CH_B = 96 000000r 2 CH_C = 104 000000r 2 CH_E = 112 000000r 2 CH_G = 120 000000r 2 CH_I = 128 000000r 2 CH_K = 136 000000r 2 CH_L = 144 000000r 2 CH_M = 152 000000r 2 CH_N = 160 000000r 2 CH_O = 168 000000r 2 CH_P = 176 000000r 2 CH_R = 184 000000r 2 CH_S = 192 000000r 2 CH_T = 200 000000r 2 CH_U = 208 000000r 2 CH_V = 216 000000r 2 CH_X = 224 000000r 2 CH_Y = 232 000000r 2 CH_BANG = 240 000000r 2 CH_DASH = 248 000000r 2 000000r 1 000000r 1 ; --------------------------------------------------------------------------- 000000r 1 ; Play-field geometry (see docs/design.md). 000000r 1 HUDH = 22 ; HUD lines (score, status, set-up) 000000r 1 PLAYH = 170 ; play-area lines; kernel line counter Y = PLAYH - line 000000r 1 BH = 4 ; ball height in lines (2 colour clocks wide) 000000r 1 XMIN = 16 ; ball's left edge range inside the walls 000000r 1 XMAX = 142 000000r 1 BATTOP = 160 ; play line of the bat's top edge 000000r 1 CEIL = 10 ; top floor: the roof's lower edge 000000r 1 RELEASE_Y = 111 ; Y of line 59, where the paddle capacitor is released 000000r 1 PADINIT = 112 000000r 1 000000r 1 ; Horizontal positions (MEASURED on our board by the first session's harness 000000r 1 ; `calib` command, which was lost in a reboot; the bot's pixel probes re-check 000000r 1 ; the bat, ball, clown, bumpers and balloon rows against RAM, see docs/design.md). PosObj puts a player at x - POS_KP + ... : callers pass 000000r 1 ; x - POS_K so the object lands on x. 000000r 1 POS_KP = 4 ; players through PosObj 000000r 1 POS_KB = 2 ; the ball through PosObj 000000r 1 SCORE_SLEEP = 37 ; HUD/title text: RESP0 written on cycle SCORE_SLEEP+2 000000r 1 SCORE_HM0 = $00 000000r 1 SCORE_HM1 = $10 000000r 1 BUMP_SLEEP = 34 ; middle floor bumpers (x = 44) 000000r 1 BUMP_HM = $40 000000r 1 000000r 1 CTRL_REF = $15 ; reflect, PF above players, ball 2 clocks 000000r 1 CTRL_NONREF = $14 000000r 1 000000r 1 ; Speed as power (2026-11-23; provisional, docs/design.md). Speed steps 0-7 (7 is 000000r 1 ; the cap, the velocity table's last step). -D overrides, for tuning. 000000r 1 .ifndef PUNCH_SPEED 000000r 1 PUNCH_SPEED = 5 ; from this step the ball punches through balloons 000000r 1 .endif 000000r 1 .ifndef BUMP_MAX 000000r 1 BUMP_MAX = 3 ; a bumper's speed-up stops at this step (kicks go higher) 000000r 1 .endif 000000r 1 000000r 1 ; game states 000000r 1 ST_TITLE = 0 000000r 1 ST_SERVE = 1 000000r 1 ST_PLAY = 2 000000r 1 ST_LOST = 3 000000r 1 ST_OVER = 4 000000r 1 000000r 1 ; --------------------------------------------------------------------------- 000000r 1 ; RAM ($80-$FF). The play kernel's temporaries share `dp` with the score 000000r 1 ; pointers: they are written only after the score has been drawn. 000000r 1 .segment "ZEROPAGE" 000000r 1 xx frame: .res 1 000001r 1 xx rngLo: .res 1 000002r 1 xx rngHi: .res 1 000003r 1 xx gameState: .res 1 000004r 1 xx stateTimer: .res 1 000005r 1 xx gameNum: .res 1 ; 0-3 (shown as 1-4) 000006r 1 xx twoPlayer: .res 1 ; 0 or 1 000007r 1 xx curPlayer: .res 1 ; 0 or 1 000008r 1 xx swOld: .res 1 ; SWCHB last frame 000009r 1 xx btnOld: .res 1 ; paddle button last frame (1 = pressed) 00000Ar 1 00000Ar 1 pStart: ; ---- the active player's block ---- 00000Ar 1 xx xx xx score: .res 3 ; BCD, score+0 most significant 00000Dr 1 xx balls: .res 1 ; balls left, including the one in play 00000Er 1 xx level: .res 1 00000Fr 1 xx cleared: .res 1 ; floors cleared this level (bits 0-2) 000010r 1 xx xx xx xx bricks: .res 6 ; bottom floor, one byte per row (bit c = column c) 000014r 1 xx xx 000016r 1 xx xx xx balloons: .res 3 ; top floor rows: bits 0-2 P0 copies, bits 3-5 P1 copies 000019r 1 xx drops: .res 1 ; middle floor drop targets 00001Ar 1 pEnd: 00001Ar 1 PBLK = pEnd - pStart 00001Ar 1 xx xx xx xx stash: .res PBLK ; the other player's block 00001Er 1 xx xx xx xx 000022r 1 xx xx xx xx 00002Ar 1 00002Ar 1 xx ballXL: .res 1 00002Br 1 xx ballX: .res 1 00002Cr 1 xx ballYL: .res 1 00002Dr 1 xx ballY: .res 1 00002Er 1 xx vxL: .res 1 00002Fr 1 xx vxH: .res 1 000030r 1 xx vyL: .res 1 000031r 1 xx vyH: .res 1 000032r 1 xx floor: .res 1 ; 0 bottom, 1 middle, 2 top 000033r 1 xx speed: .res 1 ; 0-7 000034r 1 xx cool: .res 1 ; collision cool-down frames 000035r 1 000035r 1 xx batX: .res 1 000036r 1 xx padY: .res 1 000037r 1 xx kick: .res 1 ; kick timer 000038r 1 xx batW: .res 1 ; 16 or 24 000039r 1 000039r 1 xx xx xx rowX: .res 3 ; balloon rows' x 00003Cr 1 xx rowDirs: .res 1 ; bit r set: row r slides left 00003Dr 1 xx balT: .res 1 ; fours of frames until the next empty balloon row drifts in (0 idle) 00003Er 1 xx dropT: .res 1 ; fours of frames until the drop targets are back (0 idle) 00003Fr 1 xx multK: .res 1 ; this ball's score multiplier: (multiplier - 1) * 6, 0..24 000040r 1 xx clownX: .res 1 000041r 1 xx clownDir: .res 1 000042r 1 xx clownHit: .res 1 ; tumble timer 000043r 1 xx flash: .res 1 ; bumper flash timer 000044r 1 000044r 1 xx xx sfxPtr0: .res 2 000046r 1 xx sfxCnt0: .res 1 000047r 1 xx xx sfxPtr1: .res 2 000049r 1 xx sfxCnt1: .res 1 00004Ar 1 00004Ar 1 xx msgT: .res 1 ; message frames left 00004Br 1 xx msgIdx: .res 1 ; message offset in Messages 00004Cr 1 00004Cr 1 xx kernelMode: .res 1 ; 0 play, 1 title 00004Dr 1 xx ballK: .res 1 ; PLAYH-BH+1 - ballY: ball shows where Y-ballK < BH 00004Er 1 xx ballK2: .res 1 ; ballK+2 00004Fr 1 xx batCoarse: .res 1 000050r 1 xx batFine: .res 1 000051r 1 xx xx batPtr: .res 2 000053r 1 xx batCol: .res 1 000054r 1 xx pipsPF: .res 1 000055r 1 xx xx xx floorPF: .res 3 000058r 1 xx scoreCol: .res 1 000059r 1 xx clownTop: .res 1 ; clown frame's last table index 00005Ar 1 xx bumpCol: .res 1 00005Br 1 xx ballXpos: .res 1 ; ball x for the positioning routine 00005Cr 1 xx clownXpos: .res 1 00005Dr 1 xx titleX: .res 1 ; title balloons' x 00005Er 1 xx xx xx xx dropPF: .res 5 ; middle floor drop-target row: PF1 L, PF2 L, PF0 R, PF1 R, PF2 R 000062r 1 xx 000063r 1 000063r 1 xx xx xx xx dp: .res 12 ; score digit pointers / kernel temporaries 000067r 1 xx xx xx xx 00006Br 1 xx xx xx xx 00006Fr 1 xx tmp: .res 1 000070r 1 xx row: .res 1 000071r 1 xx t0: .res 1 000072r 1 xx t1: .res 1 000073r 1 xx t2: .res 1 000074r 1 xx t3: .res 1 000075r 1 000075r 1 ; kernel temporaries inside dp (used after the score is drawn) 000075r 1 tE1 = dp+0 000075r 1 tE2 = dp+1 000075r 1 v1L = dp+2 ; brick rows 000075r 1 v2L = dp+3 000075r 1 v0R = dp+4 000075r 1 v1R = dp+5 000075r 1 v2R = dp+6 000075r 1 bc0 = dp+2 ; balloon rows 000075r 1 bc1 = dp+3 000075r 1 bf0 = dp+4 000075r 1 bf1 = dp+5 000075r 1 bn0 = dp+6 000075r 1 bn1 = dp+7 000075r 1 bsum = dp+8 000075r 1 bcol = dp+9 ; the next balloon row's colour (HITCOL) 000075r 1 000075r 1 ; --------------------------------------------------------------------------- 000075r 1 ; Macros 000075r 1 000075r 1 ; SLEEP n: burn n cycles (n >= 2) without touching registers or flags 000075r 1 ; (BIT on a RAM byte changes flags; it is used only for odd counts and the 000075r 1 ; macro is never placed between a compare and its branch). 000075r 1 .macro SLEEP n 000075r 1 .if n = 1 000075r 1 .error "SLEEP 1" 000075r 1 .endif 000075r 1 .if (n .mod 2) = 1 000075r 1 bit $80 000075r 1 .repeat (n-3)/2 000075r 1 nop 000075r 1 .endrepeat 000075r 1 .else 000075r 1 .repeat n/2 000075r 1 nop 000075r 1 .endrepeat 000075r 1 .endif 000075r 1 .endmacro 000075r 1 000075r 1 ; GUARD n: if the next n bytes would cross a page, jump to the next page 000075r 1 ; (3 cycles, placed where the line has room). Keeps timed loops' branches from 000075r 1 ; taking the extra page-crossing cycle; the loops also assert it. 000075r 1 .macro GUARD n 000075r 1 .if (<*) + (n) > 256 000075r 1 jmp :+ 000075r 1 .res (256 - <*) & $FF, $EA 000075r 1 : 000075r 1 .endif 000075r 1 .endmacro 000075r 1 000075r 1 ; KEXIT stub: the kernels' common exit, after their last visible line: ends that 000075r 1 ; line, blanks, and returns to bank 0 at the same cycle from every kernel (the 000075r 1 ; overscan timer starts from there). 000075r 1 .macro KEXIT stub 000075r 1 sta WSYNC 000075r 1 lda #$82 000075r 1 sta VBLANK 000075r 1 lda #0 000075r 1 sta ENABL 000075r 1 sta GRP0 000075r 1 sta GRP1 000075r 1 sta PF0 000075r 1 sta PF1 000075r 1 sta PF2 000075r 1 sta COLUBK 000075r 1 jmp stub 000075r 1 .endmacro 000075r 1 000075r 1 ; BALL: 16 cycles. ENABL for the current line from the line counter Y. 000075r 1 .macro BALL 000075r 1 tya 000075r 1 sec 000075r 1 sbc ballK 000075r 1 cmp #BH 000075r 1 lda #$FF 000075r 1 adc #0 000075r 1 sta ENABL 000075r 1 .endmacro 000075r 1 000075r 1 ; BALLAT kv, dest: 16 cycles. ENABL value for a later line (kv = ballK2). 000075r 1 .macro BALLAT kv, dest 000075r 1 tya 000075r 1 sec 000075r 1 sbc kv 000075r 1 cmp #BH 000075r 1 lda #$FF 000075r 1 adc #0 000075r 1 sta dest 000075r 1 .endmacro 000075r 1 000075r 1 ; BALLAT1 dest: 16 cycles. ENABL value for the next line: Y - ballK - 1, the 1 000075r 1 ; from the borrow of a clear carry (saves a RAM byte; same cycles as BALLAT). 000075r 1 .macro BALLAT1 dest 000075r 1 tya 000075r 1 clc 000075r 1 sbc ballK 000075r 1 cmp #BH 000075r 1 lda #$FF 000075r 1 adc #0 000075r 1 sta dest 000075r 1 .endmacro 000075r 1 000075r 1 ; PADDLE9: 9 cycles on either path. While INPT0 D7 is still low (capacitor not 000075r 1 ; yet charged, DOC: SPG "Dumped Input Ports"), remember this line's Y in padY. 000075r 1 ; The $2C byte is BIT absolute: on the charged path it swallows `sty padY`. 000075r 1 .macro PADDLE9 000075r 1 .local skip 000075r 1 bit INPT0 000075r 1 bpl skip 000075r 1 .byte $2C 000075r 1 skip: sty padY 000075r 1 .assert >(skip-1) = >skip, error, "PADDLE9 branch crosses a page" 000075r 1 .endmacro 000075r 1 000075r 1 .include "bands.inc" 000075r 2 ; SPDX-License-Identifier: MIT 000075r 2 ; Play-area band macros shared by the two play-kernel banks. KY is the line 000075r 2 ; counter value (Y) at the band's first line; each macro advances it. 000075r 2 000075r 2 ; --------------------------------------------------------------------------- 000075r 2 ; Shared play-area bands. 000075r 2 000075r 2 ; EMPTY n: n plain lines (ball, paddle). 000075r 2 .macro EMPTY n 000075r 2 .local loop 000075r 2 GUARD 30 000075r 2 loop: sta WSYNC 000075r 2 BALL ; 16 000075r 2 PADDLE9 ; 25 000075r 2 dey ; 27 000075r 2 cpy #(KY-(n)) ; 29 000075r 2 bne loop ; 32 000075r 2 .assert >loop = >*, error, "EMPTY loop crosses a page" 000075r 2 KY .set KY-(n) 000075r 2 .endmacro 000075r 2 000075r 2 ; RELEASE: line 59 on every floor: stop dumping the paddle capacitors. 000075r 2 .macro RELEASE 000075r 2 .assert KY = RELEASE_Y, error, "RELEASE on the wrong line" 000075r 2 sta WSYNC 000075r 2 BALL ; 16 000075r 2 lda #0 ; 18 000075r 2 sta VBLANK ; 21 000075r 2 lda #PADINIT ; 23 000075r 2 sta padY ; 26 000075r 2 PADDLE9 ; 35 000075r 2 dey ; 37 000075r 2 KY .set KY-1 000075r 2 .endmacro 000075r 2 000075r 2 ; BATBAND: the last 18 lines (Y 18..1): position P0, then draw the bat. 000075r 2 .macro BATBAND 000075r 2 .local s1loop, batloop 000075r 2 .assert KY = 18, error, "BATBAND must start at Y=18" 000075r 2 ; s0 (Y=18) 000075r 2 sta WSYNC 000075r 2 BALL ; 16 000075r 2 PADDLE9 ; 25 000075r 2 BALLAT1 tE1 ; 41 000075r 2 lda #0 ; 43 000075r 2 sta GRP0 ; 46 000075r 2 lda batFine ; 49 000075r 2 sta HMP0 ; 52 000075r 2 ldx batCoarse ; 55 000075r 2 dey ; 57 000075r 2 ; s1 (Y=17) 000075r 2 sta WSYNC ; 60 000075r 2 lda tE1 ; 3 000075r 2 sta ENABL ; 6 000075r 2 PADDLE9 ; 15 000075r 2 GUARD 8 000075r 2 s1loop: dex ; 000075r 2 bpl s1loop ; 15+5c+4 000075r 2 sta RESP0 ; 22+5c (c <= 9: 67) 000075r 2 .assert >s1loop = >*, error, "bat loop crosses a page" 000075r 2 dey ; 69 000075r 2 ; s2 (Y=16) 000075r 2 sta WSYNC 000075r 2 sta HMOVE ; 3 000075r 2 BALL ; 19 000075r 2 PADDLE9 ; 28 000075r 2 lda #7 ; 30 (quad width) 000075r 2 sta NUSIZ0 ; 33 000075r 2 lda batCol ; 36 000075r 2 sta COLUP0 ; 39 000075r 2 dey ; 41 000075r 2 sta HMCLR ; 44 000075r 2 GUARD 32 000075r 2 batloop: 000075r 2 sta WSYNC 000075r 2 BALL ; 16 000075r 2 lda (batPtr),y ; 21 000075r 2 sta GRP0 ; 24 000075r 2 PADDLE9 ; 33 000075r 2 dey ; 35 000075r 2 bne batloop ; 38 000075r 2 .assert >batloop = >*, error, "bat loop crosses a page" 000075r 2 KY .set 0 000075r 2 .endmacro 000075r 2 000075r 2 ; --------------------------------------------------------------------------- 000075r 2 ; Brick-row bands. Non-reflected playfield with every register written twice a 000075r 2 ; line: the wall ($F0 in PF0 left and PF2 right) is merged into the values. 000075r 2 ; Write windows (cycle of the store's write, DOC: SPG playfield timing; checked 000075r 2 ; on our board): PF0 right 28-49, PF1 right 39-54, PF2 right 50-64, PF0 next 000075r 2 ; line >= 55, PF1 next line >= 66, PF2 left before 38. 000075r 2 000075r 2 ; BRICK_E: switch to the non-reflected playfield, walls only. 000075r 2 .macro BRICK_E 000075r 2 sta WSYNC 000075r 2 BALL ; 16 000075r 2 lda #CTRL_NONREF ; 18 000075r 2 sta CTRLPF ; 21 000075r 2 lda #0 ; 23 000075r 2 sta PF2 ; 26 000075r 2 PADDLE9 ; 35 000075r 2 sta PF0 ; 38 right PF0 = 0 000075r 2 lda #$F0 ; 40 000075r 2 SLEEP 10 ; 50 000075r 2 sta PF2 ; 53 right wall 000075r 2 sta PF0 ; 56 next line's left wall 000075r 2 dey ; 58 000075r 2 KY .set KY-1 000075r 2 .endmacro 000075r 2 000075r 2 ; BRICK_T: back to the reflected playfield with plain walls. 000075r 2 .macro BRICK_T wallcol 000075r 2 sta WSYNC 000075r 2 BALL ; 16 000075r 2 lda #0 ; 18 000075r 2 sta PF1 ; 21 000075r 2 sta PF2 ; 24 000075r 2 lda #CTRL_REF ; 26 000075r 2 sta CTRLPF ; 29 000075r 2 PADDLE9 ; 38 000075r 2 lda #wallcol ; 40 000075r 2 sta COLUPF ; 43 000075r 2 dey ; 45 000075r 2 KY .set KY-1 000075r 2 .endmacro 000075r 2 000075r 2 ; BRICK_TV: BRICK_T with the wall colour from bcol (the ball's power colour on the 000075r 2 ; middle floor); one cycle later. 000075r 2 .macro BRICK_TV 000075r 2 sta WSYNC 000075r 2 BALL ; 16 000075r 2 lda #0 ; 18 000075r 2 sta PF1 ; 21 000075r 2 sta PF2 ; 24 000075r 2 lda #CTRL_REF ; 26 000075r 2 sta CTRLPF ; 29 000075r 2 PADDLE9 ; 38 000075r 2 lda bcol ; 41 000075r 2 sta COLUPF ; 44 000075r 2 dey ; 46 000075r 2 KY .set KY-1 000075r 2 .endmacro 000075r 2 000075r 2 ; BRICK_ROW mask, col, n: two gap lines (G1, G2) that look the row up, then n 000075r 2 ; brick lines. 000075r 2 .macro BRICK_ROW mask, col, n 000075r 2 .local bl 000075r 2 ; G1 000075r 2 sta WSYNC 000075r 2 BALL ; 16 000075r 2 lda #0 ; 18 000075r 2 sta PF1 ; 21 000075r 2 sta PF2 ; 24 000075r 2 ldx #col ; 26 000075r 2 stx COLUPF ; 29 000075r 2 PADDLE9 ; 38 000075r 2 sta PF0 ; 41 right PF0 = 0 000075r 2 ldx mask ; 44 000075r 2 lda TA,x ; 48 000075r 2 sta v1L ; 51 000075r 2 lda TB,x ; 55 000075r 2 sta v2L ; 58 000075r 2 lda #$F0 ; 60 000075r 2 sta PF2 ; 63 right wall 000075r 2 sta PF0 ; 66 next left wall 000075r 2 dey ; 68 000075r 2 ; G2 000075r 2 sta WSYNC ; 71 000075r 2 BALL ; 16 000075r 2 lda #0 ; 18 000075r 2 sta PF2 ; 21 000075r 2 PADDLE9 ; 30 000075r 2 sta PF0 ; 33 000075r 2 lda TC,x ; 37 000075r 2 sta v0R ; 40 000075r 2 lda TD,x ; 44 000075r 2 sta v1R ; 47 000075r 2 lda TE,x ; 51 000075r 2 sta v2R ; 54 000075r 2 lda #$F0 ; 56 000075r 2 sta PF2 ; 59 000075r 2 sta PF0 ; 62 000075r 2 ldx v1L ; 65 000075r 2 stx PF1 ; 68 first brick line's left PF1 000075r 2 dey ; 70 000075r 2 KY .set KY-2 000075r 2 BRICK_LINES v1L, n 000075r 2 .endmacro 000075r 2 000075r 2 ; BRICK_LINES base, n: n brick lines from the five values at base: 000075r 2 ; PF1 left, PF2 left, PF0 right, PF1 right, PF2 right. 000075r 2 .macro BRICK_LINES base, n 000075r 2 .local bl 000075r 2 GUARD 56 000075r 2 bl: sta WSYNC ; 73 000075r 2 BALL ; 16 000075r 2 lda base+1 ; 19 000075r 2 sta PF2 ; 22 000075r 2 lda base+2 ; 25 000075r 2 ldx base+3 ; 28 000075r 2 sta PF0 ; 31 000075r 2 lda base+4 ; 34 000075r 2 PADDLE9 ; 43 000075r 2 stx PF1 ; 46 000075r 2 ldx base+0 ; 49 000075r 2 dey ; 51 000075r 2 sta PF2 ; 54 000075r 2 lda #$F0 ; 56 000075r 2 sta PF0 ; 59 000075r 2 cpy #(KY-(n)) ; 61 000075r 2 nop ; 63 000075r 2 nop ; 65 000075r 2 stx PF1 ; 68 000075r 2 bne bl ; 71 000075r 2 .assert >bl = >*, error, "brick loop crosses a page" 000075r 2 KY .set KY-(n) 000075r 2 .endmacro 000075r 2 000075r 2 ; BRICK_ROWV base, col, n: a row whose five values are already in RAM at base 000075r 2 ; (the drop targets, prepared by bank 0): two gap lines, then n brick lines. 000075r 2 .macro BRICK_ROWV base, col, n 000075r 2 ; G1 000075r 2 sta WSYNC 000075r 2 BALL ; 16 000075r 2 lda #0 ; 18 000075r 2 sta PF1 ; 21 000075r 2 sta PF2 ; 24 000075r 2 ldx #col ; 26 000075r 2 stx COLUPF ; 29 000075r 2 PADDLE9 ; 38 000075r 2 sta PF0 ; 41 000075r 2 lda #$F0 ; 43 000075r 2 SLEEP 12 ; 55 000075r 2 sta PF2 ; 58 000075r 2 sta PF0 ; 61 000075r 2 dey ; 63 000075r 2 ; G2 000075r 2 sta WSYNC 000075r 2 BALL ; 16 000075r 2 lda #0 ; 18 000075r 2 sta PF2 ; 21 000075r 2 PADDLE9 ; 30 000075r 2 sta PF0 ; 33 000075r 2 lda #$F0 ; 35 000075r 2 SLEEP 16 ; 51 000075r 2 sta PF2 ; 54 000075r 2 sta PF0 ; 57 000075r 2 ldx base+0 ; 60 000075r 2 SLEEP 4 ; 64 000075r 2 stx PF1 ; 67 000075r 2 dey ; 69 000075r 2 KY .set KY-2 000075r 2 BRICK_LINES base, n 000075r 2 .endmacro 000075r 2 000075r 2 000075r 1 .include "play_low.s" 000075r 2 ; SPDX-License-Identifier: MIT 000075r 2 ; Bank 3: the play kernel for the bottom floor (the brick wall). Line numbers below are 000075r 2 ; play-area lines (0-169); Y = 170 - line. Cycle counts are the cycle at which 000075r 2 ; the instruction ends, counted from the end of the line's WSYNC. 000075r 2 000075r 2 .segment "BANK3" 000000r 2 .org $9000 009000 2 .scope low 009000 2 TOLOGIC = ToLogic3 009000 2 .include "shared.s" 009000 3 ; SPDX-License-Identifier: MIT 009000 3 ; Shared start of the two play-kernel banks (1 and 3). Included inside each bank's 009000 3 ; scope; the including file defines FloorSetup (the floor's set-up lines) and 009000 3 ; TOLOGIC (the stub that returns to bank 0). Font and BatGfx sit at the same 009000 3 ; offsets in both banks (and Font in bank 2), so one pointer serves all banks. 009000 3 009000 3 .include "gen/font.inc" ; offset $000, one page 009000 4 ; SPDX-License-Identifier: MIT 009000 4 ; Generated by scripts/gen_tables.py: do not edit. 009000 4 .align 256 009000 4 Font: 009000 4 ; '0' 009000 4 00 7C C6 E6 .byte $00,$7C,$C6,$E6,$D6,$CE,$C6,$7C 009004 4 D6 CE C6 7C 009008 4 ; '1' 009008 4 00 7E 18 18 .byte $00,$7E,$18,$18,$18,$78,$38,$18 00900C 4 18 78 38 18 009010 4 ; '2' 009010 4 00 FE C0 70 .byte $00,$FE,$C0,$70,$1C,$06,$C6,$7C 009014 4 1C 06 C6 7C 009018 4 ; '3' 009018 4 00 7C C6 06 .byte $00,$7C,$C6,$06,$3C,$06,$C6,$7C 00901C 4 3C 06 C6 7C 009020 4 ; '4' 009020 4 00 0C 0C FE .byte $00,$0C,$0C,$FE,$6C,$3C,$1C,$0C 009024 4 6C 3C 1C 0C 009028 4 ; '5' 009028 4 00 7C C6 06 .byte $00,$7C,$C6,$06,$06,$FC,$C0,$FE 00902C 4 06 FC C0 FE 009030 4 ; '6' 009030 4 00 7C C6 C6 .byte $00,$7C,$C6,$C6,$FC,$C0,$60,$3C 009034 4 FC C0 60 3C 009038 4 ; '7' 009038 4 00 30 30 30 .byte $00,$30,$30,$30,$18,$0C,$06,$FE 00903C 4 18 0C 06 FE 009040 4 ; '8' 009040 4 00 7C C6 C6 .byte $00,$7C,$C6,$C6,$7C,$C6,$C6,$7C 009044 4 7C C6 C6 7C 009048 4 ; '9' 009048 4 00 78 0C 06 .byte $00,$78,$0C,$06,$7E,$C6,$C6,$7C 00904C 4 7E C6 C6 7C 009050 4 ; ' ' 009050 4 00 00 00 00 .byte $00,$00,$00,$00,$00,$00,$00,$00 009054 4 00 00 00 00 009058 4 ; 'A' 009058 4 00 C6 C6 FE .byte $00,$C6,$C6,$FE,$C6,$C6,$6C,$38 00905C 4 C6 C6 6C 38 009060 4 ; 'B' 009060 4 00 FC C6 C6 .byte $00,$FC,$C6,$C6,$FC,$C6,$C6,$FC 009064 4 FC C6 C6 FC 009068 4 ; 'C' 009068 4 00 7C C6 C0 .byte $00,$7C,$C6,$C0,$C0,$C0,$C6,$7C 00906C 4 C0 C0 C6 7C 009070 4 ; 'E' 009070 4 00 FE C0 C0 .byte $00,$FE,$C0,$C0,$F8,$C0,$C0,$FE 009074 4 F8 C0 C0 FE 009078 4 ; 'G' 009078 4 00 7E C6 C6 .byte $00,$7E,$C6,$C6,$DE,$C0,$C6,$7C 00907C 4 DE C0 C6 7C 009080 4 ; 'I' 009080 4 00 7E 18 18 .byte $00,$7E,$18,$18,$18,$18,$18,$7E 009084 4 18 18 18 7E 009088 4 ; 'K' 009088 4 00 C6 CC D8 .byte $00,$C6,$CC,$D8,$F0,$D8,$CC,$C6 00908C 4 F0 D8 CC C6 009090 4 ; 'L' 009090 4 00 FE C0 C0 .byte $00,$FE,$C0,$C0,$C0,$C0,$C0,$C0 009094 4 C0 C0 C0 C0 009098 4 ; 'M' 009098 4 00 C6 C6 C6 .byte $00,$C6,$C6,$C6,$D6,$FE,$EE,$C6 00909C 4 D6 FE EE C6 0090A0 4 ; 'N' 0090A0 4 00 C6 C6 CE .byte $00,$C6,$C6,$CE,$DE,$F6,$E6,$C6 0090A4 4 DE F6 E6 C6 0090A8 4 ; 'O' 0090A8 4 00 7C C6 C6 .byte $00,$7C,$C6,$C6,$C6,$C6,$C6,$7C 0090AC 4 C6 C6 C6 7C 0090B0 4 ; 'P' 0090B0 4 00 C0 C0 C0 .byte $00,$C0,$C0,$C0,$FC,$C6,$C6,$FC 0090B4 4 FC C6 C6 FC 0090B8 4 ; 'R' 0090B8 4 00 C6 CC D8 .byte $00,$C6,$CC,$D8,$FC,$C6,$C6,$FC 0090BC 4 FC C6 C6 FC 0090C0 4 ; 'S' 0090C0 4 00 7C C6 06 .byte $00,$7C,$C6,$06,$7C,$C0,$C6,$7C 0090C4 4 7C C0 C6 7C 0090C8 4 ; 'T' 0090C8 4 00 30 30 30 .byte $00,$30,$30,$30,$30,$30,$30,$FC 0090CC 4 30 30 30 FC 0090D0 4 ; 'U' 0090D0 4 00 7C C6 C6 .byte $00,$7C,$C6,$C6,$C6,$C6,$C6,$C6 0090D4 4 C6 C6 C6 C6 0090D8 4 ; 'V' 0090D8 4 00 10 38 6C .byte $00,$10,$38,$6C,$C6,$C6,$C6,$C6 0090DC 4 C6 C6 C6 C6 0090E0 4 ; 'X' 0090E0 4 00 C6 6C 38 .byte $00,$C6,$6C,$38,$38,$38,$6C,$C6 0090E4 4 38 38 6C C6 0090E8 4 ; 'Y' 0090E8 4 00 30 30 30 .byte $00,$30,$30,$30,$30,$78,$CC,$CC 0090EC 4 30 78 CC CC 0090F0 4 ; '!' 0090F0 4 00 18 00 18 .byte $00,$18,$00,$18,$18,$18,$18,$18 0090F4 4 18 18 18 18 0090F8 4 ; '-' 0090F8 4 00 00 00 00 .byte $00,$00,$00,$00,$7C,$00,$00,$00 0090FC 4 7C 00 00 00 009100 4 009100 3 009100 3 .align 256 009100 3 BatGfx: 009100 3 .include "gen/bat.inc" 009100 4 ; SPDX-License-Identifier: MIT 009100 4 ; Generated by scripts/gen_tables.py: do not edit. 009100 4 BatBlank = * - BatGfx 009100 4 00 00 00 00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 009104 4 00 00 00 00 009108 4 00 00 00 00 009110 4 Bat16N = * - BatGfx 009110 4 00 00 00 00 .byte $00,$00,$00,$00,$00,$00,$00,$60,$F0,$F0,$60,$00,$00,$00,$00,$00 009114 4 00 00 00 60 009118 4 F0 F0 60 00 009120 4 Bat16K = * - BatGfx 009120 4 00 00 00 00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$60,$F0,$F0,$60,$00,$00,$00 009124 4 00 00 00 00 009128 4 00 60 F0 F0 009130 4 Bat24N = * - BatGfx 009130 4 00 00 00 00 .byte $00,$00,$00,$00,$00,$00,$00,$78,$FC,$FC,$78,$00,$00,$00,$00,$00 009134 4 00 00 00 78 009138 4 FC FC 78 00 009140 4 Bat24K = * - BatGfx 009140 4 00 00 00 00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$78,$FC,$FC,$78,$00,$00,$00 009144 4 00 00 00 00 009148 4 00 78 FC FC 009150 4 009150 3 ; the including bank's own small graphics follow in this page 009150 3 009150 3 009150 2 .include "gen/low.inc" 009150 3 ; SPDX-License-Identifier: MIT 009150 3 ; Generated by scripts/gen_tables.py: do not edit. 009150 3 xx xx xx xx .align 256 009154 3 xx xx xx xx 009158 3 xx xx xx xx 009200 3 TA: 009200 3 00 E0 0E EE .byte $00,$E0,$0E,$EE,$00,$E0,$0E,$EE,$00,$E0,$0E,$EE,$00,$E0,$0E,$EE 009204 3 00 E0 0E EE 009208 3 00 E0 0E EE 009210 3 00 E0 0E EE .byte $00,$E0,$0E,$EE,$00,$E0,$0E,$EE,$00,$E0,$0E,$EE,$00,$E0,$0E,$EE 009214 3 00 E0 0E EE 009218 3 00 E0 0E EE 009220 3 00 E0 0E EE .byte $00,$E0,$0E,$EE,$00,$E0,$0E,$EE,$00,$E0,$0E,$EE,$00,$E0,$0E,$EE 009224 3 00 E0 0E EE 009228 3 00 E0 0E EE 009230 3 00 E0 0E EE .byte $00,$E0,$0E,$EE,$00,$E0,$0E,$EE,$00,$E0,$0E,$EE,$00,$E0,$0E,$EE 009234 3 00 E0 0E EE 009238 3 00 E0 0E EE 009240 3 00 E0 0E EE .byte $00,$E0,$0E,$EE,$00,$E0,$0E,$EE,$00,$E0,$0E,$EE,$00,$E0,$0E,$EE 009244 3 00 E0 0E EE 009248 3 00 E0 0E EE 009250 3 00 E0 0E EE .byte $00,$E0,$0E,$EE,$00,$E0,$0E,$EE,$00,$E0,$0E,$EE,$00,$E0,$0E,$EE 009254 3 00 E0 0E EE 009258 3 00 E0 0E EE 009260 3 00 E0 0E EE .byte $00,$E0,$0E,$EE,$00,$E0,$0E,$EE,$00,$E0,$0E,$EE,$00,$E0,$0E,$EE 009264 3 00 E0 0E EE 009268 3 00 E0 0E EE 009270 3 00 E0 0E EE .byte $00,$E0,$0E,$EE,$00,$E0,$0E,$EE,$00,$E0,$0E,$EE,$00,$E0,$0E,$EE 009274 3 00 E0 0E EE 009278 3 00 E0 0E EE 009280 3 00 E0 0E EE .byte $00,$E0,$0E,$EE,$00,$E0,$0E,$EE,$00,$E0,$0E,$EE,$00,$E0,$0E,$EE 009284 3 00 E0 0E EE 009288 3 00 E0 0E EE 009290 3 00 E0 0E EE .byte $00,$E0,$0E,$EE,$00,$E0,$0E,$EE,$00,$E0,$0E,$EE,$00,$E0,$0E,$EE 009294 3 00 E0 0E EE 009298 3 00 E0 0E EE 0092A0 3 00 E0 0E EE .byte $00,$E0,$0E,$EE,$00,$E0,$0E,$EE,$00,$E0,$0E,$EE,$00,$E0,$0E,$EE 0092A4 3 00 E0 0E EE 0092A8 3 00 E0 0E EE 0092B0 3 00 E0 0E EE .byte $00,$E0,$0E,$EE,$00,$E0,$0E,$EE,$00,$E0,$0E,$EE,$00,$E0,$0E,$EE 0092B4 3 00 E0 0E EE 0092B8 3 00 E0 0E EE 0092C0 3 00 E0 0E EE .byte $00,$E0,$0E,$EE,$00,$E0,$0E,$EE,$00,$E0,$0E,$EE,$00,$E0,$0E,$EE 0092C4 3 00 E0 0E EE 0092C8 3 00 E0 0E EE 0092D0 3 00 E0 0E EE .byte $00,$E0,$0E,$EE,$00,$E0,$0E,$EE,$00,$E0,$0E,$EE,$00,$E0,$0E,$EE 0092D4 3 00 E0 0E EE 0092D8 3 00 E0 0E EE 0092E0 3 00 E0 0E EE .byte $00,$E0,$0E,$EE,$00,$E0,$0E,$EE,$00,$E0,$0E,$EE,$00,$E0,$0E,$EE 0092E4 3 00 E0 0E EE 0092E8 3 00 E0 0E EE 0092F0 3 00 E0 0E EE .byte $00,$E0,$0E,$EE,$00,$E0,$0E,$EE,$00,$E0,$0E,$EE,$00,$E0,$0E,$EE 0092F4 3 00 E0 0E EE 0092F8 3 00 E0 0E EE 009300 3 .align 256 009300 3 TB: 009300 3 00 00 00 00 .byte $00,$00,$00,$00,$07,$07,$07,$07,$70,$70,$70,$70,$77,$77,$77,$77 009304 3 07 07 07 07 009308 3 70 70 70 70 009310 3 00 00 00 00 .byte $00,$00,$00,$00,$07,$07,$07,$07,$70,$70,$70,$70,$77,$77,$77,$77 009314 3 07 07 07 07 009318 3 70 70 70 70 009320 3 00 00 00 00 .byte $00,$00,$00,$00,$07,$07,$07,$07,$70,$70,$70,$70,$77,$77,$77,$77 009324 3 07 07 07 07 009328 3 70 70 70 70 009330 3 00 00 00 00 .byte $00,$00,$00,$00,$07,$07,$07,$07,$70,$70,$70,$70,$77,$77,$77,$77 009334 3 07 07 07 07 009338 3 70 70 70 70 009340 3 00 00 00 00 .byte $00,$00,$00,$00,$07,$07,$07,$07,$70,$70,$70,$70,$77,$77,$77,$77 009344 3 07 07 07 07 009348 3 70 70 70 70 009350 3 00 00 00 00 .byte $00,$00,$00,$00,$07,$07,$07,$07,$70,$70,$70,$70,$77,$77,$77,$77 009354 3 07 07 07 07 009358 3 70 70 70 70 009360 3 00 00 00 00 .byte $00,$00,$00,$00,$07,$07,$07,$07,$70,$70,$70,$70,$77,$77,$77,$77 009364 3 07 07 07 07 009368 3 70 70 70 70 009370 3 00 00 00 00 .byte $00,$00,$00,$00,$07,$07,$07,$07,$70,$70,$70,$70,$77,$77,$77,$77 009374 3 07 07 07 07 009378 3 70 70 70 70 009380 3 00 00 00 00 .byte $00,$00,$00,$00,$07,$07,$07,$07,$70,$70,$70,$70,$77,$77,$77,$77 009384 3 07 07 07 07 009388 3 70 70 70 70 009390 3 00 00 00 00 .byte $00,$00,$00,$00,$07,$07,$07,$07,$70,$70,$70,$70,$77,$77,$77,$77 009394 3 07 07 07 07 009398 3 70 70 70 70 0093A0 3 00 00 00 00 .byte $00,$00,$00,$00,$07,$07,$07,$07,$70,$70,$70,$70,$77,$77,$77,$77 0093A4 3 07 07 07 07 0093A8 3 70 70 70 70 0093B0 3 00 00 00 00 .byte $00,$00,$00,$00,$07,$07,$07,$07,$70,$70,$70,$70,$77,$77,$77,$77 0093B4 3 07 07 07 07 0093B8 3 70 70 70 70 0093C0 3 00 00 00 00 .byte $00,$00,$00,$00,$07,$07,$07,$07,$70,$70,$70,$70,$77,$77,$77,$77 0093C4 3 07 07 07 07 0093C8 3 70 70 70 70 0093D0 3 00 00 00 00 .byte $00,$00,$00,$00,$07,$07,$07,$07,$70,$70,$70,$70,$77,$77,$77,$77 0093D4 3 07 07 07 07 0093D8 3 70 70 70 70 0093E0 3 00 00 00 00 .byte $00,$00,$00,$00,$07,$07,$07,$07,$70,$70,$70,$70,$77,$77,$77,$77 0093E4 3 07 07 07 07 0093E8 3 70 70 70 70 0093F0 3 00 00 00 00 .byte $00,$00,$00,$00,$07,$07,$07,$07,$70,$70,$70,$70,$77,$77,$77,$77 0093F4 3 07 07 07 07 0093F8 3 70 70 70 70 009400 3 .align 256 009400 3 TC: 009400 3 00 00 00 00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 009404 3 00 00 00 00 009408 3 00 00 00 00 009410 3 70 70 70 70 .byte $70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70 009414 3 70 70 70 70 009418 3 70 70 70 70 009420 3 00 00 00 00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 009424 3 00 00 00 00 009428 3 00 00 00 00 009430 3 70 70 70 70 .byte $70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70 009434 3 70 70 70 70 009438 3 70 70 70 70 009440 3 00 00 00 00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 009444 3 00 00 00 00 009448 3 00 00 00 00 009450 3 70 70 70 70 .byte $70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70 009454 3 70 70 70 70 009458 3 70 70 70 70 009460 3 00 00 00 00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 009464 3 00 00 00 00 009468 3 00 00 00 00 009470 3 70 70 70 70 .byte $70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70 009474 3 70 70 70 70 009478 3 70 70 70 70 009480 3 00 00 00 00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 009484 3 00 00 00 00 009488 3 00 00 00 00 009490 3 70 70 70 70 .byte $70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70 009494 3 70 70 70 70 009498 3 70 70 70 70 0094A0 3 00 00 00 00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 0094A4 3 00 00 00 00 0094A8 3 00 00 00 00 0094B0 3 70 70 70 70 .byte $70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70 0094B4 3 70 70 70 70 0094B8 3 70 70 70 70 0094C0 3 00 00 00 00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 0094C4 3 00 00 00 00 0094C8 3 00 00 00 00 0094D0 3 70 70 70 70 .byte $70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70 0094D4 3 70 70 70 70 0094D8 3 70 70 70 70 0094E0 3 00 00 00 00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 0094E4 3 00 00 00 00 0094E8 3 00 00 00 00 0094F0 3 70 70 70 70 .byte $70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70,$70 0094F4 3 70 70 70 70 0094F8 3 70 70 70 70 009500 3 .align 256 009500 3 TD: 009500 3 00 00 00 00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 009504 3 00 00 00 00 009508 3 00 00 00 00 009510 3 00 00 00 00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 009514 3 00 00 00 00 009518 3 00 00 00 00 009520 3 E0 E0 E0 E0 .byte $E0,$E0,$E0,$E0,$E0,$E0,$E0,$E0,$E0,$E0,$E0,$E0,$E0,$E0,$E0,$E0 009524 3 E0 E0 E0 E0 009528 3 E0 E0 E0 E0 009530 3 E0 E0 E0 E0 .byte $E0,$E0,$E0,$E0,$E0,$E0,$E0,$E0,$E0,$E0,$E0,$E0,$E0,$E0,$E0,$E0 009534 3 E0 E0 E0 E0 009538 3 E0 E0 E0 E0 009540 3 0E 0E 0E 0E .byte $0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E 009544 3 0E 0E 0E 0E 009548 3 0E 0E 0E 0E 009550 3 0E 0E 0E 0E .byte $0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E 009554 3 0E 0E 0E 0E 009558 3 0E 0E 0E 0E 009560 3 EE EE EE EE .byte $EE,$EE,$EE,$EE,$EE,$EE,$EE,$EE,$EE,$EE,$EE,$EE,$EE,$EE,$EE,$EE 009564 3 EE EE EE EE 009568 3 EE EE EE EE 009570 3 EE EE EE EE .byte $EE,$EE,$EE,$EE,$EE,$EE,$EE,$EE,$EE,$EE,$EE,$EE,$EE,$EE,$EE,$EE 009574 3 EE EE EE EE 009578 3 EE EE EE EE 009580 3 00 00 00 00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 009584 3 00 00 00 00 009588 3 00 00 00 00 009590 3 00 00 00 00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 009594 3 00 00 00 00 009598 3 00 00 00 00 0095A0 3 E0 E0 E0 E0 .byte $E0,$E0,$E0,$E0,$E0,$E0,$E0,$E0,$E0,$E0,$E0,$E0,$E0,$E0,$E0,$E0 0095A4 3 E0 E0 E0 E0 0095A8 3 E0 E0 E0 E0 0095B0 3 E0 E0 E0 E0 .byte $E0,$E0,$E0,$E0,$E0,$E0,$E0,$E0,$E0,$E0,$E0,$E0,$E0,$E0,$E0,$E0 0095B4 3 E0 E0 E0 E0 0095B8 3 E0 E0 E0 E0 0095C0 3 0E 0E 0E 0E .byte $0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E 0095C4 3 0E 0E 0E 0E 0095C8 3 0E 0E 0E 0E 0095D0 3 0E 0E 0E 0E .byte $0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E 0095D4 3 0E 0E 0E 0E 0095D8 3 0E 0E 0E 0E 0095E0 3 EE EE EE EE .byte $EE,$EE,$EE,$EE,$EE,$EE,$EE,$EE,$EE,$EE,$EE,$EE,$EE,$EE,$EE,$EE 0095E4 3 EE EE EE EE 0095E8 3 EE EE EE EE 0095F0 3 EE EE EE EE .byte $EE,$EE,$EE,$EE,$EE,$EE,$EE,$EE,$EE,$EE,$EE,$EE,$EE,$EE,$EE,$EE 0095F4 3 EE EE EE EE 0095F8 3 EE EE EE EE 009600 3 .align 256 009600 3 TE: 009600 3 F0 F0 F0 F0 .byte $F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0 009604 3 F0 F0 F0 F0 009608 3 F0 F0 F0 F0 009610 3 F0 F0 F0 F0 .byte $F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0 009614 3 F0 F0 F0 F0 009618 3 F0 F0 F0 F0 009620 3 F0 F0 F0 F0 .byte $F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0 009624 3 F0 F0 F0 F0 009628 3 F0 F0 F0 F0 009630 3 F0 F0 F0 F0 .byte $F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0 009634 3 F0 F0 F0 F0 009638 3 F0 F0 F0 F0 009640 3 F0 F0 F0 F0 .byte $F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0 009644 3 F0 F0 F0 F0 009648 3 F0 F0 F0 F0 009650 3 F0 F0 F0 F0 .byte $F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0 009654 3 F0 F0 F0 F0 009658 3 F0 F0 F0 F0 009660 3 F0 F0 F0 F0 .byte $F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0 009664 3 F0 F0 F0 F0 009668 3 F0 F0 F0 F0 009670 3 F0 F0 F0 F0 .byte $F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0,$F0 009674 3 F0 F0 F0 F0 009678 3 F0 F0 F0 F0 009680 3 F7 F7 F7 F7 .byte $F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7 009684 3 F7 F7 F7 F7 009688 3 F7 F7 F7 F7 009690 3 F7 F7 F7 F7 .byte $F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7 009694 3 F7 F7 F7 F7 009698 3 F7 F7 F7 F7 0096A0 3 F7 F7 F7 F7 .byte $F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7 0096A4 3 F7 F7 F7 F7 0096A8 3 F7 F7 F7 F7 0096B0 3 F7 F7 F7 F7 .byte $F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7 0096B4 3 F7 F7 F7 F7 0096B8 3 F7 F7 F7 F7 0096C0 3 F7 F7 F7 F7 .byte $F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7 0096C4 3 F7 F7 F7 F7 0096C8 3 F7 F7 F7 F7 0096D0 3 F7 F7 F7 F7 .byte $F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7 0096D4 3 F7 F7 F7 F7 0096D8 3 F7 F7 F7 F7 0096E0 3 F7 F7 F7 F7 .byte $F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7 0096E4 3 F7 F7 F7 F7 0096E8 3 F7 F7 F7 F7 0096F0 3 F7 F7 F7 F7 .byte $F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7,$F7 0096F4 3 F7 F7 F7 F7 0096F8 3 F7 F7 F7 F7 009700 3 009700 2 .include "hud.s" 009700 3 ; SPDX-License-Identifier: MIT 009700 3 ; Shared play-kernel code (banks 1 and 3): positioning, the HUD, the kernel exit. 009700 3 ; Included inside each bank's scope after its graphics. 009700 3 009700 3 ; --------------------------------------------------------------------------- 009700 3 ; PosObj: A = x - POS_K (0..149), X = object (0 P0, 1 P1, 2 M0, 3 M1, 4 BL). 009700 3 ; Ends the current line, strobes RESx on the next one, ends that line, and sets 009700 3 ; HMxx early on the line after. Always exactly the same lines: the strobe falls 009700 3 ; at cycle 19+5k at the latest 69 (k <= 10, so x - POS_K <= 149). 009700 3 PosObj: 009700 3 85 02 sta WSYNC 009702 3 EA EA EA EA SLEEP 14 009706 3 EA EA EA 009709 3 38 sec 00970A 3 E9 0F @div: sbc #15 00970C 3 B0 FC bcs @div 00970E 3 95 10 sta RESP0,x 009710 3 85 02 sta WSYNC 009712 3 49 07 eor #7 009714 3 0A asl 009715 3 0A asl 009716 3 0A asl 009717 3 0A asl 009718 3 95 20 sta HMP0,x 00971A 3 60 rts 00971B 3 00971B 3 ; --------------------------------------------------------------------------- 00971B 3 ; HUD: entered on line 36 (VBLANK on). Lines 36-39 position the ball and the 00971B 3 ; score's players; 40-61 are the 22 HUD lines; FloorSetup is entered during 00971B 3 ; line 56 and must end lines 56-60 with five WSYNCs, leaving line 61 for the 00971B 3 ; first play line's own WSYNC to end. 00971B 3 HudStart: 00971B 3 A5 rr lda ballXpos 00971D 3 A2 04 ldx #4 00971F 3 20 00 97 jsr PosObj ; ends 36, strobe on 37, ends 37 009722 3 85 02 sta WSYNC ; ends 38 009724 3 ; line 39: the score's players, fixed positions 009724 3 24 80 EA EA SLEEP ::SCORE_SLEEP 009728 3 EA EA EA EA 00972C 3 EA EA EA EA 009737 3 85 10 sta RESP0 009739 3 85 11 sta RESP1 ; three cycles (9 clocks) later 00973B 3 A9 00 lda #SCORE_HM0 00973D 3 85 20 sta HMP0 00973F 3 A9 10 lda #SCORE_HM1 009741 3 85 21 sta HMP1 009743 3 85 02 sta WSYNC ; ends 39 (PosObj left the ball's motion in HMBL) 009745 3 .assert ::SCORE_SLEEP >= 2, error, "SCORE_SLEEP" 009745 3 ; HUD line 0 (40) 009745 3 85 2A sta HMOVE 009747 3 A9 80 lda #$80 009749 3 85 01 sta VBLANK ; picture on; paddle capacitors still dumped 00974B 3 A9 03 lda #3 00974D 3 85 04 sta NUSIZ0 00974F 3 85 05 sta NUSIZ1 009751 3 A9 01 lda #1 009753 3 85 25 sta VDELP0 009755 3 85 26 sta VDELP1 009757 3 A5 rr lda scoreCol 009759 3 85 06 sta COLUP0 00975B 3 85 07 sta COLUP1 00975D 3 A9 00 lda #0 00975F 3 85 1F sta ENABL 009761 3 85 09 sta COLUBK 009763 3 85 0D sta PF0 009765 3 85 0E sta PF1 009767 3 85 0F sta PF2 009769 3 85 0A sta CTRLPF 00976B 3 85 2B sta HMCLR 00976D 3 A0 07 ldy #7 00976F 3 84 rr sty row 009771 3 GUARD 56 009771 3 ScoreLoop: 009771 3 B1 rr lda (dp+0),y 009773 3 85 1B sta GRP0 009775 3 85 02 sta WSYNC 009777 3 B1 rr lda (dp+2),y ; 5 009779 3 85 1C sta GRP1 ; 8 00977B 3 B1 rr lda (dp+4),y ; 13 00977D 3 85 1B sta GRP0 ; 16 00977F 3 B1 rr lda (dp+6),y ; 21 009781 3 85 rr sta tmp ; 24 009783 3 B1 rr lda (dp+8),y ; 29 009785 3 AA tax ; 31 009786 3 B1 rr lda (dp+10),y ; 36 009788 3 A8 tay ; 38 009789 3 A5 rr lda tmp ; 41 00978B 3 85 1C sta GRP1 ; 44 00978D 3 86 1B stx GRP0 ; 47 00978F 3 84 1C sty GRP1 ; 50 009791 3 85 1B sta GRP0 ; 53 009793 3 C6 rr dec row ; 58 009795 3 A4 rr ldy row ; 61 009797 3 10 D8 bpl ScoreLoop ; 64 009799 3 .assert >ScoreLoop = >*, error, "ScoreLoop crosses a page" 009799 3 85 02 sta WSYNC ; ends 48 00979B 3 ; HUD line 9 (49) 00979B 3 A9 00 lda #0 00979D 3 85 1B sta GRP0 00979F 3 85 1C sta GRP1 0097A1 3 85 1B sta GRP0 0097A3 3 85 25 sta VDELP0 0097A5 3 85 26 sta VDELP1 0097A7 3 A9 02 lda #2 ; score mode: left PF in COLUP0, right in COLUP1 0097A9 3 85 0A sta CTRLPF 0097AB 3 A9 0E lda #C_PIPS 0097AD 3 85 06 sta COLUP0 0097AF 3 A9 6C lda #C_FLOORMK 0097B1 3 85 07 sta COLUP1 0097B3 3 A9 05 lda #5 ; P0 (left where the score's first digit was), one 0097B5 3 85 04 sta NUSIZ0 ; copy at double width: the multiplier, in COLUP0 0097B7 3 A2 05 ldx #5 0097B9 3 GUARD 40 0097B9 3 StatLoop: 0097B9 3 85 02 sta WSYNC ; ends 49 .. 54 0097BB 3 A5 rr lda pipsPF ; 3 0097BD 3 85 0E sta PF1 ; 6 0097BF 3 8A txa ; 8 0097C0 3 18 clc ; 10 0097C1 3 65 rr adc multK ; 13 0097C3 3 A8 tay ; 15 0097C4 3 B9 F1 97 lda MultGfx,y ; 19 (20 across a page) 0097C7 3 85 1B sta GRP0 ; 23 (before the player is drawn) 0097C9 3 8A txa ; 25 0097CA 3 4A lsr ; 27 0097CB 3 A8 tay ; 29 0097CC 3 B9 rr rr lda floorPF,y ; 33 0097CF 3 24 80 EA EA SLEEP 7 ; 40 0097D3 3 85 0E sta PF1 ; 43 (right half) 0097D5 3 CA dex ; 45 0097D6 3 10 E1 bpl StatLoop ; 48 0097D8 3 .assert >StatLoop = >*, error, "StatLoop crosses a page" 0097D8 3 85 02 sta WSYNC ; ends 55 0097DA 3 ; HUD line 16 (56) 0097DA 3 A9 00 lda #0 0097DC 3 85 0E sta PF1 0097DE 3 85 1B sta GRP0 0097E0 3 85 1C sta GRP1 0097E2 3 85 04 sta NUSIZ0 0097E4 3 85 05 sta NUSIZ1 0097E6 3 85 06 sta COLUP0 0097E8 3 85 07 sta COLUP1 0097EA 3 A9 15 lda #CTRL_REF 0097EC 3 85 0A sta CTRLPF 0097EE 3 4C 2B 98 jmp FloorSetup 0097F1 3 0097F1 3 ; The multiplier on the status line (2026-11-22): six lines, [multK + line], the 0097F1 3 ; bottom line first; nothing at 1x. Drawn at double width: "x" then the digit. 0097F1 3 MultGfx: 0097F1 3 00 00 00 00 .byte $00, $00, $00, $00, $00, $00 ; 1x: blank 0097F5 3 00 00 0097F7 3 AF 44 A2 01 .byte $AF, $44, $A2, $01, $09, $06 ; x2 ....-##- / ....#--# / .......# / #-#---#- / -#---#-- / #-#-#### 0097FB 3 09 06 0097FD 3 AE 41 A1 06 .byte $AE, $41, $A1, $06, $01, $0E ; x3 ....###- / .......# / .....##- / #-#....# / -#.....# / #-#-###- 009801 3 01 0E 009803 3 A1 41 A1 0F .byte $A1, $41, $A1, $0F, $09, $09 ; x4 ....#..# / ....#..# / ....#### / #-#....# / -#.....# / #-#....# 009807 3 09 09 009809 3 AE 41 A1 0E .byte $AE, $41, $A1, $0E, $08, $0F ; x5 ....#### / ....#... / ....###. / #-#....# / -#.....# / #-#-###- 00980D 3 08 0F 00980F 3 .assert MultGfx + 30 <= $10000, error, "MultGfx" 00980F 3 00980F 3 ; --------------------------------------------------------------------------- 00980F 3 ; Kernel exit: after the last play line (Y = 0). Ends line 231, blanks, returns. 00980F 3 KernelEnd: 00980F 3 85 02 A9 82 KEXIT TOLOGIC 009813 3 85 01 A9 00 009817 3 85 1F 85 1B 009828 3 009828 3 009828 2 009828 2 ; Bank 3 entry (from the stub): the HUD, then the floor. 009828 2 Entry: 009828 2 4C 1B 97 jmp HudStart 00982B 2 00982B 2 ; --------------------------------------------------------------------------- 00982B 2 ; Bottom floor: five set-up lines with nothing to position. 00982B 2 FloorSetup: 00982B 2 A2 04 ldx #4 00982D 2 GUARD 8 00982D 2 85 02 L_l: sta WSYNC ; ends 56..60 00982F 2 CA dex 009830 2 D0 FB bne L_l 009832 2 85 02 sta WSYNC 009834 2 A9 D0 lda #C_BG0 009836 2 85 09 sta COLUBK 009838 2 A9 0C lda #C_WALL0 00983A 2 85 08 sta COLUPF 00983C 2 A9 F0 lda #$F0 00983E 2 85 0D sta PF0 009840 2 A0 AA ldy #PLAYH 009842 2 KY .set ::PLAYH 009842 2 85 02 98 38 EMPTY 8 ; lines 0-7 009846 2 E5 rr C9 04 00984A 2 A9 FF 69 00 00985C 2 85 02 98 38 BRICK_E ; 8 009860 2 E5 rr C9 04 009864 2 A9 FF 69 00 009887 2 85 02 98 38 BRICK_ROW bricks+0, C_ROW0, 6 ; 9-16 00988B 2 E5 rr C9 04 00988F 2 A9 FF 69 00 009934 2 85 02 98 38 BRICK_ROW bricks+1, C_ROW1, 6 ; 17-24 009938 2 E5 rr C9 04 00993C 2 A9 FF 69 00 0099D1 2 85 02 98 38 BRICK_ROW bricks+2, C_ROW2, 6 ; 25-32 0099D5 2 E5 rr C9 04 0099D9 2 A9 FF 69 00 009A6E 2 85 02 98 38 BRICK_ROW bricks+3, C_ROW3, 6 ; 33-40 009A72 2 E5 rr C9 04 009A76 2 A9 FF 69 00 009B34 2 85 02 98 38 BRICK_ROW bricks+4, C_ROW4, 6 ; 41-48 009B38 2 E5 rr C9 04 009B3C 2 A9 FF 69 00 009BD1 2 85 02 98 38 BRICK_ROW bricks+5, C_ROW5, 6 ; 49-56 009BD5 2 E5 rr C9 04 009BD9 2 A9 FF 69 00 009C6E 2 85 02 98 38 BRICK_T C_WALL0 ; 57 009C72 2 E5 rr C9 04 009C76 2 A9 FF 69 00 009C92 2 85 02 98 38 EMPTY 1 ; 58 009C96 2 E5 rr C9 04 009C9A 2 A9 FF 69 00 009CAC 2 85 02 98 38 RELEASE ; 59 009CB0 2 E5 rr C9 04 009CB4 2 A9 FF 69 00 009CCA 2 85 02 98 38 EMPTY 92 ; 60-151 009CCE 2 E5 rr C9 04 009CD2 2 A9 FF 69 00 009CE4 2 85 02 98 38 BATBAND ; 152-169 009CE8 2 E5 rr C9 04 009CEC 2 A9 FF 69 00 009D61 2 4C 0F 98 jmp KernelEnd 009D64 2 009D64 2 .endscope 009D64 2 KernelLow = low::Entry 009D64 2 .assert low::Font = $9000, error, "Font must start bank 3" 009D64 2 009D64 1 .include "play_top.s" 009D64 2 ; SPDX-License-Identifier: MIT 009D64 2 ; Bank 1: the play kernels for the middle floor (the clown, the bumpers and the 009D64 2 ; drop targets) and the top floor: the tent roof and three rows of balloons that 009D64 2 ; slide from side to side. Each row is P0 and P1 with NUSIZ copies 009D64 2 ; (three per player, 16 colour clocks apart when interleaved); a popped balloon 009D64 2 ; is removed by changing NUSIZ and the copy's x (gen_tables.py: BalNus, BalOff). 009D64 2 ; A player with no balloons left is parked behind the left wall (HIDE_X; the 009D64 2 ; playfield has priority over the players). 009D64 2 009D64 2 .segment "BANK1" 009D64 2 .org $F000 00F000 2 .scope top 00F000 2 TOLOGIC = ToLogic1 00F000 2 .include "shared.s" 00F000 3 ; SPDX-License-Identifier: MIT 00F000 3 ; Shared start of the two play-kernel banks (1 and 3). Included inside each bank's 00F000 3 ; scope; the including file defines FloorSetup (the floor's set-up lines) and 00F000 3 ; TOLOGIC (the stub that returns to bank 0). Font and BatGfx sit at the same 00F000 3 ; offsets in both banks (and Font in bank 2), so one pointer serves all banks. 00F000 3 00F000 3 .include "gen/font.inc" ; offset $000, one page 00F000 4 ; SPDX-License-Identifier: MIT 00F000 4 ; Generated by scripts/gen_tables.py: do not edit. 00F000 4 .align 256 00F000 4 Font: 00F000 4 ; '0' 00F000 4 00 7C C6 E6 .byte $00,$7C,$C6,$E6,$D6,$CE,$C6,$7C 00F004 4 D6 CE C6 7C 00F008 4 ; '1' 00F008 4 00 7E 18 18 .byte $00,$7E,$18,$18,$18,$78,$38,$18 00F00C 4 18 78 38 18 00F010 4 ; '2' 00F010 4 00 FE C0 70 .byte $00,$FE,$C0,$70,$1C,$06,$C6,$7C 00F014 4 1C 06 C6 7C 00F018 4 ; '3' 00F018 4 00 7C C6 06 .byte $00,$7C,$C6,$06,$3C,$06,$C6,$7C 00F01C 4 3C 06 C6 7C 00F020 4 ; '4' 00F020 4 00 0C 0C FE .byte $00,$0C,$0C,$FE,$6C,$3C,$1C,$0C 00F024 4 6C 3C 1C 0C 00F028 4 ; '5' 00F028 4 00 7C C6 06 .byte $00,$7C,$C6,$06,$06,$FC,$C0,$FE 00F02C 4 06 FC C0 FE 00F030 4 ; '6' 00F030 4 00 7C C6 C6 .byte $00,$7C,$C6,$C6,$FC,$C0,$60,$3C 00F034 4 FC C0 60 3C 00F038 4 ; '7' 00F038 4 00 30 30 30 .byte $00,$30,$30,$30,$18,$0C,$06,$FE 00F03C 4 18 0C 06 FE 00F040 4 ; '8' 00F040 4 00 7C C6 C6 .byte $00,$7C,$C6,$C6,$7C,$C6,$C6,$7C 00F044 4 7C C6 C6 7C 00F048 4 ; '9' 00F048 4 00 78 0C 06 .byte $00,$78,$0C,$06,$7E,$C6,$C6,$7C 00F04C 4 7E C6 C6 7C 00F050 4 ; ' ' 00F050 4 00 00 00 00 .byte $00,$00,$00,$00,$00,$00,$00,$00 00F054 4 00 00 00 00 00F058 4 ; 'A' 00F058 4 00 C6 C6 FE .byte $00,$C6,$C6,$FE,$C6,$C6,$6C,$38 00F05C 4 C6 C6 6C 38 00F060 4 ; 'B' 00F060 4 00 FC C6 C6 .byte $00,$FC,$C6,$C6,$FC,$C6,$C6,$FC 00F064 4 FC C6 C6 FC 00F068 4 ; 'C' 00F068 4 00 7C C6 C0 .byte $00,$7C,$C6,$C0,$C0,$C0,$C6,$7C 00F06C 4 C0 C0 C6 7C 00F070 4 ; 'E' 00F070 4 00 FE C0 C0 .byte $00,$FE,$C0,$C0,$F8,$C0,$C0,$FE 00F074 4 F8 C0 C0 FE 00F078 4 ; 'G' 00F078 4 00 7E C6 C6 .byte $00,$7E,$C6,$C6,$DE,$C0,$C6,$7C 00F07C 4 DE C0 C6 7C 00F080 4 ; 'I' 00F080 4 00 7E 18 18 .byte $00,$7E,$18,$18,$18,$18,$18,$7E 00F084 4 18 18 18 7E 00F088 4 ; 'K' 00F088 4 00 C6 CC D8 .byte $00,$C6,$CC,$D8,$F0,$D8,$CC,$C6 00F08C 4 F0 D8 CC C6 00F090 4 ; 'L' 00F090 4 00 FE C0 C0 .byte $00,$FE,$C0,$C0,$C0,$C0,$C0,$C0 00F094 4 C0 C0 C0 C0 00F098 4 ; 'M' 00F098 4 00 C6 C6 C6 .byte $00,$C6,$C6,$C6,$D6,$FE,$EE,$C6 00F09C 4 D6 FE EE C6 00F0A0 4 ; 'N' 00F0A0 4 00 C6 C6 CE .byte $00,$C6,$C6,$CE,$DE,$F6,$E6,$C6 00F0A4 4 DE F6 E6 C6 00F0A8 4 ; 'O' 00F0A8 4 00 7C C6 C6 .byte $00,$7C,$C6,$C6,$C6,$C6,$C6,$7C 00F0AC 4 C6 C6 C6 7C 00F0B0 4 ; 'P' 00F0B0 4 00 C0 C0 C0 .byte $00,$C0,$C0,$C0,$FC,$C6,$C6,$FC 00F0B4 4 FC C6 C6 FC 00F0B8 4 ; 'R' 00F0B8 4 00 C6 CC D8 .byte $00,$C6,$CC,$D8,$FC,$C6,$C6,$FC 00F0BC 4 FC C6 C6 FC 00F0C0 4 ; 'S' 00F0C0 4 00 7C C6 06 .byte $00,$7C,$C6,$06,$7C,$C0,$C6,$7C 00F0C4 4 7C C0 C6 7C 00F0C8 4 ; 'T' 00F0C8 4 00 30 30 30 .byte $00,$30,$30,$30,$30,$30,$30,$FC 00F0CC 4 30 30 30 FC 00F0D0 4 ; 'U' 00F0D0 4 00 7C C6 C6 .byte $00,$7C,$C6,$C6,$C6,$C6,$C6,$C6 00F0D4 4 C6 C6 C6 C6 00F0D8 4 ; 'V' 00F0D8 4 00 10 38 6C .byte $00,$10,$38,$6C,$C6,$C6,$C6,$C6 00F0DC 4 C6 C6 C6 C6 00F0E0 4 ; 'X' 00F0E0 4 00 C6 6C 38 .byte $00,$C6,$6C,$38,$38,$38,$6C,$C6 00F0E4 4 38 38 6C C6 00F0E8 4 ; 'Y' 00F0E8 4 00 30 30 30 .byte $00,$30,$30,$30,$30,$78,$CC,$CC 00F0EC 4 30 78 CC CC 00F0F0 4 ; '!' 00F0F0 4 00 18 00 18 .byte $00,$18,$00,$18,$18,$18,$18,$18 00F0F4 4 18 18 18 18 00F0F8 4 ; '-' 00F0F8 4 00 00 00 00 .byte $00,$00,$00,$00,$7C,$00,$00,$00 00F0FC 4 7C 00 00 00 00F100 4 00F100 3 00F100 3 .align 256 00F100 3 BatGfx: 00F100 3 .include "gen/bat.inc" 00F100 4 ; SPDX-License-Identifier: MIT 00F100 4 ; Generated by scripts/gen_tables.py: do not edit. 00F100 4 BatBlank = * - BatGfx 00F100 4 00 00 00 00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 00F104 4 00 00 00 00 00F108 4 00 00 00 00 00F110 4 Bat16N = * - BatGfx 00F110 4 00 00 00 00 .byte $00,$00,$00,$00,$00,$00,$00,$60,$F0,$F0,$60,$00,$00,$00,$00,$00 00F114 4 00 00 00 60 00F118 4 F0 F0 60 00 00F120 4 Bat16K = * - BatGfx 00F120 4 00 00 00 00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$60,$F0,$F0,$60,$00,$00,$00 00F124 4 00 00 00 00 00F128 4 00 60 F0 F0 00F130 4 Bat24N = * - BatGfx 00F130 4 00 00 00 00 .byte $00,$00,$00,$00,$00,$00,$00,$78,$FC,$FC,$78,$00,$00,$00,$00,$00 00F134 4 00 00 00 78 00F138 4 FC FC 78 00 00F140 4 Bat24K = * - BatGfx 00F140 4 00 00 00 00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$78,$FC,$FC,$78,$00,$00,$00 00F144 4 00 00 00 00 00F148 4 00 78 FC FC 00F150 4 00F150 3 ; the including bank's own small graphics follow in this page 00F150 3 00F150 3 00F150 2 .include "gen/top.inc" 00F150 3 ; SPDX-License-Identifier: MIT 00F150 3 ; Generated by scripts/gen_tables.py: do not edit. 00F150 3 GfxTop: 00F150 3 BalloonGfx: 00F150 3 00 08 18 18 .byte $00,$08,$18,$18,$3C,$7E,$7E,$FF,$FF,$FF,$BF,$BF,$DF,$7E,$3C 00F154 3 3C 7E 7E FF 00F158 3 FF FF BF BF 00F15F 3 BAL_ROW12 = $18 00F15F 3 BAL_ROW13 = $08 00F15F 3 RoofPF1: 00F15F 3 00 00 00 00 .byte $00,$00,$00,$00,$00,$11,$77,$FF,$FF,$FF 00F163 3 00 11 77 FF 00F167 3 FF FF 00F169 3 RoofPF2: 00F169 3 00 00 00 00 .byte $00,$00,$00,$00,$00,$88,$EE,$FF,$FF,$FF 00F16D 3 00 88 EE FF 00F171 3 FF FF 00F173 3 RoofCol: 00F173 3 0C .byte C_WALL2 00F174 3 0C .byte C_WALL2 00F175 3 0C .byte C_WALL2 00F176 3 0C .byte C_WALL2 00F177 3 0C .byte C_WALL2 00F178 3 84 .byte C_ROOFA 00F179 3 0E .byte C_ROOFB 00F17A 3 84 .byte C_ROOFA 00F17B 3 0E .byte C_ROOFB 00F17C 3 84 .byte C_ROOFA 00F17D 3 BalNus: 00F17D 3 00 00 00 02 .byte $00,$00,$00,$02,$00,$04,$02,$06 00F181 3 00 04 02 06 00F185 3 BalOff0: 00F185 3 00 00 20 00 .byte $00,$00,$20,$00,$40,$00,$20,$00 00F189 3 40 00 20 00 00F18D 3 BalOff1: 00F18D 3 10 10 30 10 .byte $10,$10,$30,$10,$50,$10,$30,$10 00F191 3 50 10 30 10 00F195 3 .assert >* = >BatGfx, error, "GfxTop crosses a page" 00F195 3 xx xx xx xx .align 256 00F199 3 xx xx xx xx 00F19D 3 xx xx xx xx 00F200 3 BalC: 00F200 3 00 00 00 00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$0B,$0B,$03,$03 00F204 3 00 00 00 00 00F208 3 00 00 00 00 00F210 3 03 03 03 03 .byte $03,$03,$03,$03,$03,$03,$03,$03,$03,$03,$03,$03,$03,$04,$04,$04 00F214 3 03 03 03 03 00F218 3 03 03 03 03 00F220 3 04 04 04 04 .byte $04,$04,$04,$04,$04,$04,$04,$04,$04,$04,$04,$04,$05,$05,$05,$05 00F224 3 04 04 04 04 00F228 3 04 04 04 04 00F230 3 05 05 05 05 .byte $05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$06,$06,$06,$06,$06 00F234 3 05 05 05 05 00F238 3 05 05 05 06 00F240 3 06 06 06 06 .byte $06,$06,$06,$06,$06,$06,$06,$06,$06,$06,$07,$07,$07,$07,$07,$07 00F244 3 06 06 06 06 00F248 3 06 06 07 07 00F250 3 07 07 07 07 .byte $07,$07,$07,$07,$07,$07,$07,$07,$07,$08,$08,$08,$08,$08,$08,$08 00F254 3 07 07 07 07 00F258 3 07 08 08 08 00F260 3 08 08 08 08 .byte $08,$08,$08,$08,$08,$08,$08,$08,$09,$09,$09,$09,$09,$09,$09,$09 00F264 3 08 08 08 08 00F268 3 09 09 09 09 00F270 3 09 09 09 09 .byte $09,$09,$09,$09,$09,$09,$09,$0A,$0A,$0A,$0A,$0A,$0A,$0A,$0A,$0A 00F274 3 09 09 09 0A 00F278 3 0A 0A 0A 0A 00F280 3 0A 0A 0A 0A .byte $0A,$0A,$0A,$0A,$0A,$0A,$0B,$0B,$0B,$0B,$0B,$0B,$0B,$0B,$0B,$0B 00F284 3 0A 0A 0B 0B 00F288 3 0B 0B 0B 0B 00F290 3 0B 0B 0B 0B .byte $0B,$0B,$0B,$0B,$0B,$0B,$0B,$0B,$0B,$0B,$0B,$0B,$00,$00,$00,$00 00F294 3 0B 0B 0B 0B 00F298 3 0B 0B 0B 0B 00F2A0 3 xx xx xx xx .align 256 00F2A4 3 xx xx xx xx 00F2A8 3 xx xx xx xx 00F300 3 BalF: 00F300 3 30 20 10 00 .byte $30,$20,$10,$00,$F0,$E0,$D0,$C0,$B0,$A0,$90,$80,$00,$00,$70,$60 00F304 3 F0 E0 D0 C0 00F308 3 B0 A0 90 80 00F310 3 50 40 30 20 .byte $50,$40,$30,$20,$10,$00,$F0,$E0,$D0,$C0,$B0,$A0,$90,$70,$60,$50 00F314 3 10 00 F0 E0 00F318 3 D0 C0 B0 A0 00F320 3 40 30 20 10 .byte $40,$30,$20,$10,$00,$F0,$E0,$D0,$C0,$B0,$A0,$90,$70,$60,$50,$40 00F324 3 00 F0 E0 D0 00F328 3 C0 B0 A0 90 00F330 3 30 20 10 00 .byte $30,$20,$10,$00,$F0,$E0,$D0,$C0,$B0,$A0,$90,$70,$60,$50,$40,$30 00F334 3 F0 E0 D0 C0 00F338 3 B0 A0 90 70 00F340 3 20 10 00 F0 .byte $20,$10,$00,$F0,$E0,$D0,$C0,$B0,$A0,$90,$70,$60,$50,$40,$30,$20 00F344 3 E0 D0 C0 B0 00F348 3 A0 90 70 60 00F350 3 10 00 F0 E0 .byte $10,$00,$F0,$E0,$D0,$C0,$B0,$A0,$90,$70,$60,$50,$40,$30,$20,$10 00F354 3 D0 C0 B0 A0 00F358 3 90 70 60 50 00F360 3 00 F0 E0 D0 .byte $00,$F0,$E0,$D0,$C0,$B0,$A0,$90,$70,$60,$50,$40,$30,$20,$10,$00 00F364 3 C0 B0 A0 90 00F368 3 70 60 50 40 00F370 3 F0 E0 D0 C0 .byte $F0,$E0,$D0,$C0,$B0,$A0,$90,$70,$60,$50,$40,$30,$20,$10,$00,$F0 00F374 3 B0 A0 90 70 00F378 3 60 50 40 30 00F380 3 E0 D0 C0 B0 .byte $E0,$D0,$C0,$B0,$A0,$90,$70,$60,$50,$40,$30,$20,$10,$00,$F0,$E0 00F384 3 A0 90 70 60 00F388 3 50 40 30 20 00F390 3 D0 C0 B0 A0 .byte $D0,$C0,$B0,$A0,$90,$80,$00,$00,$00,$00,$00,$00,$70,$60,$50,$40 00F394 3 90 80 00 00 00F398 3 00 00 00 00 00F3A0 3 xx xx xx xx .align 256 00F3A4 3 xx xx xx xx 00F3A8 3 xx xx xx xx 00F400 3 GfxMid: 00F400 3 BumperGfx: 00F400 3 00 00 3C 66 .byte $00,$00,$3C,$66,$DB,$BD,$BD,$DB,$66,$3C 00F404 3 DB BD BD DB 00F408 3 66 3C 00F40A 3 ClownAGfx: 00F40A 3 E7 66 24 3C .byte $E7,$66,$24,$3C,$7E,$BD,$7E,$FF,$BD,$24,$3C,$24,$7E,$3C,$3C,$18 00F40E 3 7E BD 7E FF 00F412 3 BD 24 3C 24 00F41A 3 ClownBGfx: 00F41A 3 63 22 24 3C .byte $63,$22,$24,$3C,$7E,$BD,$7E,$FF,$BD,$24,$3C,$24,$7E,$3C,$3C,$18 00F41E 3 7E BD 7E FF 00F422 3 BD 24 3C 24 00F42A 3 ClownHitGfx: 00F42A 3 18 3C 3C 7E .byte $18,$3C,$3C,$7E,$24,$3C,$24,$BD,$FF,$7E,$BD,$7E,$3C,$24,$66,$E7 00F42E 3 24 3C 24 BD 00F432 3 FF 7E BD 7E 00F43A 3 ClownACol: 00F43A 3 84 .byte C_CL_RED 00F43B 3 58 .byte C_CL_GREEN 00F43C 3 58 .byte C_CL_GREEN 00F43D 3 B8 .byte C_CL_BLUE 00F43E 3 B8 .byte C_CL_BLUE 00F43F 3 B8 .byte C_CL_BLUE 00F440 3 B8 .byte C_CL_BLUE 00F441 3 0E .byte C_CL_WHITE 00F442 3 0E .byte C_CL_WHITE 00F443 3 6C .byte C_CL_SKIN 00F444 3 6C .byte C_CL_SKIN 00F445 3 6C .byte C_CL_SKIN 00F446 3 4C .byte C_CL_YELLOW 00F447 3 4C .byte C_CL_YELLOW 00F448 3 4C .byte C_CL_YELLOW 00F449 3 84 .byte C_CL_RED 00F44A 3 ClownBCol: 00F44A 3 84 .byte C_CL_RED 00F44B 3 58 .byte C_CL_GREEN 00F44C 3 58 .byte C_CL_GREEN 00F44D 3 B8 .byte C_CL_BLUE 00F44E 3 B8 .byte C_CL_BLUE 00F44F 3 B8 .byte C_CL_BLUE 00F450 3 B8 .byte C_CL_BLUE 00F451 3 0E .byte C_CL_WHITE 00F452 3 0E .byte C_CL_WHITE 00F453 3 6C .byte C_CL_SKIN 00F454 3 6C .byte C_CL_SKIN 00F455 3 6C .byte C_CL_SKIN 00F456 3 4C .byte C_CL_YELLOW 00F457 3 4C .byte C_CL_YELLOW 00F458 3 4C .byte C_CL_YELLOW 00F459 3 84 .byte C_CL_RED 00F45A 3 ClownHitCol: 00F45A 3 84 .byte C_CL_RED 00F45B 3 4C .byte C_CL_YELLOW 00F45C 3 4C .byte C_CL_YELLOW 00F45D 3 4C .byte C_CL_YELLOW 00F45E 3 6C .byte C_CL_SKIN 00F45F 3 6C .byte C_CL_SKIN 00F460 3 6C .byte C_CL_SKIN 00F461 3 0E .byte C_CL_WHITE 00F462 3 0E .byte C_CL_WHITE 00F463 3 B8 .byte C_CL_BLUE 00F464 3 B8 .byte C_CL_BLUE 00F465 3 B8 .byte C_CL_BLUE 00F466 3 B8 .byte C_CL_BLUE 00F467 3 58 .byte C_CL_GREEN 00F468 3 58 .byte C_CL_GREEN 00F469 3 84 .byte C_CL_RED 00F46A 3 .assert >* = >GfxMid, error, "GfxMid crosses a page" 00F46A 3 00F46A 2 .include "hud.s" 00F46A 3 ; SPDX-License-Identifier: MIT 00F46A 3 ; Shared play-kernel code (banks 1 and 3): positioning, the HUD, the kernel exit. 00F46A 3 ; Included inside each bank's scope after its graphics. 00F46A 3 00F46A 3 ; --------------------------------------------------------------------------- 00F46A 3 ; PosObj: A = x - POS_K (0..149), X = object (0 P0, 1 P1, 2 M0, 3 M1, 4 BL). 00F46A 3 ; Ends the current line, strobes RESx on the next one, ends that line, and sets 00F46A 3 ; HMxx early on the line after. Always exactly the same lines: the strobe falls 00F46A 3 ; at cycle 19+5k at the latest 69 (k <= 10, so x - POS_K <= 149). 00F46A 3 PosObj: 00F46A 3 85 02 sta WSYNC 00F46C 3 EA EA EA EA SLEEP 14 00F470 3 EA EA EA 00F473 3 38 sec 00F474 3 E9 0F @div: sbc #15 00F476 3 B0 FC bcs @div 00F478 3 95 10 sta RESP0,x 00F47A 3 85 02 sta WSYNC 00F47C 3 49 07 eor #7 00F47E 3 0A asl 00F47F 3 0A asl 00F480 3 0A asl 00F481 3 0A asl 00F482 3 95 20 sta HMP0,x 00F484 3 60 rts 00F485 3 00F485 3 ; --------------------------------------------------------------------------- 00F485 3 ; HUD: entered on line 36 (VBLANK on). Lines 36-39 position the ball and the 00F485 3 ; score's players; 40-61 are the 22 HUD lines; FloorSetup is entered during 00F485 3 ; line 56 and must end lines 56-60 with five WSYNCs, leaving line 61 for the 00F485 3 ; first play line's own WSYNC to end. 00F485 3 HudStart: 00F485 3 A5 rr lda ballXpos 00F487 3 A2 04 ldx #4 00F489 3 20 6A F4 jsr PosObj ; ends 36, strobe on 37, ends 37 00F48C 3 85 02 sta WSYNC ; ends 38 00F48E 3 ; line 39: the score's players, fixed positions 00F48E 3 24 80 EA EA SLEEP ::SCORE_SLEEP 00F492 3 EA EA EA EA 00F496 3 EA EA EA EA 00F4A1 3 85 10 sta RESP0 00F4A3 3 85 11 sta RESP1 ; three cycles (9 clocks) later 00F4A5 3 A9 00 lda #SCORE_HM0 00F4A7 3 85 20 sta HMP0 00F4A9 3 A9 10 lda #SCORE_HM1 00F4AB 3 85 21 sta HMP1 00F4AD 3 85 02 sta WSYNC ; ends 39 (PosObj left the ball's motion in HMBL) 00F4AF 3 .assert ::SCORE_SLEEP >= 2, error, "SCORE_SLEEP" 00F4AF 3 ; HUD line 0 (40) 00F4AF 3 85 2A sta HMOVE 00F4B1 3 A9 80 lda #$80 00F4B3 3 85 01 sta VBLANK ; picture on; paddle capacitors still dumped 00F4B5 3 A9 03 lda #3 00F4B7 3 85 04 sta NUSIZ0 00F4B9 3 85 05 sta NUSIZ1 00F4BB 3 A9 01 lda #1 00F4BD 3 85 25 sta VDELP0 00F4BF 3 85 26 sta VDELP1 00F4C1 3 A5 rr lda scoreCol 00F4C3 3 85 06 sta COLUP0 00F4C5 3 85 07 sta COLUP1 00F4C7 3 A9 00 lda #0 00F4C9 3 85 1F sta ENABL 00F4CB 3 85 09 sta COLUBK 00F4CD 3 85 0D sta PF0 00F4CF 3 85 0E sta PF1 00F4D1 3 85 0F sta PF2 00F4D3 3 85 0A sta CTRLPF 00F4D5 3 85 2B sta HMCLR 00F4D7 3 A0 07 ldy #7 00F4D9 3 84 rr sty row 00F4DB 3 4C 00 F5 EA GUARD 56 00F4DF 3 EA EA EA EA 00F4E3 3 EA EA EA EA 00F500 3 ScoreLoop: 00F500 3 B1 rr lda (dp+0),y 00F502 3 85 1B sta GRP0 00F504 3 85 02 sta WSYNC 00F506 3 B1 rr lda (dp+2),y ; 5 00F508 3 85 1C sta GRP1 ; 8 00F50A 3 B1 rr lda (dp+4),y ; 13 00F50C 3 85 1B sta GRP0 ; 16 00F50E 3 B1 rr lda (dp+6),y ; 21 00F510 3 85 rr sta tmp ; 24 00F512 3 B1 rr lda (dp+8),y ; 29 00F514 3 AA tax ; 31 00F515 3 B1 rr lda (dp+10),y ; 36 00F517 3 A8 tay ; 38 00F518 3 A5 rr lda tmp ; 41 00F51A 3 85 1C sta GRP1 ; 44 00F51C 3 86 1B stx GRP0 ; 47 00F51E 3 84 1C sty GRP1 ; 50 00F520 3 85 1B sta GRP0 ; 53 00F522 3 C6 rr dec row ; 58 00F524 3 A4 rr ldy row ; 61 00F526 3 10 D8 bpl ScoreLoop ; 64 00F528 3 .assert >ScoreLoop = >*, error, "ScoreLoop crosses a page" 00F528 3 85 02 sta WSYNC ; ends 48 00F52A 3 ; HUD line 9 (49) 00F52A 3 A9 00 lda #0 00F52C 3 85 1B sta GRP0 00F52E 3 85 1C sta GRP1 00F530 3 85 1B sta GRP0 00F532 3 85 25 sta VDELP0 00F534 3 85 26 sta VDELP1 00F536 3 A9 02 lda #2 ; score mode: left PF in COLUP0, right in COLUP1 00F538 3 85 0A sta CTRLPF 00F53A 3 A9 0E lda #C_PIPS 00F53C 3 85 06 sta COLUP0 00F53E 3 A9 6C lda #C_FLOORMK 00F540 3 85 07 sta COLUP1 00F542 3 A9 05 lda #5 ; P0 (left where the score's first digit was), one 00F544 3 85 04 sta NUSIZ0 ; copy at double width: the multiplier, in COLUP0 00F546 3 A2 05 ldx #5 00F548 3 GUARD 40 00F548 3 StatLoop: 00F548 3 85 02 sta WSYNC ; ends 49 .. 54 00F54A 3 A5 rr lda pipsPF ; 3 00F54C 3 85 0E sta PF1 ; 6 00F54E 3 8A txa ; 8 00F54F 3 18 clc ; 10 00F550 3 65 rr adc multK ; 13 00F552 3 A8 tay ; 15 00F553 3 B9 80 F5 lda MultGfx,y ; 19 (20 across a page) 00F556 3 85 1B sta GRP0 ; 23 (before the player is drawn) 00F558 3 8A txa ; 25 00F559 3 4A lsr ; 27 00F55A 3 A8 tay ; 29 00F55B 3 B9 rr rr lda floorPF,y ; 33 00F55E 3 24 80 EA EA SLEEP 7 ; 40 00F562 3 85 0E sta PF1 ; 43 (right half) 00F564 3 CA dex ; 45 00F565 3 10 E1 bpl StatLoop ; 48 00F567 3 .assert >StatLoop = >*, error, "StatLoop crosses a page" 00F567 3 85 02 sta WSYNC ; ends 55 00F569 3 ; HUD line 16 (56) 00F569 3 A9 00 lda #0 00F56B 3 85 0E sta PF1 00F56D 3 85 1B sta GRP0 00F56F 3 85 1C sta GRP1 00F571 3 85 04 sta NUSIZ0 00F573 3 85 05 sta NUSIZ1 00F575 3 85 06 sta COLUP0 00F577 3 85 07 sta COLUP1 00F579 3 A9 15 lda #CTRL_REF 00F57B 3 85 0A sta CTRLPF 00F57D 3 4C BA F5 jmp FloorSetup 00F580 3 00F580 3 ; The multiplier on the status line (2026-11-22): six lines, [multK + line], the 00F580 3 ; bottom line first; nothing at 1x. Drawn at double width: "x" then the digit. 00F580 3 MultGfx: 00F580 3 00 00 00 00 .byte $00, $00, $00, $00, $00, $00 ; 1x: blank 00F584 3 00 00 00F586 3 AF 44 A2 01 .byte $AF, $44, $A2, $01, $09, $06 ; x2 ....-##- / ....#--# / .......# / #-#---#- / -#---#-- / #-#-#### 00F58A 3 09 06 00F58C 3 AE 41 A1 06 .byte $AE, $41, $A1, $06, $01, $0E ; x3 ....###- / .......# / .....##- / #-#....# / -#.....# / #-#-###- 00F590 3 01 0E 00F592 3 A1 41 A1 0F .byte $A1, $41, $A1, $0F, $09, $09 ; x4 ....#..# / ....#..# / ....#### / #-#....# / -#.....# / #-#....# 00F596 3 09 09 00F598 3 AE 41 A1 0E .byte $AE, $41, $A1, $0E, $08, $0F ; x5 ....#### / ....#... / ....###. / #-#....# / -#.....# / #-#-###- 00F59C 3 08 0F 00F59E 3 .assert MultGfx + 30 <= $10000, error, "MultGfx" 00F59E 3 00F59E 3 ; --------------------------------------------------------------------------- 00F59E 3 ; Kernel exit: after the last play line (Y = 0). Ends line 231, blanks, returns. 00F59E 3 KernelEnd: 00F59E 3 85 02 A9 82 KEXIT TOLOGIC 00F5A2 3 85 01 A9 00 00F5A6 3 85 1F 85 1B 00F5B7 3 00F5B7 3 00F5B7 2 00F5B7 2 Entry: 00F5B7 2 4C 85 F4 jmp HudStart 00F5BA 2 00F5BA 2 HIDE_X = 4 00F5BA 2 00F5BA 2 ; The next row's positioning values, split over three lines. 00F5BA 2 .macro CHUNK_A nr 00F5BA 2 .local skip 00F5BA 2 lda balloons+nr 00F5BA 2 and #7 00F5BA 2 tax 00F5BA 2 lda BalNus,x 00F5BA 2 sta bn0 00F5BA 2 lda rowX+nr 00F5BA 2 clc 00F5BA 2 adc BalOff0,x 00F5BA 2 cpx #0 00F5BA 2 bne skip 00F5BA 2 lda #HIDE_X 00F5BA 2 skip: tax 00F5BA 2 lda BalC,x 00F5BA 2 sta bc0 00F5BA 2 lda BalF,x 00F5BA 2 sta bf0 00F5BA 2 .endmacro 00F5BA 2 00F5BA 2 .macro CHUNK_B nr 00F5BA 2 .local skip 00F5BA 2 lda balloons+nr 00F5BA 2 lsr 00F5BA 2 lsr 00F5BA 2 lsr 00F5BA 2 tax 00F5BA 2 lda BalNus,x 00F5BA 2 sta bn1 00F5BA 2 lda rowX+nr 00F5BA 2 clc 00F5BA 2 adc BalOff1,x 00F5BA 2 cpx #0 00F5BA 2 bne skip 00F5BA 2 lda #HIDE_X 00F5BA 2 skip: sta bsum 00F5BA 2 .endmacro 00F5BA 2 00F5BA 2 .macro CHUNK_C 00F5BA 2 ldx bsum 00F5BA 2 lda BalC,x 00F5BA 2 sta bc1 00F5BA 2 lda BalF,x 00F5BA 2 sta bf1 00F5BA 2 .endmacro 00F5BA 2 00F5BA 2 ; BALLOON_LINES first, stop: balloon lines with X from `first` down to stop+1. 00F5BA 2 .macro BALLOON_LINES stop 00F5BA 2 .local bl 00F5BA 2 GUARD 40 00F5BA 2 bl: sta WSYNC 00F5BA 2 lda BalloonGfx,x ; 4 00F5BA 2 sta GRP0 ; 7 00F5BA 2 sta GRP1 ; 10 00F5BA 2 BALL ; 26 00F5BA 2 PADDLE9 ; 35 00F5BA 2 dey ; 37 00F5BA 2 dex ; 39 00F5BA 2 cpx #stop ; 41 00F5BA 2 bne bl ; 44 00F5BA 2 .assert >bl = >*, error, "balloon loop crosses a page" 00F5BA 2 .endmacro 00F5BA 2 00F5BA 2 ; BROW c0, c1, next, rel: one balloon row, 19 lines: s0-s3 position the two 00F5BA 2 ; players; b0-b14 draw (b0-b11 the body). b12-b14 compute the next row when there 00F5BA 2 ; is one (next >= 0); the row whose b-line `rel` is play line 59 releases the 00F5BA 2 ; paddle capacitor there (rel = -1: none). 00F5BA 2 .macro BROW c0, c1, next, rel 00F5BA 2 .local l1, l2 00F5BA 2 ; s0 00F5BA 2 sta WSYNC 00F5BA 2 BALL ; 16 00F5BA 2 BALLAT1 tE1 ; 32 00F5BA 2 BALLAT ballK2, tE2 ; 48 00F5BA 2 lda bf0 ; 51 00F5BA 2 sta HMP0 ; 54 00F5BA 2 lda bf1 ; 57 00F5BA 2 sta HMP1 ; 60 00F5BA 2 ldx bc0 ; 63 00F5BA 2 dey ; 65 00F5BA 2 dey ; 67 (s1 and s2 do not use Y) 00F5BA 2 ; s1 00F5BA 2 sta WSYNC ; 70 00F5BA 2 lda tE1 ; 3 00F5BA 2 sta ENABL ; 6 00F5BA 2 GUARD 6 00F5BA 2 l1: dex 00F5BA 2 bpl l1 ; 10+5c 00F5BA 2 sta RESP0 ; 13+5c (c <= 11: 68) 00F5BA 2 ldx bc1 ; 71 00F5BA 2 .assert >l1 = >*, error, "row loop crosses a page" 00F5BA 2 ; s2 00F5BA 2 sta WSYNC 00F5BA 2 lda tE2 ; 3 00F5BA 2 sta ENABL ; 6 00F5BA 2 GUARD 6 00F5BA 2 l2: dex 00F5BA 2 bpl l2 00F5BA 2 sta RESP1 ; 13+5c 00F5BA 2 dey ; 70 00F5BA 2 .assert >l2 = >*, error, "row loop crosses a page" 00F5BA 2 ; s3 00F5BA 2 sta WSYNC 00F5BA 2 sta HMOVE ; 3 00F5BA 2 BALL ; 19 00F5BA 2 lda bn0 ; 22 00F5BA 2 sta NUSIZ0 ; 25 00F5BA 2 lda bn1 ; 28 00F5BA 2 sta NUSIZ1 ; 31 00F5BA 2 lda #c0 ; 33 00F5BA 2 sta COLUP0 ; 36 00F5BA 2 lda #c1 ; 38 00F5BA 2 sta COLUP1 ; 41 00F5BA 2 ldx #14 ; 43 00F5BA 2 dey ; 45 00F5BA 2 sta HMCLR ; 48 00F5BA 2 .if rel < 0 00F5BA 2 BALLOON_LINES 2 ; b0-b11 00F5BA 2 .else 00F5BA 2 BALLOON_LINES (14-rel) ; b0 .. b(rel-1) 00F5BA 2 ; b(rel): play line 59 00F5BA 2 .assert KY - 4 - rel = RELEASE_Y, error, "release line" 00F5BA 2 sta WSYNC 00F5BA 2 lda BalloonGfx+(14-rel) ; 4 00F5BA 2 sta GRP0 ; 7 00F5BA 2 sta GRP1 ; 10 00F5BA 2 BALL ; 26 00F5BA 2 lda #0 ; 28 00F5BA 2 sta VBLANK ; 31 00F5BA 2 lda #PADINIT ; 33 00F5BA 2 sta padY ; 36 00F5BA 2 PADDLE9 ; 45 00F5BA 2 dey ; 47 00F5BA 2 dex ; 49 00F5BA 2 BALLOON_LINES 2 ; the rest of b0-b11 00F5BA 2 .endif 00F5BA 2 ; b12 00F5BA 2 sta WSYNC 00F5BA 2 lda #BAL_ROW12 ; 2 00F5BA 2 sta GRP0 ; 5 00F5BA 2 sta GRP1 ; 8 00F5BA 2 BALL ; 24 00F5BA 2 dey ; 26 00F5BA 2 .if next >= 0 00F5BA 2 CHUNK_A next ; <= 71 00F5BA 2 .else 00F5BA 2 PADDLE9 00F5BA 2 .endif 00F5BA 2 ; b13 00F5BA 2 sta WSYNC 00F5BA 2 lda #BAL_ROW13 00F5BA 2 sta GRP0 00F5BA 2 sta GRP1 00F5BA 2 BALL 00F5BA 2 dey 00F5BA 2 .if next >= 0 00F5BA 2 CHUNK_B next ; 62 00F5BA 2 .else 00F5BA 2 PADDLE9 00F5BA 2 .endif 00F5BA 2 ; b14 00F5BA 2 sta WSYNC 00F5BA 2 lda #0 00F5BA 2 sta GRP0 00F5BA 2 sta GRP1 00F5BA 2 BALL 00F5BA 2 dey 00F5BA 2 .if next >= 0 00F5BA 2 CHUNK_C ; 43 00F5BA 2 .else 00F5BA 2 PADDLE9 00F5BA 2 .endif 00F5BA 2 KY .set KY-19 00F5BA 2 .endmacro 00F5BA 2 00F5BA 2 FloorSetup: 00F5BA 2 A5 rr lda floor 00F5BC 2 C9 02 cmp #2 00F5BE 2 D0 03 bne SetupMiddle 00F5C0 2 4C B8 F8 jmp SetupTop 00F5C3 2 00F5C3 2 ; Middle floor: the clown (P0, double width) and the bumpers (P1, three copies). 00F5C3 2 SetupMiddle: 00F5C3 2 A5 rr lda clownXpos 00F5C5 2 A2 00 ldx #0 00F5C7 2 20 6A F4 jsr PosObj ; ends 56, strobe 57, ends 57 00F5CA 2 85 02 sta WSYNC ; ends 58 00F5CC 2 EA EA EA EA SLEEP ::BUMP_SLEEP ; line 59: bumpers at a fixed x 00F5D0 2 EA EA EA EA 00F5D4 2 EA EA EA EA 00F5DD 2 85 11 sta RESP1 00F5DF 2 A9 40 lda #BUMP_HM 00F5E1 2 85 21 sta HMP1 00F5E3 2 85 02 sta WSYNC ; ends 59 00F5E5 2 85 2A sta HMOVE ; line 60 00F5E7 2 A9 05 lda #5 00F5E9 2 85 04 sta NUSIZ0 ; double-width clown 00F5EB 2 A9 06 lda #6 00F5ED 2 85 05 sta NUSIZ1 ; three copies, medium spacing 00F5EF 2 A5 rr lda bumpCol 00F5F1 2 85 07 sta COLUP1 00F5F3 2 A6 rr ldx speed ; the ball's power colour (walls and ball) 00F5F5 2 BD 58 FD lda PowerCol,x 00F5F8 2 85 rr sta bcol 00F5FA 2 85 02 sta WSYNC ; ends 60 00F5FC 2 85 2B sta HMCLR ; line 61 00F5FE 2 A9 A0 lda #C_BG1 00F600 2 85 09 sta COLUBK 00F602 2 A5 rr lda bcol 00F604 2 85 08 sta COLUPF 00F606 2 A9 F0 lda #$F0 00F608 2 85 0D sta PF0 00F60A 2 A0 AA ldy #PLAYH 00F60C 2 KY .set ::PLAYH 00F60C 2 85 02 98 38 EMPTY 2 ; 0-1 00F610 2 E5 rr C9 04 00F614 2 A9 FF 69 00 00F626 2 A6 rr ldx clownTop 00F628 2 ; clown: 16 lines (2-17). Its x is kept in 32..112, so GRP0 and COLUP0 can be 00F628 2 ; written up to cycle 32. 00F628 2 GUARD 36 00F628 2 85 02 M_clown: sta WSYNC 00F62A 2 98 38 E5 rr BALL ; 16 00F62E 2 C9 04 A9 FF 00F632 2 69 00 85 1F 00F636 2 BD 0A F4 lda ClownAGfx,x ; 20 00F639 2 85 1B sta GRP0 ; 23 00F63B 2 BD 3A F4 lda ClownACol,x ; 27 00F63E 2 85 06 sta COLUP0 ; 30 00F640 2 24 08 10 01 PADDLE9 ; 39 00F644 2 2C 84 rr 00F647 2 CA dex ; 41 00F648 2 88 dey ; 43 00F649 2 C0 98 cpy #(KY-16) ; 45 00F64B 2 D0 DB bne M_clown ; 48 00F64D 2 .assert >M_clown = >*, error, "clown loop crosses a page" 00F64D 2 KY .set KY-16 00F64D 2 A9 00 lda #0 00F64F 2 85 1B sta GRP0 00F651 2 85 02 98 38 EMPTY 6 ; 18-23 00F655 2 E5 rr C9 04 00F659 2 A9 FF 69 00 00F66B 2 A2 09 ldx #9 00F66D 2 GUARD 34 00F66D 2 85 02 M_bumpA: sta WSYNC ; bumpers A: 24-33 00F66F 2 BD 00 F4 lda BumperGfx,x ; 4 00F672 2 85 1C sta GRP1 ; 7 00F674 2 98 38 E5 rr BALL ; 23 00F678 2 C9 04 A9 FF 00F67C 2 69 00 85 1F 00F680 2 24 08 10 01 PADDLE9 ; 32 00F684 2 2C 84 rr 00F687 2 88 dey ; 34 00F688 2 CA dex ; 36 00F689 2 10 E2 bpl M_bumpA ; 39 00F68B 2 .assert >M_bumpA = >*, error, "bumper loop crosses a page" 00F68B 2 KY .set KY-10 00F68B 2 85 02 98 38 EMPTY 8 ; 34-41 00F68F 2 E5 rr C9 04 00F693 2 A9 FF 69 00 00F6A5 2 85 02 98 38 BRICK_E ; 42 00F6A9 2 E5 rr C9 04 00F6AD 2 A9 FF 69 00 00F6D0 2 85 02 98 38 BRICK_ROWV dropPF, C_DROP, 4 ; 43-48 00F6D4 2 E5 rr C9 04 00F6D8 2 A9 FF 69 00 00F762 2 85 02 98 38 BRICK_TV ; 49 00F766 2 E5 rr C9 04 00F76A 2 A9 FF 69 00 00F786 2 85 02 98 38 EMPTY 9 ; 50-58 00F78A 2 E5 rr C9 04 00F78E 2 A9 FF 69 00 00F7A0 2 85 02 98 38 RELEASE ; 59 00F7A4 2 E5 rr C9 04 00F7A8 2 A9 FF 69 00 00F7BE 2 85 02 98 38 EMPTY 29 ; 60-88 00F7C2 2 E5 rr C9 04 00F7C6 2 A9 FF 69 00 00F7D8 2 85 02 sta WSYNC ; 89: bumper row B: two copies, wide 00F7DA 2 98 38 E5 rr BALL ; 16 00F7DE 2 C9 04 A9 FF 00F7E2 2 69 00 85 1F 00F7E6 2 24 08 10 01 PADDLE9 ; 25 00F7EA 2 2C 84 rr 00F7ED 2 A9 04 lda #4 ; 27 00F7EF 2 85 05 sta NUSIZ1 ; 30 00F7F1 2 A2 09 ldx #9 ; 32 00F7F3 2 88 dey ; 34 00F7F4 2 KY .set KY-1 00F7F4 2 4C 00 F8 EA GUARD 34 00F7F8 2 EA EA EA EA 00F7FC 2 EA EA EA EA 00F800 2 85 02 M_bumpB: sta WSYNC ; bumpers B: 90-99 00F802 2 BD 00 F4 lda BumperGfx,x 00F805 2 85 1C sta GRP1 00F807 2 98 38 E5 rr BALL 00F80B 2 C9 04 A9 FF 00F80F 2 69 00 85 1F 00F813 2 24 08 10 01 PADDLE9 00F817 2 2C 84 rr 00F81A 2 88 dey 00F81B 2 CA dex 00F81C 2 10 E2 bpl M_bumpB 00F81E 2 .assert >M_bumpB = >*, error, "bumper loop crosses a page" 00F81E 2 KY .set KY-10 00F81E 2 85 02 98 38 EMPTY 52 ; 100-151 00F822 2 E5 rr C9 04 00F826 2 A9 FF 69 00 00F838 2 85 02 98 38 BATBAND ; 152-169 00F83C 2 E5 rr C9 04 00F840 2 A9 FF 69 00 00F8B5 2 4C 9E F5 jmp KernelEnd 00F8B8 2 00F8B8 2 00F8B8 2 ; Top floor set-up lines 56-60 (no ball on these lines). 00F8B8 2 SetupTop: 00F8B8 2 85 02 sta WSYNC ; ends 56 00F8BA 2 A5 rr 29 07 CHUNK_A 0 00F8BE 2 AA BD 7D F1 00F8C2 2 85 rr A5 rr 00F8DB 2 85 02 sta WSYNC ; ends 57 00F8DD 2 A5 rr 4A 4A CHUNK_B 0 00F8E1 2 4A AA BD 7D 00F8E5 2 F1 85 rr A5 00F8F6 2 85 02 sta WSYNC ; ends 58 00F8F8 2 A6 rr BD 00 CHUNK_C 00F8FC 2 F2 85 rr BD 00F900 2 00 F3 85 rr 00F904 2 85 02 sta WSYNC ; ends 59 00F906 2 A9 62 lda #C_BG2 00F908 2 85 09 sta COLUBK 00F90A 2 A9 00 lda #0 00F90C 2 85 1F sta ENABL 00F90E 2 A6 rr ldx speed ; the ball's power colour (walls and ball) 00F910 2 BD 58 FD lda PowerCol,x 00F913 2 85 rr sta bcol 00F915 2 85 02 sta WSYNC ; ends 60 00F917 2 A9 F0 lda #$F0 ; line 61 00F919 2 85 0D sta PF0 00F91B 2 A0 AA ldy #PLAYH 00F91D 2 A2 09 ldx #9 00F91F 2 KY .set ::PLAYH 00F91F 2 ; Roof: 10 lines (0-9), symmetric playfield; the ball never enters them. Lines 0-8 00F91F 2 ; in the loop, line 9 after it, in the power colour. 00F91F 2 GUARD 24 00F91F 2 85 02 T_roof: sta WSYNC 00F921 2 BD 73 F1 lda RoofCol,x ; 4 00F924 2 85 08 sta COLUPF ; 7 00F926 2 BD 5F F1 lda RoofPF1,x ; 11 00F929 2 85 0E sta PF1 ; 14 00F92B 2 BD 69 F1 lda RoofPF2,x ; 18 00F92E 2 85 0F sta PF2 ; 21 00F930 2 88 dey ; 23 00F931 2 CA dex ; 25 00F932 2 D0 EB bne T_roof ; 28 00F934 2 .assert >T_roof = >*, error, "roof loop crosses a page" 00F934 2 85 02 sta WSYNC ; line 9 00F936 2 A5 rr lda bcol ; 3 00F938 2 85 08 sta COLUPF ; 6 00F93A 2 AD 5F F1 lda RoofPF1 ; 10 00F93D 2 85 0E sta PF1 ; 13 00F93F 2 AD 69 F1 lda RoofPF2 ; 17 00F942 2 85 0F sta PF2 ; 20 00F944 2 88 dey ; 22 00F945 2 KY .set KY-10 00F945 2 ; (the roof's last line leaves PF1 = PF2 = 0 and COLUPF = the power colour) 00F945 2 85 02 98 38 BROW C_BAL0A, C_BAL0B, 1, -1 ; 10-28 00F949 2 E5 rr C9 04 00F94D 2 A9 FF 69 00 00FA5C 2 85 02 98 38 BROW C_BAL1A, C_BAL1B, 2, -1 ; 29-47 00FA60 2 E5 rr C9 04 00FA64 2 A9 FF 69 00 00FB73 2 85 02 98 38 BROW C_BAL2A, C_BAL2B, -1, 7 ; 48-66 (b7 = line 59) 00FB77 2 E5 rr C9 04 00FB7B 2 A9 FF 69 00 00FCBE 2 85 02 98 38 EMPTY 85 ; 67-151 00FCC2 2 E5 rr C9 04 00FCC6 2 A9 FF 69 00 00FCD8 2 85 02 98 38 BATBAND ; 152-169 00FCDC 2 E5 rr C9 04 00FCE0 2 A9 FF 69 00 00FD55 2 4C 9E F5 jmp KernelEnd 00FD58 2 00FD58 2 ; The ball's power by speed step (0-7), as the colour of the ball and the walls on 00FD58 2 ; the middle and top floors (they share COLUPF): grey at the slower steps, then 00FD58 2 ; yellow, orange, and blue-white from PUNCH_SPEED, when the ball punches through 00FD58 2 ; balloons (2026-11-23; provisional). 00FD58 2 PowerCol: 00FD58 2 0C 0C 0C 4C .repeat 8, I 00FD5C 2 6C BE BE BE 00FD60 2 .if I >= ::PUNCH_SPEED 00FD60 2 .byte C_POW3 00FD60 2 .elseif I = ::PUNCH_SPEED - 1 00FD60 2 .byte C_POW2 00FD60 2 .elseif I = ::PUNCH_SPEED - 2 00FD60 2 .byte C_POW1 00FD60 2 .else 00FD60 2 .byte C_WALL1 00FD60 2 .endif 00FD60 2 .endrepeat 00FD60 2 .assert >PowerCol = >(PowerCol+7), error, "PowerCol crosses a page" 00FD60 2 00FD60 2 .endscope 00FD60 2 KernelTop = top::Entry 00FD60 2 .assert top::Font = $F000, error, "Font must start bank 1" 00FD60 2 .assert top::BatGfx - top::Font = low::BatGfx - low::Font, error, "BatGfx offsets differ" 00FD60 2 00FD60 1 .include "title.s" 00FD60 2 ; SPDX-License-Identifier: MIT 00FD60 2 ; Bank 2: the title and attract screen. 4 set-up lines (VBLANK on) and 192 00FD60 2 ; visible lines, like the play kernel. Section line numbers are visible lines. 00FD60 2 ; 0-7 last game's score (dp, prepared by bank 0) 00FD60 2 ; 10-33 the tent roof (12 rows, 2 lines each) 00FD60 2 ; 38-53 BIG TOP (two colours, double height) 00FD60 2 ; 58-73 BOUNCE 00FD60 2 ; 80-94 a row of balloons sliding (P0 and P1, three copies each) 00FD60 2 ; 104-119 the clown 00FD60 2 ; 132-139 GAME n 00FD60 2 ; 150-173 the ring 00FD60 2 00FD60 2 .segment "BANK2" 00FD60 2 .org $B000 00B000 2 .scope title 00B000 2 .include "gen/font.inc" 00B000 3 ; SPDX-License-Identifier: MIT 00B000 3 ; Generated by scripts/gen_tables.py: do not edit. 00B000 3 .align 256 00B000 3 Font: 00B000 3 ; '0' 00B000 3 00 7C C6 E6 .byte $00,$7C,$C6,$E6,$D6,$CE,$C6,$7C 00B004 3 D6 CE C6 7C 00B008 3 ; '1' 00B008 3 00 7E 18 18 .byte $00,$7E,$18,$18,$18,$78,$38,$18 00B00C 3 18 78 38 18 00B010 3 ; '2' 00B010 3 00 FE C0 70 .byte $00,$FE,$C0,$70,$1C,$06,$C6,$7C 00B014 3 1C 06 C6 7C 00B018 3 ; '3' 00B018 3 00 7C C6 06 .byte $00,$7C,$C6,$06,$3C,$06,$C6,$7C 00B01C 3 3C 06 C6 7C 00B020 3 ; '4' 00B020 3 00 0C 0C FE .byte $00,$0C,$0C,$FE,$6C,$3C,$1C,$0C 00B024 3 6C 3C 1C 0C 00B028 3 ; '5' 00B028 3 00 7C C6 06 .byte $00,$7C,$C6,$06,$06,$FC,$C0,$FE 00B02C 3 06 FC C0 FE 00B030 3 ; '6' 00B030 3 00 7C C6 C6 .byte $00,$7C,$C6,$C6,$FC,$C0,$60,$3C 00B034 3 FC C0 60 3C 00B038 3 ; '7' 00B038 3 00 30 30 30 .byte $00,$30,$30,$30,$18,$0C,$06,$FE 00B03C 3 18 0C 06 FE 00B040 3 ; '8' 00B040 3 00 7C C6 C6 .byte $00,$7C,$C6,$C6,$7C,$C6,$C6,$7C 00B044 3 7C C6 C6 7C 00B048 3 ; '9' 00B048 3 00 78 0C 06 .byte $00,$78,$0C,$06,$7E,$C6,$C6,$7C 00B04C 3 7E C6 C6 7C 00B050 3 ; ' ' 00B050 3 00 00 00 00 .byte $00,$00,$00,$00,$00,$00,$00,$00 00B054 3 00 00 00 00 00B058 3 ; 'A' 00B058 3 00 C6 C6 FE .byte $00,$C6,$C6,$FE,$C6,$C6,$6C,$38 00B05C 3 C6 C6 6C 38 00B060 3 ; 'B' 00B060 3 00 FC C6 C6 .byte $00,$FC,$C6,$C6,$FC,$C6,$C6,$FC 00B064 3 FC C6 C6 FC 00B068 3 ; 'C' 00B068 3 00 7C C6 C0 .byte $00,$7C,$C6,$C0,$C0,$C0,$C6,$7C 00B06C 3 C0 C0 C6 7C 00B070 3 ; 'E' 00B070 3 00 FE C0 C0 .byte $00,$FE,$C0,$C0,$F8,$C0,$C0,$FE 00B074 3 F8 C0 C0 FE 00B078 3 ; 'G' 00B078 3 00 7E C6 C6 .byte $00,$7E,$C6,$C6,$DE,$C0,$C6,$7C 00B07C 3 DE C0 C6 7C 00B080 3 ; 'I' 00B080 3 00 7E 18 18 .byte $00,$7E,$18,$18,$18,$18,$18,$7E 00B084 3 18 18 18 7E 00B088 3 ; 'K' 00B088 3 00 C6 CC D8 .byte $00,$C6,$CC,$D8,$F0,$D8,$CC,$C6 00B08C 3 F0 D8 CC C6 00B090 3 ; 'L' 00B090 3 00 FE C0 C0 .byte $00,$FE,$C0,$C0,$C0,$C0,$C0,$C0 00B094 3 C0 C0 C0 C0 00B098 3 ; 'M' 00B098 3 00 C6 C6 C6 .byte $00,$C6,$C6,$C6,$D6,$FE,$EE,$C6 00B09C 3 D6 FE EE C6 00B0A0 3 ; 'N' 00B0A0 3 00 C6 C6 CE .byte $00,$C6,$C6,$CE,$DE,$F6,$E6,$C6 00B0A4 3 DE F6 E6 C6 00B0A8 3 ; 'O' 00B0A8 3 00 7C C6 C6 .byte $00,$7C,$C6,$C6,$C6,$C6,$C6,$7C 00B0AC 3 C6 C6 C6 7C 00B0B0 3 ; 'P' 00B0B0 3 00 C0 C0 C0 .byte $00,$C0,$C0,$C0,$FC,$C6,$C6,$FC 00B0B4 3 FC C6 C6 FC 00B0B8 3 ; 'R' 00B0B8 3 00 C6 CC D8 .byte $00,$C6,$CC,$D8,$FC,$C6,$C6,$FC 00B0BC 3 FC C6 C6 FC 00B0C0 3 ; 'S' 00B0C0 3 00 7C C6 06 .byte $00,$7C,$C6,$06,$7C,$C0,$C6,$7C 00B0C4 3 7C C0 C6 7C 00B0C8 3 ; 'T' 00B0C8 3 00 30 30 30 .byte $00,$30,$30,$30,$30,$30,$30,$FC 00B0CC 3 30 30 30 FC 00B0D0 3 ; 'U' 00B0D0 3 00 7C C6 C6 .byte $00,$7C,$C6,$C6,$C6,$C6,$C6,$C6 00B0D4 3 C6 C6 C6 C6 00B0D8 3 ; 'V' 00B0D8 3 00 10 38 6C .byte $00,$10,$38,$6C,$C6,$C6,$C6,$C6 00B0DC 3 C6 C6 C6 C6 00B0E0 3 ; 'X' 00B0E0 3 00 C6 6C 38 .byte $00,$C6,$6C,$38,$38,$38,$6C,$C6 00B0E4 3 38 38 6C C6 00B0E8 3 ; 'Y' 00B0E8 3 00 30 30 30 .byte $00,$30,$30,$30,$30,$78,$CC,$CC 00B0EC 3 30 78 CC CC 00B0F0 3 ; '!' 00B0F0 3 00 18 00 18 .byte $00,$18,$00,$18,$18,$18,$18,$18 00B0F4 3 18 18 18 18 00B0F8 3 ; '-' 00B0F8 3 00 00 00 00 .byte $00,$00,$00,$00,$7C,$00,$00,$00 00B0FC 3 7C 00 00 00 00B100 3 00B100 2 .include "gen/title.inc" 00B100 3 ; SPDX-License-Identifier: MIT 00B100 3 ; Generated by scripts/gen_tables.py: do not edit. 00B100 3 .align 256 00B100 3 GfxTitle: 00B100 3 TBalloonGfx: 00B100 3 00 08 18 18 .byte $00,$08,$18,$18,$3C,$7E,$7E,$FF,$FF,$FF,$BF,$BF,$DF,$7E,$3C 00B104 3 3C 7E 7E FF 00B108 3 FF FF BF BF 00B10F 3 TClownGfx: 00B10F 3 E7 66 24 3C .byte $E7,$66,$24,$3C,$7E,$BD,$7E,$FF,$BD,$24,$3C,$24,$7E,$3C,$3C,$18 00B113 3 7E BD 7E FF 00B117 3 BD 24 3C 24 00B11F 3 TClownCol: 00B11F 3 84 .byte C_CL_RED 00B120 3 58 .byte C_CL_GREEN 00B121 3 58 .byte C_CL_GREEN 00B122 3 B8 .byte C_CL_BLUE 00B123 3 B8 .byte C_CL_BLUE 00B124 3 B8 .byte C_CL_BLUE 00B125 3 B8 .byte C_CL_BLUE 00B126 3 0E .byte C_CL_WHITE 00B127 3 0E .byte C_CL_WHITE 00B128 3 6C .byte C_CL_SKIN 00B129 3 6C .byte C_CL_SKIN 00B12A 3 6C .byte C_CL_SKIN 00B12B 3 4C .byte C_CL_YELLOW 00B12C 3 4C .byte C_CL_YELLOW 00B12D 3 4C .byte C_CL_YELLOW 00B12E 3 84 .byte C_CL_RED 00B12F 3 TRoofPF1: 00B12F 3 00 00 00 00 .byte $00,$00,$00,$00,$00,$11,$77,$FF,$FF,$FF 00B133 3 00 11 77 FF 00B137 3 FF FF 00B139 3 TRoofPF2: 00B139 3 00 00 00 00 .byte $00,$00,$00,$00,$00,$88,$EE,$FF,$FF,$FF 00B13D 3 00 88 EE FF 00B141 3 FF FF 00B143 3 TRoofCol: 00B143 3 0C .byte C_WALL2 00B144 3 0C .byte C_WALL2 00B145 3 0C .byte C_WALL2 00B146 3 0C .byte C_WALL2 00B147 3 0C .byte C_WALL2 00B148 3 84 .byte C_ROOFA 00B149 3 0E .byte C_ROOFB 00B14A 3 84 .byte C_ROOFA 00B14B 3 0E .byte C_ROOFB 00B14C 3 84 .byte C_ROOFA 00B14D 3 TRingPF0: 00B14D 3 00 00 00 00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 00B151 3 00 00 00 00 00B155 3 00 00 00 00 00B15D 3 00 00 00 00 .byte $00,$00,$00,$00,$00,$00,$00,$00 00B161 3 00 00 00 00 00B165 3 TRingPF1: 00B165 3 00 00 03 0E .byte $00,$00,$03,$0E,$1C,$30,$70,$60,$C0,$C0,$C0,$80,$80,$C0,$C0,$C0 00B169 3 1C 30 70 60 00B16D 3 C0 C0 C0 80 00B175 3 60 70 30 1C .byte $60,$70,$30,$1C,$0E,$03,$00,$00 00B179 3 0E 03 00 00 00B17D 3 TRingPF2: 00B17D 3 F8 3F 03 00 .byte $F8,$3F,$03,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 00B181 3 00 00 00 00 00B185 3 00 00 00 00 00B18D 3 00 00 00 00 .byte $00,$00,$00,$00,$00,$03,$3F,$F8 00B191 3 00 03 3F F8 00B195 3 .assert >* = >GfxTitle, error, "GfxTitle crosses a page" 00B195 3 00B195 2 00B195 2 ; PosObj: as in shared.s (two lines, x - POS_K in 0..149). 00B195 2 PosObj: 00B195 2 85 02 sta WSYNC 00B197 2 EA EA EA EA SLEEP 14 00B19B 2 EA EA EA 00B19E 2 38 sec 00B19F 2 E9 0F @div: sbc #15 00B1A1 2 B0 FC bcs @div 00B1A3 2 95 10 sta RESP0,x 00B1A5 2 85 02 sta WSYNC 00B1A7 2 49 07 eor #7 00B1A9 2 0A asl 00B1AA 2 0A asl 00B1AB 2 0A asl 00B1AC 2 0A asl 00B1AD 2 95 20 sta HMP0,x 00B1AF 2 60 rts 00B1B0 2 00B1B0 2 ; TEXTPTRS str: copy six glyph offsets into dp's low bytes (35 cycles + 6). 00B1B0 2 .macro TEXTPTRS str 00B1B0 2 .repeat 6, i 00B1B0 2 lda str+i 00B1B0 2 sta dp+i*2 00B1B0 2 .endrepeat 00B1B0 2 .endmacro 00B1B0 2 00B1B0 2 ; The 48-pixel text loop (as the HUD's), each row drawn on two lines. 00B1B0 2 .macro TEXT2 00B1B0 2 .local loop 00B1B0 2 ldy #7 00B1B0 2 sty row 00B1B0 2 GUARD 110 00B1B0 2 loop: lda (dp+0),y 00B1B0 2 sta GRP0 00B1B0 2 sta WSYNC 00B1B0 2 lda (dp+2),y ; 5 00B1B0 2 sta GRP1 ; 8 00B1B0 2 lda (dp+4),y ; 13 00B1B0 2 sta GRP0 ; 16 00B1B0 2 lda (dp+6),y ; 21 00B1B0 2 sta tmp ; 24 00B1B0 2 lda (dp+8),y ; 29 00B1B0 2 tax ; 31 00B1B0 2 lda (dp+10),y ; 36 00B1B0 2 tay ; 38 00B1B0 2 lda tmp ; 41 00B1B0 2 sta GRP1 ; 44 00B1B0 2 stx GRP0 ; 47 00B1B0 2 sty GRP1 ; 50 00B1B0 2 sta GRP0 ; 53 00B1B0 2 ldy row ; 56 00B1B0 2 lda (dp+0),y ; 61 00B1B0 2 sta GRP0 ; 64 00B1B0 2 sta WSYNC ; 67 00B1B0 2 lda (dp+2),y ; 5 00B1B0 2 sta GRP1 ; 8 00B1B0 2 lda (dp+4),y ; 13 00B1B0 2 sta GRP0 ; 16 00B1B0 2 lda (dp+6),y ; 21 00B1B0 2 sta tmp ; 24 00B1B0 2 lda (dp+8),y ; 29 00B1B0 2 tax ; 31 00B1B0 2 lda (dp+10),y ; 36 00B1B0 2 tay ; 38 00B1B0 2 lda tmp ; 41 00B1B0 2 sta GRP1 ; 44 00B1B0 2 stx GRP0 ; 47 00B1B0 2 sty GRP1 ; 50 00B1B0 2 sta GRP0 ; 53 00B1B0 2 dec row ; 58 00B1B0 2 ldy row ; 61 00B1B0 2 bpl loop ; 64 00B1B0 2 .assert >loop = >*, error, "text loop crosses a page" 00B1B0 2 .endmacro 00B1B0 2 00B1B0 2 ; The same, one line per row. 00B1B0 2 .macro TEXT1 00B1B0 2 .local loop 00B1B0 2 ldy #7 00B1B0 2 sty row 00B1B0 2 GUARD 56 00B1B0 2 loop: lda (dp+0),y 00B1B0 2 sta GRP0 00B1B0 2 sta WSYNC 00B1B0 2 lda (dp+2),y 00B1B0 2 sta GRP1 00B1B0 2 lda (dp+4),y 00B1B0 2 sta GRP0 00B1B0 2 lda (dp+6),y 00B1B0 2 sta tmp 00B1B0 2 lda (dp+8),y 00B1B0 2 tax 00B1B0 2 lda (dp+10),y 00B1B0 2 tay 00B1B0 2 lda tmp 00B1B0 2 sta GRP1 00B1B0 2 stx GRP0 00B1B0 2 sty GRP1 00B1B0 2 sta GRP0 00B1B0 2 dec row 00B1B0 2 ldy row 00B1B0 2 bpl loop 00B1B0 2 .assert >loop = >*, error, "text loop crosses a page" 00B1B0 2 .endmacro 00B1B0 2 00B1B0 2 ; Text players at the score's fixed position: ends the current line, strobes on 00B1B0 2 ; the next, ends it. 00B1B0 2 .macro TEXTPOS 00B1B0 2 sta WSYNC 00B1B0 2 SLEEP ::SCORE_SLEEP 00B1B0 2 sta RESP0 00B1B0 2 sta RESP1 00B1B0 2 lda #SCORE_HM0 00B1B0 2 sta HMP0 00B1B0 2 lda #SCORE_HM1 00B1B0 2 sta HMP1 00B1B0 2 sta WSYNC 00B1B0 2 .endmacro 00B1B0 2 00B1B0 2 ; WAITLINES n: end n lines doing nothing. 00B1B0 2 .macro WAITLINES n 00B1B0 2 .local l 00B1B0 2 ldx #n 00B1B0 2 l: sta WSYNC 00B1B0 2 dex 00B1B0 2 bne l 00B1B0 2 .endmacro 00B1B0 2 00B1B0 2 Entry: 00B1B0 2 ; set-up lines 36-39 00B1B0 2 85 02 sta WSYNC ; ends 36 00B1B2 2 A2 01 85 02 WAITLINES 1 ; ends 37 00B1B6 2 CA D0 FB 00B1B9 2 85 02 24 80 TEXTPOS ; ends 38, strobes on 39, ends 39 00B1BD 2 EA EA EA EA 00B1C1 2 EA EA EA EA 00B1DC 2 ; visible 0 (40) 00B1DC 2 85 2A sta HMOVE 00B1DE 2 A9 82 lda #$82 00B1E0 2 85 01 sta VBLANK ; still blank on this first line; capacitors dumped 00B1E2 2 A9 03 lda #3 00B1E4 2 85 04 sta NUSIZ0 00B1E6 2 85 05 sta NUSIZ1 00B1E8 2 A9 01 lda #1 00B1EA 2 85 25 sta VDELP0 00B1EC 2 85 26 sta VDELP1 00B1EE 2 A5 rr lda scoreCol 00B1F0 2 85 06 sta COLUP0 00B1F2 2 85 07 sta COLUP1 00B1F4 2 A9 00 lda #0 00B1F6 2 85 09 sta COLUBK 00B1F8 2 85 0D sta PF0 00B1FA 2 85 0E sta PF1 00B1FC 2 85 0F sta PF2 00B1FE 2 85 1F sta ENABL 00B200 2 85 0A sta CTRLPF 00B202 2 85 2B sta HMCLR 00B204 2 85 02 sta WSYNC ; ends 0 00B206 2 A9 80 lda #$80 00B208 2 85 01 sta VBLANK ; visible from line 1 on 00B20A 2 ; lines 1-8: score (the loop's first WSYNC ends line 0... see count) 00B20A 2 A0 07 84 rr TEXT1 ; 8 lines: 1-8 00B20E 2 B1 rr 85 1B 00B212 2 85 02 B1 rr 00B236 2 85 02 sta WSYNC ; ends 8 00B238 2 A9 00 lda #0 ; 9 00B23A 2 85 1B sta GRP0 00B23C 2 85 1C sta GRP1 00B23E 2 85 1B sta GRP0 00B240 2 A9 15 lda #CTRL_REF 00B242 2 85 0A sta CTRLPF 00B244 2 A9 F0 lda #$F0 00B246 2 85 0D sta PF0 00B248 2 A2 0B ldx #11 00B24A 2 A9 00 lda #0 00B24C 2 85 rr sta row ; row = line parity for the roof 00B24E 2 85 02 sta WSYNC ; ends 9 00B250 2 ; roof: 24 lines (10-33), each table row twice 00B250 2 GUARD 40 00B250 2 TT_roof: 00B250 2 BD 43 B1 lda TRoofCol,x ; 4 00B253 2 85 08 sta COLUPF ; 7 00B255 2 BD 2F B1 lda TRoofPF1,x ; 11 00B258 2 85 0E sta PF1 ; 14 00B25A 2 BD 39 B1 lda TRoofPF2,x ; 18 00B25D 2 85 0F sta PF2 ; 21 00B25F 2 85 02 sta WSYNC 00B261 2 BD 43 B1 lda TRoofCol,x 00B264 2 85 08 sta COLUPF 00B266 2 BD 2F B1 lda TRoofPF1,x 00B269 2 85 0E sta PF1 00B26B 2 BD 39 B1 lda TRoofPF2,x 00B26E 2 85 0F sta PF2 00B270 2 CA dex 00B271 2 85 02 sta WSYNC 00B273 2 10 DB bpl TT_roof 00B275 2 ; line 34 00B275 2 A9 00 lda #0 00B277 2 85 0D sta PF0 00B279 2 85 0E sta PF1 00B27B 2 85 0F sta PF2 00B27D 2 A9 B0 lda #>Font 00B27F 2 85 rr 85 rr .repeat 6, i 00B283 2 85 rr 85 rr 00B287 2 85 rr 85 rr 00B28B 2 sta dp+i*2+1 00B28B 2 .endrepeat 00B28B 2 A9 86 lda #C_TITLE1 00B28D 2 85 06 sta COLUP0 00B28F 2 A9 4E lda #C_TITLE2 00B291 2 85 07 sta COLUP1 00B293 2 85 02 sta WSYNC ; ends 34 00B295 2 AD 7F B5 85 TEXTPTRS StrBig ; line 35 00B299 2 rr AD 80 B5 00B29D 2 85 rr AD 81 00B2B3 2 85 02 sta WSYNC ; ends 35 00B2B5 2 A2 01 85 02 WAITLINES 1 ; ends 36 00B2B9 2 CA D0 FB 00B2BC 2 ; 37: the loop's first WSYNC ends it 00B2BC 2 A0 07 84 rr TEXT2 ; 38-53 00B2C0 2 4C 00 B3 EA 00B2C4 2 EA EA EA EA 00B34C 2 85 02 sta WSYNC ; ends 53 00B34E 2 A9 00 lda #0 ; 54 00B350 2 85 1B sta GRP0 00B352 2 85 1C sta GRP1 00B354 2 85 1B sta GRP0 00B356 2 A9 BC lda #C_TITLE3 00B358 2 85 06 sta COLUP0 00B35A 2 A9 8E lda #C_TITLE4 00B35C 2 85 07 sta COLUP1 00B35E 2 85 02 sta WSYNC ; ends 54 00B360 2 AD 85 B5 85 TEXTPTRS StrBounce ; 55 00B364 2 rr AD 86 B5 00B368 2 85 rr AD 87 00B37E 2 85 02 sta WSYNC ; ends 55 00B380 2 A2 01 85 02 WAITLINES 1 ; ends 56 00B384 2 CA D0 FB 00B387 2 A0 07 84 rr TEXT2 ; 58-73 (57 ended by the loop) 00B38B 2 B1 rr 85 1B 00B38F 2 85 02 B1 rr 00B3D7 2 85 02 sta WSYNC ; ends 73 00B3D9 2 A9 00 lda #0 ; 74 00B3DB 2 85 1B sta GRP0 00B3DD 2 85 1C sta GRP1 00B3DF 2 85 1B sta GRP0 00B3E1 2 85 25 sta VDELP0 00B3E3 2 85 26 sta VDELP1 00B3E5 2 A9 06 lda #6 00B3E7 2 85 04 sta NUSIZ0 00B3E9 2 85 05 sta NUSIZ1 00B3EB 2 A9 86 lda #C_BAL0A 00B3ED 2 85 06 sta COLUP0 00B3EF 2 A9 5A lda #C_BAL1B 00B3F1 2 85 07 sta COLUP1 00B3F3 2 A5 rr lda titleX 00B3F5 2 A2 00 ldx #0 00B3F7 2 20 95 B1 jsr PosObj ; ends 74, strobes 75, ends 75 00B3FA 2 A5 rr lda titleX 00B3FC 2 18 clc 00B3FD 2 69 10 adc #16 00B3FF 2 A2 01 ldx #1 00B401 2 20 95 B1 jsr PosObj ; ends 76, strobes 77, ends 77 00B404 2 85 02 sta WSYNC ; ends 78 00B406 2 85 2A sta HMOVE ; 79 00B408 2 EA EA EA EA SLEEP 24 ; HMCLR no sooner than 24 cycles after HMOVE 00B40C 2 EA EA EA EA 00B410 2 EA EA EA EA 00B414 2 85 2B sta HMCLR 00B416 2 A2 0E ldx #14 ; all 15 rows of the balloon (the first build 00B418 2 85 02 sta WSYNC ; ends 79 drew only the lower 11: a heart shape) 00B41A 2 GUARD 16 00B41A 2 BD 00 B1 TT_bal: lda TBalloonGfx,x ; 80-94 00B41D 2 85 1B sta GRP0 00B41F 2 85 1C sta GRP1 00B421 2 85 02 sta WSYNC 00B423 2 CA dex 00B424 2 10 F4 bpl TT_bal 00B426 2 A9 00 lda #0 ; 95 00B428 2 85 1B sta GRP0 00B42A 2 85 1C sta GRP1 00B42C 2 85 05 sta NUSIZ1 00B42E 2 A9 05 lda #5 00B430 2 85 04 sta NUSIZ0 00B432 2 A9 44 lda #(72 - POS_KP) 00B434 2 A2 00 ldx #0 00B436 2 20 95 B1 jsr PosObj ; ends 95, strobes 96, ends 96 00B439 2 85 02 sta WSYNC ; ends 97 00B43B 2 85 2A sta HMOVE ; 98 00B43D 2 A2 05 85 02 WAITLINES 5 ; ends 98-102 00B441 2 CA D0 FB 00B444 2 A2 0F ldx #15 00B446 2 85 2B sta HMCLR 00B448 2 85 02 sta WSYNC ; ends 103 00B44A 2 GUARD 20 00B44A 2 BD 0F B1 TT_clown: lda TClownGfx,x ; 104-119 00B44D 2 85 1B sta GRP0 00B44F 2 BD 1F B1 lda TClownCol,x 00B452 2 85 06 sta COLUP0 00B454 2 85 02 sta WSYNC 00B456 2 CA dex 00B457 2 10 F1 bpl TT_clown 00B459 2 A9 00 lda #0 ; 120 00B45B 2 85 1B sta GRP0 00B45D 2 A9 03 lda #3 00B45F 2 85 04 sta NUSIZ0 00B461 2 85 05 sta NUSIZ1 00B463 2 A9 01 lda #1 00B465 2 85 25 sta VDELP0 00B467 2 85 26 sta VDELP1 00B469 2 A9 0E lda #C_TEXT 00B46B 2 85 06 sta COLUP0 00B46D 2 85 07 sta COLUP1 00B46F 2 85 02 24 80 TEXTPOS ; ends 120, strobes 121, ends 121 00B473 2 EA EA EA EA 00B477 2 EA EA EA EA 00B492 2 85 2A sta HMOVE ; 122 00B494 2 85 02 sta WSYNC ; ends 122 00B496 2 85 2B sta HMCLR ; 123 00B498 2 AD 8B B5 85 TEXTPTRS StrGame 00B49C 2 rr AD 8C B5 00B4A0 2 85 rr AD 8D 00B4B6 2 A5 rr lda gameNum ; the game number's digit 00B4B8 2 18 clc 00B4B9 2 69 01 adc #1 00B4BB 2 0A asl 00B4BC 2 0A asl 00B4BD 2 0A asl 00B4BE 2 85 rr sta dp+10 00B4C0 2 85 02 sta WSYNC ; ends 123 00B4C2 2 A2 07 85 02 WAITLINES 7 ; ends 124-130 00B4C6 2 CA D0 FB 00B4C9 2 A0 07 84 rr TEXT1 ; 132-139 (131 ended by the loop) 00B4CD 2 4C 00 B5 EA 00B4D1 2 EA EA EA EA 00B528 2 85 02 sta WSYNC ; ends 139 00B52A 2 A9 00 lda #0 ; 140 00B52C 2 85 1B sta GRP0 00B52E 2 85 1C sta GRP1 00B530 2 85 1B sta GRP0 00B532 2 85 25 sta VDELP0 00B534 2 85 26 sta VDELP1 00B536 2 A9 86 lda #C_TITLE1 00B538 2 85 08 sta COLUPF 00B53A 2 A2 0A 85 02 WAITLINES 10 ; ends 140-149 00B53E 2 CA D0 FB 00B541 2 A2 17 ldx #23 00B543 2 GUARD 24 00B543 2 BD 4D B1 TT_ring: lda TRingPF0,x ; 150-173 00B546 2 85 0D sta PF0 00B548 2 BD 65 B1 lda TRingPF1,x 00B54B 2 85 0E sta PF1 00B54D 2 BD 7D B1 lda TRingPF2,x 00B550 2 85 0F sta PF2 00B552 2 85 02 sta WSYNC 00B554 2 CA dex 00B555 2 10 EC bpl TT_ring 00B557 2 A9 00 lda #0 ; 174 00B559 2 85 0D sta PF0 00B55B 2 85 0E sta PF1 00B55D 2 85 0F sta PF2 00B55F 2 A2 10 85 02 WAITLINES 16 00B563 2 CA D0 FB 00B566 2 85 02 A9 82 KEXIT ToLogic2 ; ends the last visible line 00B56A 2 85 01 A9 00 00B56E 2 85 1F 85 1B 00B57F 2 00B57F 2 60 80 78 C8 StrBig: .byte CH_B, CH_I, CH_G, CH_T, CH_O, CH_P 00B583 2 A8 B0 00B585 2 60 A8 D0 A0 StrBounce: .byte CH_B, CH_O, CH_U, CH_N, CH_C, CH_E 00B589 2 68 70 00B58B 2 78 58 98 70 StrGame: .byte CH_G, CH_A, CH_M, CH_E, CH_SP, CH_0 00B58F 2 50 00 00B591 2 00B591 2 .endscope 00B591 2 TitleKernel = title::Entry 00B591 2 .assert title::Font = $B000, error, "Font must start bank 2" 00B591 2 00B591 1 .include "logic.s" 00B591 2 ; SPDX-License-Identifier: MIT 00B591 2 ; Bank 0: the frame loop, the game logic and the sound. 00B591 2 00B591 2 .segment "BANK0" 00B591 2 .org $D000 00D000 2 .include "gen/logic.inc" 00D000 3 ; SPDX-License-Identifier: MIT 00D000 3 ; Generated by scripts/gen_tables.py: do not edit. 00D000 3 VXLO: 00D000 3 35 66 91 B1 .byte $35,$66,$91,$B1,$3C,$73,$A3,$C8,$42,$80,$B5,$DE,$4B,$90,$CC,$F9 00D004 3 3C 73 A3 C8 00D008 3 42 80 B5 DE 00D010 3 53 A0 E2 15 .byte $53,$A0,$E2,$15,$5B,$B0,$F9,$31,$63,$C0,$10,$4D,$6D,$D3,$2B,$6E 00D014 3 5B B0 F9 31 00D018 3 63 C0 10 4D 00D020 3 VXHI: 00D020 3 00 00 00 00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 00D024 3 00 00 00 00 00D028 3 00 00 00 00 00D030 3 00 00 00 01 .byte $00,$00,$00,$01,$00,$00,$00,$01,$00,$00,$01,$01,$00,$00,$01,$01 00D034 3 00 00 00 01 00D038 3 00 00 01 01 00D040 3 VYLO: 00D040 3 8C 63 22 CD .byte $8C,$63,$22,$CD,$BD,$8F,$46,$E6,$EF,$BB,$6A,$00,$2C,$F3,$97,$20 00D044 3 BD 8F 46 E6 00D048 3 EF BB 6A 00 00D050 3 6A 2A C5 40 .byte $6A,$2A,$C5,$40,$A8,$62,$F2,$60,$E6,$99,$1F,$80,$30,$DC,$55,$A6 00D054 3 A8 62 F2 60 00D058 3 E6 99 1F 80 00D060 3 VYHI: 00D060 3 01 01 01 00 .byte $01,$01,$01,$00,$01,$01,$01,$00,$01,$01,$01,$01,$02,$01,$01,$01 00D064 3 01 01 01 00 00D068 3 01 01 01 01 00D070 3 02 02 01 01 .byte $02,$02,$01,$01,$02,$02,$01,$01,$02,$02,$02,$01,$03,$02,$02,$01 00D074 3 02 02 01 01 00D078 3 02 02 02 01 00D080 3 Zone16: 00D080 3 00 00 00 01 .byte $00,$00,$00,$01,$01,$02,$02,$03,$03,$04,$04,$04,$05,$05,$06,$06 00D084 3 01 02 02 03 00D088 3 03 04 04 04 00D090 3 07 07 .byte $07,$07 00D092 3 Zone24: 00D092 3 00 00 00 00 .byte $00,$00,$00,$00,$01,$01,$01,$02,$02,$02,$03,$03,$03,$04,$04,$04 00D096 3 01 01 01 02 00D09A 3 02 02 03 03 00D0A2 3 04 05 05 05 .byte $04,$05,$05,$05,$06,$06,$06,$07,$07,$07 00D0A6 3 06 06 06 07 00D0AA 3 07 07 00D0AC 3 BatC: 00D0AC 3 00 00 00 00 .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$01,$01,$01,$01 00D0B0 3 00 00 00 00 00D0B4 3 00 00 00 00 00D0BC 3 01 01 01 01 .byte $01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$02,$02,$02,$02,$02 00D0C0 3 01 01 01 01 00D0C4 3 01 01 01 02 00D0CC 3 02 02 02 02 .byte $02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$03,$03,$03,$03,$03,$03 00D0D0 3 02 02 02 02 00D0D4 3 02 02 03 03 00D0DC 3 03 03 03 03 .byte $03,$03,$03,$03,$03,$03,$03,$03,$03,$04,$04,$04,$04,$04,$04,$04 00D0E0 3 03 03 03 03 00D0E4 3 03 04 04 04 00D0EC 3 04 04 04 04 .byte $04,$04,$04,$04,$04,$04,$04,$04,$05,$05,$05,$05,$05,$05,$05,$05 00D0F0 3 04 04 04 04 00D0F4 3 05 05 05 05 00D0FC 3 05 05 05 05 .byte $05,$05,$05,$05,$05,$05,$05,$06,$06,$06,$06,$06,$06,$06,$06,$06 00D100 3 05 05 05 06 00D104 3 06 06 06 06 00D10C 3 06 06 06 06 .byte $06,$06,$06,$06,$06,$06,$07,$07,$07,$07,$07,$07,$07,$07,$07,$07 00D110 3 06 06 07 07 00D114 3 07 07 07 07 00D11C 3 07 07 07 07 .byte $07,$07,$07,$07,$07,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08 00D120 3 07 08 08 08 00D124 3 08 08 08 08 00D12C 3 08 08 08 08 .byte $08,$08,$08,$08,$09,$09,$09,$09,$09,$09,$09,$09,$09,$09,$09,$09 00D130 3 09 09 09 09 00D134 3 09 09 09 09 00D13C 3 09 09 09 09 .byte $09,$09,$09,$09,$09,$09,$09,$09,$09,$09,$09,$09,$00,$00,$00,$00 00D140 3 09 09 09 09 00D144 3 09 09 09 09 00D14C 3 BatF: 00D14C 3 30 20 10 00 .byte $30,$20,$10,$00,$F0,$E0,$D0,$C0,$B0,$A0,$90,$80,$70,$60,$50,$40 00D150 3 F0 E0 D0 C0 00D154 3 B0 A0 90 80 00D15C 3 30 20 10 00 .byte $30,$20,$10,$00,$F0,$E0,$D0,$C0,$B0,$A0,$90,$70,$60,$50,$40,$30 00D160 3 F0 E0 D0 C0 00D164 3 B0 A0 90 70 00D16C 3 20 10 00 F0 .byte $20,$10,$00,$F0,$E0,$D0,$C0,$B0,$A0,$90,$70,$60,$50,$40,$30,$20 00D170 3 E0 D0 C0 B0 00D174 3 A0 90 70 60 00D17C 3 10 00 F0 E0 .byte $10,$00,$F0,$E0,$D0,$C0,$B0,$A0,$90,$70,$60,$50,$40,$30,$20,$10 00D180 3 D0 C0 B0 A0 00D184 3 90 70 60 50 00D18C 3 00 F0 E0 D0 .byte $00,$F0,$E0,$D0,$C0,$B0,$A0,$90,$70,$60,$50,$40,$30,$20,$10,$00 00D190 3 C0 B0 A0 90 00D194 3 70 60 50 40 00D19C 3 F0 E0 D0 C0 .byte $F0,$E0,$D0,$C0,$B0,$A0,$90,$70,$60,$50,$40,$30,$20,$10,$00,$F0 00D1A0 3 B0 A0 90 70 00D1A4 3 60 50 40 30 00D1AC 3 E0 D0 C0 B0 .byte $E0,$D0,$C0,$B0,$A0,$90,$70,$60,$50,$40,$30,$20,$10,$00,$F0,$E0 00D1B0 3 A0 90 70 60 00D1B4 3 50 40 30 20 00D1BC 3 D0 C0 B0 A0 .byte $D0,$C0,$B0,$A0,$90,$70,$60,$50,$40,$30,$20,$10,$00,$F0,$E0,$D0 00D1C0 3 90 70 60 50 00D1C4 3 40 30 20 10 00D1CC 3 C0 B0 A0 90 .byte $C0,$B0,$A0,$90,$70,$60,$50,$40,$30,$20,$10,$00,$F0,$E0,$D0,$C0 00D1D0 3 70 60 50 40 00D1D4 3 30 20 10 00 00D1DC 3 B0 A0 90 80 .byte $B0,$A0,$90,$80,$00,$00,$00,$00,$00,$00,$00,$00,$70,$60,$50,$40 00D1E0 3 00 00 00 00 00D1E4 3 00 00 00 00 00D1EC 3 00D1EC 2 00D1EC 2 ; --------------------------------------------------------------------------- 00D1EC 2 Init: 00D1EC 2 78 sei 00D1ED 2 D8 cld 00D1EE 2 A2 00 ldx #0 00D1F0 2 8A txa 00D1F1 2 95 00 @clr: sta $00,x ; TIA registers and RAM 00D1F3 2 CA dex 00D1F4 2 D0 FB bne @clr 00D1F6 2 CA dex 00D1F7 2 9A txs 00D1F8 2 8D 81 02 sta SWACNT ; ports as inputs (A = 0) 00D1FB 2 8D 83 02 sta SWBCNT 00D1FE 2 A9 A7 lda #$A7 00D200 2 85 rr sta rngLo 00D202 2 A9 1D lda #$1D 00D204 2 85 rr sta rngHi 00D206 2 AD 82 02 lda SWCHB 00D209 2 85 rr sta swOld 00D20B 2 A9 01 lda #1 00D20D 2 85 rr sta kernelMode 00D20F 2 A9 00 lda #ST_TITLE 00D211 2 85 rr sta gameState 00D213 2 A9 18 lda #24 00D215 2 85 rr sta titleX 00D217 2 A9 C8 lda #200 00D219 2 85 rr sta ballY 00D21B 2 00D21B 2 MainLoop: 00D21B 2 ; VSYNC: three lines 00D21B 2 A9 02 lda #2 00D21D 2 85 01 sta VBLANK 00D21F 2 85 00 sta VSYNC 00D221 2 85 02 sta WSYNC 00D223 2 85 02 sta WSYNC 00D225 2 85 02 sta WSYNC 00D227 2 A9 00 lda #0 00D229 2 85 00 sta VSYNC 00D22B 2 .if VBDELAY > 0 00D22B 2 EA EA EA EA SLEEP VBDELAY 00D22F 2 EA EA EA EA 00D233 2 EA 00D234 2 .endif 00D234 2 A9 26 lda #VBTIM 00D236 2 8D 96 02 sta TIM64T 00D239 2 A9 82 lda #$82 00D23B 2 85 01 sta VBLANK 00D23D 2 20 82 D2 jsr VBlankLogic 00D240 2 2C 85 02 WaitVB: bit TIMINT ; D7: the timer has passed zero 00D243 2 10 FB bpl WaitVB 00D245 2 85 02 sta WSYNC 00D247 2 A5 rr lda kernelMode 00D249 2 D0 10 bne @title 00D24B 2 A5 rr lda floor 00D24D 2 D0 06 bne @top 00D24F 2 20 D2 DF jsr ToLow 00D252 2 4C 5E D2 jmp @os 00D255 2 20 C6 DF @top: jsr ToTop 00D258 2 4C 5E D2 jmp @os 00D25B 2 20 CC DF @title: jsr ToTitle 00D25E 2 @os: 00D25E 2 .if OSDELAY > 0 00D25E 2 EA EA EA SLEEP OSDELAY 00D261 2 .endif 00D261 2 A9 22 lda #OSTIM 00D263 2 8D 96 02 sta TIM64T 00D266 2 20 DE D4 jsr OverscanLogic 00D269 2 2C 85 02 WaitOS: bit TIMINT 00D26C 2 10 FB bpl WaitOS 00D26E 2 85 02 sta WSYNC 00D270 2 4C 1B D2 jmp MainLoop 00D273 2 00D273 2 ; --------------------------------------------------------------------------- 00D273 2 ; Random: 16-bit Galois LFSR (taps $B400). 00D273 2 Random: 00D273 2 46 rr lsr rngHi 00D275 2 66 rr ror rngLo 00D277 2 90 06 bcc @n 00D279 2 A5 rr lda rngHi 00D27B 2 49 B4 eor #$B4 00D27D 2 85 rr sta rngHi 00D27F 2 A5 rr @n: lda rngLo 00D281 2 60 rts 00D282 2 00D282 2 ; --------------------------------------------------------------------------- 00D282 2 VBlankLogic: 00D282 2 E6 rr inc frame 00D284 2 20 73 D2 jsr Random 00D287 2 ; console switches: t0 = switches pressed this frame (1 = newly pressed) 00D287 2 AD 82 02 lda SWCHB 00D28A 2 AA tax 00D28B 2 49 FF eor #$FF 00D28D 2 25 rr and swOld 00D28F 2 85 rr sta t0 00D291 2 86 rr stx swOld 00D293 2 ; paddle button (paddle 0 = SWCHA D7, 0 = pressed): t1 = $80 if newly pressed 00D293 2 AD 80 02 lda SWCHA 00D296 2 49 FF eor #$FF 00D298 2 29 80 and #$80 00D29A 2 AA tax ; X = $80 while held 00D29B 2 A5 rr lda btnOld 00D29D 2 49 80 eor #$80 00D29F 2 85 rr sta t1 00D2A1 2 8A txa 00D2A2 2 25 rr and t1 00D2A4 2 85 rr sta t1 00D2A6 2 86 rr stx btnOld 00D2A8 2 00D2A8 2 ; Game Reset: start a game from anywhere 00D2A8 2 A5 rr lda t0 00D2AA 2 4A lsr 00D2AB 2 90 06 bcc @noreset 00D2AD 2 20 98 D3 jsr StartGame 00D2B0 2 4C E5 D2 jmp @states 00D2B3 2 @noreset: 00D2B3 2 ; Game Select: back to the title, then step the game number 00D2B3 2 A5 rr lda swOld 00D2B5 2 29 02 and #2 00D2B7 2 D0 2C bne @nosel 00D2B9 2 A5 rr lda gameState 00D2BB 2 F0 0F beq @selTitle 00D2BD 2 A9 00 lda #ST_TITLE ; leave the game for the title 00D2BF 2 85 rr sta gameState 00D2C1 2 A9 01 lda #1 00D2C3 2 85 rr sta kernelMode 00D2C5 2 A9 1E lda #30 00D2C7 2 85 rr sta stateTimer 00D2C9 2 4C E5 D2 jmp @states 00D2CC 2 @selTitle: 00D2CC 2 A5 rr lda t0 00D2CE 2 29 02 and #2 00D2D0 2 D0 04 bne @step ; pressed this frame 00D2D2 2 C6 rr dec stateTimer ; held: repeat every 30 frames 00D2D4 2 D0 0F bne @states 00D2D6 2 A9 1E @step: lda #30 00D2D8 2 85 rr sta stateTimer 00D2DA 2 E6 rr inc gameNum 00D2DC 2 A5 rr lda gameNum 00D2DE 2 29 03 and #3 00D2E0 2 85 rr sta gameNum 00D2E2 2 4C E5 D2 jmp @states 00D2E5 2 @nosel: 00D2E5 2 00D2E5 2 @states: 00D2E5 2 A5 rr lda gameState 00D2E7 2 C9 00 cmp #ST_TITLE 00D2E9 2 D0 19 bne @notTitle 00D2EB 2 ; title: the button starts a game (after a short pause after a game) 00D2EB 2 A5 rr lda stateTimer 00D2ED 2 F0 0B beq @tready 00D2EF 2 A5 rr lda swOld 00D2F1 2 29 02 and #2 00D2F3 2 F0 0C beq @tdone ; Select held: its repeat timer 00D2F5 2 C6 rr dec stateTimer 00D2F7 2 4C 01 D3 jmp @tdone 00D2FA 2 @tready: 00D2FA 2 A5 rr lda t1 00D2FC 2 F0 03 beq @tdone 00D2FE 2 20 98 D3 jsr StartGame 00D301 2 4C 2B D3 @tdone: jmp @prep 00D304 2 @notTitle: 00D304 2 C9 01 cmp #ST_SERVE 00D306 2 D0 0E bne @notServe 00D308 2 A5 rr lda t1 00D30A 2 D0 04 bne @launch 00D30C 2 C6 rr dec stateTimer 00D30E 2 D0 1B bne @prep 00D310 2 @launch: 00D310 2 20 51 D4 jsr Launch 00D313 2 4C 2B D3 jmp @prep 00D316 2 @notServe: 00D316 2 C9 02 cmp #ST_PLAY 00D318 2 D0 11 bne @prep 00D31A 2 A5 rr lda t1 00D31C 2 F0 0D beq @prep 00D31E 2 A5 rr lda kick 00D320 2 D0 09 bne @prep 00D322 2 A9 18 lda #KICKLEN 00D324 2 85 rr sta kick 00D326 2 A2 03 ldx #SFX_SWISH 00D328 2 20 33 DB jsr Sfx0 00D32B 2 @prep: 00D32B 2 20 34 D3 jsr PaddleToBat 00D32E 2 20 51 DB jsr Sound 00D331 2 4C C1 DC jmp Prep 00D334 2 00D334 2 KICKLEN = 24 ; kick timer on a press 00D334 2 KICKWIN = 14 ; a bat hit while kick >= KICKWIN is a kick 00D334 2 KICKSHOW = 16 ; the bat is drawn raised while kick >= KICKSHOW 00D334 2 00D334 2 ; --------------------------------------------------------------------------- 00D334 2 ; The paddle: padY is the line counter of the last line on which the capacitor 00D334 2 ; was still charging (line 59 on). L = PADINIT - padY lines; turning the knob 00D334 2 ; clockwise (less resistance) charges sooner and moves the bat right. 00D334 2 PaddleToBat: 00D334 2 A5 rr lda gameState 00D336 2 C9 01 cmp #ST_SERVE 00D338 2 F0 04 beq @go 00D33A 2 C9 02 cmp #ST_PLAY 00D33C 2 D0 59 bne @done 00D33E 2 @go: ; bat width from this player's difficulty switch (A = narrow, a set bit). 00D33E 2 ; SWCHB D6 is the left switch (P0), D7 the right (P1): DOC, Stella 00D33E 2 ; Programmer's Guide, "Console Switches"; a2600-python docs/start-here.md. 00D33E 2 ; (Fixed 2026-11-21: player 1 had read D7, the right switch.) 00D33E 2 A5 rr lda swOld 00D340 2 A6 rr ldx curPlayer 00D342 2 D0 01 bne @p1 00D344 2 0A asl ; player 1: D6 after two shifts 00D345 2 0A @p1: asl ; player 2: D7 after one 00D346 2 A9 18 lda #24 00D348 2 90 02 bcc @w 00D34A 2 A9 10 lda #16 00D34C 2 85 rr @w: sta batW 00D34E 2 ; target x = (144 - batW) - clamp(L - PADOFF, 0, 128 - batW) 00D34E 2 A9 70 lda #PADINIT 00D350 2 38 sec 00D351 2 E5 rr sbc padY ; L 00D353 2 38 sec 00D354 2 E9 02 sbc #PADOFF 00D356 2 B0 02 bcs @pos 00D358 2 A9 00 lda #0 00D35A 2 85 rr @pos: sta t0 00D35C 2 A9 80 lda #128 00D35E 2 38 sec 00D35F 2 E5 rr sbc batW 00D361 2 C5 rr cmp t0 00D363 2 B0 02 bcs @inr 00D365 2 85 rr sta t0 ; clamp 00D367 2 A9 90 @inr: lda #144 00D369 2 38 sec 00D36A 2 E5 rr sbc batW 00D36C 2 38 sec 00D36D 2 E5 rr sbc t0 ; target 00D36F 2 ; smoothing: steps of one clock are taken only on the second frame 00D36F 2 ; in a row (a real paddle's reading wanders by a line or so) 00D36F 2 85 rr sta t2 00D371 2 38 sec 00D372 2 E5 rr sbc batX 00D374 2 F0 0C beq @same 00D376 2 C9 01 cmp #1 00D378 2 F0 0D beq @small 00D37A 2 C9 FF cmp #$FF 00D37C 2 F0 09 beq @small 00D37E 2 A5 rr lda t2 00D380 2 85 rr sta batX 00D382 2 A9 00 @same: lda #0 00D384 2 85 rr sta t3 00D386 2 60 rts 00D387 2 E6 rr @small: inc t3 00D389 2 A5 rr lda t3 00D38B 2 C9 02 cmp #2 00D38D 2 90 08 bcc @done 00D38F 2 A5 rr lda t2 00D391 2 85 rr sta batX 00D393 2 A9 00 lda #0 00D395 2 85 rr sta t3 00D397 2 60 @done: rts 00D398 2 00D398 2 PADOFF = 2 00D398 2 00D398 2 ; --------------------------------------------------------------------------- 00D398 2 StartGame: 00D398 2 A5 rr lda gameNum 00D39A 2 29 01 and #1 00D39C 2 85 rr sta twoPlayer 00D39E 2 ; player block: score 0, 5 balls, level 0 (2 in games 3-4) 00D39E 2 A2 0F ldx #PBLK-1 00D3A0 2 A9 00 lda #0 00D3A2 2 95 rr @z: sta pStart,x 00D3A4 2 CA dex 00D3A5 2 10 FB bpl @z 00D3A7 2 A9 05 lda #5 00D3A9 2 85 rr sta balls 00D3AB 2 A5 rr lda gameNum 00D3AD 2 29 02 and #2 00D3AF 2 85 rr sta level 00D3B1 2 20 E1 D3 jsr FillBricks 00D3B4 2 20 04 D4 jsr ResetBalloons 00D3B7 2 A9 FF lda #$FF 00D3B9 2 85 rr sta drops 00D3BB 2 A2 0F ldx #PBLK-1 00D3BD 2 B5 rr @c: lda pStart,x 00D3BF 2 95 rr sta stash,x 00D3C1 2 CA dex 00D3C2 2 10 F9 bpl @c 00D3C4 2 A9 00 lda #0 00D3C6 2 85 rr sta curPlayer 00D3C8 2 85 rr sta kernelMode 00D3CA 2 85 rr sta msgT 00D3CC 2 A9 40 lda #64 00D3CE 2 85 rr sta clownX 00D3D0 2 A9 01 lda #1 00D3D2 2 85 rr sta clownDir 00D3D4 2 20 1D D4 jsr ServeBall 00D3D7 2 A2 11 ldx #SFX_START 00D3D9 2 20 42 DB jsr Sfx1 00D3DC 2 A9 00 lda #MSG_P1 00D3DE 2 4C D7 D4 jmp ShowMsg 00D3E1 2 00D3E1 2 ; bricks: rows filled = min(4 + level, 6), from the bottom row (5) up 00D3E1 2 FillBricks: 00D3E1 2 A5 rr lda level 00D3E3 2 18 clc 00D3E4 2 69 04 adc #4 00D3E6 2 C9 06 cmp #6 00D3E8 2 90 02 bcc @ok 00D3EA 2 A9 06 lda #6 00D3EC 2 85 rr @ok: sta t0 00D3EE 2 A2 05 ldx #5 00D3F0 2 A9 FF @f: lda #$FF 00D3F2 2 A4 rr ldy t0 00D3F4 2 D0 02 bne @set 00D3F6 2 A9 00 lda #0 00D3F8 2 95 rr @set: sta bricks,x 00D3FA 2 A5 rr lda t0 00D3FC 2 F0 02 beq @nx 00D3FE 2 C6 rr dec t0 00D400 2 CA @nx: dex 00D401 2 10 ED bpl @f 00D403 2 60 rts 00D404 2 00D404 2 ; ResetBalloons: three full rows at their starting places (a new game, Big Top). 00D404 2 ResetBalloons: 00D404 2 A9 3F lda #$3F 00D406 2 85 rr sta balloons 00D408 2 85 rr sta balloons+1 00D40A 2 85 rr sta balloons+2 00D40C 2 A9 10 lda #16 00D40E 2 85 rr sta rowX 00D410 2 A9 28 lda #40 00D412 2 85 rr sta rowX+1 00D414 2 A9 38 lda #56 00D416 2 85 rr sta rowX+2 00D418 2 A9 00 lda #0 00D41A 2 85 rr sta balT 00D41C 2 60 rts 00D41D 2 00D41D 2 ServeBall: 00D41D 2 ; A row still sliding in (rowX >= ENTRY_MIN) may hold only the balloons 00D41D 2 ; already past the right wall; after a turn change the balloons belong to 00D41D 2 ; the other player, so such a row is put at the right end of its normal 00D41D 2 ; range, where any mask is drawable. 00D41D 2 A2 02 ldx #2 00D41F 2 B5 rr @cl: lda rowX,x 00D421 2 C9 3A cmp #ENTRY_MIN 00D423 2 90 04 bcc @ok 00D425 2 A9 39 lda #ENTRY_MIN-1 00D427 2 95 rr sta rowX,x 00D429 2 CA @ok: dex 00D42A 2 10 F3 bpl @cl 00D42C 2 A9 00 lda #0 00D42E 2 85 rr sta multK ; a new ball: multiplier 1x 00D430 2 85 rr sta dropT ; (MoveDrops restarts a wait if the targets are down) 00D432 2 A9 01 lda #ST_SERVE 00D434 2 85 rr sta gameState 00D436 2 A9 F0 lda #240 00D438 2 85 rr sta stateTimer ; launches by itself after 4 seconds 00D43A 2 A9 00 lda #0 00D43C 2 85 rr sta floor 00D43E 2 85 rr sta kick 00D440 2 85 rr sta cool 00D442 2 20 48 D4 jsr BaseSpeed 00D445 2 85 rr sta speed 00D447 2 60 rts 00D448 2 00D448 2 ; base speed = min(level, 4) 00D448 2 BaseSpeed: 00D448 2 A5 rr lda level 00D44A 2 C9 04 cmp #4 00D44C 2 90 02 bcc @r 00D44E 2 A9 04 lda #4 00D450 2 60 @r: rts 00D451 2 00D451 2 Launch: 00D451 2 A9 02 lda #ST_PLAY 00D453 2 85 rr sta gameState 00D455 2 20 73 D2 jsr Random 00D458 2 29 80 and #$80 ; left or right 00D45A 2 85 rr sta t1 00D45C 2 20 73 D2 jsr Random 00D45F 2 29 01 and #1 00D461 2 18 clc 00D462 2 69 01 adc #1 ; angle class 1 or 2 00D464 2 20 6C D4 jsr SetVelocity ; up 00D467 2 A2 01 ldx #SFX_BAT 00D469 2 4C 33 DB jmp Sfx0 00D46C 2 00D46C 2 ; SetVelocity: A = angle class (0 steep .. 3 shallow), speed in `speed`, 00D46C 2 ; t1 D7 = left, D6 = down. 00D46C 2 SetVelocity: 00D46C 2 85 rr sta t0 00D46E 2 A5 rr lda speed 00D470 2 0A asl 00D471 2 0A asl 00D472 2 18 clc 00D473 2 65 rr adc t0 00D475 2 AA tax 00D476 2 BD 00 D0 lda VXLO,x 00D479 2 85 rr sta vxL 00D47B 2 BD 20 D0 lda VXHI,x 00D47E 2 85 rr sta vxH 00D480 2 BD 40 D0 lda VYLO,x 00D483 2 85 rr sta vyL 00D485 2 BD 60 D0 lda VYHI,x 00D488 2 85 rr sta vyH 00D48A 2 24 rr bit t1 00D48C 2 10 03 bpl @right 00D48E 2 20 97 D4 jsr NegVX 00D491 2 70 03 @right: bvs @down 00D493 2 20 A5 D4 jsr NegVY 00D496 2 60 @down: rts 00D497 2 00D497 2 38 NegVX: sec 00D498 2 A9 00 lda #0 00D49A 2 E5 rr sbc vxL 00D49C 2 85 rr sta vxL 00D49E 2 A9 00 lda #0 00D4A0 2 E5 rr sbc vxH 00D4A2 2 85 rr sta vxH 00D4A4 2 60 rts 00D4A5 2 00D4A5 2 38 NegVY: sec 00D4A6 2 A9 00 lda #0 00D4A8 2 E5 rr sbc vyL 00D4AA 2 85 rr sta vyL 00D4AC 2 A9 00 lda #0 00D4AE 2 E5 rr sbc vyH 00D4B0 2 85 rr sta vyH 00D4B2 2 60 rts 00D4B3 2 00D4B3 2 ; --------------------------------------------------------------------------- 00D4B3 2 ; Messages (six glyph offsets each), shown in the HUD instead of the score. 00D4B3 2 Messages: 00D4B3 2 MSG_P1 = * - Messages 00D4B3 2 B0 90 E8 B8 .byte CH_P, CH_L, CH_Y, CH_R, CH_SP, CH_1 00D4B7 2 50 08 00D4B9 2 MSG_P2 = * - Messages 00D4B9 2 B0 90 E8 B8 .byte CH_P, CH_L, CH_Y, CH_R, CH_SP, CH_2 00D4BD 2 50 10 00D4BF 2 MSG_CLEAR = * - Messages 00D4BF 2 68 90 70 58 .byte CH_C, CH_L, CH_E, CH_A, CH_R, CH_BANG 00D4C3 2 B8 F0 00D4C5 2 MSG_BIGTOP = * - Messages 00D4C5 2 60 80 78 C8 .byte CH_B, CH_I, CH_G, CH_T, CH_O, CH_P 00D4C9 2 A8 B0 00D4CB 2 MSG_OVER = * - Messages 00D4CB 2 50 A8 D8 70 .byte CH_SP, CH_O, CH_V, CH_E, CH_R, CH_SP 00D4CF 2 B8 50 00D4D1 2 MSG_XBALL = * - Messages 00D4D1 2 E0 60 58 90 .byte CH_X, CH_B, CH_A, CH_L, CH_L, CH_BANG 00D4D5 2 90 F0 00D4D7 2 00D4D7 2 ShowMsg: 00D4D7 2 85 rr sta msgIdx 00D4D9 2 A9 64 lda #100 00D4DB 2 85 rr sta msgT 00D4DD 2 60 rts 00D4DE 2 00D4DE 2 ; --------------------------------------------------------------------------- 00D4DE 2 OverscanLogic: 00D4DE 2 A5 rr lda kick 00D4E0 2 F0 02 beq @k 00D4E2 2 C6 rr dec kick 00D4E4 2 A5 rr @k: lda flash 00D4E6 2 F0 02 beq @f 00D4E8 2 C6 rr dec flash 00D4EA 2 A5 rr @f: lda msgT 00D4EC 2 F0 02 beq @m 00D4EE 2 C6 rr dec msgT 00D4F0 2 A5 rr @m: lda cool 00D4F2 2 F0 02 beq @c 00D4F4 2 C6 rr dec cool 00D4F6 2 @c: 00D4F6 2 A5 rr lda gameState 00D4F8 2 C9 00 cmp #ST_TITLE 00D4FA 2 D0 24 bne @nt 00D4FC 2 ; title: balloons slide. clownDir is theirs here: MoveClown must not 00D4FC 2 ; run on the title, or the two would flip it against each other and 00D4FC 2 ; push titleX out of range (FOUND by scripts/check.sh: after a game 00D4FC 2 ; over, titleX ran away and title frames grew to 263-264 lines). 00D4FC 2 A5 rr lda frame 00D4FE 2 29 01 and #1 00D500 2 D0 1D bne @tx 00D502 2 A5 rr lda clownDir ; reuse the clown's direction bit for the title row 00D504 2 30 0D bmi @tl 00D506 2 E6 rr inc titleX 00D508 2 A5 rr lda titleX 00D50A 2 C9 38 cmp #56 00D50C 2 90 11 bcc @tx 00D50E 2 A9 FF lda #$FF 00D510 2 85 rr sta clownDir 00D512 2 60 rts 00D513 2 C6 rr @tl: dec titleX 00D515 2 A5 rr lda titleX 00D517 2 C9 11 cmp #17 00D519 2 B0 04 bcs @tx 00D51B 2 A9 01 lda #1 00D51D 2 85 rr sta clownDir 00D51F 2 60 @tx: rts 00D520 2 20 66 D5 @nt: jsr MoveClown 00D523 2 20 9F D5 jsr MoveBalloons 00D526 2 20 71 D6 jsr MoveDrops 00D529 2 A5 rr lda gameState 00D52B 2 C9 01 cmp #ST_SERVE 00D52D 2 D0 10 bne @ns 00D52F 2 ; the ball rides on the bat 00D52F 2 A5 rr lda batW 00D531 2 4A lsr 00D532 2 18 clc 00D533 2 65 rr adc batX 00D535 2 38 sec 00D536 2 E9 01 sbc #1 00D538 2 85 rr sta ballX 00D53A 2 A9 9C lda #BATTOP-BH 00D53C 2 85 rr sta ballY 00D53E 2 60 rts 00D53F 2 C9 02 @ns: cmp #ST_PLAY 00D541 2 D0 03 bne @np 00D543 2 4C C6 D6 jmp Physics 00D546 2 C9 03 @np: cmp #ST_LOST 00D548 2 D0 07 bne @nl 00D54A 2 C6 rr dec stateTimer 00D54C 2 D0 17 bne @r 00D54E 2 4C E8 DA jmp NextTurn 00D551 2 C9 04 @nl: cmp #ST_OVER 00D553 2 D0 10 bne @r 00D555 2 C6 rr dec stateTimer 00D557 2 D0 0C bne @r 00D559 2 A9 00 lda #ST_TITLE 00D55B 2 85 rr sta gameState 00D55D 2 A9 01 lda #1 00D55F 2 85 rr sta kernelMode 00D561 2 A9 3C lda #60 00D563 2 85 rr sta stateTimer 00D565 2 60 @r: rts 00D566 2 00D566 2 MoveClown: 00D566 2 A5 rr lda clownHit 00D568 2 F0 03 beq @walk 00D56A 2 C6 rr dec clownHit 00D56C 2 60 rts 00D56D 2 @walk: ; level 0 steps every other frame; later levels every frame; a cleared 00D56D 2 ; middle floor adds a step every fourth frame 00D56D 2 A5 rr lda level 00D56F 2 D0 06 bne @step 00D571 2 A5 rr lda frame 00D573 2 29 01 and #1 00D575 2 D0 03 bne @extra 00D577 2 20 86 D5 @step: jsr @one 00D57A 2 A5 rr @extra: lda cleared 00D57C 2 29 02 and #2 00D57E 2 F0 1E beq @r 00D580 2 A5 rr lda frame 00D582 2 29 03 and #3 00D584 2 D0 18 bne @r 00D586 2 A5 rr @one: lda clownX 00D588 2 18 clc 00D589 2 65 rr adc clownDir 00D58B 2 85 rr sta clownX 00D58D 2 C9 70 cmp #112 00D58F 2 90 05 bcc @lo 00D591 2 A9 FF lda #$FF 00D593 2 85 rr sta clownDir 00D595 2 60 rts 00D596 2 C9 21 @lo: cmp #33 00D598 2 B0 04 bcs @r 00D59A 2 A9 01 lda #1 00D59C 2 85 rr sta clownDir 00D59E 2 60 @r: rts 00D59F 2 00D59F 2 ; Balloon rows slide between x = 16 and 57 (the row spans 88 clocks). 00D59F 2 ; Row r moves every BalPeriod frames; rows 0 and 2 start rightwards. 00D59F 2 ; 00D59F 2 ; Refill (2026-11-21, Aubrey's playtest: the top floor went empty and the game 00D59F 2 ; stalled there): once every row is popped (the top floor's net opens and the 00D59F 2 ; ball falls), the top row waits BalDelay frames, then a full row drifts in from 00D59F 2 ; behind the right wall. (Refilling each row as soon as it emptied was tried 00D59F 2 ; first: the floor never emptied, the bot's ball spent 56-71% of its time there 00D59F 2 ; and no Big Top came in six 20-minute runs.) While it enters, rowX runs 00D59F 2 ; down from ENTRY_X to ENTRY_MIN-1, one clock every other frame, and balloon k is 00D59F 2 ; added as its left edge reaches x = 147 - 16k (RevealX), so every balloon in the 00D59F 2 ; mask sits at x <= 147 and its copy's positioning value stays inside BalC/BalF 00D59F 2 ; (x <= 149, gen_tables.py). Behind the wall (x >= 144) the playfield hides it. 00D59F 2 ; The top row is refilled first; while one row is entering, the next empty row 00D59F 2 ; waits only BAL_STAGGER frames, so a whole set comes back row after row. One 00D59F 2 ; timer (balT) serves all rows. Values provisional, tuned with the bot. 00D59F 2 ENTRY_X = 148 00D59F 2 ENTRY_MIN = 58 ; rowX >= this: the row is still entering 00D59F 2 BAL_STAGGER = 40 00D59F 2 00D59F 2 MoveBalloons: 00D59F 2 ; refill only once the whole set is gone (the net opens and the ball 00D59F 2 ; drops first), or while a set is already coming back in 00D59F 2 A0 02 ldy #2 00D5A1 2 B9 rr rr @any: lda rowX,y 00D5A4 2 C9 3A cmp #ENTRY_MIN 00D5A6 2 B0 0B bcs @look ; a row is entering: carry on with the set 00D5A8 2 88 dey 00D5A9 2 10 F6 bpl @any 00D5AB 2 A5 rr lda balloons 00D5AD 2 05 rr ora balloons+1 00D5AF 2 05 rr ora balloons+2 00D5B1 2 D0 11 bne @idle ; balloons up and none entering: nothing to do 00D5B3 2 @look: ; find the first empty row at rest (top row first) 00D5B3 2 A2 00 ldx #0 00D5B5 2 B5 rr @find: lda balloons,x 00D5B7 2 D0 06 bne @nf 00D5B9 2 B5 rr lda rowX,x 00D5BB 2 C9 3A cmp #ENTRY_MIN 00D5BD 2 90 0B bcc @empty 00D5BF 2 E8 @nf: inx 00D5C0 2 E0 03 cpx #3 00D5C2 2 90 F1 bcc @find 00D5C4 2 A9 00 @idle: lda #0 00D5C6 2 85 rr sta balT ; nothing to refill 00D5C8 2 F0 39 beq @moverows 00D5CA 2 A5 rr @empty: lda balT 00D5CC 2 D0 20 bne @tick 00D5CE 2 ; start the wait: BAL_STAGGER while another row enters, else BalDelay 00D5CE 2 A0 02 ldy #2 00D5D0 2 B9 rr rr @ent: lda rowX,y 00D5D3 2 C9 3A cmp #ENTRY_MIN 00D5D5 2 B0 11 bcs @stag 00D5D7 2 88 dey 00D5D8 2 10 F6 bpl @ent 00D5DA 2 A5 rr lda level 00D5DC 2 C9 03 cmp #3 00D5DE 2 90 02 bcc @dl 00D5E0 2 A9 03 lda #3 00D5E2 2 A8 @dl: tay 00D5E3 2 B9 A4 D6 lda BalDelay,y 00D5E6 2 D0 02 bne @setT 00D5E8 2 A9 0A @stag: lda #BAL_STAGGER/4 00D5EA 2 85 rr @setT: sta balT 00D5EC 2 D0 15 bne @moverows 00D5EE 2 A5 rr @tick: lda frame ; balT counts in fours of frames 00D5F0 2 29 03 and #3 00D5F2 2 D0 0F bne @moverows 00D5F4 2 C6 rr dec balT 00D5F6 2 D0 0B bne @moverows 00D5F8 2 A9 94 lda #ENTRY_X ; X = the empty row: it starts in from the right 00D5FA 2 95 rr sta rowX,x 00D5FC 2 A5 rr lda rowDirs 00D5FE 2 1D BE D6 ora BitTab,x 00D601 2 85 rr sta rowDirs 00D603 2 @moverows: 00D603 2 A2 02 ldx #2 00D605 2 B5 rr @row: lda rowX,x 00D607 2 C9 3A cmp #ENTRY_MIN 00D609 2 90 20 bcc @normal 00D60B 2 ; entering: one clock left every other frame, balloons appearing 00D60B 2 A5 rr lda frame 00D60D 2 29 01 and #1 00D60F 2 D0 5C bne @next 00D611 2 D6 rr dec rowX,x 00D613 2 B5 rr lda rowX,x 00D615 2 A0 05 ldy #5 00D617 2 D9 A8 D6 @rv: cmp RevealX,y 00D61A 2 F0 05 beq @reveal 00D61C 2 88 dey 00D61D 2 10 F8 bpl @rv 00D61F 2 30 4C bmi @next 00D621 2 @reveal: 00D621 2 B9 E5 D9 lda BalBit,y 00D624 2 15 rr ora balloons,x 00D626 2 95 rr sta balloons,x 00D628 2 4C 6D D6 jmp @next 00D62B 2 @normal: 00D62B 2 A5 rr lda level 00D62D 2 C9 03 cmp #3 00D62F 2 90 02 bcc @lv 00D631 2 A9 03 lda #3 00D633 2 0A @lv: asl 00D634 2 0A asl 00D635 2 85 rr sta t0 ; level * 4 (capped) 00D637 2 8A txa 00D638 2 18 clc 00D639 2 65 rr adc t0 00D63B 2 A8 tay 00D63C 2 B9 AE D6 lda BalPeriod,y ; frames between steps (a power of two minus one) 00D63F 2 25 rr and frame 00D641 2 D0 2A bne @next 00D643 2 A5 rr lda rowDirs ; bit r set: row r moving left 00D645 2 3D BE D6 and BitTab,x 00D648 2 D0 12 bne @left 00D64A 2 F6 rr inc rowX,x 00D64C 2 B5 rr lda rowX,x 00D64E 2 C9 38 cmp #56 00D650 2 90 1B bcc @next 00D652 2 A5 rr lda rowDirs 00D654 2 1D BE D6 ora BitTab,x 00D657 2 85 rr sta rowDirs 00D659 2 4C 6D D6 jmp @next 00D65C 2 D6 rr @left: dec rowX,x 00D65E 2 B5 rr lda rowX,x 00D660 2 C9 11 cmp #17 00D662 2 B0 09 bcs @next 00D664 2 BD BE D6 lda BitTab,x 00D667 2 49 FF eor #$FF 00D669 2 25 rr and rowDirs 00D66B 2 85 rr sta rowDirs 00D66D 2 CA @next: dex 00D66E 2 10 95 bpl @row 00D670 2 60 rts 00D671 2 00D671 2 .ifndef BALDELAY ; (-D BALDELAY=n overrides level 0's, for tuning) 00D671 2 BALDELAY = 150 00D671 2 .endif 00D671 2 ; Drop targets come back (2026-11-22, Aubrey's second playtest; provisional): once 00D671 2 ; all eight are down, they wait as long as an emptied balloon set (BalDelay), then 00D671 2 ; return one column every 4 frames from the left. dropT counts the wait plus the 00D671 2 ; 8-step sweep in fours of frames; a clear counts only while dropT is 0 (HitMiddle). 00D671 2 MoveDrops: 00D671 2 A5 rr lda dropT 00D673 2 D0 16 bne @run 00D675 2 A5 rr lda drops 00D677 2 D0 11 bne @r ; targets up: nothing to do 00D679 2 A5 rr lda level 00D67B 2 C9 03 cmp #3 00D67D 2 90 02 bcc @lv 00D67F 2 A9 03 lda #3 00D681 2 A8 @lv: tay 00D682 2 B9 A4 D6 lda BalDelay,y 00D685 2 18 clc 00D686 2 69 08 adc #8 00D688 2 85 rr sta dropT 00D68A 2 60 @r: rts 00D68B 2 A5 rr @run: lda frame 00D68D 2 29 03 and #3 00D68F 2 D0 F9 bne @r 00D691 2 C6 rr dec dropT 00D693 2 A5 rr lda dropT 00D695 2 C9 08 cmp #8 00D697 2 B0 F1 bcs @r 00D699 2 49 07 eor #7 ; 7 - dropT: column 0 first 00D69B 2 AA tax 00D69C 2 BD BE D6 lda BitTab,x 00D69F 2 05 rr ora drops 00D6A1 2 85 rr sta drops 00D6A3 2 60 rts 00D6A4 2 00D6A4 2 BalDelay: ; fours of frames an emptied set waits before refilling, by level (capped at 3) 00D6A4 2 25 1E 19 14 .byte BALDELAY/4, BALDELAY/5, BALDELAY/6, BALDELAY*2/15 00D6A8 2 RevealX: ; rowX at which balloon k (0-5) appears while a row enters 00D6A8 2 93 83 73 63 .byte 147, 131, 115, 99, 83, 67 00D6AC 2 53 43 00D6AE 2 BalPeriod: ; [level*4 + row] (level capped at 3): and-masks for frame 00D6AE 2 03 07 03 00 .byte 3, 7, 3, 0, 1, 3, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0 00D6B2 2 01 03 01 00 00D6B6 2 01 01 01 00 00D6BE 2 01 02 04 08 BitTab: .byte 1, 2, 4, 8, 16, 32, 64, 128 00D6C2 2 10 20 40 80 00D6C6 2 00D6C6 2 .include "physics.s" 00D6C6 3 ; SPDX-License-Identifier: MIT 00D6C6 3 ; Bank 0 (continued): ball physics, collisions, scoring, turns, sound, and the 00D6C6 3 ; values the kernels read. 00D6C6 3 00D6C6 3 ; --------------------------------------------------------------------------- 00D6C6 3 Physics: 00D6C6 3 A5 rr lda ballY 00D6C8 3 85 rr sta t2 ; old y 00D6CA 3 ; x 00D6CA 3 18 clc 00D6CB 3 A5 rr lda ballXL 00D6CD 3 65 rr adc vxL 00D6CF 3 85 rr sta ballXL 00D6D1 3 A5 rr lda ballX 00D6D3 3 65 rr adc vxH 00D6D5 3 85 rr sta ballX 00D6D7 3 C9 C8 cmp #200 00D6D9 3 B0 12 bcs @left ; wrapped below 0 00D6DB 3 C9 10 cmp #XMIN 00D6DD 3 90 0E bcc @left 00D6DF 3 C9 8F cmp #XMAX+1 00D6E1 3 90 19 bcc @y 00D6E3 3 A9 1C lda #<(2*XMAX) ; mirror at the right wall 00D6E5 3 38 sec 00D6E6 3 E5 rr sbc ballX 00D6E8 3 85 rr sta ballX 00D6EA 3 4C F4 D6 jmp @wall 00D6ED 3 A9 20 @left: lda #2*XMIN 00D6EF 3 38 sec 00D6F0 3 E5 rr sbc ballX 00D6F2 3 85 rr sta ballX 00D6F4 3 20 97 D4 @wall: jsr NegVX 00D6F7 3 A2 00 ldx #SFX_WALL 00D6F9 3 20 33 DB jsr Sfx0 00D6FC 3 18 @y: clc 00D6FD 3 A5 rr lda ballYL 00D6FF 3 65 rr adc vyL 00D701 3 85 rr sta ballYL 00D703 3 A5 rr lda ballY 00D705 3 65 rr adc vyH 00D707 3 85 rr sta ballY 00D709 3 24 rr bit vyH 00D70B 3 10 03 bpl @down 00D70D 3 4C C1 D7 jmp @up 00D710 3 @down: ; moving down 00D710 3 C9 AA cmp #PLAYH 00D712 3 90 1C bcc @bat 00D714 3 A5 rr lda floor 00D716 3 D0 03 bne @dropFloor 00D718 3 4C D3 DA jmp BallLost 00D71B 3 @dropFloor: 00D71B 3 C6 rr dec floor 00D71D 3 A5 rr lda ballY 00D71F 3 38 sec 00D720 3 E9 AA sbc #PLAYH 00D722 3 85 rr sta ballY 00D724 3 A9 00 lda #0 00D726 3 85 rr sta cool 00D728 3 A2 0F ldx #SFX_DOWN 00D72A 3 20 42 DB jsr Sfx1 00D72D 3 4C F5 D7 jmp Collide 00D730 3 @bat: ; the top floor has no bat: the ball falls 00D730 3 20 3F DA jsr FloorOpen 00D733 3 D0 27 bne @nobat 00D735 3 ; the ball's bottom line crossed the bat's top this frame? 00D735 3 A5 rr lda t2 00D737 3 18 clc 00D738 3 69 03 adc #BH-1 00D73A 3 C9 A0 cmp #BATTOP 00D73C 3 B0 1E bcs @nobat 00D73E 3 A5 rr lda ballY 00D740 3 18 clc 00D741 3 69 03 adc #BH-1 00D743 3 C9 A0 cmp #BATTOP 00D745 3 90 15 bcc @nobat 00D747 3 A5 rr lda ballX 00D749 3 18 clc 00D74A 3 69 02 adc #2 00D74C 3 38 sec 00D74D 3 E5 rr sbc batX ; offset 0..batW+1 when touching 00D74F 3 90 0B bcc @nobat 00D751 3 A6 rr ldx batW 00D753 3 E8 inx 00D754 3 86 rr stx t0 00D756 3 C5 rr cmp t0 00D758 3 90 05 bcc @hit 00D75A 3 F0 03 beq @hit 00D75C 3 4C F5 D7 @nobat: jmp Collide 00D75F 3 AA @hit: tax 00D760 3 A5 rr lda batW 00D762 3 C9 10 cmp #16 00D764 3 F0 06 beq @z16 00D766 3 BD 92 D0 lda Zone24,x 00D769 3 4C 6F D7 jmp @zone 00D76C 3 BD 80 D0 @z16: lda Zone16,x 00D76F 3 @zone: ; zone 0-3 left (class 3-zone), 4-7 right (class zone-4) 00D76F 3 A2 80 ldx #$80 00D771 3 C9 04 cmp #4 00D773 3 B0 05 bcs @r 00D775 3 49 03 eor #3 00D777 3 4C 7E D7 jmp @cls 00D77A 3 E9 04 @r: sbc #4 00D77C 3 A2 00 ldx #0 00D77E 3 85 rr @cls: sta t3 ; class 00D780 3 86 rr stx t1 ; direction (up) 00D782 3 A9 9C lda #BATTOP-BH 00D784 3 85 rr sta ballY 00D786 3 A5 rr lda kick 00D788 3 C9 0E cmp #KICKWIN 00D78A 3 90 1F bcc @plain 00D78C 3 ; a kick: faster and steeper 00D78C 3 A5 rr lda speed 00D78E 3 18 clc 00D78F 3 69 02 adc #2 00D791 3 C9 08 cmp #8 00D793 3 90 02 bcc @sp 00D795 3 A9 07 lda #7 00D797 3 85 rr @sp: sta speed 00D799 3 A5 rr lda t3 00D79B 3 F0 02 beq @k0 00D79D 3 C6 rr dec t3 00D79F 3 A9 00 @k0: lda #0 00D7A1 3 85 rr sta kick ; one kick per press 00D7A3 3 A2 02 ldx #SFX_KICK 00D7A5 3 20 33 DB jsr Sfx0 00D7A8 3 4C B9 D7 jmp @vel 00D7AB 3 20 48 D4 @plain: jsr BaseSpeed 00D7AE 3 C5 rr cmp speed 00D7B0 3 B0 02 bcs @nodecay 00D7B2 3 C6 rr dec speed 00D7B4 3 @nodecay: 00D7B4 3 A2 01 ldx #SFX_BAT 00D7B6 3 20 33 DB jsr Sfx0 00D7B9 3 A5 rr @vel: lda t3 00D7BB 3 20 6C D4 jsr SetVelocity 00D7BE 3 4C F5 D7 jmp Collide 00D7C1 3 A5 rr @up: lda floor 00D7C3 3 C9 02 cmp #2 00D7C5 3 D0 18 bne @notTop 00D7C7 3 A5 rr lda ballY 00D7C9 3 C9 0A cmp #CEIL 00D7CB 3 B0 0F bcs @cl 00D7CD 3 A9 14 lda #2*CEIL ; the roof 00D7CF 3 38 sec 00D7D0 3 E5 rr sbc ballY 00D7D2 3 85 rr sta ballY 00D7D4 3 20 A5 D4 jsr NegVY 00D7D7 3 A2 00 ldx #SFX_WALL 00D7D9 3 20 33 DB jsr Sfx0 00D7DC 3 4C F5 D7 @cl: jmp Collide 00D7DF 3 @notTop: 00D7DF 3 A5 rr lda ballY 00D7E1 3 C9 C8 cmp #200 00D7E3 3 90 10 bcc Collide 00D7E5 3 E6 rr inc floor ; up through the top: the floor above 00D7E7 3 18 clc 00D7E8 3 69 AA adc #PLAYH 00D7EA 3 85 rr sta ballY 00D7EC 3 A9 00 lda #0 00D7EE 3 85 rr sta cool 00D7F0 3 A2 0E ldx #SFX_UP 00D7F2 3 20 42 DB jsr Sfx1 00D7F5 3 ; fall through 00D7F5 3 Collide: 00D7F5 3 ; leading line: top line moving up, bottom line moving down 00D7F5 3 A5 rr lda ballY 00D7F7 3 24 rr bit vyH 00D7F9 3 30 03 bmi @u 00D7FB 3 18 clc 00D7FC 3 69 03 adc #BH-1 00D7FE 3 85 rr @u: sta t2 ; leading line 00D800 3 A5 rr lda ballX 00D802 3 18 clc 00D803 3 69 01 adc #1 00D805 3 85 rr sta t3 ; centre column 00D807 3 A5 rr lda floor 00D809 3 F0 0A beq HitBricks 00D80B 3 C9 01 cmp #1 00D80D 3 D0 03 bne @t 00D80F 3 4C 72 D8 jmp HitMiddle 00D812 3 4C 7D D9 @t: jmp HitBalloons 00D815 3 00D815 3 ; --- bottom floor: rows on lines 11+8r .. 16+8r --- 00D815 3 HitBricks: 00D815 3 A5 rr lda cool ; set only by the Big Top refill on this floor 00D817 3 D0 4C bne @none 00D819 3 A5 rr lda t2 00D81B 3 38 sec 00D81C 3 E9 09 sbc #9 00D81E 3 C9 30 cmp #48 00D820 3 B0 43 bcs @none 00D822 3 AA tax 00D823 3 29 07 and #7 00D825 3 C9 02 cmp #2 00D827 3 90 3C bcc @none ; gap lines 00D829 3 8A txa 00D82A 3 4A lsr 00D82B 3 4A lsr 00D82C 3 4A lsr 00D82D 3 A8 tay ; row 00D82E 3 A5 rr lda t3 00D830 3 38 sec 00D831 3 E9 10 sbc #16 00D833 3 4A lsr 00D834 3 4A lsr 00D835 3 4A lsr 00D836 3 4A lsr 00D837 3 AA tax ; column 00D838 3 BD BE D6 lda BitTab,x 00D83B 3 39 rr rr and bricks,y 00D83E 3 F0 25 beq @none 00D840 3 59 rr rr eor bricks,y 00D843 3 99 rr rr sta bricks,y 00D846 3 20 A5 D4 jsr NegVY 00D849 3 B9 66 D8 lda RowPoints,y 00D84C 3 A2 00 ldx #0 00D84E 3 20 AC DA jsr AddScore 00D851 3 BE 6C D8 ldx SfxBrick,y 00D854 3 20 33 DB jsr Sfx0 00D857 3 A2 05 ldx #5 00D859 3 B5 rr @all: lda bricks,x 00D85B 3 D0 08 bne @none 00D85D 3 CA dex 00D85E 3 10 F9 bpl @all 00D860 3 A9 00 lda #0 00D862 3 4C 44 DA jmp FloorCleared 00D865 3 60 @none: rts 00D866 3 00D866 3 60 50 40 30 RowPoints: .byte $60, $50, $40, $30, $20, $10 00D86A 3 20 10 00D86C 3 04 05 06 07 SfxBrick: .byte SFX_BRICK0, SFX_BRICK0+1, SFX_BRICK0+2, SFX_BRICK0+3, SFX_BRICK0+4, SFX_BRICK0+5 00D870 3 08 09 00D872 3 00D872 3 ; --- middle floor --- 00D872 3 HitMiddle: 00D872 3 ; drop targets: brick lines 45-48 00D872 3 A5 rr lda t2 00D874 3 C9 2D cmp #45 00D876 3 90 35 bcc @nodrop 00D878 3 C9 31 cmp #49 00D87A 3 B0 31 bcs @nodrop 00D87C 3 A5 rr lda t3 00D87E 3 38 sec 00D87F 3 E9 10 sbc #16 00D881 3 4A lsr 00D882 3 4A lsr 00D883 3 4A lsr 00D884 3 4A lsr 00D885 3 AA tax 00D886 3 BD BE D6 lda BitTab,x 00D889 3 25 rr and drops 00D88B 3 F0 20 beq @nodrop 00D88D 3 45 rr eor drops 00D88F 3 85 rr sta drops 00D891 3 20 A5 D4 jsr NegVY 00D894 3 A9 00 lda #0 00D896 3 A2 01 ldx #$01 ; 100 00D898 3 20 AC DA jsr AddScore 00D89B 3 A2 0D ldx #SFX_DROP 00D89D 3 20 33 DB jsr Sfx0 00D8A0 3 A5 rr lda drops 00D8A2 3 D0 7B bne @r 00D8A4 3 A5 rr lda dropT ; still coming back (MoveDrops): not a clear 00D8A6 3 D0 77 bne @r 00D8A8 3 A9 01 lda #1 00D8AA 3 4C 44 DA jmp FloorCleared 00D8AD 3 @nodrop: 00D8AD 3 A5 rr lda cool 00D8AF 3 D0 6E bne @r 00D8B1 3 ; the clown: lines 2-17, x clownX .. clownX+15. Hit from below only 00D8B1 3 ; (2026-11-21, Aubrey's playtest): a ball falling in from the top floor 00D8B1 3 ; enters right where the clown walks, and bouncing it straight back up 00D8B1 3 ; was too fast to follow; now it passes in front of the clown. A ball 00D8B1 3 ; moving down on lines 2-17 can only have come from above (the middle 00D8B1 3 ; floor has no roof) or off the clown itself (then `cool` is set). 00D8B1 3 A5 rr lda clownHit 00D8B3 3 D0 2E bne @noclown 00D8B5 3 24 rr bit vyH 00D8B7 3 10 2A bpl @noclown 00D8B9 3 A5 rr lda t2 00D8BB 3 C9 02 cmp #2 00D8BD 3 90 24 bcc @noclown 00D8BF 3 C9 12 cmp #18 00D8C1 3 B0 20 bcs @noclown 00D8C3 3 A5 rr lda t3 00D8C5 3 38 sec 00D8C6 3 E5 rr sbc clownX 00D8C8 3 C9 10 cmp #16 00D8CA 3 B0 17 bcs @noclown 00D8CC 3 20 A5 D4 jsr NegVY 00D8CF 3 A9 3C lda #60 00D8D1 3 85 rr sta clownHit 00D8D3 3 A9 0A lda #10 00D8D5 3 85 rr sta cool 00D8D7 3 A9 00 lda #0 00D8D9 3 A2 05 ldx #$05 ; 500 00D8DB 3 20 AC DA jsr AddScore 00D8DE 3 A2 0C ldx #SFX_CLOWN 00D8E0 3 4C 33 DB jmp Sfx0 00D8E3 3 @noclown: 00D8E3 3 ; bumpers: row A centred on line 28 (x 48, 80, 112), row B on 94 (48, 112) 00D8E3 3 A5 rr lda ballY 00D8E5 3 18 clc 00D8E6 3 69 02 adc #2 00D8E8 3 85 rr sta t2 ; ball centre line 00D8EA 3 38 sec 00D8EB 3 E9 1C sbc #28 00D8ED 3 20 6C D9 jsr Abs 00D8F0 3 C9 07 cmp #7 00D8F2 3 B0 09 bcs @rowB 00D8F4 3 A9 1C lda #28 00D8F6 3 85 rr sta t0 00D8F8 3 A2 02 ldx #2 00D8FA 3 4C 20 D9 jmp @bx 00D8FD 3 A5 rr @rowB: lda t2 00D8FF 3 38 sec 00D900 3 E9 5E sbc #94 00D902 3 20 6C D9 jsr Abs 00D905 3 C9 07 cmp #7 00D907 3 B0 16 bcs @r 00D909 3 A9 5E lda #94 00D90B 3 85 rr sta t0 00D90D 3 A2 01 ldx #1 ; B: entries 0 and 1 of BumpXB 00D90F 3 A5 rr @bxB: lda t3 00D911 3 38 sec 00D912 3 FD 6A D9 sbc BumpXB,x 00D915 3 20 74 D9 jsr AbsS 00D918 3 C9 06 cmp #6 00D91A 3 90 15 bcc @bump 00D91C 3 CA dex 00D91D 3 10 F0 bpl @bxB 00D91F 3 60 @r: rts 00D920 3 A5 rr @bx: lda t3 00D922 3 38 sec 00D923 3 FD 67 D9 sbc BumpXA,x 00D926 3 20 74 D9 jsr AbsS 00D929 3 C9 06 cmp #6 00D92B 3 90 04 bcc @bump 00D92D 3 CA dex 00D92E 3 10 F0 bpl @bx 00D930 3 60 rts 00D931 3 @bump: ; A = |dx| (0-5), t1 D7 = left of the bumper (from AbsS) 00D931 3 4A lsr 00D932 3 C9 03 cmp #3 00D934 3 90 02 bcc @cl 00D936 3 A9 03 lda #3 00D938 3 85 rr @cl: sta t3 ; class from |dx| 00D93A 3 A5 rr lda t2 00D93C 3 C5 rr cmp t0 00D93E 3 90 06 bcc @upw ; above the centre: bounce up 00D940 3 A5 rr lda t1 00D942 3 09 40 ora #$40 00D944 3 85 rr sta t1 00D946 3 A5 rr @upw: lda speed ; a speed step, up to BUMP_MAX: only kicks make a 00D948 3 C9 03 cmp #BUMP_MAX ; ball strong enough to punch (2026-11-23; it was 7, 00D94A 3 B0 02 bcs @fast ; and the bot's ball sat at the cap) 00D94C 3 E6 rr inc speed 00D94E 3 A9 0A @fast: lda #10 00D950 3 85 rr sta cool 00D952 3 A9 08 lda #8 00D954 3 85 rr sta flash 00D956 3 A5 rr lda t3 00D958 3 20 6C D4 jsr SetVelocity 00D95B 3 A9 20 lda #$20 00D95D 3 A2 00 ldx #0 00D95F 3 20 AC DA jsr AddScore 00D962 3 A2 0B ldx #SFX_BUMP 00D964 3 4C 33 DB jmp Sfx0 00D967 3 00D967 3 30 50 70 BumpXA: .byte 48, 80, 112 00D96A 3 30 70 BumpXB: .byte 48, 112 00D96C 3 00D96C 3 ; Abs: |A| of a signed byte. AbsS: the same, and t1 D7 = sign (1 = negative). 00D96C 3 10 05 Abs: bpl @p 00D96E 3 49 FF eor #$FF 00D970 3 18 clc 00D971 3 69 01 adc #1 00D973 3 60 @p: rts 00D974 3 48 AbsS: pha 00D975 3 29 80 and #$80 00D977 3 85 rr sta t1 00D979 3 68 pla 00D97A 3 4C 6C D9 jmp Abs 00D97D 3 00D97D 3 ; --- top floor: rows' balloon bodies on lines 14+19r .. 25+19r --- 00D97D 3 HitBalloons: 00D97D 3 A5 rr lda cool ; set only by the Big Top refill on this floor 00D97F 3 D0 17 bne @none 00D981 3 A5 rr lda t2 00D983 3 38 sec 00D984 3 E9 0E sbc #14 00D986 3 90 10 bcc @none 00D988 3 A0 00 ldy #0 00D98A 3 C9 0C @rw: cmp #12 00D98C 3 90 0B bcc @inrow 00D98E 3 38 sec 00D98F 3 E9 13 sbc #19 00D991 3 90 05 bcc @none 00D993 3 C8 iny 00D994 3 C0 03 cpy #3 00D996 3 90 F2 bcc @rw 00D998 3 60 @none: rts 00D999 3 A5 rr @inrow: lda t3 00D99B 3 38 sec 00D99C 3 F9 rr rr sbc rowX,y 00D99F 3 90 F7 bcc @none 00D9A1 3 C9 60 cmp #96 00D9A3 3 B0 F3 bcs @none 00D9A5 3 AA tax 00D9A6 3 29 0F and #15 00D9A8 3 C9 09 cmp #9 00D9AA 3 B0 EC bcs @none 00D9AC 3 8A txa 00D9AD 3 4A lsr 00D9AE 3 4A lsr 00D9AF 3 4A lsr 00D9B0 3 4A lsr 00D9B1 3 AA tax ; balloon 0-5 00D9B2 3 BD E5 D9 lda BalBit,x 00D9B5 3 39 rr rr and balloons,y 00D9B8 3 F0 DE beq @none 00D9BA 3 59 rr rr eor balloons,y ; pop 00D9BD 3 99 rr rr sta balloons,y 00D9C0 3 ; Speed as power (2026-11-23, Aubrey's idea; provisional): from PUNCH_SPEED 00D9C0 3 ; up the ball punches through instead of bouncing, so it can pop several in 00D9C0 3 ; a line; every pop spends one speed step (not below the level's base), so 00D9C0 3 ; a fast ball burns itself down. The speed cap (7, the velocity table's 00D9C0 3 ; last step) stays. 00D9C0 3 A5 rr lda speed 00D9C2 3 C9 05 cmp #PUNCH_SPEED 00D9C4 3 B0 03 bcs @punch 00D9C6 3 20 A5 D4 jsr NegVY ; a plain pop bounces 00D9C9 3 20 EB D9 @punch: jsr SpeedDown 00D9CC 3 A9 50 lda #$50 00D9CE 3 A2 00 ldx #0 00D9D0 3 20 AC DA jsr AddScore 00D9D3 3 A2 0A ldx #SFX_POP 00D9D5 3 20 33 DB jsr Sfx0 00D9D8 3 A5 rr lda balloons 00D9DA 3 05 rr ora balloons+1 00D9DC 3 05 rr ora balloons+2 00D9DE 3 D0 B8 bne @none 00D9E0 3 A9 02 lda #2 00D9E2 3 4C 44 DA jmp FloorCleared 00D9E5 3 00D9E5 3 01 08 02 10 BalBit: .byte 1, 8, 2, 16, 4, 32 00D9E9 3 04 20 00D9EB 3 ; SpeedDown: one speed step less, not below the level's base speed, keeping the 00D9EB 3 ; ball's direction and angle class. Every velocity comes from the table (walls only 00D9EB 3 ; change signs), so |vx| matches exactly one class at the current speed. Uses t1, 00D9EB 3 ; tmp, row; changes X and Y. 00D9EB 3 SpeedDown: 00D9EB 3 20 48 D4 jsr BaseSpeed 00D9EE 3 C5 rr cmp speed 00D9F0 3 B0 4C bcs @r ; at the base already 00D9F2 3 A9 00 lda #0 00D9F4 3 85 rr sta t1 00D9F6 3 A5 rr lda vxL ; |vx| into tmp (low), row (high); t1 D7 = left 00D9F8 3 85 rr sta tmp 00D9FA 3 A5 rr lda vxH 00D9FC 3 85 rr sta row 00D9FE 3 10 11 bpl @px 00DA00 3 A9 80 lda #$80 00DA02 3 85 rr sta t1 00DA04 3 38 sec 00DA05 3 A9 00 lda #0 00DA07 3 E5 rr sbc tmp 00DA09 3 85 rr sta tmp 00DA0B 3 A9 00 lda #0 00DA0D 3 E5 rr sbc row 00DA0F 3 85 rr sta row 00DA11 3 24 rr @px: bit vyH ; t1 D6 = down 00DA13 3 30 06 bmi @cls 00DA15 3 A5 rr lda t1 00DA17 3 09 40 ora #$40 00DA19 3 85 rr sta t1 00DA1B 3 A5 rr @cls: lda speed 00DA1D 3 0A asl 00DA1E 3 0A asl 00DA1F 3 AA tax ; speed * 4: this speed's four classes 00DA20 3 A0 00 ldy #0 00DA22 3 BD 00 D0 @c: lda VXLO,x 00DA25 3 C5 rr cmp tmp 00DA27 3 D0 07 bne @n 00DA29 3 BD 20 D0 lda VXHI,x 00DA2C 3 C5 rr cmp row 00DA2E 3 F0 08 beq @f 00DA30 3 E8 @n: inx 00DA31 3 C8 iny 00DA32 3 C0 04 cpy #4 00DA34 3 90 EC bcc @c 00DA36 3 A0 01 ldy #1 ; (no match: cannot happen; class 1) 00DA38 3 C6 rr @f: dec speed 00DA3A 3 98 tya 00DA3B 3 4C 6C D4 jmp SetVelocity 00DA3E 3 60 @r: rts 00DA3F 3 00DA3F 3 ; --------------------------------------------------------------------------- 00DA3F 3 ; The top floor has no bat (2026-11-21, Aubrey's playtest; kept after his second 00DA3F 3 ; playtest): each visit is one burst among the balloons, then the ball falls back. 00DA3F 3 ; (A top bat until its balloons were gone made Big Top ten times rarer under the 00DA3F 3 ; bot; an open net on the cleared middle floor was dropped on 2026-11-22 at 00DA3F 3 ; Aubrey's request: the middle floor keeps its bat and its targets come back.) 00DA3F 3 ; FloorOpen: A nonzero (Z clear) on the top floor. 00DA3F 3 FloorOpen: 00DA3F 3 OpenTopOnly: ; (the harness reads this label to know the rule) 00DA3F 3 A5 rr lda floor 00DA41 3 29 02 and #2 00DA43 3 60 rts 00DA44 3 00DA44 3 ; FloorCleared: A = floor. Every clear pays 1000 (times the multiplier). 00DA44 3 ; - Bricks (0): stay cleared until Big Top. 00DA44 3 ; - Drop targets (1): the clear is remembered (cleared bit 1, its HUD marker 00DA44 3 ; widens) until Big Top, and the targets come back (MoveDrops), so they keep 00DA44 3 ; scoring; clearing them again pays again. 00DA44 3 ; - Balloons (2): they drift back (MoveBalloons); the clear raises this ball's 00DA44 3 ; multiplier one step after its own 1000 is paid (2026-11-22, Aubrey's idea: 00DA44 3 ; "a small bonus for future scores for that particular ball"; provisional). 00DA44 3 ; Big Top when the bricks are cleared and the drop targets have been cleared at 00DA44 3 ; least once this level: 5000 (times the multiplier), and every floor comes back 00DA44 3 ; harder (more brick rows, faster balloons and clown, a faster base speed). 00DA44 3 MULT_MAX = 5 ; the multiplier's cap (multK = (multiplier - 1) * 6) 00DA44 3 00DA44 3 FloorCleared: 00DA44 3 C9 02 cmp #2 00DA46 3 D0 14 bne @lower 00DA48 3 A9 00 lda #0 00DA4A 3 A2 10 ldx #$10 ; 1000 00DA4C 3 20 AC DA jsr AddScore 00DA4F 3 A5 rr lda multK ; then one step up, to MULT_MAX 00DA51 3 C9 18 cmp #(MULT_MAX-1)*6 00DA53 3 B0 1E bcs @clear 00DA55 3 69 06 adc #6 00DA57 3 85 rr sta multK 00DA59 3 4C 73 DA jmp @clear 00DA5C 3 AA @lower: tax 00DA5D 3 BD BE D6 lda BitTab,x 00DA60 3 05 rr ora cleared 00DA62 3 85 rr sta cleared 00DA64 3 A9 00 lda #0 00DA66 3 A2 10 ldx #$10 ; 1000 00DA68 3 20 AC DA jsr AddScore 00DA6B 3 A5 rr lda cleared 00DA6D 3 29 03 and #3 ; (the floor clears; keeps Big Top to bits 0-1) 00DA6F 3 C9 03 cmp #3 00DA71 3 F0 0A beq @bigtop 00DA73 3 @clear: 00DA73 3 A2 12 ldx #SFX_CLEAR 00DA75 3 20 42 DB jsr Sfx1 00DA78 3 A9 0C lda #MSG_CLEAR 00DA7A 3 4C D7 D4 jmp ShowMsg 00DA7D 3 @bigtop: 00DA7D 3 A9 00 lda #0 00DA7F 3 85 rr sta cleared 00DA81 3 A2 50 ldx #$50 ; 5000 00DA83 3 20 AC DA jsr AddScore 00DA86 3 E6 rr inc level 00DA88 3 20 E1 D3 jsr FillBricks 00DA8B 3 20 04 D4 jsr ResetBalloons 00DA8E 3 A9 FF lda #$FF 00DA90 3 85 rr sta drops 00DA92 3 A9 00 lda #0 00DA94 3 85 rr sta dropT 00DA96 3 A9 14 lda #20 ; no collisions while the ball leaves the refilled floor 00DA98 3 85 rr sta cool 00DA9A 3 A5 rr lda balls 00DA9C 3 C9 09 cmp #9 00DA9E 3 B0 02 bcs @nx 00DAA0 3 E6 rr inc balls 00DAA2 3 A2 13 @nx: ldx #SFX_FANFARE 00DAA4 3 20 42 DB jsr Sfx1 00DAA7 3 A9 12 lda #MSG_BIGTOP 00DAA9 3 4C D7 D4 jmp ShowMsg 00DAAC 3 00DAAC 3 ; AddScore: A = BCD for the last two digits, X = BCD for the middle two; added 00DAAC 3 ; once per multiplier step (multK = (multiplier - 1) * 6). Keeps Y. 00DAAC 3 AddScore: 00DAAC 3 85 rr sta tmp 00DAAE 3 86 rr stx row 00DAB0 3 98 tya 00DAB1 3 48 pha 00DAB2 3 A4 rr ldy multK 00DAB4 3 F8 @rep: sed 00DAB5 3 18 clc 00DAB6 3 A5 rr lda tmp 00DAB8 3 65 rr adc score+2 00DABA 3 85 rr sta score+2 00DABC 3 A5 rr lda row 00DABE 3 65 rr adc score+1 00DAC0 3 85 rr sta score+1 00DAC2 3 A9 00 lda #0 00DAC4 3 65 rr adc score+0 00DAC6 3 85 rr sta score+0 00DAC8 3 D8 cld 00DAC9 3 98 tya 00DACA 3 38 sec 00DACB 3 E9 06 sbc #6 00DACD 3 A8 tay 00DACE 3 B0 E4 bcs @rep 00DAD0 3 68 pla 00DAD1 3 A8 tay 00DAD2 3 60 rts 00DAD3 3 00DAD3 3 ; --------------------------------------------------------------------------- 00DAD3 3 BallLost: 00DAD3 3 A9 03 lda #ST_LOST 00DAD5 3 85 rr sta gameState 00DAD7 3 A9 5A lda #90 00DAD9 3 85 rr sta stateTimer 00DADB 3 A9 C8 lda #200 00DADD 3 85 rr sta ballY ; off every line 00DADF 3 A9 00 lda #0 00DAE1 3 85 rr sta floor 00DAE3 3 A2 10 ldx #SFX_LOST 00DAE5 3 4C 42 DB jmp Sfx1 00DAE8 3 00DAE8 3 ; After a lost ball: one fewer; the other player's turn in a two-player game 00DAE8 3 ; while they have balls; game over when nobody has. 00DAE8 3 NextTurn: 00DAE8 3 C6 rr dec balls 00DAEA 3 A5 rr lda twoPlayer 00DAEC 3 F0 28 beq @solo 00DAEE 3 A5 rr lda stash+(balls-pStart) 00DAF0 3 F0 24 beq @solo ; the other player is out: keep going alone 00DAF2 3 A2 0F ldx #PBLK-1 ; swap the player blocks 00DAF4 3 B5 rr @sw: lda pStart,x 00DAF6 3 B4 rr ldy stash,x 00DAF8 3 95 rr sta stash,x 00DAFA 3 94 rr sty pStart,x 00DAFC 3 CA dex 00DAFD 3 10 F5 bpl @sw 00DAFF 3 A5 rr lda curPlayer 00DB01 3 49 01 eor #1 00DB03 3 85 rr sta curPlayer 00DB05 3 20 1D D4 jsr ServeBall 00DB08 3 A5 rr lda curPlayer 00DB0A 3 F0 05 beq @m1 00DB0C 3 A9 06 lda #MSG_P2 00DB0E 3 4C D7 D4 jmp ShowMsg 00DB11 3 A9 00 @m1: lda #MSG_P1 00DB13 3 4C D7 D4 jmp ShowMsg 00DB16 3 A5 rr @solo: lda balls 00DB18 3 F0 03 beq @end 00DB1A 3 4C 1D D4 jmp ServeBall 00DB1D 3 A9 04 @end: lda #ST_OVER 00DB1F 3 85 rr sta gameState 00DB21 3 A9 B4 lda #180 00DB23 3 85 rr sta stateTimer 00DB25 3 A2 14 ldx #SFX_OVER 00DB27 3 20 42 DB jsr Sfx1 00DB2A 3 A9 18 lda #MSG_OVER 00DB2C 3 85 rr sta msgIdx 00DB2E 3 A9 B4 lda #180 00DB30 3 85 rr sta msgT 00DB32 3 60 rts 00DB33 3 00DB33 3 ; --------------------------------------------------------------------------- 00DB33 3 ; Sound. Each effect is a list of steps: (AUDC << 4 | AUDV), AUDF, frames; 00DB33 3 ; a 0 ends it. Channel 0 plays the play sounds, channel 1 the longer ones. 00DB33 3 ; All sounds here are original to this game. 00DB33 3 BD AA DB Sfx0: lda SfxLo,x 00DB36 3 85 rr sta sfxPtr0 00DB38 3 BD BF DB lda SfxHi,x 00DB3B 3 85 rr sta sfxPtr0+1 00DB3D 3 A9 00 lda #0 00DB3F 3 85 rr sta sfxCnt0 00DB41 3 60 rts 00DB42 3 BD AA DB Sfx1: lda SfxLo,x 00DB45 3 85 rr sta sfxPtr1 00DB47 3 BD BF DB lda SfxHi,x 00DB4A 3 85 rr sta sfxPtr1+1 00DB4C 3 A9 00 lda #0 00DB4E 3 85 rr sta sfxCnt1 00DB50 3 60 rts 00DB51 3 00DB51 3 Sound: 00DB51 3 A2 00 ldx #0 00DB53 3 20 58 DB jsr @chan 00DB56 3 A2 03 ldx #3 ; channel 1 state is 3 bytes on 00DB58 3 B5 rr @chan: lda sfxPtr0+1,x 00DB5A 3 F0 06 beq @r 00DB5C 3 B5 rr lda sfxCnt0,x 00DB5E 3 F0 03 beq @next 00DB60 3 D6 rr dec sfxCnt0,x 00DB62 3 60 @r: rts 00DB63 3 A1 rr @next: lda (sfxPtr0,x) ; first byte of the step 00DB65 3 F0 2A beq @stop 00DB67 3 85 rr sta t0 00DB69 3 BD A6 DB lda ChanOf,x 00DB6C 3 A8 tay 00DB6D 3 A5 rr lda t0 00DB6F 3 4A lsr 00DB70 3 4A lsr 00DB71 3 4A lsr 00DB72 3 4A lsr 00DB73 3 99 15 00 sta AUDC0,y 00DB76 3 A5 rr lda t0 00DB78 3 29 0F and #15 00DB7A 3 99 19 00 sta AUDV0,y 00DB7D 3 20 9F DB jsr @adv 00DB80 3 A1 rr lda (sfxPtr0,x) 00DB82 3 99 17 00 sta AUDF0,y 00DB85 3 20 9F DB jsr @adv 00DB88 3 A1 rr lda (sfxPtr0,x) 00DB8A 3 95 rr sta sfxCnt0,x 00DB8C 3 D6 rr dec sfxCnt0,x 00DB8E 3 4C 9F DB jmp @adv 00DB91 3 A9 00 @stop: lda #0 00DB93 3 95 rr sta sfxPtr0+1,x 00DB95 3 BD A6 DB lda ChanOf,x 00DB98 3 A8 tay 00DB99 3 A9 00 lda #0 00DB9B 3 99 19 00 sta AUDV0,y 00DB9E 3 60 rts 00DB9F 3 F6 rr @adv: inc sfxPtr0,x 00DBA1 3 D0 02 bne @a 00DBA3 3 F6 rr inc sfxPtr0+1,x 00DBA5 3 60 @a: rts 00DBA6 3 00DBA6 3 00 00 00 01 ChanOf: .byte 0, 0, 0, 1 00DBAA 3 00DBAA 3 .include "sounds.s" 00DBAA 4 ; SPDX-License-Identifier: MIT 00DBAA 4 ; Sound effects and jingles, original to this game. Step: (AUDC << 4 | AUDV), 00DBAA 4 ; AUDF, frames; $10 is a rest (AUDC 1, volume 0); 0 ends. AUDC 4 is a pure tone 00DBAA 4 ; at 31.4 kHz / 2 / (AUDF+1) on NTSC, AUDC 12 the same / 3, AUDC 8 white noise, 00DBAA 4 ; AUDC 6 a low buzz (DOC: SPG "Audio": tone types). 00DBAA 4 00DBAA 4 .enum 00DBAA 4 SFX_WALL 00DBAA 4 SFX_BAT 00DBAA 4 SFX_KICK 00DBAA 4 SFX_SWISH 00DBAA 4 SFX_BRICK0 00DBAA 4 SFX_BRICK1 00DBAA 4 SFX_BRICK2 00DBAA 4 SFX_BRICK3 00DBAA 4 SFX_BRICK4 00DBAA 4 SFX_BRICK5 00DBAA 4 SFX_POP 00DBAA 4 SFX_BUMP 00DBAA 4 SFX_CLOWN 00DBAA 4 SFX_DROP 00DBAA 4 SFX_UP 00DBAA 4 SFX_DOWN 00DBAA 4 SFX_LOST 00DBAA 4 SFX_START 00DBAA 4 SFX_CLEAR 00DBAA 4 SFX_FANFARE 00DBAA 4 SFX_OVER 00DBAA 4 .endenum 00DBAA 4 00DBAA 4 D4 D8 DF E9 SfxLo: .lobytes sWall, sBat, sKick, sSwish, sBrick0, sBrick1, sBrick2, sBrick3, sBrick4, sBrick5, sPop, sBump, sClown, sDrop, sUp, sDown, sLost, sStart, sClear, sFanfare, sOver 00DBAE 4 F0 F7 FE 05 00DBB2 4 0C 13 1A 24 00DBBF 4 DB DB DB DB SfxHi: .hibytes sWall, sBat, sKick, sSwish, sBrick0, sBrick1, sBrick2, sBrick3, sBrick4, sBrick5, sPop, sBump, sClown, sDrop, sUp, sDown, sLost, sStart, sClear, sFanfare, sOver 00DBC3 4 DB DB DB DC 00DBC7 4 DC DC DC DC 00DBD4 4 00DBD4 4 46 06 02 00 sWall: .byte $46, 6, 2, 0 00DBD8 4 C8 0C 03 C4 sBat: .byte $C8, 12, 3, $C4, 12, 2, 0 00DBDC 4 0C 02 00 00DBDF 4 8A 03 02 48 sKick: .byte $8A, 3, 2, $48, 4, 3, $44, 4, 3, 0 00DBE3 4 04 03 44 04 00DBE7 4 03 00 00DBE9 4 84 01 02 82 sSwish: .byte $84, 1, 2, $82, 2, 2, 0 00DBED 4 02 02 00 00DBF0 4 48 08 03 44 sBrick0: .byte $48, 8, 3, $44, 8, 2, 0 00DBF4 4 08 02 00 00DBF7 4 48 09 03 44 sBrick1: .byte $48, 9, 3, $44, 9, 2, 0 00DBFB 4 09 02 00 00DBFE 4 48 0A 03 44 sBrick2: .byte $48, 10, 3, $44, 10, 2, 0 00DC02 4 0A 02 00 00DC05 4 48 0B 03 44 sBrick3: .byte $48, 11, 3, $44, 11, 2, 0 00DC09 4 0B 02 00 00DC0C 4 48 0C 03 44 sBrick4: .byte $48, 12, 3, $44, 12, 2, 0 00DC10 4 0C 02 00 00DC13 4 48 0D 03 44 sBrick5: .byte $48, 13, 3, $44, 13, 2, 0 00DC17 4 0D 02 00 00DC1A 4 8C 04 01 88 sPop: .byte $8C, 4, 1, $88, 8, 2, $84, 12, 2, 0 00DC1E 4 08 02 84 0C 00DC22 4 02 00 00DC24 4 CA 05 02 C6 sBump: .byte $CA, 5, 2, $C6, 5, 3, $C3, 5, 3, 0 00DC28 4 05 03 C3 05 00DC2C 4 03 00 00DC2E 4 4A 14 03 4A sClown: .byte $4A, 20, 3, $4A, 15, 3, $4A, 24, 3, $4A, 18, 4, 0 00DC32 4 0F 03 4A 18 00DC36 4 03 4A 12 04 00DC3B 4 6A 0A 03 66 sDrop: .byte $6A, 10, 3, $66, 12, 3, 0 00DC3F 4 0C 03 00 00DC42 4 46 18 02 46 sUp: .byte $46, 24, 2, $46, 20, 2, $46, 16, 2, $46, 12, 2, 0 00DC46 4 14 02 46 10 00DC4A 4 02 46 0C 02 00DC4F 4 46 0C 02 46 sDown: .byte $46, 12, 2, $46, 16, 2, $46, 20, 2, $46, 24, 2, 0 00DC53 4 10 02 46 14 00DC57 4 02 46 18 02 00DC5C 4 6A 08 05 6A sLost: .byte $6A, 8, 5, $6A, 10, 5, $6A, 12, 5, $6A, 14, 5, $6A, 17, 6, $6A, 20, 8, $66, 24, 10, 0 00DC60 4 0A 05 6A 0C 00DC64 4 05 6A 0E 05 00DC72 4 48 1D 06 10 sStart: .byte $48, 29, 6, $10, 0, 2, $48, 23, 6, $10, 0, 2, $48, 19, 6, $10, 0, 2, $4A, 14, 14, $46, 14, 8, 0 00DC76 4 00 02 48 17 00DC7A 4 06 10 00 02 00DC8B 4 48 13 04 48 sClear: .byte $48, 19, 4, $48, 14, 4, $4A, 11, 10, $44, 11, 6, 0 00DC8F 4 0E 04 4A 0B 00DC93 4 0A 44 0B 06 00DC98 4 48 13 05 10 sFanfare: .byte $48, 19, 5, $10, 0, 1, $48, 19, 5, $10, 0, 1, $4A, 14, 8, $4A, 11, 8, $4C, 9, 20, $46, 9, 10, 0 00DC9C 4 00 01 48 13 00DCA0 4 05 10 00 01 00DCB1 4 48 0E 0A 48 sOver: .byte $48, 14, 10, $48, 19, 10, $48, 23, 10, $4A, 29, 24, $44, 29, 10, 0 00DCB5 4 13 0A 48 17 00DCB9 4 0A 4A 1D 18 00DCC1 4 00DCC1 3 00DCC1 3 ; --------------------------------------------------------------------------- 00DCC1 3 ; Prep: everything the kernels read, from the state after this frame's logic. 00DCC1 3 Prep: 00DCC1 3 A5 rr lda gameState 00DCC3 3 D0 07 bne @play 00DCC5 3 A9 01 lda #1 00DCC7 3 85 rr sta kernelMode 00DCC9 3 4C D6 DD jmp PrepScore 00DCCC 3 A9 00 @play: lda #0 00DCCE 3 85 rr sta kernelMode 00DCD0 3 ; the ball 00DCD0 3 A9 A7 lda #PLAYH-BH+1 00DCD2 3 38 sec 00DCD3 3 E5 rr sbc ballY 00DCD5 3 85 rr sta ballK 00DCD7 3 18 clc 00DCD8 3 69 02 adc #2 00DCDA 3 85 rr sta ballK2 ; (ballK + 1 comes from a borrow: BALLAT1) 00DCDC 3 A5 rr lda ballX 00DCDE 3 38 sec 00DCDF 3 E9 02 sbc #low::BatGfx 00DD16 3 85 rr sta batPtr+1 00DD18 3 86 rr stx batCol 00DD1A 3 A5 rr lda gameState 00DD1C 3 C9 01 cmp #ST_SERVE 00DD1E 3 F0 0D beq @showbat 00DD20 3 C9 02 cmp #ST_PLAY 00DD22 3 D0 05 bne @hidebat 00DD24 3 20 3F DA jsr FloorOpen ; no bat on the top floor 00DD27 3 F0 04 beq @showbat 00DD29 3 @hidebat: 00DD29 3 A9 00 lda #<(low::BatGfx+low::BatBlank) ; no bat while a ball is lost or at the end 00DD2B 3 85 rr sta batPtr 00DD2D 3 @showbat: 00DD2D 3 ; status: reserve balls and the floor markers 00DD2D 3 A6 rr ldx balls 00DD2F 3 CA dex 00DD30 3 8A txa 00DD31 3 10 02 bpl @p 00DD33 3 A9 00 lda #0 00DD35 3 C9 05 @p: cmp #5 00DD37 3 90 02 bcc @p4 00DD39 3 A9 04 lda #4 00DD3B 3 AA @p4: tax 00DD3C 3 BD 72 DE lda Pips,x 00DD3F 3 85 rr sta pipsPF 00DD41 3 ; floor markers: wide for the bricks cleared, the drop targets cleared 00DD41 3 ; this level, and the top floor while all its balloons are popped 00DD41 3 A5 rr lda balloons 00DD43 3 05 rr ora balloons+1 00DD45 3 05 rr ora balloons+2 00DD47 3 C9 01 cmp #1 ; carry clear: no balloons up 00DD49 3 A5 rr lda cleared 00DD4B 3 29 03 and #3 ; (and keeps the carry) 00DD4D 3 B0 02 bcs @bal 00DD4F 3 09 04 ora #4 00DD51 3 85 rr @bal: sta t0 00DD53 3 A2 02 ldx #2 00DD55 3 BD BE D6 @fl: lda BitTab,x 00DD58 3 25 rr and t0 00DD5A 3 F0 04 beq @nc 00DD5C 3 A9 3C lda #$3C 00DD5E 3 D0 02 bne @st 00DD60 3 A9 18 @nc: lda #$18 00DD62 3 E4 rr @st: cpx floor 00DD64 3 D0 02 bne @nf 00DD66 3 A9 FF lda #$FF 00DD68 3 95 rr @nf: sta floorPF,x 00DD6A 3 CA dex 00DD6B 3 10 E8 bpl @fl 00DD6D 3 ; middle floor 00DD6D 3 A5 rr lda clownX 00DD6F 3 38 sec 00DD70 3 E9 04 sbc #low::Font 00DDE4 3 A2 0B ldx #11 00DDE6 3 95 rr @hi: sta dp,x 00DDE8 3 CA dex 00DDE9 3 CA dex 00DDEA 3 10 FA bpl @hi 00DDEC 3 A5 rr lda gameState 00DDEE 3 F0 16 beq @digits ; the title shows the last score 00DDF0 3 A5 rr lda msgT 00DDF2 3 F0 12 beq @digits 00DDF4 3 ; a message 00DDF4 3 A6 rr ldx msgIdx 00DDF6 3 A0 00 ldy #0 00DDF8 3 BD B3 D4 @mc: lda Messages,x 00DDFB 3 99 rr rr sta dp,y 00DDFE 3 E8 inx 00DDFF 3 C8 iny 00DE00 3 C8 iny 00DE01 3 C0 0C cpy #12 00DE03 3 90 F3 bcc @mc 00DE05 3 60 rts 00DE06 3 @digits: 00DE06 3 ; six BCD digits, leading zeros blank (the last digit always shown). 00DE06 3 ; On the title in a two-player game the two scores take turns. 00DE06 3 A2 00 ldx #0 00DE08 3 A5 rr lda gameState 00DE0A 3 D0 18 bne @own 00DE0C 3 A5 rr lda twoPlayer 00DE0E 3 F0 14 beq @own 00DE10 3 A5 rr lda frame 00DE12 3 10 10 bpl @own 00DE14 3 A2 10 ldx #PBLK ; the stashed player's score (stash follows pEnd) 00DE16 3 A5 rr lda curPlayer 00DE18 3 49 01 eor #1 00DE1A 3 F0 04 beq @o1 00DE1C 3 A9 BE lda #C_SCORE2 00DE1E 3 D0 02 bne @o2 00DE20 3 A9 4E @o1: lda #C_SCORE1 00DE22 3 85 rr @o2: sta scoreCol 00DE24 3 8A @own: txa 00DE25 3 18 clc 00DE26 3 69 03 adc #3 00DE28 3 85 rr sta t1 ; end index 00DE2A 3 A0 00 ldy #0 00DE2C 3 A9 00 lda #0 00DE2E 3 85 rr sta t0 ; 0 while still blanking 00DE30 3 B5 rr @d: lda score,x 00DE32 3 4A lsr 00DE33 3 4A lsr 00DE34 3 4A lsr 00DE35 3 4A lsr 00DE36 3 20 4C DE jsr @put 00DE39 3 B5 rr lda score,x 00DE3B 3 29 0F and #15 00DE3D 3 C0 0A cpy #10 00DE3F 3 D0 02 bne @np 00DE41 3 E6 rr inc t0 ; the last digit always shows 00DE43 3 20 4C DE @np: jsr @put 00DE46 3 E8 inx 00DE47 3 E4 rr cpx t1 00DE49 3 90 E5 bcc @d 00DE4B 3 60 rts 00DE4C 3 C9 00 @put: cmp #0 00DE4E 3 D0 0F bne @nz 00DE50 3 48 pha 00DE51 3 A5 rr lda t0 00DE53 3 D0 09 bne @zero 00DE55 3 68 pla 00DE56 3 A9 50 lda #CH_SP 00DE58 3 99 rr rr sta dp,y 00DE5B 3 C8 iny 00DE5C 3 C8 iny 00DE5D 3 60 rts 00DE5E 3 68 @zero: pla 00DE5F 3 E6 rr @nz: inc t0 00DE61 3 0A asl 00DE62 3 0A asl 00DE63 3 0A asl 00DE64 3 99 rr rr sta dp,y 00DE67 3 C8 iny 00DE68 3 C8 iny 00DE69 3 60 rts 00DE6A 3 00DE6A 3 00 E0 0E EE PairA: .byte $00, $E0, $0E, $EE ; two bricks in PF1 (D7 first) 00DE6E 3 00 07 70 77 PairB: .byte $00, $07, $70, $77 ; two bricks in PF2 (D0 first) 00DE72 3 00 80 A0 A8 Pips: .byte $00, $80, $A0, $A8, $AA 00DE76 3 AA 00DE77 3 00DE77 3 00DE77 2 00DE77 1 .include "stubs.s" 00DE77 2 ; SPDX-License-Identifier: MIT 00DE77 2 ; Bank-switch stubs, identical in all four banks at $xFC0. A store to a hotspot 00DE77 2 ; switches the bank, and the next instruction is fetched from the new bank at the 00DE77 2 ; same offset, so each jump below is only ever executed in the bank it names. 00DE77 2 ; F6 hotspots: $1FF6 bank 0, $1FF7 bank 1, $1FF8 bank 2, $1FF9 bank 3 00DE77 2 ; (DOC: Kevin Horton's 2600 bankswitching document, prose description of F6). 00DE77 2 00DE77 2 .macro STUBS 00DE77 2 Start_: sta $1FF6 ; $FC0 reset in any bank: go to bank 0 00DE77 2 jmp Init ; $FC3 (runs in bank 0) 00DE77 2 ToTop_: sta $1FF7 ; $FC6 called from bank 0 00DE77 2 jmp KernelTop ; $FC9 (runs in bank 1) 00DE77 2 ToTitle_: sta $1FF8 ; $FCC called from bank 0 00DE77 2 jmp TitleKernel ; $FCF (runs in bank 2) 00DE77 2 ToLow_: sta $1FF9 ; $FD2 called from bank 0 00DE77 2 jmp KernelLow ; $FD5 (runs in bank 3) 00DE77 2 ToLogic_: sta $1FF6 ; $FD8 jumped to from banks 1-3 00DE77 2 rts ; $FDB (runs in bank 0) 00DE77 2 .res $FF6-$FDC, $00 00DE77 2 .byte 0,0,0,0 ; $FF6-$FF9 hotspots 00DE77 2 .word $FFC0 ; NMI 00DE77 2 .word $FFC0 ; RESET 00DE77 2 .word $FFC0 ; IRQ/BRK 00DE77 2 .endmacro 00DE77 2 00DE77 2 .segment "STUB0" 00DE77 2 .org $DFC0 00DFC0 2 .scope s0 00DFC0 2 8D F6 1F 4C STUBS 00DFC4 2 EC D1 8D F7 00DFC8 2 1F 4C B7 F5 00E000 2 .endscope 00E000 2 .segment "STUB1" 00E000 2 .org $FFC0 00FFC0 2 .scope s1 00FFC0 2 8D F6 1F 4C STUBS 00FFC4 2 EC D1 8D F7 00FFC8 2 1F 4C B7 F5 010000 2 .endscope 010000 2 .segment "STUB2" 010000 2 .org $BFC0 00BFC0 2 .scope s2 00BFC0 2 8D F6 1F 4C STUBS 00BFC4 2 EC D1 8D F7 00BFC8 2 1F 4C B7 F5 00C000 2 .endscope 00C000 2 .segment "STUB3" 00C000 2 .org $9FC0 009FC0 2 .scope s3 009FC0 2 8D F6 1F 4C STUBS 009FC4 2 EC D1 8D F7 009FC8 2 1F 4C B7 F5 00A000 2 .endscope 00A000 2 00A000 2 ; The callers use these fixed offsets (the same in every bank, linked per bank). 00A000 2 ToTop = $DFC6 ; jsr from bank 0 00A000 2 ToTitle = $DFCC 00A000 2 ToLow = $DFD2 00A000 2 ToLogic1 = $FFD8 ; jmp from bank 1 00A000 2 ToLogic2 = $BFD8 ; jmp from bank 2 00A000 2 ToLogic3 = $9FD8 ; jmp from bank 3 00A000 2 .assert s0::ToTop_ = ToTop, error, "stub layout" 00A000 2 .assert s0::ToTitle_ = ToTitle, error, "stub layout" 00A000 2 .assert s0::ToLow_ = ToLow, error, "stub layout" 00A000 2 .assert s1::ToLogic_ = ToLogic1, error, "stub layout" 00A000 2 .assert s2::ToLogic_ = ToLogic2, error, "stub layout" 00A000 2 .assert s3::ToLogic_ = ToLogic3, error, "stub layout" 00A000 2 00A000 1