summaryrefslogtreecommitdiff
path: root/system/shard-x86-at/7/src/PCSCREEN.ASM
blob: 62d37eb15aa9c875cca92116138179a01a756288 (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
;***************************************************************************
;*======= Copyright (C) 1985,86 Martin Schoenbeck, Spenge =================*
;*                                                                         *
;*   Behandlung des PC Bildschirms und der Tastatur                        *
;*                                                                         *
;***************************************************************************

     device pc

     dtcbroutines iocontrol
     routine 1,devicetype
     routine 2,frout_ok
     routine 5,nil_size
     routine 6,priv_op_question
     routine 8,priv_op_question
     routine 9,priv_op_question
     routine -3,set_attribute
     routine -4,set_palette
     routine -5,switch_mode
     routine -6,draw
     routine -7,move
     routine -8,pen
     routine -9,new_pen1
     routine -10,new_pen2
     routine -11,mask_mode

     routine -1,unknowncontrol

     dtcbroutines control32
     routine -2,pc_init
     routine -1,no_channel_setup

     dtcbroutines blockin
     dtcbroutines blockout
     routine -1,unknowncontrol

     dtcbparams pc_output,3   ;typ = nur stream io


;***************************************************************************

pc_init:
breakaddress    equ     01bh*4  ;tastatur break adresse 
     mov bx,0
     mov es,bx                ;in die interrupt vektoren zeigen
     mov word ptr es:[breakaddress+2],cs
     mov word ptr es:[breakaddress],offset breakint
     mov dx,0                 ;cursor in die obere ecke 
     mov bh,0
     mov ah,2                 ;cursor setzen
     int 10h
     mov ax,0600h             ;clear entire window
     mov cx,0                 ;von oben
     mov dx,25*256+80         ;bis unten
     mov bh,7                 ;attribut
     int 10h 
     ret

;
breakint:
                push cx
                push ax
                push ds
                push cs
                pop ds
;               mov al,1
;               mov ch,'i'
;               call inputinterrupt
                mov al,1
                mov ch,2            ;sv
                call inputinterrupt
                pop ds
                pop ax
                pop cx
                iret
;
;
;
REVERS          EQU     01110000B       ;ATTRIBUT FUER REVERS-VIDEO
NORMAL          EQU     00000111B       ;ATTRIBUT FUER NORMAL-VIDEO
HOME            EQU     1 
RECHTS          EQU     2
OBEN            EQU     3
CLEOP           EQU     4               ;CLEAR TO END OF PAGE
CLEOL           EQU     5               ;CLEAR TO END OF LINE
CPOS            EQU     6               ;CURSOR-POSITIONIERUNG
;                                        ES FOLGEN X- UND Y-KOORDINATE
BELL            EQU     7 
LINKS           EQU     8
UNTEN           EQU     10
RETURN          EQU     13
BEGMARK         EQU     15
ENDMARK         EQU     14
MAXCOLS         EQU     79
MAXLINES        EQU     23
ATTRIBUT        DB      NORMAL
CURFLAG         DB      0
YPOS            DB      0
;
;***********************************************************************
;*   output auf bildschirm des pc
;*
pc_output:
       PUSH    CX     ;RETTE ORIGINALLAENGE DES STRINGS
       CLD            ;DIRECTION FLAG : INCREM. SI
       MOV     SI,BX
OUT:   mov al,es:[si]    ;HOLE ZEICHEN
       inc si
       MOV     AH,CURFLAG
       CMP     AH,0
       JNZ     s0
       CMP     AL,HOME
       JZ      s1     ;CURSOR HOME VERLANGT ?
       CMP     AL,RECHTS 
       JZ      s2     ;CURSOR NACH RECHTS ?
       CMP     AL,OBEN 
       JZ      s3     ;CURSOR NACH OBEN ?
       CMP     AL,CLEOP 
       JZ      s4     ;LOESCHEN BIS BILDSCHIRMENDE ?
       CMP     AL,CLEOL
       JZ      s5     ;LOESCHEN BIS ZEILENENDE ?
       CMP     AL,CPOS 
       JZ      s6     ;CURSOR POSITIONIEREN ?
       CMP     AL,LINKS
       JZ      s7     ;CURSOR NACH LINKS?
       CMP     AL,UNTEN
       JZ      s8     ;CURSOR NACH UNTEN ?
       CMP     AL,RETURN 
       JZ      s9     ;CURSOR AN DEN ANFANG DER AKT. ZEILE ?
       CMP     AL,BEGMARK 
       JZ      s10    ;AB JETZT REVERS ?
       CMP     AL,ENDMARK 
       JZ      s11    ;WIEDER NORMALE VIDEO-DARSTELLUNG ?
       CMP     AL,BELL
       JZ      s12    ;KLINGELN ?
;
       PUSH    CX
       PUSH    BX
       PUSH    SI 
       PUSH    AX     ;AKTUELLES ATTRIBUT
       MOV     AL,ATTRIBUT
       MOV     BL,AL
       POP     AX
       MOV     AH,9   ;SCHREIBEN MIT ATTRIBUT
       MOV     BH,0   ;PAGE #
       MOV     CX,1
       INT     010H   ;CALL BIOS
       MOV     AH,3   ;GET CURRENT CURSOR-POSITION
       MOV     BH,0   ;PAGE #
       INT     010H   ;CALL BIOS
       INC     DL     ;COL = COL + 1
       CMP     DL,MAXCOLS+1
       JNZ     SAME_LINE
       MOV     DL,0
       CMP     DH,MAXLINES 
       JZ      SCROLL_UP
       INC     DH
SAME_LINE:      MOV     AH,2
       mov bh,0     ;page number 
       INT     010H
       POP     SI
       POP     BX
       POP     CX
       JMP     DONE
;
SCROLL_UP:      CALL    SCROLL
       JMP     SAME_LINE 
;
DONE:  DEC     CX     ;ANZAHL ZEICHEN = ANZAHL ZEICHEN - 1
       JNZ     OUT    ;WEITER ?
       POP     CX     ;ANZAHL UEBERNOMMENE ZEICHEN (S.O.)
       RET
; 
s0:    JMP     CUR1
s1:    JMP     CURHOME
s2:    JMP     RIGHT
s3:    JMP     UP
s4:    JMP     CLEAREOP
s5:    JMP     CLEAREOL
s6:    JMP     CURPOS
s7:    JMP     LEFT
s8:    JMP     DOWN
s9:    JMP     ENTER
s10:   JMP     MARK
s11:   JMP     UNMARK
s12:   JMP     KLINGELN
;
;
CURPOS:MOV     AL,2
       MOV     CURFLAG,AL
       JMP     DONE
;
CUR1:  CMP     AH,1
       JZ      CURX
     cmp al,maxlines
     jc  cur1ok
     mov al,maxlines
cur1ok:
       MOV     YPOS,AL
       DEC     CURFLAG
       JMP     DONE

CURX:  DEC     CURFLAG
       MOV     DH,YPOS;Y-KOORDINATE
     cmp  al,maxcols
     jc   curxok
     mov  al,maxcols
curxok:
       MOV     DL,AL  ;X-KOORDINATE
       PUSH    BX
       PUSH    CX
       PUSH    SI
       MOV     BH,0   ;PAGE #
       MOV     AH,2   ;SET CURSOR POSITION
       INT     010H   ;CALL BIOS
       POP     SI
       POP     CX
       POP     BX
       JMP     DONE
;
CURHOME:        PUSH    BX
       PUSH    CX
       PUSH    SI
       MOV     BH,0   ;PAGE #
       MOV     DX,0000H        ;POSITION (0,0)
       MOV     AH,2
       INT     010H   ;CALL BIOS
       POP     SI
       POP     CX
       POP     BX
       JMP     DONE
;
RIGHT: PUSH    BX
       PUSH    CX
       PUSH    SI
       MOV     AH,3   ;GET CURRENT CURSOR-POSITION
       MOV     BH,0   ;PAGE #
       INT     010H   ;CALL BIOS
       CMP     DL,MAXCOLS      ;X-POSITION DES CURSOR ZU GROSS?
       JZ      RUNTER
       INC     DL     ;COL = COL + 1
       MOV     AH,2
       INT     010H
       POP     SI
       POP     CX
       POP     BX
       JMP     DONE
RUNTER:MOV     DL,0
       MOV     BH,0
     mov  ah,2
       INT     010H
       JMP     down1
; 
LEFT:  PUSH    BX     ;KOMMENTARE : S.O.
       PUSH    CX
       PUSH    SI
       MOV     AH,3
       MOV     BH,0
       INT     010H
       DEC     DL
       MOV     AH,2
       INT     010H
       POP     SI
       POP     CX
       POP     BX
       JMP     DONE
;
UP:    PUSH    BX
       PUSH    CX
       PUSH    SI
       MOV     AH,3
       MOV     BH,0
       INT     010H
       DEC     DH
       MOV     AH,2 
       INT     010H
       POP     SI
       POP     CX
       POP     BX
       JMP     DONE
;
DOWN:  PUSH    BX
       PUSH    CX
       PUSH    SI
down1:       MOV     AH,3
       MOV     BH,0
       INT     010H
       CMP     DH,MAXLINES
       JZ      SCRL
       INC     DH
       MOV     AH,2
       INT     010H
       POP     SI
       POP     CX
       POP     BX
       JMP     DONE
SCRL:  CALL    SCROLL
       POP     SI
       POP     CX
       POP     BX
       JMP     DONE
;
;
ENTER: PUSH    BX
       PUSH    CX
       PUSH    SI
       MOV     AH,3
       MOV     BH,0
       INT     010H
       MOV     DL,0
       MOV     AH,2
       INT     010H
       POP     SI
       POP     CX
       POP     BX
       JMP     DONE
;
;
CLEAREOP:       PUSH    BX
       PUSH    CX
       PUSH    SI
       MOV     AH,3   ;GET CURRENT CURSOR-POSITION
       MOV     BH,0   ;PAGE #
       INT     010H   ;CALL BIOS
       MOV     CX,DX  ;CURRENT CURS.POS = UPPER LEFT CORNER
       MOV     DL,maxcols      ;END OF LINE
       MOV     AX,600H;AH=6 : SCROLL AL=0 : BLANK WINDOW
       MOV     BH,7   ;ATTRIBUTE FOR CLS
       INT     010H   ;CLEAR TO END OF LINE
       MOV     CL,0
       CMP     DH,MAXLINES
       JZ      FERTIG
       INC     CH
       MOV     DH,MAXLINES     ;NEW LOWER RIGHT CORNER 
       MOV     DL,MAXCOLS
       MOV     AX,600H
       MOV     BH,7   ;ATTRIBUTE FOR CLS
       INT     010H
FERTIG:POP     SI
       POP     CX
       POP     BX
       JMP     DONE
;
CLEAREOL:       PUSH    BX
       PUSH    CX
       PUSH    SI
       MOV     AH,3   ;GET CURRENT CURSOR-POSITION
       MOV     BH,0   ;PAGE #
       INT     010H   ;CALL BIOS
       MOV     CX,DX  ;CURRENT CURS.POS = UPPER LEFT CORNER
       MOV     DL,maxcols      ;END OF LINE
       MOV     AX,600H;AH=6 : SCROLL AL=0 : BLANK WINDOW
       MOV     BH,7   ;ATTRIBUTE FOR CLS
       INT     010H   ;CLEAR TO END OF LINE
       POP     SI
       POP     CX
       POP     BX
       JMP     DONE
;
MARK:
       MOV     ATTRIBUT,revers
       JMP     DONE
;
UNMARK:
       MOV     ATTRIBUT,normal 
       JMP     DONE
;
SCROLL:MOV     AH,6
       MOV     AL,1   ;SCROLL WINDOW ONE LINE UP
       MOV     CX,0000H        ;UPPER LEFT CORNER : (0,0)
       MOV     DH,MAXLINES
       MOV     DL,MAXCOLS
       mov bh,7          ;attribute for scroll
       INT     010H
       MOV     DH,MAXLINES
       MOV     DL,0
       MOV     BH,0   ;PAGE #
       RET
;
;
KLINGELN:       PUSH    BX
       PUSH    CX
       PUSH    SI
       MOV     AH,14
       MOV     BH,0
       INT     010H   ;PIEEPS
       POP     SI
       POP     CX
       POP     BX
       JMP     DONE
;
set_attribute:
     mov attribut,dl
     ret

set_palette:
     mov ah,11                ;set color palette
     int 10h
     ret

;
;
;
;**********************************************************************
;*
;*   checkkey prueft ob ein zeichen auf der tastatur eingegeben wurde
;*   und uebergibt dies ggf. dem EUMEL;
;*   muss regelmaessig (z.B. aus timerinterrupt aufgerufen werden
; 
checkkey:
     push ax
checkagain:
     MOV     AH,1    ;Z-FLAG GESETZT : ZEICHEN !
   cli
     INT     016H    ;INPUT FROM KEYBOARD
     JZ      NO_KEY  ;NEIN,KEINE TASTE GEDRUECKT
     MOV     AH,0
     INT     016H    ;JA, ZEICHEN ABHOLEN
     cmp ax,0        ;kommt von 'break'
     jz no_key
     cmp al,0        ;extended code
     jnz normal_key
     mov al,ah       ;mit bit acht kennzeichnen
     or  al,80h
normal_key:
     push cx
     MOV     CH,AL
     MOV     AL,1    ;KANAL-NUMMER
     CALL    inputinterrupt
     pop cx
   sti
     jmp checkagain
NO_KEY:
   sti
     pop ax
     ret
;