Source code of Windows XP (NT5)
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.

1471 lines
41 KiB

  1. page ,132
  2. ;----------------------------Module-Header------------------------------;
  3. ; Module Name: STRETCH32.ASM
  4. ;
  5. ; StretchBLT for DIBs
  6. ;
  7. ; NOTES:
  8. ; - Does not handle mirroring in x or y.
  9. ; - Does not handle pixel translation
  10. ; - will not work "in place"
  11. ;
  12. ; - This is the 32 bit version (32 bit code seg that is...)
  13. ;
  14. ; AUTHOR: ToddLa (Todd Laney) Microsoft
  15. ;
  16. ;-----------------------------------------------------------------------;
  17. ?PLM=1
  18. ?WIN=0
  19. .xlist
  20. include cmacro32.inc
  21. ; include cmacros.inc
  22. include windows.inc
  23. .list
  24. sBegin Data
  25. sEnd Data
  26. ifndef SEGNAME
  27. SEGNAME equ <_TEXT>
  28. endif
  29. createSeg %SEGNAME, CodeSeg, word, public, CODE
  30. sBegin CodeSeg
  31. .386
  32. assumes cs,CodeSeg
  33. assumes ds,nothing
  34. assumes es,nothing
  35. ;--------------------------------------------------------------------------;
  36. ;
  37. ; DDA type constants returned from stretch_init_dda
  38. ;
  39. ;--------------------------------------------------------------------------;
  40. STRETCH_1to1 equ (0*4) ; dst = src
  41. STRETCH_1to2 equ (1*4) ; dst = src * 2
  42. STRETCH_1to4 equ (2*4) ; dst = src * 4
  43. STRETCH_1toN equ (3*4) ; dst > src
  44. STRETCH_2to1 equ (4*4) ; dst = src / 2
  45. STRETCH_4to1 equ (5*4) ; dst = src / 4
  46. STRETCH_Nto1 equ (6*4) ; dst < src
  47. STRETCH_VOID equ (7*4) ; not used.
  48. ;--------------------------------------------------------------------------;
  49. ;
  50. ; x_stretch_functions
  51. ;
  52. ; functions for stretching a single scanline, this table is indexed
  53. ; by the x dda type (see above) and the bit depth
  54. ;
  55. ;--------------------------------------------------------------------------;
  56. x_stretch_functions label dword ;function table for x_stretch
  57. x_stretch_8_functions label dword ;function table for x_stretch
  58. dd x_stretch_1to1 ; STRETCH_1to1
  59. dd x_stretch_8_1to2 ; STRETCH_1to2
  60. dd x_stretch_8_1to4 ; STRETCH_1to4
  61. dd x_stretch_8_1toN ; STRETCH_1toN
  62. dd x_stretch_8_Nto1 ; STRETCH_2to1
  63. dd x_stretch_8_Nto1 ; STRETCH_4to1
  64. dd x_stretch_8_Nto1 ; STRETCH_Nto1
  65. dd 0
  66. x_stretch_16_functions label dword ;function table for x_stretch
  67. dd x_stretch_1to1 ; STRETCH_1to1
  68. dd x_stretch_16_1to2 ; STRETCH_1to2
  69. dd x_stretch_16_1toN ; STRETCH_1to4
  70. dd x_stretch_16_1toN ; STRETCH_1toN
  71. dd x_stretch_16_Nto1 ; STRETCH_2to1
  72. dd x_stretch_16_Nto1 ; STRETCH_4to1
  73. dd x_stretch_16_Nto1 ; STRETCH_Nto1
  74. dd 0
  75. x_stretch_24_functions label dword ;function table for x_stretch
  76. dd x_stretch_1to1 ; STRETCH_1to1
  77. dd x_stretch_24_1toN ; STRETCH_1to2
  78. dd x_stretch_24_1toN ; STRETCH_1to4
  79. dd x_stretch_24_1toN ; STRETCH_1toN
  80. dd x_stretch_24_Nto1 ; STRETCH_2to1
  81. dd x_stretch_24_Nto1 ; STRETCH_4to1
  82. dd x_stretch_24_Nto1 ; STRETCH_Nto1
  83. dd 0
  84. x_stretch_32_functions label dword ;function table for x_stretch
  85. dd x_stretch_1to1 ; STRETCH_1to1
  86. dd x_stretch_32_1to2 ; STRETCH_1to2
  87. dd x_stretch_32_1toN ; STRETCH_1to4
  88. dd x_stretch_32_1toN ; STRETCH_1toN
  89. dd x_stretch_32_Nto1 ; STRETCH_2to1
  90. dd x_stretch_32_Nto1 ; STRETCH_4to1
  91. dd x_stretch_32_Nto1 ; STRETCH_Nto1
  92. dd 0
  93. ;--------------------------------------------------------------------------;
  94. ;
  95. ; y_stretch_functions
  96. ;
  97. ; functions for stretching in the y direction, indexed by the y dda type
  98. ;
  99. ;--------------------------------------------------------------------------;
  100. y_stretch_functions label dword ;function table for y_stretch
  101. dd y_stretch_1toN ; STRETCH_1to1
  102. dd y_stretch_1toN ; STRETCH_1to2
  103. dd y_stretch_1toN ; STRETCH_1to4
  104. dd y_stretch_1toN ; STRETCH_1toN
  105. dd y_stretch_Nto1 ; STRETCH_2to1
  106. dd y_stretch_Nto1 ; STRETCH_4to1
  107. dd y_stretch_Nto1 ; STRETCH_Nto1
  108. ;--------------------------------------------------------------------------;
  109. ;
  110. ; stretch_functions
  111. ;
  112. ; special case stretching routines, used if (y dda type) = (x dda type)
  113. ; (and entry exists in this table)
  114. ;
  115. ; these functions stretch the entire image.
  116. ;
  117. ;--------------------------------------------------------------------------;
  118. stretch_functions label dword
  119. stretch_8_functions label dword
  120. dd 0 ; STRETCH_1to1
  121. dd stretch_8_1to2 ; STRETCH_1to2
  122. dd 0 ; STRETCH_1to4
  123. dd 0 ; STRETCH_1toN
  124. dd 0 ; STRETCH_2to1
  125. dd 0 ; STRETCH_4to1
  126. dd 0 ; STRETCH_Nto1
  127. dd 0
  128. stretch_16_functions label dword
  129. dd 0 ; STRETCH_1to1
  130. dd stretch_16_1to2 ; STRETCH_1to2
  131. dd 0 ; STRETCH_1to4
  132. dd 0 ; STRETCH_1toN
  133. dd 0 ; STRETCH_2to1
  134. dd 0 ; STRETCH_4to1
  135. dd 0 ; STRETCH_Nto1
  136. dd 0
  137. stretch_24_functions label dword
  138. dd 0 ; STRETCH_1to1
  139. dd 0 ; STRETCH_1to2
  140. dd 0 ; STRETCH_1to4
  141. dd 0 ; STRETCH_1toN
  142. dd 0 ; STRETCH_2to1
  143. dd 0 ; STRETCH_4to1
  144. dd 0 ; STRETCH_Nto1
  145. dd 0
  146. stretch_32_functions label dword
  147. dd 0 ; STRETCH_1to1
  148. dd 0 ; STRETCH_1to2
  149. dd 0 ; STRETCH_1to4
  150. dd 0 ; STRETCH_1toN
  151. dd 0 ; STRETCH_2to1
  152. dd 0 ; STRETCH_4to1
  153. dd 0 ; STRETCH_Nto1
  154. dd 0
  155. ;--------------------------------------------------------------------------;
  156. ;
  157. ; StretchDIB()
  158. ;
  159. ; Entry:
  160. ; Stack based parameters as described below.
  161. ;
  162. ; Returns:
  163. ; none
  164. ;
  165. ; Registers Preserved:
  166. ; DS,ES,ESI,EDI,EBP
  167. ;
  168. ;--------------------------------------------------------------------------;
  169. assumes ds,nothing
  170. assumes es,nothing
  171. cProc StretchDIB,<FAR,PUBLIC,PASCAL>,<>
  172. parmD biDst ;--> BITMAPINFO of dest
  173. parmD lpDst ;--> to destination bits
  174. parmW DstX ;Destination origin - x coordinate
  175. parmW DstY ;Destination origin - y coordinate
  176. parmW DstXE ;x extent of the BLT
  177. parmW DstYE ;y extent of the BLT
  178. parmD biSrc ;--> BITMAPINFO of source
  179. parmD lpSrc ;--> to source bits
  180. parmW SrcX ;Source origin - x coordinate
  181. parmW SrcY ;Source origin - y coordinate
  182. parmW SrcXE ;x extent of the BLT
  183. parmW SrcYE ;y extent of the BLT
  184. localD x_stretch ;X stretch function
  185. localD y_stretch ;Y stretch function
  186. localD x_stretch_dda ;X stretch DDA
  187. localD x_stretch_dda_fract ;X stretch DDA fract
  188. localD y_stretch_dda ;Y stretch DDA
  189. localD y_stretch_dda_fract ;Y stretch DDA fract
  190. localD ScanCount ;number of scans left to do
  191. localD Yerr ;Y dda error
  192. localD SrcWidth ;width of source dib in bytes
  193. localD DstWidth ;width of dest in bytes
  194. localD SrcBytes ;width of source blt in bytes
  195. localD DstBytes ;width of dest blt in bytes
  196. localD SrcInc
  197. localD DstInc
  198. localD lDstXE ;x extent of the BLT
  199. localD lDstYE ;y extent of the BLT
  200. localD lSrcXE ;x extent of the BLT
  201. localD lSrcYE ;y extent of the BLT
  202. cBegin
  203. cld
  204. push esi
  205. push edi
  206. push ds
  207. call stretch_init ; init all the frame variables
  208. jc short StretchDIBExit
  209. call y_stretch ; do it!
  210. StretchDIBExit:
  211. pop ds
  212. pop edi
  213. pop esi
  214. cEnd
  215. ;--------------------------------------------------------------------------;
  216. ;
  217. ; stretch_init_dda
  218. ;
  219. ; initialize the parameters of a DDA from ax to dx.
  220. ;
  221. ; Entry:
  222. ; eax - source coord
  223. ; edx - dest coord
  224. ; Returns:
  225. ; eax - STRETCH_1to1
  226. ; STRETCH_1to2
  227. ; STRETCH_1to4
  228. ; STRETCH_1toN
  229. ; STRETCH_2to1
  230. ; STRETCH_4to1
  231. ; STRETCH_Nto1
  232. ;
  233. ; edx - src / dst
  234. ; ebx - src / dst fraction
  235. ;
  236. ;--------------------------------------------------------------------------;
  237. stretch_init_dda proc near
  238. cmp eax,edx
  239. je short stretch_init_dda_1to1
  240. ja short stretch_init_dda_Nto1
  241. errn$ stretch_init_dda_1toN
  242. stretch_init_dda_1toN:
  243. mov ebx,eax
  244. add ebx,ebx
  245. cmp ebx,edx
  246. je short stretch_init_dda_1to2
  247. add ebx,ebx
  248. cmp ebx,edx
  249. je short stretch_init_dda_1to4
  250. mov ebx,edx ; ebx = dest
  251. mov edx,eax ; edx = src
  252. xor eax,eax ; edx:eax = src<<32
  253. div ebx ; eax = (src<<32)/dst
  254. mov ebx,eax
  255. xor edx,edx
  256. mov eax,STRETCH_1toN
  257. ret
  258. stretch_init_dda_Nto1:
  259. mov ebx,edx
  260. add ebx,ebx
  261. cmp eax,ebx
  262. je short stretch_init_dda_2to1
  263. add ebx,ebx
  264. cmp eax,ebx
  265. je short stretch_init_dda_4to1
  266. mov ebx,edx ; ebx = dst
  267. xor edx,edx ; edx:eax = src
  268. mov eax,eax
  269. div ebx ; eax = src/dst edx = rem
  270. push eax
  271. xor eax,eax ; edx:eax = rem<<32
  272. div ebx ; eax = rem<<32/dst
  273. mov ebx,eax
  274. pop edx
  275. mov eax,STRETCH_Nto1
  276. ret
  277. stretch_init_dda_1to1:
  278. mov edx, 1
  279. xor ebx, ebx
  280. mov eax, STRETCH_1to1
  281. ret
  282. stretch_init_dda_1to2:
  283. xor edx, edx
  284. mov ebx, 80000000h
  285. mov eax, STRETCH_1to2
  286. ret
  287. stretch_init_dda_1to4:
  288. xor edx, edx
  289. mov ebx, 40000000h
  290. mov eax, STRETCH_1to4
  291. ret
  292. stretch_init_dda_2to1:
  293. mov edx, 2
  294. xor ebx, ebx
  295. mov eax, STRETCH_2to1
  296. ret
  297. stretch_init_dda_4to1:
  298. mov edx, 4
  299. xor ebx, ebx
  300. mov eax, STRETCH_4to1
  301. ret
  302. stretch_init_dda endp
  303. ;--------------------------------------------------------------------------;
  304. ;
  305. ; stretch_init
  306. ;
  307. ; init local frame vars for StretchDIB
  308. ;
  309. ; ENTRY:
  310. ; ss:bp --> stretchdib frame
  311. ;
  312. ;--------------------------------------------------------------------------;
  313. stretch_init_error:
  314. stc
  315. ret
  316. stretch_init proc near
  317. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  318. ; expand word params to dwords
  319. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  320. movzx eax,DstXE
  321. movzx ebx,DstYE
  322. movzx ecx,SrcXE
  323. movzx edx,SrcYE
  324. mov lDstXE,eax
  325. mov lDstYE,ebx
  326. mov lSrcXE,ecx
  327. mov lSrcYE,edx
  328. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  329. ; Make sure they didn't give us an extent of zero anywhere
  330. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  331. or eax,eax
  332. jz short stretch_init_error
  333. or ebx,ebx
  334. jz short stretch_init_error
  335. or ecx,ecx
  336. jz short stretch_init_error
  337. or edx,edx
  338. jz short stretch_init_error
  339. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  340. ; make sure the bit depth of the source and dest match and are valid
  341. ; we only handle 8,16,24 bit depths.
  342. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  343. xor edi,edi ; be sure the high words are clear.
  344. xor esi,esi
  345. xor ecx,ecx
  346. lds si, biSrc
  347. les di, biDst
  348. mov cx, [esi].biBitCount ; get the bit depth
  349. cmp cx, es:[edi].biBitCount ; make sure they are the same.
  350. jne short stretch_init_error
  351. cmp ecx,8
  352. je short stretch_init_bit_depth_ok
  353. cmp ecx,16
  354. je short stretch_init_bit_depth_ok
  355. cmp ecx,24
  356. je short stretch_init_bit_depth_ok
  357. cmp ecx,32
  358. jne short stretch_init_error
  359. errn$ stretch_init_bit_depth_ok
  360. stretch_init_bit_depth_ok:
  361. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  362. ;
  363. ; Set up the initial source pointer
  364. ;
  365. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  366. mov eax,[esi].biWidth
  367. mul ecx
  368. add eax,31
  369. and eax,not 31
  370. shr eax,3
  371. mov SrcWidth,eax
  372. mov SrcInc,eax
  373. lds si,lpSrc
  374. movzx edx,SrcY
  375. mul edx
  376. add esi,eax
  377. movzx eax,SrcX
  378. mul ecx
  379. shr eax,3
  380. add esi,eax
  381. mov eax,lSrcXE
  382. mul ecx
  383. shr eax,3
  384. mov SrcBytes,eax
  385. sub SrcInc,eax
  386. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  387. ;
  388. ; Set up the initial dest pointer
  389. ;
  390. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  391. mov eax,es:[edi].biWidth
  392. mul ecx
  393. add eax,31
  394. and eax,not 31
  395. shr eax,3
  396. mov DstWidth,eax
  397. mov DstInc,eax
  398. cmp es:[edi].biHeight,0 ; init a upside down DIB
  399. jge short @f
  400. movsx ebx,DstY
  401. add ebx,es:[edi].biHeight
  402. not ebx
  403. mov DstY,bx
  404. neg DstWidth
  405. neg DstInc
  406. @@:
  407. les di,lpDst
  408. movsx edx,DstY
  409. mul edx
  410. add edi,eax
  411. movsx eax,DstX
  412. mul ecx
  413. shr eax,3
  414. add edi,eax
  415. mov eax,lDstXE
  416. mul ecx
  417. shr eax,3
  418. mov DstBytes,eax
  419. sub DstInc,eax
  420. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  421. ;
  422. ; conver the bit depth (in cx) to a table index
  423. ;
  424. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  425. sub ecx,8 ; cx = 0,8,16,24
  426. shl ecx,2 ; cx = (0,1,2,3) * 32
  427. errnz <stretch_16_functions - stretch_8_functions - 32>
  428. errnz <stretch_24_functions - stretch_16_functions - 32>
  429. errnz <stretch_32_functions - stretch_24_functions - 32>
  430. errnz <x_stretch_16_functions - x_stretch_8_functions - 32>
  431. errnz <x_stretch_24_functions - x_stretch_16_functions - 32>
  432. errnz <x_stretch_32_functions - x_stretch_24_functions - 32>
  433. errnz <STRETCH_1to2 - STRETCH_1to1 - 4>
  434. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  435. ;
  436. ; Setup y_stretch function pointer
  437. ;
  438. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  439. mov eax,lSrcYE
  440. mov edx,lDstYE
  441. call stretch_init_dda
  442. mov y_stretch_dda,edx
  443. mov y_stretch_dda_fract,ebx
  444. mov ebx,eax
  445. mov edx,y_stretch_functions[ebx]
  446. mov y_stretch,edx
  447. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  448. ;
  449. ; Setup x_stretch function pointer
  450. ;
  451. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  452. push eax ; Save Y stretch type
  453. mov eax,lSrcXE
  454. mov edx,lDstXE
  455. call stretch_init_dda
  456. mov x_stretch_dda,edx
  457. mov x_stretch_dda_fract,ebx
  458. mov ebx,eax ; get x stretch
  459. or ebx,ecx ; or in bit depth
  460. mov edx,x_stretch_functions[ebx]
  461. mov x_stretch,edx
  462. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  463. ;
  464. ; check for a special case stretch routine
  465. ;
  466. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  467. pop edx ; get y stretch back
  468. cmp eax,edx ; is x stretch == to y stretch?
  469. jne short stretch_init_exit
  470. or ebx,ecx
  471. mov edx,stretch_functions[ebx]
  472. or edx,edx
  473. jz short stretch_init_exit
  474. mov y_stretch,edx ; we have special case routine.
  475. errn$ stretch_init_exit
  476. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  477. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  478. stretch_init_exit:
  479. clc
  480. ret
  481. stretch_init endp
  482. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  483. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  484. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  485. ;--------------------------------------------------------------------------;
  486. ;
  487. ; y_stretch_1toN
  488. ;
  489. ; do the entire stretch, y stretching (DstYE > SrcYE)
  490. ;
  491. ; Entry:
  492. ; ds:esi --> (SrcX, SrcY) in source
  493. ; es:edi --> (DstX, DstY) in destination
  494. ; ss:bp --> stack frame of StretchDIB
  495. ; Returns:
  496. ; none. (stretch is done.)
  497. ;--------------------------------------------------------------------------;
  498. y_stretch_1toN proc near
  499. mov ecx,lDstYE
  500. mov ScanCount,ecx
  501. mov edx,lDstYE ; dda error
  502. dec edx
  503. mov Yerr,edx
  504. y_stretch_1toN_loop:
  505. push esi
  506. push edi
  507. call x_stretch
  508. pop edi
  509. pop esi
  510. add edi, DstWidth ; next dest scan.
  511. mov eax,lSrcYE
  512. sub Yerr,eax
  513. jnc short y_stretch_1toN_next
  514. mov eax,lDstYE
  515. add Yerr,eax
  516. add esi, SrcWidth ; next source scan.
  517. y_stretch_1toN_next:
  518. dec ScanCount
  519. jnz short y_stretch_1toN_loop
  520. ret
  521. y_stretch_1toN endp
  522. ;--------------------------------------------------------------------------;
  523. ;
  524. ; y_stretch_Nto1
  525. ;
  526. ; do the entire stretch, y shrinking (DstYE < SrcYE)
  527. ;
  528. ; Entry:
  529. ; ds:esi --> (SrcX, SrcY) in source
  530. ; es:edi --> (DstX, DstY) in destination
  531. ; ss:bp --> stack frame of StretchDIB
  532. ; Returns:
  533. ; none. (stretch is done.)
  534. ;--------------------------------------------------------------------------;
  535. y_stretch_Nto1 proc near
  536. mov ecx,lDstYE
  537. mov ScanCount,ecx
  538. mov edx,lSrcYE ; dda error
  539. dec edx
  540. mov Yerr,edx
  541. y_stretch_Nto1_loop:
  542. push esi
  543. push edi
  544. call x_stretch
  545. pop edi
  546. pop esi
  547. add edi, DstWidth ; next dest scan.
  548. mov eax, lDstYE
  549. @@: add esi, SrcWidth ; next source scan.
  550. sub Yerr, eax
  551. jnc short @b
  552. mov eax,lSrcYE
  553. add Yerr,eax
  554. y_stretch_Nto1_next:
  555. dec ScanCount
  556. jnz short y_stretch_Nto1_loop
  557. ret
  558. y_stretch_Nto1 endp
  559. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  560. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  561. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  562. ;--------------------------------------------------------------------------;
  563. ;
  564. ; x_stretch_1to1
  565. ;
  566. ; handle a stretch of a scanline (DstXE == SrcXE)
  567. ;
  568. ; Entry:
  569. ; ds:esi --> begining of scan
  570. ; es:edi --> destination scan
  571. ; ss:bp --> stack frame of StretchDIB
  572. ; Returns:
  573. ; ds:esi --> at end of scan
  574. ; es:edi --> at end of scan
  575. ;
  576. ;--------------------------------------------------------------------------;
  577. align 4
  578. x_stretch_1to1 proc near
  579. mov ecx,DstBytes ; number of bytes to copy
  580. mov ebx,ecx
  581. shr ecx,2 ; get count in DWORDs
  582. rep movs dword ptr es:[edi], dword ptr ds:[esi]
  583. mov ecx,ebx
  584. and ecx,3
  585. rep movs byte ptr es:[edi], byte ptr ds:[esi]
  586. ret
  587. x_stretch_1to1 endp
  588. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  589. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8 BIT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  590. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  591. ;--------------------------------------------------------------------------;
  592. ;
  593. ; x_stretch_8_1toN
  594. ;
  595. ; handle a stretch of a scanline (DstXE > SrcXE)
  596. ;
  597. ; Entry:
  598. ; ds:esi --> begining of scan
  599. ; es:edi --> destination scan
  600. ; ss:bp --> stack frame of StretchDIB
  601. ; Returns:
  602. ; ds:esi --> at end of scan
  603. ; es:edi --> at end of scan
  604. ;
  605. ;--------------------------------------------------------------------------;
  606. align 4
  607. x_stretch_8_1toN proc near
  608. mov ebx,x_stretch_dda_fract
  609. xor edx,edx
  610. mov ecx,lDstXE ; # bytes to store
  611. shr ecx,2 ; unroll by 4
  612. jz short x_stretch_8_1toN_next
  613. align 4
  614. x_stretch_8_1toN_loop:
  615. rept 2
  616. mov al,byte ptr ds:[esi]
  617. add edx,ebx
  618. adc esi,0
  619. mov ah,byte ptr ds:[esi]
  620. add edx,ebx
  621. adc esi,0
  622. ror eax,16
  623. endm
  624. mov dword ptr es:[edi],eax
  625. add edi,4
  626. dec ecx
  627. jnz short x_stretch_8_1toN_loop
  628. x_stretch_8_1toN_next:
  629. mov ecx,lDstXE
  630. and ecx,3
  631. jnz short x_stretch_8_1toN_odd
  632. ret
  633. x_stretch_8_1toN_odd:
  634. mov al,byte ptr ds:[esi]
  635. mov byte ptr es:[edi],al
  636. add edx,ebx
  637. adc esi,0
  638. inc edi
  639. dec ecx
  640. jnz short x_stretch_8_1toN_odd
  641. ret
  642. x_stretch_8_1toN endp
  643. ;--------------------------------------------------------------------------;
  644. ;
  645. ; x_stretch_8_1to2
  646. ;
  647. ; handle a stretch of a scanline (DstXE > SrcXE)
  648. ;
  649. ; Entry:
  650. ; ds:esi --> begining of scan
  651. ; es:edi --> destination scan
  652. ; ss:bp --> stack frame of StretchDIB
  653. ; Returns:
  654. ; ds:esi --> at end of scan
  655. ; es:edi --> at end of scan
  656. ;
  657. ;--------------------------------------------------------------------------;
  658. align 4
  659. x_stretch_8_1to2 proc near
  660. mov ecx,lSrcXE ; loop cout
  661. mov ebx,ecx
  662. shr ecx,1
  663. jz short x_stretch_8_1to2_next
  664. align 4
  665. x_stretch_8_1to2_loop:
  666. mov ax, word ptr ds:[esi] ; get 2 pixels
  667. add esi,2
  668. mov edx,eax
  669. mov al,ah
  670. shl eax,16
  671. mov al,dl
  672. mov ah,dl
  673. mov dword ptr es:[edi], eax ; store 4
  674. add edi,4
  675. dec ecx
  676. jnz short x_stretch_8_1to2_loop
  677. x_stretch_8_1to2_next:
  678. test ebx,1
  679. jnz short x_stretch_8_1to2_done
  680. ret
  681. x_stretch_8_1to2_done:
  682. mov al,byte ptr ds:[esi]
  683. mov ah,al
  684. mov word ptr es:[edi],ax
  685. inc esi
  686. add edi,2
  687. ret
  688. x_stretch_8_1to2 endp
  689. ;--------------------------------------------------------------------------;
  690. ;
  691. ; x_stretch_8_1to4
  692. ;
  693. ; handle a stretch of a scanline (DstXE > SrcXE)
  694. ;
  695. ; Entry:
  696. ; ds:esi --> begining of scan
  697. ; es:edi --> destination scan
  698. ; ss:bp --> stack frame of StretchDIB
  699. ; Returns:
  700. ; ds:esi --> at end of scan
  701. ; es:edi --> at end of scan
  702. ;
  703. ;--------------------------------------------------------------------------;
  704. align 4
  705. x_stretch_8_1to4 proc near
  706. mov ecx,lSrcXE ; loop cout
  707. mov ebx,ecx
  708. shr ecx,1
  709. jz short x_stretch_8_1to4_next
  710. align 4
  711. x_stretch_8_1to4_loop:
  712. ; lods word ptr ds:[esi] ; get 2 pixels
  713. mov ax,word ptr ds:[esi] ; get 2 pixels
  714. add esi,2
  715. mov edx,eax
  716. mov ah,al
  717. shl eax,16
  718. mov al,dl
  719. mov ah,dl
  720. ; stos dword ptr es:[edi] ; store 4
  721. mov dword ptr es:[edi],eax
  722. add edi,4
  723. mov ax,dx
  724. mov al,ah
  725. shl eax,16
  726. mov ax,dx
  727. mov al,ah
  728. ; stos dword ptr es:[edi] ; store 4
  729. mov dword ptr es:[edi],eax ; store 4
  730. add edi,4
  731. dec ecx
  732. jnz short x_stretch_8_1to4_loop
  733. x_stretch_8_1to4_next:
  734. test ebx,1
  735. jnz short x_stretch_8_1to4_done
  736. ret
  737. x_stretch_8_1to4_done:
  738. mov al,byte ptr ds:[esi]
  739. mov ah,al
  740. mov dx,ax
  741. shl eax,16
  742. mov ax,dx
  743. mov dword ptr es:[edi],eax
  744. inc esi
  745. add edi,4
  746. ret
  747. x_stretch_8_1to4 endp
  748. ;--------------------------------------------------------------------------;
  749. ;
  750. ; x_stretch_8_Nto1
  751. ;
  752. ; handle a shrink of a scanline (DstXE < SrcXE)
  753. ;
  754. ; Entry:
  755. ; ds:esi --> begining of scan
  756. ; es:edi --> destination scan
  757. ; ecx - destination pixels to write
  758. ; edx - source pixels to copy
  759. ; ss:bp --> stack frame of StretchDIB
  760. ; Returns:
  761. ; ds:esi --> at end of scan
  762. ; es:edi --> at end of scan
  763. ;
  764. ;--------------------------------------------------------------------------;
  765. align 4
  766. x_stretch_8_Nto1 proc near
  767. mov ebx,x_stretch_dda_fract
  768. xor edx,edx
  769. mov ecx,lDstXE ; # bytes to store
  770. shr ecx,2
  771. jz short x_stretch_8_Nto1_cleanup
  772. push ebp
  773. mov ebp,x_stretch_dda
  774. align 4
  775. x_stretch_8_Nto1_loop:
  776. rept 4
  777. mov al,byte ptr ds:[esi]
  778. ror eax,8
  779. add edx,ebx
  780. adc esi,ebp
  781. endm
  782. mov dword ptr es:[edi],eax
  783. add edi,4
  784. dec ecx
  785. jnz short x_stretch_8_Nto1_loop
  786. pop ebp
  787. x_stretch_8_Nto1_cleanup:
  788. mov ecx,lDstXE
  789. and ecx,011b
  790. jnz short x_stretch_8_Nto1_loop2
  791. ret
  792. x_stretch_8_Nto1_loop2:
  793. mov al,byte ptr ds:[esi]
  794. mov byte ptr es:[edi],al
  795. inc edi
  796. add edx,ebx
  797. adc esi,x_stretch_dda
  798. dec ecx
  799. jnz short x_stretch_8_Nto1_loop2
  800. ret
  801. x_stretch_8_Nto1 endp
  802. ;--------------------------------------------------------------------------;
  803. ;
  804. ; stretch_8_1to2
  805. ;
  806. ; handle a x2 stretch of a entire image
  807. ;
  808. ; Entry:
  809. ; ds:esi --> begining of scan
  810. ; es:edi --> destination scan
  811. ; ss:bp --> stack frame of StretchDIB
  812. ; Returns:
  813. ; ds:esi --> at end of scan
  814. ; es:edi --> at end of scan
  815. ;
  816. ;--------------------------------------------------------------------------;
  817. align 4
  818. stretch_8_1to2 proc near
  819. mov eax, DstWidth
  820. add DstInc, eax
  821. mov ecx, lSrcXE
  822. mov ebx, DstWidth
  823. align 4
  824. stretch_8_1to2_outer_loop:
  825. mov ecx,lSrcXE ; loop cout (/4)
  826. shr ecx,2
  827. jz short stretch_8_1to2_next
  828. align 4
  829. stretch_8_1to2_loop:
  830. mov edx, dword ptr ds:[esi] ; get 4 pixels
  831. mov al,dh
  832. mov ah,dh
  833. shl eax,16
  834. mov al,dl
  835. mov ah,dl
  836. mov dword ptr es:[edi], eax ; store 4
  837. mov dword ptr es:[edi+ebx], eax ; store 4
  838. shr edx,16
  839. mov al,dh
  840. mov ah,dh
  841. shl eax,16
  842. mov al,dl
  843. mov ah,dl
  844. mov dword ptr es:[edi+4], eax ; store 4
  845. mov dword ptr es:[edi+4+ebx], eax ; store 4
  846. add edi,8
  847. add esi,4
  848. dec ecx
  849. jnz short stretch_8_1to2_loop
  850. stretch_8_1to2_next:
  851. mov ecx,lSrcXE
  852. and ecx,3
  853. jnz short stretch_8_1to2_odd
  854. stretch_8_1to2_even:
  855. add edi, DstInc
  856. add esi, SrcInc
  857. dec lSrcYE
  858. jnz short stretch_8_1to2_outer_loop
  859. ret
  860. stretch_8_1to2_odd:
  861. mov al,byte ptr ds:[esi]
  862. mov ah,al
  863. mov word ptr es:[edi],ax
  864. mov word ptr es:[edi+ebx],ax
  865. inc esi
  866. add edi,2
  867. dec ecx
  868. jnz short stretch_8_1to2_odd
  869. jz short stretch_8_1to2_even
  870. stretch_8_1to2 endp
  871. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  872. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;16 BIT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  873. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  874. ;--------------------------------------------------------------------------;
  875. ;
  876. ; x_stretch_16_1toN
  877. ;
  878. ; handle a stretch of a scanline (DstXE > SrcXE)
  879. ;
  880. ; Entry:
  881. ; ds:esi --> begining of scan
  882. ; es:edi --> destination scan
  883. ; ss:bp --> stack frame of StretchDIB
  884. ; Returns:
  885. ; ds:esi --> at end of scan
  886. ; es:edi --> at end of scan
  887. ;
  888. ;--------------------------------------------------------------------------;
  889. align 4
  890. x_stretch_16_1toN proc near
  891. xor edx,edx
  892. mov ecx,lDstXE
  893. shr ecx,1
  894. jz short x_stretch_16_1toN_cleanup
  895. align 4
  896. x_stretch_16_1toN_loop:
  897. rept 2
  898. mov ax,word ptr ds:[esi]
  899. ror eax,16
  900. add edx, x_stretch_dda_fract
  901. sbb ebx, ebx ; ebx = CF ? -1 : 0
  902. and ebx, 2
  903. add esi, ebx
  904. endm
  905. mov dword ptr es:[edi],eax
  906. add edi,4
  907. dec ecx
  908. jnz short x_stretch_16_1toN_loop
  909. x_stretch_16_1toN_cleanup:
  910. test byte ptr DstXE, 1
  911. jnz short x_stretch_16_1toN_odd
  912. ret
  913. x_stretch_16_1toN_odd:
  914. mov ax,word ptr ds:[esi]
  915. mov word ptr es:[edi],ax
  916. add esi,2
  917. add edi,2
  918. ret
  919. x_stretch_16_1toN endp
  920. ;--------------------------------------------------------------------------;
  921. ;
  922. ; x_stretch_16_1to2
  923. ;
  924. ; handle a stretch of a scanline (DstXE > SrcXE)
  925. ;
  926. ; Entry:
  927. ; ds:esi --> begining of scan
  928. ; es:edi --> destination scan
  929. ; ss:bp --> stack frame of StretchDIB
  930. ; Returns:
  931. ; ds:esi --> at end of scan
  932. ; es:edi --> at end of scan
  933. ;
  934. ;--------------------------------------------------------------------------;
  935. align 4
  936. x_stretch_16_1to2 proc near
  937. mov ecx,lSrcXE ; loop cout
  938. mov ebx,ecx
  939. shr ecx,1
  940. jz short x_stretch_16_1to2_done
  941. align 4
  942. x_stretch_16_1to2_loop:
  943. mov eax, dword ptr ds:[esi] ; get 2 pixels
  944. add esi,4
  945. mov edx,eax
  946. shl eax,16
  947. mov ax,dx
  948. mov dword ptr es:[edi], eax ; store 2
  949. add edi,4
  950. mov eax,edx
  951. shr edx,16
  952. mov ax,dx
  953. mov dword ptr es:[edi], eax ; store 2
  954. add edi,4
  955. dec ecx
  956. jnz short x_stretch_16_1to2_loop
  957. x_stretch_16_1to2_done:
  958. test ebx,1
  959. jnz short x_stretch_16_1to2_odd
  960. ret
  961. x_stretch_16_1to2_odd:
  962. mov bx,word ptr ds:[esi]
  963. mov eax,ebx
  964. shl eax,16
  965. mov ax,bx
  966. mov dword ptr es:[edi],eax
  967. add esi,2
  968. add edi,4
  969. ret
  970. x_stretch_16_1to2 endp
  971. ;--------------------------------------------------------------------------;
  972. ;
  973. ; x_stretch_16_Nto1
  974. ;
  975. ; handle a shrink of a scanline (DstXE < SrcXE)
  976. ;
  977. ; Entry:
  978. ; ds:esi --> begining of scan
  979. ; es:edi --> destination scan
  980. ; ecx - destination pixels to write
  981. ; edx - source pixels to copy
  982. ; ss:bp --> stack frame of StretchDIB
  983. ; Returns:
  984. ; ds:esi --> at end of scan
  985. ; es:edi --> at end of scan
  986. ;
  987. ;--------------------------------------------------------------------------;
  988. align 4
  989. x_stretch_16_Nto1 proc near
  990. mov ecx,lDstXE ; # loop count
  991. mov ebx,x_stretch_dda_fract
  992. xor edx,edx
  993. push ebp
  994. mov ebp,x_stretch_dda
  995. dec ebp
  996. add ebp,ebp
  997. align 4
  998. x_stretch_16_Nto1_loop:
  999. movs word ptr es:[edi], word ptr ds:[esi]
  1000. add esi,ebp
  1001. add edx,ebx
  1002. sbb eax,eax
  1003. and eax,2
  1004. add esi,eax
  1005. dec ecx
  1006. jnz short x_stretch_16_Nto1_loop
  1007. pop ebp
  1008. x_stretch_16_Nto1_exit:
  1009. ret
  1010. x_stretch_16_Nto1 endp
  1011. ;--------------------------------------------------------------------------;
  1012. ;
  1013. ; stretch_16_1to2
  1014. ;
  1015. ; handle a x2 stretch of a entire image
  1016. ;
  1017. ; Entry:
  1018. ; ds:esi --> begining of scan
  1019. ; es:edi --> destination scan
  1020. ; ss:bp --> stack frame of StretchDIB
  1021. ; Returns:
  1022. ; ds:esi --> at end of scan
  1023. ; es:edi --> at end of scan
  1024. ;
  1025. ;--------------------------------------------------------------------------;
  1026. align 4
  1027. stretch_16_1to2 proc near
  1028. mov ebx, DstWidth
  1029. add DstInc, ebx
  1030. align 4
  1031. stretch_16_1to2_outer_loop:
  1032. mov ecx,lSrcXE ; loop cout (/2)
  1033. shr ecx,1
  1034. jz short stretch_16_1to2_next
  1035. align 4
  1036. stretch_16_1to2_loop:
  1037. mov edx, dword ptr ds:[esi] ; get 2 pixels
  1038. mov ax,dx
  1039. shl eax,16
  1040. mov ax,dx
  1041. mov dword ptr es:[edi], eax ; store 2
  1042. mov dword ptr es:[edi+ebx], eax ; store 2
  1043. shr edx,16
  1044. mov ax,dx
  1045. shl eax,16
  1046. mov ax,dx
  1047. mov dword ptr es:[edi+4], eax ; store 2
  1048. mov dword ptr es:[edi+4+ebx], eax ; store 2
  1049. add edi,8
  1050. add esi,4
  1051. dec ecx
  1052. jnz short stretch_16_1to2_loop
  1053. stretch_16_1to2_next:
  1054. test lSrcXE,1
  1055. jnz short stretch_16_1to2_odd
  1056. stretch_16_1to2_even:
  1057. add edi, DstInc
  1058. add esi, SrcInc
  1059. dec SrcYE
  1060. jnz short stretch_16_1to2_outer_loop
  1061. ret
  1062. stretch_16_1to2_odd:
  1063. mov dx,word ptr ds:[esi]
  1064. mov ax,dx
  1065. shl eax,16
  1066. mov ax,dx
  1067. mov dword ptr es:[edi],eax
  1068. mov dword ptr es:[edi+ebx],eax
  1069. add esi,2
  1070. add edi,4
  1071. jmp short stretch_16_1to2_even
  1072. stretch_16_1to2 endp
  1073. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1074. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;24 BIT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1075. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1076. ;--------------------------------------------------------------------------;
  1077. ;
  1078. ; x_stretch_24_1toN
  1079. ;
  1080. ; handle a stretch of a scanline (DstXE > SrcXE)
  1081. ;
  1082. ; Entry:
  1083. ; ds:esi --> begining of scan
  1084. ; es:edi --> destination scan
  1085. ; ss:bp --> stack frame of StretchDIB
  1086. ; Returns:
  1087. ; ds:esi --> at end of scan
  1088. ; es:edi --> at end of scan
  1089. ;
  1090. ;--------------------------------------------------------------------------;
  1091. align 4
  1092. x_stretch_24_1toN proc near
  1093. mov ecx,lDstXE ; # loop count
  1094. mov ebx,x_stretch_dda_fract
  1095. xor edx,edx
  1096. align 4
  1097. x_stretch_24_1toN_loop:
  1098. movs word ptr es:[edi], word ptr ds:[esi]
  1099. movs byte ptr es:[edi], byte ptr ds:[esi]
  1100. add edx,ebx
  1101. sbb eax,eax
  1102. not eax
  1103. and eax,-3
  1104. add esi,eax
  1105. dec ecx
  1106. jnz short x_stretch_24_1toN_loop
  1107. x_stretch_24_1toN_exit:
  1108. ret
  1109. x_stretch_24_1toN endp
  1110. ;--------------------------------------------------------------------------;
  1111. ;
  1112. ; x_stretch_24_Nto1
  1113. ;
  1114. ; handle a shrink of a scanline (DstXE < SrcXE)
  1115. ;
  1116. ; Entry:
  1117. ; ds:esi --> begining of scan
  1118. ; es:edi --> destination scan
  1119. ; ecx - destination pixels to write
  1120. ; edx - source pixels to copy
  1121. ; ss:bp --> stack frame of StretchDIB
  1122. ; Returns:
  1123. ; ds:esi --> at end of scan
  1124. ; es:edi --> at end of scan
  1125. ;
  1126. ;--------------------------------------------------------------------------;
  1127. align 4
  1128. x_stretch_24_Nto1 proc near
  1129. mov ecx,lDstXE ; # loop count
  1130. mov ebx,x_stretch_dda_fract
  1131. xor edx,edx
  1132. push ebp
  1133. mov ebp,x_stretch_dda
  1134. dec ebp
  1135. mov eax,ebp
  1136. add ebp,ebp
  1137. add ebp,eax
  1138. align 4
  1139. x_stretch_24_Nto1_loop:
  1140. movs word ptr es:[edi], word ptr ds:[esi]
  1141. movs byte ptr es:[edi], byte ptr ds:[esi]
  1142. add esi,ebp
  1143. add edx,ebx
  1144. sbb eax,eax
  1145. and eax,3
  1146. add esi,eax
  1147. dec ecx
  1148. jnz short x_stretch_24_Nto1_loop
  1149. pop ebp
  1150. x_stretch_24_Nto1_exit:
  1151. ret
  1152. x_stretch_24_Nto1 endp
  1153. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1154. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;32 BIT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1155. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1156. ;--------------------------------------------------------------------------;
  1157. ;
  1158. ; x_stretch_32_1toN
  1159. ;
  1160. ; handle a stretch of a scanline (DstXE > SrcXE)
  1161. ;
  1162. ; Entry:
  1163. ; ds:esi --> begining of scan
  1164. ; es:edi --> destination scan
  1165. ; ss:bp --> stack frame of StretchDIB
  1166. ; Returns:
  1167. ; ds:esi --> at end of scan
  1168. ; es:edi --> at end of scan
  1169. ;
  1170. ;--------------------------------------------------------------------------;
  1171. align 4
  1172. x_stretch_32_1toN proc near
  1173. xor edx,edx
  1174. mov ecx,lDstXE
  1175. align 4
  1176. x_stretch_32_1toN_loop:
  1177. mov eax,word ptr ds:[esi]
  1178. add edx, x_stretch_dda_fract
  1179. sbb ebx, ebx ; ebx = CF ? -1 : 0
  1180. and ebx, 4
  1181. add esi, ebx
  1182. mov dword ptr es:[edi],eax
  1183. add edi,4
  1184. dec ecx
  1185. jnz short x_stretch_32_1toN_loop
  1186. ret
  1187. x_stretch_32_1toN endp
  1188. ;--------------------------------------------------------------------------;
  1189. ;
  1190. ; x_stretch_32_1to2
  1191. ;
  1192. ; handle a stretch of a scanline (DstXE > SrcXE)
  1193. ;
  1194. ; Entry:
  1195. ; ds:esi --> begining of scan
  1196. ; es:edi --> destination scan
  1197. ; ss:bp --> stack frame of StretchDIB
  1198. ; Returns:
  1199. ; ds:esi --> at end of scan
  1200. ; es:edi --> at end of scan
  1201. ;
  1202. ;--------------------------------------------------------------------------;
  1203. align 4
  1204. x_stretch_32_1to2 proc near
  1205. mov ecx,lSrcXE ; loop cout
  1206. align 4
  1207. x_stretch_32_1to2_loop:
  1208. mov eax, dword ptr ds:[esi] ; get a pel
  1209. mov dword ptr es:[edi], eax ; store it
  1210. add esi,4
  1211. mov dword ptr es:[edi+4], eax ; store it again
  1212. add edi,8
  1213. dec ecx
  1214. jnz short x_stretch_32_1to2_loop
  1215. x_stretch_32_1to2_done:
  1216. ret
  1217. x_stretch_32_1to2 endp
  1218. ;--------------------------------------------------------------------------;
  1219. ;
  1220. ; x_stretch_32_Nto1
  1221. ;
  1222. ; handle a shrink of a scanline (DstXE < SrcXE)
  1223. ;
  1224. ; Entry:
  1225. ; ds:esi --> begining of scan
  1226. ; es:edi --> destination scan
  1227. ; ecx - destination pixels to write
  1228. ; edx - source pixels to copy
  1229. ; ss:bp --> stack frame of StretchDIB
  1230. ; Returns:
  1231. ; ds:esi --> at end of scan
  1232. ; es:edi --> at end of scan
  1233. ;
  1234. ;--------------------------------------------------------------------------;
  1235. align 4
  1236. x_stretch_32_Nto1 proc near
  1237. mov ecx,lDstXE ; # loop count
  1238. mov ebx,x_stretch_dda_fract
  1239. xor edx,edx
  1240. push ebp
  1241. mov ebp,x_stretch_dda
  1242. dec ebp
  1243. add ebp,ebp
  1244. add ebp,ebp
  1245. align 4
  1246. x_stretch_32_Nto1_loop:
  1247. movs dword ptr es:[edi], dword ptr ds:[esi]
  1248. add esi,ebp
  1249. add edx,ebx
  1250. sbb eax,eax
  1251. and eax,4
  1252. add esi,eax
  1253. dec ecx
  1254. jnz short x_stretch_32_Nto1_loop
  1255. pop ebp
  1256. x_stretch_32_Nto1_exit:
  1257. ret
  1258. x_stretch_32_Nto1 endp
  1259. sEnd CodeSeg
  1260. end