-
Notifications
You must be signed in to change notification settings - Fork 0
/
cda.mac
247 lines (247 loc) · 3 KB
/
cda.mac
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
MACRO
&lab _DisposeHandle
&lab ldx #$1002
jsl $E10000
MEND
MACRO
&lab _MMStartUp
&lab ldx #$0202
jsl $E10000
MEND
MACRO
&lab _GetInGlobals
&lab ldx #$0C0C
jsl $E10000
MEND
MACRO
&lab _GetInputDevice
&lab ldx #$120C
jsl $E10000
MEND
MACRO
&lab _GetOutGlobals
&lab ldx #$0D0C
jsl $E10000
MEND
MACRO
&lab _GetOutputDevice
&lab ldx #$130C
jsl $E10000
MEND
MACRO
&lab _SetInGlobals
&lab ldx #$090C
jsl $E10000
MEND
MACRO
&lab _SetInputDevice
&lab ldx #$0F0C
jsl $E10000
MEND
MACRO
&lab _SetOutGlobals
&lab ldx #$0A0C
jsl $E10000
MEND
MACRO
&lab _SetOutputDevice
&lab ldx #$100C
jsl $E10000
MEND
MACRO
&lab _EMStatus
&lab ldx #$0606
jsl $E10000
MEND
macro
&l ~GetNextEvent &p1,&p2
&l ph2 &p1
ph4 &p2
ldx #$0A06
jsl $E10000
mend
macro
&l ~NewHandle &p1,&p2,&p3,&p4
&l ph4 &p1
ph2 &p2
ph2 &p3
ph4 &p4
ldx #$0902
jsl $E10000
mend
macro
&l ~InitTextDev &p1
&l ph2 &p1
ldx #$150C
jsl $E10000
mend
macro
&l ~SetInGlobals &p1,&p2
&l ph2 &p1
ph2 &p2
ldx #$090C
jsl $E10000
mend
macro
&l ~SetInputDevice &p1,&p2
&l ph2 &p1
ph4 &p2
ldx #$0F0C
jsl $E10000
mend
macro
&l ~SetOutGlobals &p1,&p2
&l ph2 &p1
ph2 &p2
ldx #$0A0C
jsl $E10000
mend
macro
&l ~SetOutputDevice &p1,&p2
&l ph2 &p1
ph4 &p2
ldx #$100C
jsl $E10000
mend
macro
&l ~WriteChar &p1
&l ph2 &p1
ldx #$180C
jsl $E10000
mend
macro
&l dw &adr
&l dc i1"l:~&SYSNAME&SYSCNT"
~&SYSNAME&SYSCNT dc c"&adr"
mend
macro
&l long &a,&b
lclb &i
lclb &m
&a amid &a,1,1
&m setb ("&a"="M").or.("&a"="m")
&i setb ("&a"="I").or.("&a"="i")
aif c:&b=0,.a
&b amid &b,1,1
&m setb ("&b"="M").or.("&b"="m").or.&m
&i setb ("&b"="I").or.("&b"="i").or.&i
.a
&l rep #&m*32+&i*16
aif .not.&m,.b
longa on
.b
aif .not.&i,.c
longi on
.c
mend
macro
&l ph2 &n1
&l anop
aif "&n1"="*",.f
lclc &c
&c amid &n1,1,1
aif "&c"="#",.d
aif s:longa=1,.a
rep #%00100000
.a
aif "&c"<>"{",.b
&c amid &n1,l:&n1,1
aif "&c"<>"}",.g
&n1 amid &n1,2,l:&n1-2
lda (&n1)
pha
ago .e
.b
aif "&c"="<",.c
lda &n1
pha
ago .e
.c
&n1 amid &n1,2,l:&n1-1
pei &n1
ago .e
.d
&n1 amid &n1,2,l:&n1-1
pea &n1
ago .f
.e
aif s:longa=1,.f
sep #%00100000
.f
mexit
.g
mnote "Missing closing '}'",16
mend
macro
&l ph4 &n1
&l anop
aif "&n1"="*",.f
lclc &c
&c amid &n1,1,1
aif "&c"="#",.d
aif s:longa=1,.a
rep #%00100000
.a
aif "&c"<>"{",.b
&c amid &n1,l:&n1,1
aif "&c"<>"}",.g
&n1 amid &n1,2,l:&n1-2
ldy #2
lda (&n1),y
pha
lda (&n1)
pha
ago .e
.b
aif "&c"<>"[",.c
ldy #2
lda &n1,y
pha
lda &n1
pha
ago .e
.c
aif "&c"<>"<",.c1
&n1 amid &n1,2,l:&n1-1
pei &n1+2
pei &n1
ago .e
.c1
lda &n1+2
pha
lda &n1
pha
ago .e
.d
&n1 amid &n1,2,l:&n1-1
pea +(&n1)|-16
pea &n1
ago .f
.e
aif s:longa=1,.f
sep #%00100000
.f
mexit
.g
mnote "Missing closing '}'",16
mend
macro
&l short &a,&b
lclb &i
lclb &m
&a amid &a,1,1
&m setb ("&a"="M").or.("&a"="m")
&i setb ("&a"="I").or.("&a"="i")
aif c:&b=0,.a
&b amid &b,1,1
&m setb ("&b"="M").or.("&b"="m").or.&m
&i setb ("&b"="I").or.("&b"="i").or.&i
.a
&l sep #&m*32+&i*16
aif .not.&m,.b
longa off
.b
aif .not.&i,.c
longi off
.c
mend