; SPDX-License-Identifier: MIT ; Play-area band macros shared by the two play-kernel banks. KY is the line ; counter value (Y) at the band's first line; each macro advances it. ; --------------------------------------------------------------------------- ; Shared play-area bands. ; EMPTY n: n plain lines (ball, paddle). .macro EMPTY n .local loop GUARD 30 loop: sta WSYNC BALL ; 16 PADDLE9 ; 25 dey ; 27 cpy #(KY-(n)) ; 29 bne loop ; 32 .assert >loop = >*, error, "EMPTY loop crosses a page" KY .set KY-(n) .endmacro ; RELEASE: line 59 on every floor: stop dumping the paddle capacitors. .macro RELEASE .assert KY = RELEASE_Y, error, "RELEASE on the wrong line" sta WSYNC BALL ; 16 lda #0 ; 18 sta VBLANK ; 21 lda #PADINIT ; 23 sta padY ; 26 PADDLE9 ; 35 dey ; 37 KY .set KY-1 .endmacro ; BATBAND: the last 18 lines (Y 18..1): position P0, then draw the bat. .macro BATBAND .local s1loop, batloop .assert KY = 18, error, "BATBAND must start at Y=18" ; s0 (Y=18) sta WSYNC BALL ; 16 PADDLE9 ; 25 BALLAT1 tE1 ; 41 lda #0 ; 43 sta GRP0 ; 46 lda batFine ; 49 sta HMP0 ; 52 ldx batCoarse ; 55 dey ; 57 ; s1 (Y=17) sta WSYNC ; 60 lda tE1 ; 3 sta ENABL ; 6 PADDLE9 ; 15 GUARD 8 s1loop: dex ; bpl s1loop ; 15+5c+4 sta RESP0 ; 22+5c (c <= 9: 67) .assert >s1loop = >*, error, "bat loop crosses a page" dey ; 69 ; s2 (Y=16) sta WSYNC sta HMOVE ; 3 BALL ; 19 PADDLE9 ; 28 lda #7 ; 30 (quad width) sta NUSIZ0 ; 33 lda batCol ; 36 sta COLUP0 ; 39 dey ; 41 sta HMCLR ; 44 GUARD 32 batloop: sta WSYNC BALL ; 16 lda (batPtr),y ; 21 sta GRP0 ; 24 PADDLE9 ; 33 dey ; 35 bne batloop ; 38 .assert >batloop = >*, error, "bat loop crosses a page" KY .set 0 .endmacro ; --------------------------------------------------------------------------- ; Brick-row bands. Non-reflected playfield with every register written twice a ; line: the wall ($F0 in PF0 left and PF2 right) is merged into the values. ; Write windows (cycle of the store's write, DOC: SPG playfield timing; checked ; on our board): PF0 right 28-49, PF1 right 39-54, PF2 right 50-64, PF0 next ; line >= 55, PF1 next line >= 66, PF2 left before 38. ; BRICK_E: switch to the non-reflected playfield, walls only. .macro BRICK_E sta WSYNC BALL ; 16 lda #CTRL_NONREF ; 18 sta CTRLPF ; 21 lda #0 ; 23 sta PF2 ; 26 PADDLE9 ; 35 sta PF0 ; 38 right PF0 = 0 lda #$F0 ; 40 SLEEP 10 ; 50 sta PF2 ; 53 right wall sta PF0 ; 56 next line's left wall dey ; 58 KY .set KY-1 .endmacro ; BRICK_T: back to the reflected playfield with plain walls. .macro BRICK_T wallcol sta WSYNC BALL ; 16 lda #0 ; 18 sta PF1 ; 21 sta PF2 ; 24 lda #CTRL_REF ; 26 sta CTRLPF ; 29 PADDLE9 ; 38 lda #wallcol ; 40 sta COLUPF ; 43 dey ; 45 KY .set KY-1 .endmacro ; BRICK_TV: BRICK_T with the wall colour from bcol (the ball's power colour on the ; middle floor); one cycle later. .macro BRICK_TV sta WSYNC BALL ; 16 lda #0 ; 18 sta PF1 ; 21 sta PF2 ; 24 lda #CTRL_REF ; 26 sta CTRLPF ; 29 PADDLE9 ; 38 lda bcol ; 41 sta COLUPF ; 44 dey ; 46 KY .set KY-1 .endmacro ; BRICK_ROW mask, col, n: two gap lines (G1, G2) that look the row up, then n ; brick lines. .macro BRICK_ROW mask, col, n .local bl ; G1 sta WSYNC BALL ; 16 lda #0 ; 18 sta PF1 ; 21 sta PF2 ; 24 ldx #col ; 26 stx COLUPF ; 29 PADDLE9 ; 38 sta PF0 ; 41 right PF0 = 0 ldx mask ; 44 lda TA,x ; 48 sta v1L ; 51 lda TB,x ; 55 sta v2L ; 58 lda #$F0 ; 60 sta PF2 ; 63 right wall sta PF0 ; 66 next left wall dey ; 68 ; G2 sta WSYNC ; 71 BALL ; 16 lda #0 ; 18 sta PF2 ; 21 PADDLE9 ; 30 sta PF0 ; 33 lda TC,x ; 37 sta v0R ; 40 lda TD,x ; 44 sta v1R ; 47 lda TE,x ; 51 sta v2R ; 54 lda #$F0 ; 56 sta PF2 ; 59 sta PF0 ; 62 ldx v1L ; 65 stx PF1 ; 68 first brick line's left PF1 dey ; 70 KY .set KY-2 BRICK_LINES v1L, n .endmacro ; BRICK_LINES base, n: n brick lines from the five values at base: ; PF1 left, PF2 left, PF0 right, PF1 right, PF2 right. .macro BRICK_LINES base, n .local bl GUARD 56 bl: sta WSYNC ; 73 BALL ; 16 lda base+1 ; 19 sta PF2 ; 22 lda base+2 ; 25 ldx base+3 ; 28 sta PF0 ; 31 lda base+4 ; 34 PADDLE9 ; 43 stx PF1 ; 46 ldx base+0 ; 49 dey ; 51 sta PF2 ; 54 lda #$F0 ; 56 sta PF0 ; 59 cpy #(KY-(n)) ; 61 nop ; 63 nop ; 65 stx PF1 ; 68 bne bl ; 71 .assert >bl = >*, error, "brick loop crosses a page" KY .set KY-(n) .endmacro ; BRICK_ROWV base, col, n: a row whose five values are already in RAM at base ; (the drop targets, prepared by bank 0): two gap lines, then n brick lines. .macro BRICK_ROWV base, col, n ; G1 sta WSYNC BALL ; 16 lda #0 ; 18 sta PF1 ; 21 sta PF2 ; 24 ldx #col ; 26 stx COLUPF ; 29 PADDLE9 ; 38 sta PF0 ; 41 lda #$F0 ; 43 SLEEP 12 ; 55 sta PF2 ; 58 sta PF0 ; 61 dey ; 63 ; G2 sta WSYNC BALL ; 16 lda #0 ; 18 sta PF2 ; 21 PADDLE9 ; 30 sta PF0 ; 33 lda #$F0 ; 35 SLEEP 16 ; 51 sta PF2 ; 54 sta PF0 ; 57 ldx base+0 ; 60 SLEEP 4 ; 64 stx PF1 ; 67 dey ; 69 KY .set KY-2 BRICK_LINES base, n .endmacro