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.

543 lines
15 KiB

  1. page ,132
  2. ;----------------------------Module-Header------------------------------;
  3. ; Module Name: SETDI16.ASM
  4. ;
  5. ; move bits from one DIB format into another. doing color conversion if
  6. ; needed.
  7. ;
  8. ; convert_8_16
  9. ; convert_16_16
  10. ; convert_24_16
  11. ; convert_32_16
  12. ;
  13. ; convert_8_565 (same as convert_8_16)
  14. ; convert_16_565
  15. ; convert_24_565
  16. ; convert_32_565
  17. ;
  18. ; NOTES:
  19. ;
  20. ; AUTHOR: ToddLa (Todd Laney) Microsoft
  21. ;
  22. ;-----------------------------------------------------------------------;
  23. ?PLM=1
  24. ?WIN=0
  25. .xlist
  26. include cmacro32.inc
  27. include windows.inc
  28. .list
  29. sBegin Data
  30. sEnd Data
  31. ifndef SEGNAME
  32. SEGNAME equ <_TEXT32>
  33. endif
  34. .386
  35. createSeg %SEGNAME, CodeSeg, dword, public, CODE
  36. sBegin CodeSeg
  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_16
  57. ;
  58. ;--------------------------------------------------------------------------;
  59. assumes ds,nothing
  60. assumes es,nothing
  61. cProc convert_8_16,<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. xor edx,edx
  77. lfs si,src_ptr
  78. les di,dst_ptr
  79. lds bx,xlat_table
  80. add esi,src_offset
  81. add edi,dst_offset
  82. mov eax,pel_count
  83. sub src_next_scan,eax
  84. add eax,eax
  85. sub dst_next_scan,eax
  86. align 4
  87. convert_8_16_start:
  88. mov ecx,pel_count
  89. shr ecx,2
  90. jz short convert_8_16_ack
  91. align 4
  92. convert_8_16_loop:
  93. mov eax,fs:[esi] ; grab 4 pixels
  94. mov dl,ah ; get pel
  95. mov bx,[edx+edx] ; convert to 16bpp
  96. shl ebx,16
  97. mov dl,al ; get pel
  98. mov bx,[edx+edx] ; convert to 16bpp
  99. mov es:[edi],ebx ; store 2 pels
  100. rol eax,16
  101. mov dl,ah ; get pel
  102. mov bx,[edx+edx] ; convert to 16bpp
  103. rol ebx,16
  104. mov dl,al ; get pel
  105. mov bx,[edx+edx] ; convert to 16bpp
  106. mov es:[edi+4],ebx ; store 2 pels
  107. add esi,4
  108. add edi,8
  109. dec ecx
  110. jnz short convert_8_16_loop
  111. convert_8_16_ack:
  112. mov ecx,pel_count
  113. and ecx,3
  114. jnz short convert_8_16_odd
  115. convert_8_16_next:
  116. nxtscan si,src_next_scan
  117. nxtscan di,dst_next_scan,dst_fill_bytes
  118. dec scan_count
  119. jnz short convert_8_16_start
  120. cEnd
  121. convert_8_16_odd:
  122. mov dl,fs:[esi] ; get pel
  123. mov bx,[edx+edx] ; convert to 16bpp
  124. mov es:[edi],bx ; store pel
  125. inc esi
  126. add edi,2
  127. dec ecx
  128. jnz short convert_8_16_odd
  129. jz short convert_8_16_next
  130. ;--------------------------------------------------------------------------;
  131. ;
  132. ; convert_16_16
  133. ;
  134. ;--------------------------------------------------------------------------;
  135. assumes ds,nothing
  136. assumes es,nothing
  137. cProc convert_16_16,<FAR,PUBLIC,PASCAL>,<esi,edi,ds>
  138. ParmD dst_ptr ; --> dst.
  139. ParmD dst_offset ; offset to start at
  140. ParmD dst_next_scan ; dst_next_scan.
  141. ParmD dst_fill_bytes ; dst_fill_bytes
  142. ParmD src_ptr ; --> src.
  143. ParmD src_offset ; offset to start at
  144. ParmD src_next_scan ; dst_next_scan.
  145. ParmD pel_count ; pixel count.
  146. ParmD scan_count ; scan count.
  147. ParmD xlat_table ; pixel convert table.
  148. cBegin
  149. xor esi,esi
  150. xor edi,edi
  151. lds si,src_ptr
  152. les di,dst_ptr
  153. add esi,src_offset
  154. add edi,dst_offset
  155. mov eax,pel_count
  156. add eax,eax
  157. sub src_next_scan,eax
  158. sub dst_next_scan,eax
  159. mov ebx,eax
  160. mov edx,eax
  161. shr ebx,2
  162. and edx,3
  163. align 4
  164. convert_16_16_start:
  165. mov ecx,ebx
  166. rep movs dword ptr es:[edi],dword ptr ds:[esi]
  167. mov ecx,edx
  168. rep movs byte ptr es:[edi],byte ptr ds:[esi]
  169. nxtscan si,src_next_scan
  170. nxtscan di,dst_next_scan,dst_fill_bytes
  171. dec scan_count
  172. jnz short convert_16_16_start
  173. cEnd
  174. ;--------------------------------------------------------------------------;
  175. ;
  176. ; convert_24_16
  177. ;
  178. ;--------------------------------------------------------------------------;
  179. assumes ds,nothing
  180. assumes es,nothing
  181. cProc convert_24_16,<FAR,PUBLIC,PASCAL>,<esi,edi,ds>
  182. ParmD dst_ptr ; --> dst.
  183. ParmD dst_offset ; offset to start at
  184. ParmD dst_next_scan ; dst_next_scan.
  185. ParmD dst_fill_bytes ; dst_fill_bytes
  186. ParmD src_ptr ; --> src.
  187. ParmD src_offset ; offset to start at
  188. ParmD src_next_scan ; dst_next_scan.
  189. ParmD pel_count ; pixel count.
  190. ParmD scan_count ; scan count.
  191. ParmD xlat_table ; pixel convert table.
  192. cBegin
  193. xor esi,esi
  194. xor edi,edi
  195. lds si,src_ptr
  196. les di,dst_ptr
  197. add esi,src_offset
  198. add edi,dst_offset
  199. mov eax,pel_count
  200. add eax,eax
  201. sub dst_next_scan,eax
  202. add eax,pel_count
  203. sub src_next_scan,eax
  204. mov dl,0F8h
  205. align 4
  206. convert_24_16_start:
  207. mov ecx,pel_count
  208. align 4
  209. convert_24_16_loop:
  210. mov al,[esi+0] ; get BLUE
  211. and al,dl
  212. mov bl,al
  213. mov bh,[esi+1] ; get GREEN
  214. shr bh,3
  215. shr ebx,3
  216. mov al,[esi+2] ; get RED
  217. and al,dl
  218. shr al,1
  219. or bh,al
  220. mov es:[edi],bx
  221. add esi,3
  222. add edi,2
  223. dec ecx
  224. jnz convert_24_16_loop
  225. convert_24_16_next:
  226. nxtscan si,src_next_scan
  227. nxtscan di,dst_next_scan,dst_fill_bytes
  228. dec scan_count
  229. jnz convert_24_16_start
  230. cEnd
  231. ;--------------------------------------------------------------------------;
  232. ;
  233. ; convert_32_16
  234. ;
  235. ;--------------------------------------------------------------------------;
  236. assumes ds,nothing
  237. assumes es,nothing
  238. cProc convert_32_16,<FAR,PUBLIC,PASCAL>,<esi,edi,ds>
  239. ParmD dst_ptr ; --> dst.
  240. ParmD dst_offset ; offset to start at
  241. ParmD dst_next_scan ; dst_next_scan.
  242. ParmD dst_fill_bytes ; dst_fill_bytes
  243. ParmD src_ptr ; --> src.
  244. ParmD src_offset ; offset to start at
  245. ParmD src_next_scan ; dst_next_scan.
  246. ParmD pel_count ; pixel count.
  247. ParmD scan_count ; scan count.
  248. ParmD xlat_table ; pixel convert table.
  249. cBegin
  250. xor esi,esi
  251. xor edi,edi
  252. lds si,src_ptr
  253. les di,dst_ptr
  254. add esi,src_offset
  255. add edi,dst_offset
  256. mov eax,pel_count
  257. add eax,eax
  258. sub dst_next_scan,eax
  259. add eax,eax
  260. sub src_next_scan,eax
  261. mov dl,0F8h
  262. align 4
  263. convert_32_16_start:
  264. mov ecx,pel_count
  265. align 4
  266. convert_32_16_loop:
  267. mov al,[esi+0] ; get BLUE
  268. and al,dl
  269. mov bl,al
  270. mov bh,[esi+1] ; get GREEN
  271. shr bh,3
  272. shr ebx,3
  273. mov al,[esi+2] ; get RED
  274. and al,dl
  275. shr al,1
  276. or bh,al
  277. mov es:[edi],bx
  278. add esi,4
  279. add edi,2
  280. dec ecx
  281. jnz short convert_32_16_loop
  282. convert_32_16_next:
  283. nxtscan si,src_next_scan
  284. nxtscan di,dst_next_scan,dst_fill_bytes
  285. dec scan_count
  286. jnz short convert_32_16_start
  287. cEnd
  288. ;--------------------------------------------------------------------------;
  289. ;
  290. ; convert_8_565
  291. ;
  292. ;--------------------------------------------------------------------------;
  293. public convert_8_565
  294. convert_8_565 = convert_8_16
  295. ;--------------------------------------------------------------------------;
  296. ;
  297. ; convert_16_565
  298. ;
  299. ;--------------------------------------------------------------------------;
  300. assumes ds,nothing
  301. assumes es,nothing
  302. cProc convert_16_565,<FAR,PUBLIC,PASCAL>,<esi,edi,ds>
  303. ParmD dst_ptr ; --> dst.
  304. ParmD dst_offset ; offset to start at
  305. ParmD dst_next_scan ; dst_next_scan.
  306. ParmD dst_fill_bytes ; dst_fill_bytes
  307. ParmD src_ptr ; --> src.
  308. ParmD src_offset ; offset to start at
  309. ParmD src_next_scan ; dst_next_scan.
  310. ParmD pel_count ; pixel count.
  311. ParmD scan_count ; scan count.
  312. ParmD xlat_table ; pixel convert table.
  313. cBegin
  314. xor esi,esi
  315. xor edi,edi
  316. lds si,src_ptr
  317. les di,dst_ptr
  318. add esi,src_offset
  319. add edi,dst_offset
  320. and pel_count,not 1 ;;!!!
  321. mov eax,pel_count
  322. add eax,eax
  323. sub src_next_scan,eax
  324. sub dst_next_scan,eax
  325. mov ecx,pel_count
  326. shr ecx,1
  327. jz short convert_16_565_exit
  328. mov pel_count,ecx
  329. align 4
  330. convert_16_565_start:
  331. mov ecx,pel_count
  332. align 4
  333. convert_16_565_loop:
  334. mov ebx,[esi] ;ebx=xRRRRRGGGGGBBBBBxRRRRRGGGGGBBBBB
  335. mov eax,ebx ;eax=xRRRRRGGGGGBBBBBxRRRRRGGGGGBBBBB
  336. add eax,eax ;eax=RRRRRGGGGGBBBBBxRRRRRGGGGGBBBBBx
  337. and ebx,0001F001Fh ;ebx=00000000000BBBBB00000000000BBBBB
  338. and eax,0FFC0FFC0h ;eax=RRRRRGGGGG000000RRRRRGGGGG000000
  339. or eax,ebx ;eax=RRRRRGGGGG0BBBBBRRRRRGGGGG0BBBBB
  340. mov es:[edi],eax ;store both 565 pels
  341. add esi,4
  342. add edi,4
  343. dec ecx
  344. jnz short convert_16_565_loop
  345. convert_16_565_next:
  346. nxtscan si,src_next_scan
  347. nxtscan di,dst_next_scan,dst_fill_bytes
  348. dec scan_count
  349. jnz short convert_16_565_start
  350. convert_16_565_exit:
  351. cEnd
  352. ;--------------------------------------------------------------------------;
  353. ;
  354. ; convert_24_565
  355. ;
  356. ;--------------------------------------------------------------------------;
  357. assumes ds,nothing
  358. assumes es,nothing
  359. cProc convert_24_565,<FAR,PUBLIC,PASCAL>,<esi,edi,ds>
  360. ParmD dst_ptr ; --> dst.
  361. ParmD dst_offset ; offset to start at
  362. ParmD dst_next_scan ; dst_next_scan.
  363. ParmD dst_fill_bytes ; dst_fill_bytes
  364. ParmD src_ptr ; --> src.
  365. ParmD src_offset ; offset to start at
  366. ParmD src_next_scan ; dst_next_scan.
  367. ParmD pel_count ; pixel count.
  368. ParmD scan_count ; scan count.
  369. ParmD xlat_table ; pixel convert table.
  370. cBegin
  371. xor esi,esi
  372. xor edi,edi
  373. lds si,src_ptr
  374. les di,dst_ptr
  375. add esi,src_offset
  376. add edi,dst_offset
  377. mov eax,pel_count
  378. add eax,eax
  379. sub dst_next_scan,eax
  380. add eax,pel_count
  381. sub src_next_scan,eax
  382. mov dl,0F8h
  383. align 4
  384. convert_24_565_start:
  385. mov ecx,pel_count
  386. align 4
  387. convert_24_565_loop:
  388. mov al,[esi+0] ; get BLUE
  389. and al,dl
  390. mov bl,al
  391. mov bh,[esi+1] ; get GREEN
  392. shr bh,2
  393. shr ebx,3
  394. mov al,[esi+2] ; get RED
  395. and al,dl
  396. or bh,al
  397. mov es:[edi],bx
  398. add esi,3
  399. add edi,2
  400. dec ecx
  401. jnz short convert_24_565_loop
  402. convert_24_565_next:
  403. nxtscan si,src_next_scan
  404. nxtscan di,dst_next_scan,dst_fill_bytes
  405. dec scan_count
  406. jnz short convert_24_565_start
  407. cEnd
  408. ;--------------------------------------------------------------------------;
  409. ;
  410. ; convert_32_565
  411. ;
  412. ;--------------------------------------------------------------------------;
  413. assumes ds,nothing
  414. assumes es,nothing
  415. cProc convert_32_565,<FAR,PUBLIC,PASCAL>,<esi,edi,ds>
  416. ParmD dst_ptr ; --> dst.
  417. ParmD dst_offset ; offset to start at
  418. ParmD dst_next_scan ; dst_next_scan.
  419. ParmD dst_fill_bytes ; dst_fill_bytes
  420. ParmD src_ptr ; --> src.
  421. ParmD src_offset ; offset to start at
  422. ParmD src_next_scan ; dst_next_scan.
  423. ParmD pel_count ; pixel count.
  424. ParmD scan_count ; scan count.
  425. ParmD xlat_table ; pixel convert table.
  426. cBegin
  427. xor esi,esi
  428. xor edi,edi
  429. lds si,src_ptr
  430. les di,dst_ptr
  431. add esi,src_offset
  432. add edi,dst_offset
  433. mov eax,pel_count
  434. add eax,eax
  435. sub dst_next_scan,eax
  436. add eax,eax
  437. sub src_next_scan,eax
  438. mov dl,0F8h
  439. align 4
  440. convert_32_565_start:
  441. mov ecx,pel_count
  442. align 4
  443. convert_32_565_loop:
  444. mov al,[esi+0] ; get BLUE
  445. and al,dl
  446. mov bl,al
  447. mov bh,[esi+1] ; get GREEN
  448. shr bh,2
  449. shr ebx,3
  450. mov al,[esi+2] ; get RED
  451. and al,dl
  452. or bh,al
  453. mov es:[edi],bx
  454. add esi,4
  455. add edi,2
  456. dec ecx
  457. jnz short convert_32_565_loop
  458. convert_32_565_next:
  459. nxtscan si,src_next_scan
  460. nxtscan di,dst_next_scan,dst_fill_bytes
  461. dec scan_count
  462. jnz short convert_32_565_start
  463. cEnd
  464. sEnd CodeSeg
  465. end