Read_Btns_Mask ($F1B4)

Read_Btns ($F1BA)

Both of these routines read the button states on the two joysticks, and return their state in the following RAM locations:

joystick 1,
button 1: $C812 = $01
button 2: $C813 = $02
button 3: $C814 = $04
button 4: $C815 = $08

joystick 2,
button 1: $C816 = $10
button 2: $C817 = $20
button 3: $C818 = $40
button 4: $C819 = $80

Contains current state of all buttons;

1 = depressed, 0 = not depressed

Contains state of all buttons from LAST time these routines were called; if Read_Btns_Mask was called, then this is AND'ed with the passed in mask.

Contains the same information as $C812-$C819

Bit 7 		  Bit 0
2.4 2.3 2.2 2.1 1.4 1.3 1.2 1.1


If Read_Btns is called, the result will be the same as Read_Btns_Mask with a mask of $FF1, and a 1 will only be returned if the button has transitioned to being pressed.

If Read_Btns_Mask is called, then a mask, passed in in the A-reg will be used to determine how the button state info is returned:

If a bit is 0, then the current state of the button is to be returned in the appropriate RAM location; 0 = not pressed, and 1 = pressed.

If a bit is 1, then the appropriate RAM location is set to 1 only on the depression transition of the button; additional calls will return 0, until the button is released and then depressed again.



DP = $D0

A-reg = mask (for Read_Btns_Mask only)



A-reg = button transition state (same as $C811)

B-reg, X-reg trashed