1 ;****************************************************************************
3 ;* SciTech Multi-platform Graphics Library
5 ;* ========================================================================
7 ;* The contents of this file are subject to the SciTech MGL Public
8 ;* License Version 1.0 (the "License"); you may not use this file
9 ;* except in compliance with the License. You may obtain a copy of
10 ;* the License at http://www.scitechsoft.com/mgl-license.txt
12 ;* Software distributed under the License is distributed on an
13 ;* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
14 ;* implied. See the License for the specific language governing
15 ;* rights and limitations under the License.
17 ;* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc.
19 ;* The Initial Developer of the Original Code is SciTech Software, Inc.
20 ;* All Rights Reserved.
22 ;* ========================================================================
24 ;* Language: 80386 Assembler
25 ;* Environment: IBM PC (MS DOS)
27 ;* Description: Assembly language support routines for the event module.
29 ;****************************************************************************
33 include "scitech.mac" ; Memory model macros
37 header _event ; Set up memory model
41 cextern _EVT_biosPtr,DPTR
44 %define KB_HEAD WORD esi+01Ah ; Keyboard buffer head in BIOS data area
45 %define KB_TAIL WORD esi+01Ch ; Keyboard buffer tail in BIOS data area
46 %define KB_START WORD esi+080h ; Start of keyboard buffer in BIOS data area
47 %define KB_END WORD esi+082h ; End of keyboard buffer in BIOS data area
49 KB_HEAD EQU WORD esi+01Ah ; Keyboard buffer head in BIOS data area
50 KB_TAIL EQU WORD esi+01Ch ; Keyboard buffer tail in BIOS data area
51 KB_START EQU WORD esi+080h ; Start of keyboard buffer in BIOS data area
52 KB_END EQU WORD esi+082h ; End of keyboard buffer in BIOS data area
57 begcodeseg _event ; Start of code segment
59 cpublic _EVT_codeStart
61 ;----------------------------------------------------------------------------
62 ; int _EVT_getKeyCode(void)
63 ;----------------------------------------------------------------------------
64 ; Returns the key code for the next available key by extracting it from
65 ; the BIOS keyboard buffer.
66 ;----------------------------------------------------------------------------
67 cprocstart _EVT_getKeyCode
71 mov esi,[_EVT_biosPtr]
78 mov ax,[esi+ebx] ; EAX := character from keyboard buffer
81 cmp bx,[KB_END] ; Hit the end of the keyboard buffer?
84 @@1: mov [KB_HEAD],bx ; Update keyboard buffer head pointer
91 ;----------------------------------------------------------------------------
92 ; void _EVT_pumpMessages(void)
93 ;----------------------------------------------------------------------------
94 ; This function would normally do nothing, however due to strange bugs
95 ; in the Windows 3.1 and OS/2 DOS boxes, we don't get any hardware keyboard
96 ; interrupts unless we periodically call the BIOS keyboard functions. Hence
97 ; this function gets called every time that we check for events, and works
98 ; around this problem (in essence it tells the DOS VDM to pump the
99 ; keyboard events to our program ;-).
101 ; Note that this bug is not present under Win 9x DOS boxes.
102 ;----------------------------------------------------------------------------
103 cprocstart _EVT_pumpMessages
105 mov ah,11h ; Function - Check keyboard status
108 mov ax, 0Bh ; Reset Move Mouse
114 ;----------------------------------------------------------------------------
115 ; int _EVT_disableInt(void);
116 ;----------------------------------------------------------------------------
117 ; Return processor interrupt status and disable interrupts.
118 ;----------------------------------------------------------------------------
119 cprocstart _EVT_disableInt
121 pushf ; Put flag word on stack
122 cli ; Disable interrupts!
123 pop eax ; deposit flag word in return register
128 ;----------------------------------------------------------------------------
129 ; void _EVT_restoreInt(int ps);
130 ;----------------------------------------------------------------------------
131 ; Restore processor interrupt status.
132 ;----------------------------------------------------------------------------
133 cprocstart _EVT_restoreInt
138 mov ebp,esp ; Set up stack frame
140 popf ; Restore processor status (and interrupts)
146 ;----------------------------------------------------------------------------
147 ; int EVT_rdinx(int port,int index)
148 ;----------------------------------------------------------------------------
149 ; Reads an indexed register value from an I/O port.
150 ;----------------------------------------------------------------------------
153 ARG port:UINT, index:UINT
168 ;----------------------------------------------------------------------------
169 ; void EVT_wrinx(int port,int index,int value)
170 ;----------------------------------------------------------------------------
171 ; Writes an indexed register value to an I/O port.
172 ;----------------------------------------------------------------------------
175 ARG port:UINT, index:UINT, value:UINT