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
|
;
page 80,132
;0
title CP/DOS KbdCharIn mapper
;
kbdxxx segment byte public 'kbd'
assume cs:kbdxxx,ds:nothing,es:nothing,ss:nothing
;
; ************************************************************************* *
; *
; * MODULE: kbdcharin
; *
; * FILE NAME: charin.asm
; *
; * CALLING SEQUENCE:
; *
; * push@ dword chardata ; buffer for data
; * push word iowait ; Indicate if wait
; * push word kbdhandle ; Keyboard Handle
; *
; * call kbdcharin
; *
; *
; * MODULES CALLED: BIOS int 16h
; * PC-DOS Int 21h, ah=2ch, get time
; *
; *************************************************************************
public kbdcharin
.sall
.xlist
include kbd.inc
.list
extrn savedkbdinput:word
error_kbd_parameter equ 0002h
str struc
old_bp dw ?
return dd ?
handle dw ? ; keyboard handle
iowait dw ? ; indicate if wait for io
data dd ? ; data buffer pointer
str ends
kbdcharin proc far
Enter KbdCharIn ; save registers
lds si,[bp].data ; set up return data area
loopx:
mov ax,savedkbdinput
cmp ah,0
je nosavedchar
mov savedkbdinput,0
jmp avail
nosavedchar:
mov ah,0bh ; Check for ^C
int 021h
mov ah,06
mov dl,-1
int 021h
jnz avail
mov ax,[bp].iowait ; else, see if wait is desired
cmp ax,0 ; if so,
jz loopx ; keep trying
; else...
mov ds:[si].Char_Code,0 ; | zero out scan and char codes
mov ds:[si].Scan_Code,0 ; | zero out scan and char codes
mov ds:[si].Status,0 ; | 0 for status
jmp short shift ; | go to get shift status
; end of block
avail:
cmp al,0
je loopx
mov ds:[si].Scan_Code,0 ; |
mov ds:[si].Char_Code,al ; | move char&scan code into structure
mov ds:[si].Status,1 ; | 1 for status
;
shift: mov ah,02h ; Start of shift check block
int 16h ; | BIOS call to get shift state
sub ah,ah ; |
mov ds:[si].Shift_State,ax ; | put shift status into structure
mov ah,2ch ; start time stamping
int 21h ; | get current time of day
mov byte ptr ds:[si].Time+0,ch ; | put hours into structure
mov byte ptr ds:[si].Time+1,cl ; | put minutes into structure
mov byte ptr ds:[si].Time+2,dh ; | put seconds into structure
mov byte ptr cs:[si].Time+3,dl ; | put hundreds into structure
sub ax,ax ; set good return code
Mexit ; pop registers
ret size str - 6 ; return
kbdcharin endp
kbdxxx ends
end
|