MOUSE.ASM 75 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226
  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 : MOUSE.ASM *
  26. ;* *
  27. ;* Programmer : Phil W. Gorrow *
  28. ;* *
  29. ;* Start Date : August 26, 1994 *
  30. ;* *
  31. ;* Last Update : November 3, 1994 [PWG] *
  32. ;* *
  33. ;*-------------------------------------------------------------------------*
  34. ;* Functions: *
  35. ;* Install_Mouse -- Initializes mouse driver and verifies mouse exists *
  36. ;* Remove_Mouse -- uninstalls the mouse interrupt by disabling the call *
  37. ;* Get_Mouse_X -- Returns the mouses x pixel position *
  38. ;* Get_Mouse_Y -- Returns the mouse's y pixel position *
  39. ;* Get_Mouse_Button -- Gets the values of the mouse button *
  40. ;* Set_Mouse_Cursor -- Sets the shape to be used as the mouse. *
  41. ;* Low_Hide_Mouse -- Low-level routine which hides the mouse *
  42. ;* Low_Show_Mouse -- Low level routine which shows the mouse *
  43. ;* Mouse_Shadow_Buffer -- Handles storing and restoring the mouse buffer *
  44. ;* Draw_Mouse -- Handles drawing the mouse cursor *
  45. ;* Hide_Mouse -- Hides mouse cursor on screen if it was show *
  46. ;* Show_Mouse -- Display mouse cursor on screen if it was hidden *
  47. ;* Conditional_Hide_Mouse -- Hides mouse if its with given region *
  48. ;* Conditional_Show_Mouse -- shows mouse if it was conditionally hidden *
  49. ;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
  50. IDEAL ; the product runs in ideal mode
  51. P386 ; use 386 real mode instructions
  52. MODEL USE32 FLAT
  53. LOCALS ?? ; ?? is the symbol for a local
  54. ;WARN ; generate all warnings we can
  55. ;JUMPS ; optimize jumps if possible
  56. ;---------------------------------------------------------------------------
  57. ; Include all of the keyboard specific defines
  58. ;---------------------------------------------------------------------------
  59. INCLUDE "keystruc.inc"
  60. INCLUDE "shape.inc"
  61. include "svgaprim.inc"
  62. DOS_SYS_CALL EQU 21h ; to do TNT DOS-XNDR system calls.
  63. RESTORE_VISIBLE_PAGE EQU 0
  64. STORE_VISIBLE_PAGE EQU 1
  65. CONDHIDE EQU 08000H ; bit for testing conditional region
  66. CONDHIDDEN EQU 04000H ; bit for testing conditional hidden
  67. ;---------------------------------------------------------------------------
  68. ; Define any data which needs to be global...
  69. ;---------------------------------------------------------------------------
  70. GLOBAL RealModePtr:DWORD
  71. GLOBAL MInstalled:DWORD
  72. GLOBAL MouseBuffer:DWORD
  73. GLOBAL LCW_Uncompress:NEAR
  74. GLOBAL Get_Shape_Uncomp_Size :NEAR
  75. GLOBAL Get_Shape_Width :NEAR
  76. GLOBAL Get_Shape_Original_Height :NEAR
  77. GLOBAL Size_Of_Region :NEAR
  78. GLOBAL _ShapeBuffer :DWORD
  79. GLOBAL XRes : dword
  80. GLOBAL YRes : dword
  81. GLOBAL VesaFunc : dword
  82. GLOBAL Vesa_XRes : near
  83. GLOBAL Vesa_YRes : near
  84. DPMI_INTR EQU 31h
  85. STRUC DPMI_REGS
  86. _edi dd ?
  87. _esi dd ?
  88. _ebp dd ?
  89. dd ?
  90. _ebx dd ?
  91. _edx dd ?
  92. _ecx dd ?
  93. _eax dd ?
  94. Flags dw ?
  95. _es dw ?
  96. _ds dw ?
  97. _fs dw ?
  98. _gs dw ?
  99. _ip dw ?
  100. _cs dw ?
  101. _sp dw ?
  102. _ss dw ?
  103. dd ?
  104. dd ?
  105. nothing dd ?
  106. ENDS
  107. ;---------------------------------------------------------------------------
  108. ; Now lets handle any data in the data segment
  109. ;---------------------------------------------------------------------------
  110. DATASEG
  111. RealInt DPMI_REGS <> ; structure to call a real mode int
  112. MInstalled DD 0 ; is the mouse installed?
  113. MouseCursor DD 0
  114. MouseBuffer DD 0
  115. BufferWidth DD 0
  116. BufferHeight DD 0
  117. BufferSize DD 0
  118. PrevMousePtr DD 0
  119. MouseBufferSel DD 0
  120. Draw_Mouse dd VGA_Draw_Mouse
  121. Mouse_Shadow_Buffer dd VGA_Mouse_Shadow_Buffer
  122. ;---------------------------------------------------------------------------
  123. ; Time to write some code
  124. ;---------------------------------------------------------------------------
  125. CODESEG
  126. ;***************************************************************************
  127. ;* INSTALL_MOUSE -- Initializes mouse driver and verifies mouse connected *
  128. ;* *
  129. ;* First check the mouse interupt to see if the vector is pointing to zero *
  130. ;* page. If it is not then make sure it is not pointing to an IRET. If *
  131. ;* not call the mouse reset to verify that the hardware is attached. *
  132. ;* *
  133. ;* INPUT: int mouse_max_width - the max width of the mouse cursor *
  134. ;* int mouse_max_height - the max height of the mouse cursor *
  135. ;* int screen_width - width of the physical screen *
  136. ;* int screen_height - height of the physical screen *
  137. ;* *
  138. ;* OUTPUT: TRUE is mouse driver is initialized, FALSE if unable to *
  139. ;* initialize mouse driver. *
  140. ;* *
  141. ;* PROTO: int Install_Mouse( int mouse_max_width, *
  142. ;* int mouse_max_height, *
  143. ;* int screen_width, *
  144. ;* int screen_height); *
  145. ;* *
  146. ;* HISTORY: *
  147. ;* 08/26/1994 PWG : Created. *
  148. ;*=========================================================================*
  149. GLOBAL Install_Mouse:NEAR
  150. PROC Install_Mouse C NEAR
  151. USES ebx,ecx,edx,esi,edi
  152. ARG mouse_max_width:DWORD
  153. ARG mouse_max_height:DWORD
  154. ARG screen_width:DWORD
  155. ARG screen_height:DWORD
  156. ;*=========================================================================*
  157. ;* Initialize all of the general mouse variables
  158. ;*=========================================================================*
  159. mov esi,[RealModePtr] ; get offset of real mode data start
  160. test esi , esi ; mouse driver should be install
  161. jz ??exit ; after keyboard interrup is install
  162. mov eax , [ XRes ]
  163. shr eax , 1
  164. mov [(KeyboardType esi).MouseX],eax ; set the mouses x coordinate to 160
  165. mov eax , [ YRes ]
  166. shr eax , 1
  167. mov [(KeyboardType esi).MouseY],eax ; set the mouses y coordinate to 100
  168. mov [(KeyboardType esi).MState],1 ; flag the mouse as hidden
  169. mov [(KeyboardType esi).MCState],0 ; turn off conditional region
  170. mov eax , [ XRes ]
  171. mov [(KeyboardType esi).MouseRight],eax
  172. mov eax , [ YRes ]
  173. mov [(KeyboardType esi).MouseBottom],eax
  174. ;==========================================================================
  175. ; Get the real mode interrupt vector keyboard
  176. ; input ax = 0200, bl = number of interrupt to get
  177. ; output cf error, cx,dx= address (seg:off) of RM int handler routine.
  178. ; cl set above
  179. ;==========================================================================
  180. mov eax,0200h
  181. mov bl,033h
  182. int DPMI_INTR ; do call.
  183. jc ??error ; no mouse driver present
  184. ;*=========================================================================*
  185. ;* If the interupt vector is pointing to 0000:0000h, there is no mouse
  186. ;*=========================================================================*
  187. mov ax,cx
  188. or ax,dx
  189. jz short ??nomouse
  190. and edx , 0ffffh
  191. and ecx , 0ffffh
  192. shl ecx,4
  193. add ecx,edx
  194. ;*=========================================================================*
  195. ;* If the first instruction is an IRET, there is no mouse
  196. ;*=========================================================================*
  197. cmp [byte ptr ecx],0CFH ; is this an IRET
  198. jne short ??mouse_buff ; if it isnt then reset the mouse
  199. ??nomouse:
  200. mov eax,FALSE ; flag no mouse driver
  201. mov [MInstalled],FALSE ; flag no mouse driver
  202. jmp ??exit ; exit
  203. ??mouse_buff:
  204. ;*=========================================================================*
  205. ;* Allocate two real mode memory buffers for the mouse cursor and the
  206. ;* mouse shadow
  207. ;*=========================================================================*
  208. mov eax,[mouse_max_width] ; get the is max width
  209. mov [BufferWidth],eax ; save it off for set cursor
  210. mov edx,[mouse_max_height] ; get the max height
  211. mov [BufferHeight],edx ; save it off for set cursor
  212. mul edx ; size = max_width * max_height
  213. add eax,22 ; add width/height(8) + para align(15)
  214. and al, 0f0h ; now size is even paragraphs
  215. mov [BufferSize],eax ; store off the buffer size
  216. shl eax,1 ; make two of them
  217. mov ebx,eax ; get size of RM binary.
  218. mov ecx,eax ; ecx will use it later.
  219. add ebx,15 ; round up
  220. shr ebx,4 ; convert to pages.
  221. mov eax,0100h ; alloc real buffer
  222. int DPMI_INTR ; do call.
  223. jc ??error ; check for error.
  224. mov esi,[RealModePtr] ; get offset of real mode data start
  225. mov [MouseBufferSel], edx
  226. shl eax , 16
  227. mov [(KeyboardType esi).MouseCursor],eax ; store off the real mode segment
  228. mov edx,eax ; get the buffer position
  229. add edx,[BufferSize] ; add in the buffer size
  230. mov [(KeyboardType esi).MouseBuffer],edx ; store off the real mode segment
  231. shr eax,12 ; convert the seg/off to 32 bit offset
  232. mov edx,eax
  233. add edx,[BufferSize]
  234. mov [MouseCursor],eax ; store it off in the mouse buffer
  235. mov [MouseBuffer],edx ; store it off in the mouse buffer
  236. mov eax,0600h ; function number.
  237. mov ecx,[MouseCursor] ; ecx must have start of memory.
  238. mov edi,[BufferSize]
  239. shl edi,1
  240. shld ebx,ecx,16
  241. shld esi,edi,16
  242. int DPMI_INTR ; do call.
  243. jc ??error ; eax = 8 if mem err, eax = 9 if invalid mem region.
  244. ??begin:
  245. mov esi,[RealModePtr] ; get offset of real mode data start
  246. ; Reset mouse thru int 33h funtion 0
  247. call Clear_RM_regs
  248. mov eax , 0300h
  249. mov ebx , 033h
  250. xor ecx , ecx
  251. mov [RealInt . _eax ] , 0
  252. lea edi, [RealInt]
  253. int DPMI_INTR
  254. mov eax ,[RealInt . _eax]
  255. cmp ax,-1 ; was the mouse attached to system
  256. jne ??nomouse ; if not exit out of the routine
  257. mov [(KeyboardType esi).Adjust],0 ; assume we do not need to adjust mouse
  258. ;***************************************************************************
  259. ; Set the Vesa Parameters
  260. mov eax , [ VesaFunc ]
  261. test eax , eax
  262. jz ??set_vga_mouse
  263. mov [(KeyboardType esi). VesaPtr ] , eax
  264. mov ax , [(KeyboardType esi). VESAMouseShadow ]
  265. mov [(KeyboardType esi). ShadowPtr] , ax
  266. mov ax , [(KeyboardType esi). VESAMouseDraw ]
  267. mov [(KeyboardType esi). DrawMousePtr ] , ax
  268. lea eax , [ VESA_Draw_Mouse ]
  269. mov [ Draw_Mouse ] , eax
  270. lea eax , [ VESA_Mouse_Shadow_Buffer ]
  271. mov [ Mouse_Shadow_Buffer ] , eax
  272. mov eax , [ XRes ]
  273. mov [(KeyboardType esi). MouseRight ] , eax
  274. mov eax , [ YRes ]
  275. mov [(KeyboardType esi). MouseBottom ] , eax
  276. lea edi , [(KeyboardType esi). VesaBankTable]
  277. lea esi , [ BankTable ]
  278. mov ecx , 8
  279. rep movsd
  280. mov esi,[RealModePtr] ; get offset of real mode data start
  281. jmp ??end_vesa
  282. ??set_vga_mouse:
  283. mov ax , [(KeyboardType esi). VGAMouseShadow ]
  284. mov [(KeyboardType esi). ShadowPtr] , ax
  285. mov ax , [(KeyboardType esi). VGAMouseDraw ]
  286. mov [(KeyboardType esi). DrawMousePtr ] , ax
  287. lea eax , [ VGA_Draw_Mouse ]
  288. mov [ Draw_Mouse ] , eax
  289. lea eax , [ VGA_Mouse_Shadow_Buffer ]
  290. mov [ Mouse_Shadow_Buffer ] , eax
  291. ??end_vesa:
  292. call Reset_Mouse
  293. mov eax , TRUE
  294. ret
  295. ??error:
  296. mov eax,FALSE
  297. ??exit:
  298. ret
  299. ENDP Install_Mouse
  300. ;***************************************************************************
  301. ;* ResET_MOUSE -- Reset mouse to a new graphif mode *
  302. ;* *
  303. ;* reset mouse driver funtions to a a currently graphic mode *
  304. ;* *
  305. ;* INPUT: *
  306. ;* OUTPUT: *
  307. ;* PROTO: Reset_Mouse ( void ) *
  308. ;* *
  309. ;* *
  310. ;* HISTORY: *
  311. ;* 08/26/1994 JRJ : Created. *
  312. ;*=========================================================================*
  313. GLOBAL Reset_Mouse:NEAR
  314. PROC Reset_Mouse C NEAR
  315. USES eax,ebx,ecx,edx,esi,edi
  316. ;*=========================================================================*
  317. ;* Initialize all of the general mouse variables
  318. ;*=========================================================================*
  319. mov esi , [RealModePtr] ; get offset of real mode data start
  320. test esi , esi
  321. jz ??exit
  322. mov eax , [ XRes ]
  323. shr eax , 1
  324. mov [(KeyboardType esi).MouseX],eax ; set the mouses x coordinate to 160
  325. mov eax , [ YRes ]
  326. shr eax , 1
  327. mov [(KeyboardType esi).MouseY],eax ; set the mouses y coordinate to 100
  328. mov [(KeyboardType esi).MState],1 ; flag the mouse as hidden
  329. mov [(KeyboardType esi).MCState],0 ; turn off conditional region
  330. mov eax , [ XRes ]
  331. mov [(KeyboardType esi).MouseRight],eax
  332. mov eax , [ YRes ]
  333. mov [(KeyboardType esi).MouseBottom],eax
  334. mov [(KeyboardType esi).Adjust],0 ; assume we do not need to adjust mouse
  335. ;***************************************************************************
  336. ; Set the Vesa Parameters
  337. mov eax , [ VesaFunc ]
  338. test eax , eax
  339. jz ??set_vga_mouse
  340. mov [(KeyboardType esi). VesaPtr ] , eax
  341. mov ax , [(KeyboardType esi). VESAMouseShadow ]
  342. mov [(KeyboardType esi). ShadowPtr] , ax
  343. mov ax , [(KeyboardType esi). VESAMouseDraw ]
  344. mov [(KeyboardType esi). DrawMousePtr ] , ax
  345. lea eax , [ VESA_Draw_Mouse ]
  346. mov [ Draw_Mouse ] , eax
  347. lea eax , [ VESA_Mouse_Shadow_Buffer ]
  348. mov [ Mouse_Shadow_Buffer ] , eax
  349. mov eax , [ XRes ]
  350. mov [(KeyboardType esi). MouseRight ] , eax
  351. mov eax , [ YRes ]
  352. mov [(KeyboardType esi). MouseBottom ] , eax
  353. lea edi , [(KeyboardType esi). VesaBankTable]
  354. lea esi , [ BankTable ]
  355. mov ecx , 8
  356. rep movsd
  357. mov esi,[RealModePtr] ; get offset of real mode data start
  358. jmp ??end_vesa
  359. ??set_vga_mouse:
  360. mov ax , [(KeyboardType esi). VGAMouseShadow ]
  361. mov [(KeyboardType esi). ShadowPtr] , ax
  362. mov ax , [(KeyboardType esi). VGAMouseDraw ]
  363. mov [(KeyboardType esi). DrawMousePtr ] , ax
  364. lea eax , [ VGA_Draw_Mouse ]
  365. mov [ Draw_Mouse ] , eax
  366. lea eax , [ VGA_Mouse_Shadow_Buffer ]
  367. mov [ Mouse_Shadow_Buffer ] , eax
  368. ??end_vesa:
  369. ; S Mickey/pixel Ratio cursor limits
  370. call Clear_RM_regs
  371. mov eax , 0300h
  372. mov ebx , 033h
  373. mov ecx , 8
  374. mov edx , 16
  375. mov [RealInt . _eax ] , 0fh
  376. mov [RealInt . _ecx] , ecx
  377. mov [RealInt . _edx] , edx
  378. xor ecx , ecx
  379. lea edi, [RealInt]
  380. int DPMI_INTR
  381. ; Set Min/Max X pos
  382. call Clear_RM_regs
  383. mov eax , 0300h
  384. mov ebx , 033h
  385. mov ecx , 0
  386. mov edx , [ XRes ]
  387. cmp edx , 320
  388. jne ??set_it
  389. shl edx , 1
  390. mov [(KeyboardType esi).Adjust],1
  391. ??set_it:
  392. ; dec edx
  393. mov [RealInt . _eax ] , 7
  394. mov [RealInt . _ecx] , ecx
  395. mov [RealInt . _edx] , edx
  396. xor ecx , ecx
  397. lea edi, [RealInt]
  398. int DPMI_INTR
  399. ; Set Min/Max Y pos
  400. call Clear_RM_regs
  401. mov eax , 0300h
  402. mov ebx , 033h
  403. mov ecx , 0
  404. mov edx , [ YRes ]
  405. dec edx
  406. mov [RealInt . _eax ] , 8
  407. mov [RealInt . _ecx] , ecx
  408. mov [RealInt . _edx] , edx
  409. xor ecx , ecx
  410. lea edi, [RealInt]
  411. int DPMI_INTR
  412. IF 0
  413. ; Check for scale factors in X and Y pos
  414. call Clear_RM_regs
  415. mov eax , 0300h
  416. mov ebx , 033h
  417. mov ecx , [ XRes ]
  418. mov edx , [ YRes ]
  419. sub ecx , 8
  420. sub edx , 16
  421. mov [RealInt . _eax ] , 4
  422. mov [RealInt . _ecx] , ecx
  423. mov [RealInt . _edx] , edx
  424. xor ecx , ecx
  425. lea edi, [RealInt]
  426. int DPMI_INTR
  427. ; Read mouse position thru int 33 funtion 3
  428. call Clear_RM_regs
  429. mov eax , 0300h
  430. mov ebx , 033h
  431. xor ecx , ecx
  432. mov [RealInt . _eax ] , 3
  433. lea edi, [RealInt]
  434. int DPMI_INTR
  435. mov ecx ,[RealInt . _ecx]
  436. mov edx ,[RealInt . _edx]
  437. ; compute Scale values X Y for different vendor mouse driver if nessesary
  438. add ecx , 8
  439. add edx , 16
  440. cmp ecx , [ XRes ]
  441. mov [(KeyboardType esi).Adjust_XPos],0
  442. jz ??No_scaleX
  443. mov [(KeyboardType esi).Adjust_XPos],ecx
  444. ??No_scaleX:
  445. cmp edx , [ YRes ]
  446. mov [(KeyboardType esi).Adjust_YPos],0
  447. jz ??No_scaleY
  448. mov [(KeyboardType esi).Adjust_YPos],edx
  449. ??No_scaleY:
  450. ENDIF
  451. mov ecx, [ XRes ] ; set the mouses x coordinate to 160
  452. mov edx, [ YRes ] ; set the mouses x coordinate to 160
  453. cmp [(KeyboardType esi).Adjust],1
  454. je ??no_ecx_shift
  455. shr ecx , 1
  456. ??no_ecx_shift:
  457. shr edx , 1
  458. mov [MInstalled],TRUE ; set the fact that mouse is installed
  459. mov [(KeyboardType esi).MDisabled],TRUE ; disable mouse until the overlay is loaded
  460. ; Set new Mouse position any way
  461. call Clear_RM_regs
  462. mov eax , 0300h
  463. mov ebx , 033h
  464. mov [RealInt . _eax ] , 4
  465. mov [RealInt . _ecx] , ecx
  466. mov [RealInt . _edx] , edx
  467. xor ecx , ecx
  468. lea edi, [RealInt]
  469. int DPMI_INTR
  470. call Clear_RM_regs
  471. mov eax, 0300h
  472. mov ebx ,33h ; mouse is in 33h
  473. mov ecx,0 ; any mouse condition generates int
  474. mov edx,[RealModePtr] ; get real mode memory address
  475. shr edx,4 ; convert it to a segment
  476. mov [RealInt. _es],dx ; store it in the real mode es
  477. movzx edx,[(KeyboardType PTR esi).MouseCodeOffset] ; Get address of code
  478. mov [RealInt._edx],edx ; set edx to offset of code
  479. mov [RealInt._eax],12 ; set eax to set interrupt routine
  480. mov [RealInt._ecx],31
  481. lea edi, [RealInt]
  482. int DPMI_INTR
  483. ??installed:
  484. mov eax,TRUE ; return TRUE if all is well
  485. mov [(KeyboardType esi).MDisabled],FALSE ; no 32 bit overlays installed
  486. je ??exit
  487. ??error:
  488. mov eax,FALSE
  489. ??exit:
  490. ret
  491. ENDP Reset_Mouse
  492. ;***************************************************************************
  493. ;* REMOVE_MOUSE -- uninstalls the mouse interrupt by disabling the call *
  494. ;* *
  495. ;* This routine will uninstall the mouse interrupt. It does this by *
  496. ;* simply disabling the call condition. The interrupt itself is still *
  497. ;* present, just uncalled until dos removes it at program termination. *
  498. ;* *
  499. ;* INPUT: none *
  500. ;* *
  501. ;* OUTPUT: none *
  502. ;* *
  503. ;* PROTO: VOID Remove_Mouse(VOID); *
  504. ;* *
  505. ;* HISTORY: *
  506. ;* 08/29/1994 PWG : Created. *
  507. ;*=========================================================================*
  508. GLOBAL Remove_Mouse:NEAR
  509. PROC Remove_Mouse C NEAR
  510. USES eax,ebx,ecx,edx,esi,edi
  511. call Clear_RM_regs
  512. cmp [MInstalled],FALSE ; check to see if mouse installed
  513. je ??exit ; if not then no need to remove it
  514. mov [MInstalled],FALSE ; Force to NOT-Installed.
  515. ;;PWG cmp [_MSWIFTDevice],1 ; check to see if SWIFT device installed
  516. ;;PWG je short ??prevSWIFT ; if so use previous SWIFT event handler
  517. mov ebx , 033h
  518. mov edx,[RealModePtr] ; get real mode memory address
  519. test edx,edx ; check that the memory block is valid
  520. jz ??exit
  521. shr edx,4 ; convert it to a segment
  522. mov [RealInt._es],dx ; store it in the real mode es
  523. xor edx,edx
  524. mov esi,[RealModePtr] ; get offset of real mode data start
  525. mov dx,[(KeyboardType PTR esi).MouseCodeOffset] ; Get address of code
  526. mov [RealInt._edx],edx ; set edx to offset of code
  527. mov [RealInt._eax],12 ; set eax to set interrupt routine
  528. mov [RealInt._ecx],0
  529. mov ecx,0 ; no mouse condition generates an int
  530. mov eax,0300h
  531. lea edi,[RealInt]
  532. int DPMI_INTR
  533. mov eax,0601h ; function number.
  534. mov ecx,[MouseCursor] ; ecx must have start of memory.
  535. mov edi,[BufferSize]
  536. shl edi,1
  537. shld ebx,ecx,16
  538. shld esi,edi,16
  539. int DPMI_INTR ; do call.
  540. ; Deallocate real memory buffer
  541. mov edx ,[MouseBufferSel]
  542. test dx ,dx
  543. jz ??exit
  544. mov eax ,0101h
  545. int DPMI_INTR
  546. ??exit:
  547. ret
  548. ENDP Remove_Mouse
  549. ;***************************************************************************
  550. GLOBAL Clear_RM_regs :NEAR
  551. PROC Clear_RM_regs NEAR
  552. push eax
  553. push ecx
  554. push edi
  555. lea edi , [ RealInt ]
  556. lea ecx , [ RealInt . nothing ]
  557. sub ecx , edi
  558. xor eax , eax
  559. shr ecx , 2
  560. rep stosd
  561. pop edi
  562. pop ecx
  563. pop eax
  564. ret
  565. ENDP Clear_RM_regs
  566. ;***************************************************************************
  567. ;* GET_MOUSE_X -- Returns the mouses x pixel position *
  568. ;* *
  569. ;* *
  570. ;* *
  571. ;* INPUT: none *
  572. ;* *
  573. ;* OUTPUT: int - the mouse x position in pixels *
  574. ;* *
  575. ;* WARNINGS: int Get_Mouse_X(void); *
  576. ;* *
  577. ;* HISTORY: *
  578. ;* 08/29/1994 PWG : Created. *
  579. ;*=========================================================================*
  580. GLOBAL Get_Mouse_X:NEAR
  581. PROC Get_Mouse_X C NEAR
  582. USES esi
  583. mov esi,[RealModePtr]
  584. mov eax,[(KeyboardType esi).MouseX]
  585. ret
  586. ENDP Get_Mouse_X
  587. ;***************************************************************************
  588. ;* GET_MOUSE_STATE -- Returns the current mouse state *
  589. ;* *
  590. ;* *
  591. ;* *
  592. ;* INPUT: none *
  593. ;* *
  594. ;* OUTPUT: int - the mouse's current state *
  595. ;* *
  596. ;* WARNINGS: int Get_Mouse_State(void); *
  597. ;* *
  598. ;* HISTORY: *
  599. ;* 08/29/1994 PWG : Created. *
  600. ;*=========================================================================*
  601. GLOBAL Get_Mouse_State:NEAR
  602. PROC Get_Mouse_State C NEAR
  603. USES esi
  604. mov esi,[RealModePtr]
  605. mov eax,[(KeyboardType esi).MState]
  606. ret
  607. ENDP Get_Mouse_State
  608. ;***************************************************************************
  609. ;* GET_MOUSE_X -- Returns the mouses x pixel position *
  610. ;* *
  611. ;* *
  612. ;* *
  613. ;* INPUT: none *
  614. ;* *
  615. ;* OUTPUT: int - the mouse x position in pixels *
  616. ;* *
  617. ;* WARNINGS: int Get_Mouse_X(void); *
  618. ;* *
  619. ;* HISTORY: *
  620. ;* 08/29/1994 PWG : Created. *
  621. ;*=========================================================================*
  622. GLOBAL Get_Mouse_Disabled:NEAR
  623. PROC Get_Mouse_Disabled C NEAR
  624. USES esi
  625. mov esi,[RealModePtr]
  626. movzx eax,[(KeyboardType esi).MDisabled]
  627. ret
  628. ENDP Get_Mouse_Disabled
  629. ;***************************************************************************
  630. ;* GET_MOUSE_Y -- Returns the mouse's y pixel position *
  631. ;* *
  632. ;* *
  633. ;* *
  634. ;* INPUT: none *
  635. ;* *
  636. ;* OUTPUT: int - the mouses y position in pixels *
  637. ;* *
  638. ;* PROTO: int Get_Mouse_Y(void); *
  639. ;* *
  640. ;* HISTORY: *
  641. ;* 08/29/1994 PWG : Created. *
  642. ;*=========================================================================*
  643. GLOBAL Get_Mouse_Y:NEAR
  644. PROC Get_Mouse_Y C NEAR
  645. USES esi
  646. mov esi,[RealModePtr]
  647. mov eax,[(KeyboardType esi).MouseY]
  648. ret
  649. ENDP Get_Mouse_Y
  650. ;***************************************************************************
  651. ;* GET_MOUSE_BUTTON -- Gets the values of the mouse button *
  652. ;* *
  653. ;* *
  654. ;* *
  655. ;* INPUT: *
  656. ;* *
  657. ;* OUTPUT: *
  658. ;* *
  659. ;* PROTO: *
  660. ;* *
  661. ;* WARNINGS: *
  662. ;* *
  663. ;* HISTORY: *
  664. ;* 09/19/1994 PWG : Created. *
  665. ;*=========================================================================*
  666. GLOBAL Get_Mouse_Button:NEAR
  667. PROC Get_Mouse_Button C NEAR
  668. USES eax,esi
  669. mov esi,[RealModePtr]
  670. xor eax,eax
  671. mov al,[(KeyboardType esi).Button]
  672. ret
  673. ENDP Get_Mouse_Button
  674. ;***************************************************************************
  675. ;* SET_MOUSE_CURSOR -- Sets the shape to be used as the mouse. *
  676. ;* *
  677. ;* This will inform the system of the shape desired as the mouse *
  678. ;* cursor. *
  679. ;* *
  680. ;* INPUT: xhotspot -- Offset of click point into shape. *
  681. ;* *
  682. ;* yhotspot -- Offset of click point into shape. *
  683. ;* *
  684. ;* cursor -- Shape to use as the new mouse shape. *
  685. ;* *
  686. ;* OUTPUT: Returns with a pointer to the original mouse shape. *
  687. ;* *
  688. ;* PROTO: VOID *Set_Mouse_Cursor( int xhotspot, *
  689. ;* int yhotspot, *
  690. ;* void *cursor); *
  691. ;* *
  692. ;* HISTORY: *
  693. ;* 02/13/1992 JLB : Created. *
  694. ;*=========================================================================*
  695. GLOBAL Set_Mouse_Cursor:NEAR
  696. PROC Set_Mouse_Cursor C NEAR
  697. USES ebx,ecx,edx,esi,edi
  698. ARG xhotspot:DWORD ; the x hot spot of the mouse
  699. ARG yhotspot:DWORD ; the y hot spot of the mouse
  700. ARG cursor:DWORD ; ptr to the new mouse cursor
  701. LOCAL datasize:DWORD
  702. LOCAL stype:WORD
  703. LOCAL swidth:DWORD ; Shape width.
  704. LOCAL sheight:DWORD ; Shape height.
  705. LOCAL ssize:DWORD ; Size of raw shape.
  706. ;*=========================================================================*
  707. ; Direction flag must be forward in this routine.
  708. ;*=========================================================================*
  709. cld
  710. mov esi,[RealModePtr] ; get offset of real mode data start
  711. ;-------------------------------------------------------------------
  712. ; Make sure the mouse is Enabled and Installed before continuing
  713. ;-------------------------------------------------------------------
  714. mov eax,[cursor]
  715. cmp eax,0 ; if the mouse cursor is in zero page
  716. je ??exit ; it is completely invalid
  717. cmp eax,[PrevMousePtr]
  718. je ??exit
  719. cmp [(KeyboardType esi).MDisabled],FALSE ; make sure the mouse is not disabled
  720. jne ??exit ; if it is not then give it a try
  721. ;-------------------------------------------------------------------
  722. ; We need to wait if a mouse interrupt is in progress. Once the
  723. ; interrupt is finished flag that it is occuring so that it will
  724. ; not attempt to draw the mouse while we are changing the cursor.
  725. ;-------------------------------------------------------------------
  726. ??try:
  727. inc [(KeyboardType esi).MouseUpdate] ; flag that mouse can not be drawn
  728. ;-------------------------------------------------------------------
  729. ; If the mouse is currently on the screen hide it.
  730. ;-------------------------------------------------------------------
  731. call Low_Hide_Mouse
  732. ;-------------------------------------------------------------------
  733. ; Calculate the size of the buffer needed.
  734. ;-------------------------------------------------------------------
  735. push [cursor]
  736. call Get_Shape_Uncomp_Size
  737. pop edx
  738. mov [datasize],eax
  739. push [cursor]
  740. call Get_Shape_Width
  741. pop edx
  742. mov [swidth],eax
  743. cmp eax,[BufferWidth]
  744. jg ??end
  745. push [cursor]
  746. call Get_Shape_Original_Height
  747. pop edx
  748. mov [sheight],eax
  749. cmp eax,[BufferHeight]
  750. jg ??end
  751. mov ebx,[sheight]
  752. mov eax,[swidth]
  753. imul ebx,eax
  754. ??copy_mouse:
  755. mov esi,[cursor] ; set esi to point to mouse shape
  756. mov ax,[esi] ; get the shape type byte
  757. mov [stype],ax ; save off the shape type
  758. test ax,MAKESHAPE_NOCOMP ; is it marked as no compression?
  759. je ??comp_shape ; if not go to the comped shape code
  760. mov edi,[MouseCursor] ; set edi to point to mouse buffer
  761. ??copy_type:
  762. test [stype],MAKESHAPE_COMPACT ; if the shape a 16 color shape?
  763. jne ??16_color_copy ; if it is then go handle it
  764. ??normal_copy:
  765. ;-------------------------------------------------------------------
  766. ;* Uncompressed NORMAL shapes just get run-length uncompressed
  767. ;-------------------------------------------------------------------
  768. add esi,10 ; adjust past header of shape
  769. mov eax,[swidth] ; load up the width
  770. mul [sheight] ; find size of shape in pixels
  771. mov edx,eax ; save this in number of bytes
  772. xor ecx,ecx ; clear high of loop variable
  773. ??norm_unrle:
  774. mov al,[esi] ; get a byte out of the file
  775. inc esi ; increment to the next pos
  776. or al,al ; set the flags on register state
  777. jz ??norm_trans ; if its a zero its transparent
  778. mov [edi],al ; write out the pixel to dest
  779. inc edi ; move to next dest position
  780. dec edx ; we have now written another pix
  781. jnz ??norm_unrle ; if more to write then do it
  782. jmp ??done_copy ; otherwise we are all done
  783. ??norm_trans:
  784. mov cl,[esi] ; get how many zeros to write
  785. sub edx,ecx
  786. inc esi ; increment the source position
  787. xor al,al ; clear out al cuz we're writing zeros
  788. rep stosb ; write all of them out
  789. or edx,edx
  790. jnz ??norm_unrle ; if more to do then do it
  791. jmp ??done_copy ; otherwise we are done
  792. ??16_color_copy:
  793. ;-------------------------------------------------------------------
  794. ;* Uncompressed 16 color shapes just get remaped and UN-RLE'd
  795. ;-------------------------------------------------------------------
  796. add esi,10 ; adjust past header of shape
  797. mov ebx,esi ; save of position of remap
  798. add esi,16 ; move past remap table
  799. mov eax,[swidth] ; load up the width
  800. mul [sheight] ; load up the height
  801. mov edx,eax ; save this in number of bytes
  802. xor eax,eax ; clear high of lookup variable
  803. xor ecx,ecx ; clear high of loop variable
  804. ??16_color_unrle:
  805. mov al,[esi] ; get a byte out of the file
  806. inc esi ; increment to the next pos
  807. or al,al ; set the flags on register state
  808. jz ??16_color_trans ; if its a zero its transparent
  809. mov al,[ebx+eax] ; remap the pixel from 16 color table
  810. mov [edi],al ; store it out to the dest address
  811. inc edi ; move to next dest address
  812. dec edx ; we have now written a pixel
  813. jnz ??16_color_unrle
  814. jmp ??done_copy
  815. ??16_color_trans:
  816. mov cl,[esi] ; get how many zeros to write
  817. sub edx,ecx ; subtract off count ahead of time
  818. inc esi ; increment the source position
  819. xor al,al ; clear out al cuz we're writing zeros
  820. rep stosb ; write all of them out
  821. or edx,edx ; or edx to test for zero
  822. jnz ??16_color_unrle
  823. jmp ??done_copy
  824. ;-------------------------------------------------------------------
  825. ; Deal with the compressed shape by copying it into the shape
  826. ; staging buffer.
  827. ;-------------------------------------------------------------------
  828. ??comp_shape:
  829. mov edi,[_ShapeBuffer] ; get a pointer to ShapeBuffer
  830. mov ax,[esi] ; load in the shape type
  831. add esi,2 ; increment the shape pointer
  832. or ax,MAKESHAPE_NOCOMP ; make the shape as uncompressed
  833. mov [stype],ax ; save off the shape type
  834. mov [edi],ax ; write out uncompressed shape
  835. add edi,2
  836. ;-------------------------------------------------------------------
  837. ; Process the shape header information and copy it over to the new
  838. ; location.
  839. ;-------------------------------------------------------------------
  840. mov ecx,4 ; transfer height, width, org and
  841. test eax,MAKESHAPE_COMPACT ; is it a 16 color shape?
  842. je ??copy_head ; no - don't worry about it
  843. add ecx,8 ; otherwise adjust ecx for header
  844. ??copy_head:
  845. rep movsw ; copy the necessary bytes
  846. mov eax,[datasize] ; get uncompressed length
  847. push eax ; push as third param
  848. push edi ; push the destination offset
  849. push esi ; push the source offset
  850. call LCW_Uncompress ; do the uncompress
  851. pop eax
  852. pop eax
  853. pop eax
  854. mov esi,[_ShapeBuffer]
  855. mov edi,[MouseCursor] ; set edi to point to mouse buffer
  856. jmp ??copy_type
  857. ??done_copy:
  858. mov esi,[RealModePtr] ; get offset of real mode data start
  859. mov eax,[xhotspot] ; get the mouse cursors x hotspot
  860. mov [(KeyboardType esi).MouseXHot],eax
  861. mov eax,[yhotspot] ; get the mouse cursors y hotspot
  862. mov [(KeyboardType esi).MouseYHot],eax
  863. mov ebx,[sheight] ; get shape height
  864. mov [(KeyboardType esi).MouseHeight],ebx
  865. mov ebx,[swidth]
  866. mov [(KeyboardType esi).MouseWidth],ebx
  867. ??error:
  868. call Low_Show_Mouse
  869. ;-------------------------------------------------------------------
  870. ; Final cleanup and exit.
  871. ;-------------------------------------------------------------------
  872. ??end:
  873. dec [(KeyboardType esi).MouseUpdate] ; we are done modifying the cursor
  874. ??exit:
  875. push [cursor]
  876. push [PrevMousePtr]
  877. pop eax
  878. pop [PrevMousePtr]
  879. ret ; and return back to the world
  880. ENDP Set_Mouse_Cursor
  881. ;***************************************************************************
  882. ;* LOW_HIDE_MOUSE -- Low-level routine which hides the mouse *
  883. ;* *
  884. ;* INPUT: none *
  885. ;* *
  886. ;* OUTPUT: none *
  887. ;* *
  888. ;* WARNINGS: none *
  889. ;* *
  890. ;* HISTORY: *
  891. ;* 09/19/1994 PWG : Created. *
  892. ;*=========================================================================*
  893. GLOBAL C Low_Hide_Mouse:NEAR
  894. PROC Low_Hide_Mouse C NEAR
  895. USES eax,ebx,esi
  896. mov ebx,[RealModePtr] ; get 32 bit offset of dos data
  897. ;*=========================================================================*
  898. ;* Is the mouse disabled or hidden?
  899. ;*=========================================================================*
  900. cmp [(KeyboardType ebx).MDisabled],0 ; is the mouse disabled?
  901. jne short ??end
  902. cmp [(KeyboardType ebx).MState],0 ; is the mouse hidden?
  903. jne short ??endnodraw ; no need to hide again
  904. ;*=========================================================================*
  905. ;* Take care of restoring the mouse cursor
  906. ;*=========================================================================*
  907. mov eax,RESTORE_VISIBLE_PAGE
  908. push eax
  909. call [ Mouse_Shadow_Buffer]
  910. pop eax
  911. ;*=========================================================================*
  912. ;* The mouse is now hidden -- again.
  913. ;*=========================================================================*
  914. ??endnodraw:
  915. add [(KeyboardType ebx).MState],1
  916. adc [(KeyboardType ebx).MState],0
  917. ??end:
  918. ret
  919. ENDP Low_Hide_Mouse
  920. ;***************************************************************************
  921. ;* LOW_SHOW_MOUSE -- Low level routine which shows the mouse *
  922. ;* *
  923. ;* INPUT: none *
  924. ;* *
  925. ;* OUTPUT: none *
  926. ;* *
  927. ;* WARNINGS: none *
  928. ;* *
  929. ;* HISTORY: *
  930. ;* 09/19/1994 PWG : Created. *
  931. ;*=========================================================================*
  932. GLOBAL C Low_Show_Mouse:NEAR
  933. PROC Low_Show_Mouse C NEAR
  934. USES eax,ebx,ecx,edx,edi,esi
  935. LOCAL mousex:DWORD
  936. LOCAL mousey:DWORD
  937. mov esi,[RealModePtr] ; get offset of real mode data start
  938. ;*=========================================================================*
  939. ;* Don't show the mouse if it is not hidden or it is disabled
  940. ;*=========================================================================*
  941. cmp [(KeyboardType esi).MDisabled],0 ; is the mouse disabled
  942. jne ??exit ; if so then exit
  943. cmp [(KeyboardType esi).MState],0 ; is the mouse already visible
  944. je ??exit ; if so then exit
  945. ;*=========================================================================*
  946. ;* Don't show the mouse if it was hidden multiple times
  947. ;*=========================================================================*
  948. dec [(KeyboardType esi).MState] ; show the mouse one level
  949. cmp [(KeyboardType esi).MState],0 ; can the mouse be shown
  950. jne short ??exit
  951. ;*=========================================================================*
  952. ;* Determine the theoretcial drawing position of the mouse
  953. ;*=========================================================================*
  954. mov ecx,[(KeyboardType esi).MouseWidth] ; Theoretical buffer width (pixel).
  955. mov edx,[(KeyboardType esi).MouseHeight] ; Theoretical buffer height (pixel).
  956. mov eax,[(KeyboardType esi).MouseX]
  957. mov [mousex],eax ; Draw X pixel.
  958. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  959. mov ebx,[(KeyboardType esi).MouseY]
  960. mov [mousey],ebx ; Draw Y pixel.
  961. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  962. ;*=========================================================================*
  963. ;* Determine the theoretical coordinates and dimensions of the
  964. ;* area the mouse shape will be rendered upon.
  965. ;*=========================================================================*
  966. mov [(KeyboardType esi).MouseBuffX],eax
  967. mov [(KeyboardType esi).MouseBuffY],ebx
  968. mov [(KeyboardType esi).MouseBuffW],ecx
  969. mov [(KeyboardType esi).MouseBuffH],edx
  970. ;------ Move the area that will be drawn upon, to the graphic buffer.
  971. mov eax,STORE_VISIBLE_PAGE
  972. push eax
  973. call [ Mouse_Shadow_Buffer ]
  974. pop eax
  975. ;------ Draw the mouse shape to the seenpage.
  976. push [mousey]
  977. push [mousex]
  978. call [ Draw_Mouse ]
  979. pop eax
  980. pop eax
  981. ??exit:
  982. ret
  983. ENDP Low_Show_Mouse
  984. ;***************************************************************************
  985. ;* HIDE_MOUSE -- Hides mouse cursor on screen if it was show *
  986. ;* *
  987. ;* INPUT: none *
  988. ;* *
  989. ;* OUTPUT: none *
  990. ;* *
  991. ;* PROTO: void Hide_Mouse(void); *
  992. ;* *
  993. ;* HISTORY: *
  994. ;* 11/03/1994 PWG : Created. *
  995. ;*=========================================================================*
  996. GLOBAL Hide_Mouse:NEAR
  997. PROC Hide_Mouse C NEAR
  998. USES eax,esi
  999. mov esi,[RealModePtr] ; get the real mode offset
  1000. ;*=========================================================================*
  1001. ;* Mark us as updating the mouse and then run and do the update
  1002. ;*=========================================================================*
  1003. inc [(KeyboardType esi).MouseUpdate] ; were drawing the mouse
  1004. call Low_Hide_Mouse ; make the function call
  1005. dec [(KeyboardType esi).MouseUpdate] ; were done drawing mouse
  1006. ret
  1007. ENDP Hide_Mouse
  1008. ;----------------------------------------------------------------------------
  1009. ;***************************************************************************
  1010. ;* SHOW_MOUSE -- Display mouse cursor on screen if it was hidden *
  1011. ;* *
  1012. ;* INPUT: none *
  1013. ;* *
  1014. ;* OUTPUT: none *
  1015. ;* *
  1016. ;* PROTO: void Show_Mouse(void) *
  1017. ;* *
  1018. ;* HISTORY: *
  1019. ;* 11/03/1994 PWG : Created. *
  1020. ;*=========================================================================*
  1021. GLOBAL Show_Mouse:NEAR
  1022. PROC Show_Mouse C NEAR
  1023. USES eax,esi
  1024. mov esi,[RealModePtr] ; get the real mode offset
  1025. ;*=========================================================================*
  1026. ;* Mark us as updating the mouse and then run and do the update
  1027. ;*=========================================================================*
  1028. inc [(KeyboardType esi).MouseUpdate] ; were drawing the mouse
  1029. call Low_Show_Mouse ; make the function call
  1030. dec [(KeyboardType esi).MouseUpdate] ; were done drawing mouse
  1031. ret
  1032. ENDP Show_Mouse
  1033. ;***************************************************************************
  1034. ;* CONDITIONAL_HIDE_MOUSE -- Hides mouse if its with given region *
  1035. ;* *
  1036. ;* INPUT: int sx_pixel - the left-most pixel position of the region *
  1037. ;* int sy_pixel - the upper-most pixel position of the region *
  1038. ;* int dx_pixel - the right most pixel position of the region *
  1039. ;* int dy_pixel - the lower most pixel position of the region *
  1040. ;* *
  1041. ;* OUTPUT: none *
  1042. ;* *
  1043. ;* PROTO: void Conditional_Hide_Mouse( int sx_pixel, *
  1044. ;* int sy_pixel, *
  1045. ;* int dx_pixel, *
  1046. ;* int dy_pixel); *
  1047. ;* *
  1048. ;* HISTORY: *
  1049. ;* 11/03/1994 PWG : Created. *
  1050. ;*=========================================================================*
  1051. GLOBAL Conditional_Hide_Mouse:NEAR
  1052. PROC Conditional_Hide_Mouse C NEAR
  1053. USES eax,ebx,ecx,edx,esi,edi
  1054. ARG sx_pixel:DWORD ; left x pixel pos
  1055. ARG sy_pixel:DWORD ; upper y pixel pos
  1056. ARG dx_pixel:DWORD ; right x pixel pos
  1057. ARG dy_pixel:DWORD ; lower y pixel pos
  1058. mov esi,[RealModePtr] ; get the real mode offset
  1059. ;*=========================================================================*
  1060. ;* Widen region leftward by amount mouse shape spills to the right of
  1061. ;* its hot point. Limited to the left edge of the screen.
  1062. ;*=========================================================================*
  1063. mov eax,[(KeyboardType esi).MouseWidth]
  1064. sub eax,[(KeyboardType esi).MouseXHot]
  1065. neg eax
  1066. add eax,[sx_pixel]
  1067. jns short ??noleftlimit
  1068. xor eax,eax
  1069. ??noleftlimit:
  1070. ;*=========================================================================*
  1071. ;* Widen region upward by amount mouse shape spills below the
  1072. ;* mouse's hot point. Limited by the top edge of the screen.
  1073. ;*=========================================================================*
  1074. mov ebx,[(KeyboardType esi).MouseHeight]
  1075. sub ebx,[(KeyboardType esi).MouseYHot]
  1076. neg ebx
  1077. add ebx,[sy_pixel]
  1078. jns short ??notoplimit
  1079. xor ebx,ebx
  1080. ??notoplimit:
  1081. ;*=========================================================================*
  1082. ;* Widen region rightward by amount mouse shape spills to the
  1083. ;* left of its hot point. Limited by the right edge of the
  1084. ;* screen.
  1085. ;*=========================================================================*
  1086. mov ecx,[dx_pixel]
  1087. add ecx,[(KeyboardType esi).MouseXHot]
  1088. cmp ecx,[(KeyboardType esi).MouseRight]
  1089. jb short ??norightlimit
  1090. mov ecx,[(KeyboardType esi).MouseRight]
  1091. dec ecx
  1092. ??norightlimit:
  1093. ;*=========================================================================*
  1094. ;* Widen region downward by amout the mouse shape extends above
  1095. ;* its hot point. Limited to the bottom of the screen.
  1096. ;*=========================================================================*
  1097. mov edx,[dy_pixel]
  1098. add edx,[(KeyboardType esi).MouseYHot]
  1099. cmp edx,[(KeyboardType esi).MouseBottom]
  1100. jb short ??nobottomlimit
  1101. mov edx,[(KeyboardType esi).MouseBottom]
  1102. dec edx
  1103. ??nobottomlimit:
  1104. inc [(KeyboardType esi).MouseUpdate] ; don't let interrupt scrag variables
  1105. ;*=========================================================================*
  1106. ;* The mouse could be in one of four conditions.
  1107. ;* 1) The mouse is visible and no conditional hide has been specified.
  1108. ;* (perform normal region checking with possible hide)
  1109. ;* 2) The mouse is hidden and no conditional hide as been specified.
  1110. ;* (record region and do nothing)
  1111. ;* 3) The mouse is visible and a conditional region has been specified
  1112. ;* (expand region and perform check with possible hide).
  1113. ;* 4) The mouse is already hidden by a previous conditional.
  1114. ;* (expand region and do nothing)
  1115. ;*
  1116. ;* First: Set or expand the region according to the specified parameters
  1117. ;*=========================================================================*
  1118. cmp [(KeyboardType esi).MCState],0
  1119. jne short ??expand
  1120. mov [(KeyboardType esi).MouseCXLeft],eax
  1121. mov [(KeyboardType esi).MouseCYUpper],ebx
  1122. mov [(KeyboardType esi).MouseCXRight],ecx
  1123. mov [(KeyboardType esi).MouseCYLower],edx
  1124. jmp ??noylower
  1125. ??expand:
  1126. ;*=========================================================================*
  1127. ;* Expand the clipping rectangle.
  1128. ;*=========================================================================*
  1129. cmp eax,[(KeyboardType esi).MouseCXLeft]
  1130. jb short ??noxleft
  1131. mov [(KeyboardType esi).MouseCXLeft],eax
  1132. ??noxleft:
  1133. cmp ebx,[(KeyboardType esi).MouseCYUpper]
  1134. jb short ??noyupper
  1135. mov [(KeyboardType esi).MouseCYUpper],ebx
  1136. ??noyupper:
  1137. cmp ecx,[(KeyboardType esi).MouseCXRight]
  1138. ja short ??noxright
  1139. mov [(KeyboardType esi).MouseCXRight],ecx
  1140. ??noxright:
  1141. cmp edx,[(KeyboardType esi).MouseCYLower]
  1142. ja short ??noylower
  1143. mov [(KeyboardType esi).MouseCYLower],edx
  1144. ??noylower:
  1145. ;*=========================================================================*
  1146. ;* If the mouse isn't already hidden, then check its location against
  1147. ;* the hiding region and hide if necessary.
  1148. ;*=========================================================================*
  1149. test [(KeyboardType esi).MCState],CONDHIDDEN
  1150. jne short ??nohide
  1151. mov eax,[(KeyboardType esi).MouseX]
  1152. mov ebx,[(KeyboardType esi).MouseY]
  1153. cmp eax,[(KeyboardType esi).MouseCXLeft]
  1154. jb short ??nohide
  1155. cmp eax,[(KeyboardType esi).MouseCXRight]
  1156. ja short ??nohide
  1157. cmp ebx,[(KeyboardType esi).MouseCYUpper]
  1158. jb short ??nohide
  1159. cmp ebx,[(KeyboardType esi).MouseCYLower]
  1160. ja short ??nohide
  1161. ;*=========================================================================*
  1162. ;* The mouse falls within the region for hiding, so hide it.
  1163. ;*=========================================================================*
  1164. call Low_Hide_Mouse ; make the function call
  1165. or [(KeyboardType esi).MCState],CONDHIDDEN
  1166. ??nohide:
  1167. ;*=========================================================================*
  1168. ;* Record the fact that a Conditional_Hide_Mouse was
  1169. ;* called and then exit.
  1170. ;*=========================================================================*
  1171. or [(KeyboardType esi).MCState],CONDHIDE
  1172. add [BYTE PTR (KeyboardType esi).MCState],1
  1173. adc [BYTE PTR (KeyboardType esi).MCState],0
  1174. dec [(KeyboardType esi).MouseUpdate]
  1175. ret
  1176. ENDP Conditional_Hide_Mouse
  1177. ;***************************************************************************
  1178. ;* CONDITIONAL_SHOW_MOUSE -- shows mouse if it was conditionally hidden *
  1179. ;* *
  1180. ;* INPUT: none *
  1181. ;* *
  1182. ;* OUTPUT: none *
  1183. ;* *
  1184. ;* PROTO: void Conditional_Show_Mouse(void); *
  1185. ;* *
  1186. ;* HISTORY: *
  1187. ;* 11/03/1994 PWG : Created. *
  1188. ;*=========================================================================*
  1189. GLOBAL Conditional_Show_Mouse:NEAR
  1190. PROC Conditional_Show_Mouse C NEAR
  1191. USES eax,esi
  1192. mov esi,[RealModePtr] ; get the real mode offset
  1193. ;*=========================================================================*
  1194. ; Notify the interrupt that we are updating the mouse
  1195. ;*=========================================================================*
  1196. inc [(KeyboardType esi).MouseUpdate]
  1197. mov ax,[(KeyboardType esi).MCState]
  1198. cmp al,0
  1199. je short ??exit ; if no more nesting clear cond
  1200. ;*=========================================================================*
  1201. ;* Decrement the conditional hide counter.
  1202. ;*=========================================================================*
  1203. dec al
  1204. ;*=========================================================================*
  1205. ;* If there are more conditional levels to undo, then just abort the show.
  1206. ;*=========================================================================*
  1207. jne short ??exit
  1208. ;*=========================================================================*
  1209. ;* Yup, the mouse should be show, but only if it was previously hidden.
  1210. ;*=========================================================================*
  1211. test ax,CONDHIDDEN ; was it hidden by interrupt??
  1212. je short ??exit1 ; or initial check for level 0
  1213. call Low_Show_Mouse
  1214. ??exit1:
  1215. mov ax,0
  1216. ??exit:
  1217. mov [(KeyboardType esi).MCState],ax
  1218. dec [(KeyboardType esi).MouseUpdate]
  1219. ret
  1220. ENDP Conditional_Show_Mouse
  1221. ;***************************************************************************
  1222. ;***************************************************************************
  1223. ;***************************************************************************
  1224. ;***************************************************************************
  1225. ;* MOUSE_SHADOW_BUFFER -- Handles storing and restoring the mouse buffer *
  1226. ;* *
  1227. ;* INPUT: int store - indicates whether we are storing the buffer or *
  1228. ;* not. *
  1229. ;* *
  1230. ;* OUTPUT: none *
  1231. ;* *
  1232. ;* PROTO: Asm callable only! *
  1233. ;* *
  1234. ;* HISTORY: *
  1235. ;* 10/27/1994 PWG : Created. *
  1236. ;*=========================================================================*
  1237. GLOBAL C VGA_Mouse_Shadow_Buffer:NEAR
  1238. PROC VGA_Mouse_Shadow_Buffer C NEAR
  1239. USES eax,ebx,ecx,edx,edi,esi
  1240. ARG store:DWORD
  1241. local x0 : dword
  1242. local y0 : dword
  1243. local x1 : dword
  1244. local y1 : dword
  1245. local buffx0 : dword
  1246. local buffy0 : dword
  1247. mov esi,[RealModePtr] ; get 32 bit offset of dos data
  1248. ;*=========================================================================*
  1249. ; Direction flag must be forward in this routine.
  1250. ;*=========================================================================*
  1251. cld
  1252. ;*===================================================================
  1253. ;* Copy of X, Y, Width and Height into local registers
  1254. ;*===================================================================
  1255. mov eax,[(KeyboardType esi).MouseBuffX]
  1256. mov ebx,[(KeyboardType esi).MouseBuffY]
  1257. sub eax,[(KeyboardType esi).MouseXHot]
  1258. sub ebx,[(KeyboardType esi).MouseYHot]
  1259. mov [ x0 ] , eax
  1260. mov [ y0 ] , ebx
  1261. add eax,[(KeyboardType esi).MouseBuffW]
  1262. add ebx,[(KeyboardType esi).MouseBuffH]
  1263. mov [ x1 ] , eax
  1264. mov [ y1 ] , ebx
  1265. mov [ buffx0 ] , 0
  1266. mov eax , [ MouseBuffer ]
  1267. mov [ buffy0 ] , eax
  1268. ;*===================================================================
  1269. ;* Bounds check source X.
  1270. ;*===================================================================
  1271. xor eax , eax
  1272. xor edx , edx
  1273. mov ecx , [ x0 ]
  1274. mov ebx , [ x1 ]
  1275. shld eax , ecx , 1
  1276. shld edx , ebx , 1
  1277. mov ecx , [ x0 ]
  1278. mov ebx , [ x1 ]
  1279. sub ecx , [(KeyboardType esi).MouseRight]
  1280. sub ebx , [(KeyboardType esi).MouseRight]
  1281. dec ecx
  1282. dec ebx
  1283. shld eax , ecx , 1
  1284. shld edx , ebx , 1
  1285. mov ecx , [ y0 ]
  1286. mov ebx , [ y1 ]
  1287. shld eax , ecx , 1
  1288. shld edx , ebx , 1
  1289. mov ecx , [ y0 ]
  1290. mov ebx , [ y1 ]
  1291. sub ecx , [(KeyboardType esi).MouseBottom]
  1292. sub ebx , [(KeyboardType esi).MouseBottom]
  1293. dec ecx
  1294. dec ebx
  1295. shld eax , ecx , 1
  1296. shld edx , ebx , 1
  1297. xor al , 5
  1298. xor dl , 5
  1299. mov ah , al
  1300. test dl , al
  1301. jnz ??out
  1302. or al , dl
  1303. jz ??not_clip
  1304. test ah , 1000b
  1305. jz ??scr_left_ok
  1306. mov ebx , [ x0 ]
  1307. neg ebx
  1308. mov [ buffx0 ] , ebx
  1309. mov [ x0 ] , 0
  1310. ??scr_left_ok:
  1311. test ah , 0010b
  1312. jz ??scr_bottom_ok
  1313. mov ebx , [ y0 ]
  1314. neg ebx
  1315. imul ebx , [(KeyboardType esi).MouseBuffW]
  1316. add [ buffy0 ] , ebx
  1317. mov [ y0 ] , 0
  1318. ??scr_bottom_ok:
  1319. test dl , 0100b
  1320. jz ??scr_right_ok
  1321. mov eax , [(KeyboardType esi).MouseRight] ; get width into register
  1322. mov [ x1 ] , eax
  1323. ??scr_right_ok:
  1324. test dl , 0001b
  1325. jz ??not_clip
  1326. mov eax , [(KeyboardType esi).MouseBottom] ; get width into register
  1327. mov [ y1 ] , eax
  1328. ??not_clip:
  1329. ;*===================================================================
  1330. ;* Get the offset into the screen.
  1331. ;*===================================================================
  1332. mov eax , [ y0 ]
  1333. mov edx , [(KeyboardType esi).MouseRight]
  1334. imul eax , edx
  1335. add eax , [ x0 ]
  1336. lea edi , [ 0a0000h + eax ]
  1337. ;*===================================================================
  1338. ;* Adjust the source for the top clip.
  1339. ;*===================================================================
  1340. mov ebx , [(KeyboardType esi).MouseBuffW] ; turn this into an offset
  1341. mov esi , [ buffy0 ] ; edx points to source
  1342. add esi , [ buffx0 ] ; plus clipped lines
  1343. ;*===================================================================
  1344. ;* Calculate the bytes per row add value
  1345. ;*===================================================================
  1346. mov eax , [ x1 ]
  1347. mov ecx , [ y1 ]
  1348. sub eax , [ x0 ]
  1349. jle ??out
  1350. sub ecx , [ y0 ]
  1351. jle ??out
  1352. sub edx , eax
  1353. sub ebx , eax
  1354. push ebp
  1355. cmp [store],RESTORE_VISIBLE_PAGE ; are we restoring page?
  1356. jne ??store_entry ; if not the go to store
  1357. ;*===================================================================
  1358. ;* Handle restoring the buffer to the visible page
  1359. ;*===================================================================
  1360. mov ebp , ecx
  1361. ??restore_loop:
  1362. mov ecx,eax ; get number to really write
  1363. rep movsb ; store them into the buffer
  1364. add esi,ebx ; move past right clipped pixels
  1365. add edi,edx ; adjust dest to next line
  1366. dec ebp ; decrement number of rows to do
  1367. jnz ??restore_loop ; if more to do, do it
  1368. pop ebp
  1369. ret
  1370. ;*===================================================================
  1371. ;* Handle soting the visible page into the Mouse Shadow Buffer
  1372. ;*===================================================================
  1373. ??store_entry:
  1374. xchg esi,edi ; xchg the source and the dest
  1375. mov ebp , ecx
  1376. ??store_loop:
  1377. mov ecx,eax ; get number to really write
  1378. rep movsb ; store them into the buffer
  1379. add esi,edx ; move past right clipped pixels
  1380. add edi,ebx ; adjust dest to next line
  1381. dec ebp ; decrement number of rows to do
  1382. jnz ??store_loop ; if more to do, do it
  1383. pop ebp
  1384. ??out:
  1385. ret
  1386. ENDP VGA_Mouse_Shadow_Buffer
  1387. ;***************************************************************************
  1388. ;* DRAW_MOUSE -- Handles drawing the mouse cursor *
  1389. ;* *
  1390. ;* INPUT: none *
  1391. ;* *
  1392. ;* OUTPUT: none *
  1393. ;* *
  1394. ;* PROTO: Asm callable only! *
  1395. ;* *
  1396. ;* HISTORY: *
  1397. ;* 10/27/1994 PWG : Created. *
  1398. ;*=========================================================================*
  1399. GLOBAL VGA_Draw_Mouse:NEAR
  1400. PROC VGA_Draw_Mouse C NEAR
  1401. USES eax,ebx,ecx,edx,edi,esi
  1402. ARG mousex:DWORD
  1403. ARG mousey:DWORD
  1404. local x0 : dword
  1405. local y0 : dword
  1406. local x1 : dword
  1407. local y1 : dword
  1408. local buffx0 : dword
  1409. local buffy0 : dword
  1410. mov esi,[RealModePtr] ; get 32 bit offset of dos data
  1411. ;*===================================================================
  1412. ;* Copy of X, Y, Width and Height into local registers
  1413. ;*===================================================================
  1414. mov eax,[mousex]
  1415. mov ebx,[mousey]
  1416. sub eax,[(KeyboardType esi).MouseXHot]
  1417. sub ebx,[(KeyboardType esi).MouseYHot]
  1418. mov [ x0 ] , eax
  1419. mov [ y0 ] , ebx
  1420. add eax,[(KeyboardType esi).MouseWidth]
  1421. add ebx,[(KeyboardType esi).MouseHeight]
  1422. mov [ x1 ] , eax
  1423. mov [ y1 ] , ebx
  1424. mov [ buffx0 ] , 0
  1425. mov eax , [ MouseCursor ]
  1426. mov [ buffy0 ] , eax
  1427. ;*===================================================================
  1428. ;* Bounds check source X. Y.
  1429. ;*===================================================================
  1430. xor eax , eax
  1431. xor edx , edx
  1432. mov ecx , [ x0 ]
  1433. mov ebx , [ x1 ]
  1434. shld eax , ecx , 1
  1435. shld edx , ebx , 1
  1436. mov ecx , [ x0 ]
  1437. mov ebx , [ x1 ]
  1438. sub ecx , [(KeyboardType esi).MouseRight]
  1439. sub ebx , [(KeyboardType esi).MouseRight]
  1440. dec ecx
  1441. dec ebx
  1442. shld eax , ecx , 1
  1443. shld edx , ebx , 1
  1444. mov ecx , [ y0 ]
  1445. mov ebx , [ y1 ]
  1446. shld eax , ecx , 1
  1447. shld edx , ebx , 1
  1448. mov ecx , [ y0 ]
  1449. mov ebx , [ y1 ]
  1450. sub ecx , [(KeyboardType esi).MouseBottom]
  1451. sub ebx , [(KeyboardType esi).MouseBottom]
  1452. dec ecx
  1453. dec ebx
  1454. shld eax , ecx , 1
  1455. shld edx , ebx , 1
  1456. xor al , 5
  1457. xor dl , 5
  1458. mov ah , al
  1459. test dl , al
  1460. jnz ??out
  1461. or al , dl
  1462. jz ??not_clip
  1463. test ah , 1000b
  1464. jz ??scr_left_ok
  1465. mov ebx , [ x0 ]
  1466. neg ebx
  1467. mov [ buffx0 ] , ebx
  1468. mov [ x0 ] , 0
  1469. ??scr_left_ok:
  1470. test ah , 0010b
  1471. jz ??scr_bottom_ok
  1472. mov ebx , [ y0 ]
  1473. neg ebx
  1474. imul ebx , [(KeyboardType esi).MouseWidth]
  1475. add [ buffy0 ] , ebx
  1476. mov [ y0 ] , 0
  1477. ??scr_bottom_ok:
  1478. test dl , 0100b
  1479. jz ??scr_right_ok
  1480. mov eax , [(KeyboardType esi).MouseRight] ; get width into register
  1481. mov [ x1 ] , eax
  1482. ??scr_right_ok:
  1483. test dl , 0001b
  1484. jz ??not_clip
  1485. mov eax , [(KeyboardType esi).MouseBottom] ; get width into register
  1486. mov [ y1 ] , eax
  1487. ??not_clip:
  1488. ;*===================================================================
  1489. ;* Get the offset into the screen.
  1490. ;*===================================================================
  1491. mov eax , [ y0 ]
  1492. mov edx , [(KeyboardType esi).MouseRight]
  1493. imul eax , edx
  1494. add eax , [ x0 ]
  1495. lea edi , [ 0a0000h + eax ]
  1496. ;*===================================================================
  1497. ;* Adjust the source for the top clip.
  1498. ;*===================================================================
  1499. mov ebx , [(KeyboardType esi).MouseWidth] ; turn this into an offset
  1500. mov esi , [ buffy0 ] ; edx points to source
  1501. add esi , [ buffx0 ] ; plus clipped lines
  1502. ;*===================================================================
  1503. ;* Calculate the bytes per row add value
  1504. ;*===================================================================
  1505. mov eax , [ x1 ]
  1506. mov ecx , [ y1 ]
  1507. sub eax , [ x0 ]
  1508. jle ??out
  1509. sub ecx , [ y0 ]
  1510. jle ??out
  1511. sub edx , eax
  1512. sub ebx , eax
  1513. ;*===================================================================
  1514. ;* Handle restoring the buffer to the visible page
  1515. ;*===================================================================
  1516. ??top_loop:
  1517. mov ah,al
  1518. ??inner_loop:
  1519. mov ch ,[esi]
  1520. inc esi
  1521. or ch,ch
  1522. jz ??inc_edi
  1523. mov [edi],ch
  1524. ??inc_edi:
  1525. inc edi
  1526. dec ah
  1527. jnz ??inner_loop
  1528. add esi,ebx ; move past right clipped pixels
  1529. add edi,edx ; adjust dest to next line
  1530. dec cl ; decrement number of rows to do
  1531. jnz ??top_loop ; if more to do, do it
  1532. ??out:
  1533. ret
  1534. ENDP VGA_Draw_Mouse
  1535. ;***************************************************************************
  1536. ;***************************************************************************
  1537. ;***************************************************************************
  1538. ;***************************************************************************
  1539. ;* MOUSE_SHADOW_BUFFER -- Handles storing and restoring the mouse buffer *
  1540. ;* *
  1541. ;* INPUT: int store - indicates whether we are storing the buffer or *
  1542. ;* not. *
  1543. ;* *
  1544. ;* OUTPUT: none *
  1545. ;* *
  1546. ;* PROTO: Asm callable only! *
  1547. ;* *
  1548. ;* HISTORY: *
  1549. ;* 10/27/1994 PWG : Created. *
  1550. ;*=========================================================================*
  1551. GLOBAL C VESA_Mouse_Shadow_Buffer:NEAR
  1552. PROC VESA_Mouse_Shadow_Buffer C NEAR
  1553. USES eax,ebx,ecx,edx,edi,esi
  1554. ARG store:DWORD
  1555. local x0 : dword
  1556. local y0 : dword
  1557. local x1 : dword
  1558. local y1 : dword
  1559. local buffx0 : dword
  1560. local buffy0 : dword
  1561. local vesa_linear : dword
  1562. mov eax , [ cpu_video_page ]
  1563. mov [ vesa_linear ] , eax
  1564. mov esi,[RealModePtr] ; get 32 bit offset of dos data
  1565. ;*=========================================================================*
  1566. ; Direction flag must be forward in this routine.
  1567. ;*=========================================================================*
  1568. ;*===================================================================
  1569. ;* Copy of X, Y, Width and Height into local registers
  1570. ;*===================================================================
  1571. mov eax,[(KeyboardType esi).MouseBuffX]
  1572. mov ebx,[(KeyboardType esi).MouseBuffY]
  1573. sub eax,[(KeyboardType esi).MouseXHot]
  1574. sub ebx,[(KeyboardType esi).MouseYHot]
  1575. mov [ x0 ] , eax
  1576. mov [ y0 ] , ebx
  1577. add eax,[(KeyboardType esi).MouseBuffW]
  1578. add ebx,[(KeyboardType esi).MouseBuffH]
  1579. mov [ x1 ] , eax
  1580. mov [ y1 ] , ebx
  1581. mov [ buffx0 ] , 0
  1582. mov eax , [ MouseBuffer ]
  1583. mov [ buffy0 ] , eax
  1584. ;*===================================================================
  1585. ;* Bounds check source X.
  1586. ;*===================================================================
  1587. xor eax , eax
  1588. xor edx , edx
  1589. mov ecx , [ x0 ]
  1590. mov ebx , [ x1 ]
  1591. shld eax , ecx , 1
  1592. shld edx , ebx , 1
  1593. mov ecx , [ x0 ]
  1594. mov ebx , [ x1 ]
  1595. sub ecx , [(KeyboardType esi).MouseRight]
  1596. sub ebx , [(KeyboardType esi).MouseRight]
  1597. dec ecx
  1598. dec ebx
  1599. shld eax , ecx , 1
  1600. shld edx , ebx , 1
  1601. mov ecx , [ y0 ]
  1602. mov ebx , [ y1 ]
  1603. shld eax , ecx , 1
  1604. shld edx , ebx , 1
  1605. mov ecx , [ y0 ]
  1606. mov ebx , [ y1 ]
  1607. sub ecx , [(KeyboardType esi).MouseBottom]
  1608. sub ebx , [(KeyboardType esi).MouseBottom]
  1609. dec ecx
  1610. dec ebx
  1611. shld eax , ecx , 1
  1612. shld edx , ebx , 1
  1613. xor al , 5
  1614. xor dl , 5
  1615. mov ah , al
  1616. test dl , al
  1617. jnz ??out
  1618. or al , dl
  1619. jz ??not_clip
  1620. test ah , 1000b
  1621. jz ??scr_left_ok
  1622. mov ebx , [ x0 ]
  1623. neg ebx
  1624. mov [ buffx0 ] , ebx
  1625. mov [ x0 ] , 0
  1626. ??scr_left_ok:
  1627. test ah , 0010b
  1628. jz ??scr_bottom_ok
  1629. mov ebx , [ y0 ]
  1630. neg ebx
  1631. imul ebx , [(KeyboardType esi).MouseBuffW]
  1632. add [ buffy0 ] , ebx
  1633. mov [ y0 ] , 0
  1634. ??scr_bottom_ok:
  1635. test dl , 0100b
  1636. jz ??scr_right_ok
  1637. mov eax , [(KeyboardType esi).MouseRight] ; get width into register
  1638. mov [ x1 ] , eax
  1639. ??scr_right_ok:
  1640. test dl , 0001b
  1641. jz ??not_clip
  1642. mov eax , [(KeyboardType esi).MouseBottom] ; get width into register
  1643. mov [ y1 ] , eax
  1644. ??not_clip:
  1645. ;*===================================================================
  1646. ;* Get the offset into the screen.
  1647. ;*===================================================================
  1648. mov eax , [ y0 ]
  1649. mov edx , [(KeyboardType esi).MouseRight]
  1650. imul eax , edx
  1651. add eax , [ x0 ]
  1652. lea edi , [ 0a0000h + eax ]
  1653. call Vesa_Asm_Set_Win
  1654. ;*===================================================================
  1655. ;* Adjust the source for the top clip.
  1656. ;*===================================================================
  1657. mov ebx , [(KeyboardType esi).MouseBuffW] ; turn this into an offset
  1658. mov esi , [ buffy0 ] ; edx points to source
  1659. add esi , [ buffx0 ] ; plus clipped lines
  1660. ;*===================================================================
  1661. ;* Calculate the bytes per row add value
  1662. ;*===================================================================
  1663. mov eax , [ x1 ]
  1664. mov ecx , [ y1 ]
  1665. sub eax , [ x0 ]
  1666. jle ??out
  1667. sub ecx , [ y0 ]
  1668. jle ??out
  1669. sub edx , eax
  1670. sub ebx , eax
  1671. cmp [store],RESTORE_VISIBLE_PAGE ; are we restoring page?
  1672. jne ??store_entry ; if not the go to store
  1673. ;*===================================================================
  1674. ;* Handle restoring the buffer to the visible page
  1675. ;*===================================================================
  1676. mov [ tempreg ] , ebx
  1677. ??restore__top_loop:
  1678. mov ah,al
  1679. ??restore__inner_loop:
  1680. mov ch ,[esi]
  1681. mov [edi],ch
  1682. inc esi
  1683. inc edi
  1684. mov ebx , edi
  1685. add ebx , [ cpu_video_page ]
  1686. cmp ebx , [ cpu_page_limit ]
  1687. jl ??restore__in_range
  1688. add edi , [ cpu_video_page ]
  1689. call Vesa_Asm_Set_Win
  1690. ??restore__in_range:
  1691. dec ah
  1692. jnz ??restore__inner_loop
  1693. add esi,[ tempreg ] ; move past right clipped pixels
  1694. add edi,edx ; adjust dest to next line
  1695. mov ebx , edi
  1696. add ebx , [ cpu_video_page ]
  1697. cmp ebx , [ cpu_page_limit ]
  1698. jl ??restore__in_range1
  1699. add edi ,[ cpu_video_page ]
  1700. call Vesa_Asm_Set_Win
  1701. ??restore__in_range1:
  1702. dec cl ; decrement number of rows to do
  1703. jnz ??restore__top_loop ; if more to do, do it
  1704. jmp ??out ; get the heck outta the routine
  1705. ;*===================================================================
  1706. ;* Handle soting the visible page into the Mouse Shadow Buffer
  1707. ;*===================================================================
  1708. ??store_entry:
  1709. mov [ tempreg ] , ebx
  1710. ??store_top_loop:
  1711. mov ah,al
  1712. ??store_inner_loop:
  1713. mov ch ,[edi]
  1714. mov [esi],ch
  1715. inc esi
  1716. inc edi
  1717. mov ebx , edi
  1718. add ebx , [ cpu_video_page ]
  1719. cmp ebx , [ cpu_page_limit ]
  1720. jl ??store_in_range
  1721. add edi ,[ cpu_video_page ]
  1722. call Vesa_Asm_Set_Win
  1723. ??store_in_range:
  1724. dec ah
  1725. jnz ??store_inner_loop
  1726. add esi,[ tempreg ] ; move past right clipped pixels
  1727. add edi,edx ; adjust dest to next line
  1728. mov ebx , edi
  1729. add ebx , [ cpu_video_page ]
  1730. cmp ebx , [ cpu_page_limit ]
  1731. jl ??store_in_range1
  1732. add edi ,[ cpu_video_page ]
  1733. call Vesa_Asm_Set_Win
  1734. ??store_in_range1:
  1735. dec cl ; decrement number of rows to do
  1736. jnz ??store_top_loop ; if more to do, do it
  1737. ??out:
  1738. mov edi , [ vesa_linear ]
  1739. add edi , 0a0000h
  1740. call Vesa_Asm_Set_Win
  1741. ret
  1742. ENDP VESA_Mouse_Shadow_Buffer
  1743. ;***************************************************************************
  1744. ;* DRAW_MOUSE -- Handles drawing the mouse cursor *
  1745. ;* *
  1746. ;* INPUT: none *
  1747. ;* *
  1748. ;* OUTPUT: none *
  1749. ;* *
  1750. ;* PROTO: Asm callable only! *
  1751. ;* *
  1752. ;* HISTORY: *
  1753. ;* 10/27/1994 PWG : Created. *
  1754. ;*=========================================================================*
  1755. GLOBAL VESA_Draw_Mouse:NEAR
  1756. PROC VESA_Draw_Mouse C NEAR
  1757. USES eax,ebx,ecx,edx,edi,esi
  1758. ARG mousex:DWORD
  1759. ARG mousey:DWORD
  1760. local x0 : dword
  1761. local y0 : dword
  1762. local x1 : dword
  1763. local y1 : dword
  1764. local buffx0 : dword
  1765. local buffy0 : dword
  1766. local tempreg : dword
  1767. local vesa_linear : dword
  1768. mov eax , [ cpu_video_page ]
  1769. mov [ vesa_linear ] , eax
  1770. mov esi,[RealModePtr] ; get 32 bit offset of dos data
  1771. ;*===================================================================
  1772. ;* Copy of X, Y, Width and Height into local registers
  1773. ;*===================================================================
  1774. mov eax,[mousex]
  1775. mov ebx,[mousey]
  1776. sub eax,[(KeyboardType esi).MouseXHot]
  1777. sub ebx,[(KeyboardType esi).MouseYHot]
  1778. mov [ x0 ] , eax
  1779. mov [ y0 ] , ebx
  1780. add eax,[(KeyboardType esi).MouseWidth]
  1781. add ebx,[(KeyboardType esi).MouseHeight]
  1782. mov [ x1 ] , eax
  1783. mov [ y1 ] , ebx
  1784. mov [ buffx0 ] , 0
  1785. mov eax , [ MouseCursor ]
  1786. mov [ buffy0 ] , eax
  1787. ;*===================================================================
  1788. ;* Bounds check source X. Y.
  1789. ;*===================================================================
  1790. xor eax , eax
  1791. xor edx , edx
  1792. mov ecx , [ x0 ]
  1793. mov ebx , [ x1 ]
  1794. shld eax , ecx , 1
  1795. shld edx , ebx , 1
  1796. mov ecx , [ x0 ]
  1797. mov ebx , [ x1 ]
  1798. sub ecx , [(KeyboardType esi).MouseRight]
  1799. sub ebx , [(KeyboardType esi).MouseRight]
  1800. dec ecx
  1801. dec ebx
  1802. shld eax , ecx , 1
  1803. shld edx , ebx , 1
  1804. mov ecx , [ y0 ]
  1805. mov ebx , [ y1 ]
  1806. shld eax , ecx , 1
  1807. shld edx , ebx , 1
  1808. mov ecx , [ y0 ]
  1809. mov ebx , [ y1 ]
  1810. sub ecx , [(KeyboardType esi).MouseBottom]
  1811. sub ebx , [(KeyboardType esi).MouseBottom]
  1812. dec ecx
  1813. dec ebx
  1814. shld eax , ecx , 1
  1815. shld edx , ebx , 1
  1816. xor al , 5
  1817. xor dl , 5
  1818. mov ah , al
  1819. test dl , al
  1820. jnz ??out
  1821. or al , dl
  1822. jz ??not_clip
  1823. test ah , 1000b
  1824. jz ??scr_left_ok
  1825. mov ebx , [ x0 ]
  1826. neg ebx
  1827. mov [ buffx0 ] , ebx
  1828. mov [ x0 ] , 0
  1829. ??scr_left_ok:
  1830. test ah , 0010b
  1831. jz ??scr_bottom_ok
  1832. mov ebx , [ y0 ]
  1833. neg ebx
  1834. imul ebx , [(KeyboardType esi).MouseWidth]
  1835. add [ buffy0 ] , ebx
  1836. mov [ y0 ] , 0
  1837. ??scr_bottom_ok:
  1838. test dl , 0100b
  1839. jz ??scr_right_ok
  1840. mov eax , [(KeyboardType esi).MouseRight] ; get width into register
  1841. mov [ x1 ] , eax
  1842. ??scr_right_ok:
  1843. test dl , 0001b
  1844. jz ??not_clip
  1845. mov eax , [(KeyboardType esi).MouseBottom] ; get width into register
  1846. mov [ y1 ] , eax
  1847. ??not_clip:
  1848. ;*===================================================================
  1849. ;* Get the offset into the screen.
  1850. ;*===================================================================
  1851. mov eax , [ y0 ]
  1852. mov edx , [(KeyboardType esi).MouseRight]
  1853. imul eax , edx
  1854. add eax , [ x0 ]
  1855. lea edi , [ 0a0000h + eax ]
  1856. call Vesa_Asm_Set_Win
  1857. ;*===================================================================
  1858. ;* Adjust the source for the top clip.
  1859. ;*===================================================================
  1860. mov ebx , [(KeyboardType esi).MouseWidth] ; turn this into an offset
  1861. mov esi , [ buffy0 ] ; edx points to source
  1862. add esi , [ buffx0 ] ; plus clipped lines
  1863. ;*===================================================================
  1864. ;* Calculate the bytes per row add value
  1865. ;*===================================================================
  1866. mov eax , [ x1 ]
  1867. mov ecx , [ y1 ]
  1868. sub eax , [ x0 ]
  1869. jle ??out
  1870. sub ecx , [ y0 ]
  1871. jle ??out
  1872. sub edx , eax
  1873. sub ebx , eax
  1874. ;*===================================================================
  1875. ;* Handle restoring the buffer to the visible page
  1876. ;*===================================================================
  1877. mov [ tempreg ] , ebx
  1878. ??top_loop:
  1879. mov ah,al
  1880. ??inner_loop:
  1881. mov ch ,[esi]
  1882. inc esi
  1883. or ch,ch
  1884. jz ??inc_edi
  1885. mov [edi],ch
  1886. ??inc_edi:
  1887. inc edi
  1888. mov ebx , edi
  1889. add ebx , [ cpu_video_page ]
  1890. cmp ebx , [ cpu_page_limit ]
  1891. jl ??in_range
  1892. add edi ,[ cpu_video_page ]
  1893. call Vesa_Asm_Set_Win
  1894. ??in_range:
  1895. dec ah
  1896. jnz ??inner_loop
  1897. add esi,[ tempreg ] ; move past right clipped pixels
  1898. add edi,edx ; adjust dest to next line
  1899. mov ebx , edi
  1900. add ebx , [ cpu_video_page ]
  1901. cmp ebx , [ cpu_page_limit ]
  1902. jl ??in_range1
  1903. add edi ,[ cpu_video_page ]
  1904. call Vesa_Asm_Set_Win
  1905. ??in_range1:
  1906. dec cl ; decrement number of rows to do
  1907. jnz ??top_loop ; if more to do, do it
  1908. ??out:
  1909. mov edi , [ vesa_linear ]
  1910. add edi , 0a0000h
  1911. call Vesa_Asm_Set_Win
  1912. ret
  1913. ENDP VESA_Draw_Mouse
  1914. ;----------------------------------------------------------------------------
  1915. END