home *** CD-ROM | disk | FTP | other *** search
- ;
- ; kb_drive.asm
- ;
- ; Purpose: Keyboard primitives.
- ;
- ; Blackstar C Function Libarary
- ; (c) Copyright 1985,1989 Sterling Castle Software
- ;
-
- include model
- include blackstr.mac
-
-
- ;---------------------------------------------
- ; the interrupt and codes for the interface.
- ;--------------------------------------------
- keyboard equ 16h ;interrupt 16 to deal with keyboard
- video equ 10h ;interrupt for screen
- cicode equ 0 ;code for reading keyboard character
- cstscode equ 1 ;code for keyboard status
- readch equ 08 ;read character
-
- dseg 'DATA'
- unchar dw 0 ;un-keyed character
- enddseg
-
-
- cseg kb_getc_
-
- ;-----------------
- ; kb_getc_ get the next keyboard character.
- ;-----------------
- ; Usage: character = kb_getc_();
- ;
- ; int kb_getc(void);
-
- public kb_getc_
-
- kb_getc_ proc
- prolog
-
- ifdef Large_data
- mov ax,seg dgroup
- mov ds,ax
- endif
-
- mov ax,unchar ;see if character was un_key
- cmp ax,0
- je key_c1
- mov unchar,0 ;kill un_key character
- jmp key_x ;and done
- key_c1:
- mov ah,cicode ;ask for a keyboard character
- int keyboard
- key_x:
-
- ifdef asm_386
- movsx eax,ax
- endif
-
- epilog
- kb_getc_ endp
-
-
- ;--------------------
- ; kb_hit_ return 255 if any available. otherwise
- ;-------------------- return zero.
- ;
- ; Usage: character = kb_hit_();
- ;
- ; int kb_hit_(void);
-
- public kb_hit_
-
- kb_hit_ proc ;return status code if any available
- prolog
-
- ifdef Large_data
- mov ax,seg dgroup
- mov ds,ax
- endif
-
- mov ah,cstscode
- int keyboard
- mov ax,unchar ;get previously un-keyed char
- jz hit_x
- mov ax,255 ;character available flag
-
- hit_x:
- ifdef asm_386
- movsx eax,ax
- endif
-
- epilog
- kb_hit_ endp
-
-
- ;------------------
- ; kb_ungetc_ put back character for next input
- ;------------------
- ; Usage: kb_ungetc_(c);
- ;
- ; int kb_ungetc(char c);
-
- public kb_ungetc_
-
- kb_ungetc_ proc
- parms<<c,byte>>
- prolog
-
- ifdef Large_data
- mov ax,seg dgroup
- mov ds,ax
- endif
-
- mov al,c ;get character to un_key
- mov unchar,ax ;save it
-
- ifdef asm_386
- movsx eax,ax
- endif
-
- epilog
- kb_ungetc_ endp
-
- endcseg kb_getc_
- end
-