$include (..\lib\compStch.ext) /* *============================================================================ * 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 * * Permission to use for any purpose, modify, copy, and make enhancements * and derivative works of the software is granted if attribution is given to * R.M. Gillmore, dba the ACME Software Deli, as the author * * While the ACME Software Deli does not work for money, there is nonetheless * a significant amount of work involved. The ACME Software Deli maintains the * rights to all code written, though it may be used and distributed as long as * the following conditions are maintained. * * 1. The copyright statement at the top of each code block is maintained in * your distribution. * 2. You do not identify yourself as the ACME Software Deli * 3. Any changes made to the software are sent to the ACME Software Deli *============================================================================ */ keyInModule: do; $set (keyInSource) $include (..\lib\comnDefs.ext) $include (..\lib\fileIO.ext) $include (..\lib\sysCalls.ext) $if not noID declare IDString (*) byte data ( '@(#)keyIn.p86 $Author: rmgillmore $ $Date:: 2025-05-04 19:35:39#$:', 0 ); $endif keyboardStatus: procedure byte reentrant public; declare cpuRegisters; byteRegs.Ah = 2; call int86( 16h, @wordRegs ); return ( byteRegs.Al ); end keyboardStatus; kbhit: procedure boolean reentrant public; declare keyAvailable boolean, cpuRegisters; byteRegs.Ah = 00bh; call int86( DOS_CALL, @wordRegs ); keyAvailable = byteRegs.Al; return ( keyAvailable ); end kbhit; /* * call this CI because that is what Intel used in their OS API */ ci: procedure integer reentrant public; declare keyRead integer, cpuRegisters; /* * flush the input buffer * read a key * if zero is returned * read another key * negate the value read */ /* console input without echo */ /* flush keyboard buffer */ wordRegs.Ax = 00c08h; call int86( DOS_CALL, @wordRegs ); if ( byteRegs.Al <> 0 ) then do; keyRead = signed( double( byteRegs.Al ) ); end; else do; byteRegs.Ah = 008h; call int86( DOS_CALL, @wordRegs ); keyRead = -( signed( double( byteRegs.Al ) ) ); end; return ( keyRead ); end ci; getch: procedure integer reentrant public; declare keyRead integer, cpuRegisters; wordRegs.Ax = 00800h; call int86( DOS_CALL, @wordRegs ); if ( byteRegs.Al <> 0 ) then do; keyRead = signed( double( byteRegs.Al ) ); end; else do; call int86( DOS_CALL, @wordRegs ); keyRead = -( signed( double( byteRegs.Al ) ) ); end; return ( keyRead ); end getch; /* * ============================================================================ * Function: pause * * Description: This function writes a prompt string to the console, then * flushes the console input device buffer and waits for a * keystroke * ============================================================================ */ pause: procedure reentrant public; declare keyDoesntMatter integer; call printStringAsciiZ( @( 'Press Any Key to Continue', 0 ) ); keyDoesntMatter = ci; end pause; end keyInModule;