MODEX.ASM 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836
  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/modex.asm $
  13. ; $Revision: 1.19 $
  14. ; $Author: john $
  15. ; $Date: 1995/03/01 15:37:46 $
  16. ;
  17. ; Routines to access ModeX VGA memory
  18. ;
  19. ; $Log: modex.asm $
  20. ; Revision 1.19 1995/03/01 15:37:46 john
  21. ; Better ModeX support.
  22. ;
  23. ; Revision 1.18 1994/11/24 13:24:20 john
  24. ; Made sure that some rep movs had the cld set first.
  25. ; Took some unused functions out.
  26. ;
  27. ; Revision 1.17 1994/09/22 18:15:02 john
  28. ; Made flip page wait for retrace.
  29. ;
  30. ; Revision 1.16 1994/09/22 16:08:27 john
  31. ; Fixed some palette stuff.
  32. ;
  33. ; Revision 1.15 1994/07/13 12:03:05 john
  34. ; Added assembly modex line-drawer.
  35. ;
  36. ; Revision 1.14 1994/05/06 12:50:34 john
  37. ; Added supertransparency; neatend things up; took out warnings.
  38. ;
  39. ; Revision 1.13 1994/05/03 19:39:04 john
  40. ; *** empty log message ***
  41. ;
  42. ; Revision 1.12 1994/02/18 15:32:32 john
  43. ; *** empty log message ***
  44. ;
  45. ; Revision 1.11 1993/12/21 11:40:36 john
  46. ; *** empty log message ***
  47. ;
  48. ; Revision 1.10 1993/12/09 15:02:26 john
  49. ; Changed palette stuff majorly
  50. ;
  51. ; Revision 1.9 1993/12/03 12:11:32 john
  52. ; fixed cx/ecx loop bugs.
  53. ;
  54. ; Revision 1.8 1993/11/16 11:28:18 john
  55. ; *** empty log message ***
  56. ;
  57. ; Revision 1.7 1993/10/15 16:23:23 john
  58. ; y
  59. ;
  60. ; Revision 1.6 1993/09/28 19:07:19 john
  61. ; stripped the waitforretrace out of fade to speed things up.
  62. ;
  63. ; Revision 1.5 1993/09/26 18:58:58 john
  64. ; fade stuff
  65. ;
  66. ; Revision 1.4 1993/09/21 14:01:15 john
  67. ; turned off video before mode set to reduce flicker.
  68. ;
  69. ; Revision 1.3 1993/09/08 11:38:36 john
  70. ; changed rcs stuff at beginning.
  71. ;
  72. ;
  73. ;
  74. .386
  75. _DATA SEGMENT BYTE PUBLIC USE32 'DATA'
  76. INCLUDE psmacros.inc
  77. INCLUDE TWEAK.INC
  78. INCLUDE VGAREGS.INC
  79. extd _gr_var_bwidth
  80. extd _modex_line_vertincr
  81. extd _modex_line_incr1
  82. extd _modex_line_incr2
  83. _modex_line_routine dd ?
  84. extd _modex_line_x1
  85. extd _modex_line_y1
  86. extd _modex_line_x2
  87. extd _modex_line_y2
  88. extb _modex_line_Color
  89. SavedColor db ?
  90. LEFT_MASK1 = 1000b
  91. LEFT_MASK2 = 1100b
  92. LEFT_MASK3 = 1110b
  93. RIGHT_MASK1 = 0001b
  94. RIGHT_MASK2 = 0011b
  95. RIGHT_MASK3 = 0111b
  96. ALL_MASK = 1111b
  97. tmppal db 768 dup (0)
  98. fb_pal dd ?
  99. fb_add dw ?
  100. fb_count dd ?
  101. MaskTable1 db ALL_MASK AND RIGHT_MASK1,
  102. ALL_MASK AND RIGHT_MASK2,
  103. ALL_MASK AND RIGHT_MASK3,
  104. ALL_MASK,
  105. LEFT_MASK3 AND RIGHT_MASK1,
  106. LEFT_MASK3 AND RIGHT_MASK2,
  107. LEFT_MASK3 AND RIGHT_MASK3,
  108. LEFT_MASK3,
  109. LEFT_MASK2 AND RIGHT_MASK1,
  110. LEFT_MASK2 AND RIGHT_MASK2,
  111. LEFT_MASK2 AND RIGHT_MASK3,
  112. LEFT_MASK2,
  113. LEFT_MASK1 AND RIGHT_MASK1,
  114. LEFT_MASK1 AND RIGHT_MASK2,
  115. LEFT_MASK1 AND RIGHT_MASK3,
  116. LEFT_MASK1,
  117. MaskTable2 db ALL_MASK,RIGHT_MASK1,
  118. ALL_MASK,RIGHT_MASK2,
  119. ALL_MASK,RIGHT_MASK3,
  120. ALL_MASK,ALL_MASK,
  121. LEFT_MASK3,RIGHT_MASK1,
  122. LEFT_MASK3,RIGHT_MASK2,
  123. LEFT_MASK3,RIGHT_MASK3,
  124. LEFT_MASK3,ALL_MASK,
  125. LEFT_MASK2,RIGHT_MASK1,
  126. LEFT_MASK2,RIGHT_MASK2,
  127. LEFT_MASK2,RIGHT_MASK3,
  128. LEFT_MASK2,ALL_MASK,
  129. LEFT_MASK1,RIGHT_MASK1,
  130. LEFT_MASK1,RIGHT_MASK2,
  131. LEFT_MASK1,RIGHT_MASK3,
  132. LEFT_MASK1,ALL_MASK
  133. DrawTable dd DrawMR,
  134. DrawMR,
  135. DrawMR,
  136. DrawM,
  137. DrawLMR,
  138. DrawLMR,
  139. DrawLMR,
  140. DrawLM,
  141. DrawLMR,
  142. DrawLMR,
  143. DrawLMR,
  144. DrawLM,
  145. DrawLMR,
  146. DrawLMR,
  147. DrawLMR,
  148. DrawLM
  149. _DATA ENDS
  150. DGROUP GROUP _DATA
  151. _TEXT SEGMENT BYTE PUBLIC USE32 'CODE'
  152. ASSUME DS:_DATA
  153. ASSUME CS:_TEXT
  154. PUBLIC gr_sync_display_
  155. gr_sync_display_:
  156. push ax
  157. push dx
  158. mov dx, VERT_RESCAN
  159. VS2A: in al, dx
  160. and al, 08h
  161. jnz VS2A ; Loop until not in vertical retrace
  162. VS2B: in al, dx
  163. and al, 08h
  164. jz VS2B ; Loop until in vertical retrace
  165. pop dx
  166. pop ax
  167. ret
  168. PUBLIC gr_modex_uscanline_
  169. gr_modex_uscanline_:
  170. push edi
  171. ; EAX = X1 (X1 and X2 don't need to be sorted)
  172. ; EDX = X2
  173. ; EBX = Y
  174. ; ECX = Color
  175. mov SavedColor, cl
  176. ;mov ebx, _RowOffset[ebx*4]
  177. mov edi, _gr_var_bwidth
  178. imul edi, ebx
  179. add edi, 0A0000h
  180. cmp eax, edx
  181. jle @f
  182. xchg eax, edx
  183. @@: mov bl, al
  184. shl bl, 2
  185. mov bh, dl
  186. and bh, 011b
  187. or bl, bh
  188. and ebx, 0fh
  189. ; BX = LeftRight switch command. (4bit)
  190. shr eax, 2
  191. shr edx, 2
  192. add edi, eax
  193. ; EDI = Offset into video memory
  194. mov ecx, edx
  195. sub ecx, eax
  196. ; ECX = X2/4 - X1/4 - 1
  197. jnz LargerThan4
  198. ;======================= ONE GROUP OF 4 OR LESS TO DRAW ====================
  199. mov dx, SC_INDEX
  200. mov al, SC_MAP_MASK
  201. out dx, al
  202. inc dx
  203. mov al, MaskTable1[ebx]
  204. out dx, al
  205. mov al, SavedColor
  206. mov [edi], al ; Write the one pixel
  207. pop edi
  208. ret
  209. LargerThan4:
  210. dec ecx
  211. jnz LargerThan8
  212. ;===================== TWO GROUPS OF 4 OR LESS TO DRAW ====================
  213. mov cx, WORD PTR MaskTable2[ebx*2]
  214. mov bl, SavedColor
  215. mov dx, SC_INDEX
  216. mov al, SC_MAP_MASK
  217. out dx, al
  218. inc dx
  219. mov al, cl
  220. out dx, al
  221. mov [edi], bl ; Write the left pixel
  222. mov al, ch
  223. out dx, al
  224. mov [edi+1], bl ; Write the right pixel
  225. pop edi
  226. ret
  227. ;========================= MANY GROUPS OF 4 TO DRAW ======================
  228. LargerThan8:
  229. mov dx, SC_INDEX
  230. mov al, SC_MAP_MASK
  231. out dx, al
  232. inc dx
  233. ; DX = SC_INDEX
  234. mov al, SavedColor
  235. mov ah, al
  236. ; AL,AH = color of pixel
  237. jmp NEAR32 PTR DrawTable[ebx*4]
  238. DrawM: ;AH=COLOR, EDI=DEST, CX=X2/4-X1/4-1, BX=Table Index
  239. mov al, ALL_MASK
  240. out dx, al
  241. mov al, ah
  242. cld
  243. add ecx, 2
  244. shr ecx, 1
  245. rep stosw ; Write the middle pixels
  246. jnc @F
  247. stosb ; Write the middle odd pixel
  248. @@: pop edi
  249. ret
  250. DrawLM:
  251. ;AH=COLOR, EDI=DEST, CX=X2/4-X1/4-1, BX=Table Index
  252. mov al, BYTE PTR MaskTable2[ebx*2]
  253. out dx, al
  254. mov [edi], ah ; Write leftmost pixels
  255. inc edi
  256. mov al, ALL_MASK
  257. out dx, al
  258. mov al, ah
  259. cld
  260. inc ecx
  261. shr ecx, 1
  262. rep stosw ; Write the middle pixels
  263. jnc @F
  264. stosb ; Write the middle odd pixel
  265. @@: pop edi
  266. ret
  267. DrawLMR: ;AH=COLOR, EDI=DEST, CX=X2/4-X1/4-1, BX=Table Index
  268. mov bx, WORD PTR MaskTable2[ebx*2]
  269. mov al, bl
  270. out dx, al
  271. mov [edi], ah ; Write leftmost pixels
  272. inc edi
  273. mov al, ALL_MASK
  274. out dx, al
  275. mov al, ah
  276. cld
  277. shr ecx, 1
  278. rep stosw ; Write the middle pixels
  279. jnc @F
  280. stosb ; Write the middle odd pixel
  281. @@: mov al, bh
  282. out dx, al
  283. mov [edi], ah ; Write the rightmost pixels
  284. pop edi
  285. ret
  286. DrawMR: ;AH=COLOR, EDI=DEST, CX=X2/4-X1/4-1, BX=Table Index
  287. mov bx, WORD PTR MaskTable2[ebx*2]
  288. mov al, ALL_MASK
  289. out dx, al
  290. mov al, ah
  291. cld
  292. inc ecx
  293. shr ecx, 1
  294. rep stosw ; Write the middle pixels
  295. jnc @F
  296. stosb ; Write the middle odd pixel
  297. @@: mov al, bh
  298. out dx, al
  299. mov [edi], ah ; Write the rightmost pixels
  300. pop edi
  301. ret
  302. PUBLIC gr_modex_setmode_
  303. gr_modex_setmode_:
  304. push ebx
  305. push ecx
  306. push edx
  307. push esi
  308. push edi
  309. mov ecx, eax
  310. dec ecx
  311. cmp ecx, LAST_X_MODE
  312. jbe @f
  313. mov ecx, 0
  314. @@:
  315. ;call turn_screen_off
  316. push ecx ; some bios's dont preserve cx
  317. ;mov ax, 1201h
  318. ;mov bl, 31h ; disable palette loading at mode switch
  319. ;int 10h
  320. mov ax,13h ; let the BIOS set standard 256-color
  321. int 10h ; mode (320x200 linear)
  322. ;mov ax, 1200h
  323. ;mov bl, 31h ; enable palette loading at mode switch
  324. ;int 10h
  325. pop ecx
  326. mov dx,SC_INDEX
  327. mov ax,0604h
  328. out dx,ax ; disable chain4 mode
  329. mov dx,SC_INDEX
  330. mov ax,0100h
  331. out dx,ax ; synchronous reset while setting Misc
  332. ; Output for safety, even though clock
  333. ; unchanged
  334. mov esi, dword ptr ModeTable[ecx*4]
  335. lodsb
  336. or al,al
  337. jz DontSetDot
  338. mov dx,MISC_OUTPUT
  339. out dx,al ; select the dot clock and Horiz
  340. ; scanning rate
  341. ;mov dx,SC_INDEX
  342. ;mov al,01h
  343. ;out dx,al
  344. ;inc dx
  345. ;in al, dx
  346. ;or al, 1000b
  347. ;out dx, al
  348. DontSetDot:
  349. mov dx,SC_INDEX
  350. mov ax,0300h
  351. out dx,ax ; undo reset (restart sequencer)
  352. mov dx,CRTC_INDEX ; reprogram the CRT Controller
  353. mov al,11h ; VSync End reg contains register write
  354. out dx,al ; protect bit
  355. inc dx ; CRT Controller Data register
  356. in al,dx ; get current VSync End register setting
  357. and al,07fh ; remove write protect on various
  358. out dx,al ; CRTC registers
  359. dec dx ; CRT Controller Index
  360. cld
  361. xor ecx,ecx
  362. lodsb
  363. mov cl,al
  364. SetCRTParmsLoop:
  365. lodsw ; get the next CRT Index/Data pair
  366. out dx,ax ; set the next CRT Index/Data pair
  367. loop SetCRTParmsLoop
  368. mov dx,SC_INDEX
  369. mov ax,0f02h
  370. out dx,ax ; enable writes to all four planes
  371. mov edi, 0A0000h ; point ES:DI to display memory
  372. xor ax,ax ; clear to zero-value pixels
  373. mov ecx,8000h ; # of words in display memory
  374. rep stosw ; clear all of display memory
  375. ; Set pysical screen dimensions
  376. xor eax, eax
  377. lodsw ; Load scrn pixel width
  378. mov cx, ax
  379. shl eax, 16
  380. mov dx,CRTC_INDEX
  381. mov al,CRTC_OFFSET
  382. out dx,al
  383. inc dx
  384. mov ax,cx
  385. shr ax,3
  386. out dx,al
  387. ;mov si, 360
  388. ;@@:
  389. ;mov ax, 04f06h
  390. ;mov bl, 0
  391. ;mov cx, si
  392. ;int 10h
  393. ;cmp cx, si
  394. ;je @f
  395. ;inc si
  396. ;jmp @B
  397. ;@@:
  398. ;movzx eax, si
  399. lodsw ; Load Screen Phys. Height
  400. ;call turn_screen_on
  401. pop edi
  402. pop esi
  403. pop edx
  404. pop ecx
  405. pop ebx
  406. ret
  407. PUBLIC gr_modex_setplane_
  408. gr_modex_setplane_:
  409. push cx
  410. push dx
  411. mov cl, al
  412. ; SELECT WRITE PLANE
  413. and cl,011b ;CL = plane
  414. mov ax,0100h + MAP_MASK ;AL = index in SC of Map Mask reg
  415. shl ah,cl ;set only the bit for the required
  416. ; plane to 1
  417. mov dx,SC_INDEX ;set the Map Mask to enable only the
  418. out dx,ax ; pixel's plane
  419. ; SELECT READ PLANE
  420. mov ah,cl ;AH = plane
  421. mov al,READ_MAP ;AL = index in GC of the Read Map reg
  422. mov dx,GC_INDEX ;set the Read Map to read the pixel's
  423. out dx,ax ; plane
  424. pop dx
  425. pop cx
  426. ret
  427. PUBLIC gr_modex_setstart_
  428. gr_modex_setstart_:
  429. ; EAX = X
  430. ; EDX = Y
  431. ; EBX = Wait for retrace
  432. push ebx
  433. push ecx
  434. push ebx
  435. mov ecx, _gr_var_bwidth
  436. imul ecx, edx
  437. shr eax, 2
  438. add eax, ecx
  439. mov ch, ah
  440. mov bh, al
  441. mov bl, CC_START_LO
  442. mov cl, CC_START_HI
  443. cli
  444. mov dx, VERT_RESCAN
  445. WaitDE: in al, dx
  446. test al, 01h
  447. jnz WaitDE
  448. mov dx, CRTC_INDEX
  449. mov ax, bx
  450. out dx, ax ; Start address low
  451. mov ax, cx
  452. out dx, ax ; Start address high
  453. sti
  454. pop ebx
  455. cmp ebx, 0
  456. je NoWaitVS
  457. mov dx, VERT_RESCAN
  458. WaitVS: in al, dx
  459. test al, 08h
  460. jz WaitVS ; Loop until in vertical retrace
  461. NoWaitVS:
  462. pop ecx
  463. pop ebx
  464. ret
  465. ModeXAddr macro
  466. ; given: ebx=x, eax=y, return cl=plane mask, ebx=address, trash eax
  467. mov cl, bl
  468. and cl, 3
  469. shr ebx, 2
  470. imul eax, _gr_var_bwidth
  471. add ebx, eax
  472. add ebx, 0A0000h
  473. endm
  474. ;-----------------------------------------------------------------------
  475. ;
  476. ; Line drawing function for all MODE X 256 Color resolutions
  477. ; Based on code from "PC and PS/2 Video Systems" by Richard Wilton.
  478. PUBLIC gr_modex_line_
  479. gr_modex_line_:
  480. pusha
  481. mov dx,SC_INDEX ; setup for plane mask access
  482. ; check for vertical line
  483. mov esi,_gr_var_bwidth
  484. mov ecx,_modex_line_x2
  485. sub ecx,_modex_line_x1
  486. jz VertLine
  487. ; force x1 < x2
  488. jns L01
  489. neg ecx
  490. mov ebx,_modex_line_x2
  491. xchg ebx,_modex_line_x1
  492. mov _modex_line_x2,ebx
  493. mov ebx,_modex_line_y2
  494. xchg ebx,_modex_line_y1
  495. mov _modex_line_y2,ebx
  496. ; calc dy = abs(y2 - y1)
  497. L01:
  498. mov ebx,_modex_line_y2
  499. sub ebx,_modex_line_y1
  500. jnz short skip
  501. jmp HorizLine
  502. skip: jns L03
  503. neg ebx
  504. neg esi
  505. ; select appropriate routine for slope of line
  506. L03:
  507. mov _modex_line_vertincr,esi
  508. mov _modex_line_routine,offset LoSlopeLine
  509. cmp ebx,ecx
  510. jle L04
  511. mov _modex_line_routine,offset HiSlopeLine
  512. xchg ebx,ecx
  513. ; calc initial decision variable and increments
  514. L04:
  515. shl ebx,1
  516. mov _modex_line_incr1,ebx
  517. sub ebx,ecx
  518. mov esi,ebx
  519. sub ebx,ecx
  520. mov _modex_line_incr2,ebx
  521. ; calc first pixel address
  522. push ecx
  523. mov eax,_modex_line_y1
  524. mov ebx,_modex_line_x1
  525. ModeXAddr
  526. mov edi,ebx
  527. mov al,1
  528. shl al,cl
  529. mov ah,al ; duplicate nybble
  530. shl al,4
  531. add ah,al
  532. mov bl,ah
  533. pop ecx
  534. inc ecx
  535. jmp [_modex_line_routine]
  536. ; routine for verticle lines
  537. VertLine:
  538. mov eax,_modex_line_y1
  539. mov ebx,_modex_line_y2
  540. mov ecx,ebx
  541. sub ecx,eax
  542. jge L31
  543. neg ecx
  544. mov eax,ebx
  545. L31:
  546. inc ecx
  547. mov ebx,_modex_line_x1
  548. push ecx
  549. ModeXAddr
  550. mov ah,1
  551. shl ah,cl
  552. mov al,MAP_MASK
  553. out dx,ax
  554. pop ecx
  555. mov ax, word ptr _modex_line_Color
  556. ; draw the line
  557. L32:
  558. mov [ebx],al
  559. add ebx,esi
  560. loop L32
  561. jmp Lexit
  562. ; routine for horizontal line
  563. HorizLine:
  564. mov eax,_modex_line_y1
  565. mov ebx,_modex_line_x1
  566. ModeXAddr
  567. mov edi,ebx ; set dl = first byte mask
  568. mov dl,00fh
  569. shl dl,cl
  570. mov ecx,_modex_line_x2 ; set dh = last byte mask
  571. and cl,3
  572. mov dh,00eh
  573. shl dh,cl
  574. not dh
  575. ; determine byte offset of first and last pixel in line
  576. mov eax,_modex_line_x2
  577. mov ebx,_modex_line_x1
  578. shr eax,2 ; set ax = last byte column
  579. shr ebx,2 ; set bx = first byte column
  580. mov ecx,eax ; cx = ax - bx
  581. sub ecx,ebx
  582. mov eax,edx ; mov end byte masks to ax
  583. mov dx,SC_INDEX ; setup dx for VGA outs
  584. mov bl,_modex_line_Color
  585. ; set pixels in leftmost byte of line
  586. or ecx,ecx ; is start and end pt in same byte
  587. jnz L42 ; no !
  588. and ah,al ; combine start and end masks
  589. jmp short L44
  590. L42: push eax
  591. mov ah,al
  592. mov al,MAP_MASK
  593. out dx,ax
  594. mov al,bl
  595. stosb
  596. dec ecx
  597. ; draw remainder of the line
  598. L43:
  599. mov ah,0Fh
  600. mov al,MAP_MASK
  601. out dx,ax
  602. mov al,bl
  603. rep stosb
  604. pop eax
  605. ; set pixels in rightmost byte of line
  606. L44:
  607. mov al,MAP_MASK
  608. out dx, ax
  609. mov byte ptr [edi],bl
  610. jmp Lexit
  611. ; routine for dy >= dx (slope <= 1)
  612. LoSlopeLine:
  613. mov al,MAP_MASK
  614. mov bh,byte ptr _modex_line_Color
  615. L10:
  616. mov ah,bl
  617. L11:
  618. or ah,bl
  619. rol bl,1
  620. jc L14
  621. ; bit mask not shifted out
  622. or esi,esi
  623. jns L12
  624. add esi,_modex_line_incr1
  625. loop L11
  626. out dx,ax
  627. mov [edi],bh
  628. jmp short Lexit
  629. L12:
  630. add esi,_modex_line_incr2
  631. out dx,ax
  632. mov [edi],bh
  633. add edi,_modex_line_vertincr
  634. loop L10
  635. jmp short Lexit
  636. ; bit mask shifted out
  637. L14: out dx,ax
  638. mov [edi],bh
  639. inc edi
  640. or esi,esi
  641. jns L15
  642. add esi,_modex_line_incr1
  643. loop L10
  644. jmp short Lexit
  645. L15:
  646. add esi,_modex_line_incr2
  647. add edi,_modex_line_vertincr
  648. loop L10
  649. jmp short Lexit
  650. ; routine for dy > dx (slope > 1)
  651. HiSlopeLine:
  652. mov ebx,_modex_line_vertincr
  653. mov al,MAP_MASK
  654. L21: out dx,ax
  655. push eax
  656. mov al,_modex_line_Color
  657. mov [edi],al
  658. pop eax
  659. add edi,ebx
  660. L22:
  661. or esi,esi
  662. jns L23
  663. add esi,_modex_line_incr1
  664. loop L21
  665. jmp short Lexit
  666. L23:
  667. add esi,_modex_line_incr2
  668. rol ah,1
  669. adc edi,0
  670. lx21: loop L21
  671. ; return to caller
  672. Lexit:
  673. popa
  674. ret
  675. _TEXT ENDS
  676. END
  677.