2018-09-12 13:54:54 +00:00
|
|
|
;Paddle Controller Constants and Functions for Apple II
|
|
|
|
|
2020-04-27 16:41:16 +00:00
|
|
|
PADDLS EQU 4 ;Maximum Numbers of Paddles
|
2018-09-12 13:54:54 +00:00
|
|
|
|
2020-04-27 16:41:16 +00:00
|
|
|
;paddle(n) - Read Paddle n
|
|
|
|
;Args: A = Paddle Number (0-3)
|
|
|
|
;Returns: A, Y = Paddle Value (0-255)
|
|
|
|
; Carry Set if P
|
2018-09-12 13:54:54 +00:00
|
|
|
PADDLE: LDY #0 ;Set Result to 0
|
|
|
|
CMP #PADDLS ;If Paddle# >= Max
|
2020-04-27 16:41:16 +00:00
|
|
|
BCS PADDLZ ; Return 0 & Carry Set
|
2018-09-12 13:54:54 +00:00
|
|
|
TAX ;Copy Paddle# to X Register
|
|
|
|
JSR $FB1E ;Execute Monitor PREAD Routine
|
|
|
|
PADDLZ: TYA ;Copy Result to Accumulator
|
|
|
|
RTS
|
|
|
|
|
2020-04-27 16:41:16 +00:00
|
|
|
BUTTNS EQU 2 ;Maximum Numbers of Buttons
|
2018-09-12 13:54:54 +00:00
|
|
|
|
2020-04-27 16:41:16 +00:00
|
|
|
;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
|
2018-09-12 13:54:54 +00:00
|
|
|
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
|