mirror of
https://github.com/RevCurtisP/C02.git
synced 2024-11-29 01:49:19 +00:00
35 lines
1.1 KiB
Plaintext
35 lines
1.1 KiB
Plaintext
;Paddle Controller Constants and Functions for Apple II
|
|
|
|
PADDLS EQU 4 ;Maximum Numbers of Paddles
|
|
|
|
;paddle(n) - Read Paddle n
|
|
;Args: A = Paddle Number (0-3)
|
|
;Returns: A, Y = Paddle Value (0-255)
|
|
; Carry Set if P
|
|
PADDLE: LDY #0 ;Set Result to 0
|
|
CMP #PADDLS ;If Paddle# >= Max
|
|
BCS PADDLZ ; Return 0 & Carry Set
|
|
TAX ;Copy Paddle# to X Register
|
|
JSR $FB1E ;Execute Monitor PREAD Routine
|
|
PADDLZ: TYA ;Copy Result to Accumulator
|
|
RTS
|
|
|
|
BUTTNS EQU 2 ;Maximum Numbers of Buttons
|
|
|
|
;button(n) - Read Paddle Button n
|
|
;Args: A = Button Number (0-1)
|
|
;Returns: A, Y = Button State
|
|
; 0 = Not Pressed
|
|
; $FF = Pressed
|
|
; X = Button Number
|
|
; Carry Set if P
|
|
BUTTON: LDY #0 ;Set Result to 0
|
|
CMP #BUTTNS ;If Button# >= Max
|
|
BCS BUTTOZ ; Return Zero & Carry Set
|
|
TAX ;Copy Paddle# to X Register
|
|
LDA $C061,X ;Load Button Register
|
|
BPL BUTTOZ ;If Bit 7 Set
|
|
DEY ; Change Result to $FF
|
|
BUTTOZ: TYA ;Copy Result to Accumulator
|
|
RTS
|