-
Notifications
You must be signed in to change notification settings - Fork 0
/
keys.asm
154 lines (141 loc) · 2.53 KB
/
keys.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
.no $0120
; STACK .eq $2
; PC_MAIN .eq $3
; R_VAR_PTR .eq $8 ; Upper byte = $0D
; R_WORK_PTR .eq $9 ; Upper byte = $0D
R_KEYS_TMP_PTR .eq $F
.do TARGET=TARGET_VIP
KEY_PORT .eq 2
.fi
.do TARGET=TARGET_ELF
KEY_PORT .eq 4
.fi
; VIP
; 3: left, C: right
; 0: up(accel), A: down(brake)
; ELF
; 0, 1, 2, 4, 6, 8, 9, A: left and brake, etc
; "EF Hex Key" needed.
; variables V_KEY_LEFT, V_KEY_RIGHT, V_KEY_DOWN, V_KEY_UP must be in this order.
GET_KEYS
LDI #V_KEY_LEFT+3
PLO R_VAR_PTR
SEX R_VAR_PTR
LDI $00
STXD
STXD
STXD
STR R_VAR_PTR
.do TARGET=TARGET_VIP
SEX STACK
DEC STACK
LDI $03
STR STACK
OUT KEY_PORT
BN3 GET_KEYS_SKIP_LEFT
STR R_VAR_PTR
GET_KEYS_SKIP_LEFT
INC R_VAR_PTR
DEC STACK
LDI $0C
STR STACK
OUT KEY_PORT
BN3 GET_KEYS_SKIP_RIGHT
STR R_VAR_PTR
GET_KEYS_SKIP_RIGHT
INC R_VAR_PTR
DEC STACK
LDI $0A
STR STACK
OUT KEY_PORT
BN3 GET_KEYS_SKIP_DOWN
STR R_VAR_PTR
GET_KEYS_SKIP_DOWN
INC R_VAR_PTR
DEC STACK
LDI $00
STR STACK
OUT KEY_PORT
BN3 GET_KEYS_SKIP_UP
LDI $10
STR R_VAR_PTR
GET_KEYS_SKIP_UP
.fi
.do TARGET=TARGET_ELF
BN3 GET_KEYS_EXIT
SEX STACK
INP KEY_PORT
ANI $0F
STR STACK
GET_KEYS_LEFT
BZ GET_KEYS_LEFT_1
SMI $04
BZ GET_KEYS_LEFT_1
SMI $04
BZ GET_KEYS_LEFT_1
BR GET_KEYS_RIGHT
GET_KEYS_LEFT_1
LDI $01
STR R_VAR_PTR
GET_KEYS_RIGHT
INC R_VAR_PTR
LDN STACK
SMI $02
BZ GET_KEYS_RIGHT_1
SMI $04
BZ GET_KEYS_RIGHT_1
SMI $04
BZ GET_KEYS_RIGHT_1
BR GET_KEYS_DOWN
GET_KEYS_RIGHT_1
LDI $01
STR R_VAR_PTR
GET_KEYS_DOWN
INC R_VAR_PTR
LDN STACK
BZ GET_KEYS_DOWN_1
SMI $01
BZ GET_KEYS_DOWN_1
SMI $01
BZ GET_KEYS_DOWN_1
BR GET_KEYS_UP
GET_KEYS_DOWN_1
LDI $01
STR R_VAR_PTR
GET_KEYS_UP
INC R_VAR_PTR
LDN STACK
SMI $08
BZ GET_KEYS_UP_1
SMI $01
BZ GET_KEYS_UP_1
SMI $01
BZ GET_KEYS_UP_1
BR GET_KEYS_EXIT
GET_KEYS_UP_1
LDI $01
STR R_VAR_PTR
.fi
GET_KEYS_EXIT
SEP PC_MAIN
; wait for any key to be pressed
WAIT_ANY_KEY
.do TARGET=TARGET_VIP
SEX STACK
DEC STACK
LDI $00
WAIT_ANY_KEY_LOOP
STR STACK
OUT 2
B3 WAIT_ANY_KEY_EXIT
DEC STACK
ADI $01
ANI $0F
BR WAIT_ANY_KEY_LOOP
.fi
.do TARGET=TARGET_ELF
WAIT_ANY_KEY_LOOP
BN3 WAIT_ANY_KEY_LOOP
.fi
WAIT_ANY_KEY_EXIT
SEP PC_MAIN