MOUSE.ASM 75 KB

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