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.

1189 lines
35 KiB

  1. ;---------------------------Module-Header------------------------------;
  2. ; Module Name: strips.asm
  3. ;
  4. ; Routines used by line code to draw strips of pixels.
  5. ;
  6. ; Copyright (c) 1992 Microsoft Corporation
  7. ;-----------------------------------------------------------------------;
  8. .386
  9. .model small,c
  10. assume cs:FLAT,ds:FLAT,es:FLAT,ss:FLAT
  11. assume fs:nothing,gs:nothing
  12. ; Set LOOP_UNROLL_SHIFT to the log2 of the number of times you want loops in
  13. ; this module unrolled. For example, LOOP_UNROLL_SHIFT of 3 yields 2**3 = 8
  14. ; times unrolling. This is the only thing you need to change to control
  15. ; unrolling.
  16. LOOP_UNROLL_SHIFT equ 1
  17. .xlist
  18. include stdcall.inc ;calling convention cmacros
  19. include i386\egavga.inc
  20. include i386\strucs.inc
  21. include i386\driver.inc
  22. include i386\lines.inc
  23. .list
  24. .code
  25. ;--------------------------Private-Routine------------------------------;
  26. ; vStripSolid0
  27. ;
  28. ; Draw lines in the 1st half-octant.
  29. ;
  30. ;-----------------------------------------------------------------------;
  31. cProc vStripSolid0,12,< \
  32. uses esi edi ebx, \
  33. pStrips: ptr STRIPS, \
  34. pls: ptr LINESTATE, \
  35. plStripEnd: ptr >
  36. ; Do some initializing:
  37. mov esi, pStrips
  38. push ebp
  39. mov ebp, plStripEnd
  40. mov eax,[esi].ST_lNextScan
  41. mov [ebp],eax ;copy delta
  42. mov eax,[esi].ST_chAndXor
  43. mov bl,ah
  44. mov bh,ah
  45. mov ah,al
  46. mov edi,[esi].ST_pjScreen
  47. add esi,offset ST_alStrips
  48. ; ax = and mask
  49. ; bx = xor mask
  50. ; ecx = pixel count
  51. ; dx = temporary register
  52. ; esi = strip pointer
  53. ; edi = display pointer
  54. ; ebp = ends of strips pointer
  55. ; [ebp] = delta
  56. mov ecx,[esi]
  57. add esi,4
  58. test edi,1
  59. jnz short sol0_unaligned_start
  60. sol0_aligned_loop:
  61. sub ecx,2
  62. jl short sol0_strip_end_unaligned
  63. je short sol0_strip_end_aligned
  64. mov dx,[edi]
  65. and edx,eax
  66. xor edx,ebx
  67. mov [edi],dx
  68. add edi,2
  69. jmp short sol0_aligned_loop
  70. sol0_strip_end_aligned:
  71. mov dx,[edi]
  72. and edx,eax
  73. xor edx,ebx
  74. mov [edi],dx
  75. add edi,2
  76. add edi,[ebp] ;go to next scan
  77. cmp esi,ebp
  78. jae short sol0_all_done
  79. mov ecx,[esi]
  80. add esi,4
  81. jmp short sol0_aligned_loop
  82. sol0_strip_end_unaligned:
  83. mov dl,[edi] ;do last pixel
  84. and dl,al
  85. xor dl,bl
  86. mov [edi],dl
  87. inc edi
  88. add edi,[ebp] ;go to next scan
  89. cmp esi,ebp
  90. jae short sol0_all_done
  91. mov ecx,[esi] ;do first pixel of next strip
  92. add esi,4
  93. sol0_unaligned_start:
  94. mov dl,[edi]
  95. and dl,al
  96. xor dl,bl
  97. mov [edi],dl
  98. inc edi
  99. dec ecx
  100. jnz short sol0_aligned_loop
  101. ; Have to be careful when there is only one pel in the strip and it starts
  102. ; on an unaligned address:
  103. add edi,[ebp]
  104. cmp esi,ebp
  105. jae short sol0_all_done
  106. mov ecx,[esi]
  107. add esi,4
  108. jmp short sol0_aligned_loop
  109. sol0_all_done:
  110. pop ebp
  111. mov esi, pStrips
  112. mov [esi].ST_pjScreen,edi
  113. cRet vStripSolid0
  114. endProc vStripSolid0
  115. ;--------------------------Private-Routine------------------------------;
  116. ; vStripSolid1
  117. ;
  118. ; Draws lines in the 2nd half-octant.
  119. ;
  120. ;-----------------------------------------------------------------------;
  121. cProc vStripSolid1,12,< \
  122. uses esi edi ebx, \
  123. pStrips: ptr STRIPS, \
  124. pls: ptr LINESTATE, \
  125. plStripEnd: ptr >
  126. mov esi,pStrips
  127. push ebp
  128. mov ebp,plStripEnd
  129. mov ecx,[esi].ST_lNextScan
  130. inc ecx ; Make delta advance 1 to right
  131. mov eax,[esi].ST_chAndXor
  132. mov edi,[esi].ST_pjScreen
  133. add esi,offset ST_alStrips
  134. ; al = and mask
  135. ; ah = xor mask
  136. ; ebx = pixel count
  137. ; ecx = delta
  138. ; dl = temporary register
  139. ; esi = strip pointer
  140. ; edi = memory pointer
  141. ; ebp = end of strips pointer
  142. sol1_next_diagonal:
  143. mov ebx,[esi]
  144. add esi, 4
  145. sol1_diagonal_loop:
  146. mov dl,[edi]
  147. and dl,al
  148. xor dl,ah
  149. mov [edi],dl
  150. add edi,ecx
  151. dec ebx
  152. jnz short sol1_diagonal_loop
  153. sub edi,ecx
  154. inc edi
  155. cmp esi,ebp
  156. jb short sol1_next_diagonal
  157. pop ebp
  158. mov esi, pStrips
  159. mov [esi].ST_pjScreen,edi
  160. cRet vStripSolid1
  161. endProc vStripSolid1
  162. ;--------------------------Private-Routine------------------------------;
  163. ; vStripSolid2
  164. ;
  165. ; Draws lines in the 3rd half-octant.
  166. ;
  167. ;-----------------------------------------------------------------------;
  168. cProc vStripSolid2,12,< \
  169. uses esi edi ebx, \
  170. pStrips: ptr STRIPS, \
  171. pls: ptr LINESTATE, \
  172. plStripEnd: ptr >
  173. mov esi,pStrips
  174. push ebp
  175. mov ebp,plStripEnd
  176. mov ecx,[esi].ST_lNextScan
  177. inc ecx ; Make delta advance 1 to right
  178. mov eax,[esi].ST_chAndXor
  179. mov edi,[esi].ST_pjScreen
  180. add esi,offset ST_alStrips
  181. ; al = and mask
  182. ; ah = xor mask
  183. ; ebx = pixel count
  184. ; ecx = delta
  185. ; dl = temporary register
  186. ; esi = strip pointer
  187. ; edi = memory pointer
  188. ; ebp = end of strips pointer
  189. sol2_next_diagonal:
  190. mov ebx,[esi]
  191. add esi,4
  192. sol2_diagonal_loop:
  193. mov dl,[edi]
  194. and dl,al
  195. xor dl,ah
  196. mov [edi],dl
  197. add edi,ecx
  198. dec ebx
  199. jnz short sol2_diagonal_loop
  200. dec edi
  201. cmp esi,ebp
  202. jb short sol2_next_diagonal
  203. pop ebp
  204. mov esi, pStrips
  205. mov [esi].ST_pjScreen,edi
  206. cRet vStripSolid2
  207. endProc vStripSolid2
  208. ;--------------------------Private-Routine------------------------------;
  209. ; vStripSolid3
  210. ;
  211. ; Draws lines in the 4th half-octant.
  212. ;
  213. ;-----------------------------------------------------------------------;
  214. cProc vStripSolid3,12,< \
  215. uses esi edi ebx, \
  216. pStrips: ptr STRIPS, \
  217. pls: ptr LINESTATE, \
  218. plStripEnd: ptr >
  219. mov esi,pStrips
  220. push ebp
  221. mov ebp,plStripEnd
  222. mov ecx,[esi].ST_lNextScan
  223. mov eax,[esi].ST_chAndXor
  224. mov edi,[esi].ST_pjScreen
  225. add esi,offset ST_alStrips
  226. ; al = and mask
  227. ; ah = xor mask
  228. ; ebx = pixel count
  229. ; ecx = delta
  230. ; dl = temporary register
  231. ; esi = strip pointer
  232. ; edi = memory pointer
  233. ; ebp = end of strips pointer
  234. sol3_next_vertical:
  235. mov ebx,[esi]
  236. add esi,4
  237. sol3_vertical_loop:
  238. mov dl,[edi]
  239. and dl,al
  240. xor dl,ah
  241. mov [edi],dl
  242. add edi,ecx
  243. dec ebx
  244. jnz short sol3_vertical_loop
  245. inc edi
  246. cmp esi,ebp
  247. jb short sol3_next_vertical
  248. pop ebp
  249. mov esi,pStrips
  250. mov [esi].ST_pjScreen,edi
  251. cRet vStripSolid3
  252. endProc vStripSolid3
  253. ;--------------------------Private-Routine------------------------------;
  254. ; vStripStyled0
  255. ;
  256. ; Draws styled lines in the 1st half-octant.
  257. ;
  258. ;-----------------------------------------------------------------------;
  259. cProc vStripStyled0,12,< \
  260. uses esi edi ebx, \
  261. pStrips: ptr STRIPS, \
  262. pls: ptr LINESTATE, \
  263. plStripEnd: ptr >
  264. local ulNumPixels: dword ;# of pixels in current style
  265. local pspEnd: dword ;pointer to end of style array
  266. local cjMajor: dword ;lNextScan for screen
  267. local cjStyleDelta: dword ;delta from end of style array to start
  268. ; al = and mask
  269. ; ah = xor mask
  270. ; ebx = # of pixels in current strip
  271. ; ecx = style pointer
  272. ; edx = temporary register
  273. ; esi = strips pointer
  274. ; edi = memory pointer
  275. mov esi,pStrips
  276. mov eax,[esi].ST_lNextScan
  277. mov cjMajor,eax
  278. mov eax,[esi].ST_pspEnd
  279. mov pspEnd,eax
  280. mov ebx,[esi].ST_pspStart
  281. sub ebx,eax ;compute cjStyleDelta
  282. sub ebx,4 ;make it exclusive
  283. mov cjStyleDelta,ebx
  284. mov edx,[esi].ST_spRemaining
  285. mov ulNumPixels,edx
  286. mov eax,[esi].ST_chAndXor
  287. mov ecx,[esi].ST_psp
  288. mov edx,[esi].ST_bIsGap
  289. mov edi,[esi].ST_pjScreen
  290. add esi,offset ST_alStrips
  291. mov ebx,[esi]
  292. add esi,4
  293. or edx,edx
  294. jz short sty0_output_loop ;if working on a dash, start there
  295. jmp short sty0_skip_loop ;if working on a gap, start there
  296. sty0_prepare_for_output:
  297. add edi,ulNumPixels ;adjust to do remainder of strip
  298. add ecx,4
  299. cmp pspEnd,ecx ;if (ecx == pspEnd + 4)
  300. sbb edx,edx ; then ecx = pspStart
  301. and edx,cjStyleDelta
  302. add ecx,edx
  303. mov ebx,ulNumPixels
  304. push eax
  305. mov eax,[ecx] ;get next style array element
  306. mov ulNumPixels,eax
  307. pop eax
  308. neg ebx
  309. jz short sty0_output_get_new_strip
  310. sty0_output_loop:
  311. mov dl,[edi]
  312. and dl,al
  313. xor dl,ah
  314. mov [edi],dl ;write pixel
  315. inc edi ;move one pixel to right
  316. dec ulNumPixels ;might have to go to next style element
  317. jz short sty0_prepare_for_skip
  318. dec ebx
  319. jnz short sty0_output_loop
  320. sty0_output_get_new_strip:
  321. add edi,cjMajor ;move up one scan
  322. cmp esi,plStripEnd
  323. jae short sty0_output_all_done
  324. mov ebx,[esi] ;get next strip
  325. add esi,4
  326. jmp short sty0_output_loop
  327. sty0_output_all_done:
  328. mov esi,pStrips
  329. mov [esi].ST_pjScreen,edi
  330. mov [esi].ST_bIsGap,0 ;we were working on a dash
  331. mov edi,ulNumPixels
  332. mov [esi].ST_spRemaining,edi
  333. mov [esi].ST_psp,ecx
  334. cRet vStripStyled0
  335. sty0_prepare_for_skip:
  336. add ecx,4
  337. cmp pspEnd,ecx ;if (ecx == pspEnd + 4)
  338. sbb edx,edx ; then ecx = pspStart
  339. and edx,cjStyleDelta
  340. add ecx,edx
  341. dec ebx
  342. push eax
  343. mov eax,[ecx] ;get next style array element
  344. mov ulNumPixels,eax
  345. pop eax
  346. jz short sty0_skip_get_new_strip
  347. sty0_skip_loop:
  348. add edi,ebx ;assume we'll skip entire strip
  349. sub ulNumPixels,ebx ; (we'll correct it if not)
  350. jle short sty0_prepare_for_output
  351. sty0_skip_get_new_strip:
  352. add edi,cjMajor ;move up one scan
  353. cmp esi,plStripEnd
  354. jae short sty0_skip_all_done
  355. mov ebx,[esi] ;get next strip
  356. add esi,4
  357. jmp short sty0_skip_loop
  358. sty0_skip_all_done:
  359. mov esi,pStrips
  360. mov [esi].ST_pjScreen,edi
  361. mov [esi].ST_bIsGap,0ffh ;we were working on a gap
  362. mov edi,ulNumPixels
  363. mov [esi].ST_spRemaining,edi
  364. mov [esi].ST_psp,ecx
  365. cRet vStripStyled0
  366. endProc vStripStyled0
  367. ;--------------------------Private-Routine------------------------------;
  368. ; vStripStyled123
  369. ;
  370. ; Draws styled lines in the 2nd, 3rd and 4th half-octants.
  371. ;
  372. ;-----------------------------------------------------------------------;
  373. cProc vStripStyled123,12,< \
  374. uses esi edi ebx, \
  375. pStrips: ptr STRIPS, \
  376. pls: ptr LINESTATE, \
  377. plStripEnd: ptr >
  378. local ulNumPixels: dword ;# of pixels in current style
  379. local pspEnd: dword ;pointer to end of style array
  380. local cjMajor: dword ;delta to go in major direction
  381. local cjMinor: dword ;delta to go in minor direction
  382. local cjStyleDelta: dword ;delta from end of style array to start
  383. ; al = and mask
  384. ; ah = xor mask
  385. ; ebx = # of pixels in current strip
  386. ; ecx = style pointer
  387. ; edx = temporary register
  388. ; esi = strips pointer
  389. ; edi = memory pointer
  390. mov esi,pStrips
  391. ; If in half-octant 3, cjMajor = cjDelta and cjMinor = 1
  392. ; If in half-octant 2, cjMajor = cjDelta + 1 and cjMinor = -1
  393. ; If in half-octant 1, cjMajor = cjDelta + 1 and cjMinor = -cjDelta
  394. mov eax,[esi].ST_lNextScan
  395. mov ebx,[esi].ST_flFlips
  396. test ebx,FL_FLIP_HALF
  397. jz short sty3_halfoctant_3
  398. inc eax
  399. mov cjMajor,eax
  400. mov cjMinor,-1
  401. test ebx,FL_FLIP_D
  402. jnz short sty3_done_major_minor_comp
  403. neg eax
  404. inc eax
  405. mov cjMinor,eax
  406. jmp short sty3_done_major_minor_comp
  407. sty3_halfoctant_3:
  408. mov cjMajor,eax
  409. mov cjMinor,1
  410. sty3_done_major_minor_comp:
  411. mov eax,[esi].ST_pspEnd
  412. mov pspEnd,eax
  413. mov ebx,[esi].ST_pspStart
  414. sub ebx,eax ;compute cjStyleDelta
  415. sub ebx,4 ;make it exclusive
  416. mov cjStyleDelta,ebx
  417. mov edx,[esi].ST_spRemaining
  418. mov ulNumPixels,edx
  419. mov eax,[esi].ST_chAndXor
  420. mov ecx,[esi].ST_psp
  421. mov edx,[esi].ST_bIsGap
  422. mov edi,[esi].ST_pjScreen
  423. add esi,offset ST_alStrips
  424. mov ebx,[esi]
  425. add esi,4
  426. or edx,edx
  427. jz short sty3_output_loop ;if working on a dash, start there
  428. jmp short sty3_skip_loop ;if working on a gap, start there
  429. sty3_prepare_for_output:
  430. add ecx,4
  431. cmp pspEnd,ecx ;if (ecx == pspEnd + 4)
  432. sbb edx,edx ; then ecx = pspStart
  433. and edx,cjStyleDelta
  434. add ecx,edx
  435. mov ebx,ulNumPixels
  436. push eax
  437. mov eax,[ecx] ;get next style array element
  438. mov ulNumPixels,eax
  439. pop eax
  440. neg ebx ;adjust to do remainder of strip
  441. jz short sty3_output_get_new_strip
  442. sty3_output_loop:
  443. mov dl,[edi]
  444. and dl,al
  445. xor dl,ah
  446. mov [edi],dl ;write pixel
  447. add edi,cjMajor ;move to next scan
  448. dec ulNumPixels ;might have to go to next style element
  449. jz short sty3_prepare_for_skip
  450. dec ebx
  451. jnz short sty3_output_loop
  452. sty3_output_get_new_strip:
  453. add edi,cjMinor ;move one pixel in minor direction
  454. cmp esi,plStripEnd
  455. jae short sty3_output_all_done
  456. mov ebx,[esi] ;get next strip
  457. add esi,4
  458. jmp short sty3_output_loop
  459. sty3_output_all_done:
  460. mov esi,pStrips
  461. mov [esi].ST_pjScreen,edi
  462. mov [esi].ST_bIsGap,0 ;we were working on a dash
  463. mov edi,ulNumPixels
  464. mov [esi].ST_spRemaining,edi
  465. mov [esi].ST_psp,ecx
  466. cRet vStripStyled123
  467. sty3_prepare_for_skip:
  468. add ecx,4
  469. cmp pspEnd,ecx ;if (ecx == pspEnd + 4)
  470. sbb edx,edx ; then ecx = pspStart
  471. and edx,cjStyleDelta
  472. add ecx,edx
  473. dec ebx
  474. push eax
  475. mov eax,[ecx] ;get next style array element
  476. mov ulNumPixels,eax
  477. pop eax
  478. jz short sty3_skip_get_new_strip
  479. sty3_skip_loop:
  480. ; compute min(left in strip, left in style)
  481. sub ulNumPixels,ebx ;ulNumPixels = # style - # strip
  482. sbb edx,edx
  483. and edx,ulNumPixels
  484. add ebx,edx ;ebx = min(pels left in strip,
  485. ; pels left in style)
  486. mov edx,cjMajor
  487. imul edx,ebx
  488. add edi,edx ;adjust our pointer
  489. cmp ulNumPixels,0
  490. jle sty3_prepare_for_output
  491. sty3_skip_get_new_strip:
  492. add edi,cjMinor ;move one pixel in minor direction
  493. cmp esi,plStripEnd
  494. jae short sty3_skip_all_done
  495. mov ebx,[esi] ;get next strip
  496. add esi,4
  497. jmp short sty3_skip_loop
  498. sty3_skip_all_done:
  499. mov esi,pStrips
  500. mov [esi].ST_pjScreen,edi
  501. mov [esi].ST_bIsGap,0ffh ;we were working on a gap
  502. mov edi,ulNumPixels
  503. mov [esi].ST_spRemaining,edi
  504. mov [esi].ST_psp,ecx
  505. cRet vStripStyled123
  506. endProc vStripStyled123
  507. ;--------------------------Private-Routine------------------------------;
  508. ; vStripSolidSet0
  509. ;
  510. ; Draw lines in the 1st half-octant.
  511. ;
  512. ;-----------------------------------------------------------------------;
  513. cProc vStripSolidSet0,12,< \
  514. uses esi edi ebx, \
  515. pStrips: ptr STRIPS, \
  516. pls: ptr LINESTATE, \
  517. plStripEnd: ptr >
  518. ; Do some initializing:
  519. mov esi, pStrips
  520. push ebp
  521. mov ebp, plStripEnd
  522. mov eax,[esi].ST_lNextScan
  523. mov [ebp],eax ;copy delta
  524. mov eax,[esi].ST_chAndXor
  525. mov bl,ah
  526. mov bh,ah
  527. mov ah,al
  528. mov edi,[esi].ST_pjScreen
  529. add esi,offset ST_alStrips
  530. ; ax = and mask
  531. ; bx = xor mask
  532. ; ecx = pixel count
  533. ; dx = temporary register
  534. ; esi = strip pointer
  535. ; edi = display pointer
  536. ; ebp = ends of strips pointer
  537. ; [ebp] = delta
  538. mov ecx,[esi]
  539. add esi,4
  540. test edi,1
  541. jnz short sol0s_unaligned_start
  542. sol0s_aligned_loop:
  543. sub ecx,2
  544. jl short sol0s_strip_end_unaligned
  545. je short sol0s_strip_end_aligned
  546. mov [edi],bx
  547. add edi,2
  548. jmp short sol0s_aligned_loop
  549. sol0s_strip_end_aligned:
  550. mov [edi],bx
  551. add edi,2
  552. add edi,[ebp] ;go to next scan
  553. cmp esi,ebp
  554. jae short sol0s_all_done
  555. mov ecx,[esi]
  556. add esi,4
  557. jmp short sol0s_aligned_loop
  558. sol0s_strip_end_unaligned:
  559. mov [edi],bl ;do last pixel
  560. inc edi
  561. add edi,[ebp] ;go to next scan
  562. cmp esi,ebp
  563. jae short sol0s_all_done
  564. mov ecx,[esi] ;do first pixel of next strip
  565. add esi,4
  566. sol0s_unaligned_start:
  567. mov [edi],bl
  568. inc edi
  569. dec ecx
  570. jnz short sol0s_aligned_loop
  571. ; Have to be careful when there is only one pel in the strip and it starts
  572. ; on an unaligned address:
  573. add edi,[ebp]
  574. cmp esi,ebp
  575. jae short sol0s_all_done
  576. mov ecx,[esi]
  577. add esi,4
  578. jmp short sol0s_aligned_loop
  579. sol0s_all_done:
  580. pop ebp
  581. mov esi, pStrips
  582. mov [esi].ST_pjScreen,edi
  583. cRet vStripSolidSet0
  584. endProc vStripSolidSet0
  585. ;--------------------------Private-Routine------------------------------;
  586. ; vStripSolidSet1
  587. ;
  588. ; Draws lines in the 2nd half-octant.
  589. ;
  590. ;-----------------------------------------------------------------------;
  591. cProc vStripSolidSet1,12,< \
  592. uses esi edi ebx, \
  593. pStrips: ptr STRIPS, \
  594. pls: ptr LINESTATE, \
  595. plStripEnd: ptr >
  596. mov esi,pStrips
  597. push ebp
  598. mov ebp,plStripEnd
  599. mov ecx,[esi].ST_lNextScan
  600. inc ecx ; Make delta advance 1 to right
  601. mov eax,[esi].ST_chAndXor
  602. mov edi,[esi].ST_pjScreen
  603. add esi,offset ST_alStrips
  604. ; al = and mask
  605. ; ah = xor mask
  606. ; ebx = pixel count
  607. ; ecx = delta
  608. ; dl = temporary register
  609. ; esi = strip pointer
  610. ; edi = memory pointer
  611. ; ebp = end of strips pointer
  612. sol1s_next_diagonal:
  613. mov ebx,[esi]
  614. add esi, 4
  615. sol1s_diagonal_loop:
  616. mov [edi],ah
  617. add edi,ecx
  618. dec ebx
  619. jnz short sol1s_diagonal_loop
  620. sub edi,ecx
  621. inc edi
  622. cmp esi,ebp
  623. jb short sol1s_next_diagonal
  624. pop ebp
  625. mov esi, pStrips
  626. mov [esi].ST_pjScreen,edi
  627. cRet vStripSolidSet1
  628. endProc vStripSolidSet1
  629. ;--------------------------Private-Routine------------------------------;
  630. ; vStripSolidSet2
  631. ;
  632. ; Draws lines in the 3rd half-octant.
  633. ;
  634. ;-----------------------------------------------------------------------;
  635. cProc vStripSolidSet2,12,< \
  636. uses esi edi ebx, \
  637. pStrips: ptr STRIPS, \
  638. pls: ptr LINESTATE, \
  639. plStripEnd: ptr >
  640. mov esi,pStrips
  641. push ebp
  642. mov ebp,plStripEnd
  643. mov ecx,[esi].ST_lNextScan
  644. inc ecx ; Make delta advance 1 to right
  645. mov eax,[esi].ST_chAndXor
  646. mov edi,[esi].ST_pjScreen
  647. add esi,offset ST_alStrips
  648. ; al = and mask
  649. ; ah = xor mask
  650. ; ebx = pixel count
  651. ; ecx = delta
  652. ; dl = temporary register
  653. ; esi = strip pointer
  654. ; edi = memory pointer
  655. ; ebp = end of strips pointer
  656. sol2s_next_diagonal:
  657. mov ebx,[esi]
  658. add esi,4
  659. sol2s_diagonal_loop:
  660. mov [edi],ah
  661. add edi,ecx
  662. dec ebx
  663. jnz short sol2s_diagonal_loop
  664. dec edi
  665. cmp esi,ebp
  666. jb short sol2s_next_diagonal
  667. pop ebp
  668. mov esi, pStrips
  669. mov [esi].ST_pjScreen,edi
  670. cRet vStripSolidSet2
  671. endProc vStripSolidSet2
  672. ;--------------------------Private-Routine------------------------------;
  673. ; vStripSolidSet3
  674. ;
  675. ; Draws lines in the 4th half-octant.
  676. ;
  677. ;-----------------------------------------------------------------------;
  678. cProc vStripSolidSet3,12,< \
  679. uses esi edi ebx, \
  680. pStrips: ptr STRIPS, \
  681. pls: ptr LINESTATE, \
  682. plStripEnd: ptr >
  683. mov esi,pStrips
  684. push ebp
  685. mov ebp,plStripEnd
  686. mov ecx,[esi].ST_lNextScan
  687. mov eax,[esi].ST_chAndXor
  688. mov edi,[esi].ST_pjScreen
  689. add esi,offset ST_alStrips
  690. ; al = and mask
  691. ; ah = xor mask
  692. ; ebx = pixel count
  693. ; ecx = delta
  694. ; dl = temporary register
  695. ; esi = strip pointer
  696. ; edi = memory pointer
  697. ; ebp = end of strips pointer
  698. sol3s_next_vertical:
  699. mov ebx,[esi]
  700. add esi,4
  701. sol3s_vertical_loop:
  702. mov [edi],ah
  703. add edi,ecx
  704. dec ebx
  705. jnz short sol3s_vertical_loop
  706. inc edi
  707. cmp esi,ebp
  708. jb short sol3s_next_vertical
  709. pop ebp
  710. mov esi,pStrips
  711. mov [esi].ST_pjScreen,edi
  712. cRet vStripSolidSet3
  713. endProc vStripSolidSet3
  714. ;--------------------------Private-Routine------------------------------;
  715. ; vStripStyledSet0
  716. ;
  717. ; Draws styled lines in the 1st half-octant.
  718. ;
  719. ;-----------------------------------------------------------------------;
  720. cProc vStripStyledSet0,12,< \
  721. uses esi edi ebx, \
  722. pStrips: ptr STRIPS, \
  723. pls: ptr LINESTATE, \
  724. plStripEnd: ptr >
  725. local ulNumPixels: dword ;# of pixels in current style
  726. local pspEnd: dword ;pointer to end of style array
  727. local cjMajor: dword ;lNextScan for screen
  728. local cjStyleDelta: dword ;delta from end of style array to start
  729. ; al = and mask
  730. ; ah = xor mask
  731. ; ebx = # of pixels in current strip
  732. ; ecx = style pointer
  733. ; edx = temporary register
  734. ; esi = strips pointer
  735. ; edi = memory pointer
  736. mov esi,pStrips
  737. mov eax,[esi].ST_lNextScan
  738. mov cjMajor,eax
  739. mov eax,[esi].ST_pspEnd
  740. mov pspEnd,eax
  741. mov ebx,[esi].ST_pspStart
  742. sub ebx,eax ;compute cjStyleDelta
  743. sub ebx,4 ;make it exclusive
  744. mov cjStyleDelta,ebx
  745. mov edx,[esi].ST_spRemaining
  746. mov ulNumPixels,edx
  747. mov eax,[esi].ST_chAndXor
  748. mov ecx,[esi].ST_psp
  749. mov edx,[esi].ST_bIsGap
  750. mov edi,[esi].ST_pjScreen
  751. add esi,offset ST_alStrips
  752. mov ebx,[esi]
  753. add esi,4
  754. or edx,edx
  755. jz short sty0s_output_loop ;if working on a dash, start there
  756. jmp short sty0s_skip_loop ;if working on a gap, start there
  757. sty0s_prepare_for_output:
  758. add edi,ulNumPixels ;adjust to do remainder of strip
  759. add ecx,4
  760. cmp pspEnd,ecx ;if (ecx == pspEnd + 4)
  761. sbb edx,edx ; then ecx = pspStart
  762. and edx,cjStyleDelta
  763. add ecx,edx
  764. mov ebx,ulNumPixels
  765. push eax
  766. mov eax,[ecx] ;get next style array element
  767. mov ulNumPixels,eax
  768. pop eax
  769. neg ebx ;see if we also need a new strip
  770. jz short sty0s_output_get_new_strip
  771. sty0s_output_loop:
  772. mov [edi],ah ;write pixel
  773. inc edi ;move one pixel to right
  774. dec ulNumPixels ;might have to go to next style element
  775. jz short sty0s_prepare_for_skip
  776. dec ebx
  777. jnz short sty0s_output_loop
  778. sty0s_output_get_new_strip:
  779. add edi,cjMajor ;move up one scan
  780. cmp esi,plStripEnd
  781. jae short sty0s_output_all_done
  782. mov ebx,[esi] ;get next strip
  783. add esi,4
  784. jmp short sty0s_output_loop
  785. sty0s_output_all_done:
  786. mov esi,pStrips
  787. mov [esi].ST_pjScreen,edi
  788. mov [esi].ST_bIsGap,0 ;we were working on a dash
  789. mov edi,ulNumPixels
  790. mov [esi].ST_spRemaining,edi
  791. mov [esi].ST_psp,ecx
  792. cRet vStripStyledSet0
  793. sty0s_prepare_for_skip:
  794. add ecx,4
  795. cmp pspEnd,ecx ;if (ecx == pspEnd + 4)
  796. sbb edx,edx ; then ecx = pspStart
  797. and edx,cjStyleDelta
  798. add ecx,edx
  799. dec ebx
  800. push eax
  801. mov eax,[ecx] ;get next style array element
  802. mov ulNumPixels,eax
  803. pop eax
  804. jz short sty0s_skip_get_new_strip
  805. sty0s_skip_loop:
  806. add edi,ebx ;assume we'll skip entire strip
  807. sub ulNumPixels,ebx ; (we'll correct it if not)
  808. jle short sty0s_prepare_for_output
  809. sty0s_skip_get_new_strip:
  810. add edi,cjMajor ;move up one scan
  811. cmp esi,plStripEnd
  812. jae short sty0s_skip_all_done
  813. mov ebx,[esi] ;get next strip
  814. add esi,4
  815. jmp short sty0s_skip_loop
  816. sty0s_skip_all_done:
  817. mov esi,pStrips
  818. mov [esi].ST_pjScreen,edi
  819. mov [esi].ST_bIsGap,0ffh ;we were working on a gap
  820. mov edi,ulNumPixels
  821. mov [esi].ST_spRemaining,edi
  822. mov [esi].ST_psp,ecx
  823. cRet vStripStyledSet0
  824. endProc vStripStyledSet0
  825. ;--------------------------Private-Routine------------------------------;
  826. ; vStripStyledSet123
  827. ;
  828. ; Draws styled lines in the 2nd, 3rd and 4th half-octants.
  829. ;
  830. ;-----------------------------------------------------------------------;
  831. cProc vStripStyledSet123,12,< \
  832. uses esi edi ebx, \
  833. pStrips: ptr STRIPS, \
  834. pls: ptr LINESTATE, \
  835. plStripEnd: ptr >
  836. local ulNumPixels: dword ;# of pixels in current style
  837. local pspEnd: dword ;pointer to end of style array
  838. local cjMajor: dword ;delta to go in major direction
  839. local cjMinor: dword ;delta to go in minor direction
  840. local cjStyleDelta: dword ;delta from end of style array to start
  841. ; al = and mask
  842. ; ah = xor mask
  843. ; ebx = # of pixels in current strip
  844. ; ecx = style pointer
  845. ; edx = temporary register
  846. ; esi = strips pointer
  847. ; edi = memory pointer
  848. mov esi,pStrips
  849. ; If in half-octant 3, cjMajor = cjDelta and cjMinor = 1
  850. ; If in half-octant 2, cjMajor = cjDelta + 1 and cjMinor = -1
  851. ; If in half-octant 1, cjMajor = cjDelta + 1 and cjMinor = -cjDelta
  852. mov eax,[esi].ST_lNextScan
  853. mov ebx,[esi].ST_flFlips
  854. test ebx,FL_FLIP_HALF
  855. jz short sty3s_halfoctant_3
  856. inc eax
  857. mov cjMajor,eax
  858. mov cjMinor,-1
  859. test ebx,FL_FLIP_D
  860. jnz short sty3s_done_major_minor_comp
  861. neg eax
  862. inc eax
  863. mov cjMinor,eax
  864. jmp short sty3s_done_major_minor_comp
  865. sty3s_halfoctant_3:
  866. mov cjMajor,eax
  867. mov cjMinor,1
  868. sty3s_done_major_minor_comp:
  869. mov eax,[esi].ST_pspEnd
  870. mov pspEnd,eax
  871. mov ebx,[esi].ST_pspStart
  872. sub ebx,eax ;compute cjStyleDelta
  873. sub ebx,4 ;make it exclusive
  874. mov cjStyleDelta,ebx
  875. mov edx,[esi].ST_spRemaining
  876. mov ulNumPixels,edx
  877. mov eax,[esi].ST_chAndXor
  878. mov ecx,[esi].ST_psp
  879. mov edx,[esi].ST_bIsGap
  880. mov edi,[esi].ST_pjScreen
  881. add esi,offset ST_alStrips
  882. mov ebx,[esi]
  883. add esi,4
  884. or edx,edx
  885. jz short sty3s_output_loop ;if working on a dash, start there
  886. jmp short sty3s_skip_loop ;if working on a gap, start there
  887. sty3s_prepare_for_output:
  888. add ecx,4
  889. cmp pspEnd,ecx ;if (ecx == pspEnd + 4)
  890. sbb edx,edx ; then ecx = pspStart
  891. and edx,cjStyleDelta
  892. add ecx,edx
  893. mov ebx,ulNumPixels
  894. push eax
  895. mov eax,[ecx] ;get next style array element
  896. mov ulNumPixels,eax
  897. pop eax
  898. neg ebx ;adjust to do remainder of strip
  899. jz short sty3s_output_get_new_strip
  900. sty3s_output_loop:
  901. mov [edi],ah ;write pixel
  902. add edi,cjMajor ;move to next scan
  903. dec ulNumPixels ;might have to go to next style element
  904. jz short sty3s_prepare_for_skip
  905. dec ebx
  906. jnz short sty3s_output_loop
  907. sty3s_output_get_new_strip:
  908. add edi,cjMinor ;move in minor direction
  909. cmp esi,plStripEnd
  910. jae short sty3s_output_all_done
  911. mov ebx,[esi] ;get next strip
  912. add esi,4
  913. jmp short sty3s_output_loop
  914. sty3s_output_all_done:
  915. mov esi,pStrips
  916. mov [esi].ST_pjScreen,edi
  917. mov [esi].ST_bIsGap,0 ;we were working on a dash
  918. mov edi,ulNumPixels
  919. mov [esi].ST_spRemaining,edi
  920. mov [esi].ST_psp,ecx
  921. cRet vStripStyledSet123
  922. sty3s_prepare_for_skip:
  923. add ecx,4
  924. cmp pspEnd,ecx ;if (ecx == pspEnd + 4)
  925. sbb edx,edx ; then ecx = pspStart
  926. and edx,cjStyleDelta
  927. add ecx,edx
  928. dec ebx
  929. push eax
  930. mov eax,[ecx] ;get next style array element
  931. mov ulNumPixels,eax
  932. pop eax
  933. jz short sty3s_skip_get_new_strip
  934. sty3s_skip_loop:
  935. ; compute min(left in strip, left in style)
  936. sub ulNumPixels,ebx ;ulNumPixels = # style - # strip
  937. sbb edx,edx
  938. and edx,ulNumPixels
  939. add ebx,edx ;ebx = min(pels left in strip,
  940. ; pels left in style)
  941. mov edx,cjMajor
  942. imul edx,ebx
  943. add edi,edx ;adjust our pointer
  944. cmp ulNumPixels,0
  945. jle sty3s_prepare_for_output
  946. sty3s_skip_get_new_strip:
  947. add edi,cjMinor ;move in minor direction
  948. cmp esi,plStripEnd
  949. jae short sty3s_skip_all_done
  950. mov ebx,[esi] ;get next strip
  951. add esi,4
  952. jmp short sty3s_skip_loop
  953. sty3s_skip_all_done:
  954. mov esi,pStrips
  955. mov [esi].ST_pjScreen,edi
  956. mov [esi].ST_bIsGap,0ffh ;we were working on a gap
  957. mov edi,ulNumPixels
  958. mov [esi].ST_spRemaining,edi
  959. mov [esi].ST_psp,ecx
  960. cRet vStripStyledSet123
  961. endProc vStripStyledSet123
  962. end