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.

283 lines
7.2 KiB

  1. ;-----------------------------------------------------------------------------
  2. ; Monolith 22. Gouraud 888
  3. ;
  4. ; This monolith selects code to draw either left or right.
  5. ;
  6. ; Globals (ATTENTION. Need to put in stack memory so can multi-process)
  7. ;
  8. ; uSpans - Count containing the number of spans.
  9. ; StackPos - Saves stack position.
  10. ;
  11. ; Register Usage:
  12. ;
  13. ; eax - Number of pixels to draw
  14. ; ecx - Prim pointer. Same as in non-monolithic loop code. (i.e. C codes pCtx->pPrim)
  15. ; edi - Pointer to Screen Buffer.
  16. ; ebp - Rast Span Pointer. Same as in non-monolithic loop code. (i.e. pS in C code)
  17. ; mm0 - contains four color components.
  18. ; mm1 - contains delta color components.
  19. ; mm3 - Temp for color conversion.
  20. ; mm5 - temp for color conversion.
  21. ;
  22. ; Both Left to Right and Right to Left are very similar.
  23. ;
  24. ; Psuedo Code
  25. ;
  26. ; loop:
  27. ; {
  28. ; copy mm0 to mm5
  29. ; convert mm5 to 888.
  30. ; write color
  31. ; }
  32. ; if (done drawing) {exit loop} (dec eax / jz NoMorePixelsLtoR)
  33. ; increment colors (mm0+=mm1)
  34. ; increment screen pointer (add edi, 4)
  35. ; jump to top of loop
  36. ;
  37. ;-----------------------------------------------------------------------------
  38. INCLUDE iammx.inc
  39. INCLUDE offs_acp.inc
  40. ; Names are read LSB to MSB, so B5G6R5 means five bits of blue starting
  41. ; at the LSB, then six bits of green, then five bits of red.
  42. ;TBD check to see if this value is correct.
  43. COLOR_SHIFT equ 8
  44. .586
  45. .model flat
  46. ; Big seperating lines seperate code into span code
  47. ; and loop code. If span and loop are not going to
  48. ; end up being combined then it will be easy to
  49. ; seperate the code.
  50. .data
  51. ; Need externs for all of the variables that are needed for various beads
  52. EXTERN MaskRed565to888:MMWORD
  53. EXTERN MaskGreen565to888:MMWORD
  54. EXTERN MaskBlue565to888:MMWORD
  55. EXTERN MaskRed555to888:MMWORD
  56. EXTERN MaskGreen555to888:MMWORD
  57. EXTERN MaskBlue555to888:MMWORD
  58. EXTERN MaskAlpha1555to8888:MMWORD
  59. EXTERN MaskRed1555to8888:MMWORD
  60. EXTERN MaskGreen1555to8888:MMWORD
  61. EXTERN MaskBlue1555to8888:MMWORD
  62. ; TBD. I think that I want to do 0xffff instead of 0xff. This will
  63. ; have to be checked. There is a value very similiar to this in
  64. ; buf write.
  65. EXTERN SetAlphato0xffff:MMWORD
  66. EXTERN SetAlphato0xff:MMWORD
  67. ; TODO This equate are identical to the ones in texread.mas. Maybe they should be in a common .inc file.
  68. RedShift565to888 equ 8
  69. GreenShift565to888 equ 5
  70. BlueShift565to888 equ 3
  71. RedShift555to888 equ 9
  72. GreenShift555to888 equ 6
  73. BlueShift555to888 equ 3
  74. AlphaShift1555to8888 equ 16
  75. RedShift1555to8888 equ 9
  76. GreenShift1555to8888 equ 6
  77. BlueShift1555to8888 equ 3
  78. EXTERN Zero:MMWORD
  79. EXTERN SetAlphato0xff:MMWORD
  80. EXTERN u888to565RedBlueMask:MMWORD
  81. EXTERN u888to565GreenMask:MMWORD
  82. EXTERN u888to565Multiplier:MMWORD
  83. EXTERN uVal0x000007ff03ff07ff:MMWORD
  84. EXTERN uVal0x0000078003c00780:MMWORD
  85. EXTERN u888to555RedBlueMask:MMWORD
  86. EXTERN u888to555GreenMask:MMWORD
  87. EXTERN u888to555Multiplier:MMWORD
  88. EXTERN uVal0x000007ff07ff07ff:MMWORD
  89. EXTERN uVal0x0000078007800780:MMWORD
  90. ;-----------------------------------------------------------------------------
  91. ; Span Variables
  92. StackPos dd ?
  93. uSpans dd ?
  94. ;-----------------------------------------------------------------------------
  95. ;-----------------------------------------------------------------------------
  96. ; Loop Variables
  97. iSurfaceStep dd ?
  98. uPix dd ?
  99. ;-----------------------------------------------------------------------------
  100. .code
  101. PUBLIC _MMXMLRast_22
  102. _MMXMLRast_22:
  103. push ebp
  104. mov StackPos, esp
  105. mov eax, esp
  106. sub esp, 0Ch ; This will need to change if stack frame size changes.
  107. push ebx
  108. push edi
  109. xor edi, edi
  110. ; Put pCtx into ebx
  111. mov ebx, [eax+8]
  112. ;PD3DI_RASTPRIM pP = pCtx->pPrim;
  113. mov ecx, [ebx+RASTCTX_pPrim]
  114. ; ebx is free after this since gouraud does not need information from pCtx.
  115. ;while (pP)
  116. ;{
  117. PrimLoop:
  118. cmp ecx, 0
  119. je ExitPrimLoop
  120. ;UINT16 uSpans = pP->uSpans;
  121. movzx eax, word ptr [ecx+RASTPRIM_uSpans]
  122. mov uSpans, eax
  123. ;PD3DI_RASTSPAN pS = (PD3DI_RASTSPAN)(pP + 1);
  124. mov ebp, ecx
  125. add ebp, SIZEOF_RASTPRIM
  126. ;while (uSpans-- > 0)
  127. ;{
  128. SpanLoop:
  129. mov edx, uSpans
  130. mov eax, edx
  131. dec eax
  132. mov uSpans, eax
  133. test edx, edx
  134. jle ExitSpanLoop
  135. mov edi, dword ptr [ebp+RASTSPAN_pSurface]
  136. movzx eax, word ptr [ebp+RASTSPAN_uPix]
  137. ;if (pP->uFlags & D3DI_RASTPRIM_X_DEC)
  138. ;{
  139. mov edx, [ecx+RASTPRIM_uFlags]
  140. and edx, D3DI_RASTPRIM_X_DEC
  141. test edx, edx
  142. jz LeftToRightSpan
  143. ; SCREWED UP RIGHT TO LEFT CASE
  144. movq mm0, MMWORD PTR [ebp+RASTSPAN_uB]
  145. movq mm1, MMWORD PTR [ecx+RASTPRIM_iDBDX]
  146. beginingpixelsRtoL:
  147. ;WritePixel
  148. ; Convert color.
  149. movq mm5, mm0
  150. psrlw mm5, 8 ; Convert color1 from 8.8 two 0.8
  151. packuswb mm5, mm7 ; pack one color1
  152. movd edx, mm5
  153. and edx, 000ffffffh
  154. mov [edi], edx
  155. dec eax ; Reduce Pixel count
  156. jz NoMorePixelsRtoL
  157. sub edi, 4 ; decrease destination pointer
  158. ;pS->uB += pP->iDBDX; pS->uG += pP->iDGDX;
  159. ;pS->uR += pP->iDRDX; pS->uA += pP->iDADX;
  160. paddw mm0, mm1
  161. jmp beginingpixelsRtoL
  162. NoMorePixelsRtoL:
  163. jmp DoneSpanDirif
  164. ;else
  165. ;{
  166. LeftToRightSpan:
  167. ; NORMAL LEFT TO RIGHT CASE
  168. movq mm0, MMWORD PTR [ebp+RASTSPAN_uB]
  169. movq mm1, MMWORD PTR [ecx+RASTPRIM_iDBDX]
  170. beginingpixelsLtoR:
  171. ;WritePixel
  172. ; Convert color.
  173. movq mm5, mm0
  174. psrlw mm5, 8 ; Convert color1 from 8.8 two 0.8
  175. packuswb mm5, mm7 ; pack one color1
  176. movd edx, mm5
  177. and edx, 000ffffffh
  178. mov [edi], edx
  179. dec eax ; Reduce Pixel count
  180. jz NoMorePixelsLtoR
  181. add edi, 4 ; Increase destination pointer.
  182. ;pS->uB += pP->iDBDX; pS->uG += pP->iDGDX;
  183. ;pS->uR += pP->iDRDX; pS->uA += pP->iDADX;
  184. paddw mm0, mm1
  185. jmp beginingpixelsLtoR
  186. NoMorePixelsLtoR:
  187. ;}
  188. DoneSpanDirif:
  189. ; Setup Code Ends
  190. ; ----------------------------------------------------------------------------------------------------------------
  191. ; Loop Code Begins
  192. ExitPixelLoop:
  193. ; Loop code ends
  194. ;-----------------------------------------------------------------------------
  195. ; LoopAny code ends here
  196. ;-----------------------------------------------------------------------------
  197. ;pS++;
  198. add ebp, SIZEOF_RASTSPAN
  199. ;}
  200. jmp SpanLoop
  201. ExitSpanLoop:
  202. ;pP = pP->pNext;
  203. mov ecx, [ecx+RASTPRIM_pNext]
  204. ;}
  205. jmp PrimLoop
  206. ExitPrimLoop:
  207. ;_asm{
  208. emms
  209. ;}
  210. ;return S_OK;
  211. xor eax, eax
  212. ;}
  213. pop edi
  214. pop ebx
  215. mov esp, StackPos
  216. pop ebp
  217. ret
  218. END