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.

383 lines
11 KiB

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