Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

5702 lines
218 KiB

  1. ; Program: Installable Device Driver for Mouse.
  2. ;
  3. ; Purpose: to provide compatability with the
  4. ; Microsoft MOUSE.SYS device driver.
  5. ; the code here installs the driver and
  6. ; hooks the IVT in exactly the same
  7. ; way as the current Insignia MOUSE.COM.
  8. ;
  9. ; Version: 1.00 Date: 28th October 1992.
  10. ;
  11. ; Author: Andrew Watson
  12. ;
  13. ; Revisions:
  14. ;
  15. ; 23-June-1994 Williamh, made mode 4/5 and 12 work.
  16. ;
  17. ; 12-Sep-1992 Jonle, Merged with ntio.sys
  18. ; optimized loading of IVT
  19. ;
  20. ; 5-March-1993 Andyw, Moved fullscreen text pointer code
  21. ; from 32bit land to 16bit driver for
  22. ; for speed purposes.
  23. ;
  24. ; This obj module is intially loaded in a temporary memory location
  25. ; along with ntio.sys. Ntio.sys will copy the resident code (marked by
  26. ; SpcMseBeg, SpcMseEnd) into the permanent memory location which resides
  27. ; just below the normal device drivers loaded by config.sys.
  28. ;
  29. ; The nonresident intialization code is run with CS= temp seg
  30. ; and DS= final seg.
  31. ;
  32. ;
  33. ;****************************************************************
  34. .286
  35. include vint.inc
  36. ;================================================================
  37. ; Defined constants used in the driver.
  38. ;================================================================
  39. VERSIONID equ 0BEEFh
  40. MAXCMD equ 16
  41. UNKNOWN equ 8003h
  42. DONE equ 0100h
  43. MOUSEVER equ 0003h
  44. INT1_BOP equ 0BAh
  45. INT2_BOP equ 0BBh
  46. IO_LANG_BOP equ 0BCh
  47. IO_INTR_BOP equ 0BDh
  48. VIDEO_IO_BOP equ 0BEh
  49. UNSIMULATE_BOP equ 0FEh
  50. VIDEO equ 010h
  51. UNEXP_BOP equ 2
  52. STACKSIZE equ 200h-1
  53. TRUE equ 0
  54. FALSE equ 1
  55. STORED equ 0
  56. NOTSTORED equ 1
  57. ON equ 0
  58. OFF equ 1
  59. MAJOR_RELEASE_NUMBER equ 6
  60. MINOR_RELEASE_NUMBER equ 26
  61. ifdef DBCS
  62. MAX_VIDEO_NUMBER equ 013h
  63. DBCS_TEXT_MODE_NUMBER equ MAX_VIDEO_NUMBER + 1
  64. DBCS_GRAPHIC_MODE_NUMBER equ 12h
  65. endif ; DBCS
  66. ;MACROSMACROSMACROSMACROSMACROSMACROSMACROSMACROSMACROSMACROSMACROSMACROSMACROS
  67. bop MACRO callid
  68. db 0c4h,0c4h,callid
  69. endm
  70. ;=============================================================================
  71. ; Macro to reassign the stack segment register to point at the driver code
  72. ; segment and the stack pointer to point to the most significant word in an
  73. ; array reserved as the driver stack.
  74. ;=============================================================================
  75. ;; !!!! interrupt must be disabled before calling this function !!!!!!
  76. make_stack MACRO
  77. LOCAL reent ;; a local symbol to this macro
  78. ;; call DOCLI ;; turn off interrupts during this
  79. ;; macro's execution even if the CPU
  80. ;; does this for you when modifying SS
  81. inc cs:reentrant ;; has the interrupt been nested?
  82. jnz reent ;; not reentrant if == zero
  83. ;; The driver code is not reentrant, so start the stack at the beginning
  84. mov cs:top_of_stack,ss ;; save the entry SS
  85. mov cs:top_of_stack-2,sp ;; save SP on the stack
  86. push cs ;; the current code/data segment
  87. pop ss ;; point SS at CS
  88. ;; point SP at the next free stack location.
  89. mov sp,offset top_of_stack-2 ;; The current stack pointer position
  90. reent: ;; REENTRANT > 0 therefore reentrancy exists
  91. ;; The driver has gone reentrant due to a nested interrupt, so just
  92. ;; leave the stack alone because it is the same under reentrancy.
  93. ;; call DOSTI ;; reenable interrupts
  94. ENDM
  95. ;=============================================================================
  96. ; Macro to return the stack pointer and segment back to what it was when
  97. ; the driver was called.
  98. ;=============================================================================
  99. kill_stack MACRO
  100. LOCAL reent1
  101. ;; cli
  102. cmp cs:reentrant,0 ;; is the code currently reentrant?
  103. jg reent1 ;; yes it is
  104. mov sp,cs:top_of_stack-2 ;; pop SP
  105. mov ss,cs:top_of_stack ;; pop SS
  106. reent1:
  107. dec cs:reentrant ;; reduce the level of reentrancy
  108. ;; call DOSTI
  109. ENDM
  110. ;MACROSMACROSMACROSMACROSMACROSMACROSMACROSMACROSMACROSMACROSMACROSMACROSMACROS
  111. ;
  112. ; Segment definitions for ntio.sys,
  113. ;
  114. include biosseg.inc
  115. SpcMseSeg segment
  116. assume cs:SpcMseSeg, ds:nothing, es:nothing
  117. ;
  118. ; SpcMseBeg - SpcMseEnd
  119. ;
  120. ; Marks the resident code, anything outside of these markers
  121. ; is discarded after intialization
  122. ; 15-Sep-1992 Jonle
  123. ;
  124. public SpcMseBeg
  125. SpcMseBeg label byte
  126. ; CAUTION: for crazy apps mouse recognition
  127. ;
  128. ; The offset for int33h_vector must not be Zero for Borlands QuattroPro
  129. ; The segment must not be in ROM area for pctools
  130. ; to keep the int33h_vector from having an offset of ZERO
  131. ; I have moved the data above it
  132. ; 25-Sep-1992 Jonle
  133. ; describe the default screen and cursor masks
  134. ; remember that x86 machines are little-endian
  135. ;;; include pointer.inc
  136. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  137. ;;;; We'll Get this back to an include file soon but I'm including it like
  138. ;;;; this for 'diplomatic' reasons. (ie I want to check this in without
  139. ;;;; also doing an 'addfile' at this stage)!!! - Simon.
  140. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  141. ; This data will be accessed, on occasion, word by word, so
  142. ; be tidy and align to a word boundary
  143. align 2
  144. ; Describe the default mouse pointer image. This is used if the
  145. ; user decides to switch on the pointer without specifying an image.
  146. default_cursor dw 0011111111111111b
  147. dw 0001111111111111b
  148. dw 0000111111111111b
  149. dw 0000011111111111b
  150. dw 0000001111111111b
  151. dw 0000000111111111b
  152. dw 0000000011111111b
  153. dw 0000000001111111b
  154. dw 0000000000111111b
  155. dw 0000000000011111b
  156. dw 0000000111111111b
  157. dw 0001000011111111b
  158. dw 0011000011111111b
  159. dw 1111100001111111b
  160. dw 1111100001111111b
  161. dw 1111110001111111b
  162. dw 0000000000000000b
  163. dw 0100000000000000b
  164. dw 0110000000000000b
  165. dw 0111000000000000b
  166. dw 0111100000000000b
  167. dw 0111110000000000b
  168. dw 0111111000000000b
  169. dw 0111111100000000b
  170. dw 0111111110000000b
  171. dw 0111110000000000b
  172. dw 0110110000000000b
  173. dw 0100011000000000b
  174. dw 0000011000000000b
  175. dw 0000001100000000b
  176. dw 0000001100000000b
  177. dw 0000000000000000b
  178. ; Set up the memory where the working cursor is situated. It is
  179. ; initialised to the default cursor image
  180. ;****************** ALIGNED FOR PIXEL ZERO *******************************
  181. ; screen mask
  182. even
  183. current_cursor db 00111111b,11111111b,11111111b
  184. db 00011111b,11111111b,11111111b
  185. db 00001111b,11111111b,11111111b
  186. db 00000111b,11111111b,11111111b
  187. db 00000011b,11111111b,11111111b
  188. db 00000001b,11111111b,11111111b
  189. db 00000000b,11111111b,11111111b
  190. db 00000000b,01111111b,11111111b
  191. db 00000000b,00111111b,11111111b
  192. db 00000000b,00011111b,11111111b
  193. db 00000001b,11111111b,11111111b
  194. db 00010000b,11111111b,11111111b
  195. db 00110000b,11111111b,11111111b
  196. db 11111000b,01111111b,11111111b
  197. db 11111000b,01111111b,11111111b
  198. db 11111100b,01111111b,11111111b
  199. ; cursor mask
  200. db 00000000b,00000000b,00000000b
  201. db 01000000b,00000000b,00000000b
  202. db 01100000b,00000000b,00000000b
  203. db 01110000b,00000000b,00000000b
  204. db 01111000b,00000000b,00000000b
  205. db 01111100b,00000000b,00000000b
  206. db 01111110b,00000000b,00000000b
  207. db 01111111b,00000000b,00000000b
  208. db 01111111b,10000000b,00000000b
  209. db 01111111b,11000000b,00000000b
  210. db 01101100b,00000000b,00000000b
  211. db 01000110b,00000000b,00000000b
  212. db 00000110b,00000000b,00000000b
  213. db 00000011b,00000000b,00000000b
  214. db 00000011b,00000000b,00000000b
  215. db 00000000b,00000000b,00000000b
  216. ;****************** ALIGNED FOR PIXEL ONE *******************************
  217. ; screen mask
  218. AlignData1:
  219. db 10011111b,11111111b,11111111b
  220. db 10001111b,11111111b,11111111b
  221. db 10000111b,11111111b,11111111b
  222. db 10000011b,11111111b,11111111b
  223. db 10000001b,11111111b,11111111b
  224. db 10000000b,11111111b,11111111b
  225. db 10000000b,01111111b,11111111b
  226. db 10000000b,00111111b,11111111b
  227. db 10000000b,00011111b,11111111b
  228. db 10000000b,00001111b,11111111b
  229. db 10000000b,11111111b,11111111b
  230. db 10001000b,01111111b,11111111b
  231. db 10011000b,01111111b,11111111b
  232. db 11111100b,00111111b,11111111b
  233. db 11111100b,00111111b,11111111b
  234. db 11111110b,00111111b,11111111b
  235. ; cursor mask
  236. db 00000000b,00000000b,00000000b
  237. db 00100000b,00000000b,00000000b
  238. db 00110000b,00000000b,00000000b
  239. db 00111000b,00000000b,00000000b
  240. db 00111100b,00000000b,00000000b
  241. db 00111110b,00000000b,00000000b
  242. db 00111111b,00000000b,00000000b
  243. db 00111111b,10000000b,00000000b
  244. db 00111111b,11000000b,00000000b
  245. db 00111111b,11100000b,00000000b
  246. db 00110110b,00000000b,00000000b
  247. db 00100011b,00000000b,00000000b
  248. db 00000011b,00000000b,00000000b
  249. db 00000001b,10000000b,00000000b
  250. db 00000001b,10000000b,00000000b
  251. db 00000000b,00000000b,00000000b
  252. ;****************** ALIGNED FOR PIXEL TWO *******************************
  253. ; screen mask
  254. AlignData2:
  255. db 11001111b,11111111b,11111111b
  256. db 11000111b,11111111b,11111111b
  257. db 11000011b,11111111b,11111111b
  258. db 11000001b,11111111b,11111111b
  259. db 11000000b,11111111b,11111111b
  260. db 11000000b,01111111b,11111111b
  261. db 11000000b,00111111b,11111111b
  262. db 11000000b,00011111b,11111111b
  263. db 11000000b,00001111b,11111111b
  264. db 11000000b,00000111b,11111111b
  265. db 11000000b,01111111b,11111111b
  266. db 11000100b,00111111b,11111111b
  267. db 11001100b,00111111b,11111111b
  268. db 11111110b,00011111b,11111111b
  269. db 11111110b,00011111b,11111111b
  270. db 11111111b,00011111b,11111111b
  271. ; cursor mask
  272. db 00000000b,00000000b,00000000b
  273. db 00010000b,00000000b,00000000b
  274. db 00011000b,00000000b,00000000b
  275. db 00011100b,00000000b,00000000b
  276. db 00011110b,00000000b,00000000b
  277. db 00011111b,00000000b,00000000b
  278. db 00011111b,10000000b,00000000b
  279. db 00011111b,11000000b,00000000b
  280. db 00011111b,11100000b,00000000b
  281. db 00011111b,11110000b,00000000b
  282. db 00011011b,00000000b,00000000b
  283. db 00010001b,10000000b,00000000b
  284. db 00000001b,10000000b,00000000b
  285. db 00000000b,11000000b,00000000b
  286. db 00000000b,11000000b,00000000b
  287. db 00000000b,00000000b,00000000b
  288. ;****************** ALIGNED FOR PIXEL THREE *******************************
  289. ; screen mask
  290. AlignData3:
  291. db 11100111b,11111111b,11111111b
  292. db 11100011b,11111111b,11111111b
  293. db 11100001b,11111111b,11111111b
  294. db 11100000b,11111111b,11111111b
  295. db 11100000b,01111111b,11111111b
  296. db 11100000b,00111111b,11111111b
  297. db 11100000b,00011111b,11111111b
  298. db 11100000b,00001111b,11111111b
  299. db 11100000b,00000111b,11111111b
  300. db 11100000b,00000011b,11111111b
  301. db 11100000b,00111111b,11111111b
  302. db 11100010b,00011111b,11111111b
  303. db 11100110b,00011111b,11111111b
  304. db 11111111b,00001111b,11111111b
  305. db 11111111b,00001111b,11111111b
  306. db 11111111b,10001111b,11111111b
  307. ; cursor mask
  308. db 00000000b,00000000b,00000000b
  309. db 00001000b,00000000b,00000000b
  310. db 00001100b,00000000b,00000000b
  311. db 00001110b,00000000b,00000000b
  312. db 00001111b,00000000b,00000000b
  313. db 00001111b,10000000b,00000000b
  314. db 00001111b,11000000b,00000000b
  315. db 00001111b,11100000b,00000000b
  316. db 00001111b,11110000b,00000000b
  317. db 00001111b,11111000b,00000000b
  318. db 00001101b,10000000b,00000000b
  319. db 00001000b,11000000b,00000000b
  320. db 00000000b,11000000b,00000000b
  321. db 00000000b,01100000b,00000000b
  322. db 00000000b,01100000b,00000000b
  323. db 00000000b,00000000b,00000000b
  324. ;****************** ALIGNED FOR PIXEL FOUR *******************************
  325. ; screen mask
  326. AlignData4:
  327. db 11110011b,11111111b,11111111b
  328. db 11110001b,11111111b,11111111b
  329. db 11110000b,11111111b,11111111b
  330. db 11110000b,01111111b,11111111b
  331. db 11110000b,00111111b,11111111b
  332. db 11110000b,00011111b,11111111b
  333. db 11110000b,00001111b,11111111b
  334. db 11110000b,00000111b,11111111b
  335. db 11110000b,00000011b,11111111b
  336. db 11110000b,00000001b,11111111b
  337. db 11110000b,00011111b,11111111b
  338. db 11110001b,00001111b,11111111b
  339. db 11110011b,00001111b,11111111b
  340. db 11111111b,10000111b,11111111b
  341. db 11111111b,10000111b,11111111b
  342. db 11111111b,11000111b,11111111b
  343. ; cursor mask
  344. db 00000000b,00000000b,00000000b
  345. db 00000100b,00000000b,00000000b
  346. db 00000110b,00000000b,00000000b
  347. db 00000111b,00000000b,00000000b
  348. db 00000111b,10000000b,00000000b
  349. db 00000111b,11000000b,00000000b
  350. db 00000111b,11100000b,00000000b
  351. db 00000111b,11110000b,00000000b
  352. db 00000111b,11111000b,00000000b
  353. db 00000111b,11111100b,00000000b
  354. db 00000110b,11000000b,00000000b
  355. db 00000100b,01100000b,00000000b
  356. db 00000000b,01100000b,00000000b
  357. db 00000000b,00110000b,00000000b
  358. db 00000000b,00110000b,00000000b
  359. db 00000000b,00000000b,00000000b
  360. ;****************** ALIGNED FOR PIXEL FIVE *******************************
  361. ; screen mask
  362. AlignData5:
  363. db 11111001b,11111111b,11111111b
  364. db 11111000b,11111111b,11111111b
  365. db 11111000b,01111111b,11111111b
  366. db 11111000b,00111111b,11111111b
  367. db 11111000b,00011111b,11111111b
  368. db 11111000b,00001111b,11111111b
  369. db 11111000b,00000111b,11111111b
  370. db 11111000b,00000011b,11111111b
  371. db 11111000b,00000001b,11111111b
  372. db 11111000b,00000000b,11111111b
  373. db 11111000b,00001111b,11111111b
  374. db 11111000b,10000111b,11111111b
  375. db 11111001b,10000111b,11111111b
  376. db 11111111b,11000011b,11111111b
  377. db 11111111b,11000011b,11111111b
  378. db 11111111b,11100011b,11111111b
  379. ; cursor mask
  380. db 00000000b,00000000b,00000000b
  381. db 00000010b,00000000b,00000000b
  382. db 00000011b,00000000b,00000000b
  383. db 00000011b,10000000b,00000000b
  384. db 00000011b,11000000b,00000000b
  385. db 00000011b,11100000b,00000000b
  386. db 00000011b,11110000b,00000000b
  387. db 00000011b,11111000b,00000000b
  388. db 00000011b,11111100b,00000000b
  389. db 00000011b,11111110b,00000000b
  390. db 00000011b,01100000b,00000000b
  391. db 00000010b,00110000b,00000000b
  392. db 00000000b,00110000b,00000000b
  393. db 00000000b,00011000b,00000000b
  394. db 00000000b,00011000b,00000000b
  395. db 00000000b,00000000b,00000000b
  396. ;****************** ALIGNED FOR PIXEL SIX *******************************
  397. ; screen mask
  398. AlignData6:
  399. db 11111100b,11111111b,11111111b
  400. db 11111100b,01111111b,11111111b
  401. db 11111100b,00111111b,11111111b
  402. db 11111100b,00011111b,11111111b
  403. db 11111100b,00001111b,11111111b
  404. db 11111100b,00000111b,11111111b
  405. db 11111100b,00000011b,11111111b
  406. db 11111100b,00000001b,11111111b
  407. db 11111100b,00000000b,11111111b
  408. db 11111100b,00000000b,01111111b
  409. db 11111100b,00000111b,11111111b
  410. db 11111100b,01000011b,11111111b
  411. db 11111100b,11000011b,11111111b
  412. db 11111111b,11100001b,11111111b
  413. db 11111111b,11100001b,11111111b
  414. db 11111111b,11110001b,11111111b
  415. ; cursor mask
  416. db 00000000b,00000000b,00000000b
  417. db 00000001b,00000000b,00000000b
  418. db 00000001b,10000000b,00000000b
  419. db 00000001b,11000000b,00000000b
  420. db 00000001b,11100000b,00000000b
  421. db 00000001b,11110000b,00000000b
  422. db 00000001b,11111000b,00000000b
  423. db 00000001b,11111100b,00000000b
  424. db 00000001b,11111110b,00000000b
  425. db 00000001b,11111111b,00000000b
  426. db 00000001b,10110000b,00000000b
  427. db 00000001b,00011000b,00000000b
  428. db 00000000b,00011000b,00000000b
  429. db 00000000b,00001100b,00000000b
  430. db 00000000b,00001100b,00000000b
  431. db 00000000b,00000000b,00000000b
  432. ;****************** ALIGNED FOR PIXEL SEVEN *******************************
  433. ; screen mask
  434. AlignData7:
  435. db 11111110b,01111111b,11111111b
  436. db 11111110b,00111111b,11111111b
  437. db 11111110b,00011111b,11111111b
  438. db 11111110b,00001111b,11111111b
  439. db 11111110b,00000111b,11111111b
  440. db 11111110b,00000011b,11111111b
  441. db 11111110b,00000001b,11111111b
  442. db 11111110b,00000000b,11111111b
  443. db 11111110b,00000000b,01111111b
  444. db 11111110b,00000000b,00111111b
  445. db 11111110b,00000011b,11111111b
  446. db 11111110b,00100001b,11111111b
  447. db 11111110b,01100001b,11111111b
  448. db 11111111b,11110000b,11111111b
  449. db 11111111b,11110000b,11111111b
  450. db 11111111b,11111000b,11111111b
  451. ; cursor mask
  452. db 00000000b,00000000b,00000000b
  453. db 00000000b,10000000b,00000000b
  454. db 00000000b,11000000b,00000000b
  455. db 00000000b,11100000b,00000000b
  456. db 00000000b,11110000b,00000000b
  457. db 00000000b,11111000b,00000000b
  458. db 00000000b,11111100b,00000000b
  459. db 00000000b,11111110b,00000000b
  460. db 00000000b,11111111b,00000000b
  461. db 00000000b,11111111b,10000000b
  462. db 00000000b,11011000b,00000000b
  463. db 00000000b,10001100b,00000000b
  464. db 00000000b,00001100b,00000000b
  465. db 00000000b,00000110b,00000000b
  466. db 00000000b,00000110b,00000000b
  467. db 00000000b,00000000b,00000000b
  468. ; Data area reserved for the clipped cursor images. When the pointer
  469. ; reaches byte 78 in the current raster, the image needs to be clipped
  470. ; to prevent it from being wrapped to the left hand edge of the screen.
  471. ; The image below stops that from happening by loading the image with
  472. ; a 1's partial AND mask and a 0's partial XOR mask.
  473. ; Note that byte 79 also needs a clipped image set.
  474. even
  475. clip_cursor78 db 00111111b,11111111b,11111111b
  476. db 00011111b,11111111b,11111111b
  477. db 00001111b,11111111b,11111111b
  478. db 00000111b,11111111b,11111111b
  479. db 00000011b,11111111b,11111111b
  480. db 00000001b,11111111b,11111111b
  481. db 00000000b,11111111b,11111111b
  482. db 00000000b,01111111b,11111111b
  483. db 00000000b,00111111b,11111111b
  484. db 00000000b,00011111b,11111111b
  485. db 00000001b,11111111b,11111111b
  486. db 00010000b,11111111b,11111111b
  487. db 00110000b,11111111b,11111111b
  488. db 11111000b,01111111b,11111111b
  489. db 11111000b,01111111b,11111111b
  490. db 11111100b,01111111b,11111111b
  491. ; cursor mask
  492. db 00000000b,00000000b,00000000b
  493. db 01000000b,00000000b,00000000b
  494. db 01100000b,00000000b,00000000b
  495. db 01110000b,00000000b,00000000b
  496. db 01111000b,00000000b,00000000b
  497. db 01111100b,00000000b,00000000b
  498. db 01111110b,00000000b,00000000b
  499. db 01111111b,00000000b,00000000b
  500. db 01111111b,10000000b,00000000b
  501. db 01111111b,11000000b,00000000b
  502. db 01101100b,00000000b,00000000b
  503. db 01000110b,00000000b,00000000b
  504. db 00000110b,00000000b,00000000b
  505. db 00000011b,00000000b,00000000b
  506. db 00000011b,00000000b,00000000b
  507. db 00000000b,00000000b,00000000b
  508. ;****************** ALIGNED FOR PIXEL ONE *******************************
  509. ; screen mask
  510. AlignClip178:
  511. db 10011111b,11111111b,11111111b
  512. db 10001111b,11111111b,11111111b
  513. db 10000111b,11111111b,11111111b
  514. db 10000011b,11111111b,11111111b
  515. db 10000001b,11111111b,11111111b
  516. db 10000000b,11111111b,11111111b
  517. db 10000000b,01111111b,11111111b
  518. db 10000000b,00111111b,11111111b
  519. db 10000000b,00011111b,11111111b
  520. db 10000000b,00001111b,11111111b
  521. db 10000000b,11111111b,11111111b
  522. db 10001000b,01111111b,11111111b
  523. db 10011000b,01111111b,11111111b
  524. db 11111100b,00111111b,11111111b
  525. db 11111100b,00111111b,11111111b
  526. db 11111110b,00111111b,11111111b
  527. ; cursor mask
  528. db 00000000b,00000000b,00000000b
  529. db 00100000b,00000000b,00000000b
  530. db 00110000b,00000000b,00000000b
  531. db 00111000b,00000000b,00000000b
  532. db 00111100b,00000000b,00000000b
  533. db 00111110b,00000000b,00000000b
  534. db 00111111b,00000000b,00000000b
  535. db 00111111b,10000000b,00000000b
  536. db 00111111b,11000000b,00000000b
  537. db 00111111b,11100000b,00000000b
  538. db 00110110b,00000000b,00000000b
  539. db 00100011b,00000000b,00000000b
  540. db 00000011b,00000000b,00000000b
  541. db 00000001b,10000000b,00000000b
  542. db 00000001b,10000000b,00000000b
  543. db 00000000b,00000000b,00000000b
  544. ;****************** ALIGNED FOR PIXEL TWO *******************************
  545. ; screen mask
  546. AlignClip278:
  547. db 11001111b,11111111b,11111111b
  548. db 11000111b,11111111b,11111111b
  549. db 11000011b,11111111b,11111111b
  550. db 11000001b,11111111b,11111111b
  551. db 11000000b,11111111b,11111111b
  552. db 11000000b,01111111b,11111111b
  553. db 11000000b,00111111b,11111111b
  554. db 11000000b,00011111b,11111111b
  555. db 11000000b,00001111b,11111111b
  556. db 11000000b,00000111b,11111111b
  557. db 11000000b,01111111b,11111111b
  558. db 11000100b,00111111b,11111111b
  559. db 11001100b,00111111b,11111111b
  560. db 11111110b,00011111b,11111111b
  561. db 11111110b,00011111b,11111111b
  562. db 11111111b,00011111b,11111111b
  563. ; cursor mask
  564. db 00000000b,00000000b,00000000b
  565. db 00010000b,00000000b,00000000b
  566. db 00011000b,00000000b,00000000b
  567. db 00011100b,00000000b,00000000b
  568. db 00011110b,00000000b,00000000b
  569. db 00011111b,00000000b,00000000b
  570. db 00011111b,10000000b,00000000b
  571. db 00011111b,11000000b,00000000b
  572. db 00011111b,11100000b,00000000b
  573. db 00011111b,11110000b,00000000b
  574. db 00011011b,00000000b,00000000b
  575. db 00010001b,10000000b,00000000b
  576. db 00000001b,10000000b,00000000b
  577. db 00000000b,11000000b,00000000b
  578. db 00000000b,11000000b,00000000b
  579. db 00000000b,00000000b,00000000b
  580. ;****************** ALIGNED FOR PIXEL THREE *******************************
  581. ; screen mask
  582. AlignClip378:
  583. db 11100111b,11111111b,11111111b
  584. db 11100011b,11111111b,11111111b
  585. db 11100001b,11111111b,11111111b
  586. db 11100000b,11111111b,11111111b
  587. db 11100000b,01111111b,11111111b
  588. db 11100000b,00111111b,11111111b
  589. db 11100000b,00011111b,11111111b
  590. db 11100000b,00001111b,11111111b
  591. db 11100000b,00000111b,11111111b
  592. db 11100000b,00000011b,11111111b
  593. db 11100000b,00111111b,11111111b
  594. db 11100010b,00011111b,11111111b
  595. db 11100110b,00011111b,11111111b
  596. db 11111111b,00001111b,11111111b
  597. db 11111111b,00001111b,11111111b
  598. db 11111111b,10001111b,11111111b
  599. ; cursor mask
  600. db 00000000b,00000000b,00000000b
  601. db 00001000b,00000000b,00000000b
  602. db 00001100b,00000000b,00000000b
  603. db 00001110b,00000000b,00000000b
  604. db 00001111b,00000000b,00000000b
  605. db 00001111b,10000000b,00000000b
  606. db 00001111b,11000000b,00000000b
  607. db 00001111b,11100000b,00000000b
  608. db 00001111b,11110000b,00000000b
  609. db 00001111b,11111000b,00000000b
  610. db 00001101b,10000000b,00000000b
  611. db 00001000b,11000000b,00000000b
  612. db 00000000b,11000000b,00000000b
  613. db 00000000b,01100000b,00000000b
  614. db 00000000b,01100000b,00000000b
  615. db 00000000b,00000000b,00000000b
  616. ;****************** ALIGNED FOR PIXEL FOUR *******************************
  617. ; screen mask
  618. AlignClip478:
  619. db 11110011b,11111111b,11111111b
  620. db 11110001b,11111111b,11111111b
  621. db 11110000b,11111111b,11111111b
  622. db 11110000b,01111111b,11111111b
  623. db 11110000b,00111111b,11111111b
  624. db 11110000b,00011111b,11111111b
  625. db 11110000b,00001111b,11111111b
  626. db 11110000b,00000111b,11111111b
  627. db 11110000b,00000011b,11111111b
  628. db 11110000b,00000001b,11111111b
  629. db 11110000b,00011111b,11111111b
  630. db 11110001b,00001111b,11111111b
  631. db 11110011b,00001111b,11111111b
  632. db 11111111b,10000111b,11111111b
  633. db 11111111b,10000111b,11111111b
  634. db 11111111b,11000111b,11111111b
  635. ; cursor mask
  636. db 00000000b,00000000b,00000000b
  637. db 00000100b,00000000b,00000000b
  638. db 00000110b,00000000b,00000000b
  639. db 00000111b,00000000b,00000000b
  640. db 00000111b,10000000b,00000000b
  641. db 00000111b,11000000b,00000000b
  642. db 00000111b,11100000b,00000000b
  643. db 00000111b,11110000b,00000000b
  644. db 00000111b,11111000b,00000000b
  645. db 00000111b,11111100b,00000000b
  646. db 00000110b,11000000b,00000000b
  647. db 00000100b,01100000b,00000000b
  648. db 00000000b,01100000b,00000000b
  649. db 00000000b,00110000b,00000000b
  650. db 00000000b,00110000b,00000000b
  651. db 00000000b,00000000b,00000000b
  652. ;****************** ALIGNED FOR PIXEL FIVE *******************************
  653. ; screen mask
  654. AlignClip578:
  655. db 11111001b,11111111b,11111111b
  656. db 11111000b,11111111b,11111111b
  657. db 11111000b,01111111b,11111111b
  658. db 11111000b,00111111b,11111111b
  659. db 11111000b,00011111b,11111111b
  660. db 11111000b,00001111b,11111111b
  661. db 11111000b,00000111b,11111111b
  662. db 11111000b,00000011b,11111111b
  663. db 11111000b,00000001b,11111111b
  664. db 11111000b,00000000b,11111111b
  665. db 11111000b,00001111b,11111111b
  666. db 11111000b,10000111b,11111111b
  667. db 11111001b,10000111b,11111111b
  668. db 11111111b,11000011b,11111111b
  669. db 11111111b,11000011b,11111111b
  670. db 11111111b,11100011b,11111111b
  671. ; cursor mask
  672. db 00000000b,00000000b,00000000b
  673. db 00000010b,00000000b,00000000b
  674. db 00000011b,00000000b,00000000b
  675. db 00000011b,10000000b,00000000b
  676. db 00000011b,11000000b,00000000b
  677. db 00000011b,11100000b,00000000b
  678. db 00000011b,11110000b,00000000b
  679. db 00000011b,11111000b,00000000b
  680. db 00000011b,11111100b,00000000b
  681. db 00000011b,11111110b,00000000b
  682. db 00000011b,01100000b,00000000b
  683. db 00000010b,00110000b,00000000b
  684. db 00000000b,00110000b,00000000b
  685. db 00000000b,00011000b,00000000b
  686. db 00000000b,00011000b,00000000b
  687. db 00000000b,00000000b,00000000b
  688. ;****************** ALIGNED FOR PIXEL SIX *******************************
  689. ; screen mask
  690. AlignClip678:
  691. db 11111100b,11111111b,11111111b
  692. db 11111100b,01111111b,11111111b
  693. db 11111100b,00111111b,11111111b
  694. db 11111100b,00011111b,11111111b
  695. db 11111100b,00001111b,11111111b
  696. db 11111100b,00000111b,11111111b
  697. db 11111100b,00000011b,11111111b
  698. db 11111100b,00000001b,11111111b
  699. db 11111100b,00000000b,11111111b
  700. db 11111100b,00000000b,11111111b
  701. db 11111100b,00000111b,11111111b
  702. db 11111100b,01000011b,11111111b
  703. db 11111100b,11000011b,11111111b
  704. db 11111111b,11100001b,11111111b
  705. db 11111111b,11100001b,11111111b
  706. db 11111111b,11110001b,11111111b
  707. ; cursor mask
  708. db 00000000b,00000000b,00000000b
  709. db 00000001b,00000000b,00000000b
  710. db 00000001b,10000000b,00000000b
  711. db 00000001b,11000000b,00000000b
  712. db 00000001b,11100000b,00000000b
  713. db 00000001b,11110000b,00000000b
  714. db 00000001b,11111000b,00000000b
  715. db 00000001b,11111100b,00000000b
  716. db 00000001b,11111110b,00000000b
  717. db 00000001b,11111111b,00000000b
  718. db 00000001b,10110000b,00000000b
  719. db 00000001b,00011000b,00000000b
  720. db 00000000b,00011000b,00000000b
  721. db 00000000b,00001100b,00000000b
  722. db 00000000b,00001100b,00000000b
  723. db 00000000b,00000000b,00000000b
  724. ;****************** ALIGNED FOR PIXEL SEVEN *******************************
  725. ; screen mask
  726. AlignClip778:
  727. db 11111110b,01111111b,11111111b
  728. db 11111110b,00111111b,11111111b
  729. db 11111110b,00011111b,11111111b
  730. db 11111110b,00001111b,11111111b
  731. db 11111110b,00000111b,11111111b
  732. db 11111110b,00000011b,11111111b
  733. db 11111110b,00000001b,11111111b
  734. db 11111110b,00000000b,11111111b
  735. db 11111110b,00000000b,11111111b
  736. db 11111110b,00000000b,11111111b
  737. db 11111110b,00000011b,11111111b
  738. db 11111110b,00100001b,11111111b
  739. db 11111110b,01100001b,11111111b
  740. db 11111111b,11110000b,11111111b
  741. db 11111111b,11110000b,11111111b
  742. db 11111111b,11111000b,11111111b
  743. ; cursor mask
  744. db 00000000b,00000000b,00000000b
  745. db 00000000b,10000000b,00000000b
  746. db 00000000b,11000000b,00000000b
  747. db 00000000b,11100000b,00000000b
  748. db 00000000b,11110000b,00000000b
  749. db 00000000b,11111000b,00000000b
  750. db 00000000b,11111100b,00000000b
  751. db 00000000b,11111110b,00000000b
  752. db 00000000b,11111111b,00000000b
  753. db 00000000b,11111111b,00000000b
  754. db 00000000b,11011000b,00000000b
  755. db 00000000b,10001100b,00000000b
  756. db 00000000b,00001100b,00000000b
  757. db 00000000b,00000110b,00000000b
  758. db 00000000b,00000110b,00000000b
  759. db 00000000b,00000000b,00000000b
  760. clip_cursor79 db 00111111b,11111111b,11111111b
  761. db 00011111b,11111111b,11111111b
  762. db 00001111b,11111111b,11111111b
  763. db 00000111b,11111111b,11111111b
  764. db 00000011b,11111111b,11111111b
  765. db 00000001b,11111111b,11111111b
  766. db 00000000b,11111111b,11111111b
  767. db 00000000b,11111111b,11111111b
  768. db 00000000b,11111111b,11111111b
  769. db 00000000b,11111111b,11111111b
  770. db 00000001b,11111111b,11111111b
  771. db 00010000b,11111111b,11111111b
  772. db 00110000b,11111111b,11111111b
  773. db 11111000b,01111111b,11111111b
  774. db 11111000b,01111111b,11111111b
  775. db 11111100b,01111111b,11111111b
  776. ; cursor mask
  777. db 00000000b,00000000b,00000000b
  778. db 01000000b,00000000b,00000000b
  779. db 01100000b,00000000b,00000000b
  780. db 01110000b,00000000b,00000000b
  781. db 01111000b,00000000b,00000000b
  782. db 01111100b,00000000b,00000000b
  783. db 01111110b,00000000b,00000000b
  784. db 01111111b,00000000b,00000000b
  785. db 01111111b,00000000b,00000000b
  786. db 01111111b,00000000b,00000000b
  787. db 01101100b,00000000b,00000000b
  788. db 01000110b,00000000b,00000000b
  789. db 00000110b,00000000b,00000000b
  790. db 00000011b,00000000b,00000000b
  791. db 00000011b,00000000b,00000000b
  792. db 00000000b,00000000b,00000000b
  793. ;****************** ALIGNED FOR PIXEL ONE *******************************
  794. ; screen mask
  795. AlignClip179:
  796. db 10011111b,11111111b,11111111b
  797. db 10001111b,11111111b,11111111b
  798. db 10000111b,11111111b,11111111b
  799. db 10000011b,11111111b,11111111b
  800. db 10000001b,11111111b,11111111b
  801. db 10000000b,11111111b,11111111b
  802. db 10000000b,11111111b,11111111b
  803. db 10000000b,11111111b,11111111b
  804. db 10000000b,11111111b,11111111b
  805. db 10000000b,11111111b,11111111b
  806. db 10000000b,11111111b,11111111b
  807. db 10001000b,11111111b,11111111b
  808. db 10011000b,11111111b,11111111b
  809. db 11111100b,11111111b,11111111b
  810. db 11111100b,11111111b,11111111b
  811. db 11111110b,11111111b,11111111b
  812. ; cursor mask
  813. db 00000000b,00000000b,00000000b
  814. db 00100000b,00000000b,00000000b
  815. db 00110000b,00000000b,00000000b
  816. db 00111000b,00000000b,00000000b
  817. db 00111100b,00000000b,00000000b
  818. db 00111110b,00000000b,00000000b
  819. db 00111111b,00000000b,00000000b
  820. db 00111111b,00000000b,00000000b
  821. db 00111111b,00000000b,00000000b
  822. db 00111111b,00000000b,00000000b
  823. db 00110110b,00000000b,00000000b
  824. db 00100011b,00000000b,00000000b
  825. db 00000011b,00000000b,00000000b
  826. db 00000001b,00000000b,00000000b
  827. db 00000001b,00000000b,00000000b
  828. db 00000000b,00000000b,00000000b
  829. ;****************** ALIGNED FOR PIXEL TWO *******************************
  830. ; screen mask
  831. AlignClip279:
  832. db 11001111b,11111111b,11111111b
  833. db 11000111b,11111111b,11111111b
  834. db 11000011b,11111111b,11111111b
  835. db 11000001b,11111111b,11111111b
  836. db 11000000b,11111111b,11111111b
  837. db 11000000b,11111111b,11111111b
  838. db 11000000b,11111111b,11111111b
  839. db 11000000b,11111111b,11111111b
  840. db 11000000b,11111111b,11111111b
  841. db 11000000b,11111111b,11111111b
  842. db 11000000b,11111111b,11111111b
  843. db 11000100b,11111111b,11111111b
  844. db 11001100b,11111111b,11111111b
  845. db 11111110b,11111111b,11111111b
  846. db 11111110b,11111111b,11111111b
  847. db 11111111b,11111111b,11111111b
  848. ; cursor mask
  849. db 00000000b,00000000b,00000000b
  850. db 00010000b,00000000b,00000000b
  851. db 00011000b,00000000b,00000000b
  852. db 00011100b,00000000b,00000000b
  853. db 00011110b,00000000b,00000000b
  854. db 00011111b,00000000b,00000000b
  855. db 00011111b,00000000b,00000000b
  856. db 00011111b,00000000b,00000000b
  857. db 00011111b,00000000b,00000000b
  858. db 00011111b,00000000b,00000000b
  859. db 00011011b,00000000b,00000000b
  860. db 00010001b,00000000b,00000000b
  861. db 00000001b,00000000b,00000000b
  862. db 00000000b,00000000b,00000000b
  863. db 00000000b,00000000b,00000000b
  864. db 00000000b,00000000b,00000000b
  865. ;****************** ALIGNED FOR PIXEL THREE *******************************
  866. ; screen mask
  867. AlignClip379:
  868. db 11100111b,11111111b,11111111b
  869. db 11100011b,11111111b,11111111b
  870. db 11100001b,11111111b,11111111b
  871. db 11100000b,11111111b,11111111b
  872. db 11100000b,11111111b,11111111b
  873. db 11100000b,11111111b,11111111b
  874. db 11100000b,11111111b,11111111b
  875. db 11100000b,11111111b,11111111b
  876. db 11100000b,11111111b,11111111b
  877. db 11100000b,11111111b,11111111b
  878. db 11100000b,11111111b,11111111b
  879. db 11100010b,11111111b,11111111b
  880. db 11100110b,11111111b,11111111b
  881. db 11111111b,11111111b,11111111b
  882. db 11111111b,11111111b,11111111b
  883. db 11111111b,11111111b,11111111b
  884. ; cursor mask
  885. db 00000000b,00000000b,00000000b
  886. db 00001000b,00000000b,00000000b
  887. db 00001100b,00000000b,00000000b
  888. db 00001110b,00000000b,00000000b
  889. db 00001111b,00000000b,00000000b
  890. db 00001111b,00000000b,00000000b
  891. db 00001111b,00000000b,00000000b
  892. db 00001111b,00000000b,00000000b
  893. db 00001111b,00000000b,00000000b
  894. db 00001111b,00000000b,00000000b
  895. db 00001101b,00000000b,00000000b
  896. db 00001000b,00000000b,00000000b
  897. db 00000000b,00000000b,00000000b
  898. db 00000000b,00000000b,00000000b
  899. db 00000000b,00000000b,00000000b
  900. db 00000000b,00000000b,00000000b
  901. ;****************** ALIGNED FOR PIXEL FOUR *******************************
  902. ; screen mask
  903. AlignClip479:
  904. db 11110011b,11111111b,11111111b
  905. db 11110001b,11111111b,11111111b
  906. db 11110000b,11111111b,11111111b
  907. db 11110000b,11111111b,11111111b
  908. db 11110000b,11111111b,11111111b
  909. db 11110000b,11111111b,11111111b
  910. db 11110000b,11111111b,11111111b
  911. db 11110000b,11111111b,11111111b
  912. db 11110000b,11111111b,11111111b
  913. db 11110000b,11111111b,11111111b
  914. db 11110000b,11111111b,11111111b
  915. db 11110001b,11111111b,11111111b
  916. db 11110011b,11111111b,11111111b
  917. db 11111111b,11111111b,11111111b
  918. db 11111111b,11111111b,11111111b
  919. db 11111111b,11111111b,11111111b
  920. ; cursor mask
  921. db 00000000b,00000000b,00000000b
  922. db 00000100b,00000000b,00000000b
  923. db 00000110b,00000000b,00000000b
  924. db 00000111b,00000000b,00000000b
  925. db 00000111b,00000000b,00000000b
  926. db 00000111b,00000000b,00000000b
  927. db 00000111b,00000000b,00000000b
  928. db 00000111b,00000000b,00000000b
  929. db 00000111b,00000000b,00000000b
  930. db 00000111b,00000000b,00000000b
  931. db 00000110b,00000000b,00000000b
  932. db 00000100b,00000000b,00000000b
  933. db 00000000b,00000000b,00000000b
  934. db 00000000b,00000000b,00000000b
  935. db 00000000b,00000000b,00000000b
  936. db 00000000b,00000000b,00000000b
  937. ;****************** ALIGNED FOR PIXEL FIVE *******************************
  938. ; screen mask
  939. AlignClip579:
  940. db 11111001b,11111111b,11111111b
  941. db 11111000b,11111111b,11111111b
  942. db 11111000b,11111111b,11111111b
  943. db 11111000b,11111111b,11111111b
  944. db 11111000b,11111111b,11111111b
  945. db 11111000b,11111111b,11111111b
  946. db 11111000b,11111111b,11111111b
  947. db 11111000b,11111111b,11111111b
  948. db 11111000b,11111111b,11111111b
  949. db 11111000b,11111111b,11111111b
  950. db 11111000b,11111111b,11111111b
  951. db 11111000b,11111111b,11111111b
  952. db 11111001b,11111111b,11111111b
  953. db 11111111b,11111111b,11111111b
  954. db 11111111b,11111111b,11111111b
  955. db 11111111b,11111111b,11111111b
  956. ; cursor mask
  957. db 00000000b,00000000b,00000000b
  958. db 00000010b,00000000b,00000000b
  959. db 00000011b,00000000b,00000000b
  960. db 00000011b,00000000b,00000000b
  961. db 00000011b,00000000b,00000000b
  962. db 00000011b,00000000b,00000000b
  963. db 00000011b,00000000b,00000000b
  964. db 00000011b,00000000b,00000000b
  965. db 00000011b,00000000b,00000000b
  966. db 00000011b,00000000b,00000000b
  967. db 00000011b,00000000b,00000000b
  968. db 00000010b,00000000b,00000000b
  969. db 00000000b,00000000b,00000000b
  970. db 00000000b,00000000b,00000000b
  971. db 00000000b,00000000b,00000000b
  972. db 00000000b,00000000b,00000000b
  973. ;****************** ALIGNED FOR PIXEL SIX *******************************
  974. ; screen mask
  975. AlignClip679:
  976. db 11111100b,11111111b,11111111b
  977. db 11111100b,11111111b,11111111b
  978. db 11111100b,11111111b,11111111b
  979. db 11111100b,11111111b,11111111b
  980. db 11111100b,11111111b,11111111b
  981. db 11111100b,11111111b,11111111b
  982. db 11111100b,11111111b,11111111b
  983. db 11111100b,11111111b,11111111b
  984. db 11111100b,11111111b,11111111b
  985. db 11111100b,11111111b,11111111b
  986. db 11111100b,11111111b,11111111b
  987. db 11111100b,11111111b,11111111b
  988. db 11111100b,11111111b,11111111b
  989. db 11111111b,11111111b,11111111b
  990. db 11111111b,11111111b,11111111b
  991. db 11111111b,11111111b,11111111b
  992. ; cursor mask
  993. db 00000000b,00000000b,00000000b
  994. db 00000001b,00000000b,00000000b
  995. db 00000001b,00000000b,00000000b
  996. db 00000001b,00000000b,00000000b
  997. db 00000001b,00000000b,00000000b
  998. db 00000001b,00000000b,00000000b
  999. db 00000001b,00000000b,00000000b
  1000. db 00000001b,00000000b,00000000b
  1001. db 00000001b,00000000b,00000000b
  1002. db 00000001b,00000000b,00000000b
  1003. db 00000001b,00000000b,00000000b
  1004. db 00000001b,00000000b,00000000b
  1005. db 00000000b,00000000b,00000000b
  1006. db 00000000b,00000000b,00000000b
  1007. db 00000000b,00000000b,00000000b
  1008. db 00000000b,00000000b,00000000b
  1009. ;****************** ALIGNED FOR PIXEL SEVEN *******************************
  1010. ; screen mask
  1011. AlignClip779:
  1012. db 11111110b,11111111b,11111111b
  1013. db 11111110b,11111111b,11111111b
  1014. db 11111110b,11111111b,11111111b
  1015. db 11111110b,11111111b,11111111b
  1016. db 11111110b,11111111b,11111111b
  1017. db 11111110b,11111111b,11111111b
  1018. db 11111110b,11111111b,11111111b
  1019. db 11111110b,11111111b,11111111b
  1020. db 11111110b,11111111b,11111111b
  1021. db 11111110b,11111111b,11111111b
  1022. db 11111110b,11111111b,11111111b
  1023. db 11111110b,11111111b,11111111b
  1024. db 11111110b,11111111b,11111111b
  1025. db 11111111b,11111111b,11111111b
  1026. db 11111111b,11111111b,11111111b
  1027. db 11111111b,11111111b,11111111b
  1028. ; cursor mask
  1029. db 00000000b,00000000b,00000000b
  1030. db 00000000b,00000000b,00000000b
  1031. db 00000000b,00000000b,00000000b
  1032. db 00000000b,00000000b,00000000b
  1033. db 00000000b,00000000b,00000000b
  1034. db 00000000b,00000000b,00000000b
  1035. db 00000000b,00000000b,00000000b
  1036. db 00000000b,00000000b,00000000b
  1037. db 00000000b,00000000b,00000000b
  1038. db 00000000b,00000000b,00000000b
  1039. db 00000000b,00000000b,00000000b
  1040. db 00000000b,00000000b,00000000b
  1041. db 00000000b,00000000b,00000000b
  1042. db 00000000b,00000000b,00000000b
  1043. db 00000000b,00000000b,00000000b
  1044. db 00000000b,00000000b,00000000b
  1045. CursorOffsetLUT dw current_cursor
  1046. dw AlignData1
  1047. dw AlignData2
  1048. dw AlignData3
  1049. dw AlignData4
  1050. dw AlignData5
  1051. dw AlignData6
  1052. dw AlignData7
  1053. ClipOffsetLUT78 dw clip_cursor78
  1054. dw AlignClip178
  1055. dw AlignClip278
  1056. dw AlignClip378
  1057. dw AlignClip478
  1058. dw AlignClip578
  1059. dw AlignClip678
  1060. dw AlignClip778
  1061. ClipOffsetLUT79 dw clip_cursor79
  1062. dw AlignClip179
  1063. dw AlignClip279
  1064. dw AlignClip379
  1065. dw AlignClip479
  1066. dw AlignClip579
  1067. dw AlignClip679
  1068. dw AlignClip779
  1069. ; pointer to the current look up table set for the pointer image.
  1070. ; The LUTs are swapped when the pointer enters bytes 78 and 79
  1071. ; along a scanline to prevent the pointer wrapping around the screen.
  1072. PointerLUT label word
  1073. dw offset CursorOffsetLUT
  1074. ;;;;;;;;;;;;;;;;;;;;;;;
  1075. ;;;; End of what should be an include for pointer.inc
  1076. ;;;;;;;;;;;;;;;;;;;;;;;
  1077. even
  1078. clrgend dw 06e41h,07964h,05720h,07461h,06f73h,0f36eh
  1079. hiresylut dw 350,350,480,480
  1080. ;============================================================================
  1081. ; Surprisingly, a look up table multiply is much faster than
  1082. ; the shift - add instruction sequence for multiplying by 80.
  1083. ; So it would be crazy not to use it eh? Times by 80 is needed
  1084. ; to convert a raster location (1 raster = 80 bytes) in pixel
  1085. ; y coordinates into a video buffer byte index
  1086. ; Note: Multiply by 80 is also used for text mode calculations
  1087. ; now! Andy on the 9/3/93
  1088. ;============================================================================
  1089. even
  1090. mult80lut label word
  1091. mulsum=0
  1092. REPT 480 ; number of VGA scanlines for mode 12h
  1093. dw mulsum
  1094. mulsum=mulsum+80
  1095. ENDM
  1096. ;============================================================================
  1097. ; A table to do a multiply by 320. This is used for converting number of
  1098. ; rasters into video buffer offsets for mode 13h (256 VGA colour mode).
  1099. ;============================================================================
  1100. even
  1101. mult320lut label word
  1102. mulsum=0
  1103. REPT 200 ; number of VGA scanlines for mode 13h
  1104. dw mulsum
  1105. mulsum=mulsum+320
  1106. ENDM
  1107. even
  1108. ;============================================================================
  1109. ; Look up table for use with modes 10h and 12h. This table provides the means
  1110. ; for the selection of a clipped or unclipped pointer image depending on the
  1111. ; current x position of the pointer.
  1112. ;============================================================================
  1113. ChooseImageLUT label word
  1114. REPT 624
  1115. dw offset CursorOffsetLUT
  1116. ENDM
  1117. REPT 8
  1118. dw offset ClipOffsetLUT78
  1119. ENDM
  1120. REPT 8
  1121. dw offset ClipOffsetLUT79
  1122. ENDM
  1123. ;============================================================================
  1124. ; Buffer arranged for 4 plane EGA video modes. The screen where
  1125. ; the pointer is going to be drawn is scanned plane by plane and
  1126. ; saved as bitplane separations.
  1127. ;============================================================================
  1128. even ; make sure that this data is word aligned
  1129. behindcursor dw 24 dup(?) ; Plane 0
  1130. dw 24 dup(?) ; Plane 1
  1131. dw 24 dup(?) ; Plane 2
  1132. dw 24 dup(?) ; Plane 3
  1133. ;============================================================================
  1134. ; a table of the video buffer segment for the supported
  1135. ; BIOS text and graphics modes.
  1136. ;============================================================================
  1137. even ; make sure that this data is word aligned
  1138. videomodetable dw 0b800h,0b800h ; modes 0,1
  1139. dw 0b800h,0b800h ; modes 2,3
  1140. dw 0b800h,0b800h ; modes 4,5
  1141. dw 0b800h,0b000h ; modes 6,7
  1142. dw 0ffffh,0ffffh ; n/a
  1143. dw 0ffffh,0ffffh ; n/a
  1144. dw 0ffffh,0a000h ; n/a,mode 0dh
  1145. dw 0a000h,0a000h ; modes 0eh,0fh
  1146. dw 0a000h,0a000h ; modes 10h,11h
  1147. dw 0a000h,0a000h ; modes 12h,13h
  1148. videobufferseg dw ?
  1149. even ; make sure that this data is word aligned
  1150. hotspot dw 2 dup(0)
  1151. VRAMlasttextcelloff label word ; last text offset in VRAM
  1152. VRAMlastbyteoff dw ? ; Last offset in VRAM
  1153. VRAMlastbitoff dw ? ; LSB: Where pointer is in byte
  1154. ; MSB: ODD/EVEN of the pointer
  1155. ; first scan line
  1156. LastXCounters dw ? ; last X looping counter
  1157. LastYCounters dw ? ; last Y looping counter
  1158. ; ODD in LSB and EVEN in MSB
  1159. lasttextimage dw ? ; text cell from last time
  1160. background dw NOTSTORED ; STORED if data in buffer
  1161. current_position_x dw ?
  1162. current_position_y dw ?
  1163. vidbytealigned dw ?
  1164. lastmaskrotate dw ?
  1165. lastvidmode db 0ffh ; the video mode during the last int.
  1166. internalCF db 0ffh ; the mouse driver keeps a flag called
  1167. ; the internal cursor flag. If the flag
  1168. ; = 0, then int 33h f1 will display the
  1169. ; pointer, -1 = default value.
  1170. ; 32 bit code writes to this area on a hardware interrupt and
  1171. ; when an app does an int 33h function 3, it reads the data
  1172. ; directly from here.
  1173. ; Data format is: word 0 -> button status
  1174. ; word 1 -> x virtual coordinate
  1175. ; word 2 -> y virtual coordinate
  1176. function3data dw 3 dup(?)
  1177. conditional_off db 0 ;!= 0 if conditional off is on
  1178. ;
  1179. ;=============================================================================
  1180. ; Data to determine the address of where the latches should be saved in the
  1181. ; video buffer for the current video mode.
  1182. ; latchcache contains the value looked up by saveVGAregisters and used by
  1183. ; restoreVGAregisters.
  1184. ;=============================================================================
  1185. latchcache dw ? ; location of latch cache in VRAM
  1186. even
  1187. latchhomeLUT label word
  1188. dw ? ; mode 0
  1189. dw ? ; mode 1
  1190. dw ? ; mode 2
  1191. dw ? ; mode 3
  1192. dw ? ; mode 4
  1193. dw ? ; mode 5
  1194. dw ? ; mode 6
  1195. dw ? ; mode 7
  1196. dw ? ; mode 8
  1197. dw ? ; mode 9
  1198. dw ? ; mode a
  1199. dw ? ; mode b
  1200. dw ? ; mode c
  1201. dw ? ; mode d
  1202. dw 80*200+78 ; mode e
  1203. dw 80*350+78 ; mode f
  1204. dw 80*350+78 ; mode 10
  1205. dw 80*480+78 ; mode 11
  1206. dw 80*480+78 ; mode 12
  1207. ifdef DBCS
  1208. dw 80*480+78 ; DBCS_TEXT_MODE
  1209. endif ; DBCS
  1210. ;=============================================================================
  1211. ; CGA video mode 4 is a 2 bit per pixel graphics mode. The pointer images
  1212. ; received from the application (or the default images for that matter) are
  1213. ; described by a one bit per pixel map. This look up table provides the means
  1214. ; of conversion from one to two bits per pixel.
  1215. ;=============================================================================
  1216. even
  1217. LUT1to2bit label word
  1218. dw 00000h,00003h,0000Ch,0000Fh,00030h,00033h,0003Ch,0003Fh
  1219. dw 000C0h,000C3h,000CCh,000CFh,000F0h,000F3h,000FCh,000FFh
  1220. dw 00300h,00303h,0030Ch,0030Fh,00330h,00333h,0033Ch,0033Fh
  1221. dw 003C0h,003C3h,003CCh,003CFh,003F0h,003F3h,003FCh,003FFh
  1222. dw 00C00h,00C03h,00C0Ch,00C0Fh,00C30h,00C33h,00C3Ch,00C3Fh
  1223. dw 00CC0h,00CC3h,00CCCh,00CCFh,00CF0h,00CF3h,00CFCh,00CFFh
  1224. dw 00F00h,00F03h,00F0Ch,00F0Fh,00F30h,00F33h,00F3Ch,00F3Fh
  1225. dw 00FC0h,00FC3h,00FCCh,00FCFh,00FF0h,00FF3h,00FFCh,00FFFh
  1226. dw 03000h,03003h,0300Ch,0300Fh,03030h,03033h,0303Ch,0303Fh
  1227. dw 030C0h,030C3h,030CCh,030CFh,030F0h,030F3h,030FCh,030FFh
  1228. dw 03300h,03303h,0330Ch,0330Fh,03330h,03333h,0333Ch,0333Fh
  1229. dw 033C0h,033C3h,033CCh,033CFh,033F0h,033F3h,033FCh,033FFh
  1230. dw 03C00h,03C03h,03C0Ch,03C0Fh,03C30h,03C33h,03C3Ch,03C3Fh
  1231. dw 03CC0h,03CC3h,03CCCh,03CCFh,03CF0h,03CF3h,03CFCh,03CFFh
  1232. dw 03F00h,03F03h,03F0Ch,03F0Fh,03F30h,03F33h,03F3Ch,03F3Fh
  1233. dw 03FC0h,03FC3h,03FCCh,03FCFh,03FF0h,03FF3h,03FFCh,03FFFh
  1234. dw 0C000h,0C003h,0C00Ch,0C00Fh,0C030h,0C033h,0C03Ch,0C03Fh
  1235. dw 0C0C0h,0C0C3h,0C0CCh,0C0CFh,0C0F0h,0C0F3h,0C0FCh,0C0FFh
  1236. dw 0C300h,0C303h,0C30Ch,0C30Fh,0C330h,0C333h,0C33Ch,0C33Fh
  1237. dw 0C3C0h,0C3C3h,0C3CCh,0C3CFh,0C3F0h,0C3F3h,0C3FCh,0C3FFh
  1238. dw 0CC00h,0CC03h,0CC0Ch,0CC0Fh,0CC30h,0CC33h,0CC3Ch,0CC3Fh
  1239. dw 0CCC0h,0CCC3h,0CCCCh,0CCCFh,0CCF0h,0CCF3h,0CCFCh,0CCFFh
  1240. dw 0CF00h,0CF03h,0CF0Ch,0CF0Fh,0CF30h,0CF33h,0CF3Ch,0CF3Fh
  1241. dw 0CFC0h,0CFC3h,0CFCCh,0CFCFh,0CFF0h,0CFF3h,0CFFCh,0CFFFh
  1242. dw 0F000h,0F003h,0F00Ch,0F00Fh,0F030h,0F033h,0F03Ch,0F03Fh
  1243. dw 0F0C0h,0F0C3h,0F0CCh,0F0CFh,0F0F0h,0F0F3h,0F0FCh,0F0FFh
  1244. dw 0F300h,0F303h,0F30Ch,0F30Fh,0F330h,0F333h,0F33Ch,0F33Fh
  1245. dw 0F3C0h,0F3C3h,0F3CCh,0F3CFh,0F3F0h,0F3F3h,0F3FCh,0F3FFh
  1246. dw 0FC00h,0FC03h,0FC0Ch,0FC0Fh,0FC30h,0FC33h,0FC3Ch,0FC3Fh
  1247. dw 0FCC0h,0FCC3h,0FCCCh,0FCCFh,0FCF0h,0FCF3h,0FCFCh,0FCFFh
  1248. dw 0FF00h,0FF03h,0FF0Ch,0FF0Fh,0FF30h,0FF33h,0FF3Ch,0FF3Fh
  1249. dw 0FFC0h,0FFC3h,0FFCCh,0FFCFh,0FFF0h,0FFF3h,0FFFCh,0FFFFh
  1250. ;============================================================================
  1251. ; Table for selection of the correct pointer image for the current location
  1252. ; in the video buffer, when using video BIOS mode 4.
  1253. ;============================================================================
  1254. mode4pointerLUT label word
  1255. REPT 76 ; for the first 76 bytes of scanline, use these
  1256. dw current_cursor
  1257. dw AlignData1
  1258. dw AlignData2
  1259. dw AlignData3
  1260. ENDM
  1261. dw clip_cursor78
  1262. dw AlignClip178
  1263. dw AlignClip278
  1264. dw AlignClip378
  1265. dw AlignClip478
  1266. dw AlignClip578
  1267. dw AlignClip678
  1268. dw AlignClip778
  1269. dw clip_cursor79
  1270. dw AlignClip179
  1271. dw AlignClip279
  1272. dw AlignClip379
  1273. dw AlignClip479
  1274. dw AlignClip579
  1275. dw AlignClip679
  1276. dw AlignClip779
  1277. ;============================================================================
  1278. ; Look up table to adjust CX on clipping in mode 4. This allows the mode4
  1279. ; pointer drawing algorithm to use the modes 10h/12h clipped pointer data
  1280. ; without having to modify it. The problem is that mode 10/12 expects the
  1281. ; data to be 4 bits per pixel and aligned to a word, whereas mode 4 is 2 bits
  1282. ; per pixel and aligns to a byte.
  1283. ;============================================================================
  1284. mode4clipCXadjustLUT label word
  1285. adjtemp=0 ; data for pixel x-coordinates 0 -> 307
  1286. REPT 77
  1287. dw 4 dup(adjtemp)
  1288. adjtemp=adjtemp+1
  1289. ENDM
  1290. dw 4 dup(76) ; data for pixels 308 -> 311
  1291. dw 8 dup(78) ; data for pixels 312 -> 319
  1292. ;============================================================================
  1293. ; The CGA buffer is split at 2000h. Therefore if the pointer starts writing
  1294. ; below scanline 199 on the video display, the odd scanline video buffer
  1295. ; will become corrupted. In these cases, the pointer should be clipped to
  1296. ; display scanline 199. The look up table below maps loop counters to a
  1297. ; display scanline for this purpose.
  1298. ;
  1299. ; table arrangement (odd scanline data, even scanline data)
  1300. ;
  1301. ;============================================================================
  1302. mode4clipDXLUT label word
  1303. db 200-15 dup(8,8) ; scanlines 0 -> 184
  1304. db 8,7 ; scanline 185
  1305. db 7,7 ; scanline 186
  1306. db 7,6 ; scanline 187
  1307. db 6,6 ; scanline 188
  1308. db 6,5 ; scanline 189
  1309. db 5,5 ; scanline 190
  1310. db 5,4 ; scanline 191
  1311. db 4,4 ; scanline 192
  1312. db 4,3 ; scanline 193
  1313. db 3,3 ; scanline 194
  1314. db 3,2 ; scanline 195
  1315. db 2,2 ; scanline 196
  1316. db 2,1 ; scanline 197
  1317. db 1,1 ; scanline 198
  1318. db 1,0 ; scanline 199
  1319. mode4SelectedPointer label word
  1320. dw ?
  1321. ;==========================================================================
  1322. ; Some space into which the Medium resolution graphics pointer background
  1323. ; gets stored. Note that the 256 colour mode buffer encroaches on that of
  1324. ; mode 4.
  1325. ;==========================================================================
  1326. bkgrnd256 label byte ; 256 colour buffer = 24*16 @ 1 byte/pix
  1327. db 384-64 dup(?) ; share the CGA buffer(=64 bytes)
  1328. CGAbackgrnd label byte
  1329. db 24/4*16 dup(?) ; 24 pixels/row @ 4 pixels/byte for 16
  1330. ; rows.
  1331. ifdef DBCS
  1332. dbcs_vector label DWORD
  1333. dbcs_vector_off dw 0
  1334. dbcs_vector_seg dw 0
  1335. even
  1336. saved_ac_on_mouse_cursor dw ?
  1337. line_buffer db ((80 + 1) * 2) dup (?)
  1338. mouse_cursor_offset dw ?
  1339. saved_ac_cursor_position dw ?
  1340. saved_ac_count dw ?
  1341. saved_ac_offset dw ?
  1342. active_page db ?
  1343. video_io_enter_count db 0
  1344. SCREENtoCHARCELL macro
  1345. shr cx, 3
  1346. shr dx, 3
  1347. mov dh, dl
  1348. mov dl, cl
  1349. endm
  1350. endif ; DBCS
  1351. ;===========================================================================
  1352. ; Jump table to redirect the code flow according to the current video mode.
  1353. ; Used in the 32 bit entry point procedure.
  1354. ; Pointer drawing routines.
  1355. ;===========================================================================
  1356. even
  1357. drawpointerJMPT label word
  1358. dw offset not_supported ; mode 0
  1359. dw offset not_supported ; mode 1
  1360. IFDEF SIXTEENBIT
  1361. dw offset drawTextPointer ; mode 2
  1362. dw offset drawTextPointer ; mode 3
  1363. ELSE
  1364. dw offset not_supported ; mode 2
  1365. dw offset not_supported ; mode 3
  1366. ENDIF
  1367. dw offset drawMediumResPointer ; mode 4
  1368. dw offset drawMediumResPointer ; mode 5
  1369. dw offset not_supported ; mode 6
  1370. IFDEF SIXTEENBIT
  1371. dw offset drawTextPointer ; mode 7
  1372. ELSE
  1373. dw offset not_supported ; mode 7
  1374. ENDIF
  1375. dw offset not_supported ; mode 8
  1376. dw offset not_supported ; mode 9
  1377. dw offset not_supported ; mode a
  1378. dw offset not_supported ; mode b
  1379. dw offset not_supported ; mode c
  1380. dw offset not_supported ; mode d
  1381. dw offset not_supported ; mode e
  1382. dw offset drawHiResPointer ; mode f
  1383. dw offset drawHiResPointer ; mode 10
  1384. dw offset drawHiResPointer ; mode 11
  1385. dw offset drawHiResPointer ; mode 12
  1386. dw offset drawC256pointer ; mode 13
  1387. ifdef DBCS
  1388. dw offset DBCS_drawTextPointer ;DBCS_TEXT_MODE_NUMBER
  1389. endif ; DBCS
  1390. ;===========================================================================
  1391. ; Jump table to redirect the code flow according to the current video mode.
  1392. ; Used in the 32 bit entry point procedure.
  1393. ; INT 33h Function 1 support modules.
  1394. ;===========================================================================
  1395. even
  1396. int33function1JMPT label word
  1397. dw offset not_supported ; mode 0
  1398. dw offset not_supported ; mode 1
  1399. IFDEF SIXTEENBIT
  1400. dw offset TextInt33Function1 ; mode 2
  1401. dw offset TextInt33Function1 ; mode 3
  1402. ELSE
  1403. dw offset not_supported ; mode 2
  1404. dw offset not_supported ; mode 3
  1405. ENDIF
  1406. dw offset MediumResInt33Function1 ; mode 4
  1407. dw offset MediumResInt33Function1 ; mode 5
  1408. dw offset not_supported ; mode 6
  1409. IFDEF SIXTEENBIT
  1410. dw offset TextInt33Function1 ; mode 7
  1411. ELSE
  1412. dw offset not_supported ; mode 7
  1413. ENDIF
  1414. dw offset not_supported ; mode 8
  1415. dw offset not_supported ; mode 9
  1416. dw offset not_supported ; mode a
  1417. dw offset not_supported ; mode b
  1418. dw offset not_supported ; mode c
  1419. dw offset not_supported ; mode d
  1420. dw offset not_supported ; mode e
  1421. dw offset HiResInt33Function1 ; mode f
  1422. dw offset HiResInt33Function1 ; mode 10
  1423. dw offset HiResInt33Function1 ; mode 11
  1424. dw offset HiResInt33Function1 ; mode 12
  1425. dw offset C256Int33Function1 ; mode 13
  1426. ifdef DBCS
  1427. dw offset DBCS_TextInt33Function1 ; DBCS_TEXT_MODE_NUMBER
  1428. endif ; DBCS
  1429. ;===========================================================================
  1430. ; Jump table to redirect the code flow according to the current video mode.
  1431. ; Used in the 32 bit entry point procedure.
  1432. ; INT 33h Function 2 support modules.
  1433. ;===========================================================================
  1434. even
  1435. int33function2JMPT label word
  1436. dw offset not_supported ; mode 0
  1437. dw offset not_supported ; mode 1
  1438. IFDEF SIXTEENBIT
  1439. dw offset TextInt33Function2 ; mode 2
  1440. dw offset TextInt33Function2 ; mode 3
  1441. ELSE
  1442. dw offset not_supported ; mode 2
  1443. dw offset not_supported ; mode 3
  1444. ENDIF
  1445. dw offset MediumResInt33Function2 ; mode 4
  1446. dw offset MediumResInt33Function2 ; mode 5
  1447. dw offset not_supported ; mode 6
  1448. IFDEF SIXTEENBIT
  1449. dw offset TextInt33Function2 ; mode 7
  1450. ELSE
  1451. dw offset not_supported ; mode 7
  1452. ENDIF
  1453. dw offset not_supported ; mode 8
  1454. dw offset not_supported ; mode 9
  1455. dw offset not_supported ; mode a
  1456. dw offset not_supported ; mode b
  1457. dw offset not_supported ; mode c
  1458. dw offset not_supported ; mode d
  1459. dw offset not_supported ; mode e
  1460. dw offset HiResInt33Function2 ; mode f
  1461. dw offset HiResInt33Function2 ; mode 10
  1462. dw offset HiResInt33Function2 ; mode 11
  1463. dw offset HiResInt33Function2 ; mode 12
  1464. dw offset C256Int33Function2 ; mode 13
  1465. ifdef DBCS
  1466. dw offset DBCS_TextInt33Function2 ; DBCS_TEXT_MODE_NUMBER
  1467. endif ; DBCS
  1468. ;==========================================================================
  1469. ; Some storage space for the critical VGA registers.
  1470. ;==========================================================================
  1471. ;Sequencer Registers
  1472. seqregs label byte
  1473. db 4 dup(?) ; N.B. sequencer reset reg doesn't
  1474. ; get saved.
  1475. ; Graphics Controller Registers
  1476. GCregs label byte
  1477. db 9 dup(?)
  1478. ;==========================================================================
  1479. ; The mouse driver's very own stack. To prevent unnecessary tears,
  1480. ; particulary from the application running in DOS land, a stack is
  1481. ; maintained by the driver. This prevents the driver routines from
  1482. ; blowing a very full stack elsewhere.
  1483. ; N.B. on leaving the driver, the stack should be empty!
  1484. ;==========================================================================
  1485. even
  1486. mouse_stack dw STACKSIZE dup(?)
  1487. top_of_stack label word
  1488. dw ? ; this is where the stack starts
  1489. ;===========================================================================
  1490. ; The memory variable below is incremented on entry to the 16 bit code
  1491. ; and on exit, decremented. If an interrupt occurs during the execution of
  1492. ; this 16 bit code, the flag is incremented again, and thus greater than zero
  1493. ; so it is known that the code has been reentered and the stack must be
  1494. ; maintained accordingly.
  1495. ;===========================================================================
  1496. reentrant dw -1
  1497. ;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1498. ;
  1499. ; END OF DATA
  1500. ;
  1501. ;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1502. ;================================================================
  1503. ; code to redirect the flow of control from the segment:offset for
  1504. ; the mouse interrupt (33h) as indicated in the IVT (the IVT entry
  1505. ; has been set to point to here) to the Insignia mouse driver code.
  1506. ;================================================================
  1507. ifdef DBCS
  1508. ;; DBCS works needs this message just before the int33 vector to work
  1509. screte_msg label byte
  1510. db "*** This is Copyright 1983 Microsoft ***"
  1511. endif ; DBCS
  1512. int33h_vector:
  1513. jmp short skip
  1514. ; High level language entry point.
  1515. lvector db 0EAh ; far jump opcode
  1516. loffset dw ? ; destination offset
  1517. lseg dw ? ; destination segment
  1518. skip:
  1519. db 0EAh ; far jump opcode
  1520. moff dw ? ; will be filled in by the driver code from the IVT
  1521. mseg dw ? ; as before
  1522. DOCLI:
  1523. FCLI
  1524. ret
  1525. DOSTI:
  1526. FSTI
  1527. ret
  1528. DOIRET:
  1529. FIRET
  1530. ;================================================================
  1531. ; Functions moved out of ROM - real ROMS mapped in
  1532. ;================================================================
  1533. unexp_int:
  1534. bop UNEXP_BOP
  1535. jmp DOIRET
  1536. mouse_io:
  1537. ;
  1538. ; INT 33h entry point
  1539. ;
  1540. jmp mio_hack
  1541. nop
  1542. mouse_io_lang: ; entry point for HLL
  1543. pushf ; check ASAP if redundant show/hide cursor
  1544. push di ; save di,
  1545. mov di, [di+14] ; get first parameter (mouse function),
  1546. ; then duplicate mio_hack below.
  1547. ; this has to be done to preserve
  1548. ; compatibility between both ways to
  1549. ; call the mouse.
  1550. jz lbop ; F0
  1551. cmp di,2
  1552. jg lbop ; >F2
  1553. je miol_2
  1554. miol_1:
  1555. mov conditional_off, 0 ; disable conditonal off
  1556. cmp [internalCF],0 ; is the flag already zero?
  1557. je miol_12_quit ; if so, do nothing
  1558. inc [internalCF] ; increment it
  1559. jz lbop
  1560. miol_12_quit:
  1561. pop di
  1562. popf
  1563. jmp DOIRET
  1564. miol_2:
  1565. dec [internalCF] ; decrement the pointer internal flag
  1566. cmp [internalCF], 0ffh; currently displayed?
  1567. jne miol_12_quit
  1568. lbop:
  1569. pop ax
  1570. popf
  1571. bop IO_LANG_BOP
  1572. retf 8
  1573. mio_hack: ; int 33h handler
  1574. pushf ; save up the flags
  1575. cmp ax,1 ; mouse show cursor.
  1576. je mio_1
  1577. cmp ax,2 ; mouse hide cursor.
  1578. je mio_2
  1579. cmp ax,3 ; get button status and mouse position.
  1580. je mio_3
  1581. cmp ax,9 ; set graphics cursor
  1582. je mio_9
  1583. cmp ax,10 ; set text cursor - not supported
  1584. je mio_quit ; return straight back to app.
  1585. jmp short hack1bop ; none of the above, so goto 32 bit land
  1586. mio_1:
  1587. mov conditional_off, 0 ; disable conditional off
  1588. cmp [internalCF],0 ; is the flag already zero?
  1589. je mio_quit ; if so, do nothing
  1590. inc [internalCF] ; increment it
  1591. jz hack1bop ; just turned zero, so turn pointer on
  1592. ; via the 32 bit code.
  1593. mio_quit:
  1594. popf
  1595. jmp DOIRET
  1596. mio_2:
  1597. dec [internalCF] ; decrement the pointer internal flag
  1598. cmp [internalCF], 0ffh; currently displayed?
  1599. jne mio_quit ; Already turned off, so quit
  1600. hack1bop:
  1601. popf
  1602. bop IO_INTR_BOP ; BOP to the 32 bit part of the handler
  1603. jmp DOIRET ; return back after the BOP to caller
  1604. mio_9:
  1605. call int33function9 ; change the shape of the graphics pointer
  1606. popf ; restore the flag state
  1607. jmp DOIRET ; back to the caller
  1608. mio_3:
  1609. mov bx,[function3data] ; return button status
  1610. mov cx,[function3data+2] ; return x coordinate
  1611. mov dx,[function3data+4] ; return x coordinate
  1612. popf ; return back to the application
  1613. jmp DOIRET ; via an iret.
  1614. IFDEF MOUSE_VIDEO_BIOS
  1615. mouse_video_io:
  1616. pushf
  1617. or ah,ah
  1618. jne mvio1
  1619. jmp do_bop
  1620. mvio1:
  1621. cmp ax,6f05h
  1622. jne mvio2
  1623. jmp do_bop
  1624. mvio2:
  1625. cmp ah,4
  1626. jne mvio3
  1627. jmp do_bop
  1628. mvio3:
  1629. ;=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
  1630. ; Microsoft EGA.LIB function support
  1631. ; input: AH = the function required
  1632. cmp ah,0f0h ; is function F0 or greater?
  1633. jge mvio4 ; YES, so check to see if less than or == F7
  1634. jmp go_rom ; NO, so do rom stuff
  1635. mvio4:
  1636. cmp ah,0f7h ; is it greater than F7
  1637. jg mvio5 ; YES, so test for == FA
  1638. jmp ega_lib ; NO, but in range F0 to F7, so do EGALIB emm
  1639. mvio5:
  1640. cmp ah,0fah
  1641. jne mvio6
  1642. jmp egaFA
  1643. mvio6:
  1644. jmp go_rom
  1645. ; to get here, must want to do mouse video functions 0f0h to 0f7h or
  1646. ; function 0fah.
  1647. jmp ega_lib
  1648. ; data area for EGA.LIB function support
  1649. ; Notice that the sequencer register buffer only has space
  1650. ; for four entrys even though it actually has five addressable
  1651. ; registers. The Sequencer RESET status is not stored, so the buffer
  1652. ; is arranged thus:
  1653. ; buffer offset 0 1 2 3
  1654. ; register index 1 2 3 4
  1655. ;
  1656. even
  1657. ega_current_crtc db 25 dup(?) ; driver's copy of CRTC regs
  1658. ega_current_seq db 4 dup(?) ; driver's copy of Seq regs
  1659. ega_current_graph db 9 dup(?) ; driver's copy of GC regs
  1660. ega_current_attr db 20 dup(?) ; driver's copy of AC regs
  1661. ega_current_misc db ? ; driver's copy of misc reg
  1662. dirty_crtc db 25 dup(?)
  1663. dirty_seq db 4 dup(?)
  1664. dirty_graph db 9 dup(?)
  1665. dirty_attr db 20 dup(?)
  1666. ega_default_crtc db 25 dup(?) ; default EGA register values
  1667. ega_default_seq db 4 dup(?) ; as set by the application
  1668. ega_default_graph db 9 dup(?) ; through a call to F7
  1669. ega_default_attr db 20 dup(?)
  1670. ega_default_misc db ?
  1671. relnum label word
  1672. release_major db MAJOR_RELEASE_NUMBER
  1673. release_minor db MINOR_RELEASE_NUMBER
  1674. even
  1675. egalibjmp label word ; crafty jump table to replace a base
  1676. ; switch
  1677. dw egaF0 ; 0F0h - read one EGA register
  1678. dw egaF1 ; 0F1h - write one EGA register
  1679. dw egaF2 ; 0F2h - read register range
  1680. dw egaF3 ; 0F3h - write register range
  1681. dw egaF4 ; 0F4h - read register set
  1682. dw egaF5 ; 0F5h - write register set
  1683. dw egaF6 ; 0F6h - revert to default regs
  1684. dw egaF7 ; 0F7h - define deflt reg table
  1685. dw noint ; 0F8h is not a valid function
  1686. dw noint ; 0F9h is not a valid function
  1687. dw egaFA ; 0FAh - interrogate driver
  1688. ega_lib:
  1689. xor al,al
  1690. sub ax,0f0h ; create a jump table index
  1691. shl ax,1 ; remember that a word pointer is reqd
  1692. mov si,ax
  1693. jmp [egalibjmp+si] ; get the relavent jump address
  1694. egaF0: ;--- Read an EGA register ----------------------------------------------
  1695. pusha
  1696. and bx,0ffh ; just want the lower byte (BL)
  1697. F00:
  1698. cmp dx,0
  1699. jne F08
  1700. mov bl,byte ptr [ega_current_crtc+bx]
  1701. popa
  1702. jmp noint
  1703. F08:
  1704. cmp dx,8
  1705. jne F010
  1706. dec bx ; note that RESET is not stored
  1707. mov bl,byte ptr [ega_current_seq+bx]
  1708. popa
  1709. jmp noint
  1710. F010:
  1711. cmp dx,010h
  1712. jne F018
  1713. mov bl,byte ptr [ega_current_graph+bx]
  1714. popa
  1715. jmp noint
  1716. F018:
  1717. cmp dx,018h
  1718. jne F020
  1719. mov bl,byte ptr [ega_current_attr+bx]
  1720. popa
  1721. jmp noint
  1722. F020:
  1723. cmp dx,020h
  1724. jne F028
  1725. mov bl,byte ptr [ega_current_misc]
  1726. F028: ; do nothing for this case
  1727. F0quit:
  1728. popa
  1729. jmp noint
  1730. egaF1: ;--- Write an EGA register --------------------------------------------
  1731. F10:
  1732. pusha
  1733. cmp dx,0
  1734. jne F18
  1735. mov dx,03d4h ; write to the CRTC index register
  1736. mov ax,bx ; values to write to ports 3d4/3d5
  1737. out dx,ax ; do the write
  1738. mov di,bx ; save the written values to memory
  1739. and di,0ffh ; get just the lower 8 bits
  1740. mov byte ptr [ega_current_crtc+di],bh
  1741. mov byte ptr [dirty_crtc+di],1
  1742. popa
  1743. jmp noint
  1744. F18:
  1745. cmp dx,8
  1746. jne F110
  1747. mov dx,03c4h ; write to the Sequencer index register
  1748. mov ax,bx ; values to write to ports 3c4/3c5
  1749. out dx,ax ; do the write
  1750. cmp bl,0 ; Cannot index reset because it its
  1751. jle F18bra1 ; not stored. range = 1->4
  1752. and bx,0ffh ; just want BL
  1753. dec bx ; actually, one less than that
  1754. mov byte ptr [ega_current_seq+bx],ah
  1755. mov byte ptr [dirty_seq+bx],1
  1756. F18bra1:
  1757. popa
  1758. jmp noint
  1759. F110:
  1760. cmp dx,010h
  1761. jne F118
  1762. mov dx,03ceh ; write to the Graphics controller
  1763. mov ax,bx ; values to write to ports 3ce/3cf
  1764. out dx,ax ; do the write
  1765. mov di,bx ; save the written values to memory
  1766. and di,0ffh ; get just the lower 8 bits
  1767. mov byte ptr [ega_current_graph+di],bh
  1768. mov byte ptr [dirty_graph+di],1
  1769. popa
  1770. jmp noint
  1771. F118:
  1772. cmp dx,018h
  1773. jne F120
  1774. mov dx,03dah ; clear attribute controller index
  1775. in al,dx ; the read clears this register
  1776. mov ax,bx ; need to write BX to the ports
  1777. mov dx,03c0h ; Attribute Controller index register
  1778. out dx,ax ; do the write
  1779. inc dx
  1780. mov al,020h ; EGA palette enable
  1781. out dx,al ; enable the palette
  1782. mov di,bx ; save the written values to memory
  1783. and di,0ffh ; get just the lower 8 bits
  1784. mov byte ptr [ega_current_graph+di],bh
  1785. mov byte ptr [dirty_graph+di],1
  1786. popa
  1787. jmp noint
  1788. F120:
  1789. cmp dx,020h
  1790. jne F128
  1791. mov dx,03c2h ; EGA miscellaneous register
  1792. mov al,bl
  1793. out dx,al ; write to the register
  1794. mov [ega_current_misc],bl
  1795. popa
  1796. jmp noint
  1797. F128:
  1798. cmp dx,028h
  1799. jne F128
  1800. mov dx,03dah ; EGA feature register
  1801. mov al,bl
  1802. out dx,al
  1803. F1quit:
  1804. popa
  1805. jmp noint
  1806. egaF2: ;--- Read a register range ---------------------------------------------
  1807. pusha
  1808. cmp dx,0
  1809. jne F28
  1810. F20:
  1811. lea si,ega_current_crtc ; get the address of this buffer
  1812. mov dx,cx ; save this value
  1813. xchg ch,cl ; create an index with CH
  1814. and cx,0ffh ; only need CH (now CL)
  1815. add si,cx ; SOURCE adjust the address
  1816. xor dh,dh ; only want the old CL value
  1817. mov cx,dx ; restore CX
  1818. mov di,bx ; DESTINATION got from the application
  1819. rep movsb ; copy to the app's register block
  1820. popa
  1821. jmp noint
  1822. F28:
  1823. cmp dx,8
  1824. jne F210
  1825. lea si,ega_current_seq ; get the address of this buffer
  1826. mov dx,cx ; save this value
  1827. xchg ch,cl ; create an index with CH
  1828. and cx,0ffh ; only need CH (now CL)
  1829. dec cx ; RESET is not stored, so index-1
  1830. add si,cx ; SOURCE adjust the address
  1831. xor dh,dh ; only want the old CL value
  1832. mov cx,dx ; restore CX
  1833. mov di,bx ; DESTINATION got from the application
  1834. rep movsb ; copy to the app's register block
  1835. popa
  1836. jmp noint
  1837. F210:
  1838. cmp dx,010h
  1839. jne F218
  1840. lea si,ega_current_graph ; get the address of this buffer
  1841. mov dx,cx ; save this value
  1842. xchg ch,cl ; create an index with CH
  1843. and cx,0ffh ; only need CH (now CL)
  1844. add si,cx ; SOURCE adjust the address
  1845. xor dh,dh ; only want the old CL value
  1846. mov cx,dx ; restore CX
  1847. mov di,bx ; DESTINATION got from the application
  1848. rep movsb ; copy to the app's register block
  1849. popa
  1850. jmp noint
  1851. F218:
  1852. cmp dx,018h
  1853. jne F2quit
  1854. lea si,ega_current_attr ; get the address of this buffer
  1855. mov dx,cx ; save this value
  1856. xchg ch,cl ; create an index with CH
  1857. and cx,0ffh ; only need CH (now CL)
  1858. add si,cx ; SOURCE adjust the address
  1859. xor dh,dh ; only want the old CL value
  1860. mov cx,dx ; restore CX
  1861. mov di,bx ; DESTINATION got from the application
  1862. rep movsb ; copy the application's register block
  1863. F2quit:
  1864. popa
  1865. jmp noint
  1866. egaF3: ;--- Write a register range to the EGA adapter ------------------------
  1867. pusha
  1868. push ds
  1869. push es
  1870. F31:
  1871. cmp dx,0
  1872. jne F38
  1873. lea di,ega_current_crtc ; write the application data here
  1874. mov al,ch ; adjust the write position as required
  1875. cbw
  1876. add di,ax ; DESTINATION specified address
  1877. mov si,bx ; SOURCE from the application
  1878. lea bx,dirty_crtc ; need to write some data into here
  1879. add bx,ax ; well, at this offset anyway
  1880. mov ax,es ; The application is the source
  1881. mov ds,ax ; so point to its segment
  1882. mov dx,03d4h ; CRTC index register
  1883. mov ah,ch ; CRTC register to start at
  1884. xor ch,ch ; CX is now the loop counter
  1885. assume ds:nothing
  1886. F31cp:
  1887. mov byte ptr cs:[bx],1 ; fill in the dirty_crtc array
  1888. inc bx
  1889. movsb ; get the value from the app to write
  1890. ; and write to the internal buffer
  1891. out dx,ax ; write to the EGA adapter
  1892. loop F31cp
  1893. jmp F3quit
  1894. F38:
  1895. cmp dx,8
  1896. jne F310
  1897. lea di,ega_current_seq ; write the application data here
  1898. mov al,ch ; adjust the write position as required
  1899. cbw
  1900. add di,ax ; DESTINATION specified address
  1901. dec di ; RESET is not stored, so index-1
  1902. mov si,bx ; SOURCE from the application
  1903. lea bx,dirty_seq ; need to write some data into here
  1904. add bx,ax ; well, at this offset anyway
  1905. inc bx
  1906. mov ax,es ; The application is the source
  1907. mov ds,ax ; so point to its segment
  1908. mov dx,03c4h ; Sequencer index register
  1909. mov ah,ch ; Sequencer register to start at
  1910. inc ah
  1911. xor ch,ch ; CX is now the loop counter
  1912. assume ds:nothing
  1913. F38cp:
  1914. mov byte ptr cs:[bx],1 ; fill in the dirty_seq array
  1915. inc bx
  1916. movsb ; get the value from the app to write
  1917. ; and write to the internal buffer
  1918. out dx,ax ; write to the EGA adapter
  1919. loop F38cp
  1920. assume ds:SpcMseSeg
  1921. jmp F3quit
  1922. F310:
  1923. cmp dx,010h
  1924. jne F318
  1925. lea di,ega_current_graph ; write the application data here
  1926. mov al,ch ; adjust the write position as required
  1927. cbw
  1928. add di,ax ; DESTINATION specified address
  1929. mov si,bx ; SOURCE from the application
  1930. lea bx,dirty_graph ; need to write some data into here
  1931. add bx,ax ; well, at this offset anyway
  1932. mov ax,es ; The application is the source
  1933. mov ds,ax ; so point to its segment
  1934. mov dx,03ceh ; Graphics Controller index register
  1935. mov ah,ch ; GC register to start at
  1936. xor ch,ch ; CX is now the loop counter
  1937. assume ds:nothing
  1938. F310cp:
  1939. mov byte ptr cs:[bx],1 ; fill in the dirty_graph array
  1940. inc bx
  1941. movsb ; get the value from the app to write
  1942. ; and write to the internal buffer
  1943. out dx,ax ; write to the EGA adapter
  1944. loop F310cp
  1945. assume ds:SpcMseSeg
  1946. jmp short F3quit
  1947. F318:
  1948. cmp dx,018h
  1949. jne F3quit
  1950. mov dx,03dah ; clear attribute controller index
  1951. in al,dx ; the read clears this register
  1952. lea di,ega_current_attr ; write the application data here
  1953. mov al,ch ; adjust the write position as required
  1954. cbw
  1955. add di,ax ; DESTINATION specified address
  1956. mov si,bx ; SOURCE from the application
  1957. lea bx,dirty_attr ; need to write some data into here
  1958. add bx,ax ; well, at this offset anyway
  1959. mov ax,es ; The application is the source
  1960. mov ds,ax ; so point to its segment
  1961. mov dx,03c0h ; Attribute Controller index register
  1962. mov ah,ch ; AC register to start at
  1963. xor ch,ch ; CX is now the loop counter
  1964. assume ds:nothing
  1965. F318cp:
  1966. mov byte ptr cs:[bx],1 ; fill in the dirty_attr array
  1967. inc bx
  1968. movsb ; get the value from the app to write
  1969. ; and write to the internal buffer
  1970. out dx,ax ; write to the EGA adapter
  1971. loop F318cp
  1972. assume ds:SpcMseSeg
  1973. F3quit:
  1974. pop es
  1975. pop ds
  1976. popa
  1977. jmp noint
  1978. egaF4: ;--- Read EGA register set -------------------------------------------
  1979. ;
  1980. ; note that the incoming/outgoing data is structured thus:
  1981. ;
  1982. ; from application --> db Port number
  1983. ; --> db must be zero
  1984. ; --> db pointer value
  1985. ; to application <-- db data read from register
  1986. pusha
  1987. F4lp:
  1988. mov al,byte ptr es:[bx] ; get the type of the next EGA register
  1989. mov dl,byte ptr es:[bx+2] ; load up the offset required
  1990. xor dh,dh ; convert DL to a word (DX)
  1991. add bx,3 ; point to where the data should
  1992. ; be written for the application
  1993. F40:
  1994. cmp al,0
  1995. jne F48
  1996. lea di,ega_current_crtc ; point to the internal CRTC reg. buffer
  1997. add di,dx ; index into the buffer
  1998. mov al,byte ptr [di] ; get the register value from the driver
  1999. mov byte ptr es:[bx],al ; store the register value
  2000. jmp short F4lp2 ; do the next loop iteration
  2001. F48:
  2002. cmp al,8
  2003. jne F410
  2004. lea di,ega_current_seq ; point to the internal Sequencer buffer
  2005. add di,dx ; index into the buffer
  2006. dec di ; RESET is not stored, so index off 1
  2007. mov al,byte ptr [di] ; get the register value from the driver
  2008. mov byte ptr es:[bx],al ; store the register value
  2009. jmp short F4lp2 ; do the next loop iteration
  2010. F410:
  2011. cmp al,010h
  2012. jne F418
  2013. lea di,ega_current_graph ; point to the internal GC reg. buffer
  2014. add di,dx ; index into the buffer
  2015. mov al,byte ptr [di] ; get the register value from the driver
  2016. mov byte ptr es:[bx],al ; store the register value
  2017. jmp short F4lp2 ; do the next loop iteration
  2018. F418:
  2019. cmp al,018h
  2020. jne F420
  2021. lea di,ega_current_attr ; point to the interal AC reg. buffer
  2022. add di,dx ; index into the buffer
  2023. mov al,byte ptr [di] ; get the register value from the driver
  2024. mov byte ptr es:[bx],al ; store the register value
  2025. jmp short F4lp2 ; do the next loop iteration
  2026. F420:
  2027. cmp al,020h
  2028. jne F4lp2
  2029. mov al,[ega_current_misc] ; load contents of miscellaneous reg
  2030. mov byte ptr[di],al ; store the register value
  2031. ; the C code actually loads BL here but I don't know why!
  2032. F4lp2:
  2033. inc bx ; point to the next 'record'
  2034. loop F4lp
  2035. popa
  2036. jmp noint
  2037. egaF5: ;--- Write EGA register set -------------------------------------------
  2038. ;
  2039. ; note that the incoming data is structured thus:
  2040. ;
  2041. ; from application --> db Port number
  2042. ; --> db must be zero
  2043. ; --> db pointer value
  2044. ; --> db data read from register
  2045. pusha
  2046. F5lp:
  2047. mov al,byte ptr es:[bx] ; get the type of the next EGA register
  2048. mov dl,byte ptr es:[bx+2] ; load up the offset required
  2049. xor dh,dh ; turn from 8 bit to a word quantity
  2050. mov si,dx ; need this when accessing buffers
  2051. add bx,3 ; point to where the data should
  2052. ; be written for the application
  2053. mov ah,byte ptr es:[bx] ; load data to send to the port
  2054. inc bx ; point to the next 'record'
  2055. F50:
  2056. cmp al,0
  2057. jne F58
  2058. mov al,dl ; also the port offset to access
  2059. mov dx,03d4h ; index register for CRTC
  2060. out dx,ax ; write to the specified port
  2061. mov byte ptr [ega_current_crtc+si],ah
  2062. mov byte ptr [dirty_crtc+si],1
  2063. jmp short F5lp2
  2064. F58:
  2065. cmp al,8
  2066. jne F510
  2067. mov al,dl ; also the port offset to access
  2068. mov dx,03c4h ; index register for Sequencer
  2069. out dx,ax ; write to the specified port
  2070. dec si ; RESET is not stored, so index off 1
  2071. mov byte ptr [ega_current_seq+si],ah
  2072. mov byte ptr [dirty_seq+si],1
  2073. jmp short F5lp2
  2074. F510:
  2075. cmp al,010h
  2076. jne F518
  2077. mov al,dl ; also the port offset to access
  2078. mov dx,03ceh ; index register for GC
  2079. out dx,ax ; write to the specified port
  2080. mov byte ptr [ega_current_graph+si],ah
  2081. mov byte ptr [dirty_graph+si],1
  2082. jmp short F5lp2
  2083. F518:
  2084. cmp al,018h
  2085. jne F520
  2086. mov dx,03dah ; clear attribute controller index
  2087. in al,dx ; the read clears this register
  2088. lea di,ega_current_attr ; write the application data here
  2089. mov al,dl ; also the port offset to access
  2090. mov dx,03c0h ; index register for AC
  2091. out dx,ax ; write to the specified port
  2092. mov al,020h ; EGA palette enable
  2093. out dx,al ; reenable the video
  2094. mov byte ptr [ega_current_attr+si],ah
  2095. mov byte ptr [dirty_attr+si],1
  2096. jmp short F5lp2
  2097. F520:
  2098. cmp al,020h
  2099. jne F528
  2100. mov byte ptr [ega_current_misc],ah
  2101. mov dx,03c2h ; Miscellaneous output register
  2102. xchg ah,al
  2103. out dx,al ; write one byte
  2104. jmp short F5lp2
  2105. F528:
  2106. xchg ah,al
  2107. mov dx,03dah ; EGA feature register
  2108. out dx,al
  2109. F5lp2:
  2110. dec cx
  2111. cmp cx,0
  2112. jz F5quit
  2113. jmp F5lp
  2114. F5quit:
  2115. popa
  2116. jmp noint
  2117. egaF6: ;--- Restore the EGA default register values --------------------------
  2118. pusha
  2119. push es
  2120. ; copy the default EGA register sets to the driver's internal cache
  2121. mov ax,ds
  2122. mov es,ax
  2123. mov cx,25
  2124. lea di,ega_current_crtc
  2125. lea si,ega_default_crtc
  2126. rep movsb
  2127. mov cx,4
  2128. lea di,ega_current_seq
  2129. lea si,ega_default_seq
  2130. rep movsb
  2131. mov cx,9
  2132. lea di,ega_current_graph
  2133. lea si,ega_default_graph
  2134. rep movsb
  2135. mov cx,20
  2136. lea di,ega_current_attr
  2137. lea si,ega_default_attr
  2138. rep movsb
  2139. mov al,[ega_default_misc]
  2140. mov [ega_current_misc],al
  2141. ; Set up the Sequencer defaults
  2142. mov dx,03c4h ; Sequencer index register
  2143. mov ax,0100h ; Synchronous reset
  2144. out dx,ax ; do the work
  2145. xor bx,bx ; do the four non reset registers
  2146. inc al ; point to the next Sequencer register
  2147. F6lp1:
  2148. cmp [dirty_seq+bx],1 ; has the dirty bit been set?
  2149. jne F6ne1
  2150. mov ah,[ega_default_seq+bx] ; default value to send to the register
  2151. out dx,ax ; do the work
  2152. F6ne1:
  2153. inc bx ; point to the next buffer location
  2154. inc al ; point to the next Sequencer register
  2155. cmp bx,3 ; copy elements 0->3 to ports
  2156. jl F6lp1
  2157. mov ax,0300h ; Clear synchronous reset
  2158. out dx,ax ; do the work
  2159. ; Set up the default Miscellaneous Output Register value.
  2160. mov dx,03c2h ; Miscellaneous o/p register address
  2161. mov al,[ega_default_misc] ; the default value
  2162. out dx,al ; write to the EGA/VGA
  2163. ; Set up the Cathode Ray Tube Controller in the default fashion
  2164. mov dx,03d4h ; Index to the CRTC
  2165. xor bx,bx ; clear an index register
  2166. F6lp2:
  2167. cmp [dirty_crtc+bx],1 ; has the dirty bit been set?
  2168. jne F6ne2
  2169. mov ax,bx ; index for the CRTC index register
  2170. mov ah,[ega_default_crtc+bx] ; default value for the selected reg.
  2171. out dx,ax
  2172. F6ne2:
  2173. inc bx ; point to the next location
  2174. cmp bx,25 ; 25 registers to copy
  2175. jl F6lp2
  2176. ; Set up the Attribute Controller default values
  2177. ; Remember that this is a funny beast which uses a flip-flop
  2178. ; off just one address/data port
  2179. mov dx,03dah ; CRT status register
  2180. in al,dx ; set the AC flip-flop
  2181. mov dx,03c0h ; Attibute controller address/data regs
  2182. xor bx,bx ; clear an index register
  2183. F6lp3:
  2184. cmp [dirty_attr+bx],1 ; has the dirty bit been set?
  2185. jne F6ne3
  2186. mov ax,bx ; index for the CRTC index register
  2187. mov ah,[ega_default_attr+bx] ; default value for the selected reg.
  2188. out dx,al ; index the register, then flip the flop
  2189. xchg al,ah ; get the default data for this register
  2190. out dx,al ; write the data out
  2191. F6ne3:
  2192. inc bx ; point to the next location
  2193. cmp bx,20 ; 20 registers to copy
  2194. ; Set the Graphics Controller default values
  2195. mov dx,03ceh ; Index to the GC
  2196. xor bx,bx ; clear an index register
  2197. F6lp4:
  2198. cmp [dirty_graph+bx],1 ; has the dirty bit been set?
  2199. jne F6ne4
  2200. mov ax,bx ; index for the GC index register
  2201. mov ah,[ega_default_graph+bx] ; default value for the selected reg.
  2202. out dx,ax
  2203. F6ne4:
  2204. inc bx ; point to the next location
  2205. cmp bx,9 ; 9 registers to copy
  2206. jl F6lp2
  2207. ; Reenable the video
  2208. mov dx,03c0h ; index register for AC
  2209. mov al,020h ; EGA palette enable
  2210. out dx,al ; reenable the video
  2211. ; Clean out the dirty register arrays
  2212. xor al,al ; put a nice zero in all the dirty
  2213. ; registers
  2214. mov cx,25+4+9+20 ; do the CRTC, SEQ, GC and AC in
  2215. mov di,offset dirty_crtc ; one go
  2216. rep stosb
  2217. pop es
  2218. popa
  2219. jmp noint
  2220. egaF7: ;---Define default register table -------------------------------------
  2221. pusha
  2222. push es
  2223. push ds
  2224. ; Load a new set of default registers for a particular EGA/VGA component
  2225. mov si,bx ; SOURCE of the incoming data from the app
  2226. mov ax,es ; save the SOURCE segment register
  2227. mov bx,ds ; save the DESTINATION offset
  2228. mov ds,ax ; DS is now the SOURCE segment in the app
  2229. mov es,bx ; ES is now the DESTINATION segment in the dvr
  2230. assume ds:nothing, es:SpcMseSeg
  2231. F70: ; Set the default CRTC registers
  2232. cmp dx,0
  2233. jne F78
  2234. mov cx,25 ; copy 25 register entries
  2235. mov di,offset ega_default_crtc
  2236. rep movsb ; do the copy
  2237. jmp short F7dirty
  2238. F78: ; Set the default Sequencer registers
  2239. cmp dx,8
  2240. jne F710
  2241. mov cx,4 ; copy 4 register entries
  2242. mov di,offset ega_default_seq
  2243. rep movsb ; do the copy
  2244. jmp short F7dirty
  2245. F710: ; Set the default Graphic Controller registers
  2246. cmp dx,10
  2247. jne F718
  2248. mov cx,9 ; copy 9 register entries
  2249. mov di,offset ega_default_graph
  2250. rep movsb ; do the copy
  2251. jmp short F7dirty
  2252. F718: ; Set the default Attribute Controller registers
  2253. cmp dx,18
  2254. jne F720
  2255. mov cx,20 ; copy 20 register entries
  2256. mov di,offset ega_default_attr
  2257. rep movsb ; do the copy
  2258. jmp short F7dirty
  2259. F720: ; Set the default Miscellaneous Output register
  2260. cmp dx,20
  2261. jne F7quit
  2262. mov word ptr cs:[ega_default_misc],si
  2263. F7dirty:
  2264. ; Set all the dirty register arrays
  2265. mov al,1 ; put a nice one in all the dirty
  2266. ; registers
  2267. mov cx,25+4+9+20 ; dirty all the registers in one go
  2268. mov di,offset dirty_crtc
  2269. rep stosb
  2270. F7quit:
  2271. pop ds ; need to restore the segment registers
  2272. pop es
  2273. assume ds:SpcMseSeg, es:nothing
  2274. popa
  2275. jmp noint
  2276. egaFA: ;--- Interrogate driver -----------------------------------------------
  2277. ; The real Microsoft mouse driver gets this wrong (release 7.03)
  2278. push ax
  2279. mov ax,cs
  2280. mov es,ax
  2281. mov bx,offset relnum ; return the address of the mouse
  2282. ; driver version number
  2283. pop ax
  2284. jmp noint
  2285. ;=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
  2286. ENDIF ; MOUSE_VIDEO_BIOS
  2287. do_bop:
  2288. bop VIDEO_IO_BOP ;BOP BE
  2289. nop
  2290. nop
  2291. jnc noint
  2292. go_rom:
  2293. popf
  2294. db 0EAh ; this is a far jump
  2295. old_vid_int dd ? ; far pointer to the old int 10h vector
  2296. jmp DOIRET
  2297. noint:
  2298. popf
  2299. jmp DOIRET
  2300. mouse_int1:
  2301. bop INT1_BOP
  2302. jmp DOIRET
  2303. mouse_version:
  2304. ifdef DBCS
  2305. dw 0626h
  2306. else ; !DBCS
  2307. dw 04242h
  2308. endif ; !DBCS
  2309. dw 0000h
  2310. mouse_copyright:
  2311. db "Windows NT MS-DOS subsystem Mouse Driver"
  2312. video_io:
  2313. int VIDEO
  2314. bop UNSIMULATE_BOP
  2315. mouse_int2:
  2316. bop INT2_BOP
  2317. jmp DOIRET
  2318. mouseINB:
  2319. in al,dx
  2320. bop 0feh
  2321. mouseOUTB:
  2322. out dx,al
  2323. bop 0feh
  2324. mouseOUTW:
  2325. out dx,ax
  2326. bop 0feh
  2327. ;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2328. ;
  2329. ;16 BIT ENTRY POINT 16 BIT ENTRY POINT 16 BIT ENTRY POINT 16 BIT ENTRY POINT
  2330. ;
  2331. ;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2332. ;========================================================================
  2333. ; Procedure that provides the driver interface to 32 bit land. This is
  2334. ; the entry point to the Intel 16 bit driver from the mouse interrupt
  2335. ; handler in the host mouse code.
  2336. ;
  2337. ; This procedure determines the current video mode from the BIOS data
  2338. ; area, and depending on this branches to the correct display routines
  2339. ; for this mode.
  2340. ;
  2341. ; N.B. This function MUST NOT modify CX and DX because the next level
  2342. ; of functions in the driver heirarchy requires the values passed in
  2343. ; them from 32 bit land.
  2344. ;========================================================================
  2345. assume ds:SpcMseSeg
  2346. entry_point_from_32bit proc near
  2347. make_stack ; use the driver's own stack
  2348. push ds
  2349. push ax
  2350. push bx
  2351. mov ax,cs
  2352. mov ds,ax
  2353. call getBIOSvideomode; read the BIOS data area
  2354. xor bx,bx ; clear the jump table index
  2355. shl al,1 ; create a table index for word sized entries
  2356. mov bl,al ; move into a base register
  2357. call [drawpointerJMPT+bx] ; jump to the correct routine
  2358. pop bx
  2359. pop ax
  2360. pop ds
  2361. kill_stack ; return to the previous stack
  2362. bop 0FEh ; return to the 32 bit side
  2363. entry_point_from_32bit endp
  2364. ;========================================================================
  2365. ; Procedure to set the cursor draw flag to DO DRAW. This is called from
  2366. ; SoftPC code via a host_simulate(). This routine is called when the
  2367. ; application does an INT 33h, function 1.
  2368. ;
  2369. ; In accordance with the Microsoft Programmer's Reference, the internal
  2370. ; cursor flag (internalCF) has a default value of -1. If intenalCF = 0
  2371. ; then the cursor is drawn. If the flag is already 0, then this function
  2372. ; does nothing.
  2373. ;
  2374. ; Note: with calls to int 33h AX = 2, it is legal to
  2375. ; make internalCF less than -1.
  2376. ;========================================================================
  2377. int33function1 proc near
  2378. make_stack ; use the driver's own stack
  2379. push ax
  2380. push bx
  2381. push ds
  2382. mov ax,cs
  2383. mov ds,ax
  2384. ;; do not allow mouse int comes in while we are updating the cursor.
  2385. ;; call DOCLI
  2386. ; check to see if the pointer should be drawn
  2387. ; cmp [internalCF],0 ; is the flag already zero?
  2388. ; jz fn1quit ; if so, do nothing
  2389. ; pointer is not ON, so increment the flag to try to turn it ON
  2390. ; inc [internalCF] ; increment the pointer internal flag
  2391. ; cmp [internalCF],0 ; if 0, then the pointer can be drawn
  2392. ; jl fn1quit ; it is < 0, so don't draw the pointer.
  2393. ; The internal cursor flag hits zero for the first time, so
  2394. ; draw the pointer.
  2395. call getBIOSvideomode; read the BIOS data area
  2396. xor bx,bx ; clear the jump table index
  2397. shl al,1 ; create a table index for word sized entries
  2398. mov bl,al ; move into a base register
  2399. call [Int33function1JMPT+bx] ; do the correct function 1 handler
  2400. fn1quit:
  2401. ;; call DOSTI
  2402. pop ds
  2403. pop bx
  2404. pop ax
  2405. kill_stack ; return to the previous stack
  2406. bop 0FEh ; back to jolly old 32 bit land
  2407. int33function1 endp
  2408. ;========================================================================
  2409. ; Procedure to set the cursor draw flag to DONT DRAW. This is called from
  2410. ; SoftPC code via a host_simulate(). This routine is called when the
  2411. ; application does an INT 33h, function 2
  2412. ;
  2413. ; Note: with calls to int 33h AX = 2, it is legal to
  2414. ; make internalCF less than -1.
  2415. ;========================================================================
  2416. int33function2 proc near
  2417. make_stack ; use the driver's own stack
  2418. push ax
  2419. push bx
  2420. push ds
  2421. mov ax,cs
  2422. mov ds,ax
  2423. ;; do not allow mouse int comes in while we are updating the cursor.
  2424. ;; call DOCLI
  2425. ; dec [internalCF] ; decrement the pointer internal flag
  2426. ; if the internal cursor flag is less than -1, then do not try
  2427. ; do remove the pointer from the screen because this has already
  2428. ; been done.
  2429. ; cmp [internalCF],0ffh
  2430. ; jl fn2quit ; do nothing if < -1
  2431. ; Internal flag hits -1, so remove the pointer from the screen.
  2432. call getBIOSvideomode; read the BIOS data area
  2433. xor bx,bx ; clear the jump table index
  2434. shl al,1 ; create a table index for word sized entries
  2435. mov bl,al ; move into a base register
  2436. call [Int33function2JMPT+bx] ; do the correct function 1 handler
  2437. fn2quit:
  2438. ;; call DOSTI
  2439. pop ds
  2440. pop bx
  2441. pop ax
  2442. kill_stack ; return to the previous stack
  2443. bop 0feh
  2444. int33function2 endp
  2445. ;========================================================================
  2446. ; Procedure to return straight back to cloud 32. This is needed if an
  2447. ; unsupported video mode is found in the BIOS data area.
  2448. ;========================================================================
  2449. not_supported proc near
  2450. ret ; cant't BOP 0feh here or the stack will die
  2451. ; (out of balance with CS:IP stored from call)
  2452. not_supported endp
  2453. ;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2454. ;
  2455. ; END 16 BIT ENTRY END 16 BIT ENTRY END 16 BIT ENTRY END 16 BIT ENTRY
  2456. ;
  2457. ;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2458. ;========================================================================
  2459. ; Procedure to draw a cursor on the fullscreen X86 graphics display for
  2460. ; high resolution graphics modes.
  2461. ; This procedure saves the area about to be written over, blts the
  2462. ; pointer image onto the screen and restores the background from whence
  2463. ; cursor has just come.
  2464. ;
  2465. ; Input: CX = x-coordinate
  2466. ; DX = y-coordinate
  2467. ; Output: None
  2468. ;========================================================================
  2469. drawHiResPointer proc near
  2470. ; save the video card's read/write context
  2471. ;; call DOCLI
  2472. pusha
  2473. push ds
  2474. mov ax,cs ; make sure that DS points to the
  2475. mov ds,ax ; right segment
  2476. call saveVGAregisters
  2477. call check_for_mode_change
  2478. mov bx,cx ; get X coordinate into a base register
  2479. shl bx,1 ; calculate a word index
  2480. mov ax,[ChooseImageLUT+bx] ; select the right image LUT
  2481. mov [PointerLUT],ax ; store the LUT address
  2482. xor ax,ax ; assume carry clear after the next call
  2483. call determineboundary
  2484. jnc detcont ; pointer in buonds if carry clear
  2485. not ax ; carry was set, so set AX non zero
  2486. detcont:
  2487. ; Coordinates are now transformed from Cartesian to physical VRAM
  2488. ; memory byte and bit offsets.
  2489. mov di,dx ; store DX for later
  2490. ; internalCF = the current pointer status
  2491. ; background = indicates if a background has been stored or not
  2492. ;
  2493. ; if(internalCF == Zero && background == STORED)
  2494. ; The normal cursor ON condition
  2495. cmp [internalCF],0
  2496. jnz end_the_if ; request to turn pointer on
  2497. cmp [background],STORED
  2498. jne end_the_if
  2499. mov si,cx
  2500. mov di,dx
  2501. mov dx,[VRAMlastbyteoff]
  2502. mov cx,[VRAMlastbitoff]
  2503. call restore_background
  2504. cmp ax,0 ; should the pointer be drawn?
  2505. jnz end_the_if ; if the pointer has gone off the edge of
  2506. ; the screen, then quit
  2507. mov [VRAMlastbyteoff],di ; save the current position
  2508. mov [VRAMlastbitoff],si
  2509. mov cx,si
  2510. mov dx,di
  2511. call save_background
  2512. mov cx,si
  2513. mov dx,di
  2514. call drawEGApointer
  2515. end_the_if:
  2516. call restoreVGAregisters
  2517. pop ds
  2518. popa
  2519. ;; call DOSTI
  2520. ret
  2521. drawHiResPointer endp
  2522. ;========================================================================
  2523. ; Procedure to draw a cursor on the fullscreen X86 graphics display.for
  2524. ; medium resolution graphics modes.
  2525. ; This procedure saves the area about to be written over, blts the
  2526. ; pointer image onto the screen and restores the background from whence
  2527. ; cursor has just come.
  2528. ;
  2529. ; Input: CX = x-coordinate
  2530. ; DX = y-coordinate
  2531. ; Output: None
  2532. ;========================================================================
  2533. drawMediumResPointer proc near
  2534. pusha
  2535. ;; call DOCLI
  2536. shr cx,1 ; map from 640 virtual to 320 real
  2537. ; CX,DX = x,y cartesian coordinates here.
  2538. call check_for_mode_change
  2539. ; internalCF = the current pointer status
  2540. ; background = indicates if a background has been stored or not
  2541. ;
  2542. ; if(internalCF == Zero && background == STORED)
  2543. ; The normal cursor ON condition
  2544. cmp [internalCF],0
  2545. jnz cant_draw_ptr ; request to turn pointer on
  2546. cmp [background],STORED
  2547. jne cant_draw_ptr
  2548. mov si, cx ; save new cursor position
  2549. mov di, dx
  2550. mov dx,[VRAMlastbyteoff] ;
  2551. mov cx,[VRAMlastbitoff]
  2552. mov bp,[LastYCounters] ; Y looping counter
  2553. call restorebkgrndmode4
  2554. mov cx, si ; restore new cursor position
  2555. mov dx, di
  2556. call detboundmode4 ; calculate new byte offset
  2557. jc cant_draw_ptr ; don't draw new cursor of out of scrn
  2558. mov [VRAMlastbyteoff], dx ; byte offset
  2559. mov [VRAMlastbitoff], cx ; MSB = 0FFh if start with ODD line
  2560. ; LSB = bit offset
  2561. mov [LastYCounters], bp ; MSB: even counter, LSB for odd
  2562. call savebkgrndmode4
  2563. call drawmode4pointer
  2564. cant_draw_ptr:
  2565. ;; call DOSTI
  2566. popa
  2567. ret
  2568. drawMediumResPointer endp
  2569. ;========================================================================
  2570. ; Procedure to draw a cursor on the fullscreen X86 graphics display for
  2571. ; medium resolution, 256 colour graphics mode. (video bios mode 13h).
  2572. ; This procedure saves the area about to be written over, blts the
  2573. ; pointer image onto the screen and restores the background from whence
  2574. ; cursor has just come.
  2575. ;
  2576. ; Input: CX = x-coordinate
  2577. ; DX = y-coordinate
  2578. ; Output: None
  2579. ;========================================================================
  2580. drawC256Pointer proc near
  2581. pusha
  2582. ;; call DOCLI
  2583. shr cx,1 ; map from 640 virtual to 320 real x
  2584. ; CX,DX = x,y cartesian coordinates here.
  2585. call check_for_mode_change
  2586. ; internalCF = the current pointer status
  2587. ; background = indicates if a background has been stored or not
  2588. ;
  2589. ; if(internalCF == Zero && background == STORED)
  2590. ; The normal cursor ON condition
  2591. cmp [internalCF],0
  2592. jnz cant_draw_256ptr ; request to turn pointer on
  2593. cmp [background],STORED
  2594. jne cant_draw_256ptr
  2595. mov si,cx
  2596. mov di,dx
  2597. mov dx,[VRAMlastbyteoff]
  2598. mov cx,[LastXCounters]
  2599. mov bp,[LastYCounters]
  2600. call restorebkgrndmode13
  2601. mov cx, si
  2602. mov dx, di
  2603. call detboundmode13
  2604. jc cant_draw_256ptr
  2605. mov [VRAMlastbyteoff],dx ; save the current position
  2606. mov [LastXCounters],cx
  2607. mov [LastYCounters], bp
  2608. call savebkgrndmode13
  2609. call draw256pointer
  2610. cant_draw_256ptr:
  2611. ;; call DOSTI
  2612. popa
  2613. ret
  2614. drawC256Pointer endp
  2615. ;========================================================================
  2616. ; Procedure to draw a pointer on the fullscreen X86 text display for
  2617. ; BIOS modes 3 and 7.
  2618. ; This procedure saves the area about to be written over, XORs the
  2619. ; pointer image onto the screen and restores the background from whence
  2620. ; cursor has just come.
  2621. ;
  2622. ; Input: CX = x-coordinate
  2623. ; DX = y-coordinate
  2624. ; Output: None
  2625. ;========================================================================
  2626. IFDEF SIXTEENBIT
  2627. drawTextPointer proc near
  2628. pusha
  2629. push es
  2630. ; CX,DX = x,y virtual pixel coordinates here.
  2631. ; 0 <= x < 640
  2632. ; 0 <= y < 200 for 25 line mode
  2633. ; 0 <= y < 344 for 43 line mode
  2634. ; 0 <= y < 400 for 50 line mode
  2635. ; The virtual character size is always 8x8 virtual pixels.
  2636. call check_for_mode_change
  2637. ; internalCF = the current pointer status
  2638. ; background = indicates if a background has been stored or not
  2639. ;
  2640. ; if(internalCF == Zero && background == STORED)
  2641. ; The normal cursor ON condition
  2642. cmp [internalCF],0
  2643. jnz cant_draw_text_ptr ; request to turn pointer on
  2644. cmp [background],STORED
  2645. jne cant_draw_text_ptr
  2646. ; Calculate the current cell location as an offset
  2647. ; into the text buffer segment starting at B800:0
  2648. ; Note: The following kinky shifts allow for the fact that the text
  2649. ; video buffer consists of word elements of the form char:attr.
  2650. ; So, if a row = 80 characters wide on the screen, it is 160
  2651. ; bytes wide in VRAM.
  2652. mov bx,dx ; create a word table index
  2653. shr bx,3 ; virtual char height = 8, but 160 bytes
  2654. ; per text row, so save some shifts.
  2655. shl bx,1 ; make a word table index
  2656. mov di,[mult80lut+bx] ; multiply by 80 words per text row.
  2657. shl di,1
  2658. shr cx,3 ; divide the x virtual pixel coordinate
  2659. ; by 8 = virtual char width and mult
  2660. ; by 2 to get word offset in text row.
  2661. shl cx,1
  2662. add di,cx ; full VRAM location now in DI
  2663. ; Restore the text cell previously overwritten.
  2664. mov si,[VRAMlasttextcelloff]; address of last modified text cell
  2665. mov [VRAMlasttextcelloff],di; store the current cell location
  2666. mov ax,0b800h ; the text buffer segment
  2667. mov es,ax ; ES now points there
  2668. ; The text pointer uses the same magic as the graphics code
  2669. ; to place a pointer on the screen.
  2670. mov bx,07700h ; the magic cursor mask for pointer
  2671. mov cx,077ffh ; the magic screen mask for pointer
  2672. assume es:nothing
  2673. mov ax,[lasttextimage] ; restore the background
  2674. mov es:[si],ax ; from last time
  2675. mov ax,es:[di] ; load the cell to be modifyed
  2676. mov [lasttextimage],ax ; save this cell for next time
  2677. and ax,cx ; apply the screen mask
  2678. xor ax,bx ; apply the cursor mask
  2679. mov es:[di],ax ; and write back
  2680. assume es:SpcMseSeg
  2681. cant_draw_text_ptr:
  2682. pop es
  2683. popa
  2684. ret
  2685. drawTextPointer endp
  2686. ENDIF ;; SIXTEENBIT
  2687. ifdef DBCS
  2688. ;; video io handler
  2689. DBCS_mouse_int10:
  2690. inc cs:video_io_enter_count
  2691. pushf
  2692. call cs:old_vid_int
  2693. dec cs:video_io_enter_count
  2694. iret
  2695. ;; input: cx = mouse cursor X position in screen coordinate
  2696. ;; dx = mouse cursor Y position in screen coordinate
  2697. DBCS_drawTextPointer proc near
  2698. cmp cs:video_io_enter_count, 0
  2699. jne video_busy_01
  2700. pusha
  2701. push es
  2702. push ds
  2703. mov ax, cs
  2704. mov ds, ax
  2705. mov es, ax
  2706. cmp [background], NOTSTORED
  2707. je @F
  2708. call DBCS_erase_cursor
  2709. @@:
  2710. call DBCS_save_ac
  2711. mov [background], STORED
  2712. call DBCS_draw_new_cursor
  2713. pop ds
  2714. pop es
  2715. popa
  2716. video_busy_01:
  2717. ret
  2718. DBCS_drawTextPointer endp
  2719. DBCS_erase_cursor proc near
  2720. push cx
  2721. push dx
  2722. mov bx, mouse_cursor_offset
  2723. mov ax, saved_ac_on_mouse_cursor
  2724. mov [bx], ax
  2725. mov dx, saved_ac_cursor_position
  2726. mov cx, saved_ac_count
  2727. mov bh, active_page
  2728. mov bp, saved_ac_offset
  2729. mov ax, 1320h
  2730. int 10h
  2731. pop dx
  2732. pop cx
  2733. ret
  2734. DBCS_erase_cursor endp
  2735. DBCS_draw_new_cursor proc near
  2736. push cx
  2737. push dx
  2738. mov bx, mouse_cursor_offset
  2739. mov ax, saved_ac_on_mouse_cursor
  2740. and ax, 077FFh
  2741. xor ax, 07700h
  2742. mov [bx], ax
  2743. mov bp, saved_ac_offset
  2744. mov ax, 1320h
  2745. mov cx, saved_ac_count
  2746. mov dx, saved_ac_cursor_position
  2747. mov bh, active_page
  2748. int 10h
  2749. pop dx
  2750. pop cx
  2751. ret
  2752. DBCS_draw_new_cursor endp
  2753. ;; input: cx = mouse X virtual screen coordinate
  2754. ;; dx = mouse Y virtual screen coordinate
  2755. ;; this function assumes that DS and ES are set to CS
  2756. DBCS_save_ac proc near
  2757. push cx
  2758. push dx
  2759. push es
  2760. SCREENtoCHARCELL ;screen coord to cell coord
  2761. mov saved_ac_cursor_position, dx ;the cell coord where the
  2762. ; mouse cursor stay
  2763. mov cl, dl ;
  2764. inc cl ;read ac pairs from the
  2765. ;beginning of the line
  2766. inc cl
  2767. xor ch, ch
  2768. mov dl, ch
  2769. mov bp, offset line_buffer
  2770. mov bh, active_page
  2771. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2772. xor bl, bl
  2773. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2774. mov ax, 1310h
  2775. int 10h
  2776. dec cx
  2777. mov si, bp
  2778. les di, dbcs_vector
  2779. mov bp, di
  2780. mov dl, 3 ;dl = char code type
  2781. ;3->SBCS, 4->DBCS 1st
  2782. ;5->DBCS 2nd
  2783. cld
  2784. MBCS_parsing_loop:
  2785. lodsb ;get next char code
  2786. inc si ;place ptr to next one
  2787. cmp dl, 4 ;previous code a DBCS 1st?
  2788. je DBCS_ac ;yes, count this one the 2nd
  2789. mov dl, 3 ;reset to SBCS
  2790. DBCS_lead_byte_loop:
  2791. mov bx, es:[di] ;get next dbcs lead byte pair
  2792. or bx, bx ;done with the table?
  2793. je parse_next_ac ;yes, try next ac
  2794. inc di ;advance the dbcs table index
  2795. inc di
  2796. cmp al, bl ;is the char code a DBCS 1st?
  2797. jb DBCS_lead_byte_loop ;
  2798. cmp al, bh
  2799. ja DBCS_lead_byte_loop
  2800. DBCS_ac:
  2801. inc dl ;either DBCS 1st or DBCS 2nd
  2802. parse_next_ac:
  2803. mov di, bp ;reset DBCS vector
  2804. loop MBCS_parsing_loop
  2805. dec si ;
  2806. dec si
  2807. mov ax, [si] ;the ac we want to save
  2808. mov saved_ac_on_mouse_cursor, ax
  2809. mov mouse_cursor_offset, si ;and so is the offset in the buffer
  2810. cmp dl, 5 ;if the ac on the mouse cursor position
  2811. ;is a DBCS 2nd, we backward the
  2812. ;pointer
  2813. jne @F ;backward one ac
  2814. dec si
  2815. dec si
  2816. dec saved_ac_cursor_position ;and adjust the cursor position
  2817. @@:
  2818. mov saved_ac_offset, si ;
  2819. shr dl, 1
  2820. xor dh, dh
  2821. mov saved_ac_count, dx
  2822. pop es
  2823. pop dx
  2824. pop cx
  2825. ret
  2826. DBCS_save_ac endp
  2827. endif ; DBCS
  2828. ;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2829. ;
  2830. ; Interrupt 33h support functions.
  2831. ; These functions are called via a jump table from the 16 bit entry
  2832. ; point code.
  2833. ;
  2834. ;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2835. ;========================================================================
  2836. ; Procedure to set the cursor draw flag to DO DRAW. This is called from
  2837. ; SoftPC code via a host_simulate(). This routine is called when the
  2838. ; application does an INT 33h, function 1
  2839. ;========================================================================
  2840. int33function0 proc near
  2841. make_stack ; use the driver's own stack
  2842. push ds
  2843. push es
  2844. pusha
  2845. ; sort out the segments
  2846. mov ax,cs
  2847. mov ds,ax
  2848. mov ax,cs
  2849. mov es,ax
  2850. ;; do not allow mouse int comes in while we are updating the cursor.
  2851. ;; call DOCLI
  2852. ; set the internal pointer flag to its default value.
  2853. mov [internalCF],0ffh
  2854. ; set the default hotspot location = (0,0)
  2855. xor ax,ax
  2856. mov [hotspot],ax
  2857. mov [hotspot+2],ax
  2858. ; copy the default pointer to the working pointer buffer
  2859. lea si,default_cursor
  2860. lea di,current_cursor
  2861. call copy_pointer_to_current
  2862. ; clear the pointer enabled flag, turn the pointer off by restoring
  2863. ; the background.
  2864. mov [background],NOTSTORED ; there is no stored background now
  2865. ;; call DOSTI
  2866. popa
  2867. pop es
  2868. pop ds
  2869. kill_stack ; restore the previous stack
  2870. bop 0FEh
  2871. int33function0 endp
  2872. ;========================================================================
  2873. ; Procedure to accept a cursor bit image from the current application
  2874. ; at ES:DX. This is stored as the current pointer image for use by
  2875. ; the driver.
  2876. ;========================================================================
  2877. assume es:nothing
  2878. int33function9 proc near
  2879. call DOCLI
  2880. make_stack ; use the driver's own stack
  2881. push ds
  2882. push es
  2883. pusha
  2884. mov ax,cs ; point at the driver data segment
  2885. mov ds,ax
  2886. ;; do not allow mouse int comes in while we are updating the cursor.
  2887. ;; call DOCLI
  2888. ; Read in the hotspot cartesian coordinate values for the
  2889. ; new pointer image. If the hotspot values are out of range
  2890. ; i.e. >127 | < -128, then reset to the boundary value
  2891. ; Now using kinky non modRM short forms by clever use of AX
  2892. mov ax,127 ; load accumulator with 127
  2893. mov bp,ax ; store this constant in a register
  2894. cmp ax,bx ; compare X value of hotspot with 127
  2895. jg test_low_x ; if 127 > BX, BX is within upper limit
  2896. xchg ax,bx ; BX > 127, so set to 127
  2897. jmp short check_y_hotspot ; now test the Y values
  2898. test_low_x:
  2899. not ax ; change accumulator from 127 to -128
  2900. cmp ax,bx ; compare X value of hotspot with -128
  2901. jl check_y_hotspot ; if -128 < BX, BX is within lower lim.
  2902. xchg ax,bx ; BX < -128, so set it to -128
  2903. check_y_hotspot:
  2904. mov ax,bp ; reload AX with 127
  2905. cmp ax,cx ; compare Y value of hotspot with 127
  2906. jg test_low_y ; if 127 > CX, Cx is within upper limit
  2907. xchg ax,cx ; CX > 127, so set CX to 127
  2908. jmp short done_hotspot_check; both hotspot coords tested, so save
  2909. test_low_y:
  2910. not ax ; change accumulator from 127 to -128
  2911. cmp ax,cx ; compare Y value of hotspot with -128
  2912. jl done_hotspot_check ; if -128 < CX, CX is within lower lim.
  2913. xchg ax,cx ; CX < -128, so set it to -128
  2914. done_hotspot_check:
  2915. mov [hotspot],bx ; save the hotspot x,y
  2916. mov [hotspot+2],cx ; y component of the hotspot
  2917. ; DESTINATION: the driver current pointer buffer
  2918. ; Note: the SOURCE is already being pointed at by DX
  2919. lea di,current_cursor ; this is the bit that must change
  2920. mov si,dx
  2921. ; copy in the new application pointer
  2922. mov ax,es
  2923. mov ds,ax ; DS now points to where ES points
  2924. mov ax,cs
  2925. mov ax,es ; ES points to our data area now
  2926. call copy_pointer_to_current ; Copy the pointer image appropriately
  2927. popa
  2928. pop es
  2929. pop ds
  2930. kill_stack ; restore the previous stack
  2931. call DOSTI
  2932. ret ; this code is called from within this
  2933. ; 16 bit driver, so don't BOP
  2934. int33function9 endp
  2935. ;============================================================================
  2936. ; Procedure to display the pointer image in HIRES graphics modes
  2937. ;============================================================================
  2938. HiResInt33Function1 proc near
  2939. pusha
  2940. call check_for_mode_change
  2941. call saveVGAregisters
  2942. mov cx,[current_position_x] ; get the last known cursor position
  2943. mov dx,[current_position_y] ; from the OS via the event loop
  2944. call determineboundary ; convert to VRAM coordinates
  2945. jc end_function1 ; if the pointer has gone off the edge
  2946. ; of the screen, then quit
  2947. mov [VRAMlastbyteoff],dx ; save the restore background location
  2948. mov [VRAMlastbitoff],cx
  2949. mov si,cx
  2950. mov di,dx
  2951. call save_background
  2952. mov cx,si
  2953. mov dx,di
  2954. call drawEGApointer
  2955. mov [background],STORED
  2956. end_function1:
  2957. call restoreVGAregisters
  2958. popa
  2959. ret ; return to driver surface manager code
  2960. HiResInt33Function1 endp
  2961. ;============================================================================
  2962. ; Procedure to display the pointer image in MEDIUMRES graphics modes
  2963. ; Note that this function does a conversion from virtual pixel coordinates
  2964. ; to real screen coordinates as required if the stored values in the
  2965. ; current_position memory locations are greater than 320 for X or 200
  2966. ; for Y.
  2967. ;============================================================================
  2968. MediumResInt33Function1 proc near
  2969. pusha
  2970. call check_for_mode_change
  2971. mov cx,[current_position_x] ; get the last known cursor position
  2972. mov dx,[current_position_y] ; from the OS via the event loop
  2973. shr cx,1 ; virtual coor -> screen coor
  2974. call detboundmode4 ; convert to VRAM coordinates
  2975. jc MediumResFunction1_exit
  2976. mov [VRAMlastbyteoff],dx ; save the restore background location
  2977. mov [VRAMlastbitoff],cx
  2978. mov [LastYCounters], bp
  2979. call savebkgrndmode4
  2980. call drawmode4pointer
  2981. mov [background],STORED
  2982. MediumResFunction1_exit:
  2983. popa
  2984. ret
  2985. MediumResInt33Function1 endp
  2986. ;============================================================================
  2987. ; Procedure to display the pointer image in VGA 256 colour graphics modes
  2988. ;============================================================================
  2989. C256Int33Function1 proc near
  2990. pusha
  2991. call check_for_mode_change
  2992. call modifyentry255 ; make sure that DAC entry 255 is white
  2993. mov cx,[current_position_x] ; get the last known cursor position
  2994. mov dx,[current_position_y]
  2995. shr cx, 1 ; virtual coor -> screen coord
  2996. call detboundmode13 ; convert to VRAM coordinates
  2997. jc C256Function1_exit
  2998. mov [VRAMlastbyteoff],dx ; save the restore background location
  2999. mov [LastXCounters],cx ; X loop counter
  3000. mov [LastYCounters], bp ; Y loop counter
  3001. call savebkgrndmode13
  3002. call draw256pointer
  3003. mov [background],STORED
  3004. C256Function1_exit:
  3005. popa
  3006. ret ; return to driver surface manager code
  3007. C256Int33Function1 endp
  3008. ;============================================================================
  3009. ; Procedure to show the TEXT pointer
  3010. ;============================================================================
  3011. IFDEF SIXTEENBIT
  3012. TextInt33Function1 proc near
  3013. pusha
  3014. push es
  3015. mov [background],STORED
  3016. call check_for_mode_change
  3017. mov cx,[current_position_x] ; get the last known cursor position
  3018. mov bx,[current_position_y] ; from the OS via the event loop
  3019. shr bx,3 ; virtual char height = 8, but 160 bytes
  3020. ; per text row.
  3021. shl bx,1 ; make a word table index
  3022. mov di,[mult80lut+bx] ; multiply by 80 words per text row.
  3023. shl di,1 ; remember 160 bytes NOT 80 in a row
  3024. shr cx,3 ; divide the x virtual pixel coordinate
  3025. ; by 8 = virtual char width and mult
  3026. ; by 2 to get word offset in text row.
  3027. shl cx,1
  3028. add di,cx ; full VRAM location now in DI
  3029. mov [VRAMlasttextcelloff],di; store the current cell location
  3030. mov ax,0b800h ; the text buffer segment
  3031. mov es,ax ; DS now points there
  3032. mov bx,07700h ; the magic cursor mask for pointer
  3033. mov cx,077ffh ; the magic screen mask for pointer
  3034. assume es:nothing
  3035. mov ax,es:[di] ; load the cell to be modifyed
  3036. mov [lasttextimage],ax ; save this cell for next time
  3037. and ax,cx ; apply the screen mask
  3038. xor ax,bx ; apply the cursor mask
  3039. mov es:[di],ax ; and write back
  3040. assume es:SpcMseSeg
  3041. pop es
  3042. popa
  3043. ret ; return to driver surface manager code
  3044. TextInt33Function1 endp
  3045. ENDIF ;; SIXTEENBIT
  3046. ifdef DBCS
  3047. DBCS_TextInt33Function1 proc near
  3048. cmp cs:video_io_enter_count, 0
  3049. jne video_busy_02
  3050. pusha
  3051. push es
  3052. push ds
  3053. mov ax, cs
  3054. mov es, ax
  3055. mov ds, ax
  3056. mov cx, [current_position_x]
  3057. mov dx, [current_position_y]
  3058. call DBCS_save_ac
  3059. mov [background], STORED
  3060. call DBCS_draw_new_cursor
  3061. pop ds
  3062. pop es
  3063. popa
  3064. video_busy_02:
  3065. ret
  3066. DBCS_TextInt33Function1 endp
  3067. endif ; DBCS
  3068. ;============================================================================
  3069. ; Procedure to remove the pointer image in HIRES graphics modes
  3070. ;============================================================================
  3071. HiResInt33Function2 proc near
  3072. push cx
  3073. push dx
  3074. call saveVGAregisters
  3075. call check_for_mode_change
  3076. cmp [background],STORED ; is there some stored background?
  3077. jne no_background_stored ; no, so don't restore it
  3078. mov dx,[VRAMlastbyteoff]
  3079. mov cx,[VRAMlastbitoff]
  3080. call restore_background ; restored the background at correct
  3081. mov [background],NOTSTORED ; place. Set buffer cleared Flag
  3082. no_background_stored:
  3083. call restoreVGAregisters
  3084. pop dx
  3085. pop cx
  3086. ret
  3087. HiResInt33Function2 endp
  3088. ;============================================================================
  3089. ; Procedure to remove the pointer image in MEDIUMRES graphics modes
  3090. ;============================================================================
  3091. MediumResInt33Function2 proc near
  3092. push cx
  3093. push dx
  3094. push bp
  3095. call check_for_mode_change
  3096. cmp [background],STORED ; is there some stored background?
  3097. jne nobkgrndstored ; no, so don't restore it
  3098. mov dx,[VRAMlastbyteoff]
  3099. cmp dx,80*100 ; mustn't be greater than buffer size
  3100. jl vidoffok ; it's OK, so do nothing
  3101. mov dx,80*10-1 ; modify DX to fit in the buffer
  3102. vidoffok:
  3103. mov cx,[VRAMlastbitoff] ; CL = bit offset
  3104. ; CH = odd/even flag
  3105. and cl,3 ; cannot be greater than bit 3( 2bits/p)
  3106. mov bp, [LastYCounters]
  3107. call restorebkgrndmode4 ; restored the background at correct
  3108. mov [background],NOTSTORED ; place. Set buffer cleared Flag
  3109. nobkgrndstored:
  3110. pop bp
  3111. pop dx
  3112. pop cx
  3113. ret
  3114. MediumResInt33Function2 endp
  3115. ;============================================================================
  3116. ; Procedure to remove the pointer image in MEDIUMRES graphics modes
  3117. ;============================================================================
  3118. C256Int33Function2 proc near
  3119. push cx
  3120. push dx
  3121. push bp
  3122. call check_for_mode_change
  3123. cmp [background],STORED ; is there some stored background?
  3124. jne nobkgrndstored256 ; no, so don't restore it
  3125. mov dx,[VRAMlastbyteoff]
  3126. mov cx,[LastXCounters]
  3127. mov bp,[LastYCounters]
  3128. call restorebkgrndmode13 ; restored the background at correct
  3129. mov [background],NOTSTORED ; place. Set buffer cleared Flag
  3130. nobkgrndstored256:
  3131. pop bp
  3132. pop dx
  3133. pop cx
  3134. ret
  3135. C256Int33Function2 endp
  3136. ;============================================================================
  3137. ; Procedure to remove the pointer image in TEXT modes
  3138. ;============================================================================
  3139. IFDEF SIXTEENBIT
  3140. TextInt33Function2 proc near
  3141. push ax
  3142. push si
  3143. push es
  3144. call check_for_mode_change
  3145. cmp [background],STORED ; is there some stored background?
  3146. jne no_text_background_stored ; no, so don't restore it
  3147. mov [background],NOTSTORED ; place. Set buffer cleared Flag
  3148. ; Restore the text cell previously overwritten.
  3149. mov si,[VRAMlasttextcelloff]; address of last modified text cell
  3150. mov ax,0b800h ; the text buffer segment
  3151. mov es,ax ; DS now points there
  3152. assume es:nothing
  3153. mov ax,[lasttextimage] ; restore the background
  3154. mov es:[si],ax ; from last time
  3155. no_text_background_stored:
  3156. assume es:SpcMseSeg
  3157. pop es
  3158. pop si
  3159. pop ax
  3160. ret
  3161. TextInt33Function2 endp
  3162. ENDIF ;; SIXTEENBIT
  3163. ifdef DBCS
  3164. DBCS_TextInt33Function2 proc near
  3165. cmp cs:video_io_enter_count, 0
  3166. jne video_busy_03
  3167. cmp cs:[background], NOTSTORED
  3168. je DBCS_TextInt33Function2_exit
  3169. pusha
  3170. push es
  3171. push ds
  3172. mov ax, cs
  3173. mov ds, ax
  3174. mov es, ax
  3175. call DBCS_erase_cursor
  3176. mov [background], NOTSTORED
  3177. pop ds
  3178. pop es
  3179. popa
  3180. video_busy_03:
  3181. DBCS_TextInt33Function2_exit:
  3182. ret
  3183. DBCS_TextInt33Function2 endp
  3184. endif ; DBCS
  3185. ;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  3186. ;
  3187. ; End of Interrupt 33h support functions.
  3188. ;
  3189. ;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  3190. ;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  3191. ;
  3192. ; Mouse driver general support functions
  3193. ;
  3194. ;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  3195. ;========================================================================
  3196. ; Procedure to determine if the application has changed video modes since
  3197. ; the last mouse interrupt. If it has, then the image that is saved in the
  3198. ; background restore buffer is invalid and should not be drawn.
  3199. ;========================================================================
  3200. check_for_mode_change proc near
  3201. push ax
  3202. call getBIOSvideomode; peek at the BIOS data area for video mode
  3203. cmp al,[lastvidmode]; compare with the last mode value
  3204. ; from the preceding interrupt
  3205. jnz mode_change ; a mode change has occurred
  3206. pop ax ; no mode change, so quit
  3207. ret
  3208. mode_change:
  3209. mov [background],NOTSTORED
  3210. mov byte ptr [lastvidmode],al ; store the new mode
  3211. pop ax
  3212. ret
  3213. check_for_mode_change endp
  3214. ;========================================================================
  3215. ; Procedure to read the BIOS data area and get the current video mode
  3216. ; Output: AL = BIOS video mode
  3217. ; Modifies: memory variable -> currentvidmode, puts the video found in
  3218. ; the BIOS data area in this memory location.
  3219. ;========================================================================
  3220. getBIOSvideomode proc near
  3221. push es
  3222. push bx
  3223. ifdef DBCS
  3224. mov bx, dbcs_vector_seg
  3225. or bx, bx
  3226. je got_dbcs_state
  3227. mov es, bx
  3228. mov bx, dbcs_vector_off
  3229. mov bh, es:[bx]
  3230. got_dbcs_state:
  3231. endif ; DBCS
  3232. mov ax,40h ; BIOS data area segment
  3233. mov es,ax
  3234. ifdef DBCS
  3235. mov al,es:[62h]; ; get current page number
  3236. mov active_page, al
  3237. endif ; DBCS
  3238. mov al,es:[49h] ; get the BIOS video mode data
  3239. mov bl,al ; copy the video mode value
  3240. ifdef DBCS
  3241. cmp bh, 0
  3242. je got_mode_number
  3243. mov al, DBCS_GRAPHIC_MODE_NUMBER
  3244. cmp bl, 72h
  3245. je got_mode_number
  3246. mov al, DBCS_TEXT_MODE_NUMBER
  3247. got_mode_number:
  3248. mov bl, al
  3249. endif ; DBCS
  3250. xor bh,bh
  3251. shl bx,1 ; create a word table index
  3252. mov bx,[latchhomeLUT+bx] ; get the latch hiding place for this
  3253. ; video mode
  3254. mov [latchcache],bx ; save in memory for use in save and restore
  3255. ; vga registers.
  3256. pop bx
  3257. pop es ; restore the 'normal' data segment
  3258. ret
  3259. getBIOSvideomode endp
  3260. ;=========================================================================
  3261. ; Function to modify the 256th palette entry for 256 colour mode. The
  3262. ; driver requires white to be set in this DAC register triple.
  3263. ;=========================================================================
  3264. modifyentry255 proc near
  3265. push ax
  3266. push dx
  3267. mov dx,03c8h
  3268. mov al,0ffh
  3269. out dx,al
  3270. inc dx
  3271. out dx,al
  3272. out dx,al
  3273. out dx,al
  3274. pop dx
  3275. pop ax
  3276. ret
  3277. modifyentry255 endp
  3278. ;========================================================================
  3279. ; Procedure to copy the required pointer image to the snapshot
  3280. ; buffers. Each buffer holds a different instance of the mouse
  3281. ; pointer for each possible alignment of the pointer image in
  3282. ; a VRAM byte.
  3283. ;
  3284. ; INPUT DS:SI = pointer to the source image
  3285. ;
  3286. ;========================================================================
  3287. assume ds:nothing
  3288. copy_pointer_to_current proc near
  3289. push ds
  3290. push es
  3291. pusha
  3292. ; Set up the destination for the copy
  3293. mov ax,cs ; point ES to this segment
  3294. mov es,ax
  3295. lea di,current_cursor ; this is the bit that must change
  3296. mov bx,di ; save this address for a while
  3297. mov bp,si ; save the application source address
  3298. ; Fill the AND buffer with 1s and then fill the XOR buffer with
  3299. ; 0s for the byte aligned pointer condition. This is done so that
  3300. ; the last byte in the 3byte scanline sequence is set to the correct
  3301. ; value to prevent image loss from the screen.
  3302. cld ; move low mem -> high mem
  3303. mov ax,24 ; avoid doing a modRM load of immediate
  3304. mov cx,ax ; 24 words to fill.
  3305. mov dx,ax ; store this for a while
  3306. xor ax,ax ; clear AX (AX = 0)
  3307. not ax ; AX = 0ffffh -> fill AND mask with it.
  3308. rep stosw ; fill the screen mask (AND mask)
  3309. mov cx,dx ; do the next 24 words (XOR mask)
  3310. not ax ; AX = 0h -> fill XOR mask with it
  3311. rep stosw ; Fill the cursor mask
  3312. ; Now fill the prepared 48 word buffer with the user defined
  3313. ; AND and XOR masks
  3314. ; Note that the image passed in from the application is little-endian.
  3315. ; To write to the VGA planes byte by byte, the image has to be reversed
  3316. ; to big-endian for the purpose of quick drawing since the VGA can only
  3317. ; read and write one byte from/to its latches.
  3318. mov di,bx ; point to the top of the buffer again
  3319. mov si,bp ; point to the new pointer image
  3320. mov cx,32
  3321. norept1:
  3322. lodsw ; read in the required image word
  3323. xchg al,ah ; convert little endian to big endian
  3324. stosw ; write into local buffer
  3325. inc di ; remember local buffer in 3 bytes wide
  3326. dec cx
  3327. jnz norept1
  3328. ; Now, the aligned mask must be rotated, then copied into each of
  3329. ; the seven unaligned image buffers.
  3330. mov ax,cs
  3331. mov ds,ax ; return to the default data segment
  3332. mov bp,1000000000000000b ; a mask for the MSBit
  3333. lea di,AlignData1 ; point to the buffer for 1 bit offset
  3334. mov si,bx ; source = byte aligned pointer image
  3335. push bx
  3336. mov bx,32*7
  3337. norept2:
  3338. lodsw ; load the word from 3 byte sequence
  3339. xchg al,ah ; put into little-endian format
  3340. mov cl,byte ptr [si] ; load the remaining byte
  3341. shr ax,1 ; LSB now stored in CF
  3342. rcr cl,1 ; CF into MSB, lsb into CF
  3343. jnc $+4 ; CF=0 -> don't need to do anything
  3344. or ax,bp ; OR in the carried bit from CF
  3345. xchg al,ah ; return to bitstream format
  3346. stosw ; write the rotated data
  3347. mov byte ptr[di],cl
  3348. inc si ; point to the next source scanline
  3349. inc di ; point to the next dest scanline
  3350. dec bx
  3351. jnz norept2
  3352. pop bx
  3353. ; Just to do a little bit more work, the rotated buffers created
  3354. ; above must be copied to the instances for byte 78 and byte 79
  3355. ; of the scanline. These images are then cunningly clipped in the
  3356. ; process to the edge of the screen!
  3357. mov si,bx ; BX points to the top of current buffer
  3358. ; Note DI points to clip_cursor78 now
  3359. ; may as well use the nice string functions now that I don't
  3360. ; have to XCHG bytes. (how space and cycle efficient
  3361. xor al,al ; constant for putting in masks
  3362. ; there are 8 instances for bits 0 to 7
  3363. mov bx,8
  3364. norept3:
  3365. ; Do the AND mask modifications for byte 78
  3366. not al ; AL = 11111111b
  3367. REPT 16 ; 16 scanlines
  3368. movsw ; copy contents of AND word
  3369. stosb ; Nice clear AND mask = 11111111b
  3370. inc si ; point to the first image byte in
  3371. ; the next scanline
  3372. ENDM
  3373. ; Do the XOR mask modifications for byte 78
  3374. not al ; AL = 00000000b
  3375. REPT 16 ; 16 scanlines
  3376. movsw ; copy contents of XOR word
  3377. stosb ; Nice clear XOR mask = 00000000b
  3378. inc si ; point to the first image byte in
  3379. ; the next scanline
  3380. ENDM
  3381. dec bx
  3382. jnz norept3
  3383. ; prepare the BYTE 79 instances
  3384. ; SI and DI should be in the right place
  3385. xor ax,ax ; constant for putting in masks
  3386. mov bx,2 ; constant for addressing source
  3387. ; there are 8 instances for bits 0 to 7
  3388. mov cx,8
  3389. norept4:
  3390. ; Do the AND mask modifications for byte 79
  3391. not ax ; AX = 0ffffh
  3392. REPT 16 ; 16 scanlines
  3393. movsb ; copy contents of AND byte
  3394. stosw ; Nice clear AND mask (=0ffffh)
  3395. add si,bx ; point to the first image byte in
  3396. ; the next scanline
  3397. ENDM
  3398. ; Do the XOR mask modifications for byte 79
  3399. not ax ; AX = 0h
  3400. REPT 16 ; 16 scanlines
  3401. movsb ; copy contents of XOR byte
  3402. stosw ; Nice clear XOR mask
  3403. add si,bx ; point to the first image byte in
  3404. ; the next scanline
  3405. ENDM
  3406. dec cx
  3407. jz norept4quit
  3408. jmp norept4
  3409. norept4quit:
  3410. popa
  3411. pop es
  3412. pop ds
  3413. ret
  3414. copy_pointer_to_current endp
  3415. ;========================================================================
  3416. ; Procedure to determine the segment of the video buffer for
  3417. ; the current display mode.
  3418. ;========================================================================
  3419. assume ds:SpcMseSeg
  3420. getvideobuffer proc near
  3421. push ax
  3422. push si
  3423. ; determine the current video mode from the BIOS and save it.
  3424. ; Use this value to determine the video buffer segment address.
  3425. mov ah,0fh ; use the bios to get the video mode
  3426. int 10h
  3427. cbw ; create a table index
  3428. shl ax,1 ; word sized table entries
  3429. mov si,ax
  3430. mov ax,[videomodetable+si] ; use video mode to index the table
  3431. mov [videobufferseg],ax
  3432. pop si
  3433. pop ax
  3434. ret
  3435. getvideobuffer endp
  3436. IFDEF DEBUGMOUSE
  3437. ;=========================================================================
  3438. ; Code to provide 32 bit side with a dump of the VGA registers on request.
  3439. ;=========================================================================
  3440. VGAregs db 9+5+25 dup(?) ; enough room for sequencer, GC and CTRC
  3441. dumpVGAregs proc near
  3442. call DOCLI
  3443. pusha
  3444. push ds
  3445. mov ax,cs
  3446. mov ds,ax
  3447. assume ds:SpcMseSeg
  3448. ; Save the Graphics Controller registers
  3449. xor bx,bx ; Index into the G.C. register saving array
  3450. mov dx,03ceh ; Graphics Controller index register
  3451. xor ax,ax
  3452. mov cx,9 ; save 9 G.C. registers
  3453. norept5:
  3454. mov al,ah
  3455. out dx,al ; Select it
  3456. inc dx ; Address the register
  3457. in al,dx ; Get the register contents
  3458. mov [VGAregs+bx],al ; Save the register
  3459. inc bx ; index to next array entry
  3460. inc ah
  3461. dec dx ; Sequencer index register
  3462. dec cx
  3463. jnz norept5
  3464. ; Save the Sequencer registers
  3465. mov dx,03c4h ; Sequencer index register
  3466. xor ax,ax
  3467. mov cx,5 ; save 5 sequencer registers
  3468. norept6:
  3469. mov al,ah
  3470. out dx,al ; Select it
  3471. inc dx ; Address the register
  3472. in al,dx ; Get the register contents
  3473. mov [VGAregs+bx],al ; Save the register
  3474. inc bx ; index to next array entry
  3475. inc ah
  3476. dec dx ; Sequencer index register
  3477. dec cx
  3478. jnz norept6
  3479. ; Save the CRTC registers
  3480. mov dx,03d4h ; CRTC index register
  3481. xor ax,ax
  3482. mov cx,25 ; save 25 sequencer registers
  3483. norept7:
  3484. mov al,ah
  3485. out dx,al ; Select it
  3486. inc dx ; Address the register
  3487. in al,dx ; Get the register contents
  3488. mov [VGAregs+bx],al ; Save the register
  3489. inc bx ; index to next array entry
  3490. inc ah
  3491. dec dx ; CRTC index register
  3492. dec cx
  3493. jnz norept7
  3494. pop ds
  3495. popa
  3496. call DOSTI
  3497. bop 0feh ; return to 32 bit land
  3498. dumpVGAregs endp
  3499. ENDIF ; DEBUGMOUSE
  3500. ;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  3501. ;
  3502. ; End of Mouse driver general support functions
  3503. ;
  3504. ;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  3505. ;========================================================================
  3506. ; Procedure to draw an EGA pointer image on the graphics screen at a
  3507. ; specified bit location.
  3508. ;
  3509. ; Input: CX = pointer offset in the current VRAM byte.
  3510. ; DX = offset in the video buffer to pointer
  3511. ; Output: None
  3512. ; Modifies: AX,BX,CX,DX,BP,SI,DI
  3513. ;========================================================================
  3514. assume ds:SpcMseSeg
  3515. .286
  3516. even
  3517. drawEGApointer proc near
  3518. push es
  3519. push ds
  3520. mov ax,cs
  3521. mov ds,ax
  3522. cld ; index from low memory to high for LODSB
  3523. ; point to the video buffer
  3524. mov ax,0a000h
  3525. mov es,ax
  3526. mov bp,dx ; save the byte offset in VRAM for the XOR code
  3527. ; Select the Graphics Controller
  3528. mov dx,03ceh
  3529. ;************ AND MASK OPERATION **************************
  3530. ; use the bit position to select the relavent pointer image
  3531. shl cx,1 ; need a word offset into LUT
  3532. mov di,cx ; need an index register
  3533. mov bx,[PointerLUT]
  3534. mov si,[bx+di] ; Point to the screen (AND) mask
  3535. mov di,bp ; point to the byte offset in VRAM
  3536. mov ax,0803h ; Index the data rotate register and select AND
  3537. out dx,ax ; do it
  3538. mov ax,80-2 ; Avoid modRM loading of CX
  3539. mov cx,ax ; A constant handily kept in a register
  3540. ; The pointer contains 16 words of information
  3541. push bx
  3542. mov bx,16
  3543. norept8:
  3544. lodsw ; Load 2 bytes from the AND mask into AL and AH
  3545. xchg al,es:[di] ; Latch the 8 pixels for updating.
  3546. ; and write them back out with new data
  3547. inc di ; point to the next byte in VRAM
  3548. xchg ah,es:[di] ; Latch the 8 pixels for updating.
  3549. ; and write them back out with new data
  3550. inc di ; point to the next byte in VRAM
  3551. lodsb ; Load a byte from the AND mask into AL
  3552. xchg al,es:[di] ; Latch the 8 pixels for updating.
  3553. ; and write them back out with new data
  3554. add di,cx ; point to the next byte in VRAM on the next scan
  3555. ; line to write to. CX contains 80-2
  3556. dec bx
  3557. jnz norept8
  3558. pop bx
  3559. ;************ XOR MASK OPERATION **************************
  3560. ; Note: SI points to current_cursor+48 now, automatically
  3561. ; i.e. at the start of the XOR mask.
  3562. mov di,bp ; point to the byte offset in VRAM
  3563. mov ax,1803h ; Index the DATA ROTATE REGISTER and
  3564. ; Select the XOR function to XOR CPU data in
  3565. out dx,ax ; Do the deed
  3566. push bx
  3567. mov bx,16
  3568. norept9:
  3569. lodsw ; Load 2 bytes from the AND mask into AL and AH
  3570. xchg al,es:[di] ; Latch the 8 pixels for updating.
  3571. ; and write them back out with new data
  3572. inc di ; point to the next byte in VRAM
  3573. xchg ah,es:[di] ; Latch the 8 pixels for updating.
  3574. ; and write them back out with new data
  3575. inc di ; point to the next byte in VRAM
  3576. lodsb ; Load a byte from the XOR mask into AL
  3577. xchg al,es:[di] ; Latch the 8 pixels for updating.
  3578. ; and write them back out with new data
  3579. add di,cx ; point to the next byte in VRAM on the next scan
  3580. ; line to write to. CX contains 80-2
  3581. dec bx
  3582. jnz norept9
  3583. pop bx
  3584. pop ds
  3585. pop es
  3586. ret
  3587. drawEGApointer endp
  3588. ;========================================================================
  3589. ; Procedure to determine what the byte and bit offset is, in the current
  3590. ; VGA buffer for the top left hand corner of the pointer bitmap.
  3591. ; The X,Y value is modified for hotspot in this routine. A flag is set,
  3592. ; also, to relay whether or not the cursor bitmap is byte aligned or not.
  3593. ;
  3594. ; INPUT: CX,DX = pointer x,y coordinates
  3595. ; OUT : DX = byte offset to top left hand pointer pixel
  3596. ; CX = bit offset in the byte
  3597. ; CF = set if it is not possible to draw the pointer on the
  3598. ; screen because of the hotspot adjustment. (Usually a
  3599. ; negative hotspot value will cause clipping and wrapping
  3600. ; problems at the right and bottom screen boundaries.
  3601. ;========================================================================
  3602. determineboundary proc near
  3603. push ax
  3604. push bx
  3605. push es
  3606. ; do the adjustment in x,y for pointer hotspot
  3607. ; Also test for top or left screen boundary problems
  3608. ; and zero the coordinate if it goes negative.
  3609. sub cx,[hotspot] ; adjust the x cartesian coord for hotspot
  3610. jns dont_zero_x ; if x goes negative, assume zero
  3611. xor cx,cx
  3612. dont_zero_x:
  3613. sub dx,[hotspot+2] ; adjust the y cartesian coord for the hotspot
  3614. jns dont_zero_y ; if y goes negative, assume zero
  3615. xor dx,dx
  3616. dont_zero_y:
  3617. ; Now check the right and bottom bounds to prevent the pointer
  3618. ; image wrapping if the hotspot adjustment forces either of
  3619. ; the coordinates to exceed the screen bounds.
  3620. ; First, for all video modes that this function handles, the
  3621. ; X bound is always x < 640 ... check this first.
  3622. cmp cx,640
  3623. jl didntexceedX
  3624. stc ; Oh oh - failed, so set carry flag.
  3625. jmp short quitdet ; bye bye.
  3626. didntexceedX:
  3627. ; Now check out the y value by finding the maximum extent from
  3628. ; a lut based on the current BIOS video mode.
  3629. mov ax,40h ; B.D.A. segment
  3630. mov es,ax ; and ES points to it.
  3631. mov al,byte ptr es:[49h]
  3632. sub al,0fh ; table is normalized. mode f is in entry
  3633. ; zero.
  3634. xor ah,ah ; create a look up table index
  3635. shl ax,1 ; for a table with word sized elements.
  3636. xchg bx,ax ; use a suitable register as index
  3637. cmp dx,[hiresylut+bx] ; get the extent and compare y coord.
  3638. jl didntexceedY
  3639. stc ; Oh oh - failed, so set carry flag.
  3640. jmp short quitdet ; bye bye.
  3641. didntexceedY:
  3642. ; determine the byte offset from the start of the video buffer
  3643. ; for the modified coordinates. First calculate how many bytes
  3644. ; there are for the number of scanlines -1 to where the pointer
  3645. ; is.
  3646. mov ax,dx ; copy Y position into AX
  3647. shl ax,1 ; create a word table index
  3648. xchg ax,bx ; copy table index into a base register
  3649. mov dx,[mult80lut+bx] ; do a fast LUT multiply by 80
  3650. ; determine the byte position of the pixel in question
  3651. mov ax,cx ; save the x-coordinate displacement
  3652. and ax,7 ; do a modulus 8 to find the pixel position
  3653. ; in the byte. The bit number is in DX.
  3654. ; add the whole number of bytes in the current row to the number
  3655. ; of complete-row bytes
  3656. shr cx,3 ; divide pixels by 8 to get bytes
  3657. add dx,cx ; DX hold the complete byte offset.
  3658. xchg ax,cx ; CX = bit offset in the byte.
  3659. ; the pointer has not exceeded the screen buonds, so clear
  3660. ; the carry flag to signify this.
  3661. clc
  3662. ; Wind up the routine and return with the carry flag:
  3663. ; SET if cursor exceeded screen bounds.
  3664. ; CLEAR otherwise.
  3665. quitdet:
  3666. pop es
  3667. pop bx
  3668. pop ax
  3669. ret
  3670. determineboundary endp
  3671. ;========================================================================
  3672. ; Procedure to buffer up the data over which the cursor will next be
  3673. ; drawn. This data will be used to replace the cursor at a later point
  3674. ; when the cursor position has changed and for generating a cursor image
  3675. ; To prevent having separate routines for aligned and unaligned pointer
  3676. ; saves, this routine saves a pixel block 24 x 16 deep in all cases. The
  3677. ; start offset is a byte location into VRAM in which the pointer TLHC lives.
  3678. ;
  3679. ; Input: DX = VRAM byte
  3680. ; Modifies: AX,BX,DI,CX,DX,ES
  3681. ;
  3682. ;========================================================================
  3683. assume ds:SpcMseSeg
  3684. even
  3685. save_background proc near
  3686. push ds
  3687. push es
  3688. pusha
  3689. mov ax,cs ; point DS briefly at the driver data
  3690. mov ds,ax
  3691. mov es,ax ; point ES to the driver segment
  3692. lea di,behindcursor ; DESTINATION: a nice, safe place in the
  3693. ; driver segment
  3694. mov ax,0a000h ; point DS at VRAM
  3695. mov ds,ax
  3696. assume ds:nothing
  3697. mov bp,dx ; save DX=VRAM byte offset for later use
  3698. mov dx,03ceh ; VGA GC index register
  3699. mov al,4 ; select the read map select reg
  3700. out dx,al ; Index in the map select register
  3701. inc dx ; DX holds port address to map select register
  3702. xor al,al ; plane 0 will be selected first
  3703. cld ; make sure to address forward in memory
  3704. mov ah,3 ; number of bytes to copy per pointer scanline
  3705. xor cx,cx ; counter for the REP MOVSB
  3706. mov bx,80-3 ; another handy constant: move to next scanline
  3707. ; byte.
  3708. REPT 4 ; read the 4 EGA planes individually
  3709. mov si,bp ; SOURCE: somewhere in VRAM
  3710. out dx,al ; do the plane selection
  3711. inc al ; select the next plane to latch
  3712. ; note that only one byte at a time may be read from the latches
  3713. ; do 16 scanlines for each plane
  3714. push dx
  3715. mov dx,16
  3716. @@:
  3717. mov cl,ah ; CX now contains 3
  3718. rep movsb ; copy 3 bytes from VRAM to data segment
  3719. add si,bx ; move down to the first byte in next scanline
  3720. dec dx
  3721. jnz @B ; norept10
  3722. pop dx
  3723. ENDM
  3724. popa
  3725. pop es
  3726. pop ds
  3727. ret
  3728. save_background endp
  3729. ;========================================================================
  3730. ; Procedure to restore the area of the screen that was behind the cursor
  3731. ; before it had moved.
  3732. ;
  3733. ; Note. Currently (2/12/92) this is the only routine that modifies the
  3734. ; VGA sequencer. Therefore, the code from save and restore vga registers
  3735. ; that maintain the sequencer registers has been moved to here for
  3736. ; centralisation purposes.
  3737. ;
  3738. ; Input: DX = VRAM byte
  3739. ; Output: None
  3740. ; Modifies: AX,BX,CX,DX,DI,SI
  3741. ;========================================================================
  3742. assume ds:SpcMseSeg
  3743. even
  3744. restore_background proc near
  3745. push ds
  3746. push es
  3747. pusha
  3748. ;; call DOCLI ; turn off interrupts
  3749. mov ax,cs
  3750. mov ds,ax ; point at the driver data segment
  3751. mov ax,0a000h ; videobufferseg
  3752. mov es,ax ; point ES at VRAM segment
  3753. mov bp,dx ; save the pointer for later
  3754. mov si,offset behindcursor ; SOURCE: point at the stored planes
  3755. ; set up the Graphic Controller for the restore.
  3756. mov dx,03ceh ; VGA GC index register
  3757. mov ax,0003h ; Select copy into latches function
  3758. out dx,ax ; i.e. data rotate -> replace
  3759. mov ax,0ff08h ; bitmask register reset
  3760. out dx,ax
  3761. ; do the 4 plane restore.
  3762. mov cx,80-2 ; point to the first byte in image on next line
  3763. cld ; write forward in memory
  3764. mov bx,0102h ; BH = initial plane mask value
  3765. ; plane 0 is selected with a 1
  3766. ; BL = map mask register offset
  3767. mov dx,03c4h ; index register for sequencer
  3768. mov al,bl ; point to the map mask register in sequencer
  3769. out dx,al ; index the register into 03c5h
  3770. inc dx ; point to the data register
  3771. in al,dx ; read the data register value in
  3772. dec dx ; restore DX to 03c4h
  3773. mov [seqregs],al ; save the map mask register value
  3774. REPT 4 ; 4 planes to restore
  3775. mov di,bp ; DESTINATION: pointer into VRAM
  3776. mov ax,bx ; select the plane to mask and map mask register
  3777. out dx,ax ; do the mask
  3778. shl bh,1 ; point to the mask for the next iteration
  3779. push dx
  3780. mov dx,16
  3781. @@:
  3782. lodsw ; load the old background data (ONE WORD)
  3783. xchg al,es:[di] ; latch the VRAM data and swap with the
  3784. inc di ; point to next byte to replace
  3785. xchg ah,es:[di] ; latch the VRAM data and swap with the
  3786. inc di ; point to next byte to replace
  3787. lodsb ; load the old background data (ONE BYTE)
  3788. xchg al,es:[di] ; latch the VRAM data and swap with the
  3789. add di,cx ; point to the first byte in image on next line
  3790. dec dx
  3791. jnz @B ; norept11
  3792. pop dx
  3793. ENDM
  3794. mov ah,[seqregs] ; the old map mask value
  3795. mov al,bl ; need to restore the map mask register
  3796. out dx,ax ; do the restore
  3797. ;; call DOSTI ; reenable interrupts.
  3798. popa
  3799. pop es
  3800. pop ds
  3801. ret
  3802. restore_background endp
  3803. ;==========================================================================
  3804. ; Procedure to save the register state of the VGA card on receiving a
  3805. ; mouse pointer update interrupt. This procedure also sets up the following
  3806. ; VGA registers to nice values for the driver.
  3807. ;
  3808. ; mode register <write mode 0, read mode 0>
  3809. ; data rotate register <do not rotate, no logical ops>
  3810. ; enable set/reset register <disable set/reset>
  3811. ;
  3812. ;==========================================================================
  3813. even
  3814. assume ds:SpcMseSeg
  3815. saveVGAregisters proc near
  3816. push dx
  3817. push di
  3818. push es
  3819. ; Save the Graphics Controller registers that the
  3820. ; Driver uses
  3821. xor bx,bx ; Index into the G.C. register saving array
  3822. mov dx,03ceh ; Graphics Controller index register
  3823. xor al,al
  3824. push cx
  3825. mov cx,9 ; save 9 G.C. registers
  3826. norept12:
  3827. out dx,al ; Select it
  3828. inc dx ; Address the register
  3829. in al,dx ; Get the register contents
  3830. mov [GCregs+bx],al ; Save the register
  3831. inc bx ; index to next array entry
  3832. mov al,bl
  3833. dec dx ; G.C. index register
  3834. dec cx
  3835. jnz norept12
  3836. pop cx
  3837. ; save the latches to location in a bit of video buffer
  3838. ; off the screen.
  3839. mov ax,0a000h ; point to the video buffer
  3840. mov es,ax
  3841. assume es:nothing
  3842. mov ax,0105h ; select write mode 1 to squirt latches out
  3843. out dx,ax ; do the selection
  3844. mov di,[latchcache] ; 1 byte over the last location
  3845. mov es:[di],al ; write the latches out to the planes
  3846. ; disable the enable set/reset register
  3847. mov ax,01h ; select enable set/reset register and clear it
  3848. out dx,ax
  3849. ; clear the data rotate register (no logical operations).
  3850. inc ax
  3851. inc ax ; select data rotate register and clear it
  3852. out dx,ax ; AX = 3 therefore points to the DRR
  3853. ; set write mode 0 for the graphics display
  3854. ; conveniently, this also sets read mode to 0 which is needed too!
  3855. inc ax
  3856. inc ax ; select write mode 0
  3857. out dx,ax ; AX = 5, i.e. the mode register
  3858. ; color don't care. don't care for all planes
  3859. inc ax ;register 7, color don't care
  3860. inc ax
  3861. out dx, ax
  3862. ; bit mask register. enable all planes
  3863. ;
  3864. inc ax ;register 8, bit mask
  3865. not ah
  3866. out dx, ax
  3867. pop es
  3868. pop di
  3869. pop dx
  3870. ret
  3871. saveVGAregisters endp
  3872. ;==========================================================================
  3873. ; Procedure to restore the register state of the VGA card after dealing
  3874. ; with mouse pointer update interrupt.
  3875. ;==========================================================================
  3876. restoreVGAregisters proc near
  3877. assume ds:SpcMseSeg
  3878. push es
  3879. push di
  3880. push bx
  3881. ; restore the latches that where saved in the video planes
  3882. mov ax,0a000h ; point to the video buffer
  3883. mov es,ax
  3884. assume es:nothing
  3885. mov di,[latchcache] ; the byte just off the end of the buffer
  3886. mov al,es:[di] ; read in the latches
  3887. ; Restore the Graphics Controller registers that the
  3888. ; Driver uses
  3889. xor ax,ax ; create an index
  3890. xor bx,bx ; Index into the G.C. register saving array
  3891. mov dx,03ceh ; Graphics Controller index register
  3892. norept13:
  3893. mov ah,[GCregs+bx] ; restore the register
  3894. out dx,ax ; Select it
  3895. inc al ; index for the next register
  3896. inc bx ; index to next array entry
  3897. cmp al,9
  3898. jne norept13
  3899. pop bx
  3900. pop di
  3901. pop es
  3902. ret
  3903. restoreVGAregisters endp
  3904. ;=======================================================================
  3905. ; Procedure to draw a BIOS Mode 4 graphics pointer to the display.
  3906. ; Input: DX = byte offset
  3907. ; CL = bit offset in the byte
  3908. ; CH = 0FFh if ODD, 0 if EVEN
  3909. ; BP = Y loop counter, ODD in LSB, EVEN in MSB
  3910. ;=======================================================================
  3911. drawmode4pointer proc near
  3912. pusha
  3913. push es
  3914. cld
  3915. xchg dx, bp ;
  3916. mov di, bp ; bp = di = byte offset, dx = y counters
  3917. mov ax,0b800h ; point a segment register to
  3918. mov es,ax ; the CGA video buffer.
  3919. or ch, ch ;
  3920. je drawonevenscanline ;
  3921. jmp drawonoddscanline ; otherwise do an ODD job
  3922. ; ANDEVEN ANDEVEN ANDEVEN ANDEVEN ANDEVEN ANDEVEN ANDEVEN ANDEVEN ANDEVEN
  3923. drawonevenscanline:
  3924. mov si,[mode4SelectedPointer]
  3925. ; Load a word of the pointer image, convert it to two bits per
  3926. ; pixel and write to the screen for even scanlines
  3927. xor cx, cx
  3928. mov cl, dh ; number of even scanlines to draw
  3929. push dx
  3930. evensl1:
  3931. mov dx,3
  3932. norept14:
  3933. lodsb ; load 8 pixels from pointer bitmap
  3934. xor bh,bh ; want a zero extended 16 bit value
  3935. mov bl,al ; copy into a base register
  3936. shl bx,1 ; create a word address
  3937. mov ax,[LUT1to2bit+bx] ; get the byte to word conversion
  3938. xchg al,ah ; little-endianise
  3939. mov bx,es:[di] ; get the current displayed 8 pixels
  3940. and ax,bx ; AND the AND mask in
  3941. stosw ; write to the video buffer
  3942. dec dx
  3943. jnz norept14
  3944. add si,3
  3945. add di,80-6
  3946. loop evensl1
  3947. pop dx
  3948. ; Load a word of the pointer image, convert it to two bits per
  3949. ; pixel and write to the screen for odd scanlines
  3950. mov si,[mode4SelectedPointer]
  3951. add si,3
  3952. mov di,bp
  3953. add di,02000h ; offset into video buffer
  3954. ; the video buffer
  3955. mov cl,dl ; number of odd scanlines to draw
  3956. push dx
  3957. oddsl1:
  3958. mov dx,3
  3959. norept15:
  3960. lodsb ; load 8 pixels from bitmap
  3961. xor bh,bh
  3962. mov bl,al ; copy into a base register
  3963. shl bx,1 ; create a word address
  3964. mov ax,[LUT1to2bit+bx] ; get the byte to word conversion
  3965. xchg al,ah
  3966. mov bx,es:[di] ; get the current displayed 8 pixels
  3967. and ax,bx ; AND the AND mask in
  3968. stosw ; write to the video buffer
  3969. dec dx
  3970. jnz norept15
  3971. add si,3
  3972. add di,80-6
  3973. loop oddsl1
  3974. pop dx
  3975. ; XOREVEN XOREVEN XOREVEN XOREVEN XOREVEN XOREVEN XOREVEN XOREVEN XOREVEN
  3976. mov si,[mode4SelectedPointer]
  3977. add si,48
  3978. mov di,bp ; offset into video buffer
  3979. ; Load a word of the pointer image, convert it to two bits per
  3980. ; pixel and write to the screen for even scanlines
  3981. mov cl,dh ; number of even scanlines to draw
  3982. push dx
  3983. evensl2:
  3984. mov dx,3
  3985. norept16:
  3986. lodsb ; load 8 pixels from bitmap
  3987. xor bh,bh
  3988. mov bl,al ; copy into a base register
  3989. shl bx,1 ; create a word address
  3990. mov ax,[LUT1to2bit+bx] ; get the byte to word conversion
  3991. xchg al,ah
  3992. mov bx,es:[di] ; get the current displayed 8 pixels
  3993. xor ax,bx ; XOR the XOR mask in
  3994. stosw ; write to the video buffer
  3995. dec dx
  3996. jnz norept16
  3997. add si,3
  3998. add di,80-6
  3999. loop evensl2
  4000. pop dx
  4001. ; Load a word of the pointer image, convert it to two bits per
  4002. ; pixel and write to the screen for odd scanlines
  4003. mov si,[mode4SelectedPointer]
  4004. add si,48+3
  4005. mov di,bp
  4006. add di,02000h ; offset into video buffer
  4007. ; the video buffer
  4008. mov cl,dl ; number of odd scanlines to draw
  4009. oddsl2:
  4010. mov dx,3
  4011. norept17:
  4012. lodsb ; load 8 pixels from bitmap
  4013. xor bh,bh
  4014. mov bl,al ; copy into a base register
  4015. shl bx,1 ; create a word address
  4016. mov ax,[LUT1to2bit+bx] ; get the byte to word conversion
  4017. xchg al,ah
  4018. mov bx,es:[di] ; get the current displayed 8 pixels
  4019. xor ax,bx ; XOR the XOR mask in
  4020. stosw ; write to the video buffer
  4021. dec dx
  4022. jnz norept17
  4023. add si,3
  4024. add di,80-6
  4025. loop oddsl2
  4026. pop es
  4027. popa
  4028. ret
  4029. ; ANDODD ANDODD ANDODD ANDODD ANDODD ANDODD ANDODD ANDODD ANDODD ANDODD ANDODD
  4030. ;
  4031. ; This part of the code draws the pointer on an odd numbered scanline
  4032. ; of the video display. Since the video buffer is split, 0000 to 1fff
  4033. ; containing even scanlines and 2000 to 3fff containing odd, the data
  4034. ; must be manipulated in a subtly different fashion than that of the
  4035. ; even display scanline code.
  4036. ; The even scanline code display arrangement falls through naturally,
  4037. ; with an even scanline drawing thus:
  4038. ; buffer 0: scanline 0
  4039. ; buffer 1: scanline 0
  4040. ; buffer 0: scanline 1
  4041. ; buffer 1: scanline 1
  4042. ; buffer 0: scanline 2
  4043. ; buffer 1: scanline 2 etc.
  4044. ; whereas in the odd case:
  4045. ; buffer 1: scanline 0
  4046. ; buffer 0: scanline 0
  4047. ; buffer 1: scanline 1
  4048. ; buffer 0: scanline 1
  4049. ; buffer 1: scanline 2
  4050. ; buffer 0: scanline 2 etc.
  4051. ; and this requires that the odd image scanlines must be placed
  4052. ; one scanline lower in the even buffer than the even image scanlines
  4053. ; do in the odd buffer
  4054. drawonoddscanline:
  4055. ; Load a word of the pointer image, convert it to two bits per
  4056. ; pixel and write to the screen for odd scanlines
  4057. mov si,[mode4SelectedPointer]
  4058. add di,02000h ; offset into video buffer
  4059. ; the video buffer
  4060. xor cx,cx
  4061. mov cl,dl ; number of odd scanlines to draw
  4062. push dx
  4063. oddsl3:
  4064. mov dx,3
  4065. norept18:
  4066. lodsb ; load 8 pixels from bitmap
  4067. xor bh,bh
  4068. mov bl,al ; copy into a base register
  4069. shl bx,1 ; create a word address
  4070. mov ax,[LUT1to2bit+bx] ; get the byte to word conversion
  4071. xchg al,ah
  4072. mov bx,es:[di] ; get the current displayed 8 pixels
  4073. and ax,bx ; AND the AND mask in
  4074. stosw ; write to the video buffer
  4075. dec dx
  4076. jnz norept18
  4077. add si,3
  4078. add di,80-6
  4079. loop oddsl3
  4080. pop dx
  4081. ; Load a word of the pointer image, convert it to two bits per
  4082. ; pixel and write to the screen for even scanlines
  4083. and dh,dh
  4084. jz dontdothis1 ; can't do the loop 0 times
  4085. mov si,[mode4SelectedPointer]
  4086. add si,3
  4087. mov di,bp
  4088. add di,6 ; This is required to align the
  4089. ; even and odd scanlines together
  4090. mov cl,dh ; number of even scanlines to draw
  4091. push dx
  4092. evensl3:
  4093. add di,80-6 ; remember even BELOW odd
  4094. mov dx,3
  4095. norept19:
  4096. lodsb ; load 8 pixels from bitmap
  4097. xor bh,bh
  4098. mov bl,al ; copy into a base register
  4099. shl bx,1 ; create a word address
  4100. mov ax,[LUT1to2bit+bx] ; get the byte to word conversion
  4101. xchg al,ah
  4102. mov bx,es:[di] ; get the current displayed 8 pixels
  4103. and ax,bx ; AND the AND mask in
  4104. stosw ; write to the video buffer
  4105. dec dx
  4106. jnz norept19
  4107. add si,3
  4108. loop evensl3
  4109. pop dx
  4110. dontdothis1:
  4111. ; XORODD XORODD XORODD XORODD XORODD XORODD XORODD XORODD XORODD XORODD XORODD
  4112. mov si,[mode4SelectedPointer]
  4113. add si,48
  4114. mov di,bp ; offset into video buffer
  4115. add di,02000h ; offset into video buffer
  4116. ; the video buffer
  4117. ; Load a word of the pointer image, convert it to two bits per
  4118. ; pixel and write to the screen for odd scanlines
  4119. mov cl,dl ; number of odd scanlines to draw
  4120. push dx
  4121. oddsl4:
  4122. mov dx,3
  4123. norept20:
  4124. lodsb ; load 8 pixels from bitmap
  4125. xor bh,bh
  4126. mov bl,al ; copy into a base register
  4127. shl bx,1 ; create a word address
  4128. mov ax,[LUT1to2bit+bx] ; get the byte to word conversion
  4129. xchg al,ah
  4130. mov bx,es:[di] ; get the current displayed 8 pixels
  4131. xor ax,bx ; XOR the XOR mask in
  4132. stosw ; write to the video buffer
  4133. dec dx
  4134. jnz norept20
  4135. add si,3
  4136. add di,80-6
  4137. loop oddsl4
  4138. pop dx
  4139. ; Load a word of the pointer image, convert it to two bits per
  4140. ; pixel and write to the screen for even scanlines
  4141. and dh,dh ; can't do a loop 0 times
  4142. jz dontdothis2
  4143. mov si,[mode4SelectedPointer]
  4144. add si,48+3
  4145. mov di,bp
  4146. add di,6
  4147. mov cl,dh ; number of even scanlines to draw
  4148. evensl4:
  4149. add di,80-6
  4150. mov dx,3
  4151. norept21:
  4152. lodsb ; load 8 pixels from bitmap
  4153. xor bh,bh
  4154. mov bl,al ; copy into a base register
  4155. shl bx,1 ; create a word address
  4156. mov ax,[LUT1to2bit+bx] ; get the byte to word conversion
  4157. xchg al,ah
  4158. mov bx,es:[di] ; get the current displayed 8 pixels
  4159. xor ax,bx ; XOR the XOR mask in
  4160. stosw ; write to the video buffer
  4161. dec dx
  4162. jnz norept21
  4163. add si,3
  4164. loop evensl4
  4165. dontdothis2:
  4166. ; XORXORXORXORXORXORXORXORXORXORXORXORXORXORXORXORXORXORXORXORXORXORXORXOR
  4167. pop es
  4168. popa
  4169. ret
  4170. drawmode4pointer endp
  4171. ;========================================================================
  4172. ; Procedure to determine what the byte and bit offset is, in the current
  4173. ; VGA buffer for the top left hand corner of the pointer bitmap.
  4174. ; The X,Y value is modified for hotspot in this routine.
  4175. ; Y looping counter(ODD and EVEN) are also returned
  4176. ; The CGA buffer is interleaved, and runs from B800:0000 to B800:1999 for
  4177. ; odd scanlines and from B800:2000 for even scanlines.
  4178. ;
  4179. ; INPUT: CX,DX = pointer x,y coordinates
  4180. ; OUT :
  4181. ; carry set if either X or Y is out of screen
  4182. ; DX = byte offset to top left hand pointer pixel of the pointer
  4183. ; CL = bit offset in the byte
  4184. ; CH = 0FFh if ODD, 0 if EVEN
  4185. ; BP = Y loop counter(ODD in LSB and EVEN in MSB)
  4186. ;========================================================================
  4187. detboundmode4 proc near
  4188. push ax
  4189. push bx
  4190. push ds
  4191. mov ax,cs
  4192. mov ds,ax
  4193. assume ds:SpcMseSeg
  4194. ; do the adjustment in x,y for pointer hotspot
  4195. ; modify the raw X,Y values for hotspot
  4196. sub cx,[hotspot] ; adjust the x cartesian coord for hotspot
  4197. jns dont_zero_xmode4; if x goes negative, assume zero
  4198. xor cx,cx
  4199. dont_zero_xmode4:
  4200. sub dx,[hotspot+2] ; adjust the y cartesian coord for the hotspot
  4201. jns dont_zero_ymode4; if y goes negative, assume zero
  4202. xor dx,dx
  4203. dont_zero_ymode4:
  4204. cmp cx, 320 ;
  4205. jae detboundmode4_exit ; CY is cleared
  4206. cmp dx, 200
  4207. jae detboundmode4_exit ; CY is cleared
  4208. ; determine the byte offset from the start of the video buffer
  4209. ; for the modified coordinates. First calculate how many bytes
  4210. ; there are for the number of scanlines -1 to where the pointer
  4211. ; is. Also if the pointer starts on a odd scanline, set CF, else
  4212. ; clear CF.
  4213. mov ax,dx ; copy Y position into AX
  4214. mov bp,dx ; copy Y position into BP for use later
  4215. ; CGA video buffer is split in two. Therefore, screen scanline 0 maps
  4216. ; to video buffer scanline 0 and screen scanline 1 maps to video
  4217. ; buffer+2000h, scanline 0
  4218. and ax,0fffeh ; do the mapping 0->0, 1->0, 2->1, 3->1 etc.
  4219. ; and create a word table index
  4220. mov bx, ax ; copy table index into a base register
  4221. ; 2bits/pixel -> 4 pixels/byte
  4222. ; sine x total is 320, we have 80bytes
  4223. ; so a shl bx, 1 will be wrong.
  4224. mov dx,[mult80lut+bx] ; do a fast LUT multiply by 80
  4225. ; determine the byte position of the pixel in question
  4226. mov ax,cx ; save the x-coordinate displacement
  4227. and ax,3 ; do a modulus 4 to find the pixel position
  4228. ; in the byte. The byte number will be in DX.
  4229. ; add the whole number of bytes in the current row to the number
  4230. ; of complete-row bytes. Note that mode 4 is 2bits per pixel, so
  4231. ; there are four pixels represented by one byte.
  4232. mov bx,cx ; Save in a base reg. to create a table index
  4233. shl bx,1 ; Create a table index for word sized entries
  4234. add dx,[mode4clipCXadjustLUT+bx]; DX hold the complete byte offset.
  4235. mov cx, ax ; CX = bit offset in the byte.
  4236. mov ax, [mode4pointerLUT + bx] ; select appropriate pointer
  4237. mov [mode4SelectedPointer], ax
  4238. ; Odd or Even scanline? note BP contains y cartesian coordinate
  4239. mov bx, bp ; y coordinate
  4240. shr bp, 1 ; shift right to determine if odd or even
  4241. ; CF if odd, or 0 if even.
  4242. sbb ch, ch ; CH = 0FFh if ODD, 0 if EVEN
  4243. shl bx, 1
  4244. mov bp, [mode4clipDXLUT + bx] ;the Y counters
  4245. stc ; we are fine, set the CY so we will return
  4246. ; CY cleared.
  4247. detboundmode4_exit:
  4248. cmc ; revese the CY
  4249. pop ds
  4250. pop bx
  4251. pop ax
  4252. ret
  4253. detboundmode4 endp
  4254. ;=============================================================================
  4255. ; Procedure to save the area of CGA video buffer into which the pointer will
  4256. ; be drawn. The memory buffer in which this data is stored is arranged odd
  4257. ; scanlines first, then even. So, the first 48 bytes are the odd scanline
  4258. ; data.
  4259. ;
  4260. ; Input: DX = byte offset
  4261. ; CL = bit offset in the byte
  4262. ; CH = 0FFh if ODD, 0 if EVEN
  4263. ; BP = Y loop counter, ODD in LSB, EVEN in MSB
  4264. ;
  4265. ;=============================================================================
  4266. savebkgrndmode4 proc near
  4267. pusha
  4268. push es
  4269. push ds
  4270. ; set up the segment registers as required
  4271. mov ax,ds
  4272. mov es,ax
  4273. mov ax,0b800h
  4274. mov ds,ax
  4275. assume ds:nothing, es:SpcMseSeg
  4276. mov si,dx ; start the save.
  4277. or ch, ch
  4278. je svbkeven ; check the returned carry flag
  4279. ; the image's first scanline is odd
  4280. mov di,offset CGAbackgrnd ; where the background will be saved
  4281. mov bx,bp ; set the loop counter up
  4282. xor bh,bh ; don't want unwanted mess in MSB
  4283. add si,2000h ; odd part of buffer starts at 2000h
  4284. svodd1:
  4285. mov cx,3 ; copy six bytes
  4286. rep movsw ; do the image scanline save
  4287. add si,80-6 ; point to the next scanline
  4288. dec bx ; decrement the loop counter
  4289. jnz svodd1 ; do more scanlines if necessary
  4290. ; save some even scanlines if need be.
  4291. mov si,dx ; offset into CGA buffer
  4292. add si, 80
  4293. mov bx,bp ; set up the loop counter
  4294. xchg bl,bh ; get the even part of loop counter
  4295. xor bh,bh ; trash the top end trash
  4296. and bx,bx ; check for a zero loop
  4297. jz misseven ; can't have a loop which execs 0 times
  4298. mov di,offset CGAbackgrnd+48; where the background will be saved
  4299. sveven1:
  4300. mov cx,3 ; copy six bytes = 24 pixels
  4301. rep movsw ; do the scanline save
  4302. add si,80-6 ; point to the next scanline
  4303. dec bx ; decrement the loop counter
  4304. jnz sveven1 ; do more scanlines if necessary
  4305. misseven: ; jump to here if there are no even scanlines to draw
  4306. jmp short endsavemode4
  4307. svbkeven: ; the image's first scanline is even
  4308. mov di,offset CGAbackgrnd+48; where the background will be saved
  4309. mov bx,bp ; get the loop counter
  4310. xchg bl,bh ; rearrage to get the even part
  4311. xor bh,bh ; clear out the trash
  4312. sveven2:
  4313. mov cx,3 ; copy six bytes
  4314. rep movsw ; do the copy
  4315. add si,80-6 ; point to the next scanline
  4316. dec bx ; decrement the loop counter
  4317. jnz sveven2 ; do more scanlines if necessary
  4318. mov si,dx ; offset into CGA buffer
  4319. add si,2000h ; odd part of the video buffer
  4320. mov di,offset CGAbackgrnd ; where to save the odd scanlines
  4321. mov bx,bp ; get the loop counter
  4322. xor bh,bh ; clear out the unwanted trash
  4323. svodd2:
  4324. mov cx,3 ; copy six bytes
  4325. rep movsw ; do the copy
  4326. add si,80-6 ; point to the next scanline
  4327. dec bx ; decrement the loop counter
  4328. jnz svodd2 ; do more scanlines if necessary
  4329. endsavemode4:
  4330. assume ds:SpcMseSeg, es:nothing
  4331. pop ds
  4332. pop es
  4333. popa
  4334. ret
  4335. savebkgrndmode4 endp
  4336. ;=============================================================================
  4337. ; Procedure to restore the area of CGA video buffer into which the pointer
  4338. ; was drawn. The memory buffer in which this data is stored is arranged
  4339. ; odd scanlines first, then even. So, the first 48 bytes are the odd scanline
  4340. ; data.
  4341. ;
  4342. ; Input:
  4343. ; DX = byte offset to top left hand pointer pixel of the pointer
  4344. ; CL = bit offset in the byte
  4345. ; CH = 0FFh if ODD, 0 if EVEN
  4346. ; BP = Y loop counter(ODD in LSB and EVEN in MSB)
  4347. ;
  4348. ;=============================================================================
  4349. restorebkgrndmode4 proc near
  4350. pusha
  4351. push es
  4352. ; set up the segment registers as required
  4353. mov ax,0b800h
  4354. mov es,ax
  4355. mov di,dx ; restore background
  4356. or ch, ch
  4357. je rsbkeven ; check the returned carry flag
  4358. ; the image's first scanline is odd. The CGA buffer is translated
  4359. ; so that a scanline (row N) from the even part of the buffer appears
  4360. ; on the screen at raster I. The scanline at position N from the
  4361. ; odd part of the video buffer maps to screen position I+1. If the
  4362. ; 1st. scanline is odd, then this is drawn at raster A and the
  4363. ; following algorithm draws the 1st. even row at raster A+1 to
  4364. ; compensate for the video buffer arrangement.
  4365. mov si,offset CGAbackgrnd ; where the background is be saved
  4366. add di,2000h ; do the odd buffer
  4367. mov bx,bp ; set the loop counter up
  4368. xor bh,bh ; clear out the MSB trash
  4369. rsodd1:
  4370. mov cx,3 ; copy six bytes
  4371. rep movsw ; do the restore
  4372. add di,80-6 ; point to the next odd scanline
  4373. dec bx ; decrement the loop counter
  4374. jnz rsodd1 ; restore more even scanlines if needed
  4375. mov bx,bp ; let the loop counter
  4376. xchg bl,bh ; get the even part
  4377. xor bh,bh ; clear out the MSB trash
  4378. and bx,bx ; test for zero even scanlines
  4379. jz misseven1rs ; can't have a zero execute loop
  4380. mov di,dx ; offset into CGA buffer
  4381. add di,80 ; get the odd/even scanlines instep
  4382. mov si,offset CGAbackgrnd+48; where the background is be saved
  4383. rseven1:
  4384. mov cx,3 ; restore six bytes
  4385. rep movsw ; do the restore
  4386. add di,80-6 ; point to the next even scanline
  4387. dec bx ; decrement the loop counter
  4388. jnz rseven1 ; restore more even scanlines if needed
  4389. misseven1rs: ; jump to here if there are no even scanlines to be restored.
  4390. jmp short endrestoremode4
  4391. rsbkeven: ; the image's first scanline is even
  4392. mov si,offset CGAbackgrnd+48; where the background will be saved
  4393. mov bx,bp ; get the loop counter
  4394. xchg bl,bh ; get the even part of the loop counter
  4395. xor bh,bh ; scrap the MSB trash
  4396. rseven2:
  4397. mov cx,3 ; restore six bytes
  4398. rep movsw ; do the restore
  4399. add di,80-6 ; point to the next even scanline
  4400. dec bx ; decrement the loop counter
  4401. jnz rseven2 ; do more even scanlines if needed
  4402. mov di,dx ; offset into CGA buffer
  4403. add di,2000h ; do the odd buffer
  4404. mov si,offset CGAbackgrnd ; where to save the odd scanlines
  4405. mov bx,bp ; set the loop counter up
  4406. xor bh,bh ; scrap the MSB trash
  4407. rsodd2:
  4408. mov cx,3 ; restore six bytes
  4409. rep movsw ; do the restore
  4410. add di,80-6 ; point to the next odd scanline
  4411. dec bx ; decrement the loop counter
  4412. jnz rsodd2 ; restore more odd scanlines if needed
  4413. endrestoremode4:
  4414. assume ds:SpcMseSeg, es:nothing
  4415. pop es
  4416. popa
  4417. ret
  4418. restorebkgrndmode4 endp
  4419. ;============================================================================
  4420. ; Procedure to draw the pointer image into the video buffer for mode 13h
  4421. ; VGA graphics.
  4422. ;
  4423. ; Input:
  4424. ; DX = byte offset
  4425. ; BP = Y loop counter
  4426. ; CX = X loop counter
  4427. ;
  4428. ;============================================================================
  4429. draw256pointer proc near
  4430. pusha
  4431. push es
  4432. push ds
  4433. mov ax,0a000h ; point to the 256 colour mode video buffer
  4434. mov es,ax
  4435. mov ax,cs
  4436. mov ds,ax
  4437. assume ds:SpcMseSeg, es:nothing
  4438. cld ; write forward through the buffer
  4439. ; DX = TLHC pixel offset in the video buffer.
  4440. mov di,dx ; point DI at the video buffer location of fun
  4441. mov si, offset current_cursor ; we only use this cursor shape
  4442. ; because every pixel is on byte
  4443. ; boundary. The X counter would
  4444. ; take care of X clipping
  4445. y_256:
  4446. push cx
  4447. lodsw ;and mask
  4448. mov dx, [si + 48 - 2] ;xor mask
  4449. inc si ;we don't need the third byte
  4450. xchg al, ah ; byte sequence
  4451. xchg dh, dl ;
  4452. x_256:
  4453. shl ax, 1 ;AND mask bit
  4454. sbb bl, bl ; bl = 0FFf if CY, 0 if not CY
  4455. and bl, es:[di] ;and the target and save the result
  4456. shl dx, 1 ;XOR mask bit
  4457. sbb bh, bh ;
  4458. xor bl, bh ;xor with the save result
  4459. mov es:[di], bl ;update the target
  4460. inc di ;next pixel
  4461. loop x_256 ;until this scan line is done
  4462. pop cx ;recovery X loop counter
  4463. add di, 320 ;target address to next scan line
  4464. sub di, cx
  4465. dec bp ;Y counter
  4466. jne y_256
  4467. pop ds
  4468. pop es
  4469. popa
  4470. ret
  4471. draw256pointer endp
  4472. ;=============================================================================
  4473. ; Procedure to save the area of 256 colour mode video buffer into which the
  4474. ; pointer will be drawn. The memory buffer in which this data is stored is
  4475. ; arranged odd scanlines first, then even. So, the first 48 bytes are the odd
  4476. ; scanline data.
  4477. ;
  4478. ; Input:
  4479. ; DX = byte offset
  4480. ; BP = Y loop counter
  4481. ; CX = X loop counter
  4482. ;
  4483. ;=============================================================================
  4484. savebkgrndmode13 proc near
  4485. pusha
  4486. push es
  4487. push ds
  4488. mov di,offset bkgrnd256 ; point to the area in which backgound
  4489. ; data will be saved
  4490. mov si,dx ; SOURCE: the video buffer at x,y
  4491. mov ax,0a000h
  4492. mov ds,ax
  4493. mov ax,cs
  4494. mov es,ax
  4495. mov bx, cx ;x counter
  4496. mov dx, 320
  4497. sub dx, bx
  4498. assume ds:nothing, es:SpcMseSeg
  4499. cld
  4500. save_256_loop:
  4501. mov cx, bx
  4502. shr cx, 1
  4503. rep movsw
  4504. adc cl, 0
  4505. rep movsb
  4506. add si, dx ; next scan line offset
  4507. dec bp ; until Y counter is done
  4508. jne save_256_loop
  4509. pop ds
  4510. pop es
  4511. assume es:nothing, ds:SpcMseSeg
  4512. popa
  4513. ret
  4514. savebkgrndmode13 endp
  4515. ;=============================================================================
  4516. ; Procedure to replace an existing pointer image in the 256 colour video
  4517. ; buffer with the data that was there previous to the pointer draw operation.
  4518. ; The data is stored in an internal (to the driver) buffer.
  4519. ;
  4520. ; Input:
  4521. ; DX = byte offset
  4522. ; BP = Y loop counter
  4523. ; CX = X loop counter
  4524. ;
  4525. ;=============================================================================
  4526. restorebkgrndmode13 proc near
  4527. pusha
  4528. push es
  4529. mov di,dx ; DESTINATION: in the VRAM
  4530. mov ax,0a000h ; point a segment register at video buffer
  4531. mov es,ax
  4532. assume es:nothing
  4533. mov bx, cx
  4534. mov si,offset bkgrnd256 ; where the data is saved
  4535. mov dx, 320
  4536. sub dx, bx
  4537. cld ; write forward in memory
  4538. restore_256_loop:
  4539. mov cx, bx
  4540. shr cx, 1
  4541. rep movsw
  4542. adc cl, 0
  4543. rep movsb
  4544. add di, dx
  4545. dec bp
  4546. jne restore_256_loop
  4547. pop es
  4548. popa
  4549. ret
  4550. restorebkgrndmode13 endp
  4551. ;========================================================================
  4552. ; Procedure to determine what the byte offset is, in the current
  4553. ; VGA buffer for the top left hand corner of the pointer bitmap.
  4554. ; The X,Y value is modified for hotspot in this routine. X and Y looping
  4555. ; counters are also returned.
  4556. ;
  4557. ; INPUT: CX,DX = pointer x,y coordinates
  4558. ; OUT :
  4559. ; carry set if either X or Y is out of screen
  4560. ; DX = byte offset to top left hand pointer pixel of the pointer
  4561. ; CX = X counter
  4562. ; BP = Y counter
  4563. ;========================================================================
  4564. detboundmode13 proc near
  4565. push ax
  4566. push bx
  4567. push ds
  4568. mov ax,cs
  4569. mov ds,ax
  4570. assume ds:SpcMseSeg
  4571. ; do the adjustment in x,y for pointer hotspot
  4572. ; modify the raw X,Y values for hotspot
  4573. sub cx,[hotspot] ; adjust the x cartesian coord for hotspot
  4574. jns dont_zero_xmode13; if x goes negative, assume zero
  4575. xor cx,cx
  4576. dont_zero_xmode13:
  4577. sub dx,[hotspot+2] ; adjust the y cartesian coord for the hotspot
  4578. jns dont_zero_ymode13; if y goes negative, assume zero
  4579. xor dx,dx
  4580. dont_zero_ymode13:
  4581. cmp cx, 320
  4582. jae detboundmode13_exit ; CY is cleared
  4583. cmp dx, 200 ;
  4584. jae detboundmode13_exit ; CY is cleared
  4585. ; CX and DX are now validated for the following section: buffer
  4586. ; offset determination. Note, unlike other video modes, mode 13
  4587. ; provides a direct mapping of the video display to video buffer.
  4588. ; in other words; 1 byte represents 1 pixel. From this, it is not
  4589. ; necessary to provide byte alignment data.
  4590. mov bx,dx ; save in a base register
  4591. shl bx,1 ; create a word table index
  4592. mov dx,[mult320LUT+bx] ; do the multiply by 320
  4593. ; add in the offset along the current raster.
  4594. add dx,cx ; cx contains the byte offset from
  4595. mov ax,[mode4clipDXLUT + bx]; get Y loop counter from table
  4596. add al, ah ; the table has ODD/EVEN counters
  4597. cbw
  4598. mov bp, ax ; the final Y counter
  4599. ; column 0.
  4600. mov ax, 320 ; calculate X loop counter
  4601. sub ax, cx
  4602. cmp ax, 16 ;
  4603. jl set_new_x_counter
  4604. mov ax, 16
  4605. set_new_x_counter:
  4606. mov cx, ax ; X counter
  4607. stc ; everything is fine, set CY
  4608. ; so we will return CY cleared
  4609. detboundmode13_exit:
  4610. cmc ; complement the CY
  4611. pop ds
  4612. pop bx
  4613. pop ax
  4614. ret
  4615. detboundmode13 endp
  4616. public SpcMseEnd
  4617. SpcMseEnd label byte
  4618. ;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  4619. ;
  4620. ; Installation Code From Here Downwards
  4621. ;
  4622. ;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  4623. ; segment:offset table for redirected mouse functions for real rom version.
  4624. ifdef DBCS
  4625. mio_table dw 42 dup(?)
  4626. else ; !DBCS
  4627. mio_table dw 38 dup(?)
  4628. endif ; !DBCS
  4629. assume cs:SpcMseSeg,ds:nothing,es:nothing
  4630. public InstSpcMse
  4631. ;
  4632. ; InstSpcMse - Installs the softpc mouse driver code
  4633. ;
  4634. ; Inputs: ds == Resident location of SpcMseSeg
  4635. ; Outputs: None
  4636. ;
  4637. InstSpcMse proc near
  4638. ;;;;;;;;;;;;;;;;do ret to use old mouse driver;;; ret
  4639. pusha
  4640. ifdef DBCS
  4641. push ds
  4642. mov ax, 6300h
  4643. int 21h
  4644. mov ax, ds
  4645. pop ds
  4646. jc got_dbcs_vector
  4647. mov ds:dbcs_vector_off, si
  4648. mov ds:dbcs_vector_seg, ax
  4649. got_dbcs_vector:
  4650. endif ; DBCS
  4651. ; save old int 10 vector
  4652. xor ax,ax
  4653. mov es,ax
  4654. mov ax,es:[40h]
  4655. mov si,offset old_vid_int
  4656. mov word ptr ds:[si],ax
  4657. mov ax,es:[42h]
  4658. mov word ptr ds:[si+2],ax
  4659. ifdef DBCS
  4660. mov es:[40], offset DBCS_mouse_int10
  4661. mov ax, cs
  4662. mov es:[42], ax
  4663. endif ; DBCS
  4664. mov bx,ds
  4665. mov si,offset sysinitgrp:mio_table
  4666. push ds
  4667. push cs
  4668. pop ds
  4669. mov word ptr ds:[si], offset mouse_io
  4670. mov word ptr ds:[si+2],bx
  4671. IFDEF MOUSE_VIDEO_BIOS
  4672. mov word ptr ds:[si+4],offset mouse_video_io
  4673. mov word ptr ds:[si+6],bx
  4674. ENDIF ; MOUSE_VIDEO_BIOS
  4675. mov word ptr ds:[si+8],offset mouse_int1
  4676. mov word ptr ds:[si+10],bx
  4677. mov word ptr ds:[si+12], offset mouse_version
  4678. mov word ptr ds:[si+14],bx
  4679. mov word ptr ds:[si+16],offset mouse_copyright
  4680. mov word ptr ds:[si+18],bx
  4681. mov word ptr ds:[si+20],offset video_io
  4682. mov word ptr ds:[si+22],bx
  4683. mov word ptr ds:[si+24],offset mouse_int2
  4684. mov word ptr ds:[si+26],bx
  4685. mov word ptr ds:[si+28],offset entry_point_from_32bit
  4686. mov word ptr ds:[si+30],bx
  4687. mov word ptr ds:[si+32],offset int33function0
  4688. mov word ptr ds:[si+34],bx
  4689. mov word ptr ds:[si+36],offset int33function1
  4690. mov word ptr ds:[si+38],bx
  4691. mov word ptr ds:[si+40],offset int33function2
  4692. mov word ptr ds:[si+42],bx
  4693. mov word ptr ds:[si+44],offset int33function9
  4694. mov word ptr ds:[si+46],bx
  4695. mov word ptr ds:[si+48],offset current_position_x
  4696. mov word ptr ds:[si+50],bx
  4697. mov word ptr ds:[si+52],offset current_position_y
  4698. mov word ptr ds:[si+54],bx
  4699. mov word ptr ds:[si+56],offset mouseINB
  4700. mov word ptr ds:[si+58],bx
  4701. mov word ptr ds:[si+60],offset mouseOUTB
  4702. mov word ptr ds:[si+62],bx
  4703. mov word ptr ds:[si+64],offset mouseOUTW
  4704. mov word ptr ds:[si+66],bx
  4705. mov word ptr ds:[si+68],offset VRAMlasttextcelloff
  4706. mov word ptr ds:[si+70],bx
  4707. mov word ptr ds:[si+72],offset internalCF
  4708. mov word ptr ds:[si+74],bx
  4709. mov word ptr ds:[si+76],offset function3data
  4710. mov word ptr ds:[si+78],bx
  4711. mov word ptr ds:[si+80],offset conditional_off
  4712. mov word ptr ds:[si+82],bx
  4713. ifdef DBCS
  4714. mov word ptr ds:[si+84], offset saved_ac_on_mouse_cursor
  4715. mov word ptr ds:[si+86],bx
  4716. mov word ptr ds:[si+88], offset background
  4717. mov word ptr ds:[si+90],bx
  4718. endif ; DBCS
  4719. pop ds
  4720. mov bx, offset sysinitgrp:mio_table
  4721. bop 0C8h ; Host mouse installer BOP
  4722. ; get the freshly written int 33h vector from IVT
  4723. ; write the vector segment:offset data to the jump patch
  4724. xor ax,ax
  4725. mov es,ax
  4726. mov ax,es:[33h*4]
  4727. mov bx,es:[(33h*4)+2]
  4728. mov si,offset moff
  4729. mov word ptr ds:[si],ax
  4730. mov word ptr ds:[si+2],bx
  4731. add ax,2 ; HLL entry point
  4732. mov si,offset loffset
  4733. mov word ptr ds:[si],ax
  4734. mov word ptr ds:[si+2],bx
  4735. ; write the new value to the IVT
  4736. call DOCLI
  4737. mov bx, offset int33h_vector
  4738. mov word ptr es:[33h*4], bx
  4739. mov bx, ds
  4740. mov word ptr es:[(33h*4)+2], bx
  4741. call DOSTI
  4742. popa
  4743. ret
  4744. InstSpcMse endp
  4745. SpcMseSeg ends
  4746. end