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.

390 lines
12 KiB

  1. page ,132
  2. ;------------------------------Module-Header----------------------------;
  3. ; Module Name: str.asm
  4. ;
  5. ; Same format, no translation stretch blt inner loop
  6. ;
  7. ; Created: 17-Oct-1994
  8. ; Author: Mark Enstrom
  9. ;
  10. ; Copyright (c) 1994-1999 Microsoft Corporation
  11. ;-----------------------------------------------------------------------;
  12. .386
  13. .model small,c
  14. assume cs:FLAT,ds:FLAT,es:FLAT,ss:FLAT
  15. assume fs:nothing,gs:nothing
  16. .xlist
  17. include callconv.inc
  18. include gdii386.inc
  19. ;
  20. ; stack based params and local variables
  21. ;
  22. sp_TempXFrac equ 000H
  23. sp_YCarry equ 004H
  24. sp_LeftCase equ 008H
  25. sp_RightCase equ 00CH
  26. sp_pjSrcScan equ 010H
  27. sp_SrcIntStep equ 014H
  28. sp_DstStride equ 018H
  29. sp_XCount equ 01CH
  30. sp_ebp equ 020H
  31. sp_esi equ 024H
  32. sp_edi equ 028H
  33. sp_ebx equ 02CH
  34. sp_RetAddr equ 030H
  35. sp_pSTR_BLT equ 034H
  36. .list
  37. ;------------------------------------------------------------------------------;
  38. .code
  39. _TEXT$01 SEGMENT DWORD USE32 PUBLIC 'CODE'
  40. ASSUME DS:FLAT, ES:FLAT, SS:NOTHING, FS:NOTHING, GS:NOTHING
  41. ;------------------------------------------------------------------------------;
  42. ;------------------------------------------------------------------------------;
  43. ; vDirectStretch8
  44. ;
  45. ; Stretcg 8 to 8
  46. ;
  47. ; Entry:
  48. ;
  49. ; pSTR_BLT - pointer to stretch blt parameter block
  50. ;
  51. ; Returns:
  52. ; none
  53. ; Registers Destroyed:
  54. ; all
  55. ; Calls:
  56. ; None
  57. ; History:
  58. ;
  59. ; WARNING This routine uses EBP as a general variable.
  60. ; Also, if parameters are changed, the ret statement must
  61. ; also be fixed
  62. ;
  63. ;------------------------------------------------------------------------------;
  64. public vDirectStretch8@4
  65. vDirectStretch8@4 proc near
  66. ;
  67. ; use ebp as general register, use esp for parameter and local access
  68. ; save ebp,ebx,esi,edi
  69. push ebx
  70. push edi
  71. push esi
  72. push ebp
  73. sub esp,8 * 4
  74. mov ebp,[esp].sp_pSTR_BLT ; load pSTR_BLT into ebp
  75. ;
  76. ; calc starting addressing parameters
  77. ;
  78. mov esi,[ebp].str_pjSrcScan ; load src DIB pointer
  79. add esi,[ebp].str_XSrcStart ; add strarting Src Pixel
  80. mov edi,[ebp].str_pjDstScan ; load dst DIB pointer
  81. add edi,[ebp].str_XDstStart ; add strarting Dst Pixel
  82. mov [esp].sp_pjSrcScan,esi ; save scan line start pointer
  83. mov eax,[ebp].str_ulYDstToSrcIntCeil ; number of src scan lines to step
  84. mul dword ptr [ebp].str_lDeltaSrc ; calc scan line int lines to step
  85. mov [esp].sp_SrcIntStep,eax ; save int portion of Y src step
  86. mov eax,edi ; make copy of pjDst
  87. and eax,3 ; calc left edge case
  88. mov edx,4 ; calc left bytes = (4 - LeftCase) & 0x03
  89. sub edx,eax ; 4 - LeftCase
  90. and edx,3 ; left edge bytes
  91. mov [esp].sp_LeftCase,edx ; save left edge case pixels (4-LeftCase)&0x03
  92. mov eax,[ebp].str_pjDstScan ; make copy
  93. mov ecx,[ebp].str_XDstEnd ; load x end
  94. add eax,ecx ; ending dst addr
  95. and eax,3 ; calc right edge case
  96. mov [esp].sp_RightCase,eax ; save right edge case
  97. sub ecx,[ebp].str_XDstStart ; calc x count
  98. mov ebx,[ebp].str_lDeltaDst ; dst scan line stride
  99. sub ebx,ecx ; distance from end of one line to start of next
  100. mov [esp].sp_DstStride,ebx ; save dst scan line stride
  101. sub ecx,eax ; sub right edge from XCount
  102. sub ecx,edx ; sub left edge from XCount
  103. shr ecx,2 ; convert from byte to DWORD count
  104. mov [esp].sp_XCount,ecx ; save DWORD count
  105. mov ebx,[ebp].str_ulXDstToSrcFracCeil ; get x frac
  106. mov [esp].sp_TempXFrac,ebx ; save x frac to a esp based location
  107. LoopTop::
  108. ;
  109. ; can 2 scan dst lines be drawn from 1 src?
  110. ;
  111. xor ebx,ebx ; zero ebx
  112. mov eax,[ebp].str_ulYFracAccumulator ; get .32 part of Y pointer
  113. add eax,[ebp].str_ulYDstToSrcFracCeil ; add in fractional step
  114. adc ebx,0
  115. mov [esp].sp_YCarry,ebx ; save carry for end of loop
  116. mov [ebp].str_ulYFracAccumulator,eax ; save Y accumulator
  117. cmp [esp].sp_SrcIntStep,0 ; int step must be zero
  118. jne SingleLoop
  119. cmp ebx,0 ; carry must be zero
  120. jne SingleLoop
  121. cmp [ebp].str_YDstCount,2 ; y count must be at least 2
  122. jl SingleLoop
  123. ;
  124. ; there was no carry, draw 2 dst scan lines. Add 1 extra y Frac, and subtract
  125. ; one extra Y Count
  126. ;
  127. add eax,[ebp].str_ulYDstToSrcFracCeil ; add in fractional step
  128. adc ebx,0 ; get new carry
  129. mov [esp].sp_YCarry,ebx ; save carry for end of loop
  130. mov [ebp].str_ulYFracAccumulator,eax ; save Y accumulator
  131. dec dword ptr [ebp].str_YDstCount ; dec y count
  132. ;
  133. ; Draw 2 Dst scan lines from 1 src scan
  134. ;
  135. mov eax,[ebp].str_ulXDstToSrcIntCeil ; get src integer step for step in dst
  136. mov edx,[ebp].str_ulXFracAccumulator ; put it in edx as tmp
  137. mov ebx,[ebp].str_lDeltaDst ; Get Dst Scan line delta
  138. mov ebp,edi ; get dst pointer to ebp (ebp uses ss:)
  139. ;
  140. ; Can't directly access pSTR_BLT variables through ebp
  141. ;
  142. mov edi,edx ; get accumulator where we want it
  143. mov ecx,[esp].sp_LeftCase
  144. ; esi = pointer to source pixel
  145. ; ebp = pointer to dest pixel
  146. ; ecx = Left edge case
  147. ; eax = integer step in source
  148. ; ebx = Dst scan line delta
  149. ; edi = fractional accumulator
  150. ; edx = free for pixel data
  151. ;
  152. ; first do the left side to align dwords
  153. ;
  154. cmp ecx,0
  155. je DualDwordAligned
  156. DualLeftEdge:
  157. mov dl,[esi] ; fetch pixel
  158. mov [ebp],dl ; write it out
  159. mov [ebp+ebx],dl ; write it out to next scan line
  160. add edi,[esp].sp_tempXFrac ; step fraction
  161. adc esi,eax ; add in integer and possible carry
  162. inc ebp ; step 1 in dest
  163. dec ecx ; dec and repeat for left edge
  164. jne DualLeftEdge
  165. DualDwordAligned:
  166. mov ecx,[esp].sp_XCount ; get run length
  167. @@:
  168. mov dl,[esi] ; get a source pixel edx = ???0
  169. add edi,[esp].sp_tempXFrac ; step fraction
  170. adc esi,eax ; add integer and carry
  171. add edi,[esp].sp_tempXFrac ; step fraction
  172. mov dh,[esi] ; get source pixel edx = ??10
  173. adc esi,eax ; add integer and carry
  174. shl edx,16 ; edx = 10??
  175. add edi,[esp].sp_tempXFrac ; step fraction
  176. mov dl,[esi] ; get a source pixel edx = 10?2
  177. adc esi,eax ; add integer and carry
  178. add edi,[esp].sp_tempXFrac ; step fraction
  179. mov dh,[esi] ; get source pixel edx = 0132
  180. adc esi,eax ; add integer and carry
  181. ror edx,16 ; edx = 3210
  182. mov [ebp],edx ; write everything to dest
  183. mov [ebp+ebx],edx ; write everything to dest plus 1 scan line
  184. add ebp,4 ; increment dest pointer by 2 dwords
  185. dec ecx ; decrement count
  186. jnz @b ; do more pixels
  187. DualRightEdge:
  188. ;
  189. ; now do the right side trailing bytes
  190. ;
  191. mov ecx,[esp].sp_RightCase
  192. cmp ecx,0
  193. je DualAddScanLine
  194. @@:
  195. mov dl,[esi] ; fetch pixel
  196. mov [ebp],dl ; write it out
  197. mov [ebp+ebx],dl ; write it out to next scan line
  198. add edi,[esp].sp_tempXFrac ; step fraction
  199. adc esi,eax ; add in integer and possible carry
  200. inc ebp ; step 1 in dest
  201. dec ecx
  202. jne @B
  203. ;
  204. ; add one extra lDeltaDst (ebx) tp ebp for the
  205. ; extra dst scan line
  206. ;
  207. DualAddScanLine:
  208. add ebp,ebx
  209. jmp EndScanLine ; skip to end
  210. ;
  211. ; Expand and draw 1 scan line
  212. ;
  213. SingleLoop:
  214. mov eax,[ebp].str_ulXDstToSrcIntCeil ; get src integer step for step in dst
  215. mov ebx,[ebp].str_ulXDstToSrcFracCeil ; get src frac step for step in dst
  216. mov edx,[ebp].str_ulXFracAccumulator ; put it in edx as tmp
  217. mov ebp,edi ; get dst pointer to ebp (ebp uses ss:)
  218. ;
  219. ; Can't directly access pSTR_BLT variables through ebp
  220. ;
  221. mov edi,edx ; get accumulator where we want it
  222. mov ecx,[esp].sp_LeftCase
  223. ; esi = pointer to source pixel
  224. ; ebp = pointer to dest pixel
  225. ; ecx = Left edge case
  226. ; eax = integer step in source
  227. ; ebx = fractional step in source
  228. ; edi = fractional accumulator
  229. ; edx = free for pixel data
  230. ;
  231. ; first do the left side to align dwords
  232. ;
  233. cmp ecx,0
  234. je DwordAligned
  235. @@:
  236. mov dl,[esi] ; fetch pixel
  237. mov [ebp],dl ; write it out
  238. add edi,ebx ; step fraction
  239. adc esi,eax ; add in integer and possible carry
  240. inc ebp ; step 1 in dest
  241. dec ecx ; dec left count
  242. jne @B ; repeat until done
  243. DwordAligned:
  244. mov ecx,[esp].sp_XCount ; get run length
  245. @@:
  246. mov dl,[esi] ; get a source pixel edx = ???0
  247. add edi,ebx ; step fraction
  248. adc esi,eax ; add integer and carry
  249. add edi,ebx ; step fraction
  250. mov dh,[esi] ; get source pixel edx = ??10
  251. adc esi,eax ; add integer and carry
  252. shl edx,16 ; edx = 10??
  253. add edi,ebx ; step fraction
  254. mov dl,[esi] ; get a source pixel edx = 10?2
  255. adc esi,eax ; add integer and carry
  256. add edi,ebx ; step fraction
  257. mov dh,[esi] ; get source pixel edx = 0132
  258. adc esi,eax ; add integer and carry
  259. ror edx,16 ; edx = 3210
  260. mov [ebp],edx ; write everything to dest
  261. add ebp,4 ; increment dest pointer by 1 dword
  262. dec ecx ; decrement count
  263. jnz @b ; do more pixels
  264. ;
  265. ; now do the right side trailing bytes
  266. ;
  267. mov ecx,[esp].sp_RightCase
  268. cmp ecx,0
  269. je EndScanLine
  270. @@:
  271. mov dl,[esi] ; fetch pixel
  272. mov ss:[ebp],dl ; write it out
  273. add edi,ebx ; step fraction
  274. adc esi,eax ; add in integer and possible carry
  275. inc ebp ; step 1 in dest
  276. dec ecx ; dec right count
  277. jnz @b ; repeat until done
  278. EndScanLine:
  279. mov edi,ebp ; get dst pointer back
  280. mov ebp,[esp].sp_pSTR_BLT ; load pSTR_BLT into ebp
  281. mov esi,[esp].sp_pjSrcScan ; load src scan start addr
  282. cmp [esp].sp_YCarry,1 ; is there a carry
  283. jne @f ; no additional int step
  284. add esi,[ebp].str_lDeltaSrc ; step one extra in src
  285. @@:
  286. add esi,[esp].sp_SrcIntStep ; step int part
  287. mov [esp].sp_pjSrcScan,esi ; save starting scan addr
  288. add edi,[esp].sp_DstStride ; step to next scan in dst
  289. dec dword ptr [ebp].str_YDstCount
  290. jnz LoopTop
  291. add esp,8*4
  292. pop ebp
  293. pop esi
  294. pop edi
  295. pop ebx
  296. ret 4
  297. vDirectStretch8@4 endp
  298. _TEXT$01 ends
  299. end