; SPDX-License-Identifier: MIT ; Shared play-kernel code (banks 1 and 3): positioning, the HUD, the kernel exit. ; Included inside each bank's scope after its graphics. ; --------------------------------------------------------------------------- ; PosObj: A = x - POS_K (0..149), X = object (0 P0, 1 P1, 2 M0, 3 M1, 4 BL). ; Ends the current line, strobes RESx on the next one, ends that line, and sets ; HMxx early on the line after. Always exactly the same lines: the strobe falls ; at cycle 19+5k at the latest 69 (k <= 10, so x - POS_K <= 149). PosObj: sta WSYNC SLEEP 14 sec @div: sbc #15 bcs @div sta RESP0,x sta WSYNC eor #7 asl asl asl asl sta HMP0,x rts ; --------------------------------------------------------------------------- ; HUD: entered on line 36 (VBLANK on). Lines 36-39 position the ball and the ; score's players; 40-61 are the 22 HUD lines; FloorSetup is entered during ; line 56 and must end lines 56-60 with five WSYNCs, leaving line 61 for the ; first play line's own WSYNC to end. HudStart: lda ballXpos ldx #4 jsr PosObj ; ends 36, strobe on 37, ends 37 sta WSYNC ; ends 38 ; line 39: the score's players, fixed positions SLEEP ::SCORE_SLEEP sta RESP0 sta RESP1 ; three cycles (9 clocks) later lda #SCORE_HM0 sta HMP0 lda #SCORE_HM1 sta HMP1 sta WSYNC ; ends 39 (PosObj left the ball's motion in HMBL) .assert ::SCORE_SLEEP >= 2, error, "SCORE_SLEEP" ; HUD line 0 (40) sta HMOVE lda #$80 sta VBLANK ; picture on; paddle capacitors still dumped lda #3 sta NUSIZ0 sta NUSIZ1 lda #1 sta VDELP0 sta VDELP1 lda scoreCol sta COLUP0 sta COLUP1 lda #0 sta ENABL sta COLUBK sta PF0 sta PF1 sta PF2 sta CTRLPF sta HMCLR ldy #7 sty row GUARD 56 ScoreLoop: lda (dp+0),y sta GRP0 sta WSYNC lda (dp+2),y ; 5 sta GRP1 ; 8 lda (dp+4),y ; 13 sta GRP0 ; 16 lda (dp+6),y ; 21 sta tmp ; 24 lda (dp+8),y ; 29 tax ; 31 lda (dp+10),y ; 36 tay ; 38 lda tmp ; 41 sta GRP1 ; 44 stx GRP0 ; 47 sty GRP1 ; 50 sta GRP0 ; 53 dec row ; 58 ldy row ; 61 bpl ScoreLoop ; 64 .assert >ScoreLoop = >*, error, "ScoreLoop crosses a page" sta WSYNC ; ends 48 ; HUD line 9 (49) lda #0 sta GRP0 sta GRP1 sta GRP0 sta VDELP0 sta VDELP1 lda #2 ; score mode: left PF in COLUP0, right in COLUP1 sta CTRLPF lda #C_PIPS sta COLUP0 lda #C_FLOORMK sta COLUP1 lda #5 ; P0 (left where the score's first digit was), one sta NUSIZ0 ; copy at double width: the multiplier, in COLUP0 ldx #5 GUARD 40 StatLoop: sta WSYNC ; ends 49 .. 54 lda pipsPF ; 3 sta PF1 ; 6 txa ; 8 clc ; 10 adc multK ; 13 tay ; 15 lda MultGfx,y ; 19 (20 across a page) sta GRP0 ; 23 (before the player is drawn) txa ; 25 lsr ; 27 tay ; 29 lda floorPF,y ; 33 SLEEP 7 ; 40 sta PF1 ; 43 (right half) dex ; 45 bpl StatLoop ; 48 .assert >StatLoop = >*, error, "StatLoop crosses a page" sta WSYNC ; ends 55 ; HUD line 16 (56) lda #0 sta PF1 sta GRP0 sta GRP1 sta NUSIZ0 sta NUSIZ1 sta COLUP0 sta COLUP1 lda #CTRL_REF sta CTRLPF jmp FloorSetup ; The multiplier on the status line (2026-11-22): six lines, [multK + line], the ; bottom line first; nothing at 1x. Drawn at double width: "x" then the digit. MultGfx: .byte $00, $00, $00, $00, $00, $00 ; 1x: blank .byte $AF, $44, $A2, $01, $09, $06 ; x2 ....-##- / ....#--# / .......# / #-#---#- / -#---#-- / #-#-#### .byte $AE, $41, $A1, $06, $01, $0E ; x3 ....###- / .......# / .....##- / #-#....# / -#.....# / #-#-###- .byte $A1, $41, $A1, $0F, $09, $09 ; x4 ....#..# / ....#..# / ....#### / #-#....# / -#.....# / #-#....# .byte $AE, $41, $A1, $0E, $08, $0F ; x5 ....#### / ....#... / ....###. / #-#....# / -#.....# / #-#-###- .assert MultGfx + 30 <= $10000, error, "MultGfx" ; --------------------------------------------------------------------------- ; Kernel exit: after the last play line (Y = 0). Ends line 231, blanks, returns. KernelEnd: KEXIT TOLOGIC