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.

381 lines
10 KiB

  1. page ,132
  2. ;----------------------------Module-Header------------------------------;
  3. ; Module Name: SETDI24.ASM
  4. ;
  5. ; move bits from one DIB format into another. doing color conversion if
  6. ; needed.
  7. ;
  8. ; convert_8_24
  9. ; convert_16_24
  10. ; convert_24_24
  11. ; convert_32_24
  12. ;
  13. ; NOTES:
  14. ;
  15. ; AUTHOR: ToddLa (Todd Laney) Microsoft
  16. ;
  17. ;-----------------------------------------------------------------------;
  18. ?PLM=1
  19. ?WIN=0
  20. .xlist
  21. include cmacro32.inc
  22. include windows.inc
  23. .list
  24. sBegin Data
  25. sEnd Data
  26. ifndef SEGNAME
  27. SEGNAME equ <_TEXT32>
  28. endif
  29. .386
  30. createSeg %SEGNAME, CodeSeg, word, public, CODE
  31. sBegin CodeSeg
  32. assumes cs,CodeSeg
  33. assumes ds,nothing
  34. assumes es,nothing
  35. ;--------------------------------------------------------------------------;
  36. ;--------------------------------------------------------------------------;
  37. nxtscan macro reg, next_scan, fill_bytes
  38. ifb <fill_bytes>
  39. add e&reg,next_scan
  40. else
  41. mov eax,e&reg
  42. add e&reg,next_scan
  43. cmp ax,reg
  44. sbb eax,eax
  45. and eax,fill_bytes
  46. add e&reg,eax
  47. endif
  48. endm
  49. ;--------------------------------------------------------------------------;
  50. ;
  51. ; convert_8_24
  52. ;
  53. ;--------------------------------------------------------------------------;
  54. assumes ds,nothing
  55. assumes es,nothing
  56. cProc convert_8_24,<FAR,PUBLIC,PASCAL>,<esi,edi,ds>
  57. ParmD dst_ptr ; --> dst.
  58. ParmD dst_offset ; offset to start at
  59. ParmD dst_next_scan ; dst_next_scan.
  60. ParmD dst_fill_bytes ; dst_fill_bytes
  61. ParmD src_ptr ; --> src.
  62. ParmD src_offset ; offset to start at
  63. ParmD src_next_scan ; dst_next_scan.
  64. ParmD pel_count ; pixel count.
  65. ParmD scan_count ; scan count.
  66. ParmD xlat_table ; pixel convert table.
  67. cBegin
  68. xor esi,esi
  69. xor edi,edi
  70. xor ebx,ebx
  71. lfs si,src_ptr
  72. les di,dst_ptr
  73. lds bx,xlat_table
  74. add esi,src_offset
  75. add edi,dst_offset
  76. mov eax,pel_count
  77. sub src_next_scan,eax
  78. add eax,eax
  79. add eax,pel_count
  80. sub dst_next_scan,eax
  81. xor eax,eax
  82. align 4
  83. convert_8_24_start:
  84. mov ecx,pel_count
  85. align 4
  86. convert_8_24_loop:
  87. mov bl,fs:[esi] ; grab a pel
  88. mov edx,[ebx*4] ; convert to 24bpp
  89. mov es:[edi],dl
  90. shr edx,8
  91. mov es:[edi+1],dx
  92. inc esi
  93. add edi,3
  94. dec ecx
  95. jnz short convert_8_24_loop ;; ack
  96. convert_8_24_next:
  97. nxtscan si,src_next_scan
  98. nxtscan di,dst_next_scan,dst_fill_bytes
  99. dec scan_count
  100. jnz short convert_8_24_start
  101. cEnd
  102. ;--------------------------------------------------------------------------;
  103. ;
  104. ; STOSB32 - store a byte, every four times doing a STOSD
  105. ;
  106. ;--------------------------------------------------------------------------;
  107. STOSB32_N = 0
  108. STOSB32 macro
  109. ror eax,8 ; rotate pixel (al) into eax
  110. STOSB32_N = STOSB32_N + 1
  111. if (STOSB32_N mod 4) eq 0
  112. mov es:[edi], eax
  113. add edi,4
  114. endif
  115. endm
  116. ;--------------------------------------------------------------------------;
  117. ;
  118. ; LODSB32 - get a byte, every four times doing a LODSD
  119. ;
  120. ;--------------------------------------------------------------------------;
  121. LODSB32_N = 0
  122. LODSB32 macro
  123. if (LODSB32_N mod 4) eq 0
  124. mov eax,[esi]
  125. add esi,4
  126. else
  127. ror eax,8
  128. endif
  129. LODSB32_N = LODSB32_N + 1
  130. endm
  131. ;--------------------------------------------------------------------------;
  132. ;
  133. ; MAP16
  134. ;
  135. ;--------------------------------------------------------------------------;
  136. MAP16 macro n
  137. if n and 1
  138. shr ebx,16 ; get pel from last time
  139. else
  140. mov ebx, [esi] ; grab two pels
  141. add esi,4
  142. endif
  143. ;
  144. ; BX contains 5:5:5 RGB convert it to a 8:8:8 RGB
  145. ;
  146. mov al,bl
  147. shl al,3
  148. STOSB32
  149. shr bx,2
  150. mov al,bl
  151. and al,dh ; F8h
  152. STOSB32
  153. mov al,bh
  154. shl al,3
  155. STOSB32
  156. endm
  157. ;--------------------------------------------------------------------------;
  158. ;
  159. ; convert_16_24
  160. ;
  161. ;--------------------------------------------------------------------------;
  162. assumes ds,nothing
  163. assumes es,nothing
  164. cProc convert_16_24,<FAR,PUBLIC,PASCAL>,<esi,edi,ds>
  165. ParmD dst_ptr ; --> dst.
  166. ParmD dst_offset ; offset to start at
  167. ParmD dst_next_scan ; dst_next_scan.
  168. ParmD dst_fill_bytes ; dst_fill_bytes
  169. ParmD src_ptr ; --> src.
  170. ParmD src_offset ; offset to start at
  171. ParmD src_next_scan ; dst_next_scan.
  172. ParmD pel_count ; pixel count.
  173. ParmD scan_count ; scan count.
  174. ParmD xlat_table ; pixel convert table.
  175. cBegin
  176. xor esi,esi
  177. xor edi,edi
  178. lds si,src_ptr
  179. les di,dst_ptr
  180. add esi,src_offset
  181. add edi,dst_offset
  182. and pel_count,not 3 ;;!!!
  183. mov eax,pel_count
  184. add eax,eax
  185. sub src_next_scan,eax
  186. add eax,pel_count
  187. sub dst_next_scan,eax
  188. mov ecx,pel_count
  189. shr ecx,2
  190. mov pel_count,ecx
  191. mov dh,0F8h
  192. align 4
  193. convert_16_24_start:
  194. mov ecx,pel_count
  195. align 4
  196. convert_16_24_loop:
  197. MAP16 0
  198. MAP16 1
  199. MAP16 2
  200. MAP16 3
  201. dec ecx
  202. jnz convert_16_24_loop
  203. convert_16_24_next:
  204. nxtscan si,src_next_scan
  205. nxtscan di,dst_next_scan,dst_fill_bytes
  206. dec scan_count
  207. jnz convert_16_24_start
  208. cEnd
  209. ;--------------------------------------------------------------------------;
  210. ;
  211. ; convert_24_24
  212. ;
  213. ;--------------------------------------------------------------------------;
  214. assumes ds,nothing
  215. assumes es,nothing
  216. cProc convert_24_24,<FAR,PUBLIC,PASCAL>,<esi,edi,ds>
  217. ParmD dst_ptr ; --> dst.
  218. ParmD dst_offset ; offset to start at
  219. ParmD dst_next_scan ; dst_next_scan.
  220. ParmD dst_fill_bytes ; dst_fill_bytes
  221. ParmD src_ptr ; --> src.
  222. ParmD src_offset ; offset to start at
  223. ParmD src_next_scan ; dst_next_scan.
  224. ParmD pel_count ; pixel count.
  225. ParmD scan_count ; scan count.
  226. ParmD xlat_table ; pixel convert table.
  227. cBegin
  228. xor esi,esi
  229. xor edi,edi
  230. lds si,src_ptr
  231. les di,dst_ptr
  232. add esi,src_offset
  233. add edi,dst_offset
  234. mov eax,pel_count
  235. add eax,eax
  236. add eax,pel_count
  237. sub dst_next_scan,eax
  238. sub src_next_scan,eax
  239. mov ebx,eax
  240. mov edx,eax
  241. shr ebx,2
  242. and edx,3
  243. align 4
  244. convert_24_24_start:
  245. mov ecx,ebx
  246. rep movs dword ptr es:[edi],dword ptr ds:[esi]
  247. mov ecx,edx
  248. rep movs byte ptr es:[edi],byte ptr ds:[esi]
  249. nxtscan si,src_next_scan
  250. nxtscan di,dst_next_scan,dst_fill_bytes
  251. dec scan_count
  252. jnz short convert_24_24_start
  253. cEnd
  254. ;--------------------------------------------------------------------------;
  255. ;
  256. ; convert_32_24
  257. ;
  258. ;--------------------------------------------------------------------------;
  259. assumes ds,nothing
  260. assumes es,nothing
  261. cProc convert_32_24,<FAR,PUBLIC,PASCAL>,<esi,edi,ds>
  262. ParmD dst_ptr ; --> dst.
  263. ParmD dst_offset ; offset to start at
  264. ParmD dst_next_scan ; dst_next_scan.
  265. ParmD dst_fill_bytes ; dst_fill_bytes
  266. ParmD src_ptr ; --> src.
  267. ParmD src_offset ; offset to start at
  268. ParmD src_next_scan ; dst_next_scan.
  269. ParmD pel_count ; pixel count.
  270. ParmD scan_count ; scan count.
  271. ParmD xlat_table ; pixel convert table.
  272. cBegin
  273. xor esi,esi
  274. xor edi,edi
  275. lds si,src_ptr
  276. les di,dst_ptr
  277. add esi,src_offset
  278. add edi,dst_offset
  279. and pel_count,not 3 ; !!!
  280. mov eax,pel_count
  281. add eax,eax
  282. add eax,eax
  283. sub src_next_scan,eax
  284. sub eax,pel_count
  285. sub dst_next_scan,eax
  286. mov ecx,pel_count
  287. shr ecx,2
  288. jz short convert_32_24_exit
  289. mov pel_count,ecx
  290. align 4
  291. convert_32_24_start:
  292. mov ecx,pel_count
  293. align 4
  294. convert_32_24_loop:
  295. mov eax,[esi] ; eax = XRGB
  296. mov ebx,[esi+4] ; ebx = xrgb
  297. shl eax,8 ; eax = RGB0
  298. shrd eax,ebx,8 ; eax = bRGB
  299. mov es:[edi],eax ; store pels
  300. shl ebx,8 ; ebx = rgb0
  301. mov eax,[esi+8] ; eax = XRGB
  302. shrd ebx,eax,16 ; ebx = GBrg
  303. mov es:[edi+4],ebx ; store pels
  304. shl eax,8 ; eax = RGB0
  305. mov ebx,[esi+12] ; ebx = xrgb
  306. shrd eax,ebx,24 ; eax = rgbR
  307. mov es:[edi+8],eax ; store pels
  308. add esi,16
  309. add edi,12
  310. dec ecx
  311. jnz short convert_32_24_loop
  312. convert_32_24_next:
  313. nxtscan si,src_next_scan
  314. nxtscan di,dst_next_scan,dst_fill_bytes
  315. dec scan_count
  316. jnz short convert_32_24_start
  317. convert_32_24_exit:
  318. cEnd
  319. sEnd CodeSeg
  320. end