blob: ea92d0d1434f79231766ede6e55d3b3407305946 (
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
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; name: jaspos_keyb_getkey
;; @param none
;; @return keycode
;; Wait for a keypress from the keyboard,
;; returning the ASCII code in AL and scancode
;; in AH
;;
jaspos_keyb_getkey:
xor ax, ax ; Zero-out AX
int 0x16 ; Int 16.00 - wait for keypress
ret ; Return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; name: jaspos_keyb_getstring
;; @param buffer buffer to write to
;; @param length maximum number of bytes to store (ie. buffer length)
;; @return read total number of bytes read, excluding the carriage return
;; Copy a maximum of [length] keypresses (ASCII
;; codes) into ES:[buffer] until a ^M is read or
;; until [length]-1 bytes have been read (last byte
;; is used for null-termination)
;;
jaspos_keyb_getstring:
pop bp
pop cx
pop di
push bp
mov bx, di
dec cx
push cx
.loop:
call jaspos_keyb_getkey
cmp al, 13d
jz .quit
cmp al, 8
jz .bs
cmp al, 32d
jl .special
stosb
.return:
push ax
call jaspos_monitor_dispchar
call jaspos_monitor_updatecursor
loop .loop
jmp .quit
.special:
inc cx
loop .loop
.bs:
inc cx
cmp di, bx
jz .loop
inc cx
dec di
jmp .return
.quit:
xor al, al
stosb
pop ax
sub ax, cx
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|