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.

473 lines
11 KiB

  1. page ,132
  2. ;------------------------------Module-Header----------------------------;
  3. ; Module Name: tiler.asm
  4. ;
  5. ; Helper routines for P, Pn and DPx tiling algorithm.
  6. ;
  7. ; Created: 28-Jan-1992 10:20:08
  8. ; Author: Donald Sidoroff [donalds]
  9. ;
  10. ; Copyright (c) 1992-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 stdcall.inc
  18. include gdii386.inc
  19. .list
  20. .code
  21. ;---------------------------Private-Routine-----------------------------;
  22. ; vFetchAndCopy
  23. ;
  24. ; Fetch one row of a pattern and copy it.
  25. ;
  26. ; Entry:
  27. ; IN pff Points to a 'fetch' frame.
  28. ; Returns:
  29. ; Nothing.
  30. ; Registers Destroyed:
  31. ; EAX, ECX, EDX
  32. ; Calls:
  33. ; None
  34. ; History:
  35. ; 28-Jan-1992 -by- Donald Sidoroff [donalds]
  36. ; Wrote it
  37. ;-----------------------------------------------------------------------;
  38. cProc vFetchAndCopy,4,< \
  39. uses ebx esi edi, \
  40. pff: ptr FETCHFRAME >
  41. push ebp
  42. mov ebp,pff
  43. mov edi,[ebp].ff_pvTrg
  44. mov esi,[ebp].ff_pvPat
  45. mov ebx,[ebp].ff_xPat
  46. mov edx,[ebp].ff_culFill
  47. or ebx,ebx ; Are we at start of pattern?
  48. jz vfc_copy_body
  49. vfc_copy_head:
  50. mov eax,[esi+ebx]
  51. stosd
  52. dec edx
  53. jz vfc_done
  54. add ebx,4
  55. cmp ebx,[ebp].ff_cxPat
  56. jne vfc_copy_head
  57. vfc_copy_body:
  58. mov ecx,[ebp].ff_culWidth
  59. sub edx,ecx
  60. jl vfc_copy_tail
  61. rep movsd
  62. mov esi,[ebp].ff_pvPat ; Reset this
  63. jmp vfc_copy_body
  64. vfc_copy_tail:
  65. add edx,ecx
  66. mov ecx,edx ; This many left!
  67. rep movsd
  68. vfc_done:
  69. pop ebp
  70. cRet vFetchAndCopy
  71. endProc vFetchAndCopy
  72. ;---------------------------Private-Routine-----------------------------;
  73. ; vFetchShiftAndCopy
  74. ;
  75. ; Fetch one row of a pattern and copy it.
  76. ;
  77. ; Entry:
  78. ; IN pff Points to a 'fetch' frame.
  79. ; Returns:
  80. ; Nothing.
  81. ; Registers Destroyed:
  82. ; EAX, ECX, EDX
  83. ; Calls:
  84. ; None
  85. ; History:
  86. ; 28-Jan-1992 -by- Donald Sidoroff [donalds]
  87. ; Wrote it
  88. ;-----------------------------------------------------------------------;
  89. cProc vFetchShiftAndCopy,4,< \
  90. uses ebx esi edi, \
  91. pff: ptr FETCHFRAME >
  92. push ebp
  93. mov ebp,pff
  94. mov edi,[ebp].ff_pvTrg
  95. mov esi,[ebp].ff_pvPat
  96. mov ebx,[ebp].ff_xPat
  97. mov eax,[ebp].ff_culFill
  98. mov [ebp].ff_culFillTmp,eax ; Copy can be trashed
  99. vfsc_loop:
  100. mov ecx,ebx
  101. and ebx,NOT 3 ; Align to DWORD
  102. and ecx,3 ; Shift this many bytes
  103. shl ecx,3
  104. mov eax,[esi+ebx] ; Prime the pipeline
  105. vfsc_in_pipeline:
  106. mov edx,[esi+ebx+4]
  107. shrd eax,edx,cl
  108. stosd
  109. dec dword ptr [ebp].ff_culFillTmp ; Are we done?
  110. jz vfsc_done
  111. add dword ptr [ebp].ff_xPat,4 ; Advance position in pattern
  112. mov ebx,[ebp].ff_xPat
  113. cmp ebx,[ebp].ff_cxPat
  114. jge vfsc_blow_out
  115. and ebx,NOT 3 ; Align to DWORD
  116. mov eax,edx ; Pipeline is valid, use it
  117. jmp vfsc_in_pipeline
  118. vfsc_blow_out:
  119. sub ebx,[ebp].ff_cxPat ; Reset position in pattern
  120. mov [ebp].ff_xPat,ebx
  121. jmp vfsc_loop ; Restart pipeline
  122. vfsc_done:
  123. pop ebp
  124. cRet vFetchShiftAndCopy
  125. endProc vFetchShiftAndCopy
  126. ;---------------------------Private-Routine-----------------------------;
  127. ; vFetchNotAndCopy
  128. ;
  129. ; Fetch one row of a pattern, negate it and copy it.
  130. ;
  131. ; Entry:
  132. ; IN pff Points to a 'fetch' frame.
  133. ; Returns:
  134. ; Nothing.
  135. ; Registers Destroyed:
  136. ; EAX, ECX, EDX
  137. ; Calls:
  138. ; None
  139. ; History:
  140. ; 28-Jan-1992 -by- Donald Sidoroff [donalds]
  141. ; Wrote it
  142. ;-----------------------------------------------------------------------;
  143. cProc vFetchNotAndCopy,4,< \
  144. uses ebx esi edi, \
  145. pff: ptr FETCHFRAME >
  146. push ebp
  147. mov ebp,pff
  148. mov edi,[ebp].ff_pvTrg
  149. mov esi,[ebp].ff_pvPat
  150. mov ebx,[ebp].ff_xPat
  151. mov edx,[ebp].ff_culFill
  152. or ebx,ebx ; Are we at start of pattern?
  153. jz vfnc_copy_body
  154. vfnc_copy_head:
  155. mov eax,[esi+ebx]
  156. not eax
  157. stosd
  158. dec edx
  159. jz vfnc_done
  160. add ebx,4
  161. cmp ebx,[ebp].ff_cxPat
  162. jne vfnc_copy_head
  163. vfnc_copy_body:
  164. mov ecx,[ebp].ff_culWidth
  165. sub edx,ecx
  166. jl vfnc_copy_tail
  167. @@:
  168. lodsd
  169. not eax
  170. stosd
  171. loop @B
  172. mov esi,[ebp].ff_pvPat ; Reset this
  173. jmp vfnc_copy_body
  174. vfnc_copy_tail:
  175. add edx,ecx
  176. jz vfnc_done
  177. mov ecx,edx ; This many left!
  178. @@:
  179. lodsd
  180. not eax
  181. stosd
  182. loop @B
  183. vfnc_done:
  184. pop ebp
  185. cRet vFetchNotAndCopy
  186. endProc vFetchNotAndCopy
  187. ;---------------------------Private-Routine-----------------------------;
  188. ; vFetchShiftNotAndCopy
  189. ;
  190. ; Fetch one row of a pattern and copy it.
  191. ;
  192. ; Entry:
  193. ; IN pff Points to a 'fetch' frame.
  194. ; Returns:
  195. ; Nothing.
  196. ; Registers Destroyed:
  197. ; EAX, ECX, EDX
  198. ; Calls:
  199. ; None
  200. ; History:
  201. ; 28-Jan-1992 -by- Donald Sidoroff [donalds]
  202. ; Wrote it
  203. ;-----------------------------------------------------------------------;
  204. cProc vFetchShiftNotAndCopy,4,< \
  205. uses ebx esi edi, \
  206. pff: ptr FETCHFRAME >
  207. push ebp
  208. mov ebp,pff
  209. mov edi,[ebp].ff_pvTrg
  210. mov esi,[ebp].ff_pvPat
  211. mov ebx,[ebp].ff_xPat
  212. mov eax,[ebp].ff_culFill
  213. mov [ebp].ff_culFillTmp,eax ; Copy can be trashed
  214. vfsnc_loop:
  215. mov ecx,ebx
  216. and ebx,NOT 3 ; Align to DWORD
  217. and ecx,3 ; Shift this many bytes
  218. shl ecx,3
  219. mov eax,[esi+ebx] ; Prime the pipeline
  220. vfsnc_in_pipeline:
  221. mov edx,[esi+ebx+4]
  222. shrd eax,edx,cl
  223. not eax
  224. stosd
  225. dec dword ptr [ebp].ff_culFillTmp ; Are we done?
  226. jz vfsnc_done
  227. add dword ptr [ebp].ff_xPat,4 ; Advance position in pattern
  228. mov ebx,[ebp].ff_xPat
  229. cmp ebx,[ebp].ff_cxPat
  230. jge vfsnc_blow_out
  231. and ebx,NOT 3 ; Align to DWORD
  232. mov eax,edx ; Pipeline is valid, use it
  233. jmp vfsnc_in_pipeline
  234. vfsnc_blow_out:
  235. sub ebx,[ebp].ff_cxPat ; Reset position in pattern
  236. mov [ebp].ff_xPat,ebx
  237. jmp vfsnc_loop ; Restart pipeline
  238. vfsnc_done:
  239. pop ebp
  240. cRet vFetchShiftNotAndCopy
  241. endProc vFetchShiftNotAndCopy
  242. ;---------------------------Private-Routine-----------------------------;
  243. ; vFetchAndMerge
  244. ;
  245. ; Fetch one row of a pattern and copy it.
  246. ;
  247. ; Entry:
  248. ; IN pff Points to a 'fetch' frame.
  249. ; Returns:
  250. ; Nothing.
  251. ; Registers Destroyed:
  252. ; EAX, ECX, EDX
  253. ; Calls:
  254. ; None
  255. ; History:
  256. ; 28-Jan-1992 -by- Donald Sidoroff [donalds]
  257. ; Wrote it
  258. ;-----------------------------------------------------------------------;
  259. cProc vFetchAndMerge,4,< \
  260. uses ebx esi edi, \
  261. pff: ptr FETCHFRAME >
  262. push ebp
  263. mov ebp,pff
  264. mov edi,[ebp].ff_pvTrg
  265. mov esi,[ebp].ff_pvPat
  266. mov ebx,[ebp].ff_xPat
  267. mov edx,[ebp].ff_culFill
  268. or ebx,ebx ; Are we at start of pattern?
  269. jz vfm_copy_body
  270. vfm_copy_head:
  271. mov eax,[esi+ebx]
  272. xor [edi],eax
  273. add edi,4
  274. dec edx
  275. jz vfm_done
  276. add ebx,4
  277. cmp ebx,[ebp].ff_cxPat
  278. jne vfm_copy_head
  279. vfm_copy_body:
  280. mov ecx,[ebp].ff_culWidth
  281. sub edx,ecx
  282. jl vfm_copy_tail
  283. @@:
  284. lodsd
  285. xor [edi],eax
  286. add edi,4
  287. loop @B
  288. mov esi,[ebp].ff_pvPat ; Reset this
  289. jmp vfm_copy_body
  290. vfm_copy_tail:
  291. add edx,ecx
  292. jz vfm_done
  293. mov ecx,edx ; This many left!
  294. @@:
  295. lodsd
  296. xor [edi],eax
  297. add edi,4
  298. loop @B
  299. vfm_done:
  300. pop ebp
  301. cRet vFetchAndMerge
  302. endProc vFetchAndMerge
  303. ;---------------------------Private-Routine-----------------------------;
  304. ; vFetchShiftAndMerge
  305. ;
  306. ; Fetch one row of a pattern and XOR it into destination
  307. ;
  308. ; Entry:
  309. ; IN pff Points to a 'fetch' frame.
  310. ; Returns:
  311. ; Nothing.
  312. ; Registers Destroyed:
  313. ; EAX, ECX, EDX
  314. ; Calls:
  315. ; None
  316. ; History:
  317. ; 28-Jan-1992 -by- Donald Sidoroff [donalds]
  318. ; Wrote it
  319. ;-----------------------------------------------------------------------;
  320. cProc vFetchShiftAndMerge,4,< \
  321. uses ebx esi edi, \
  322. pff: ptr FETCHFRAME >
  323. push ebp
  324. mov ebp,pff
  325. mov edi,[ebp].ff_pvTrg
  326. mov esi,[ebp].ff_pvPat
  327. mov ebx,[ebp].ff_xPat
  328. mov eax,[ebp].ff_culFill
  329. mov [ebp].ff_culFillTmp,eax ; Copy can be trashed
  330. vfsm_loop:
  331. mov ecx,ebx
  332. and ebx,NOT 3 ; Align to DWORD
  333. and ecx,3 ; Shift this many bytes
  334. shl ecx,3
  335. mov eax,[esi+ebx] ; Prime the pipeline
  336. vfsm_in_pipeline:
  337. mov edx,[esi+ebx+4]
  338. shrd eax,edx,cl
  339. xor [edi],eax
  340. add edi,4
  341. dec dword ptr [ebp].ff_culFillTmp ; Are we done?
  342. jz vfsm_done
  343. add dword ptr [ebp].ff_xPat,4 ; Advance position in pattern
  344. mov ebx,[ebp].ff_xPat
  345. cmp ebx,[ebp].ff_cxPat
  346. jge vfsm_blow_out
  347. and ebx,NOT 3 ; Align to DWORD
  348. mov eax,edx ; Pipeline is valid, use it
  349. jmp vfsm_in_pipeline
  350. vfsm_blow_out:
  351. sub ebx,[ebp].ff_cxPat ; Reset position in pattern
  352. mov [ebp].ff_xPat,ebx
  353. jmp vfsm_loop ; Restart pipeline
  354. vfsm_done:
  355. pop ebp
  356. cRet vFetchShiftAndMerge
  357. endProc vFetchShiftAndMerge
  358. end
  359.