-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWASDDetector.asm
65 lines (47 loc) · 1.32 KB
/
WASDDetector.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
;; 6502 W/A/S/D detector
LDA #0 ; Set the lower byte
STA $01
LDA #2 ; Set the higher byte
STA $02
LDX #6 ; Set X to immediate 0
LDY #$00
Loop:
LDA $ff ; Load the last pressed key into A
CMP $00 ; Check if the new key is the same as the old key
BEQ Loop ; This is the same, go back to the beginning of the loop
STA $00 ; Save the new key into the pointer
;; Check the game controls
CMP #$77 ; Up (Idk how variables work yet)
BEQ GoingUp
CMP #$61 ; Left
BEQ GoingLeft
CMP #$73 ; Down
BEQ GoingDown
CMP #$64 ; Right
BEQ GoingRight
JMP Loop ; Listen for another key
;; Functions
GoingUp:
LDA #$2
JMP Increment ; Increment the pointer properly
GoingLeft:
LDA #$7
JMP Increment ; Increment the pointer properly
GoingDown:
LDA #$5
JMP Increment ; Increment the pointer properly
GoingRight:
LDA #$6
; Increment the pointer properly
Increment:
STA ($01), Y ; Store the colour into the GPU
INC $01 ; Increment the lower address byte
CPY $01 ; Check if the lower byte is immediate 0
BNE Loop ; If not, restart loop
INC $02 ; If so, increment higher address byte
CPX $02 ; Check if the higher byte is immediate 6
BNE Loop ; If not, restart loop
LDY #$02
STY $02 ; If so, reset it to immediate 2
LDY #$00
BEQ Loop ; Restart loop