!************************************************************************** !* !* Boot-ROM-Code to load an operating system across a TCP/IP network. !* !* Module: keyboard.S !* Purpose: Some keyboard related functions !* Entries: _getkey, _chkkey !* !************************************************************************** !* !* Copyright (C) 1995-2003 Gero Kuhlmann !* !* This program is free software; you can redistribute it and/or modify !* it under the terms of the GNU General Public License as published by !* the Free Software Foundation; either version 2 of the License, or !* any later version. !* !* This program is distributed in the hope that it will be useful, !* but WITHOUT ANY WARRANTY; without even the implied warranty of !* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the !* GNU General Public License for more details. !* !* You should have received a copy of the GNU General Public License !* along with this program; if not, write to the Free Software !* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. !* !* $Id: keyboard.S,v 1.5 2003/03/09 00:24:27 gkminix Exp $ !* ! !************************************************************************** ! ! Include assembler macros: ! #include #include "libpriv.inc" ! !************************************************************************** ! ! Start code segment. ! .text public _getkey ! define entry points public _chkkey extrn _set_timeout extrn _chk_timeout ! !************************************************************************** ! ! Wait for keyboard input, and return the key pressed. This routine ! does not print anything. ! Input: 1. arg - timeout value (0 if no timeout) ! Output: character representing pressed key, or -1 if timeout reached ! _getkey: penter (0) ! setup standard stack frame getcarg (ax,0) ! get timeout value or ax,ax jz getk2 ! dont set a timeout if none given call _set_timeout ! set the timeout getk1: getcarg (ax,0) ! check if timeout given or ax,ax jz getk2 ! no timeout call _chk_timeout ! check for timeout or ax,ax jz getk2 ! timeout not reached, so check keyboard mov ax,#-1 jmp getk9 ! got timeout getk2: call _chkkey ! check keyboard status cmp ax,#-1 je getk1 ! check if key has been pressed getk9: pleave ret ! !************************************************************************** ! ! Check if a key pressed. This routine is destructive. ! Input: none ! Output: Character, or -1 if no key pressed ! _chkkey: mov ah,#$01 int INT_KBD ! check keyboard status using BIOS jz chkk8 xor ah,ah ! get character from BIOS int INT_KBD xor ah,ah ! prepare return value ret chkk8: mov ax,#-1 ! no key pressed ret ! !************************************************************************** ! end