20 ; void fade_image(uint16_t *dest, uint32_t *src, uint16_t fade)
21 ; - dest points to a 16bit 565 framebuffer
22 ; - src points to a 32bit RGBX image
23 ; - fade is 24.8 fixed point [0, 1]
24 ; watcom register calling convention arguments: eax, edx, ebx
33 ; take fade and duplicate it across all words of mm1
34 movd mm1, ebx ; mm1 [00|00|00|VV]
35 punpckldq mm1, mm1 ; mm1 [00|VV|00|VV]
36 packssdw mm1, mm1 ; mm1 [VV|VV|VV|VV]
38 ; grab RGB32 pixel and unpack it to zero-extended words in mm0
39 movd mm0, [edx] ; mm0 [??|??|?R|GB]
42 punpcklbw mm0, mm7 ; mm0 [0?|0R|0G|0B]
43 ; multiply by fade and divide by 256 to drop the decimal part
45 psrlw mm0, 10 ; 8 for the div + 2 to make them 666, easier 565 packing
46 ; pack result into 565 in ax
50 shr al, 1 ; blue in position [........|00RRRRRR|00GGGGGG|000BBBBB]
54 or ax, bx ; green in position ...|00RRRRRR|00000GGG|GGGBBBBB]
57 or eax, ebx ; done [RRRRRGGG|GGGBBBBB]
64 emms ; clear fpu state