-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjoystick-tiny.asm
185 lines (182 loc) · 2.22 KB
/
joystick-tiny.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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
// Variable Labels
.label general8bit = $0334
.label portA = $0335
.label btnPressA = $0336
.label north = $0337
.label south = $0338
.label east = $0339
.label west = $033A
* = $0801
BasicUpstart($080D)
* = $080D
lda #$01
sta general8bit
lda $02
pha
lda $03
pha
php
clc
LBL1L1: // Top of WHILE Loop
lda general8bit // $0334
cmp #$00
.byte $D0, $03 // BNE +3
jmp LBL1L3 // if z==1 jump to ELSE
jsr shortcls
jsr getJoystickA
lda $02
pha
lda $03
pha
php
clc
lda btnPressA // $0336
cmp #$00
.byte $F0, $03 // BEQ +3
jmp LBL2L3 // jump to ELSE
lda $02
pha
lda $03
pha
lda #<STRLBL0
sta $02
lda #>STRLBL0
sta $03
jsr PRN
pla
sta $03
pla
sta $02
LBL2L3:
clc
lda north // $0337
cmp #$00
.byte $F0, $03 // BEQ +3
jmp LBL2L8 // jump to ELSE
lda $02
pha
lda $03
pha
lda #<STRLBL1
sta $02
lda #>STRLBL1
sta $03
jsr PRN
pla
sta $03
pla
sta $02
LBL2L8:
clc
lda south // $0338
cmp #$00
.byte $F0, $03 // BEQ +3
jmp LBL2L13 // jump to ELSE
lda $02
pha
lda $03
pha
lda #<STRLBL2
sta $02
lda #>STRLBL2
sta $03
jsr PRN
pla
sta $03
pla
sta $02
LBL2L13:
clc
lda west // $033A
cmp #$00
.byte $F0, $03 // BEQ +3
jmp LBL2L18 // jump to ELSE
lda $02
pha
lda $03
pha
lda #<STRLBL3
sta $02
lda #>STRLBL3
sta $03
jsr PRN
pla
sta $03
pla
sta $02
LBL2L18:
clc
lda east // $0339
cmp #$00
.byte $F0, $03 // BEQ +3
jmp LBL2L23 // jump to ELSE
lda $02
pha
lda $03
pha
lda #<STRLBL4
sta $02
lda #>STRLBL4
sta $03
jsr PRN
pla
sta $03
pla
sta $02
LBL2L23:
plp
pla
sta $03
pla
sta $02
jmp LBL1L1 // jump to top of WHILE loop
LBL1L3:
plp
pla
sta $03
pla
sta $02
rts
getJoystickA:
lda $DC00
sta portA // 0335
lda #$10
and $0335
sta btnPressA // 0336
lda #$01
and $0335
sta north // 0337
lda #$02
and $0335
sta south // 0338
lda #$04
and $0335
sta west // 033A
lda #$08
and $0335
sta east // 0339
rts
shortcls:
lda #$93
jsr $FFD2
rts
PRN:
ldy #$00
PRN_LOOP:
lda ($02),Y
beq PRN_END
jsr $FFD2
iny
jmp PRN_LOOP
PRN_END:
rts
STRLBL0: // "FIRE "
.byte $46, $49, $52, $45, $20, $00
STRLBL1: // "N"
.byte $4E, $00
STRLBL2: // "S"
.byte $53, $00
STRLBL3: // "W"
.byte $57, $00
STRLBL4: // "E"
.byte $45, $00