Raw File
1 ; _____________________________________________
2 ; | |
3 ; | Project: APPLER |
4 ; | File: CONIO.ASM |
5 ; | Compiler: 16-bit TASM (2.5) |
6 ; | |
7 ; | Subject: Keyboard input / screen output |
8 ; | |
9 ; | Author: Emil Dotchevski |
10 ; |_____________________________________________|
11
12
13 include GLOBALS.INC
14 include INTERFAC.INC
15 include CONIO.INC
16
17 CONio segment public
18 assume ds:CONio,cs:CONio,es:ApplerVideo
19
20
21 ; --- Get Line Services Proc ---
22
23 GL_ServSubrt dw GetLine
24 dw GL_Symbol,GL_String,GL_Byte,GL_GetSymb,GL_Left,GL_Right
25 dw GL_Ins,GL_Del,GL_BackSpc,GL_Home,GL_End,GL_ClrBuff,GetCommand
26 GL_Services proc far
27 push bp ds
28 shl bp,1
29 call cs:GL_ServSubrt[bp]
30 pop ds bp
31 ret
32 GL_Services endp
33
34
35 ; --- Screen Services Proc ---
36
37 SIO_ServSubrt dw ClearScreen,ShowScreen
38 dw SymbPrint,SymbPrintXY,BytePrint,StringPrint,GetSymb,ShowLine,CalcXY
39 dw ShowCursor,HideCursor,SetTextMode,SetScreen
40 SIO_Services proc far
41 push bp ds
42 shl bp,1
43 call cs:SIO_ServSubrt[bp]
44 pop ds bp
45 ret
46 SIO_Services endp
47
48
49 ; --- Pointers Storage ---
50
51 GL_ParamsAdr label dword
52 GL_ParamsOfs dw ?
53 GL_ParamsSeg dw ?
54
55 SIO_ParamsAdr label dword
56 SIO_ParamsOfs dw ?
57 SIO_ParamsSeg dw ?
58
59 RK_ParamsAdr label dword
60 RK_ParamsOfs dw ?
61 RK_ParamsSeg dw ?
62
63 GL_SetRegs macro
64 lds bp,cs:GL_ParamsAdr
65 endm
66
67 SIO_SetRegs macro
68 lds bp,cs:SIO_ParamsAdr
69 endm
70
71 RK_SetRegs macro
72 lds bp,cs:RK_ParamsAdr
73 endm
74
75
76 ; --- GET LINE proc ---
77
78 GL_Commands db 05h,06h,09h,0Ah,0Bh
79 db 01h,02h
80 db 18h,0Ch
81 GL_ComSubrt dw GL_Left,GL_Right,GL_Ins,GL_Del,GL_BackSpc
82 dw GL_Home,GL_End
83 dw GL_Enter,GL_Esc
84 GL_FirstFlag db ?
85
86 GetLine: push ax bx cx dx di bp ds
87 GL_SetRegs
88 mov cs:GL_FirstFlag,1
89 mov word ptr ds:[bp].GL_CX,cx
90 call CalcXY
91 mov ds:[bp].GL_X,cl
92 mov ds:[bp].GL_Y,ch
93 mov al,ds:[bp].GL_Length
94 cmp al,ds:[bp].GL_Pos
95 jae GL_Loop0
96 mov ds:[bp].GL_Pos,al
97 GL_Loop0: test ds:[bp].GL_InsFlag,1
98 mov al,ds:[bp].GL_OverCurColor
99 jz GL_Cursor
100 mov al,ds:[bp].GL_Length
101 cmp al,ds:[bp].GL_MaxLength
102 mov al,ds:[bp].GL_InsCurColor
103 jb GL_Cursor
104 mov al,ds:[bp].GL_OverCurColor
105 GL_Cursor: SIO_SetRegs
106 mov ds:[bp].CursorColor,al
107 GL_SetRegs
108 xor bx,bx
109 mov bl,ds:[bp].GL_Pos
110 mov ch,ds:[bp].GL_Y
111 mov cl,bl
112 sub cl,ds:[bp].GL_BegPrint
113 add cl,ds:[bp].GL_X
114 call ReadKey
115 mov di,offset GL_Commands
116 mov cx,offset GL_ComSubrt - offset GL_Commands
117 call CalcCommand
118 jc GL_NotCmnd
119 shl di,1
120 call word ptr cs:GL_ComSubrt[di]
121 mov cs:GL_FirstFlag,0
122 jnc GL_Loop0
123 cmp ax,0
124 clc
125 jz GL_MainRet
126 stc
127 GL_MainRet: pop ds bp di dx cx bx ax
128 ret
129
130 GL_NotCmnd: cmp al,20h
131 jb GL_CallUser
132 cmp cs:GL_FirstFlag,0
133 jz GL_CallSymbol
134 cmp ds:[bp].GL_Pos,0
135 ja GL_CallSymbol
136 call GL_ClrBuff
137 GL_CallSymbol: call GL_Symbol
138 jmp GL_Loop0
139 GL_CallUser: call ds:[bp].[GL_User]
140 mov cs:GL_FirstFlag,1
141 jmp GL_Loop0
142
143
144 GL_Symbol: push bx cx dx si di ds es
145 GL_SetRegs
146 test ds:[bp].GL_AllowSpc,1
147 jnz GL_S_do1
148 cmp al,20h
149 je GL_Sret
150 GL_S_do1: xor bx,bx
151 mov bl,ds:[bp].GL_Pos
152 test ds:[bp].GL_InsFlag,1
153 jz GL_S_Over
154 xor cx,cx
155 mov cl,ds:[bp].GL_Length
156 cmp cl,ds:[bp].GL_MaxLength
157 jnb GL_S_Over
158
159 push ds
160 pop es
161 sub cl,bl
162 inc cx
163 xor dx,dx
164 mov dl,ds:[bp].GL_Length
165 mov si,ds:[bp].GL_Buffer
166 add si,dx
167 mov di,si
168 inc di
169 std
170 rep movsb
171 inc ds:[bp].GL_Length
172 jmp GL_S_1
173
174 GL_S_Over: mov cl,ds:[bp].GL_Length
175 cmp bl,cl
176 jb GL_S_1
177 cmp cl,ds:[bp].GL_MaxLength
178 jnb GL_Sret
179 inc ds:[bp].GL_Length
180 GL_S_1: xor bx,bx
181 mov bl,ds:[bp].GL_Pos
182 add bx,ds:[bp].GL_Buffer
183 mov [bx],al
184 call GL_Right
185
186 GL_Sret: pop es ds di si dx cx bx
187 ret
188
189
190 GL_String: push ax bx bp ds ; Puts a string in the buffer
191 GL_SetRegs
192 GL_Str0: mov al,[bx]
193 cmp al,0
194 je GL_Str1
195 call GL_Symbol
196 inc bx
197 jmp GL_Str0
198 GL_Str1: pop ds bp bx ax
199 ret
200
201
202 GL_Byte: push ax ; Overwrite / Insert a byte
203 shr al,4
204 cmp al,0Ah
205 cmc
206 adc al,30h
207 daa
208 call GL_Symbol
209 pop ax
210 push ax
211 and al,00001111b
212 cmp al,0Ah
213 cmc
214 adc al,30h
215 daa
216 call GL_Symbol
217 pop ax
218 ret
219
220
221 GL_Left: push bx cx bp ds ; Moves cursor left
222 GL_SetRegs
223 xor bx,bx
224 mov bl,ds:[bp].GL_Pos
225 cmp bl,0
226 jna GL_Lret
227 dec bx
228 mov cx,bx
229 sub cl,ds:[bp].GL_BegPrint
230 cmp cl,2
231 jae GL_Lret
232 cmp ds:[bp].GL_BegPrint,0
233 jna GL_Lret
234 dec ds:[bp].GL_BegPrint
235 GL_Lret: mov ds:[bp].GL_Pos,bl
236 pop ds bp cx bx
237 clc
238 ret
239
240
241 GL_Right: push bx cx bp ds ; Moves cursor right
242 GL_SetRegs
243 xor bx,bx
244 mov bl,ds:[bp].GL_Pos
245 cmp bl,ds:[bp].GL_Length
246 jnb GL_Rret
247 inc bx
248 mov cx,bx
249 mov ch,ds:[bp].GL_MaxPrint
250 sub ch,2
251 sub cl,ds:[bp].GL_BegPrint
252 cmp cl,ch
253 jb GL_Rret
254 mov cl,ds:[bp].GL_Length
255 sub cl,ds:[bp].GL_BegPrint
256 cmp cl,ds:[bp].GL_MaxPrint
257 jna GL_Rret
258 inc ds:[bp].GL_BegPrint
259 GL_Rret: mov ds:[bp].GL_Pos,bl
260 pop ds bp cx bx
261 clc
262 ret
263
264
265 GL_Ins: push bp ds
266 GL_SetRegs
267 xor ds:[bp].GL_InsFlag,1 ; Toggles INS mode
268 pop ds bp
269 clc
270 ret
271
272 GL_Del: push bx cx si di ds es ; Delete char at cursor
273 GL_SetRegs
274 cmp ds:[bp].GL_Length,0
275 jz GL_Dret
276 xor bx,bx
277 mov bl,ds:[bp].GL_Pos
278 cmp bl,ds:[bp].GL_Length
279 jae GL_Dret
280 push ds
281 pop es
282 mov si,ds:[bp].GL_Buffer
283 add si,bx
284 mov di,si
285 inc si
286 xor cx,cx
287 mov cl,ds:[bp].GL_Length
288 sub cl,bl
289 cld
290 rep movsb
291 dec ds:[bp].GL_Length
292 mov bl,ds:[bp].GL_Length
293 sub bl,ds:[bp].GL_BegPrint
294 cmp bl,ds:[bp].GL_MaxPrint
295 jae GL_Dret
296 cmp ds:[bp].GL_BegPrint,0
297 jz GL_Dret
298 dec ds:[bp].GL_BegPrint
299 GL_Dret: pop es ds di si cx bx
300 clc
301 ret
302
303
304 GL_BackSpc: push bp ds
305 GL_SetRegs
306 cmp ds:[bp].GL_Pos,0
307 jna GL_BS_ret
308 call GL_Left
309 call GL_Del
310 GL_BS_ret: pop ds bp
311 clc
312 ret
313
314
315 GL_Home: push bx
316 mov bx,0FFh
317 GL_Hloop: call GL_Left
318 dec bx
319 jnz GL_Hloop
320 pop bx
321 clc
322 ret
323
324
325 GL_End: push bx
326 mov bx,0FFh
327 GL_Eloop: call GL_Right
328 dec bx
329 jnz GL_Eloop
330 pop bx
331 clc
332 ret
333
334
335 GL_Esc: call GL_SetZero
336 mov ax,1
337 stc
338 ret
339
340
341 GL_Enter: call GL_SetZero
342 mov ax,0
343 stc
344 ret
345
346
347 GL_SetZero: push bx
348 xor bx,bx
349 mov bl,ds:[bp].GL_Length
350 add bx,ds:[bp].GL_Buffer
351 mov byte ptr [bx],0
352 pop bx
353 ret
354
355
356 GL_ClrBuff: push ax bp ds
357 GL_SetRegs
358 xor ax,ax
359 mov ds:[bp].GL_Pos,al
360 mov ds:[bp].GL_Length,al
361 mov ds:[bp].GL_BegPrint,al
362 xor cx,cx
363 pop ds bp ax
364 ret
365
366
367 GL_GetSymb: push bx bp ds
368 GL_SetRegs
369 mov ds:[bp].GL_Pos,cl
370 mov ds:[bp].GL_BegPrint,ch
371 GL_GS_Loop0: xor bx,bx
372 mov bl,ds:[bp].GL_Pos
373 cmp bl,ds:[bp].GL_Length
374 mov al,0
375 jae GL_GS_ret
376 pushf
377 add bx,ds:[bp].GL_Buffer
378 mov al,ds:[bx]
379 call GL_Right
380 popf
381 jb GL_GS_0
382 inc ds:[bp].GL_Pos
383 GL_GS_0: test ds:[bp].GL_GS_SpcFl,1
384 jz GL_GS_ret
385 cmp al,' '
386 je GL_GS_Loop0
387 GL_GS_ret: mov cl,ds:[bp].GL_Pos
388 mov ch,ds:[bp].GL_BegPrint
389 pop ds bp bx
390 ret
391
392
393 GL_Ecx dw ?
394 GL_Ecx1 dw ?
395 GL_ComSymb db 'abcdefghijklmnopqrstuvwxyz?[.'
396 GL_ComSymbC = 29
397 GetCommand: push si cx dx bp ds ; Scan for commands
398 GL_SetRegs
399 mov dl,ds:[bp].GL_GS_SpcFl
400 mov ds:[bp].GL_GS_SpcFl,0
401 xor di,di
402 mov si,ds:[bp].GL_BegScan
403 mov ds:[bp].GL_Eparam,1
404 xor cx,cx
405 GL_Eloop00: call GL_GetSymb
406 cmp al,' '
407 je GL_Eloop00
408 dec cl
409 or al,al
410 jz GL_Eerror1
411 mov cs:GL_Ecx1,cx
412 GL_Eloop0: dec si
413 mov cx,cs:GL_Ecx1
414 GL_Eloop1: inc si
415 mov cs:GL_Ecx,cx
416 call GL_GetSymb
417 call Upcase
418 push cx di
419 mov di,offset GL_ComSymb
420 mov cx,GL_ComSymbC
421 call CalcCommand
422 pop di cx
423 jc GL_Eok
424 or al,al
425 jz GL_Eok0
426 cmp al,ds:[si]
427 je GL_Eloop1
428 GL_Eloop2: cmp byte ptr ds:[si],0
429 jz GL_E0
430 inc si
431 jmp GL_Eloop2
432 GL_E0: inc si
433 cmp si,ds:[bp].GL_ENDScan
434 ja GL_Eerror
435 inc di
436 jmp GL_Eloop0
437 GL_Eerror: mov ds:[bp].GL_Pos,0
438 mov ds:[bp].GL_BegPrint,0
439 mov si,ds:[bp].GL_Error
440 RK_SetRegs
441 mov ds:[bp].RK_ErrPtr,si
442 GL_SetRegs
443 GL_Eerror1: stc
444 jmp GL_Eret
445 GL_Eok0: mov ds:[bp].GL_Eparam,0
446 jmp GL_Eok1
447 GL_Eok: mov cx,cs:GL_Ecx
448 GL_Eok1: mov ds:[bp].GL_Pos,cl
449 mov ds:[bp].GL_BegPrint,ch
450 xor ax,ax
451 cmp di,0
452 jz GL_Eerror
453 dec di
454 clc
455 GL_Eret: mov ds:[bp].GL_GS_SpcFl,dl
456 pop ds bp dx cx si
457 ret
458
459
460 ; --- SCREEN I/O procs ---
461
462 ClearScreen: push ax cx di es
463 SIO_SetRegs
464 les di,dword ptr ds:[bp].SS_SourceOfs
465 mov ax,720h
466 mov cx,80*25
467 cld
468 rep stosw
469 pop es di cx ax
470 ret
471
472
473 ShowLine: push ax cx dx si di bp ds es
474 SIO_SetRegs
475 les di,dword ptr ds:[bp].SS_SourceOfs
476 GL_SetRegs
477 add di,ds:[bp].GL_CX
478 xor ax,ax
479 mov al,ds:[bp].GL_BegPrint
480 mov dh,al
481 add ax,ds:[bp].GL_Buffer
482 mov si,ax
483 mov ah,ds:[bp].GL_Color
484 cld
485 xor cx,cx
486 mov cl,ds:[bp].GL_MaxPrint
487 GL_SL_Loop0: lodsb
488 cmp dh,ds:[bp].GL_Length
489 jb GL_SL_1
490 mov al,' '
491 GL_SL_1: stosw
492 inc dh
493 loop GL_SL_Loop0
494 pop es ds bp di si dx cx ax
495 ret
496
497
498 ; CalcXY--Translate page offset to X & Y coordinates
499 ; Entry:
500 ; CX -- Page offset
501 ; Exit:
502 ; CX -- Coordinates
503
504 CalcXY: push ax bx
505 xor ax,ax
506 mov bx,80 * 2
507 CXY_CalcLoop: sub cx,bx
508 inc ax
509 jnc CXY_CalcLoop
510 add cx,bx
511 shr cx,1
512 mov ch,al
513 pop bx ax
514 ret
515
516
517 ShowScreen: push ds es di si cx bp ; Moves the screen in the text page.
518 SIO_SetRegs
519 cmp ds:[bp].SS_ScreenFLag,0
520 jz SSret
521 call SetTextMode
522 lds si,dword ptr ds:[bp].SS_SourceOfs
523 mov di,ApplerVideo
524 mov es,di
525 xor di,di
526 mov cx,80*25
527 cld
528 rep movsw
529 SSret: pop bp cx si di es ds
530 ret
531
532
533 ; Shows a byte on the screen.
534 ; Input:
535 ; AL -> byte to print, AH -> attributes
536 ; CX -> Page offset
537
538 ; Output:
539 ; CX <- CX + 2
540
541 BytePrint: push ax bx
542 mov bx,ax
543 shr al,4
544 cmp al,0Ah
545 cmc
546 adc al,30h
547 daa
548 call SymbPrint
549 mov al,bl
550 and al,00001111b
551 cmp al,0Ah
552 cmc
553 adc al,30h
554 daa
555 call SymbPrint
556 pop bx ax
557 ret
558 comment %
559 BytePrint: push ax bx di es
560 SIO_SetRegs
561 les di,dword ptr ds:[bp].SS_SourceOfs
562 add di,cx
563 cld
564 mov bx,ax
565 shr al,4
566 cmp al,0Ah
567 cmc
568 adc al,30h
569 daa
570 stosw
571 mov al,bl
572 and al,00001111b
573 cmp al,0Ah
574 cmc
575 adc al,30h
576 daa
577 stosw
578 add cx,2*2
579 pop es di bx ax
580 ret
581 %
582
583
584 ; Shows a symbol on the screen.
585 ; Input:
586 ; AL -> symb, AH -> attributes
587 ; CX -> Page offset
588
589 ; Output:
590 ; CX <- CX + 2
591
592 SymbPrint: push ds bp bx
593 SIO_SetRegs
594 cmp ds:[bp].SP_BufFlag,0
595 jnz SP_Buffer
596 lds bx, dword ptr ds:[bp].SS_SourceOfs
597 add bx,cx
598 mov ds:[bx],ax
599 SP_Ret: add cx,2
600 pop bx bp ds
601 ret
602 SP_Buffer: call GL_Symbol
603 jmp SP_Ret
604
605
606 ; Shows a symbol on the screen.
607 ; Input:
608 ; AL -> symb, AH -> attributes
609 ; CH -> vtab, CL -> htab
610
611 ; Output:
612 ; CL <- CL + 1
613
614 SymbPrintXY: push ds bp bx cx ax
615 SIO_SetRegs
616 lds bx, dword ptr ds:[bp].SS_SourceOfs
617 dec ch
618 mov al,ch
619 mov ah,80 * 2
620 mul ah
621 add bx,ax
622 xor ch,ch
623 shl cx,1
624 add bx,cx
625 pop ax
626 mov ds:[bx],ax
627 pop cx bx bp ds
628 inc cl
629 ret
630
631
632 ; Shows a string on the screen.
633 ; Input:
634 ; BX -> offset string
635 ; AH -> attributes
636 ; CX -> Page offset
637
638 ; Output:
639 ; CX <- CX + String Length * 2
640
641 StringPrint: push ax bx dx si di bp ds es
642 SIO_SetRegs
643 mov ds,ds:[bp].SP_SourceSeg
644 les di, dword ptr ds:[bp].SS_SourceOfs
645 add di,cx
646 mov si,bx
647 cld
648
649 SP_Loop1: lodsb
650 mov dl,al
651 or dl,dl
652 jz SP_0
653 dec dl
654 jz SP_1
655 dec dl
656 jz SP_2
657 dec dl
658 jz SP_3
659 stosw
660 jmp SP_Loop1
661
662 SP_3: lodsb
663 mov bl,al
664 lodsb
665 mov bh,al
666 mov al,ds:[bx]
667 jmp SP_3_Entry
668
669 SP_2: lodsb
670 SP_3_Entry: mov dl,al
671 shr al,4
672 cmp al,0Ah
673 cmc
674 adc al,30h
675 daa
676 stosw
677 mov al,dl
678 and al,00001111b
679 cmp al,0Ah
680 cmc
681 adc al,30h
682 daa
683 stosw
684 jmp SP_Loop1
685
686 SP_1: lodsb
687 mov ah,al
688 add bx,2
689 jmp SP_Loop1
690
691 SP_0: mov ds:[bp].SP_bx,si
692 dec si
693 sub si,bx
694 shl si,1
695 add cx,si
696 pop es ds bp di si dx bx ax
697 ret
698
699
700 ; Read a symbol from the screen.
701 ; Input:
702 ; CH -> vtab, CL -> htab
703
704 ; Output:
705 ; AH <- Attr, AL <- ASCII code
706 ; CX <- CX + 1
707
708 GetSymb: push ds bp si bx cx
709 SIO_SetRegs
710 GetSymb1: lds si,dword ptr ds:[bp].SS_SourceOfs
711 dec ch
712 mov al,ch
713 mov ah,80 * 2
714 mul ah
715 mov bx,ax
716 xor ch,ch
717 shl cx,1
718 add bx,cx
719 add bx,si
720 mov ax,ds:[bx]
721 pop cx
722 inc cl
723 push cx
724 SIO_SetRegs
725 test ds:[bp].SpacesFlag,1
726 jz GS_ret
727 cmp al,20h
728 je GetSymb1
729 GS_ret: pop cx bx si bp ds
730 ret
731
732
733
734
735 OldCursor db 80 dup (?)
736 ShowCursor: push ax bx cx dx bp ds
737 SIO_SetRegs
738 mov dl,ds:[bp].SpacesFlag
739 mov dh,ds:[bp].CursorLen
740 mov ds:[bp].SpacesFlag,0
741 xor bx,bx
742 SC_Loop1: call GetSymb
743 mov cs:OldCursor[bx],ah
744 cmp ds:[bp].CursorFlag,0
745 jz SC_NoCursor
746 and ah,00001111b
747 or ah,ds:[bp].CursorColor
748 dec cl
749 call SymbPrintXY
750 SC_NoCursor: inc bx
751 dec dh
752 jnz SC_Loop1
753 mov ds:[bp].SpacesFlag,dl
754 pop ds bp dx cx bx ax
755 ret
756
757
758 HideCursor: push ax bx cx dx bp ds
759 SIO_SetRegs
760 mov dl,ds:[bp].SpacesFlag
761 mov dh,ds:[bp].CursorLen
762 mov ds:[bp].SpacesFlag,0
763 xor bx,bx
764 HC_Loop1: call GetSymb
765 mov ah,cs:OldCursor[bx]
766 dec cl
767 call SymbPrintXY
768 inc bx
769 dec dh
770 jnz HC_Loop1
771 mov ds:[bp].SpacesFlag,dl
772 pop ds bp dx cx bx ax
773 ret
774
775
776
777 SetTextMode: push ax bx cx bp ds
778 SIO_SetRegs
779 test ds:[bp].SS_ScreenFlag,1
780 jz STM_DontSet
781 mov ah,0Fh
782 int 10h
783 cmp al,3
784 je STM_SetCursor
785 mov ax,3
786 int 10h
787 mov cx,2021h
788 mov ah,1
789 int 10h
790 mov ax,0500h
791 int 10h
792
793 mov cs:STM_WaitFlag,0
794 mov ax,4
795 mov cx,seg STM_Wait
796 mov dx,offset STM_Wait
797 call TimerReq
798 STM_WaitLoop: cmp cs:STM_WaitFlag,0
799 jz STM_WaitLoop
800
801 STM_DontSet: pop ds bp cx bx ax
802 ret
803 STM_SetCursor: mov cx,2021h
804 mov ah,1
805 int 10h
806 mov ax,0500h
807 int 10h
808 jmp STM_DontSet
809
810 STM_WaitFlag db ?
811 STM_Wait: mov cs:STM_WaitFlag,1
812 retf
813
814
815 SetScreen: SaveAll
816 mov bx,Apple
817 mov cx,Video
818 mov ds,bx
819 mov es,cx
820 call SetScrEntry
821 RestoreAll
822 ret
823
824
825 ; --- Wait Key proc ---
826
827 assume es:Emulate
828
829 RK_ProcessIDs db PID_DEBUGGER
830 db PID_FILE_MANAGER
831 db PID_FLOPPY_DISK_MANAGER
832 db PID_KEYBOARD_SETUP
833 db PID_DONT_SWITCH
834 db PID_DONT_SWITCH
835 db PID_DONT_SWITCH
836 db PID_DONT_SWITCH
837 db PID_ABOUT_SCREEN
838 db PID_HELP_SCREEN
839 db PID_DOS_SHELL
840 db PID_QUIT_APPLER
841
842 assume es:Keyboard
843 ReadKey proc far
844 push bx dx bp ds es
845 GK_0: mov bx,Keyboard
846 mov es,bx
847 RK_SetRegs
848 call WaitKey
849 cmp al,0Eh
850 jb GK_ret
851 cmp al,17h
852 ja GK_NoFkey
853 test es:k_Shifts,M_ALT
854 jz GK_NoAltF
855 sub al,0Eh
856 xor bx,bx
857 mov bl,al
858 mov al,cs:RK_ProcessIDs[bx]
859 call TaskSwitch
860 jmp GK_0
861 GK_NoALtF: cmp ds:[bp].RK_FkeyFlag,0
862 jz GK_NoFkey
863 sub al,0Eh
864 call ds:[bp].[RK_FkeyProc]
865 jmp GK_0
866 GK_NoFkey: test es:k_Shifts,M_ALT
867 jz GK_Ret
868 cmp ds:[bp].RK_AltFlag,0
869 jz GK_Ret
870 call ds:[bp].[RK_AltProc]
871 jc GK_0
872 GK_ret: pop es ds bp dx bx
873 ret
874 ReadKey endp
875 assume es:Emulate
876
877 WK_FkeysStr db '1D',4Fh,'e',4Fh,'b',4Fh,'u',4Fh,'g',4Fh,' ',4Fh,' '
878 db '2F',2Fh,'i',2Fh,'l',2Fh,'e',2Fh,'I',2Fh,'O',2Fh,' '
879 db '3D',6Fh,'i',6Fh,'s',6Fh,'k',6Fh,'I',6Fh,'O',6Fh,' '
880 db '4K',5Fh,'b',5Fh,'d',5Fh,'S',5Fh,'t',5Fh,'p',5Fh,' '
881 db '5 ',07h,' ',07h,' ',07h,' ',07h,' ',07h,' ',07h,' '
882 db '6 ',07h,' ',07h,' ',07h,' ',07h,' ',07h,' ',07h,' '
883 db '7 ',07h,' ',07h,' ',07h,' ',07h,' ',07h,' ',07h,' '
884 db '8 ',07h,' ',07h,' ',07h,' ',07h,' ',07h,' ',07h,' '
885 db '9A',1Fh,'b',1Fh,'o',1Fh,'u',1Fh,'t',1Fh,' ',1Fh,'1'
886 db '0H',3Fh,'e',3Fh,'l',3Fh,'p',3Fh,' ',3Fh,' ',3Fh,' '
887
888 WaitKey proc far
889 push bx si di bp ds es
890 WK_Loop0: mov bx,Keyboard
891 mov es,bx
892 assume es:Keyboard
893 mov es:k_KeyPressed,1
894 WK_Loop: mov bx,Keyboard
895 mov es,bx
896 RK_SetRegs
897 assume ds:CONio
898 cmp ds:[bp].RK_WaitKeyFlag,0
899 jz WK_05
900 call ds:[bp].[RK_WaitKeyProc]
901 jmp WK_06
902 WK_05: xor al,al
903 xchg al,es:k_KeyPressed
904 or al,al
905 jz WK_07
906 call ds:[bp].[RK_ShowAll]
907 call ShowCursor
908 WK_06: test es:k_Shifts,M_ALT
909 jz WK_AltNoPress
910 push cx ds
911 mov cx,seg EnableTaskSwitch
912 mov ds,cx
913 assume ds:seg EnableTaskSwitch
914 cmp ds:EnableTaskSwitch,0
915 jz WK_AltNoPress1
916 SIO_SetRegs
917 assume ds:CONio
918 push es
919 les di, dword ptr ds:[bp].SS_SourceOfs
920 add di,24*80*2
921 push cs
922 pop ds
923 mov si,offset WK_FkeysStr
924 mov cx,80
925 cld
926 rep movsw
927 pop es
928 RK_SetRegs
929 WK_AltNoPress1: pop ds cx
930 WK_AltNoPress: call ShowScreen
931 WK_07: mov ax,Emulate
932 mov es,ax
933 assume es:Emulate
934 mov al,es:C000
935 or al,al
936 jnz WaitKey2
937 jmp WK_Loop
938
939 WaitKey2: mov bx,Keyboard
940 mov ds,bx
941 assume ds:Keyboard
942 mov ah,ds:k_ScanCode
943 mov C000,0
944 call key_taken
945 call HideCursor
946 cmp al,80h+1Ah
947 je WK_DosShell
948 cmp al,80h+1Bh
949 je WK_QuitAppler
950 xor al,10000000b
951 RK_SetRegs
952 assume ds:CONio
953 mov ds:[bp].RK_ErrPtr,0
954 pop es ds bp di si bx
955 ret
956
957 WK_DosShell: call DosShell
958 jmp WK_Loop0
959
960 WK_QuitAppler: jmp QuitAppler
961 WaitKey endp
962
963
964
965 assume ds:seg k_Table
966 DKO_OldBuffFlag db 0
967 DebugKeysOn proc far
968 push ax ds
969 mov ax,seg k_Table
970 mov ds,ax
971 mov ds:k_Table,offset k_DebugTable
972 xor ax,ax
973 xchg ds:k_BufferFlag,al
974 mov cs:DKO_OldBuffFlag,al
975 pop ds ax
976 ret
977 DebugKeysOn endp
978
979 AppleKeysOn proc far
980 push ax ds
981 mov ax,seg k_Table
982 mov ds,ax
983 mov ds:k_Table,offset k_AppleTable
984 mov al,cs:DKO_OldBuffFlag
985 mov ds:k_BufferFlag,al
986 pop ds ax
987 ret
988 AppleKeysOn endp
989 assume ds:CONio
990
991
992
993 SwapFlag db 1
994 ScreenSwapReq proc far
995 push ax cx dx
996 mov cs:SwapFlag,0
997 mov cx,seg ScreenSwap
998 mov dx,offset ScreenSwap
999 or ax,ax
1000 jnz SSR_SetTimer
1001 call ScreenSwap
1002 jmp SSR_NoTimer
1003 SSR_SetTimer: call TimerReq
1004 SSR_NoTimer: pop dx cx ax
1005 ret
1006 ScreenSwapReq endp
1007
1008 ScreenSwap proc far
1009 cmp cs:SwapFlag,0
1010 mov cs:SwapFlag,1
1011 jnz SS_Ret
1012 push ax bx bp es
1013 mov ah,0Fh
1014 int 10h
1015 cmp al,3
1016 jne SS_NoSwap
1017 mov ax,seg C050
1018 mov es,ax
1019 mov al,C050
1020 ScreenIOservice _SetScreen
1021 SS_NoSwap: pop es bp bx ax
1022 SS_Ret: ret
1023 ScreenSwap endp
1024
1025 ; --- Internal procs ---
1026
1027 Upcase: cmp al,'A'
1028 jb UPCSret
1029 cmp al,'Z'
1030 ja UPCSret
1031 or al,20h
1032 UPCSret: ret
1033
1034 CalcCommand: push ax bx cx es ; Returns number of a command .
1035 push cs ; Input:
1036 pop es ; di -> offset Commands
1037 cld ; al -> search command
1038 mov bx,di ; cx -> commands count
1039 repne scasb
1040 stc ; Output:
1041 jne CC_end ; di <- Number of the command
1042 sub di,bx ; cf <- 1 if not found
1043 dec di
1044 clc
1045 CC_end: pop es cx bx ax
1046 ret
1047
1048 CONio ends
1049 end
1050
Generated by GNU Enscript 1.6.6, and GophHub 1.3.