1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2024-11-30 23:50:04 +00:00
C02/vcs/include/k2line0.a02

113 lines
3.5 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

;k2line.a02 - Two Line Kernal Assembly Language File for C02
;Requires Constants PLYR0H and PLYR1H,
;Variables PLYR0D and PLYR1D, and Pointers PLYR0P and PLYR1P
PLYR0H EQU $D0 ;Player 0 Height
PLYR1H EQU $D1 ;Player 1 Height
PLYR0D EQU $D2 ;Player 0 Draw Counter
PLYR1D EQU $D3 ;Player 1 Draw Pointer
PLYR0P EQU $D4 ;Player 0 Graphics Pointer
PLYR1P EQU $D6 ;Player 1 Graphics Pointer
PLYR0T EQU $D8 ;Player 0 Pointer Offset
PLYR1T EQU $DA ;Player 1 Pointer Offset
SCNLNS EQU $DF ;Number of Scanlines
;setpl0() - Set Player 0 Data
;Args: A = Player 0 Height
; Y,X = Pointer to Player 0 Graphics Data
SETPL0: STA PLYR0H ;Save Player 0 Height
DEC PLYR0H ;and Decrement
STX PLYR0P ;Save Player 0 Pointer
STY PLYR0P+1
RTS
;setpl1() - Set Player 1 Data
;Args: A = Player 1 Height
; Y,X = Pointer to Player 1 Graphics Data
SETPL1: STA PLYR1H ;Save Player 1 Height
DEC PLYR1H ;and Decrement
STX PLYR1P ;Save Player 1 Pointer
STY PLYR1P+1
RTS
;prppl0() - Prep Player Variables
;Args: A = Player 0 Y-Position
PRPPL0: STA TEMP0
LDA SCNLNS ;PLYR0D = SCNLNS + PLYR0H - PLYR0Y
CLC
ADC PLYR0H
; ADC #1
SEC
SBC TEMP0
STA PLYR0D
LDA PLYR0P ;PLYR0T = PLYR0P + PLYR0H - PLYR0Y - 1
CLC
ADC PLYR0H
SEC
SBC TEMP0
STA PLYR0T
LDA PLYR0P+1
SBC #0
STA PLYR0T+1
RTS
;prppl1() - Prep Player 1 Variables
;Args: A = Player 1 Y Position
PRPPL1: STA TEMP1
LDA SCNLNS ;PLYR1D = SCNLNS + PLYR1H - PLYR1Y
CLC
ADC PLYR1H
; ADC #1
SEC
SBC TEMP1
STA PLYR1D
LDA PLYR1P ;PLYR1T = PLYR1P + PLYR1H - PLYR1Y - 1
CLC
ADC PLYR1H
SEC
SBC TEMP1
STA PLYR1T
LDA PLYR1P+1
SBC #0
STA PLYR1T+1
RTS
;prpdsp() - Prep Display
PRPDSP: LDA #0
STA WSYNC ;Wait for Horizontal Sync
STA HMOVE ;Move Objects
STA VDELP0 ;Clear Player 0 Vertical Delay
RTS
;dsplns() - Display Two Line Kernal
DSPLNS: LDY SCNLNS ; (13) Set Number of Lines to Draw
DEY
DSPLNL: LDA PLYR0H ;2 21 - Height of Player 0 (Zero Based)
DCP PLYR0D ;5 26 - Decrement PLYR0D and compare with height
BCS DSPLN0 ;2 28 - (3 23) If Player 0 not on Current Scanline
LDA #0 ;2 30 - Load Blank Line
BYTE $2C ;4 34 - Else (BIT trick)
DSPLN0: LDA (PLYR0T),Y ;5 49 - Load Player 0 Graphics Line
STA WSYNC ;3 52 - End of Line 2
STA GRP0 ;3 3 - Set Player 0 Graphics Data
LDX #%11111111 ;2 5 - Load Playfield Pattern
STX PF0 ;3 8 - and Store
STX PF1 ;3 11
STX PF2 ;3 14
LDA PLYR1H ;2 16 - Height of Player 1
DCP PLYR1D ;5 21 - Decrement PLYR1D and compare with height
BCS DSPLN1 ;2 23 - (3 18) If Player 0 not on Current Scanline
LDA #0 ;2 25 - Load Blank Line
BYTE $2C ;4 29 - - Else (BIT trick)
DSPLN1 LDA (PLYR1T),Y ;5 34 - Load Player 1 Graphics Line
STA WSYNC ;3 37 - End of Line 1
STA GRP1 ;3 3 - Set Player 0 Graphics Data
LDX #0 ;2 5 - Load Playfield Pattern
STX PF0 ;3 8 - and Store
STX PF1 ;3 11
STX PF2 ;3 14
DEY ;2 16 - decrease the 2LK loop counter
BPL DSPLNL ;2 18 - (3 21) Branch if more lines to draw
RTS