home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.update.uu.se
/
ftp.update.uu.se.2014.03.zip
/
ftp.update.uu.se
/
pub
/
rainbow
/
msdos
/
decus
/
RB140
/
grlibfor.arj
/
GETKEY.ASM
< prev
next >
Wrap
Assembly Source File
|
1988-12-11
|
3KB
|
227 lines
PAGE ,132
TITLE GETKEY.ASM
;UPDATE HISTORY
;==============
; 3-dec-1984
convert from c to assembler
include asmc.h
include asmk.h
public CAPITAL
public INKEY
public GETKEY
extr
n KBD16:near, KBDIN:near
; convert character to uppercase if lower c
ase */
; if('a'<=c && c<='z')c+=('A'-'a');
; return c;
ucase
PROC NEAR
push BP
mov BP,SP
mov AL,+4[BP]
cbw
cmp AX,97
jl ucasex
mov AL,+4[BP]
cbw
cmp AX,1
22
jg ucasex
mov AX,-32
push AX
pop DX
mov
AL,+4[BP]
cbw
add AX,DX
mov +4[BP],AL
ucasex:
m
ov AL,+4[BP]
cbw
mov SP,BP
pop BP
ret
ucase E
NDP
;******************************************************
;convert non-function key to upper case *
;c
apital(key_pressed) *
;unsigned int key_pressed; *
;******************************************************
P
ROCDEF CAPITAL
push BP
mov BP,SP
; if ( !FUNKEY(key
_pressed) )
mov AX,+4[BP]
and AX,256
or AX,AX
je
.012
mov AX,1
jmp SHORT .014
.012: ;11
xor AX,AX
.014: ;11
or AX,AX
je .01A
jmp SHORT .027
; return(toupper(key_pressed));
.01A: ;11
push WORD PTR +
4[BP]
call ucase
add SP,2
mov SP,BP
pop BP
ret
; else
; return(key_pressed);
.027: ;13
mov AX,+4[BP]
mov SP,BP
pop BP
ret
PROCEND CAPITA
L
;******************************************************
;wait for a key to be pressed and return it to caller *
; inkey() *
;******************************************************
INKEY PROC NEAR
.032: ;19
push BP
mov BP,SP
sub SP,2
; while ((key = get
key()) == 0);
.038: ;22
call GETKEY
mov -2[BP],AX
cmp AX,0
jne .045
jmp SHORT .038
; return(key);
.045: ;22
mov AX,-2[BP]
mov SP,BP
pop BP
ret
INKEY ENDP
;***********************************************************
;see if a key was pressed and return 16-bit
char to caller *
;if function key, bit 0x0100 = 1 *
; else, b
it 0x0100 = 0 *
;return 0 if no key pressed *
;getkey() *
;***********************************************************
; };
;}
GETKEY PROC NEAR
.04C: ;27
push BP
mov BP,SP
sub SP,6
; j = kbd16(&i);
lea SI,-6[
BP]
push SI
call KBD16
add SP,2
; while (j ==
LEV2) { /* lose L2 chars */
; j = kbdin(k);
; j = kbd16(&i);
mov -4[BP],AX
.05F: ;31
cmp WORD PTR -4[BP],1
jn
e .081
push WORD PTR -2[BP]
call KBDIN
add SP,2
mov -4[BP],AX
lea SI,-6[BP]
push SI
call KBD16
a
dd SP,2
mov -4[BP],AX
jmp SHORT .05F
; if (j == AK
EY) return(i & FUNCTION ? i & FUNMASK : i & 0xFF);
.081: ;34
cmp WORD PTR -4[BP],-1
jne .0A4
mov AX,-6[BP]
and AX,
256
or AX,AX
je .09A
mov AX,-6[BP]
and AX,319
jmp SHORT .0A0
.09A: ;35
mov AX,-6[BP]
and AX,255
.0A0: ;35
mov SP,BP
pop BP
ret
; return(0
);
.0A4: ;36
xor AX,AX
mov SP,BP
pop BP
ret
GETKEY ENDP
include epilogue.h
END