summaryrefslogtreecommitdiff
path: root/system/shard-z80-ruc-64180/1.5/src/CONOUT4.INC
blob: 9ffda133590cf3b1c21ddfee801462af917e9dbc (plain)
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
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466

;
; CONOUT4.INC
;
; Character auf BASIS 108 80-Zeichen ausgeben
;
; Copyright (c) 1985 by Joerg Stattaus
;
; Modified for psi by R. Ellerbrake
;
; C=char
;
; Version 17.09.85
;	Stand: 22.12.86, mit Zeichensatzeinstellung (M.St)
;	       31.12.86, Mod. fuer 6502-Teil > 0C00
;

crtout:	
	ld	hl,gotocnt	; GotoXY in Aktion ?
	ld	a,(hl)
	or	a
	jr	z,crt2

	dec	(hl)
	ld	a,c
	jr	z,crt1		; Get X-Value

	ld	(gotoy),a	; Y storen
	ret	

crt1:	ld	(gotox),a

	ld      b,7             ; Gotoxy is Function 7
	jr      conq

crt2:
	ld      b,a
	ld	a,c

crt3:	cp	' '
	jr      nc,conq		; normales Zeichen

crt4:	ld      hl,scrfen       ; In Tabelle nach Zeichen suchen
	ld      b,22            
crt5:	cp	(hl)          
	jr      z,crtfnd	; Sequenz erkannt

	dec     hl              
	djnz    crt5

	ret			; nicht in der Tabelle enthalten

crtfnd: ld      a,b		; Found
	cp      7
	jr      nz,conq       
;
	ld      a,2
	ld      (gotocnt),a	; next 2 Bytes sind Koordinaten
	RET

SWICUR:
	LD	B,23		; Cursor invertieren
conq:
	LD	A,I		; IEF2 retten
	PUSH	AF
	DI			; keine Interrupts zulassen
;
	in0	a,(cbar)	; Set CommonBaseAreaRegister for Video
	ld	(oldcbar),a
	ld	a,biosbank
	out0	(cbar),a
;
	IN0	A,(BBR)		; Set Bank Base Register
	LD	(OLDBBR),A
	LD	A,AR6502
	OUT0	(BBR),A
;
	LD	(STKSAV),SP	; alten SP retten (im umgeschalteten Bereich)
	LD	SP,STACK
;
	CALL	CONQ1		; Print Char. on screen
;
	LD	SP,(STKSAV)	; alten Stack zurueckholen
;
	LD	A,(OLDBBR)	; restore old BBR
	OUT0	(BBR),A
	ld	a,(oldcbar)	; and CBAR
	out0	(cbar),a
	POP	AF		; IEF2 zurueckholen
	RET	PO		; vorher kein EI ->
;
	EI			;reenable Interrupts
	RET
	
; B=Sequenz / C=Char

conq1:	ld      hl,(scradr)
	ld      de,(scrxy)
	ld      a,e
	rra

	CALL	ZGERL		; Zugriff erlaubt ?
	ld	(stram1),a	; Dyn./Static RAM
	jr	nc,conq2
	ld	(stram2),a
conq2:  
	ld	a,b
	or	a
	jr	nz,scrfkt	; Screen-Function

	ld	a,(invmod)	; schreibe Zeichen auf Bildschirm
	or	c
	ld	(hl),a
adv0:   ex	de,hl
	inc	hl
	ld	a,l
	cp	80
	jp	c,onlinc

	ld      l,0
	inc     h
	ld      a,h
	cp      24
	jp      c,calc

	; scroll noetig

	ld      l,0
scroll: dec	h
	push    hl
	ld      d,0
	call    del0		; delete Zeile 0

	pop     hl
calc:   ld      (scrxy),hl
	ld      e,l
	ld      a,h
	call    basclc
	ld      a,e     	; hl=lineadr / a=scrxyr
	srl	a

	ld      (stram1),a
	jr      nc,calc3
	ld      (stram2),a
calc3:  
	add     a,l
	ld      l,a
calc4:  ld      (scradr),hl
calc5:  ld      a,(hl)  	; get char on cursor adr
	ld      (curchr),a
	ld      a,(curinv)
	xor     (hl)
	ld      (hl),a  	; invers zurueck
	ld      (stram1),a

crtret:	ret

onlinc: ld      (scrxy),a	; normales increment des scr.poi.
	ex      de,hl           ; HL wieder = scradr
	rra

	ld      (stram2),a
	jr      c,calc5         ; selbe Adresse, 2. Seite
	ld      (stram1),a
	inc     hl
	jr      calc4

scrfkt: ld	a,(curchr)	; Restore Char on Screen
	ld	(hl),a
	ld	a,b
	ld      hl,scrtab-2
	add     a,a
	add     a,l
	ld      l,a
	LD	A,H		; cross page boundary ?
	ADC	A,0
	LD	H,A
	ld      a,(hl)
	inc     hl
	ld      h,(hl)
	ld      l,a
	jp      (hl)

; Screen-Functions

advanc: ld      hl,(scradr)
	jr      adv0

schome: ld      hl,0
	jr      tocalc

gotoxy: ld      hl,(gotox)	; H=Y / L=X
got0:   ld      a,h
	cp      24
	jr      c,got1
	
	ld      h,0
got1:   ld      a,l
	cp      80
	jr      c,tocalc

got2:   ld      l,0
	jr      tocalc

up:     ex      de,hl
	dec     h
	jr      got0

carret: ex      de,hl
	jr      got2

backsp: ex      de,hl
	dec     hl
	ld      a,l
	cp      80
	jr      c,tocalc

	ld      l,79
	jr      got0

linefd: ex      de,hl
	inc     h
	ld      a,h
	cp      24
	jr      c,tocalc

	jp      scroll

erapag: push    de
	call    erap0
	pop     hl
tocalc: jp      calc

eralin: push    de
	call    eral2
	pop     hl
	jr      tocalc

insert: push    de
	ld      a,d		; korrigiert
	ld      de,SCREEN+003d0h ; Zeile 23
	cp	23
	jr      z,ins1          ; kein Verschieben

	ld      b,23
ins0:   dec     b
	call    linmov
	ld      a,(scrxy+1)	; Vertikal Adresse
	cp      b
	jr      nz,ins0

ins1:   call    blank
	pop     hl
	jr      got2

delete: push    de
	call    del0
	pop     hl
	jr      got2

normal: ld      a,80h
	jr      inv1

invers: xor     a
inv1:   ld      (invmod),a
;
inv2:   ex      de,hl
	jr      tocalc

chacur: ld      hl,curinv
	ld      a,(hl)
	xor     80h
	ld      (hl),a
	jr      inv2

clear:  call    schome
	ld      de,0
	push    de
	call    erap0
	pop     hl
	jr      tocalc

bell:   push	hl
	ld	a,(BEEPFRQ)
	ld	h,a
	ld	l,2		; task beep
	call	to6502
	pop	hl		; transport scrxy to HL
	ret

eral2:  ld      hl,(scradr)
	push    hl
	ld      (stram1),a
	ld      a,e
	srl     a
	jr      nc,eral3

	inc     a
	inc     hl
eral3:  call    erablk
	
	ld      (stram2),a
	pop     hl
	ld      a,e
	srl     a
erablk: sub     41
	cpl
	ld      b,0a0h
erabl1: or	a
	ret	z
	ld      (hl),b
	inc     hl
	dec     a
	jr      erabl1

erap0:  call    eral2
	ld      a,(scrxy+1)
erap1:  inc     a
	cp      24
	ret     nc

	push    af
	call    basclc
	
	ex      de,hl
	call    blank
	pop     af
	jr      erap1

del0:   ld      a,d
	cp      23
	ld      de,SCREEN+003d0h  ; Zeile 23
	jr      z,blank

	push    af
	call    basclc
	pop     bc              ; Vert. Adr. von D -> A -> B

	ex      de,hl
del1:   inc	b
	call    linmov
	ld      a,b
	cp      23
	jr      c,del1

blank:  ld      (stram1),a
	ld      a,' '+80h
	push    de
	call    blank1
	pop     de
	ld      (stram2),a

blank1: ld      b,40
blank2: ld      (de),a
	inc     de
	djnz    blank2

	ret

linmov: push    bc
	ld      a,b
	call    basclc
	ld      (stram1),a
	push    hl
	push    de
	ld      bc,40
	ldir                    ; eine Zeile
	pop     de
	pop     hl
	push    hl
	ld      (stram2),a
	ld      bc,40
	ldir
	pop     de              ; HL nun in DE = neues Ziel
	pop     bc
	ret

basclc: ld      c,a
	ld      l,0
	rra
	rr      l
	and     3
	add     a,HIGH SCREEN	; screen - start
	ld      h,a
	ld      a,c
	and     18h
	ld      c,a
	add     a,a
	add     a,a
	add     a,c             ; * 5 = 40
	add     a,l
	ld      l,a
	ret                     ; HL = Line adress

ger:				; German ASCII
	ld	(sw0off),a
	ld	(sw1on),a
	ld	(sw2off),a
	ret

usa:				; ASCII
	ld	(sw0off),a
	ld	(sw1off),a
	ld	(sw2on),a
	ret

apl:				; APL
	ld	(sw0off),a
	ld	(sw1on),a
	ld	(sw2on),a
	ret

uni:				; ASCII und Inv. APL
	ld	(sw0on),a
	ld	(sw1on),a
	ld	(sw2on),a
	ret

invsw:
	ld	(swinv),a
	ret

flshsw:
	ld	(swflsh),a
	ret

; Screen-Command-Definition-Table

;leadsf:db	1bh
;	db	0aah,0d9h,0d4h,0a9h,0a8h,1eh,0bdh,0bh,0ch
;	db	0ah,08h,0dh,0cch,0cdh,0dah,07h
;
;	EUMEL psi-Terminal Definition
;
	DEFB	9		;Clear Screen (bei psi undefiniert)
	DEFB	4		;Clear to End of Page
	DEFB	5		;Erase to End-of-Line
	DEFB	14		;Endmark (Normal Video)
	DEFB	15		;Beginmark (Invers Video)
	DEFB	1		;Home
	DEFB	6		;Cursor Positionierung
	DEFB	3		;Cursor 1 Zeile nach oben
	DEFB	2		;Cursor nach rechts
	DEFB	10		;Line feed
	DEFB	8		;Backspace
	DEFB	13		;Carriage Return
	DEFB	11		;Insert Line (bei psi undefiniert)
	DEFB	12		;Delete Line (bei psi undefiniert)
	DEFB	0		;NULL (nichts tun)
	DEFB	7		;BELL
	DEFB	16		;GER, Zeichensatz
	DEFB	17		;USA,     "
	DEFB	18		;APL,     "
	DEFB	19		;UNI, 	  "
	DEFB	20		;Invers > 127
	DEFB	21		;Flash > 127

scrfen	equ	$-1

scrtab: dw      clear,erapag,eralin,normal,invers,schome,gotoxy,up,advanc
	dw      linefd,backsp,carret,insert,delete,CRTRET,bell
	dw	ger,usa,apl,uni,invsw,flshsw,chacur
;
;	CRTRET anstelle von chacur

; Ende von CONOUT3.INC