-
Notifications
You must be signed in to change notification settings - Fork 1
/
conout.asm
379 lines (327 loc) · 6.6 KB
/
conout.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
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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
* vi:ts=8
*
****************
XDEF ConOut,f_norm
XDEF FIndent,LineA,SInfo
INCLUDE 'conout.i'
XREF putchar,scl_up,scl_dn,del_all,del_chr,del_bol,del_eol
XREF SndBel,SndNoise
DELAY EQU 5
Section TEXT
ConOut: move.l LineA,a5
lea SInfo,a6
clr.w $452 Cursor off!
move.b #DELAY,v_cur_tim(a5)
btst.b #S_CREV,v_status(a5)
beq 1$
bclr.b #S_CREV,v_status(a5)
move.l v_cur_ad(a5),a0
not.b (a0)
not.b 80(a0)
not.b 160(a0)
not.b 240(a0)
not.b 320(a0)
not.b 400(a0)
not.b 480(a0)
not.b 560(a0)
not.b 640(a0)
not.b 720(a0)
not.b 800(a0)
not.b 880(a0)
not.b 960(a0)
not.b 1040(a0)
not.b 1120(a0)
not.b 1200(a0)
1$: move.l v_funct(a6),a0
move.l #f_norm,v_funct(a6)
jsr (a0)
move.w #1,$452
rte
f_norm: cmp.b #' ',d0
bcc _char
cmp.b #7,d0 Bel
beq _bel
cmp.b #8,d0 Back Space
beq _bs
cmp.b #9,d0 Horizontal Tab
beq _ht
cmp.b #10,d0 Line Feed
beq _lf
cmp.b #13,d0 Carrage Return
beq _cr
cmp.b #27,d0 Escape
beq _esc
rts
_bel: jmp SndBel
_bs: subq.w #1,v_cur_cx(a6)
bpl 1$
clr.w v_cur_cx(a6)
rts
1$: subq.l #1,v_cur_ad(a5)
rts
_ht: move.l v_cur_ad(a5),d0
sub.w v_cur_cx(a6),d0
move.w v_cur_cx(a6),d1
add.w #8,d1
and.w #$fff8,d1
cmp.w v_cel_mx(a6),d1
ble 1$
move.w v_cel_mx(a6),d1
1$: add.w d1,d0
move.l d0,v_cur_ad(a5)
move.w d1,v_cur_cx(a6)
rts
_lf: move.l v_cur_ad(a5),d0
add.w v_cel_wr(a6),d0
cmp.l v_scr_bot(a6),d0
blt 1$
jmp scl_up
1$: move.l d0,v_cur_ad(a5)
addq.w #1,v_cur_cy(a6)
rts
_cr: move.l v_cur_ad(a5),d0
sub.w v_cur_cx(a6),d0
move.l d0,v_cur_ad(a5)
clr.w v_cur_cx(a6)
rts
_char: jsr putchar
move.w v_cur_cx(a6),d0
cmp.w v_cel_mx(a6),d0
bge 2$
addq.w #1,v_cur_cx(a6)
addq.l #1,v_cur_ad(a5)
3$: rts
2$: btst.b #S_WRAP,v_status(a5)
beq 3$
bsr _cr
bra _lf
_esc: move.l #f_esc,v_funct(a6)
rts
****************
f_esc: cmp.b #'A',d0 Cursor up
beq _up
cmp.b #'B',d0 Cursor down
beq _dn
cmp.b #'C',d0 Cursor right
beq _ri
cmp.b #'D',d0 Cursor left
beq _bs
cmp.b #'E',d0 Clear screen
beq _cl
cmp.b #'G',d0 Set cursor position
beq _cm
cmp.b #'H',d0 Cursor home
beq _ho
cmp.b #'J',d0 Erase to end of page
beq _cd
cmp.b #'K',d0 Clear to end of line
beq _ce
cmp.b #'L',d0 Insert line
beq _al
cmp.b #'M',d0 Delete line
beq _dl
cmp.b #'N',d0 Erase to line start
beq _cb
cmp.b #'S',d0 Scroll region
beq _cs
cmp.b #'Z',d0 Indentify
beq _ID
cmp.b #'a',d0 Reverse mode
beq _mr
cmp.b #'b',d0 Dubbel mode
beq _md
cmp.b #'c',d0 Underline mode
beq _us
cmp.b #'d',d0 Dim mode
beq _mh
cmp.b #'e',d0 Show cursor
beq _ve
cmp.b #'f',d0 Hide cursor
beq _vi
cmp.b #'g',d0 More cursor
beq _vs
cmp.b #'j',d0 Save cursor
beq _sc
cmp.b #'k',d0 Restore cursor
beq _rc
cmp.w #'v',d0 No wrap
beq _RA
cmp.w #'w',d0 Wrap right margin
beq _SA
cmp.b #'q',d0 Normal mode
beq _me
cmp.b #7,d0 Visual bel
beq _vb
_RET rts
_up: move.l v_cur_ad(a5),d0
sub.w v_cel_wr(a6),d0
cmp.l v_scr_top(a6),d0
blt 1$
move.l d0,v_cur_ad(a5)
subq.w #1,v_cur_cy(a6)
1$: rts
_dn: move.l v_cur_ad(a5),d0
add.w v_cel_wr(a6),d0
cmp.l v_scr_bot(a6),d0
bge 1$
move.l d0,v_cur_ad(a5)
addq.w #1,v_cur_cy(a6)
1$: rts
_ri: move.w v_cur_cx(a6),d0
cmp.w v_cel_mx(a6),d0
bge 1$
addq.w #1,v_cur_cx(a6)
addq.l #1,v_cur_ad(a5)
1$: rts
_cl: clr.w v_cur_cx(a6)
clr.w v_cur_cy(a6)
move.l v_scr_ad(a6),v_cur_ad(a5)
jmp del_all
_cm: move.l #_cm1,v_funct(a6)
rts
_cm1: move.l #_cm2,v_funct(a6)
sub.b #32,d0
and.w #$ff,d0
move.w d0,v_arg1(a6)
rts
_cm2: move.w v_arg1(a6),d1
sub.b #32,d0
and.l #$ff,d0
cmp.w v_cel_mx(a6),d0
ble 1$
move.w v_cel_mx(a6),d0
1$: cmp.w v_cel_my(a6),d1
ble 2$
move.w v_cel_my(a6),d1
2$: move.w d0,v_cur_cx(a6)
move.w d1,v_cur_cy(a6)
mulu v_cel_wr(a6),d1
add.l d0,d1
add.l v_scr_ad(a6),d1
move.l d1,v_cur_ad(a5)
rts
_ho: clr.w v_cur_cx(a6)
clr.w v_cur_cy(a6)
move.l v_scr_ad(a6),v_cur_ad(a5)
rts
_cd: jsr del_eol
move.l v_cur_ad(a5),d0
sub.w v_cur_cx(a6),d0
add.w v_cel_wr(a6),d0
move.l v_scr_top(a6),-(sp)
move.l d0,v_scr_top(a6)
jsr del_all
move.l (sp)+,v_scr_top(a6)
rts
_ce: jmp del_eol
_al: move.l v_cur_ad(a5),d0
sub.w v_cur_cx(a6),d0
move.l d0,v_cur_ad(a5)
clr.w v_cur_cx(a6)
move.l v_scr_top(a6),-(sp)
move.l d0,v_scr_top(a6)
jsr scl_dn
move.l (sp)+,v_scr_top(a6)
rts
_dl: move.l v_cur_ad(a5),d0
sub.w v_cur_cx(a6),d0
move.l d0,v_cur_ad(a5)
clr.w v_cur_cx(a6)
move.l v_scr_top(a6),-(sp)
move.l d0,v_scr_top(a6)
jsr scl_up
move.l (sp)+,v_scr_top(a6)
rts
_cb: jmp del_bol
_cs: move.l #_cs1,v_funct(a6)
rts
_cs1: move.l #_cs2,v_funct(a6)
sub.b #32,d0
and.w #$ff,d0
move.w d0,v_arg1(a6)
rts
_cs2: move.w v_arg1(a6),d1
sub.b #32,d0
and.l #$ff,d0
cmp.w v_cel_my(a6),d0
ble 1$
move.w v_cel_my(a6),d0
1$: cmp.w v_cel_my(a6),d1
ble 2$
move.w v_cel_my(a6),d1
2$: cmp.w d0,d1
bgt 3$
beq 4$
exg d0,d1
3$: clr.w v_cur_cx(a6)
move.w d0,v_cur_cy(a6)
addq.w #1,d1
mulu v_cel_wr(a6),d0
mulu v_cel_wr(a6),d1
add.l v_scr_ad(a6),d0
add.l v_scr_ad(a6),d1
move.l d0,v_scr_top(a6)
move.l d1,v_scr_bot(a6)
move.l d0,v_cur_ad(a5)
4$: rts
_ID: move.w #-1,FIndent
rts
_mr: or.w #%0001,v_fnt_typ(a6)
move.w v_fnt_typ(a6),d0
asl.w #2,d0
move.l v_fnt_tab(a6),a0
move.l 0(a0,d0.w),v_fnt_ad(a6)
rts
_md: or.w #%0010,v_fnt_typ(a6)
move.w v_fnt_typ(a6),d0
asl.w #2,d0
move.l v_fnt_tab(a6),a0
move.l 0(a0,d0.w),v_fnt_ad(a6)
rts
_us: or.w #%0100,v_fnt_typ(a6)
move.w v_fnt_typ(a6),d0
asl.w #2,d0
move.l v_fnt_tab(a6),a0
move.l 0(a0,d0.w),v_fnt_ad(a6)
rts
_mh: or.w #%1000,v_fnt_typ(a6)
move.w v_fnt_typ(a6),d0
asl.w #2,d0
move.l v_fnt_tab(a6),a0
move.l 0(a0,d0.w),v_fnt_ad(a6)
rts
_me: clr.w v_fnt_typ(a6)
move.w v_fnt_typ(a6),d0
asl.w #2,d0
move.l v_fnt_tab(a6),a0
move.l 0(a0,d0.w),v_fnt_ad(a6)
rts
_ve: bset.b #S_CVIS,v_status(a5)
rts
_vi: bclr.b #S_CVIS,v_status(a5)
rts
_vs: bset.b #S_CVIS,v_status(a5) NOT IMPLEMENTED
rts
_sc: move.l v_cur_ad(a5),v_sav_ad(a6)
move.w v_cur_cx(a6),v_sav_cx(a6)
move.w v_cur_cy(a6),v_sav_cy(a6)
bset.b #S_SCUR,v_status(a5)
rts
_rc: btst.b #S_SCUR,v_status(a5)
beq 1$
move.l v_sav_ad(a6),v_cur_ad(a5)
move.w v_sav_cx(a6),v_cur_cx(a6)
move.w v_sav_cy(a6),v_cur_cy(a6)
bclr.b #S_SCUR,v_status(a5)
1$: rts
_RA: bclr.b #S_WRAP,v_status(a5)
rts
_SA: bset.b #S_WRAP,v_status(a5)
rts
_vb: bra _bel NOT IMPLEMENTED
****************
Section BSS
FIndent ds.w 1
LineA ds.l 1
SInfo ds.l 25
END