MOUSE.ASM 75 KB

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