; SPDX-License-Identifier: MIT ; Bank 1: the play kernels for the middle floor (the clown, the bumpers and the ; drop targets) and the top floor: the tent roof and three rows of balloons that ; slide from side to side. Each row is P0 and P1 with NUSIZ copies ; (three per player, 16 colour clocks apart when interleaved); a popped balloon ; is removed by changing NUSIZ and the copy's x (gen_tables.py: BalNus, BalOff). ; A player with no balloons left is parked behind the left wall (HIDE_X; the ; playfield has priority over the players). .segment "BANK1" .org $F000 .scope top TOLOGIC = ToLogic1 .include "shared.s" .include "gen/top.inc" .include "hud.s" Entry: jmp HudStart HIDE_X = 4 ; The next row's positioning values, split over three lines. .macro CHUNK_A nr .local skip lda balloons+nr and #7 tax lda BalNus,x sta bn0 lda rowX+nr clc adc BalOff0,x cpx #0 bne skip lda #HIDE_X skip: tax lda BalC,x sta bc0 lda BalF,x sta bf0 .endmacro .macro CHUNK_B nr .local skip lda balloons+nr lsr lsr lsr tax lda BalNus,x sta bn1 lda rowX+nr clc adc BalOff1,x cpx #0 bne skip lda #HIDE_X skip: sta bsum .endmacro .macro CHUNK_C ldx bsum lda BalC,x sta bc1 lda BalF,x sta bf1 .endmacro ; BALLOON_LINES first, stop: balloon lines with X from `first` down to stop+1. .macro BALLOON_LINES stop .local bl GUARD 40 bl: sta WSYNC lda BalloonGfx,x ; 4 sta GRP0 ; 7 sta GRP1 ; 10 BALL ; 26 PADDLE9 ; 35 dey ; 37 dex ; 39 cpx #stop ; 41 bne bl ; 44 .assert >bl = >*, error, "balloon loop crosses a page" .endmacro ; BROW c0, c1, next, rel: one balloon row, 19 lines: s0-s3 position the two ; players; b0-b14 draw (b0-b11 the body). b12-b14 compute the next row when there ; is one (next >= 0); the row whose b-line `rel` is play line 59 releases the ; paddle capacitor there (rel = -1: none). .macro BROW c0, c1, next, rel .local l1, l2 ; s0 sta WSYNC BALL ; 16 BALLAT1 tE1 ; 32 BALLAT ballK2, tE2 ; 48 lda bf0 ; 51 sta HMP0 ; 54 lda bf1 ; 57 sta HMP1 ; 60 ldx bc0 ; 63 dey ; 65 dey ; 67 (s1 and s2 do not use Y) ; s1 sta WSYNC ; 70 lda tE1 ; 3 sta ENABL ; 6 GUARD 6 l1: dex bpl l1 ; 10+5c sta RESP0 ; 13+5c (c <= 11: 68) ldx bc1 ; 71 .assert >l1 = >*, error, "row loop crosses a page" ; s2 sta WSYNC lda tE2 ; 3 sta ENABL ; 6 GUARD 6 l2: dex bpl l2 sta RESP1 ; 13+5c dey ; 70 .assert >l2 = >*, error, "row loop crosses a page" ; s3 sta WSYNC sta HMOVE ; 3 BALL ; 19 lda bn0 ; 22 sta NUSIZ0 ; 25 lda bn1 ; 28 sta NUSIZ1 ; 31 lda #c0 ; 33 sta COLUP0 ; 36 lda #c1 ; 38 sta COLUP1 ; 41 ldx #14 ; 43 dey ; 45 sta HMCLR ; 48 .if rel < 0 BALLOON_LINES 2 ; b0-b11 .else BALLOON_LINES (14-rel) ; b0 .. b(rel-1) ; b(rel): play line 59 .assert KY - 4 - rel = RELEASE_Y, error, "release line" sta WSYNC lda BalloonGfx+(14-rel) ; 4 sta GRP0 ; 7 sta GRP1 ; 10 BALL ; 26 lda #0 ; 28 sta VBLANK ; 31 lda #PADINIT ; 33 sta padY ; 36 PADDLE9 ; 45 dey ; 47 dex ; 49 BALLOON_LINES 2 ; the rest of b0-b11 .endif ; b12 sta WSYNC lda #BAL_ROW12 ; 2 sta GRP0 ; 5 sta GRP1 ; 8 BALL ; 24 dey ; 26 .if next >= 0 CHUNK_A next ; <= 71 .else PADDLE9 .endif ; b13 sta WSYNC lda #BAL_ROW13 sta GRP0 sta GRP1 BALL dey .if next >= 0 CHUNK_B next ; 62 .else PADDLE9 .endif ; b14 sta WSYNC lda #0 sta GRP0 sta GRP1 BALL dey .if next >= 0 CHUNK_C ; 43 .else PADDLE9 .endif KY .set KY-19 .endmacro FloorSetup: lda floor cmp #2 bne SetupMiddle jmp SetupTop ; Middle floor: the clown (P0, double width) and the bumpers (P1, three copies). SetupMiddle: lda clownXpos ldx #0 jsr PosObj ; ends 56, strobe 57, ends 57 sta WSYNC ; ends 58 SLEEP ::BUMP_SLEEP ; line 59: bumpers at a fixed x sta RESP1 lda #BUMP_HM sta HMP1 sta WSYNC ; ends 59 sta HMOVE ; line 60 lda #5 sta NUSIZ0 ; double-width clown lda #6 sta NUSIZ1 ; three copies, medium spacing lda bumpCol sta COLUP1 ldx speed ; the ball's power colour (walls and ball) lda PowerCol,x sta bcol sta WSYNC ; ends 60 sta HMCLR ; line 61 lda #C_BG1 sta COLUBK lda bcol sta COLUPF lda #$F0 sta PF0 ldy #PLAYH KY .set ::PLAYH EMPTY 2 ; 0-1 ldx clownTop ; clown: 16 lines (2-17). Its x is kept in 32..112, so GRP0 and COLUP0 can be ; written up to cycle 32. GUARD 36 M_clown: sta WSYNC BALL ; 16 lda ClownAGfx,x ; 20 sta GRP0 ; 23 lda ClownACol,x ; 27 sta COLUP0 ; 30 PADDLE9 ; 39 dex ; 41 dey ; 43 cpy #(KY-16) ; 45 bne M_clown ; 48 .assert >M_clown = >*, error, "clown loop crosses a page" KY .set KY-16 lda #0 sta GRP0 EMPTY 6 ; 18-23 ldx #9 GUARD 34 M_bumpA: sta WSYNC ; bumpers A: 24-33 lda BumperGfx,x ; 4 sta GRP1 ; 7 BALL ; 23 PADDLE9 ; 32 dey ; 34 dex ; 36 bpl M_bumpA ; 39 .assert >M_bumpA = >*, error, "bumper loop crosses a page" KY .set KY-10 EMPTY 8 ; 34-41 BRICK_E ; 42 BRICK_ROWV dropPF, C_DROP, 4 ; 43-48 BRICK_TV ; 49 EMPTY 9 ; 50-58 RELEASE ; 59 EMPTY 29 ; 60-88 sta WSYNC ; 89: bumper row B: two copies, wide BALL ; 16 PADDLE9 ; 25 lda #4 ; 27 sta NUSIZ1 ; 30 ldx #9 ; 32 dey ; 34 KY .set KY-1 GUARD 34 M_bumpB: sta WSYNC ; bumpers B: 90-99 lda BumperGfx,x sta GRP1 BALL PADDLE9 dey dex bpl M_bumpB .assert >M_bumpB = >*, error, "bumper loop crosses a page" KY .set KY-10 EMPTY 52 ; 100-151 BATBAND ; 152-169 jmp KernelEnd ; Top floor set-up lines 56-60 (no ball on these lines). SetupTop: sta WSYNC ; ends 56 CHUNK_A 0 sta WSYNC ; ends 57 CHUNK_B 0 sta WSYNC ; ends 58 CHUNK_C sta WSYNC ; ends 59 lda #C_BG2 sta COLUBK lda #0 sta ENABL ldx speed ; the ball's power colour (walls and ball) lda PowerCol,x sta bcol sta WSYNC ; ends 60 lda #$F0 ; line 61 sta PF0 ldy #PLAYH ldx #9 KY .set ::PLAYH ; Roof: 10 lines (0-9), symmetric playfield; the ball never enters them. Lines 0-8 ; in the loop, line 9 after it, in the power colour. GUARD 24 T_roof: sta WSYNC lda RoofCol,x ; 4 sta COLUPF ; 7 lda RoofPF1,x ; 11 sta PF1 ; 14 lda RoofPF2,x ; 18 sta PF2 ; 21 dey ; 23 dex ; 25 bne T_roof ; 28 .assert >T_roof = >*, error, "roof loop crosses a page" sta WSYNC ; line 9 lda bcol ; 3 sta COLUPF ; 6 lda RoofPF1 ; 10 sta PF1 ; 13 lda RoofPF2 ; 17 sta PF2 ; 20 dey ; 22 KY .set KY-10 ; (the roof's last line leaves PF1 = PF2 = 0 and COLUPF = the power colour) BROW C_BAL0A, C_BAL0B, 1, -1 ; 10-28 BROW C_BAL1A, C_BAL1B, 2, -1 ; 29-47 BROW C_BAL2A, C_BAL2B, -1, 7 ; 48-66 (b7 = line 59) EMPTY 85 ; 67-151 BATBAND ; 152-169 jmp KernelEnd ; The ball's power by speed step (0-7), as the colour of the ball and the walls on ; the middle and top floors (they share COLUPF): grey at the slower steps, then ; yellow, orange, and blue-white from PUNCH_SPEED, when the ball punches through ; balloons (2026-11-23; provisional). PowerCol: .repeat 8, I .if I >= ::PUNCH_SPEED .byte C_POW3 .elseif I = ::PUNCH_SPEED - 1 .byte C_POW2 .elseif I = ::PUNCH_SPEED - 2 .byte C_POW1 .else .byte C_WALL1 .endif .endrepeat .assert >PowerCol = >(PowerCol+7), error, "PowerCol crosses a page" .endscope KernelTop = top::Entry .assert top::Font = $F000, error, "Font must start bank 1" .assert top::BatGfx - top::Font = low::BatGfx - low::Font, error, "BatGfx offsets differ"