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.

338 lines
8.0 KiB

  1. ;* *************************************************************************
  2. ;* INTEL Corporation Proprietary Information
  3. ;*
  4. ;* This listing is supplied under the terms of a license
  5. ;* agreement with INTEL Corporation and may not be copied
  6. ;* nor disclosed except in accordance with the terms of
  7. ;* that agreement.
  8. ;*
  9. ;* Copyright (c) 1995 Intel Corporation.
  10. ;* All Rights Reserved.
  11. ;*
  12. ;* *************************************************************************
  13. ;//
  14. ;//
  15. ;// $Header: S:\h26x\src\dec\dx5frmcp.asv
  16. ;//
  17. ;// $Log: S:\h26x\src\dec\dx5frmcp.asv $
  18. ;//
  19. ;// Rev 1.1 20 Dec 1995 15:55:42 RMCKENZX
  20. ;// Added FrameMirror function to file to support mirror imaging
  21. ;//
  22. ;// Rev 1.0 25 Oct 1995 18:11:36 BNICKERS
  23. ;// Initial revision.
  24. ;//
  25. ;////////////////////////////////////////////////////////////////////////////
  26. ;
  27. ; File:
  28. ; dx5frmcp
  29. ;
  30. ; Functions:
  31. ; FrameCopy
  32. ; This function copies a frame from one frame buffer to another.
  33. ; It is tuned for best performance on the Pentium(r) Microprocessor.
  34. ;
  35. ; It is assumed that the frames have the same height, width, and
  36. ; pitch, and that, if width is NOT a multiple of 8, it is okay
  37. ; to copy up to the next multiple of 8.
  38. ;
  39. ; FrameMirror
  40. ; This function mirror images a frame from one frame buffer to
  41. ; another. It is tuned for best performance on the Pentium.
  42. ;
  43. ; It is assumed that the frames have the same height, width, and
  44. ; pitch. The width may be any (non-negative) value.
  45. OPTION PROLOGUE:None
  46. OPTION EPILOGUE:ReturnAndRelieveEpilogueMacro
  47. include locals.inc
  48. IFNDEF DSEGNAME
  49. IFNDEF WIN32
  50. DSEGNAME TEXTEQU <Data_FrameCopy>
  51. ENDIF
  52. ENDIF
  53. IFDEF WIN32
  54. .xlist
  55. include memmodel.inc
  56. .list
  57. .DATA
  58. ELSE
  59. DSEGNAME SEGMENT WORD PUBLIC 'DATA'
  60. ENDIF
  61. ; any data would go here
  62. IFNDEF WIN32
  63. DSEGNAME ENDS
  64. .xlist
  65. include memmodel.inc
  66. .list
  67. ENDIF
  68. IFNDEF SEGNAME
  69. IFNDEF WIN32
  70. SEGNAME TEXTEQU <_CODE32>
  71. ENDIF
  72. ENDIF
  73. ifdef WIN32
  74. .CODE
  75. else
  76. SEGNAME SEGMENT PARA PUBLIC USE32 'CODE'
  77. endif
  78. ifdef WIN32
  79. ASSUME cs : FLAT
  80. ASSUME ds : FLAT
  81. ASSUME es : FLAT
  82. ASSUME fs : FLAT
  83. ASSUME gs : FLAT
  84. ASSUME ss : FLAT
  85. else
  86. ASSUME CS : SEGNAME
  87. ASSUME DS : Nothing
  88. ASSUME ES : Nothing
  89. ASSUME FS : Nothing
  90. ASSUME GS : Nothing
  91. endif
  92. ; void FAR ASM_CALLTYPE FrameCopy (U8 FAR * InputBase,
  93. ; X32 InputPlane,
  94. ; U8 FAR * OutputBase,
  95. ; X32 OutputPlane,
  96. ; UN FrameHeight,
  97. ; UN FrameWidth,
  98. ; UN Pitch)
  99. PUBLIC FrameCopy
  100. ; due to the need for the ebp reg, these parameter declarations aren't used,
  101. ; they are here so the assembler knows how many bytes to relieve from the stack
  102. FrameCopy proc DIST LANG AInputPlane: DWORD,
  103. AOutputPlane: DWORD,
  104. AFrameHeight: DWORD,
  105. AFrameWidth: DWORD,
  106. APitch: DWORD
  107. IFDEF WIN32
  108. RegisterStorageSize = 16
  109. ; Arguments:
  110. InputPlane = RegisterStorageSize + 4
  111. OutputPlane = RegisterStorageSize + 8
  112. FrameHeight = RegisterStorageSize + 12
  113. FrameWidth = RegisterStorageSize + 16
  114. Pitch = RegisterStorageSize + 20
  115. EndOfArgList = RegisterStorageSize + 24
  116. ELSE
  117. ; Arguments:
  118. RegisterStorageSize = 24 ; Put local variables on stack.
  119. InputPlane = RegisterStorageSize + 4
  120. InputPlane_SegNum = RegisterStorageSize + 6
  121. OutputPlane = RegisterStorageSize + 8
  122. OutputPlane_SegNum = RegisterStorageSize + 10
  123. OutputPlane = RegisterStorageSize + 12
  124. FrameHeight = RegisterStorageSize + 16
  125. FrameWidth = RegisterStorageSize + 18
  126. Pitch = RegisterStorageSize + 20
  127. EndOfArgList = RegisterStorageSize + 22
  128. ENDIF
  129. push esi
  130. push edi
  131. push ebp
  132. push ebx
  133. IFDEF WIN32
  134. mov esi,PD [esp+InputPlane]
  135. mov edi,PD [esp+OutputPlane]
  136. mov ebp,PD [esp+Pitch]
  137. mov edx,PD [esp+FrameWidth]
  138. mov ecx,PD [esp+FrameHeight]
  139. ELSE
  140. mov ax,ds
  141. mov bx,es
  142. push eax
  143. push ebx
  144. mov ax,PW [esp+InputBase_SegNum]
  145. movzx esi,PW [esp+InputPlane]
  146. mov bx,PW [esp+OutputBase_SegNum]
  147. movzx edi,PW [esp+OutputPlane]
  148. mov ds,ebx
  149. mov es,eax
  150. movzx ebp,PW [esp+Pitch]
  151. movzx edx,PW [esp+FrameWidth]
  152. movzx ecx,PW [esp+FrameHeight]
  153. ENDIF
  154. add edx,7
  155. and edx,0FFFFFFF8H
  156. sub ebp,edx
  157. sub edi,esi
  158. push edx
  159. CopyLineLoop:
  160. mov eax,Ze PD [esi]
  161. mov ebx,PD [esi+edi] ; Load output cache line
  162. mov ebx,Ze PD [esi+4]
  163. mov PD [esi+edi],eax
  164. mov PD [esi+edi+4],ebx
  165. add esi,8
  166. sub edx,8
  167. jg CopyLineLoop
  168. add esi,ebp
  169. dec ecx ; Reduce count of lines.
  170. mov edx,PD [esp] ; Reload frame width.
  171. jg CopyLineLoop
  172. pop edx
  173. IFDEF WIN32
  174. ELSE
  175. pop ebx
  176. mov es,ebx
  177. pop ebx
  178. mov ds,ebx
  179. ENDIF
  180. pop ebx
  181. pop ebp
  182. pop edi
  183. pop esi
  184. rturn
  185. FrameCopy endp
  186. PUBLIC FrameMirror
  187. ; due to the need for the ebp reg, these parameter declarations aren't used,
  188. ; they are here so the assembler knows how many bytes to relieve from the stack
  189. FrameMirror proc DIST LANG BInputPlane: DWORD,
  190. BOutputPlane: DWORD,
  191. BFrameHeight: DWORD,
  192. BFrameWidth: DWORD,
  193. BPitch: DWORD
  194. ; save registers
  195. push esi
  196. push edi
  197. push ebp
  198. push ebx
  199. ; setup and get parameters
  200. IFDEF WIN32
  201. mov esi, PD [esp+InputPlane]
  202. mov edi, PD [esp+OutputPlane]
  203. mov ebp, PD [esp+Pitch]
  204. mov edx, PD [esp+FrameWidth]
  205. mov ecx, PD [esp+FrameHeight]
  206. ELSE
  207. mov ax, ds
  208. mov bx, es
  209. push eax
  210. push ebx
  211. mov ax, PW [esp+InputBase_SegNum]
  212. movzx esi, PW [esp+InputPlane]
  213. mov bx, PW [esp+OutputBase_SegNum]
  214. movzx edi, PW [esp+OutputPlane]
  215. mov ds, ebx
  216. mov es, eax
  217. movzx ebp, PW [esp+Pitch]
  218. movzx edx, PW [esp+FrameWidth]
  219. movzx ecx, PW [esp+FrameHeight]
  220. ENDIF
  221. ; start processing
  222. ; prepare for the loop
  223. push edx ; save width
  224. per_line_loop:
  225. test edx, 7 ; check for short count
  226. je skip_short_count ; skip when no short count
  227. short_count_loop:
  228. mov al, [esi+edx-1]
  229. dec edx
  230. mov [edi], al
  231. inc edi
  232. test edx, 7
  233. jne short_count_loop
  234. skip_short_count:
  235. test edx, edx
  236. je skip_inner_loop
  237. ; inner loop is unrolled to do 8 bytes per iteration
  238. inner_loop:
  239. mov al, [edi] ; heat cache
  240. add edi, 8
  241. mov al, [esi+edx-1]
  242. mov bl, [esi+edx-5]
  243. mov [edi-8], al
  244. mov [edi-4], bl
  245. mov al, [esi+edx-2]
  246. mov bl, [esi+edx-6]
  247. mov [edi-7], al
  248. mov [edi-3], bl
  249. mov al, [esi+edx-3]
  250. mov bl, [esi+edx-7]
  251. mov [edi-6], al
  252. mov [edi-2], bl
  253. mov al, [esi+edx-4]
  254. mov bl, [esi+edx-8]
  255. mov [edi-5], al
  256. mov [edi-1], bl
  257. sub edx, 8
  258. jne inner_loop
  259. ; now move down to the next line
  260. skip_inner_loop:
  261. mov edx, [esp] ; restore width
  262. add edi, ebp ; increment destination
  263. add esi, ebp ; increment source
  264. sub edi, edx ; correct destination by width
  265. dec ecx
  266. jne per_line_loop
  267. ; restore stack pointer
  268. pop eax
  269. IFDEF WIN32
  270. ELSE
  271. pop ebx
  272. pop eax
  273. mov es, bx
  274. mov ds, ax
  275. ENDIF
  276. ; restore registers and return
  277. pop ebx
  278. pop ebp
  279. pop edi
  280. pop esi
  281. rturn
  282. FrameMirror endp
  283. IFNDEF WIN32
  284. SEGNAME ENDS
  285. ENDIF
  286. END