diff --git a/src/drivers/common/vidblit.cpp b/src/drivers/common/vidblit.cpp index 7e5cdc19..03a4c730 100644 --- a/src/drivers/common/vidblit.cpp +++ b/src/drivers/common/vidblit.cpp @@ -466,7 +466,7 @@ void Blit8To8(uint8 *src, uint8 *dest, int xr, int yr, int pitch, int xscale, in /* Todo: Make sure 24bpp code works right with big-endian cpus */ //takes a pointer to XBuf and applies fully modern deemph palettizing -u32 ModernDeemphColorMap(u8* src, u8* srcbuf, int xscale, int yscale) +template static u32 _ModernDeemphColorMap(u8* src, u8* srcbuf) { u8 pixel = *src; @@ -476,8 +476,8 @@ u32 ModernDeemphColorMap(u8* src, u8* srcbuf, int xscale, int yscale) int ofs = src-srcbuf; int xofs = ofs&255; int yofs = ofs>>8; - if(xscale!=1) xofs /= xscale; //untested optimization - if(yscale!=1) yofs /= yscale; //untested optimization + xofs /= SCALE; + yofs /= SCALE; ofs = xofs+yofs*256; //find out which deemph bitplane value we're on @@ -490,6 +490,15 @@ u32 ModernDeemphColorMap(u8* src, u8* srcbuf, int xscale, int yscale) return color; } +u32 ModernDeemphColorMap(u8* src, u8* srcbuf, int scale) +{ + if(scale == 1)_ModernDeemphColorMap<1>(src,srcbuf); + else if(scale == 2) _ModernDeemphColorMap<2>(src,srcbuf); + else if(scale == 3) _ModernDeemphColorMap<3>(src,srcbuf); + else if(scale == 4) _ModernDeemphColorMap<4>(src,srcbuf); + else abort(); +} + void Blit8ToHigh(uint8 *src, uint8 *dest, int xr, int yr, int pitch, int xscale, int yscale) { int x,y; @@ -513,6 +522,9 @@ void Blit8ToHigh(uint8 *src, uint8 *dest, int xr, int yr, int pitch, int xscale, Blit8To8(src, specbuf8bpp, xr, yr, 256*mult, xscale, yscale, 0, silt); int mdcmxs = xscale*mult; int mdcmys = yscale*mult; + + if(mdcmxs != mdcmys) + abort(); xr *= mult; yr *= mult; @@ -528,7 +540,7 @@ void Blit8ToHigh(uint8 *src, uint8 *dest, int xr, int yr, int pitch, int xscale, { for(x=xr;x;x--) { - *(uint32 *)dest=ModernDeemphColorMap(src,specbuf8bpp,mdcmxs, mdcmys); + *(uint32 *)dest=ModernDeemphColorMap(src,specbuf8bpp,mdcmxs); dest+=4; src++; } @@ -541,7 +553,7 @@ void Blit8ToHigh(uint8 *src, uint8 *dest, int xr, int yr, int pitch, int xscale, { for(x=xr;x;x--) { - uint32 tmp=ModernDeemphColorMap(src,specbuf8bpp,mdcmxs, mdcmys); + uint32 tmp=ModernDeemphColorMap(src,specbuf8bpp,mdcmxs); *(uint8 *)dest=tmp; *((uint8 *)dest+1)=tmp>>8; *((uint8 *)dest+2)=tmp>>16; @@ -581,7 +593,7 @@ void Blit8ToHigh(uint8 *src, uint8 *dest, int xr, int yr, int pitch, int xscale, { for(x=xr; x; x--) { - *(uint32 *)dest = ModernDeemphColorMap(src,XBuf,1,1); + *(uint32 *)dest = ModernDeemphColorMap(src,XBuf,1); dest += 4; src++; } @@ -920,7 +932,7 @@ void Blit8ToHigh(uint8 *src, uint8 *dest, int xr, int yr, int pitch, int xscale, for(x=xr;x;x--) { //THE MAIN BLITTING CODEPATH (there may be others that are important) - *(uint32 *)dest = ModernDeemphColorMap(src,XBuf,1,1); + *(uint32 *)dest = ModernDeemphColorMap(src,XBuf,1); dest+=4; src++; } @@ -933,7 +945,7 @@ void Blit8ToHigh(uint8 *src, uint8 *dest, int xr, int yr, int pitch, int xscale, { for(x=xr;x;x--) { - uint32 tmp = ModernDeemphColorMap(src,XBuf,1,1); + uint32 tmp = ModernDeemphColorMap(src,XBuf,1); *(uint8 *)dest=tmp; *((uint8 *)dest+1)=tmp>>8; *((uint8 *)dest+2)=tmp>>16; @@ -949,7 +961,7 @@ void Blit8ToHigh(uint8 *src, uint8 *dest, int xr, int yr, int pitch, int xscale, { for(x=xr;x;x--) { - *(uint16 *)dest = ModernDeemphColorMap(src,XBuf,1,1); + *(uint16 *)dest = ModernDeemphColorMap(src,XBuf,1); dest+=2; src++; } diff --git a/src/drivers/common/vidblit.h b/src/drivers/common/vidblit.h index 4f19f330..d9581b0b 100644 --- a/src/drivers/common/vidblit.h +++ b/src/drivers/common/vidblit.h @@ -29,4 +29,4 @@ void Blit32to16(uint32 *src, uint16 *dest, int xr, int yr, int dpitch, int shiftr[3], int shiftl[3]); -u32 ModernDeemphColorMap(u8* src, u8* srcbuf, int xscale, int yscale); \ No newline at end of file +u32 ModernDeemphColorMap(u8* src, u8* srcbuf, int scale); \ No newline at end of file diff --git a/src/video.cpp b/src/video.cpp index 0ff5d387..a4d3c6bc 100644 --- a/src/video.cpp +++ b/src/video.cpp @@ -582,7 +582,7 @@ int SaveSnapshot(void) dest++; for(x=256;x;x--) { - u32 color = ModernDeemphColorMap(tmp,XBuf,1,1); + u32 color = ModernDeemphColorMap(tmp,XBuf,1); *dest++=(color>>0x10)&0xFF; *dest++=(color>>0x08)&0xFF; *dest++=(color>>0x00)&0xFF;