-
Notifications
You must be signed in to change notification settings - Fork 0
/
fst.macros
274 lines (200 loc) · 2.57 KB
/
fst.macros
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
; dispatch table for variable-pcount structures.
MACRO
&lab dispatch &table
&lab
@loop
ldy &table,x
jsr (&table+2,x)
dex
dex
dex
dex
bpl @loop
MEND
MACRO
str.&size ; &arg, ...
lclc &str
lcla &i, &l
&str setc &setting('string')
STRING asis
if &size<>'' THEN
dc.&size @end-@start
ENDIF
@start
&i seta 1
&l seta &nbr(&syslist)
WHILE &i<=&l DO
dc.b &syslist[&i]
&i seta &i+1
ENDWHILE
@end
STRING &str
MEND
MACRO
long &p1,&p2
lcla &bits
&bits seta %00000000
;&p1 setc &lc(&p1)
;&p2 setc &lc(&p2)
if &p1='m' OR &p2='m' THEN
&bits seta &bits+%00100000
longa on
ENDIF
if &p1='x' OR &p2='x' THEN
&bits seta &bits+%00010000
longi on
ENDIF
IF &bits<>0 THEN
rep #&bits
ENDIF
MEND
MACRO
short &p1,&p2
lcla &bits
&bits seta %00000000
;&p1 setc &lc(&p1)
;&p2 setc &lc(&p2)
if &p1='m' OR &p2='m' THEN
&bits seta &bits+%00100000
longa off
ENDIF
if &p1='x' OR &p2='x' THEN
&bits seta &bits+%00010000
longi off
ENDIF
IF &bits<>0 THEN
sep #&bits
ENDIF
MEND
macro
&l ~ConvSeconds &p1,&p2,&p3
&l ph2 &p1
ph4 &p2
ph4 &p3
ldx #$3703
jsl $E10000
mend
macro
&l ~Long2Hex &p1,&p2,&p3
&l ph4 &p1
ph4 &p2
ph2 &p3
ldx #$230B
jsl $E10000
mend
macro
&l ~Int2Hex &p1,&p2,&p3
&l ph2 &p1
ph4 &p2
ph2 &p3
ldx #$220B
jsl $E10000
mend
macro
&l _DebugHexDump
&l ldx #$0fff
jsl $e10000
mend
macro
&l ~DebugHexDump &p1,&p2
&l ph4 &p1
ph2 &p2
ldx #$0fff
jsl $e10000
mend
macro
&l _DebugGetTrace
&l ldx #$10ff
jsl $e10000
mend
macro
&l ~DebugGetTrace
&l ldx #$10ff
jsl $e10000
mend
macro
&l _DebugSetTrace
&l ldx #$11ff
jsl $e10000
mend
macro
&l ~DebugSetTrace &p1
&l ph2 &p1
ldx #$11ff
jsl $e10000
mend
; borrowed from orca/m
; mpw's pushword/pushlong have bugs and generally sucks
MACRO
ph2 &n1
IF &n1='*' THEN
MEXIT
ENDIF
IF &n1[1:1]='#' THEN
pea &n1[2:255]
MEXIT
ENDIF
IF &n1[1:1]='<' THEN
pei &n1
MEXIT
ENDIF
lda &n1
pha
MEND
MACRO
ph4 &n1
IF &n1='*' THEN
MEXIT
ENDIF
IF &n1[1:1]='#' THEN
pea |(&n1[2:255])>>16
pea |&n1[2:255]
MEXIT
ENDIF
IF &n1[1:1]='<' THEN
pei &n1+2
pei &n1
MEXIT
ENDIF
lda &n1+2
pha
lda &n1
pha
MEND
; _rts.cc -> return iff carry clear
macro
&l _rts.&cond
if &cond='cc' THEN
bcs @ok
ENDIF
if &cond='cs' THEN
bcc @ok
ENDIF
if &cond='eq' THEN
bne @ok
ENDIF
if &cond='ne' THEN
beq @ok
ENDIF
if &cond='mi' THEN
bpl @ok
ENDIF
if &cond='pl' THEN
bmi @ok
ENDIF
if &cond='vs' THEN
bvc @ok
ENDIF
if &cond='vc' THEN
bvs @ok
ENDIF
rts
@ok
mend
; reverse subtract.
macro
&l rsb &target
eor #$ffff
sec
adc &target
mend