VESA.ASM 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029
  1. ;THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
  2. ;SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
  3. ;END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
  4. ;ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
  5. ;IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
  6. ;SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
  7. ;FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
  8. ;CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
  9. ;AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
  10. ;COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
  11. ;
  12. ; $Source: f:/miner/source/2d/rcs/vesa.asm $
  13. ; $Revision: 1.20 $
  14. ; $Author: john $
  15. ; $Date: 1994/07/27 15:43:37 $
  16. ;
  17. ; Routines to access VESA VGA memory
  18. ;
  19. ; $Log: vesa.asm $
  20. ; Revision 1.20 1994/07/27 15:43:37 john
  21. ; Fixed bug with allocation dos memory more than once.
  22. ;
  23. ; Revision 1.19 1994/06/24 17:27:02 john
  24. ; Made rowsizes bigger than actual screen work with SVGA.
  25. ;
  26. ; Revision 1.18 1994/05/31 11:10:45 john
  27. ; *** empty log message ***
  28. ;
  29. ; Revision 1.17 1994/05/06 12:50:21 john
  30. ; Added supertransparency; neatend things up; took out warnings.
  31. ;
  32. ; Revision 1.16 1994/03/14 16:56:29 john
  33. ; Changed grs_bitmap structure to include bm_flags.
  34. ;
  35. ; Revision 1.15 1994/02/02 11:27:22 john
  36. ; *** empty log message ***
  37. ;
  38. ; Revision 1.14 1994/01/25 11:40:46 john
  39. ; Added gr_check_mode function.
  40. ;
  41. ; Revision 1.13 1994/01/13 14:41:51 unknown
  42. ; Fixed bug with Error 7 return Error 8.
  43. ;
  44. ; Revision 1.12 1993/12/21 19:58:38 john
  45. ; made rep movsb in scanline be rep movsw
  46. ;
  47. ; Revision 1.11 1993/12/09 16:05:51 john
  48. ; Made no VESA driver detection work correctly
  49. ;
  50. ; Revision 1.10 1993/12/09 15:02:41 john
  51. ; Changed palette stuff majorly
  52. ;
  53. ; Revision 1.9 1993/11/16 11:28:28 john
  54. ; *** empty log message ***
  55. ;
  56. ; Revision 1.8 1993/10/26 13:18:03 john
  57. ; *** empty log message ***
  58. ;
  59. ; Revision 1.7 1993/10/15 16:23:28 john
  60. ; y
  61. ;
  62. ; Revision 1.6 1993/09/29 17:31:10 john
  63. ; optimized gr_vesa_pixel
  64. ;
  65. ; Revision 1.5 1993/09/26 18:59:34 john
  66. ; fade stuff
  67. ;
  68. ; Revision 1.4 1993/09/20 14:47:20 john
  69. ; *** empty log message ***
  70. ;
  71. ; Revision 1.3 1993/09/13 17:54:07 john
  72. ; Minor bug fix
  73. ;
  74. ; Revision 1.2 1993/09/08 15:56:06 john
  75. ; Started adding DPMI support for SVGA paging.
  76. ;
  77. ; Revision 1.1 1993/09/08 11:41:25 john
  78. ; Initial revision
  79. ;
  80. ;
  81. ;
  82. .386
  83. OPTION OLDSTRUCTS
  84. INCLUDE VGAREGS.INC
  85. INCLUDE GR.INC
  86. _DATA SEGMENT BYTE PUBLIC USE32 'DATA'
  87. PUBLIC __A0000
  88. __A0000 dw ?
  89. BufferPtr dd 0
  90. BufferSeg dw 0
  91. GoalMode dw ?
  92. LastPage db 0FFh
  93. BPR dw ?
  94. TempReg dd ?
  95. ; Information from VESA return SuperVGA Information
  96. VESAVersion dw ?
  97. OEMStringPtr dd ?
  98. Capabilities dd ?
  99. VideoModePtr dd ?
  100. TotalMemory dw ?
  101. WinGranularity dw ?
  102. WinSize dw ?
  103. WinFuncPtr dd ?
  104. PageSizeShift db ?
  105. VESA_Signature = 041534556h
  106. REALREGS STRUCT
  107. RealEDI dd ?
  108. RealESI dd ?
  109. RealEBP dd ?
  110. Reserved dd ?
  111. RealEBX dd ?
  112. RealEDX dd ?
  113. RealECX dd ?
  114. RealEAX dd ?
  115. RealFlags dw ?
  116. RealES dw ?
  117. RealDS dw ?
  118. RealFS dw ?
  119. RealGS dw ?
  120. RealIP dw ?
  121. RealCS dw ?
  122. RealSP dw ?
  123. RealSS dw ?
  124. REALREGS ENDS
  125. regs REALREGS < >
  126. vesa_error dd ?
  127. SourceInc dd ?
  128. DestInc dw ?
  129. RowWidth dd ?
  130. extern _gr_var_color:dword, _gr_var_bwidth:dword
  131. _DATA ENDS
  132. DGROUP GROUP _DATA
  133. _TEXT SEGMENT BYTE PUBLIC USE32 'CODE'
  134. ASSUME DS:_DATA
  135. ASSUME CS:_TEXT
  136. MyStosd MACRO Width:REQ
  137. ; Assumes: EDI = Dest Address
  138. ; Width = a 32-bit value, can't be ECX or EDI
  139. ; Trashes: ECX will be zero
  140. ; EDI = Dest Address + Width
  141. ; EDX = ????
  142. ; Width
  143. LOCAL Aligned
  144. cmp Width, 16
  145. jbe Aligned
  146. mov ecx, edi
  147. and ecx, 3
  148. jcxz Aligned
  149. neg ecx
  150. add ecx, 4
  151. sub Width, ecx
  152. rep stosb
  153. Aligned: mov ecx, Width
  154. shr ecx, 2
  155. rep stosd
  156. mov ecx, Width
  157. and ecx, 3
  158. rep stosb
  159. ENDM
  160. ENTER_PROC MACRO
  161. push esi
  162. push edi
  163. push ebp
  164. push eax
  165. push ebx
  166. push ecx
  167. push edx
  168. ENDM
  169. EXIT_PROC MACRO
  170. cmp [esp-4], edx
  171. je @f
  172. ; YOU TRASHED EDX !!!!!!!
  173. int 3
  174. @@: pop edx
  175. cmp [esp-4], ecx
  176. je @f
  177. ; YOU TRASHED ECX !!!!!!!
  178. int 3
  179. @@: pop ecx
  180. cmp [esp-4], ebx
  181. je @f
  182. ; YOU TRASHED EBX !!!!!!!
  183. int 3
  184. @@: pop ebx
  185. cmp [esp-4], eax
  186. je @f
  187. ; YOU TRASHED EAX !!!!!!!
  188. int 3
  189. @@: pop eax
  190. cmp [esp-4], ebp
  191. je @f
  192. ; YOU TRASHED EBP !!!!!!!
  193. int 3
  194. @@: pop ebp
  195. cmp [esp-4], edi
  196. je @f
  197. ; YOU TRASHED EDI !!!!!!!
  198. int 3
  199. @@: pop edi
  200. cmp [esp-4], esi
  201. je @f
  202. ; YOU TRASHED ESI !!!!!!!
  203. int 3
  204. @@: pop esi
  205. ENDM
  206. MyMovsd MACRO Width:REQ
  207. ; Assumes: EDI = Dest Address
  208. ; ESI = Source Address
  209. ; Width = a 32-bit value, can't be ECX or EDI or ESI
  210. ; Assumes that ESI is already aligned
  211. ; Trashes: ECX will be zero
  212. ; EDI = Dest Address + Width
  213. ; ESI = Source Address + Width
  214. ; EDX = ????
  215. LOCAL Aligned
  216. cmp Width, 16
  217. jbe Aligned
  218. mov ecx, edi
  219. and ecx, 3
  220. jcxz Aligned
  221. neg ecx
  222. add ecx, 4
  223. sub Width, ecx
  224. rep movsb
  225. Aligned: mov ecx, Width
  226. shr ecx, 2
  227. rep movsd
  228. mov ecx, Width
  229. and ecx, 3
  230. rep movsb
  231. ENDM
  232. EBXFarTo32:
  233. push ecx
  234. mov ecx, ebx
  235. and ecx, 0FFFF0000h
  236. shr ecx, 12
  237. and ebx, 0FFFFh
  238. add ebx, ecx
  239. pop ecx
  240. ret
  241. PUBLIC gr_init_A0000_
  242. gr_init_A0000_:
  243. push ebx
  244. mov ax, 0002h
  245. mov bx, 0a000h
  246. int 31h
  247. jc NoGo
  248. mov __A0000, ax
  249. pop ebx
  250. xor eax, eax
  251. ret
  252. NoGo: pop ebx
  253. mov eax, 1
  254. ret
  255. PUBLIC gr_vesa_checkmode_
  256. gr_vesa_checkmode_:
  257. pushad
  258. mov GoalMode, ax
  259. cmp BufferSeg, 0
  260. jne GotDosMemory
  261. ; Allocate a 256 byte block of DOS memory using DPMI
  262. mov ax, 0100h
  263. mov bx, 16
  264. int 31h
  265. jc NoMemory
  266. ; AX = real mode segment of allocated block
  267. and eax, 0FFFFh
  268. mov BufferSeg, ax
  269. shl eax, 4 ; EAX = 32-bit pointer to DOS memory
  270. mov BufferPtr, eax
  271. GotDosMemory:
  272. ; Get SuperVGA information
  273. mov ax, BufferSeg
  274. mov regs.RealEDI, 0
  275. mov regs.RealESI, 0
  276. mov regs.RealEBP, 0
  277. mov regs.Reserved, 0
  278. mov regs.RealEBX, 0
  279. mov regs.RealEDX, 0
  280. mov regs.RealECX, 0
  281. mov regs.RealEAX, 04f00h
  282. mov regs.RealFlags, 0
  283. mov regs.RealES, ax
  284. mov regs.RealDS, 0
  285. mov regs.RealFS, 0
  286. mov regs.RealGS, 0
  287. mov regs.RealIP, 0
  288. mov regs.RealCS, 0
  289. mov regs.RealSP, 0
  290. mov regs.RealSS, 0
  291. mov bl, 10h
  292. xor bh, bh
  293. xor ecx, ecx
  294. mov edi, offset regs
  295. mov ax, 0300h
  296. int 31h
  297. mov eax, regs.RealEAX
  298. cmp ax, 04fh
  299. jne NoVESADriver
  300. ; Make sure there is a VESA signature
  301. mov eax, BufferPtr
  302. cmp dword ptr[eax+0], VESA_Signature
  303. jne NoVESADriver
  304. ; We now have a valid VESA driver loaded
  305. mov bx, word ptr [eax+4]
  306. mov VESAVersion, bx
  307. mov ebx, dword ptr [eax+6]
  308. call EBXFarTo32
  309. mov OEMStringPtr, ebx
  310. mov ebx, dword ptr [eax+10]
  311. mov Capabilities, ebx
  312. mov bx, word ptr [eax+18]
  313. mov TotalMemory, bx
  314. mov ebx, dword ptr [eax+14]
  315. call EBXFarTo32
  316. mov VideoModePtr, ebx
  317. TryAnotherMode:
  318. mov ax, word ptr [ebx]
  319. add ebx, 2
  320. cmp ax, GoalMode
  321. je ModeSupported
  322. cmp ax, -1
  323. je ModeNotSupported
  324. jmp TryAnotherMode
  325. ModeSupported:
  326. ; Get SuperVGA information
  327. mov ax, BufferSeg
  328. movzx ecx, GoalMode
  329. mov regs.RealEDI, 0
  330. mov regs.RealESI, 0
  331. mov regs.RealEBP, 0
  332. mov regs.Reserved, 0
  333. mov regs.RealEBX, 0
  334. mov regs.RealEDX, 0
  335. mov regs.RealECX, ecx
  336. mov regs.RealEAX, 04f01h
  337. mov regs.RealFlags, 0
  338. mov regs.RealES, ax
  339. mov regs.RealDS, 0
  340. mov regs.RealFS, 0
  341. mov regs.RealGS, 0
  342. mov regs.RealIP, 0
  343. mov regs.RealCS, 0
  344. mov regs.RealSP, 0
  345. mov regs.RealSS, 0
  346. mov bl, 10h
  347. xor bh, bh
  348. xor cx, cx
  349. mov edi, offset regs
  350. mov ax, 0300h
  351. int 31h
  352. mov eax, regs.RealEAX
  353. cmp ax, 04fh
  354. jne BadStatus
  355. ; Check if this mode supported by hardware.
  356. mov eax, BufferPtr
  357. mov bx, [eax]
  358. bt bx, 0
  359. jnc HardwareNotSupported
  360. mov bx, [eax+4]
  361. cmp bx, 64
  362. jne @f
  363. mov PageSizeShift, 0
  364. jmp GranularityOK
  365. @@: cmp bx, 32
  366. jne @f
  367. mov PageSizeShift, 1
  368. jmp GranularityOK
  369. @@: cmp bx, 16
  370. jne @f
  371. mov PageSizeShift, 2
  372. jmp GranularityOK
  373. @@: cmp bx, 8
  374. jne @f
  375. mov PageSizeShift, 3
  376. jmp GranularityOK
  377. @@: cmp bx, 4
  378. jne @f
  379. mov PageSizeShift, 4
  380. jmp GranularityOK
  381. @@: cmp bx, 2
  382. jne @f
  383. mov PageSizeShift, 5
  384. jmp GranularityOK
  385. @@: cmp bx, 1
  386. jne WrongGranularity
  387. mov PageSizeShift, 6
  388. GranularityOK:
  389. shl bx, 10
  390. mov WinGranularity, bx
  391. mov bx, [eax+6]
  392. mov WinSize, bx
  393. mov ebx, [eax+12]
  394. call EBXFarTo32
  395. mov WinFuncPtr, ebx
  396. movzx ebx, word ptr [eax+16]
  397. NoError:
  398. mov vesa_error, 0
  399. jmp Done
  400. WrongGranularity:
  401. mov vesa_error, 2
  402. jmp Done
  403. HardwareNotSupported:
  404. mov vesa_error, 3
  405. jmp Done
  406. ModeNotSupported:
  407. mov vesa_error, 4
  408. jmp Done
  409. NoVESADriver:
  410. mov vesa_error, 5
  411. jmp Done
  412. BadStatus:
  413. mov vesa_error, 6
  414. jmp Done
  415. NoMemory:
  416. mov vesa_error, 7
  417. jmp Done
  418. DPMIError:
  419. mov vesa_error, 8
  420. Done: popad
  421. mov eax, vesa_error
  422. ret
  423. PUBLIC gr_get_dos_mem_
  424. gr_get_dos_mem_:
  425. ; eax = how many bytes
  426. push ebx
  427. mov ebx, eax
  428. shr ebx, 4
  429. mov eax, 0100h
  430. int 31h
  431. jc nomem
  432. and eax, 0ffffh
  433. shl eax, 4
  434. pop ebx
  435. ret
  436. nomem: pop ebx
  437. mov eax,0
  438. ret
  439. PUBLIC gr_vesa_setmodea_
  440. gr_vesa_setmodea_:
  441. ; eax = mode
  442. pushad
  443. mov ebx, eax
  444. mov eax, 04f02h
  445. int 10h
  446. cmp ax, 04fh
  447. jne BadStatus
  448. jmp NoError
  449. PUBLIC gr_vesa_setpage_
  450. gr_vesa_setpage_:
  451. ; EAX = 64K Page number
  452. cmp al, LastPage
  453. jne @f
  454. ret
  455. @@: mov LastPage, al
  456. push edx
  457. push ebx
  458. push ecx
  459. mov edx, eax
  460. mov cl, PageSizeShift
  461. shl edx, cl ; Convert from 64K pages to GranUnit pages.
  462. xor ebx, ebx ; BH=Select window, BL=Window A
  463. mov eax, 04f05h ; AX=Super VGA video memory window control
  464. int 10h
  465. pop ecx
  466. pop ebx
  467. pop edx
  468. ret
  469. PUBLIC gr_vesa_setaddress_
  470. gr_vesa_setaddress_:
  471. ; EAX = Address of video memory to write to
  472. push edx
  473. push ebx
  474. push ecx
  475. mov edx, eax
  476. shl edx, 12 ; Convert from address pages to 4k GranUnit pages.
  477. xor ebx, ebx ; BH=Select window, BL=Window A
  478. mov eax, 04f05h ; AX=Super VGA video memory window control
  479. int 10h
  480. pop ecx
  481. pop ebx
  482. pop edx
  483. ret
  484. PUBLIC gr_vesa_incpage_
  485. gr_vesa_incpage_:
  486. push eax
  487. push ebx
  488. push ecx
  489. push edx
  490. push ebp
  491. inc LastPage
  492. mov dl, LastPage
  493. mov cl, PageSizeShift
  494. shl edx, cl ; Convert from 64K pages to GranUnit pages.
  495. xor ebx, ebx ; BH=Select window, BL=Window A
  496. mov eax, 04f05h ; AX=Super VGA video memory window control
  497. int 10h
  498. pop ebp
  499. pop edx
  500. pop ecx
  501. pop ebx
  502. pop eax
  503. ret
  504. PUBLIC gr_vesa_setstart_
  505. gr_vesa_setstart_:
  506. ; EAX = First column
  507. ; EDX = First row
  508. push ebx
  509. push ecx
  510. mov ecx, eax
  511. mov eax, 4f07h
  512. xor ebx, ebx
  513. int 10h
  514. pop ecx
  515. pop ebx
  516. ret
  517. PUBLIC gr_vesa_setlogical_
  518. gr_vesa_setlogical_:
  519. ; EAX = line width
  520. push ebx
  521. push ecx
  522. push edx
  523. mov cx, ax
  524. mov ax, 04f06h
  525. mov bl, 0
  526. int 10h
  527. and ebx, 0FFFFh
  528. mov ax, cx
  529. pop edx
  530. pop ecx
  531. pop ebx
  532. ret
  533. PUBLIC gr_vesa_scanline_
  534. gr_vesa_scanline_:
  535. ; EAX = x1
  536. ; EDX = x2
  537. ; EBX = y
  538. ; ECX = color
  539. push edi
  540. cld
  541. cmp edx, eax
  542. jge @f
  543. xchg edx, eax
  544. @@: mov edi, ebx
  545. imul edi, _gr_var_bwidth
  546. add edi, eax ; EDI = y*bpr+x1
  547. sub edx, eax ; ECX = x2-x1
  548. inc edx
  549. mov eax, edi
  550. shr eax, 16
  551. cmp al, LastPage
  552. je @f
  553. mov LastPage, al
  554. push edx
  555. push ecx
  556. mov edx, eax
  557. mov cl, PageSizeShift
  558. shl edx, cl ; Convert from 64K pages to GranUnit pages.
  559. xor ebx, ebx ; BH=Select window, BL=Window A
  560. mov eax, 04f05h ; AX=Super VGA video memory window control
  561. int 10h
  562. pop ecx
  563. pop edx
  564. @@: and edi, 00FFFFh
  565. or edi, 0A0000h
  566. ;mov eax, _Table8to32[ecx*4]
  567. mov ch, cl
  568. mov ax, cx
  569. shl eax, 16
  570. mov ax, cx
  571. ; edx = width in bytes
  572. ; edi = dest
  573. mov bx, dx
  574. add bx, di
  575. jnc scanonepage
  576. sub dx, bx
  577. movzx ecx, dx
  578. shr ecx, 1
  579. rep stosw
  580. adc ecx, ecx
  581. rep stosb
  582. movzx edx, bx
  583. cmp edx, 0
  584. je scandone
  585. call gr_vesa_incpage_
  586. mov edi, 0A0000h
  587. scanonepage:
  588. movzx ecx, dx
  589. shr ecx, 1
  590. rep stosw
  591. adc ecx, ecx
  592. rep stosb
  593. scandone:
  594. pop edi
  595. ret
  596. PUBLIC gr_vesa_set_logical_
  597. gr_vesa_set_logical_:
  598. ; EAX = logical width in pixels
  599. push ebx
  600. push ecx
  601. mov ecx, eax
  602. mov eax, 04f06h
  603. mov bl, 0
  604. int 10h
  605. and ebx, 0ffffh
  606. movzx eax, cx
  607. pop ecx
  608. pop ebx
  609. ret
  610. PUBLIC gr_vesa_pixel_
  611. gr_vesa_pixel_:
  612. ; EAX = color (in AL)
  613. ; EDX = offset from 0A0000
  614. shld eax, edx, 16
  615. and edx, 0ffffh
  616. cmp al, LastPage
  617. jne @f
  618. shr eax, 16
  619. mov [edx+0A0000h], al
  620. ret
  621. @@: mov LastPage, al
  622. pushad
  623. and eax, 0fh
  624. mov edx, eax
  625. mov cl, PageSizeShift
  626. shl edx, cl ; Convert from 64K pages to GranUnit pages.
  627. xor ebx, ebx ; BH=Select window, BL=Window A
  628. mov eax, 04f05h ; AX=Super VGA video memory window control
  629. int 10h
  630. popad
  631. shr eax, 16
  632. mov [edx+0A0000h], al
  633. ret
  634. PUBLIC gr_vesa_bitblt_
  635. gr_vesa_bitblt_:
  636. ; EAX = source_ptr
  637. ; EDX = vesa_address
  638. ; EBX = height
  639. ; ECX = width
  640. push edi
  641. push esi
  642. mov esi, eax ; Point ESI to source bitmap
  643. ; Set the initial page
  644. mov eax, edx ; Move offset into SVGA into eax
  645. shr eax, 16 ; Page = offset / 64K
  646. call gr_vesa_setpage_
  647. mov edi, edx ; EDI = offset into SVGA
  648. and edi, 0FFFFh ; EDI = offset into 64K page
  649. add edi, 0A0000h ; EDI = ptr to dest
  650. mov edx, _gr_var_bwidth
  651. sub edx, ecx ; EDX = amount to step each row
  652. mov eax, ecx
  653. NextScanLine:
  654. push eax
  655. MyMovsd eax
  656. pop eax
  657. dec ebx
  658. jz DoneBlt
  659. add di, dx
  660. jnc NextScanLine
  661. ; Need to increment page!
  662. call gr_vesa_incpage_
  663. jmp NextScanLine
  664. DoneBlt: pop esi
  665. pop edi
  666. ret
  667. PUBLIC gr_vesa_bitmap_
  668. gr_vesa_bitmap_:
  669. ; EAX = Source bitmap (LINEAR)
  670. ; EDX = Destination bitmap (SVGA)
  671. ; EBX = x
  672. ; ECX = y
  673. push esi
  674. push edi
  675. push ebp
  676. push es
  677. push eax
  678. mov eax, [edx].bm_data
  679. imul ecx, _gr_var_bwidth
  680. add eax, ecx
  681. add eax, ebx
  682. mov edi, eax ; EDI = offset into SVGA
  683. shr eax, 16
  684. call gr_vesa_setpage_
  685. mov ax, __A0000
  686. mov es, ax
  687. pop eax
  688. mov esi, [eax].bm_data
  689. and edi, 0ffffh
  690. movzx ecx, [eax].bm_h
  691. NextScanLine1:
  692. push ecx
  693. movzx ecx, [eax].bm_w
  694. mov bx, cx
  695. add bx, di
  696. jnc OnePage
  697. sub cx,bx
  698. mov ebp, ecx
  699. MyMovsd ebp
  700. and edi, 00ffffh ; IN CASE IT WENT OVER 64K
  701. mov cx,bx
  702. call gr_vesa_incpage_
  703. jcxz DoneWithLine
  704. OnePage:
  705. mov ebp, ecx
  706. MyMovsd ebp
  707. and edi, 00ffffh ; IN CASE IT WENT OVER 64K
  708. DoneWithLine: mov bx, [eax].bm_rowsize
  709. sub bx, [eax].bm_w
  710. and ebx, 0ffffh
  711. add esi, ebx
  712. mov bx, [edx].bm_rowsize
  713. sub bx, [eax].bm_w
  714. add di, bx
  715. jnc NoPageInc
  716. call gr_vesa_incpage_
  717. NoPageInc: pop ecx
  718. dec ecx
  719. jz @f
  720. jmp NextScanLine1
  721. @@:
  722. pop es
  723. pop ebp
  724. pop edi
  725. pop esi
  726. ret
  727. PUBLIC gr_vesa_update_
  728. gr_vesa_update_:
  729. ; EAX = Source bitmap (LINEAR)
  730. ; EDX = Destination bitmap (SVGA)
  731. ; EBX = Old source bitmap (LINEAR)
  732. push ecx
  733. push esi
  734. push edi
  735. push ebp
  736. push fs
  737. push eax
  738. mov eax, [edx].bm_data
  739. mov ebp, eax ; EDI = offset into SVGA
  740. shr eax, 16
  741. call gr_vesa_setpage_
  742. mov ax, __A0000
  743. mov fs, ax
  744. pop eax
  745. mov esi, [eax].bm_data
  746. and ebp, 0ffffh
  747. movzx ecx, [eax].bm_h
  748. mov edi, [ebx].bm_data
  749. movzx ebx, [eax].bm_rowsize
  750. sub bx, [eax].bm_w
  751. mov SourceInc, ebx
  752. movzx ebx, [edx].bm_rowsize
  753. sub bx, [eax].bm_w
  754. mov DestInc, bx
  755. movzx ebx, [eax].bm_w
  756. mov RowWidth, ebx
  757. NextScanLine3:
  758. push ecx
  759. mov ecx, RowWidth
  760. mov dx, cx
  761. add dx, bp
  762. jnc OnePage3
  763. sub cx,dx
  764. mov ebx, esi
  765. InnerLoop3: repe cmpsb
  766. mov al, [esi-1]
  767. sub esi, ebx
  768. mov fs:[ebp+esi-1], al ; EDX = dest + size - bytes to end
  769. add esi, ebx
  770. cmp ecx, 0
  771. jne InnerLoop3
  772. sub esi, ebx
  773. add ebp, esi
  774. add esi, ebx
  775. and ebp, 00ffffh ; IN CASE IT WENT OVER 64K
  776. mov cx,dx
  777. call gr_vesa_incpage_
  778. jcxz DoneWithLine3
  779. OnePage3:
  780. mov ebx, esi
  781. mov edx, ecx
  782. and edx, 11b
  783. shr ecx, 2
  784. InnerLoop4: repe cmpsd
  785. mov eax, [esi-4]
  786. sub esi, ebx
  787. mov fs:[ebp+esi-4], eax ; EDX = dest + size - bytes to end
  788. add esi, ebx
  789. cmp ecx, 0
  790. jne InnerLoop4
  791. mov ecx, edx
  792. jecxz EvenWidth
  793. InnerLoop5: repe cmpsb
  794. mov al, [esi-1]
  795. sub esi, ebx
  796. mov fs:[ebp+esi-1], al ; EDX = dest + size - bytes to end
  797. add esi, ebx
  798. cmp ecx, 0
  799. jne InnerLoop5
  800. EvenWidth: sub esi, ebx
  801. add ebp, esi
  802. add esi, ebx
  803. and ebp, 00ffffh ; IN CASE IT WENT OVER 64K
  804. DoneWithLine3:
  805. add esi, SourceInc
  806. add edi, SourceInc
  807. add bp, DestInc
  808. jnc NoPageInc3
  809. call gr_vesa_incpage_
  810. NoPageInc3: pop ecx
  811. dec ecx
  812. jnz NextScanLine3
  813. pop fs
  814. pop ebp
  815. pop edi
  816. pop esi
  817. pop ecx
  818. ret
  819. _TEXT ENDS
  820. END
  821.