@@ -11,37 +11,37 @@ wNewKeys:: db
1111SECTION "UpdateKeys" , ROM0
1212
1313UpdateKeys::
14- ; Poll half the controller
15- ld a , JOYP_GET_BUTTONS
16- call .onenibble
17- ld b , a ; B7-4 = 1; B3-0 = unpressed buttons
18-
19- ; Poll the other half
20- ld a , JOYP_GET_CTRL_PAD
21- call .onenibble
22- swap a ; A3-0 = unpressed directions; A7-4 = 1
23- xor a , b ; A = pressed buttons + directions
24- ld b , a ; B = pressed buttons + directions
25-
26- ; And release the controller
27- ld a , JOYP_GET_NONE
28- ldh [ rJOYP ], a
29-
30- ; Combine with previous wCurKeys to make wNewKeys
31- ld a , [ wCurKeys ]
32- xor a , b ; A = keys that changed state
33- and a , b ; A = keys that changed to pressed
34- ld [ wNewKeys ], a
35- ld a , b
36- ld [ wCurKeys ], a
37- ret
14+ ; Poll half the controller
15+ ld a , JOYP_GET_BUTTONS
16+ call .onenibble
17+ ld b , a ; B7-4 = 1; B3-0 = unpressed buttons
18+
19+ ; Poll the other half
20+ ld a , JOYP_GET_CTRL_PAD
21+ call .onenibble
22+ swap a ; A3-0 = unpressed directions; A7-4 = 1
23+ xor a , b ; A = pressed buttons + directions
24+ ld b , a ; B = pressed buttons + directions
25+
26+ ; And release the controller
27+ ld a , JOYP_GET_NONE
28+ ldh [ rJOYP ], a
29+
30+ ; Combine with previous wCurKeys to make wNewKeys
31+ ld a , [ wCurKeys ]
32+ xor a , b ; A = keys that changed state
33+ and a , b ; A = keys that changed to pressed
34+ ld [ wNewKeys ], a
35+ ld a , b
36+ ld [ wCurKeys ], a
37+ ret
3838
3939.onenibble
40- ldh [ rJOYP ], a ; switch the key matrix
41- call .knownret ; burn 10 cycles calling a known ret
42- ldh a , [ rJOYP ] ; ignore value while waiting for the key matrix to settle
43- ldh a , [ rJOYP ]
44- ldh a , [ rJOYP ] ; this read counts
45- or a , $ F0 ; A7-4 = 1; A3-0 = unpressed keys
40+ ldh [ rJOYP ], a ; switch the key matrix
41+ call .knownret ; burn 10 cycles calling a known ret
42+ ldh a , [ rJOYP ] ; ignore value while waiting for the key matrix to settle
43+ ldh a , [ rJOYP ]
44+ ldh a , [ rJOYP ] ; this read counts
45+ or a , $ F0 ; A7-4 = 1; A3-0 = unpressed keys
4646.knownret
47- ret
47+ ret
0 commit comments