KEYIREAL.ASM 69 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610
  1. ;
  2. ; Command & Conquer Red Alert(tm)
  3. ; Copyright 2025 Electronic Arts Inc.
  4. ;
  5. ; This program is free software: you can redistribute it and/or modify
  6. ; it under the terms of the GNU General Public License as published by
  7. ; the Free Software Foundation, either version 3 of the License, or
  8. ; (at your option) any later version.
  9. ;
  10. ; This program is distributed in the hope that it will be useful,
  11. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ; GNU General Public License for more details.
  14. ;
  15. ; You should have received a copy of the GNU General Public License
  16. ; along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. ;
  18. ;***************************************************************************
  19. ;** C O N F I D E N T I A L --- W E S T W O O D A S S O C I A T E S **
  20. ;***************************************************************************
  21. ;* *
  22. ;* Project Name : Westwood 32 bit Library *
  23. ;* (Mouse Routines)
  24. ;* *
  25. ;* File Name : KEYIREAL.ASM *
  26. ;* *
  27. ;* Programmer : Philip W. Gorrow *
  28. ;* *
  29. ;* Start Date : May 21, 1992 *
  30. ;* *
  31. ;* Last Update : July 13, 1994 [PWG] *
  32. ;* *
  33. ;* This file sort of breaks the standard of keeping all of the keyboard *
  34. ;* and mouse routines isolated. This is done because the mouse and *
  35. ;* the keyboard share data, and the best way to do this is to put *
  36. ;* them in the same segment. This should probably be split into several *
  37. ;* include files to help make the code clearer once it is finally put *
  38. ;* together. *
  39. ;* *
  40. ;*-------------------------------------------------------------------------*
  41. ;* Functions: *
  42. ;* KeyNum_Translate -- Translates extended keynums to normal keynums *
  43. ;* Stuff_Key_Word -- Stuffs a word of data into keyboard buffer *
  44. ;* Stuff_Key_Num -- Stuffs a key num code into the circular buffer *
  45. ;* Keystroke_Interrupt -- Real mode handler of input from the keyboard *
  46. ;* Break_Interrupt -- Handles the break key interrupt *
  47. ;* Call_Interrupt_Chain -- Function PM calls to call RM interrupt chain *
  48. ;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
  49. ;* *
  50. ;* Keyboard driver -- 8086 Assembly portion; *
  51. ;* updated by: Phil Gorrow for 32 bit Protected Mode *
  52. ;***************************************************************************
  53. ;---------------------------------------------------------------------------
  54. ; Set the assembly directives
  55. ;---------------------------------------------------------------------------
  56. IDEAL ; the product runs in ideal mode
  57. P386N ; use 386 real mode instructions
  58. MODEL TINY ; code must be tiny so it fits
  59. LOCALS ?? ; ?? is the symbol for a local
  60. WARN ; generate all warnings we can
  61. JUMPS ; optimize jumps if possible
  62. ;---------------------------------------------------------------------------
  63. ; Include all of the keyboard specific defines
  64. ;---------------------------------------------------------------------------
  65. INCLUDE "keyboard.inc"
  66. CONDHIDE EQU 08000H ; bit for testing conditional region
  67. CONDHIDDEN EQU 04000H ; bit for testing conditional hidden
  68. RESTORE_VISIBLE_PAGE EQU 0
  69. STORE_VISIBLE_PAGE EQU 1
  70. GLOBAL set_vesa_page :near
  71. GLOBAL set_vesa_window :near
  72. GLOBAL get_vesa_window :near
  73. GLOBAL next_vesa_page :near
  74. ECHOON equ 0
  75. ;---------------------------------------------------------------------------
  76. ; WARNING!!!! All of the following code segment variables are shared by
  77. ; the protected mode interrupt. Do not change these unless you make the
  78. ; proper changes to KEYSTRUC.INC. If you do not know what you are doing,
  79. ; find someone who does!!!
  80. ;---------------------------------------------------------------------------
  81. CODESEG
  82. ;---------------------------------------------------------------------------
  83. ; Begin definition of Keyboard specific variables
  84. ;---------------------------------------------------------------------------
  85. SoundOn DW 1 ; toggled by alt S
  86. MusicOn DW 1 ; toggled by alt M
  87. KeyFlags DD REPEATON+CTRLALTTURBO ; all but repeat for now
  88. Break DW 0
  89. KeyMouseMove DB -1,0,1
  90. DB -16,0,16
  91. ScreenEdge DW 320/2,0 ; North
  92. DW 319,0 ; North-East
  93. DW 319,138/2 ; East
  94. DW 319,137 ; South-East
  95. DW 320/2,137 ; South
  96. DW 0,137 ; South-West
  97. DW 0,138/2 ; West
  98. DW 0,0 ; North-West
  99. DW 320/2,138/2 ; Center
  100. Bits DB 01H,02H,04H,08H,10H,20H,40H,80H
  101. CondPassKey DW 0220H, 0320H, 060CH, 070DH, 066AH
  102. DW 0669H, 0230H, 0330H, 007DH, 017DH
  103. DW 025AH, 035AH, 0200H, 0410H, 046EH
  104. DW 026EH, 007CH
  105. CondPassCond DW CTRLSON, CTRLSON, CTRLALTTURBO, CTRLALTTURBO, CTRLALTTURBO
  106. DW CTRLALTTURBO, CTRLCON, CTRLCON, SCROLLLOCKON, SCROLLLOCKON
  107. DW PAUSEON, PAUSEON, BREAKON, TASKSWITCHABLE, TASKSWITCHABLE
  108. DW TASKSWITCHABLE, BREAKON
  109. EscRoutine DD 0 ; vector to execute on esc key press (0=none)
  110. ; Extended raw keycodes to be converted to Westwood keycodes.
  111. ExtCodes DB 038H,01DH,052H,053H,04BH,047H,04FH,048H,050H,049H
  112. DB 051H,04DH,035H,01CH,037H
  113. DB 046H
  114. ; The matching Westwood keycodes.
  115. ExtNums DB 62, 64, 75, 76, 79, 80, 81, 83, 84, 85
  116. DB 86, 89, 95, 108, 124, 0
  117. ; If extended mapping is disabled, then these codes really are...
  118. ExtRemap DB 60, 58, 99, 104, 92, 91, 93, 96, 98, 101
  119. DB 103, 102, 55, 43, 124, 0
  120. ExtRemapEnd DB 0
  121. ExtKeyboard DB 0 ; flag for 101/102-key keyboard
  122. KeyBuffer DW 128 DUP(0) ; set to empty
  123. KeyBufferHead DD 0 ; set to first entry
  124. KeyBufferTail DD 0 ; set to head for empty buffer
  125. KeyLock DW 0 ; num and caps lock bits
  126. KeyNums DB 127,110,002,003,004,005,006,007,008,009,010,011,012,013,015,016
  127. DB 017,018,019,020,021,022,023,024,025,026,027,028,043,058,031,032
  128. DB 033,034,035,036,037,038,039,040,041,001,044,029,046,047,048,049
  129. DB 050,051,052,053,054,055,057,100,060,061,030,112,113,114,115,116
  130. DB 117,118,119,120,121,090,125,091,096,101,105,092,097,102,106,093
  131. DB 098,103,099,104,127,127,127,122,123
  132. KeysCapsLock DB 0,0,0FEH,087H,0FFH,0C0H,01FH,0,0,0,0,0,0,0,0,0
  133. KeysNumLock DB 0,0,0,0,0,0,0,0,0,0,0,038H,0EFH,1,0,0
  134. KeysUpDown DB 16 DUP(0) ; set to all keys up
  135. KeyStream DB 16 DUP(0) ; set to all keys up
  136. PassCount DW 0
  137. KeyStreamIndex DW 0
  138. LastKeyE0 DB 0
  139. LastKeyE1 DB 0
  140. ;
  141. ; Westwood key number values of keys to pass through
  142. ;
  143. ; CAPS, LEFT_SHIFT, RIGHT_SHIFT, LEFT_CTRL, LEFT_ALT,
  144. ; RIGHT_ALT, RIGHT_CTRL, NUM_LOCK, UNKNOWN
  145. PassAlways DB 30, 44, 57, 58, 60, 62, 64, 90, 128, 128
  146. PassAlwaysEnd DB 128 ; invalid code to END PassAlways
  147. CtrlFlags DB 0
  148. Buffer DW ?
  149. Time DW ?
  150. ADJUST = 1 ; do not modify DRD
  151. XYAdjust DB -ADJUST, -ADJUST ; 91 -> upleft
  152. DB -ADJUST, 0 ; 92 -> left
  153. DB -ADJUST, ADJUST ; 93 -> downleft
  154. DB 0, 0 ; 94 illegal
  155. DB 0, 0 ; 95 illegal
  156. DB 0, -ADJUST ; 96 -> up
  157. DB 0, 0 ; 97 illegal (center)
  158. DB 0, ADJUST ; 98 -> down
  159. DB 0, 0 ; 99 illegal
  160. DB 0, 0 ; 100 illegal
  161. DB ADJUST, -ADJUST ; 101 -> upright
  162. DB ADJUST, 0 ; 102 -> right
  163. DB ADJUST, ADJUST ; 103 -> downright
  164. EdgeConv DW 8,2,8,6,4,3,8,5,8,8,8,8,0,1,8,7
  165. MouseUpdate DW 0
  166. MouseX DW 0,0
  167. LocalMouseX DW 0
  168. MouseY DW 0,0
  169. LocalMouseY DW 0
  170. IsExtKey DB 0
  171. ExtIndex DW 0
  172. KeyOldRMI DD 0 ; The origianl RM interrupt seg:off.
  173. KeyOldPMIOffset DD 0 ; The origianl PM interrupt offset
  174. KeyOldPMISelector DD 0 ; The original PM interrupt segment.
  175. KeyCodeOffset DW RM_Keystroke_Interrupt ; Offset of the code in the RM stuff.
  176. CallKeyRMIntOffset DW Call_Interrupt_Chain ; Offset of function to call DOS timer interrupt.
  177. CallKeyRMIntAddr DD 0 ; PM address of CallRealIntOffset for speed.
  178. PMIssuedKeyInt DD 0
  179. BrkOldRMI DD 0 ; The origianl RM interrupt seg:off.
  180. BrkOldPMIOffset DD 0 ; The origianl PM interrupt offset
  181. BrkOldPMISelector DD 0 ; The original PM interrupt segment.
  182. BrkCodeOffset DW RM_Break_Interrupt ; Offset of the code in the RM stuff.
  183. CallBrkRMIntOffset DW 0
  184. CallBrkRMIntAddr DD 0 ; PM address of CallRealIntOffset for speed.
  185. PMIssuedBrkInt DD 0
  186. KeyIntDisabled DD 0
  187. DbgOldPMIOffset DD 0 ; The origianl PM interrupt offset
  188. DbgOldPMISelector DD 0 ; The original PM interrupt segment.
  189. ;---------------------------------------------------------------------------
  190. ; Begin definition of Mouse Specific Variables for real mode
  191. ;---------------------------------------------------------------------------
  192. Button DB 0 ; current value of the mouse button
  193. MDisabled DB 0 ; Is the mouse driver disabled
  194. MInput DB 1 ; Defaults to mouse input allowed.
  195. Adjust DW 0 ; flag to adjust coordinates if necessary
  196. MouseStepX DW 0 ; step values if the mouse moves at
  197. MouseStepY DW 0 ; more than one pixel at a time
  198. MouseOffsetX DW 0 ; Fractional step values used if a mouse
  199. MouseOffsetY DW 0 ; moves at less than one pixel at a time
  200. MState DW 0,0 ; Tracks if mouse is hidden (TRUE) or not (FALSE)
  201. MouseXOld DW 0 ; Holds last MouseX and MouseY to determine if
  202. MouseYOld DW 0 ; mouse needs to be redrawn
  203. MCState DW 0 ; Tracks if mouse conditional hidden (TRUE) or not
  204. MouseCXLeft DW 0,0 ; Conditional hide mouse left x position
  205. MouseCYUpper DW 0,0 ; Conditional hide mouse top y position
  206. MouseCXRight DW 0,0 ; Conditional hide mouse right x position
  207. MouseCYLower DW 0,0 ; Conditional hide mouse lower y position
  208. MouseCursor DD 0 ; Pointer to the mouse cursor to draw
  209. MouseCursorSize DW 0 ; Pointer to buffer mouse is saved in
  210. MouseBuffer DD 0 ; Pointer to buffer mouse is saved in
  211. MouseXHot DW 0,0 ; Offset to mouse's x hot spot
  212. MouseYHot DW 0,0 ; Offset to mouse's y hot spot
  213. MouseBuffX DW 0,0 ; X position background was saved at
  214. MouseBuffY DW 0,0 ; Y position background was saved at
  215. MouseBuffW DW 0,0 ; Width of the region saved for mouse
  216. MouseBuffH DW 0,0 ; Height of the region saved for mouse
  217. MouseWidth DW 0,0 ; Mouse cursor theoretical width
  218. MouseHeight DW 0,0 ; Mouse cursor theoretical height
  219. MouseCodeOffset DW RM_Mouse_Interrupt ; Offset of the code in the RM stuff.
  220. MouseRight DW 0,0
  221. MouseBottom DW 0,0
  222. ShadowPtr dw 0
  223. DrawMousePtr dw 0
  224. VGAMouseDraw dw VGA_Draw_Mouse
  225. VGAMouseShadow dw VGA_Mouse_Shadow_Buffer
  226. VESAMouseDraw dw VESA_Draw_Mouse
  227. VESAMouseShadow dw VESA_Mouse_Shadow_Buffer
  228. VesaPtr dd 0
  229. banktable dd 8 dup ( 0 )
  230. Adjust_XPos dw 0 , 0
  231. Adjust_YPos dw 0 , 0
  232. align 2
  233. Keyboard_App_Stack_ES dw 0 ; This the System Stack Offsset
  234. Keyboard_App_Stack_SS dw 0 ; This the System Stack Selector
  235. Keyboard_StackPointer dw 0DEADh ; We Create a Local Application
  236. Keyboard_Stack dw 512 dup (0)
  237. Keyboard_StackStart dw 0
  238. Mouse_State dw 0 ; Mouse Temp Variable
  239. Mouse_Cond dw 0 ; Mouse Temp Variable
  240. Mouse_App_Stack_ES dw 0 ; This the System Stack Offsset
  241. Mouse_App_Stack_SS dw 0 ; This the System Stack Selector
  242. Mouse_StackPointer dw 0DEADh ; We Create a Local Application
  243. Mouse_Stack dw 512 dup (0)
  244. Mouse_StackStart dw 0
  245. current_page dw 0
  246. ;***************************************************************************
  247. ;* KEYNUM_TRANSLATE -- Translates extended keynums to normal keynums *
  248. ;* *
  249. ;* INPUT: UWORD the keynum to translate *
  250. ;* *
  251. ;* OUTPUT: WORD the translated keynum *
  252. ;* *
  253. ;* PROTO: UWORD KeyNum_Translate(UWORD keynum); *
  254. ;* *
  255. ;* HISTORY: *
  256. ;* 07/11/1994 PWG : Created. *
  257. ;*=========================================================================*
  258. GLOBAL KeyNum_Translate:FAR
  259. PROC KeyNum_Translate C FAR
  260. USES cx,di,es,ds
  261. ARG keycode:WORD
  262. mov ax,cs ; since we are in tiny model
  263. mov ds,ax ; set cs = ds
  264. mov es,ax ; set es up for scansb
  265. mov ax,[keycode]
  266. test [WORD PTR KeyFlags],TRACKEXT
  267. jne short ??fini
  268. mov cx,ExtRemap-ExtNums
  269. mov di,OFFSET ExtNums
  270. repne scasb
  271. jcxz short ??fini ; No match found.
  272. mov di,OFFSET ExtRemapEnd
  273. dec di
  274. sub di,cx
  275. mov al,[es:di]
  276. ??fini:
  277. ret
  278. ENDP KeyNum_Translate
  279. ;***************************************************************************
  280. ;* STUFF_KEY_WORD -- Stuffs a word of data into keyboard buffer *
  281. ;* *
  282. ;* INPUT: WORD the code to stick into the circular buffer *
  283. ;* *
  284. ;* OUTPUT: WORD !=0 is sucessful, ==0 is not enough room *
  285. ;* *
  286. ;* PROTO: VOID Stuff_Key_WORD(WORD code); *
  287. ;* *
  288. ;* HISTORY: *
  289. ;* 07/11/1994 PWG : Created. *
  290. ;*=========================================================================*
  291. GLOBAL C Stuff_Key_WORD:FAR
  292. PROC Stuff_Key_WORD C FAR
  293. USES si,bx,ds
  294. ARG code:WORD
  295. mov ax,cs ; since we are in tiny model
  296. mov ds,ax ; set cs = ds
  297. mov ax,[WORD PTR KeyBufferTail]
  298. mov si,ax
  299. add ax,2
  300. and ax,0FFh ; New KeyBufferTail value.
  301. cmp [WORD PTR KeyBufferHead],ax
  302. je short ??noroom
  303. mov bx,[code]
  304. mov [KeyBuffer+si],bx ; Record the keystroke.
  305. mov [WORD PTR KeyBufferTail],ax
  306. xor ax,ax
  307. ret
  308. ??noroom:
  309. mov ax,1
  310. ret
  311. ENDP Stuff_Key_WORD
  312. ;***************************************************************************
  313. ;* STUFF_KEY_NUM -- Stuffs a key num code into the circular buffer *
  314. ;* *
  315. ;* INPUT: WORD the keycode to stuff *
  316. ;* *
  317. ;* OUTPUT: WORD !=0 is sucessful, ==0 is not enough room *
  318. ;* *
  319. ;* PROTO: VOID Stuff_Key_Num(WORD keynum); *
  320. ;* *
  321. ;* HISTORY: *
  322. ;* 07/11/1994 PWG : Created. *
  323. ;*=========================================================================*
  324. GLOBAL C Stuff_Key_Num:FAR
  325. PROC Stuff_Key_Num C FAR
  326. USES bx,cx,dx,di,si,ds
  327. ARG keycode:WORD
  328. LOCAL tail:WORD ; Original keybuffer tail (safety copy).
  329. LOCAL size:WORD ; Size of write.
  330. pushf
  331. cli ; disable interrupts
  332. ; Abort key recognition if in record mode and unable
  333. ; to output key due to simultaneous DOS operation.
  334. mov ax,cs ; since we are in tiny model
  335. mov ds,ax ; set cs = ds
  336. ; Record the mouse position to be stuffed into buffer.
  337. mov ax,[MouseX]
  338. mov [LocalMouseX],ax
  339. mov ax,[MouseY]
  340. mov [LocalMouseY],ax
  341. ??cando:
  342. mov ax,[keycode] ; get the code
  343. or ax,ax ; Null keycodes are not recorded.
  344. jne short ??validkey
  345. jmp ??exit
  346. ??validkey:
  347. test [WORD PTR KeyFlags],KEYMOUSE ; is the numeric keypad moving the mouse?
  348. je ??no_pad_move
  349. ; ALT-cursor keys are undefined. Pass them on to the program.
  350. test ah,ALTPRESS ; is either alt key down?
  351. jne ??no_pad_move
  352. test [WORD PTR KeyFlags],SIMLBUTTON ; are we simulating left mouse presses
  353. je short ??chkinsert
  354. cmp al,KN_RETURN
  355. je short ??forceleft
  356. cmp al,KN_SPACE
  357. je short ??forceleft
  358. cmp al,KN_KEYPAD_RETURN
  359. je short ??forceleft
  360. ??chkinsert:
  361. cmp al,KN_INSERT
  362. jne short ??regular
  363. ??forceleft:
  364. mov al,KN_LMOUSE
  365. or [Button],1 ; Left mouse bit.
  366. test ah,KEYRELEASE
  367. je ??mousefake
  368. and [Button],NOT 1
  369. jmp ??mousefake
  370. ??regular:
  371. cmp al,KN_DELETE
  372. jne short ??regular2
  373. mov al,KN_RMOUSE
  374. or [Button],2 ; Right mouse bit.
  375. test ah,KEYRELEASE
  376. je ??mousefake
  377. and [Button],NOT 2
  378. jmp ??mousefake
  379. ??regular2:
  380. ; DRD correction to ignore key releases for key mouse movement
  381. test ah,KEYRELEASE
  382. jne ??no_pad_move
  383. cmp al,KN_CENTER
  384. je short ??pad_move
  385. cmp al,KN_UPLEFT ; less than upleft?
  386. jb ??no_pad_move ; yes, then it isn't a keypad key
  387. cmp al,KN_DOWNRIGHT ; greater than downright?
  388. ja ??no_pad_move ; yes, then it isn't a keypad key
  389. cmp al,KN_DOWNLEFT ; is it UPLEFT, LEFT, or DOWNLEFT?
  390. jbe short ??pad_move
  391. cmp al,KN_UPRIGHT ; is it UPRIGHT, RIGHT, or DOWNRIGHT?
  392. jae short ??pad_move
  393. cmp al,KN_UP ; up?
  394. je short ??pad_move
  395. cmp al,KN_DOWN ; down?
  396. jne ??no_pad_move
  397. ??pad_move:
  398. ; DRD correction to use ch for ah
  399. mov ch,ah ; save shift-ctrl-alt-rlse status
  400. xor ah,ah ; get rid of any bits
  401. sub al,KN_UPLEFT ; get a number between 0 and 12
  402. mov bx,ax
  403. shl bx,1 ; double for WORD index
  404. add bx,OFFSET XYAdjust
  405. mov ax,[bx] ; get x,y add value
  406. mov bl,ah
  407. cbw
  408. xchg ax,bx
  409. cbw
  410. xchg ax,bx ; AX = mouse x delta, BX = mouse y delta
  411. ; DRD correction to use ch
  412. ; The CTRL key moves the mouse to the edge of the screen.
  413. test ch,CTRLPRESS ; is either ctrl key down?
  414. jne short ??ctrlon ; if so, ctrl is on
  415. ; DRD correction to use ch
  416. ; use fast speed of the mouse move if the shift key is held down.
  417. mov dx,1 ; for slow speed
  418. test ch,SHIFTPRESS ; is either shift key down?
  419. je short ??normspeed ; if not then neither shift is down
  420. ??doublespeed:
  421. add dx,3 ; for fast speed
  422. ??normspeed:
  423. add bx,dx ; add speed for y index
  424. mov bl,[KeyMouseMove+bx] ; get speed for y delta
  425. xchg ax,bx ; swap with ax to extend sign
  426. cbw
  427. xchg ax,bx
  428. xchg bx,dx ; save mouse y delta
  429. add bx,ax ; add speed for x index
  430. mov al,[KeyMouseMove+bx] ; get speed for x delta
  431. cbw
  432. xchg bx,dx ; restore mouse y delta
  433. jmp short ??ctrloff
  434. ??ctrlon:
  435. ; Table lookup method for determining hotkey positions for CTRL
  436. ; cursor combination. This algorithm is hard coded for an ADJUST
  437. ; value of 3. If this value changed, then this section will also
  438. ; have to be modified.
  439. and bx,011b ; Y = 1, 0, 3
  440. and ax,011b ; X = 1, 0, 3
  441. ; Table lookup method for determining hotkey positions for CTRL
  442. ; cursor combination. This algorithm is hard coded.
  443. ; -1, 0, 1
  444. and bx,011b ; Y = 3, 0, 1
  445. and ax,011b ; X = 3, 0, 1
  446. shl bx,1
  447. shl bx,1
  448. or bx,ax ; Lookup index.
  449. ; Convert raw index into logical (clockwise) index.
  450. shl bx,1
  451. mov bx,[EdgeConv+bx]
  452. shl bx,1
  453. shl bx,1
  454. mov ax,[ScreenEdge+bx] ; New absolute X
  455. mov bx,[ScreenEdge+bx+2] ; New absolute Y
  456. mov [LocalMouseX],ax
  457. mov [LocalMouseY],bx
  458. ??set_xyz:
  459. mov ax,[LocalMouseX] ; get new mouse x,y
  460. mov bx,[LocalMouseY]
  461. jmp short ??set_xy
  462. ; Process a normal faked mouse move.
  463. ??ctrloff:
  464. ; DRD change
  465. add [LocalMouseX],ax ; save it in our local
  466. jns short ??not_negative_x
  467. xor ax,ax
  468. mov [LocalMouseX],ax ; clear our local
  469. ??not_negative_x:
  470. ; DRD change
  471. add [LocalMouseY],bx ; save it in our local
  472. jns short ??not_negative_y
  473. xor bx,bx
  474. mov [LocalMouseY],bx ; clear our local
  475. ??not_negative_y:
  476. mov ax,[LocalMouseX] ; get new mouse x,y
  477. mov bx,[LocalMouseY]
  478. cmp ax,MAX_X_PIXEL ; bigger than
  479. jle short ??check_y
  480. mov ax,MAX_X_PIXEL
  481. ??check_y:
  482. cmp bx,MAX_Y_PIXEL ; bigger than
  483. jle short ??set_xy
  484. mov bx,MAX_Y_PIXEL
  485. ??set_xy:
  486. mov [LocalMouseX],ax
  487. mov [LocalMouseY],bx
  488. mov [MouseX],ax
  489. mov [MouseY],bx
  490. cmp [MouseUpdate],0 ; wait until mouse interrupt is done
  491. jne short ??noshow
  492. call Low_Hide_Mouse
  493. call Low_Show_Mouse
  494. ??noshow:
  495. mov ax,KN_MOUSE_MOVE
  496. ??mousefake:
  497. mov [keycode],ax ; Fake a MOUSE_MOVE event.
  498. ??no_pad_move:
  499. ; Fetch working pointers to the keyboard ends.
  500. mov si,[WORD KeyBufferTail]
  501. mov [tail],si ; Safety record.
  502. mov di,[WORD PTR KeyBufferHead]
  503. ; Record the base keycode (if there is room).
  504. push ax
  505. call Stuff_Key_WORD
  506. add sp,2
  507. or ax,ax
  508. jne short ??jmpnoroom
  509. ; Also record the mouse coordinates if necessary.
  510. mov ax,[keycode] ; get key code
  511. cmp al,KN_MOUSE_MOVE ; mouse move?
  512. je short ??recordmouse ; yes? then record the mouse cooordinates
  513. cmp al,KN_LMOUSE
  514. je short ??recordmouse
  515. cmp al,KN_RMOUSE
  516. je short ??recordmouse
  517. jmp short ??ok
  518. ??jmpnoroom:
  519. jmp ??noroom
  520. ; Record mouse coordinate X.
  521. ??recordmouse:
  522. push [LocalMouseX]
  523. call Stuff_Key_WORD
  524. add sp,2
  525. or ax,ax
  526. jne ??jmpnoroom
  527. add [size],2
  528. ; Record mouse coordinate Y.
  529. push [LocalMouseY]
  530. call Stuff_Key_WORD
  531. add sp,2
  532. or ax,ax
  533. jne ??jmpnoroom
  534. add [size],2
  535. ??ok:
  536. ; If PASSBREAKS is not active and this is a keyboard
  537. ; break AND it is not a mouse event, then don't put
  538. ; it into the buffer.
  539. mov bx,0101h ; Bit control tools.
  540. mov ax,[keycode]
  541. cmp al,KN_MOUSE_MOVE
  542. je short ??notreal
  543. cmp al,127
  544. je short ??notreal
  545. test ah,KEYRELEASE
  546. je short ??real
  547. xor bl,bl
  548. test [WORD PTR KeyFlags],PASSBREAKS
  549. jne short ??real
  550. cmp al,KN_LMOUSE
  551. je short ??real
  552. cmp al,KN_RMOUSE
  553. je short ??real
  554. ??notreal:
  555. mov [WORD PTR KeyBufferTail],si ; Nullify any KeyBufferTail changes.
  556. ??real:
  557. ; Update the KeysUpDown bit array.
  558. mov di,ax
  559. and di,07Fh
  560. mov cl,3
  561. shr di,cl ; DI = Byte offset into bit table.
  562. mov cl,al
  563. and cl,0111b ; CL = Bit offset into bit table byte.
  564. shl bx,cl
  565. not bh
  566. ; If this is a reapeat key and the key is already being held
  567. ; down, then don't stuff it into the keyboard buffer.
  568. test bl,[KeysUpDown+di]
  569. je short ??notalready
  570. test [WORD PTR KeyFlags],REPEATON
  571. jne short ??notalready
  572. mov [WORD PTR KeyBufferTail],si ; Nullify any KeyBufferTail changes.
  573. ??notalready:
  574. and [KeysUpDown+di],bh ; Force key bit to zero.
  575. or [KeysUpDown+di],bl ; Insert key bit as appropriate.
  576. ;??notreal:
  577. ; Successful keybuffer stuff could result in a
  578. ??norecord:
  579. mov ax,1
  580. jmp short ??exit
  581. ; Unsuccessful keybuffer stuff.
  582. ??noroom:
  583. mov ax,[tail]
  584. mov [WORD PTR KeyBufferTail],ax
  585. xor ax,ax ; Signal an error.
  586. ??exit:
  587. popf
  588. ret
  589. ENDP Stuff_Key_Num
  590. ;***********************************************************
  591. ;***************************************************************************
  592. ;* KEYSTROKE_INTERRUPT -- Handles input that comes from the keyboard *
  593. ;* *
  594. ;* This routine intercepts the key codes on their way to the *
  595. ;* BIOS. With the adjustment of the Flags described above *
  596. ;* you can get a wide variety of effects. *
  597. ;* *
  598. ;* INPUT: none *
  599. ;* *
  600. ;* OUTPUT: none *
  601. ;* *
  602. ;* WARNINGS: This is an interrupt function *
  603. ;* *
  604. ;* HISTORY: *
  605. ;* 07/13/1994 PWG : Created. *
  606. ;*=========================================================================*
  607. label RM_Keystroke_Interrupt
  608. GLOBAL C Keystroke_Interrupt:FAR
  609. PROC Keystroke_Interrupt C FAR
  610. IF 0
  611. push ax
  612. inc ax
  613. pop ax
  614. iret
  615. ELSE
  616. push ax
  617. push bx
  618. push cx
  619. push di
  620. push ds
  621. push dx
  622. push es
  623. push si
  624. cld
  625. mov ax,cs ; set ds to cs to avoid cs overide
  626. mov ds,ax
  627. ; At this point we do not know if the SS selector is a
  628. ; System Stack or the Application Stack pointer.
  629. ; Soo to be in the safe side we create our own local
  630. ; Stack Pointer Selector Relative to DS
  631. ; Note Do not try this trick in a reentrant interrupt
  632. mov cx, ss ; get SS
  633. mov [Keyboard_App_Stack_ES], sp ; Protect ES
  634. mov [Keyboard_App_Stack_SS], cx ; Protect SS
  635. lea dx, [Keyboard_StackStart ] ; Compute Local Stack size
  636. and dx, -2;
  637. cli ; Disable All interrupts
  638. mov ss, ax ; Set new SS Selector
  639. mov sp, dx ; Set new Stack Offset
  640. sti ; Enable Interrupts
  641. cmp [WORD PTR PMIssuedKeyInt],0; Check to see if PM made Int call.
  642. mov [WORD PTR PMIssuedKeyInt],0; Make it false.
  643. jne ??passcode ; if so, just call Int Chain.
  644. mov dx,[WORD PTR KeyFlags]
  645. ;*** The following fix allows proper caps and num lock tracking on Tandy
  646. ; 10-6-89 LJC, DRD
  647. and [KeyLock],NOT (NUMLOCK OR CAPSLOCK); assume caps and num inactive
  648. mov ax,040H ; BIOS segment
  649. mov es,ax ; put in es
  650. test [BYTE PTR es:017H],040H ; test Caps lock bit in BIOS
  651. je short ??bioscapsoff ; skip activate code
  652. or [KeyLock],CAPSLOCK ; Caps Lock active
  653. ??bioscapsoff:
  654. test [BYTE PTR es:017H],020H ; test Num lock bit in BIOS
  655. je short ??biosnumoff ; skip activate code
  656. or [KeyLock],NUMLOCK ; Num Lock active
  657. ??biosnumoff:
  658. mov [ExtKeyboard],TRUE ; assume 101/102-key keyboard
  659. test [BYTE PTR es:096H],010H ; test for 101/102-key keyboard
  660. jne short ??extkeyboard ; skip deactivate code
  661. mov [ExtKeyboard],FALSE ; no 101/102-key keyboard
  662. ??extkeyboard:
  663. mov ax,cs ; set ds to cs to avoid cs overide
  664. mov es,ax
  665. cld ; clear direction flag for strings
  666. xor ah,ah ; clear ctrl flags to 0
  667. mov bx,0101H ; set key to a make by default
  668. in al,KEYDATA ; get a code from the keyboard
  669. ;
  670. ; New CODE to montior key stream
  671. ;
  672. mov bx,[KeyStreamIndex]
  673. mov [KeyStream+bx],al
  674. inc bx
  675. and bx,15
  676. mov [KeyStreamIndex],bx
  677. mov bx,0101H ; set key to a make by default
  678. ;
  679. ; END OF SEQUENCE
  680. ;
  681. ;
  682. ; Handle the PAUSE key being pressed. If it is pressed, then
  683. ; signal that the next two input codes are to be thrown out.
  684. ;
  685. cmp al,0E1H ; see if this is a pause/break
  686. jne short ??notpcode ; not a pause/break start code
  687. mov [LastKeyE1],3 ; absorb this and next two codes
  688. ??notpcode:
  689. cmp [LastKeyE1],0 ; are we in a pause/break code
  690. je short ??notpause ; no, just keep going
  691. dec [LastKeyE1] ; yes, dec the count
  692. test dx,PAUSEON ; should it pass these codes
  693. jne ??passcode ; pass the code
  694. jmp ??absorbcode ; don't pass code
  695. ??notpause:
  696. ;
  697. ; Record any extended key codes that arrive. They will be
  698. ; taken into account with the next code.
  699. ;
  700. cmp al,0E0H ; is it an extended code
  701. jne short ??notextcode ; if not skip to handle key
  702. mov [LastKeyE0],TRUE ; set the extended code to 1
  703. ??jmppasscode:
  704. jmp ??passcode ; always pass E0s
  705. ??notextcode:
  706. ;
  707. ; Check and acknowledge if the key is a make or a break.
  708. ;
  709. test al,080H ; test for high bit
  710. je short ??make ; if off its a make
  711. xor bl,bl ; set make/break to break
  712. and al,07FH ; clear high bit
  713. or ah,KEYRELEASE ; CDY NEW -- ABSENT IN OLD CODE
  714. ??make:
  715. ;
  716. ; Translate the raw keycode into the Westwood keycode.
  717. ;
  718. cmp [LastKeyE0],FALSE ; was the prev byte an E0?
  719. je short ??normal ; if not it is a normal key
  720. mov [LastKeyE0],FALSE ; if so clear for next read
  721. mov [IsExtKey],TRUE ; it is an extended key
  722. mov di,OFFSET ExtCodes ; get offset of extended codes table
  723. mov cx,(ExtNums-ExtCodes) ; get number of entrys in ext table
  724. repne scasb ; look for a match
  725. jcxz ??absorbcode ; Not recognized, so throw it away.
  726. mov al,[(ExtNums - ExtCodes) - 1 + di] ; get the match
  727. mov [IsExtKey],FALSE ; it is not an extended key
  728. jmp short ??notext
  729. ??normal:
  730. cmp al,07Ah
  731. jne short ??normok
  732. mov al,128
  733. jmp short ??notext
  734. ??normok:
  735. mov di,ax ; use code as an index
  736. and di,007Fh ; Mask off any release bit.
  737. mov al,[KeyNums+di] ; get the key number of this key
  738. ??notext:
  739. ;
  740. ; Test and set the CTRL bit.
  741. ;
  742. test [KeysUpDown+8],001H ; is the right ctrl down?
  743. jne short ??ctrlon ; if so, ctrl is on
  744. test [KeysUpDown+7],004H ; is the left ctrl down?
  745. je short ??ctrloff ; if not, neither are down, no ctrl
  746. ; DRD
  747. ; check for CTRL-NUMLOCK for pause on some keyboards
  748. cmp al,KN_NUMLOCK ; check for CTRL-NUMLOCK
  749. jne short ??ctrlon
  750. cmp [ExtKeyboard],TRUE ; if 101/102-key keyboard it is ok
  751. je short ??ctrlon
  752. test dx,PAUSEON ; should it pass these codes
  753. jne short ??ctrlon ; pass the code
  754. jmp ??absorbcode ; don't pass code
  755. ??ctrlon:
  756. or ah,CTRLPRESS ; or on the ctrl bit in flags
  757. ??ctrloff:
  758. ;
  759. ; Test and set the ALT bit.
  760. ;
  761. test [KeysUpDown + 7],050H ; is either alt key down?
  762. je short ??altoff
  763. or ah,ALTPRESS ; or on the alt bit in flags
  764. ??altoff:
  765. ;
  766. ; Remap the keyboard keys if this is requested. (Do not set DGROUP
  767. ; as it is unecessary)
  768. push ax
  769. call KeyNum_Translate
  770. add sp,2
  771. ;------ Set the shift bit if necessary.
  772. test [KeysUpDown+5],010H ; is the left shift down?
  773. jne short ??shifton ; if so the shift is on
  774. test [KeysUpDown+7],002H ; is the right shift down?
  775. je short ??shiftoff ; if not then neither shift is down
  776. ??shifton:
  777. or ah,SHIFTPRESS ; or on the shift bit in flags
  778. ??shiftoff:
  779. ;
  780. ;------ Toggle the shift state if the caps lock key is on (if necessary).
  781. ;
  782. mov di,ax
  783. and di,07Fh
  784. shr di,1
  785. shr di,1
  786. shr di,1
  787. mov bx,ax
  788. and bx,07Fh
  789. and bl,0111b
  790. mov ch,[Bits+bx] ; get the bit to test
  791. test [KeyLock],CAPSLOCK ; is the caps lock on?
  792. je short ??capsoff ; if not don't worry about it
  793. test ch,[KeysCapsLock+di] ; get code for keycaps
  794. je short ??capsoff ; its not effected
  795. xor ah,SHIFTPRESS ; toggle the shift flag
  796. ??capsoff:
  797. ;
  798. ;------ Toggle the shift state if the num-lock key is on (if necessary).
  799. ;
  800. test [KeyLock],NUMLOCK ; is the num lock key on?
  801. je short ??numlockoff ; if not don't worry about it
  802. test ch,[KeysNumLock+di] ; get code for numlock
  803. je short ??numlockoff ; if not effected skip toggle
  804. xor ah,SHIFTPRESS ; toggle the shift flag if effected
  805. ??numlockoff:
  806. ;------ Remember the current control/shift/alt bit settings for later use.
  807. ;??noshiftever:
  808. mov [CtrlFlags],ah ; save off shift-ctrl-alt flags
  809. ; for the mouse and joystick routines
  810. ; to use in stuffing key into the
  811. ; keyboard buffer.
  812. test dx,DEBUGINT
  813. jz ??not_toggle
  814. IF DEBUG
  815. cmp [KeyIntDisabled],1
  816. jne ??not_currently_disabled
  817. cmp ax,115 ; is it the F4 key
  818. je ??disable
  819. cmp ax,118 ; is it less then F7 key
  820. jb ??justpass
  821. cmp ax,120 ; is it greater than F9 key
  822. ja ??justpass
  823. ??disable:
  824. mov [KeyIntDisabled],0
  825. ??justpass:
  826. jmp ??passcode
  827. ??not_currently_disabled:
  828. cmp ax,125
  829. jne ??not_toggle
  830. mov [KeyIntDisabled],1
  831. jmp ??absorbcode
  832. ENDIF
  833. ??not_toggle:
  834. ;------ The CTRL-ALT-DEL key combination always gets passed to the system.
  835. cmp ax,0668H ; is it ctrl alt del?
  836. je ??passcode
  837. cmp ax,064CH ; is it ctrl alt ext del?
  838. je ??passcode ; if so don't add it to the buffer
  839. ;------ Special Ctrl-C check.
  840. cmp ax,0230h
  841. je short ??breaker
  842. cmp ax,027Eh
  843. jne short ??nobreak
  844. ??breaker:
  845. mov [Break],1
  846. ??nobreak:
  847. ;------ Check for Music and Sound control keys.
  848. cmp ax,0420H ; is this an alt s
  849. jne short ??checkmusic ; toggle the Sound variable
  850. push ax
  851. mov ax,[SoundOn]
  852. xor ax,01H
  853. push ax
  854. add sp,2
  855. pop ax
  856. ??checkmusic:
  857. cmp ax,0434H ; is this an alt m
  858. jne short ??esc ; toggle the Music variable
  859. push ax
  860. mov ax,[MusicOn]
  861. xor ax,01H
  862. push ax
  863. add sp,2
  864. pop ax
  865. ??esc:
  866. push ax
  867. call Stuff_Key_Num
  868. pop ax
  869. ??skipstuff:
  870. ;------ Do the special ESC routine if necessary.
  871. cmp al,110 ; is this the esc key?
  872. jne short ??noroutine ; if not goto the pass always
  873. cmp [WORD PTR EscRoutine+2],0 ;if vector is 0 don't jump
  874. je short ??noroutine
  875. push ax
  876. call [EscRoutine]
  877. pop ax
  878. ??noroutine:
  879. ;------ Check to see if the key is to be passed to the system or not.
  880. mov di,OFFSET PassAlways ; get offset to table
  881. mov cx,(PassAlwaysEnd - PassAlways) ; get number of pass always CDY JLB MOD 7/11 was +1
  882. repne scasb ; look for a match
  883. or cx,cx ; see if there was no match
  884. jne ??passcode ; CDY JLB 7/11 optimization
  885. ??passalways:
  886. ; now check for conditional passes
  887. mov di,OFFSET CondPassKey ; get offset to cond key table
  888. mov cx,(CondPassCond-CondPassKey) ; get number of entries
  889. shr cx,1 ; cut in half for words
  890. repne scasw ; look for a match
  891. jcxz short ??notcondpass ; OPTIMIZATION CDY JLB
  892. mov bx,[(CondPassCond - CondPassKey) - 2 + di]
  893. and bx,dx ; are the conditions met?
  894. je short ??notcondpass ; NO... check normally.
  895. jmp short ??passcode ; YES... pass back to system.
  896. ;
  897. ;------ Last check before passing keycode back to the system.
  898. ;
  899. ??notcondpass:
  900. test dx,FILTERONLY ; is the filter only flag on?
  901. je short ??absorbcode ; if not, absorb the code.
  902. ??passcode:
  903. inc [cs:PassCount]
  904. ;mov ax , 0B000h
  905. ;mov es, ax
  906. ;inc [BYTE PTR es : 40h]
  907. ; Now it is time to set up for the call to the System Keyboard
  908. ; interrupt handler.
  909. ; 1 -Restore System Stack Pointer Selector before exit Interrupt
  910. ; 2- We Create a Returning Point from Interrupt by Push A
  911. ; Interupt Stack Frame into the Stack Pointer
  912. ; 3- We make a Far jump to the interuupt handler
  913. cmp [Keyboard_StackPointer],0DEADh
  914. je ??stackok
  915. push cx
  916. push di
  917. push ax
  918. push es
  919. mov ax,0A000h
  920. mov es,ax
  921. xor di,di
  922. mov cx,64000
  923. mov ax,1
  924. rep stosb
  925. pop es
  926. pop ax
  927. pop di
  928. pop cx
  929. ??stackok:
  930. cli ; disable Interrupts
  931. mov dx, [Keyboard_App_Stack_SS]
  932. mov ss, dx ; Get System Stack Selector
  933. mov sp, [Keyboard_App_Stack_ES] ; Get System Stack offset
  934. sti ; Enable Interrupts
  935. lea dx, [??Call_Back_Keyboard] ; Get Return address offset
  936. pushf ; push flags
  937. push cs ; push Code segment
  938. push dx ; push Offset
  939. ; Now we need to simulate an interrup call by using ired
  940. ; because we still want to come back here from the
  941. ; Old Keyboard interrupt handle.
  942. pushf
  943. push [word ptr KeyOldRMI + 2] ; push orig segment.
  944. push [word ptr KeyOldRMI] ; push orig offset.
  945. iret ; call interrupt
  946. ??absorbcode:
  947. ;mov ax , 0B000h
  948. ;mov es, ax
  949. ;inc [BYTE PTR es : 0h]
  950. in al,KEYCTRL ; get the control port
  951. mov ah,al
  952. or al,080H ; reset bit for keyboard
  953. out KEYCTRL,al
  954. xchg ah,al ; get orig control data
  955. out KEYCTRL,al ; restore control data
  956. mov ax,040h ; BIOS paragraph is always @ 040h
  957. mov es,ax ; put in es as BIOS paragraph
  958. mov al,[es:96h] ; get extended keys
  959. and al,0FDh ; turn off last key e0 flag
  960. mov [es:96h],al ; set extended keys
  961. mov al,CLEARISR ; value to clear In Service Register
  962. out INTCHIP0,al ; 8259 interrupt chip controller 0
  963. cmp [Keyboard_StackPointer],0DEADh
  964. je ??stackok2
  965. push cx
  966. push di
  967. push ax
  968. push es
  969. mov ax,0A000h
  970. mov es,ax
  971. xor di,di
  972. mov cx,64000
  973. mov ax,1
  974. rep stosb
  975. pop es
  976. pop ax
  977. pop di
  978. pop cx
  979. ??stackok2:
  980. ; Restore System Stack Pointer Selector before exit Interrupt
  981. mov dx, [Keyboard_App_Stack_SS]
  982. cli ; disable Interrupts
  983. mov ss, dx ; Get Syatem Stack Selector
  984. mov sp, [Keyboard_App_Stack_ES] ; Get Syatem Stack offset
  985. sti ; Enable Interrupts
  986. ??Call_Back_Keyboard:
  987. pop si
  988. pop es
  989. pop dx
  990. pop ds
  991. pop di
  992. pop cx
  993. pop bx
  994. pop ax
  995. iret
  996. ENDIF
  997. ENDP Keystroke_Interrupt
  998. ;***************************************************************************
  999. ;* Break interrupt routines begin here!
  1000. ;***************************************************************************
  1001. ;***************************************************************************
  1002. ;* BREAK_INTERRUPT -- Handles the break key interrupt *
  1003. ;* *
  1004. ;* INPUT: none *
  1005. ;* *
  1006. ;* OUTPUT: none *
  1007. ;* *
  1008. ;* WARNINGS: This is an interrupt routine. *
  1009. ;* *
  1010. ;* HISTORY: *
  1011. ;* 07/13/1994 PWG : Created. *
  1012. ;*=========================================================================*
  1013. label RM_Break_Interrupt
  1014. GLOBAL C Break_Interrupt:FAR
  1015. PROC Break_Interrupt C FAR
  1016. pushf
  1017. push ax
  1018. push es
  1019. mov ax,0B000h ; ES:DI = Mono RAM address.
  1020. mov es,ax
  1021. inc [BYTE PTR es:0]
  1022. pop es
  1023. pop ax
  1024. popf
  1025. iret
  1026. ENDP Break_Interrupt
  1027. ;**************************************************************************
  1028. ;* CALL_INTERRUPT_CHAIN -- Function PM calls to call the RM interrupt chain*
  1029. ;* *
  1030. ;* *
  1031. ;* INPUT: none *
  1032. ;* *
  1033. ;* OUTPUT: none *
  1034. ;* *
  1035. ;* HISTORY: *
  1036. ;* 07/08/1994 SKB : Created. *
  1037. ;*=========================================================================*
  1038. Call_Interrupt_Chain:
  1039. pushf
  1040. call Keystroke_Interrupt ;[KeyOldRMI]
  1041. retf
  1042. ;----------------------------------------------------------------------------
  1043. ; LOW_HIDE_MOUSE:
  1044. ;
  1045. ; This function hides the mouse cursor on the screen if it was shown. It
  1046. ; will not hide the mouse if it is already hidden.
  1047. ;
  1048. ; PROTOTYPE:
  1049. ;
  1050. ; VOID Low_Hide_Mouse(VOID);
  1051. ;
  1052. ; NOTE: does not check if mouse is currently being updated.
  1053. ;
  1054. ;----------------------------------------------------------------------------
  1055. GLOBAL C Low_Hide_Mouse:FAR
  1056. PROC Low_Hide_Mouse C FAR
  1057. USES ax,bx,cx,dx,ds
  1058. mov ax,cs ; since we are in tiny model
  1059. mov ds,ax ; set cs = ds
  1060. cmp [MDisabled],0 ; check if mouse is disabled
  1061. jne short ??end
  1062. cmp [MState],0 ; check if it was hidden before
  1063. jne short ??endnodraw ; no need to hide again
  1064. ;------ Move the saved graphic buffer to the seenpage to hide the mouse.
  1065. ; call Buffer_To_Page C,[buffx],[buffy],[buffw],[buffh],[MouseBuffer],SEENPAGE
  1066. mov ax,RESTORE_VISIBLE_PAGE
  1067. push ax
  1068. push cs
  1069. call [ ShadowPtr ]
  1070. add sp,2
  1071. ;------ Record that the mouse has been hidden.
  1072. ??endnodraw:
  1073. add [MState],1
  1074. adc [MState],0
  1075. ??end:
  1076. ret
  1077. ENDP Low_Hide_Mouse
  1078. ;----------------------------------------------------------------------------
  1079. ;----------------------------------------------------------------------------
  1080. ; LOW_SHOW_MOUSE:
  1081. ;
  1082. ; This function displays the mouse cursor on the screen if it was hidden.
  1083. ;
  1084. ; PROTOTYPE:
  1085. ; VOID Low_Show_Mouse(VOID);
  1086. ;
  1087. ; NOTE: does not check if mouse is currently being updated.
  1088. ;----------------------------------------------------------------------------
  1089. GLOBAL C Low_Show_Mouse:FAR
  1090. PROC Low_Show_Mouse C FAR
  1091. USES ax,bx,cx,dx,si,di,ds,es
  1092. LOCAL mousex:WORD ; Draw X position.
  1093. LOCAL mousey:WORD ; Draw Y position.
  1094. mov ax,cs ; since we are in tiny model
  1095. mov ds,ax ; set cs = ds
  1096. ;----- Don't show the mouse if it is not hidden, disabled.
  1097. cmp [MDisabled],0 ; is the mouse disabled
  1098. jne ??exit ; if so then exit
  1099. cmp [MState],0 ; is the mouse already visible
  1100. je ??exit ; if so then exit
  1101. dec [MState]
  1102. cmp [MState],0 ; can the mouse be shown
  1103. jne short ??exit
  1104. ;------ Determine the drawing position of the mouse.
  1105. mov cx,[MouseWidth] ; Theoretical buffer width (pixel).
  1106. mov dx,[MouseHeight] ; Theoretical buffer height (pixel).
  1107. mov ax,[MouseX]
  1108. ; sub ax,[MouseXHot]
  1109. mov [mousex],ax ; Draw X pixel.
  1110. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1111. IF 0
  1112. ; jns short ??xnotneg
  1113. ; add cx,ax ; Reduce width accordingly.
  1114. ; mov ax,0
  1115. ??xnotneg:
  1116. ENDIF
  1117. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1118. mov bx,[MouseY]
  1119. ; sub bx,[MouseYHot]
  1120. mov [mousey],bx ; Draw Y pixel.
  1121. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1122. IF 0
  1123. ; jns short ??ynotneg
  1124. ; add dx,bx ; Reduce height of mouse accordingly.
  1125. ; mov bx,0
  1126. ??ynotneg:
  1127. ENDIF
  1128. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1129. ;------ Determine the theoretical coordinates and dimensions of the
  1130. ; area the mouse shape will be rendered upon.
  1131. mov [MouseBuffX],ax
  1132. mov [MouseBuffY],bx
  1133. mov [MouseBuffW],cx
  1134. mov [MouseBuffH],dx
  1135. ;------ Move the area that will be drawn upon, to the graphic buffer.
  1136. mov ax,STORE_VISIBLE_PAGE
  1137. push ax
  1138. push cs
  1139. call [ ShadowPtr ]
  1140. add sp,2
  1141. ;------ Draw the mouse shape to the seenpage.
  1142. push [mousey]
  1143. push [mousex]
  1144. push cs
  1145. call [ DrawMousePtr ]
  1146. add sp,4
  1147. ??exit:
  1148. ret
  1149. ENDP Low_Show_Mouse
  1150. ;----------------------------------------------------------------------------
  1151. ;----------------------------------------------------------------------------
  1152. GLOBAL C Mouse_KeyNum:FAR
  1153. PROC Mouse_KeyNum C FAR
  1154. USES bx
  1155. ARG state:WORD ; Current mouse state.
  1156. LOCAL keynum:WORD ; Determined keynum.
  1157. mov ax,cs ; since we are in tiny model
  1158. mov ds,ax ; set cs = ds
  1159. mov [keynum],KN_MOUSE_MOVE ; Presume just a mouse move.
  1160. mov bx,[state]
  1161. mov ax,bx
  1162. xor bl,[Button] ; Bits of state change.
  1163. je short ??fini
  1164. mov [Button],al ; Record new mouse state.
  1165. test bl,0010b
  1166. je short ??notright
  1167. mov [keynum],KN_RMOUSE
  1168. test al,0010b
  1169. jne short ??notright
  1170. or [keynum],0800h ; Release bit on.
  1171. ??notright:
  1172. ; DRD
  1173. ; note: the left mouse button has priority over the right mouse button
  1174. ; this should be changed at a later date to process them independently
  1175. test bl,0001b
  1176. je short ??notleft
  1177. mov [keynum],KN_LMOUSE
  1178. test al,0001b
  1179. jne short ??notleft
  1180. or [keynum],0800h ; Release bit on.
  1181. ??notleft:
  1182. ??fini:
  1183. mov ax,[keynum]
  1184. ret
  1185. ENDP Mouse_KeyNum
  1186. ;----------------------------------------------------------------------------
  1187. ;----------------------------------------------------------------------------
  1188. ; MOUSE_INT:
  1189. ;
  1190. ; This routine is called automatically when the Mouse_Int is installed. It
  1191. ; automatically updates the global variables stored in the code segment so
  1192. ; that the mouse information is automatically known at all times.
  1193. ;
  1194. ; INPUTS (from int): AX = condition mask ( bit 0 == cursor position chg,
  1195. ; bit 1 == left button press,
  1196. ; bit 2 == left button release,
  1197. ; bit 3 == right button press,
  1198. ; bit 4 == right button release,
  1199. ; 5-15 == not used )
  1200. ; BX = button state ( bit 0 == left button down,
  1201. ; bit 1 == right button down,
  1202. ; bit 2 == middle button down.
  1203. ; 3-15 == not used )
  1204. ; CX = cursor coordinate (horizontal axis)
  1205. ; DX = cursor coordinate (vertical axis)
  1206. ; DI = horizontal mouse count (mickeys)
  1207. ; SI = vertical mouse count (mickeys)
  1208. ;
  1209. ; RETURNS: none
  1210. ;
  1211. ; MODIFIES: modifies the variables _Button, _ButtonChange,
  1212. ; _MouseX,_MouseY,_ButtonLatch
  1213. ;
  1214. ; PROTOTYPE:
  1215. ; This routine is called from an interrupt.
  1216. ;----------------------------------------------------------------------------
  1217. label RM_Mouse_Interrupt
  1218. PROC Mouse_Int C FAR
  1219. USES ax,bx,cx,dx,ds,si,es,di
  1220. LOCAL cond:WORD ; Local copy of mouse event.
  1221. LOCAL state:WORD ; Local copy of button state.
  1222. mov [cs:Mouse_State],bx
  1223. mov [cs:Mouse_Cond],ax
  1224. mov ax,cs ; since we are in tiny model
  1225. mov ds,ax ; set cs = ds
  1226. ; At this point we do not know if the SS selector is a
  1227. ; System Stack or the Application Stack pointer.
  1228. ; Soo to be in the safe side we create our own local
  1229. ; Stack Pointer Selector Relative to DS
  1230. ; Note Do not try this trick in a reentrant interrupt
  1231. mov bx, ss ; get SS
  1232. mov [Mouse_App_Stack_ES], sp ; Protect ES
  1233. mov [Mouse_App_Stack_SS], bx ; Protect SS
  1234. lea bx, [Mouse_StackStart ] ; Compute Local Stack size
  1235. and bx, -2;
  1236. cli ; Disable All interrupts
  1237. mov ss, ax ; Set new SS Selector
  1238. mov sp, bx ; Set new Stack Offset
  1239. sti ; Enable Interrupts
  1240. ;------ Process the mouse interrupt only if the mouse is enabled (whether
  1241. ; present or not).
  1242. cmp [MDisabled],0
  1243. jne ??exit
  1244. cmp [MInput],0
  1245. je ??exit
  1246. ;------ This was added because of missing mouse presses and
  1247. ; releases during a mouse update.
  1248. mov ax,[Mouse_Cond]
  1249. and ax,0001EH ; bits for left and right press and release
  1250. jne short ??dopress_release
  1251. cmp [MouseUpdate],0 ; if mouse move and mouse updating exit
  1252. jne ??exit
  1253. ??dopress_release:
  1254. ;------ In EEGA mode mouse X coordinates as 0..639. Make adjustment
  1255. ; to keep within 0..319 range.
  1256. cmp [Adjust],1 ; if the x coordinate is returned
  1257. jne short ??noadjust ; incorrectly then
  1258. shr cx,1 ; adjust x coord from 640 pixel screen
  1259. ??noadjust:
  1260. ; scale mouse posX and PosY
  1261. ; cmp [Adjust_XPos] , 0
  1262. ; jz short ??no_scaleX
  1263. ; push dx
  1264. ; mov ax , [MouseRight]
  1265. ; imul cx
  1266. ; idiv [Adjust_XPos]
  1267. ; mov cx , ax
  1268. ; pop dx
  1269. ??no_scaleX:
  1270. ; cmp [Adjust_YPos] , 0
  1271. ; jz short ??no_scaleY
  1272. ; mov ax , [MouseBottom]
  1273. ; imul dx
  1274. ; idiv [Adjust_YPos]
  1275. ; mov dx , ax
  1276. ??no_scaleY:
  1277. ;------ Keep mouse within screen bounds.
  1278. cmp cx,[MouseRight] ; in EGAMODE, the mouse may go to 320
  1279. jb short ??boundX_ok ; force it to stay at least one pixel
  1280. mov cx,[MouseRight] ; on the screen
  1281. dec cx
  1282. ??boundX_ok:
  1283. cmp dx,[MouseBottom] ; in EGAMODE, the mouse may go to 320
  1284. jb short ??boundY_ok ; force it to stay at least one pixel
  1285. mov dx,[MouseBottom] ; on the screen
  1286. dec dx
  1287. ??boundY_ok:
  1288. IF 0
  1289. ;------ Remap the middle button to equal the right button.
  1290. test bx,04h
  1291. je ??noremap
  1292. or bx,0010b ; Set the right button bit.
  1293. ??noremap:
  1294. ENDIF
  1295. mov [MouseX],cx ; and store in mouse x
  1296. mov [MouseY],dx ; store y coord in mouse y
  1297. test [KeyFlags],KEYMOUSE
  1298. jne short ??nostuffit
  1299. call Mouse_KeyNum C,[Mouse_State] ; Convert mouse state to key number code.
  1300. call Stuff_Key_Num C,ax ; Record mouse keynumber code.
  1301. ??nostuffit:
  1302. ;------ The check for Mouse in the middle of updating CAN NOT BE MOVED
  1303. ; any farther up because mouse presses and releases will be LOST!!
  1304. cmp [MouseUpdate],0
  1305. jne ??exit
  1306. ;??jexit:
  1307. ; jmp ??exit
  1308. christopher:
  1309. ??chkxy:
  1310. ;------ Signal that no mouse updating can occur at this time.
  1311. ; cmp [_MouseUpdate],0
  1312. ; jne ??exit
  1313. ; mov [_MouseUpdate],1
  1314. ;------ Perform any X movement grid adjustment.
  1315. cmp [MouseStepX],0 ; are we stepping on the X?
  1316. je short ??no_x_step ; no x
  1317. mov ax,cx ; get current x_pixel
  1318. mov cx,dx ; save dx - it is trashed by idiv
  1319. sub ax,[MouseOffsetX] ; get offset difference
  1320. mov bx,[MouseStepX] ; get step in bx for idiv
  1321. cwd ; extend ax -> dx:ax
  1322. idiv bx ; divide by Step X
  1323. imul bx ; ax = div * Step X
  1324. add ax,[MouseOffsetX] ; normalize to region offset
  1325. mov dx,cx ; restore dx (new MouseY)
  1326. mov cx,ax ; set cx (new MouseX)
  1327. ??no_x_step:
  1328. ;------ Perform any Y movement grid adjustment.
  1329. cmp [MouseStepY],0 ; are we stepping on the Y
  1330. je short ??no_step ; no y
  1331. mov ax,dx ; get current y_pixel
  1332. sub ax,[MouseOffsetY] ; get offset difference
  1333. mov bx,[MouseStepY] ; get step in bx for idiv
  1334. cwd ; extend ax -> dx:ax
  1335. idiv bx ; divide by Step Y
  1336. imul bx ; ax = div * Step Y
  1337. add ax,[MouseOffsetY] ; normalize to region offset
  1338. mov dx,ax ; set dx (new MouseY)
  1339. ??no_step:
  1340. ;------ Here is where we store the new MouseX and MouseY values
  1341. ; mov [MouseX],cx ; and store in mouse x
  1342. ; mov [MouseY],dx ; store y coord in mouse y
  1343. ;------ If the mouse is hidden or its position hasn't changed, then
  1344. ; perform no action.
  1345. cmp [MState],0
  1346. jne short ??updateend
  1347. cmp [MouseXOld],cx
  1348. jne short ??doit
  1349. cmp [MouseYOld],dx
  1350. je short ??updateend
  1351. ??doit:
  1352. ;------ At this point we KNOW the mouse has moved.
  1353. mov ax,[MCState]
  1354. and ax,CONDHIDE+CONDHIDDEN
  1355. cmp ax,CONDHIDE+CONDHIDDEN
  1356. je short ??condcheck ; If already hidden.
  1357. ;------ We know that the mouse is visible, we must hide it
  1358. ; before we update its position.
  1359. call Low_Hide_Mouse
  1360. ;------ Conditional region check goes here. If the mouse falls within the
  1361. ; conditional region, it gets marked as hidden and no other processing
  1362. ; occurs.
  1363. test [MCState],CONDHIDE
  1364. je short ??condok
  1365. ??condcheck:
  1366. cmp cx,[MouseCXLeft] ; check adjusted x region
  1367. jb short ??condok
  1368. cmp cx,[MouseCXRight]
  1369. ja short ??condok
  1370. cmp dx,[MouseCYUpper] ; check adjusted y region
  1371. jb short ??condok
  1372. cmp dx,[MouseCYLower]
  1373. ja short ??condok
  1374. or [MCState],CONDHIDDEN ; flag as conditional hidden
  1375. jmp short ??updateend
  1376. ;------ The mouse coordinates and flags pass all of the tests, proceed
  1377. ; with rendering the mouse.
  1378. ??condok:
  1379. call Low_Show_Mouse
  1380. ;------ Final clean up and exit.
  1381. ??updateend:
  1382. mov [MouseXOld],cx
  1383. mov [MouseYOld],dx
  1384. ??exit:
  1385. cmp [Mouse_StackPointer],0DEADh
  1386. je ??mouse_stk_ok
  1387. push cx
  1388. push di
  1389. push ax
  1390. push es
  1391. mov ax,0A000h
  1392. mov es,ax
  1393. xor di,di
  1394. mov cx,64000
  1395. mov ax,1
  1396. rep stosb
  1397. pop es
  1398. pop ax
  1399. pop di
  1400. pop cx
  1401. ??mouse_stk_ok:
  1402. ; Restore System Stack Pointer Selector before exit Interrupt
  1403. mov ax, [Mouse_App_Stack_SS]
  1404. cli ; disable Interrupts
  1405. mov ss, ax ; Get Syatem Stack Selector
  1406. mov sp, [Mouse_App_Stack_ES] ; Get Syatem Stack offset
  1407. sti ; Enable Interrupts
  1408. ret
  1409. ENDP Mouse_Int
  1410. ;***************************************************************************
  1411. ;***************************************************************************
  1412. ;***************************************************************************
  1413. ;* MOUSE_SHADOW_BUFFER -- Handles storing and restoring the mouse buffer *
  1414. ;* *
  1415. ;* INPUT: int store - indicates whether we are storing the buffer or *
  1416. ;* not. *
  1417. ;* *
  1418. ;* OUTPUT: none *
  1419. ;* *
  1420. ;* PROTO: Asm callable only! *
  1421. ;* *
  1422. ;* HISTORY: *
  1423. ;* 10/27/1994 PWG : Created. *
  1424. ;*=========================================================================*
  1425. GLOBAL C VGA_Mouse_Shadow_Buffer:FAR
  1426. PROC VGA_Mouse_Shadow_Buffer C FAR
  1427. USES ax,bx,cx,dx,di,si,ds,es
  1428. ARG store:WORD
  1429. local x0 : word
  1430. local y0 : word
  1431. local x1 : word
  1432. local y1 : word
  1433. local buffx0 : word
  1434. local buffy0 : word
  1435. ;*=========================================================================*
  1436. ;* Since we are in tiny model point ds to cs
  1437. ;*=========================================================================*
  1438. mov ax,cs ; since we are in tiny model
  1439. mov ds,ax ; set cs = ds
  1440. ;*=========================================================================*
  1441. ; Direction flag must be forward in this routine.
  1442. ;*=========================================================================*
  1443. cld
  1444. ;*===================================================================
  1445. ;* Copy of X, Y, Width and Height into local registers
  1446. ;*===================================================================
  1447. mov ax,[MouseBuffX]
  1448. mov bx,[MouseBuffY]
  1449. sub ax , [ MouseXHot ]
  1450. sub bx , [ MouseYHot ]
  1451. mov [ x0 ] , ax
  1452. mov [ y0 ] , bx
  1453. add ax , [MouseBuffW]
  1454. add bx , [MouseBuffH]
  1455. mov [ x1 ] , ax
  1456. mov [ y1 ] , bx
  1457. mov [ buffx0 ] , 0
  1458. mov ax , [ word ptr MouseBuffer ]
  1459. mov [ buffy0 ] , ax
  1460. ;*===================================================================
  1461. ;* Bounds check source X. Y.
  1462. ;*===================================================================
  1463. xor ax , ax
  1464. xor dx , dx
  1465. mov cx , [ x0 ]
  1466. mov bx , [ x1 ]
  1467. add cx , cx
  1468. adc ax , ax
  1469. add bx , bx
  1470. adc dx , dx
  1471. mov cx , [ x0 ]
  1472. mov bx , [ x1 ]
  1473. sub cx , [ MouseRight ]
  1474. sub bx , [ MouseRight ]
  1475. dec cx
  1476. dec bx
  1477. add cx , cx
  1478. adc ax , ax
  1479. add bx , bx
  1480. adc dx , dx
  1481. mov cx , [ y0 ]
  1482. mov bx , [ y1 ]
  1483. add cx , cx
  1484. adc ax , ax
  1485. add bx , bx
  1486. adc dx , dx
  1487. mov cx , [ y0 ]
  1488. mov bx , [ y1 ]
  1489. sub cx , [MouseBottom]
  1490. sub bx , [MouseBottom]
  1491. dec cx
  1492. dec bx
  1493. add cx , cx
  1494. adc ax , ax
  1495. add bx , bx
  1496. adc dx , dx
  1497. xor al , 5
  1498. xor dl , 5
  1499. mov ah , al
  1500. test dl , al
  1501. jnz ??out
  1502. or al , dl
  1503. jz ??acepted
  1504. test ah , 1000b
  1505. jz ??scr_left_ok
  1506. mov bx , [ x0 ]
  1507. neg bx
  1508. mov [ buffx0 ] , bx
  1509. mov [ x0 ] , 0
  1510. ??scr_left_ok:
  1511. test ah , 0010b
  1512. jz ??scr_bottom_ok
  1513. push dx
  1514. mov ax , [ y0 ]
  1515. neg ax
  1516. mul [MouseBuffW]
  1517. add [ buffy0 ] , ax
  1518. mov [ y0 ] , 0
  1519. pop dx
  1520. ??scr_bottom_ok:
  1521. test dl , 0100b
  1522. jz ??scr_right_ok
  1523. mov ax , [MouseRight] ; get width into register
  1524. mov [ x1 ] , ax
  1525. ??scr_right_ok:
  1526. test dl , 0001b
  1527. jz ??acepted
  1528. mov ax , [MouseBottom] ; get width into register
  1529. mov [ y1 ] , ax
  1530. ??acepted:
  1531. ;*===================================================================
  1532. ;* Get the offset into the screen.
  1533. ;*===================================================================
  1534. mov ax,0A000h
  1535. mov es,ax
  1536. mov ax , [ y0 ]
  1537. mul [ MouseRight ]
  1538. mov dx , [MouseRight]
  1539. mov di , ax
  1540. add di , [ x0 ]
  1541. ;*===================================================================
  1542. ;* Adjust the source for the top clip.
  1543. ;*===================================================================
  1544. mov bx , [ MouseWidth ] ; turn this into an offset
  1545. lds si , [ MouseBuffer ]
  1546. mov si , [ buffy0 ] ; edx points to source
  1547. add si , [ buffx0 ] ; plus clipped lines
  1548. ;*===================================================================
  1549. ;* Calculate the bytes per row add value
  1550. ;*===================================================================
  1551. mov ax , [ x1 ]
  1552. mov cx , [ y1 ]
  1553. sub ax , [ x0 ]
  1554. jle ??out
  1555. sub cx , [ y0 ]
  1556. jle ??out
  1557. sub dx , ax
  1558. sub bx , ax
  1559. push bp
  1560. cmp [store],RESTORE_VISIBLE_PAGE ; are we restoring page?
  1561. jne ??store_entry ; if not the go to store
  1562. ;*===================================================================
  1563. ;* Handle restoring the buffer to the visible page
  1564. ;*===================================================================
  1565. mov bp , cx
  1566. ??restore_loop:
  1567. mov cx,ax ; get number to really write
  1568. rep movsb ; store them into the buffer
  1569. add si,bx ; move past right clipped pixels
  1570. add di,dx ; adjust dest to next line
  1571. dec bp ; decrement number of rows to do
  1572. jnz ??restore_loop ; if more to do, do it
  1573. pop bp
  1574. IF ECHOON
  1575. mov ax , 0b000h
  1576. mov di , 12 * 80 + 10
  1577. mov es, ax
  1578. mov al , 'V'
  1579. mov [es:di],al
  1580. mov al,2
  1581. mov [es:di+1],al
  1582. ENDIF
  1583. ret
  1584. ;*===================================================================
  1585. ;* Handle soting the visible page into the Mouse Shadow Buffer
  1586. ;*===================================================================
  1587. ??store_entry:
  1588. xchg si,di ; xchg the source and the dest
  1589. mov bp , cx
  1590. push es ; need to swap es and ds but
  1591. push ds ; cant xchg so pop them on the
  1592. pop es ; stack and pop them off the
  1593. pop ds ; wrong way intentionally.
  1594. ??store_loop:
  1595. mov cx,ax ; get number to really write
  1596. rep movsb ; store them into the buffer
  1597. add si,dx ; move past right clipped pixels
  1598. add di,bx ; adjust dest to next line
  1599. dec bp ; decrement number of rows to do
  1600. jnz ??store_loop ; if more to do, do it
  1601. pop bp
  1602. ??out:
  1603. IF ECHOON
  1604. mov ax , 0b000h
  1605. mov di , 12 * 80 + 12
  1606. mov es, ax
  1607. mov al , 'G'
  1608. mov [es:di],al
  1609. mov al,2
  1610. mov [es:di+1],al
  1611. ENDIF
  1612. ret
  1613. ENDP VGA_Mouse_Shadow_Buffer
  1614. ;***************************************************************************
  1615. GLOBAL C VGA_Draw_Mouse:FAR
  1616. PROC VGA_Draw_Mouse C FAR
  1617. USES ax,bx,cx,dx,di,si,ds,es
  1618. ARG mousex:WORD
  1619. ARG mousey:WORD
  1620. local x0 : word
  1621. local y0 : word
  1622. local x1 : word
  1623. local y1 : word
  1624. local buffx0 : word
  1625. local buffy0 : word
  1626. ;*=========================================================================*
  1627. ;* Since we are in tiny model point ds to cs
  1628. ;*=========================================================================*
  1629. mov ax,cs ; since we are in tiny model
  1630. mov ds,ax ; set cs = ds
  1631. ;*===================================================================
  1632. ;* Pre-initialize the left, right and topclip values to zero.
  1633. ;*===================================================================
  1634. mov ax, [ mousex ]
  1635. mov bx , [ mousey ]
  1636. sub ax , [ MouseXHot ]
  1637. sub bx , [ MouseYHot ]
  1638. mov [ x0 ] , ax
  1639. mov [ y0 ] , bx
  1640. add ax, [ MouseWidth ]
  1641. add bx, [ MouseHeight ]
  1642. mov [ x1 ] , ax
  1643. mov [ y1 ] , bx
  1644. mov [ buffx0 ] , 0
  1645. les ax , [ MouseCursor ]
  1646. mov [ buffy0 ] , ax
  1647. ;*===================================================================
  1648. ;* Bounds check source X. Y.
  1649. ;*===================================================================
  1650. xor ax , ax
  1651. xor dx , dx
  1652. mov cx , [ x0 ]
  1653. mov bx , [ x1 ]
  1654. add cx , cx
  1655. adc ax , ax
  1656. add bx , bx
  1657. adc dx , dx
  1658. mov cx , [ x0 ]
  1659. mov bx , [ x1 ]
  1660. sub cx , [ MouseRight ]
  1661. sub bx , [ MouseRight ]
  1662. dec cx
  1663. dec bx
  1664. add cx , cx
  1665. adc ax , ax
  1666. add bx , bx
  1667. adc dx , dx
  1668. mov cx , [ y0 ]
  1669. mov bx , [ y1 ]
  1670. add cx , cx
  1671. adc ax , ax
  1672. add bx , bx
  1673. adc dx , dx
  1674. mov cx , [ y0 ]
  1675. mov bx , [ y1 ]
  1676. sub cx , [MouseBottom]
  1677. sub bx , [MouseBottom]
  1678. dec cx
  1679. dec bx
  1680. add cx , cx
  1681. adc ax , ax
  1682. add bx , bx
  1683. adc dx , dx
  1684. xor al , 5
  1685. xor dl , 5
  1686. mov ah , al
  1687. test dl , al
  1688. jnz ??out
  1689. or al , dl
  1690. jz ??acepted
  1691. test ah , 1000b
  1692. jz ??scr_left_ok
  1693. mov bx , [ x0 ]
  1694. neg bx
  1695. mov [ buffx0 ] , bx
  1696. mov [ x0 ] , 0
  1697. ??scr_left_ok:
  1698. test ah , 0010b
  1699. jz ??scr_bottom_ok
  1700. push dx
  1701. mov ax , [ y0 ]
  1702. neg ax
  1703. mul [MouseWidth]
  1704. add [ buffy0 ] , ax
  1705. mov [ y0 ] , 0
  1706. pop dx
  1707. ??scr_bottom_ok:
  1708. test dl , 0100b
  1709. jz ??scr_right_ok
  1710. mov bx , [MouseRight] ; get width into register
  1711. mov [ x1 ] , bx
  1712. ??scr_right_ok:
  1713. test dl , 0001b
  1714. jz ??acepted
  1715. mov bx , [MouseBottom] ; get width into register
  1716. mov [ y1 ] , bx
  1717. ??acepted:
  1718. mov ax , [ y0 ]
  1719. mul [ MouseRight ]
  1720. mov dx , [MouseRight]
  1721. mov di , ax
  1722. add di , [ x0 ]
  1723. ;*===================================================================
  1724. ;* Adjust the source for the top clip.
  1725. ;*===================================================================
  1726. mov bx , [MouseWidth] ; turn this into an offset
  1727. mov si , [ buffy0 ] ; edx points to source
  1728. add si , [ buffx0 ] ; plus clipped lines
  1729. ;*===================================================================
  1730. ;* Calculate the bytes per row add value
  1731. ;*===================================================================
  1732. mov ax , 0a000h
  1733. mov ds , ax
  1734. mov ax , [ x1 ]
  1735. mov cx , [ y1 ]
  1736. sub ax , [ x0 ]
  1737. jle ??out
  1738. sub cx , [ y0 ]
  1739. jle ??out
  1740. sub dx , ax
  1741. sub bx , ax
  1742. ;*===================================================================
  1743. ;* Handle restoring the buffer to the visible page
  1744. ;*===================================================================
  1745. ??top_loop:
  1746. mov ah,al
  1747. ??inner_loop:
  1748. mov ch , [es:si]
  1749. inc esi
  1750. or ch,ch
  1751. jz ??inc_edi
  1752. mov [di],ch
  1753. ??inc_edi:
  1754. inc di
  1755. dec ah
  1756. jnz ??inner_loop
  1757. add si,bx ; move past right clipped pixels
  1758. add di,dx ; adjust dest to next line
  1759. dec cl ; decrement number of rows to do
  1760. jnz ??top_loop ; if more to do, do it
  1761. ??out:
  1762. IF ECHOON
  1763. mov ax , 0b000h
  1764. mov di , 12 * 80 + 14
  1765. mov es, ax
  1766. mov al , 'A'
  1767. mov [es:di],al
  1768. mov al,2
  1769. mov [es:di+1],al
  1770. ENDIF
  1771. ret
  1772. ENDP VGA_Draw_Mouse
  1773. ;***************************************************************************
  1774. ;***************************************************************************
  1775. ;***************************************************************************
  1776. ;* MOUSE_SHADOW_BUFFER -- Handles storing and restoring the mouse buffer *
  1777. ;* *
  1778. ;* INPUT: int store - indicates whether we are storing the buffer or *
  1779. ;* not. *
  1780. ;* *
  1781. ;* OUTPUT: none *
  1782. ;* *
  1783. ;* PROTO: Asm callable only! *
  1784. ;* *
  1785. ;* HISTORY: *
  1786. ;* 10/27/1994 PWG : Created. *
  1787. ;*=========================================================================*
  1788. GLOBAL C VESA_Mouse_Shadow_Buffer:FAR
  1789. PROC VESA_Mouse_Shadow_Buffer C FAR
  1790. USES ax,bx,cx,dx,di,si,ds,es
  1791. ARG store:WORD
  1792. local x0 : word
  1793. local y0 : word
  1794. local x1 : word
  1795. local y1 : word
  1796. local buffx0 : word
  1797. local buffy0 : word
  1798. ;*=========================================================================*
  1799. ;* Since we are in tiny model point ds to cs
  1800. ;*=========================================================================*
  1801. mov ax,cs ; since we are in tiny model
  1802. mov ds,ax ; set cs = ds
  1803. call get_vesa_window
  1804. mov [ app_vesa_window ] , dx
  1805. ;*=========================================================================*
  1806. ; Direction flag must be forward in this routine.
  1807. ;*=========================================================================*
  1808. cld
  1809. ;*===================================================================
  1810. ;* Copy of X, Y, Width and Height into local registers
  1811. ;*===================================================================
  1812. mov ax,[MouseBuffX]
  1813. mov bx,[MouseBuffY]
  1814. sub ax , [ MouseXHot ]
  1815. sub bx , [ MouseYHot ]
  1816. mov [ x0 ] , ax
  1817. mov [ y0 ] , bx
  1818. add ax , [MouseBuffW]
  1819. add bx , [MouseBuffH]
  1820. mov [ x1 ] , ax
  1821. mov [ y1 ] , bx
  1822. mov [ buffx0 ] , 0
  1823. mov ax , [ word ptr MouseBuffer ]
  1824. mov [ buffy0 ] , ax
  1825. ;*===================================================================
  1826. ;* Bounds check source X. Y.
  1827. ;*===================================================================
  1828. xor ax , ax
  1829. xor dx , dx
  1830. mov cx , [ x0 ]
  1831. mov bx , [ x1 ]
  1832. add cx , cx
  1833. adc ax , ax
  1834. add bx , bx
  1835. adc dx , dx
  1836. mov cx , [ x0 ]
  1837. mov bx , [ x1 ]
  1838. sub cx , [ MouseRight ]
  1839. sub bx , [ MouseRight ]
  1840. dec cx
  1841. dec bx
  1842. add cx , cx
  1843. adc ax , ax
  1844. add bx , bx
  1845. adc dx , dx
  1846. mov cx , [ y0 ]
  1847. mov bx , [ y1 ]
  1848. add cx , cx
  1849. adc ax , ax
  1850. add bx , bx
  1851. adc dx , dx
  1852. mov cx , [ y0 ]
  1853. mov bx , [ y1 ]
  1854. sub cx , [MouseBottom]
  1855. sub bx , [MouseBottom]
  1856. dec cx
  1857. dec bx
  1858. add cx , cx
  1859. adc ax , ax
  1860. add bx , bx
  1861. adc dx , dx
  1862. xor al , 5
  1863. xor dl , 5
  1864. mov ah , al
  1865. test dl , al
  1866. jnz ??out
  1867. or al , dl
  1868. jz ??acepted
  1869. test ah , 1000b
  1870. jz ??scr_left_ok
  1871. mov bx , [ x0 ]
  1872. neg bx
  1873. mov [ buffx0 ] , bx
  1874. mov [ x0 ] , 0
  1875. ??scr_left_ok:
  1876. test ah , 0010b
  1877. jz ??scr_bottom_ok
  1878. push dx
  1879. mov ax , [ y0 ]
  1880. neg ax
  1881. mul [MouseBuffW]
  1882. add [ buffy0 ] , ax
  1883. mov [ y0 ] , 0
  1884. pop dx
  1885. ??scr_bottom_ok:
  1886. test dl , 0100b
  1887. jz ??scr_right_ok
  1888. mov ax , [MouseRight] ; get width into register
  1889. mov [ x1 ] , ax
  1890. ??scr_right_ok:
  1891. test dl , 0001b
  1892. jz ??acepted
  1893. mov ax , [MouseBottom] ; get width into register
  1894. mov [ y1 ] , ax
  1895. ??acepted:
  1896. ;*===================================================================
  1897. ;* Get the offset into the screen.
  1898. ;*===================================================================
  1899. mov ax,0A000h
  1900. mov es,ax
  1901. mov ax , [ y0 ]
  1902. mul [ MouseRight ]
  1903. add ax , [ x0 ]
  1904. adc dx , 0
  1905. mov di , ax
  1906. call set_vesa_page
  1907. mov dx , [MouseRight]
  1908. ;*===================================================================
  1909. ;* Adjust the source for the top clip.
  1910. ;*===================================================================
  1911. mov bx , [ MouseWidth ] ; turn this into an offset
  1912. lds si , [ MouseBuffer ]
  1913. mov si , [ buffy0 ] ; edx points to source
  1914. add si , [ buffx0 ] ; plus clipped lines
  1915. ;*===================================================================
  1916. ;* Calculate the bytes per row add value
  1917. ;*===================================================================
  1918. mov ax , [ x1 ]
  1919. mov cx , [ y1 ]
  1920. sub ax , [ x0 ]
  1921. jle ??out
  1922. sub cx , [ y0 ]
  1923. jle ??out
  1924. sub dx , ax
  1925. sub bx , ax
  1926. cmp [store],RESTORE_VISIBLE_PAGE ; are we restoring page?
  1927. jne ??store_entry ; if not the go to store
  1928. ;*===================================================================
  1929. ;* Handle restoring the buffer to the visible page
  1930. ;*===================================================================
  1931. ??restore_loop:
  1932. mov ah,al
  1933. ??res_inner_loop:
  1934. mov ch , [si]
  1935. mov [es:di],ch
  1936. inc si
  1937. inc di
  1938. jnz ??res_same_page
  1939. call next_vesa_page
  1940. ??res_same_page:
  1941. dec ah
  1942. jnz ??res_inner_loop
  1943. add si,bx ; move past right clipped pixels
  1944. add di,dx ; adjust dest to next line
  1945. jnc ??res_same_page1
  1946. call next_vesa_page
  1947. ??res_same_page1:
  1948. dec cl ; decrement number of rows to do
  1949. jnz ??restore_loop
  1950. IF ECHOON
  1951. mov ax , 0b000h
  1952. mov di , 10 * 80 + 10
  1953. mov es,ax
  1954. mov al ,'v'
  1955. mov [es:di],al
  1956. mov al,2
  1957. mov [es:di+1],al
  1958. ENDIF
  1959. jmp ??out
  1960. ;*===================================================================
  1961. ;* Handle soting the visible page into the Mouse Shadow Buffer
  1962. ;*===================================================================
  1963. ??store_entry:
  1964. mov ah,al
  1965. ??store_inner_loop:
  1966. mov ch , [es:di]
  1967. mov [si],ch
  1968. inc si
  1969. inc di
  1970. jnz ??store_same_page
  1971. call next_vesa_page
  1972. ??store_same_page:
  1973. dec ah
  1974. jnz ??store_inner_loop
  1975. add si,bx ; move past right clipped pixels
  1976. add di,dx ; adjust dest to next line
  1977. jnc ??store_same_page1
  1978. call next_vesa_page
  1979. ??store_same_page1:
  1980. dec cl ; decrement number of rows to do
  1981. jnz ??store_entry
  1982. ??out:
  1983. IF ECHOON
  1984. mov ax , 0b000h
  1985. mov di , 10 * 80 + 14
  1986. mov es,ax
  1987. mov al ,'e'
  1988. mov [es:di],al
  1989. mov al,2
  1990. mov [es:di+1],al
  1991. ENDIF
  1992. mov dx , [ app_vesa_window ]
  1993. call set_vesa_window
  1994. ret
  1995. ENDP VESA_Mouse_Shadow_Buffer
  1996. ;***************************************************************************
  1997. GLOBAL C VESA_Draw_Mouse:FAR
  1998. PROC VESA_Draw_Mouse C FAR
  1999. USES ax,bx,cx,dx,di,si,ds,es
  2000. ARG mousex:WORD
  2001. ARG mousey:WORD
  2002. local x0 : word
  2003. local y0 : word
  2004. local x1 : word
  2005. local y1 : word
  2006. local buffx0 : word
  2007. local buffy0 : word
  2008. local app_vesa_window : word
  2009. ;*=========================================================================*
  2010. ;* Since we are in tiny model point ds to cs
  2011. ;*=========================================================================*
  2012. mov ax,cs ; since we are in tiny model
  2013. mov ds,ax ; set cs = ds
  2014. call get_vesa_window
  2015. mov [ app_vesa_window ] , dx
  2016. ;*===================================================================
  2017. ;* Pre-initialize the left, right and topclip values to zero.
  2018. ;*===================================================================
  2019. mov ax, [ mousex ]
  2020. mov bx , [ mousey ]
  2021. sub ax , [ MouseXHot ]
  2022. sub bx , [ MouseYHot ]
  2023. mov [ x0 ] , ax
  2024. mov [ y0 ] , bx
  2025. add ax, [ MouseWidth ]
  2026. add bx, [ MouseHeight ]
  2027. mov [ x1 ] , ax
  2028. mov [ y1 ] , bx
  2029. mov [ buffx0 ] , 0
  2030. les ax , [ MouseCursor ]
  2031. mov [ buffy0 ] , ax
  2032. ;*===================================================================
  2033. ;* Bounds check source X. Y.
  2034. ;*===================================================================
  2035. xor ax , ax
  2036. xor dx , dx
  2037. mov cx , [ x0 ]
  2038. mov bx , [ x1 ]
  2039. add cx , cx
  2040. adc ax , ax
  2041. add bx , bx
  2042. adc dx , dx
  2043. mov cx , [ x0 ]
  2044. mov bx , [ x1 ]
  2045. sub cx , [ MouseRight ]
  2046. sub bx , [ MouseRight ]
  2047. dec cx
  2048. dec bx
  2049. add cx , cx
  2050. adc ax , ax
  2051. add bx , bx
  2052. adc dx , dx
  2053. mov cx , [ y0 ]
  2054. mov bx , [ y1 ]
  2055. add cx , cx
  2056. adc ax , ax
  2057. add bx , bx
  2058. adc dx , dx
  2059. mov cx , [ y0 ]
  2060. mov bx , [ y1 ]
  2061. sub cx , [MouseBottom]
  2062. sub bx , [MouseBottom]
  2063. dec cx
  2064. dec bx
  2065. add cx , cx
  2066. adc ax , ax
  2067. add bx , bx
  2068. adc dx , dx
  2069. xor al , 5
  2070. xor dl , 5
  2071. mov ah , al
  2072. test dl , al
  2073. jnz ??out
  2074. or al , dl
  2075. jz ??acepted
  2076. test ah , 1000b
  2077. jz ??scr_left_ok
  2078. mov bx , [ x0 ]
  2079. neg bx
  2080. mov [ buffx0 ] , bx
  2081. mov [ x0 ] , 0
  2082. ??scr_left_ok:
  2083. test ah , 0010b
  2084. jz ??scr_bottom_ok
  2085. push dx
  2086. mov ax , [ y0 ]
  2087. neg ax
  2088. mul [MouseWidth]
  2089. add [ buffy0 ] , ax
  2090. mov [ y0 ] , 0
  2091. pop dx
  2092. ??scr_bottom_ok:
  2093. test dl , 0100b
  2094. jz ??scr_right_ok
  2095. mov ax , [MouseRight] ; get width into register
  2096. mov [ x1 ] , ax
  2097. ??scr_right_ok:
  2098. test dl , 0001b
  2099. jz ??acepted
  2100. mov ax , [MouseBottom] ; get width into register
  2101. mov [ y1 ] , ax
  2102. ??acepted:
  2103. mov ax , [ y0 ]
  2104. mul [ MouseRight ]
  2105. add ax , [ x0 ]
  2106. adc dx , 0
  2107. mov di , ax
  2108. call set_vesa_page
  2109. mov dx , [MouseRight]
  2110. ;*===================================================================
  2111. ;* Adjust the source for the top clip.
  2112. ;*===================================================================
  2113. mov bx , [MouseWidth] ; turn this into an offset
  2114. mov si , [ buffy0 ] ; edx points to source
  2115. add si , [ buffx0 ] ; plus clipped lines
  2116. ;*===================================================================
  2117. ;* Calculate the bytes per row add value
  2118. ;*===================================================================
  2119. mov ax , 0a000h
  2120. mov ds , ax
  2121. mov ax , [ x1 ]
  2122. mov cx , [ y1 ]
  2123. sub ax , [ x0 ]
  2124. jle ??out
  2125. sub cx , [ y0 ]
  2126. jle ??out
  2127. sub dx , ax
  2128. sub bx , ax
  2129. ;*===================================================================
  2130. ;* Handle restoring the buffer to the visible page
  2131. ;*===================================================================
  2132. ??top_loop:
  2133. mov ah,al
  2134. ??inner_loop:
  2135. mov ch , [es:si]
  2136. inc si
  2137. or ch,ch
  2138. jz ??inc_edi
  2139. mov [di],ch
  2140. ??inc_edi:
  2141. inc di
  2142. jnz ??same_page
  2143. call next_vesa_page
  2144. ??same_page:
  2145. dec ah
  2146. jnz ??inner_loop
  2147. add si,bx ; move past right clipped pixels
  2148. add di,dx ; adjust dest to next line
  2149. jnc ??same_page1
  2150. call next_vesa_page
  2151. ??same_page1:
  2152. dec cl ; decrement number of rows to do
  2153. jnz ??top_loop ; if more to do, do it
  2154. ??out:
  2155. IF ECHOON
  2156. mov ax , 0b000h
  2157. mov di , 10 * 80 + 14
  2158. mov es, ax
  2159. mov al , 's'
  2160. mov [es:di],al
  2161. mov al,2
  2162. mov [es:di+1],al
  2163. mov di , 10 * 80 + 16
  2164. mov al , 'a'
  2165. mov [es:di],al
  2166. mov al,2
  2167. mov [es:di+1],al
  2168. ENDIF
  2169. mov dx , [ app_vesa_window ]
  2170. call set_vesa_window
  2171. ret
  2172. ENDP VESA_Draw_Mouse
  2173. ;************************************************************************
  2174. PROC get_vesa_window C near
  2175. uses ax,bx
  2176. mov ax , 04f05h
  2177. mov bh , 1
  2178. mov bl , 0
  2179. call [ dword ptr cs: VesaPtr ]
  2180. ret
  2181. ENDP
  2182. ;************************************************************************
  2183. PROC set_vesa_window C near
  2184. uses ax,bx,dx
  2185. mov ax , 04f05h
  2186. mov bh , 0
  2187. mov bl , 0
  2188. call [ dword ptr cs: VesaPtr ]
  2189. ret
  2190. ENDP
  2191. ;***************************************************************************
  2192. PROC set_vesa_page C near
  2193. USES ax,bx,dx
  2194. mov bx , dx
  2195. shl bx , 2
  2196. mov [ cs: current_page ] , bx
  2197. mov dx , [ word ptr cs:banktable + bx ]
  2198. mov ax , 04f05h
  2199. mov bh , 0
  2200. mov bl , 0
  2201. call [ dword ptr cs: VesaPtr ]
  2202. ret
  2203. ENDP set_vesa_page
  2204. PROC next_vesa_page C near
  2205. USES ax,bx,dx
  2206. mov bx , [ cs: current_page ]
  2207. add bx , 4
  2208. mov [ cs:current_page ] , bx
  2209. mov dx , [ word ptr cs:banktable + bx ]
  2210. mov ax , 04f05h
  2211. mov bh , 0
  2212. mov bl , 0
  2213. call [ dword ptr cs: VesaPtr ]
  2214. ret
  2215. ENDP next_vesa_page
  2216. ;***********************************************************
  2217. END