# HG changeset patch # User Matti Hamalainen # Date 1570535340 -10800 # Node ID fe025c461760fd736f934fb53e2f1a676b3c258f # Parent 13e54305e5fcbe452ecd7210d968ddef69df0daa Move pixel helper functions from being inline in lib64gfx.h to lib64gfx.c diff -r 13e54305e5fc -r fe025c461760 tools/lib64gfx.c --- a/tools/lib64gfx.c Wed Sep 25 12:13:28 2019 +0300 +++ b/tools/lib64gfx.c Tue Oct 08 14:49:00 2019 +0300 @@ -1330,6 +1330,128 @@ } +// +// Helper functions for pixel format decoding +// +int dmC64GetGenericSCPixel(Uint8 *col, + const DMC64Image *img, const int bmoffs, const int scroffs, + const int vshift, const int vbank, const int bitmap) +{ + if ((img->bitmap[bitmap].data[bmoffs] >> vshift) & 1) + *col = img->screen[vbank].data[scroffs] >> 4; + else + *col = img->screen[vbank].data[scroffs] & 15; + + return DMERR_OK; +} + + +int dmC64GetGenericMCPixel(Uint8 *col, + const DMC64Image *img, const int bmoffs, const int scroffs, + const int vshift, const int vbank, const int bitmap, + const int cbank, const int bgcolor) +{ + switch ((img->bitmap[bitmap].data[bmoffs] >> vshift) & 3) + { + case 0: *col = bgcolor & 15; break; + case 1: *col = img->screen[vbank].data[scroffs] >> 4; break; + case 2: *col = img->screen[vbank].data[scroffs] & 15; break; + default: *col = img->color[cbank].data[scroffs] & 15; break; + } + + return DMERR_OK; +} + + +int dmC64GetGenericCharSCPixel(Uint8 *col, + const DMC64Image *img, const int scroffs, const int rasterX, + const int chrbank, const size_t chroffs, const int chr, + const int cbank, const int bgcolor) +{ + if (chroffs >= img->charData[chrbank].size) + { + return dmError(DMERR_INVALID_DATA, + "Character map index #%d out of bounds for char ROM data.\n", + chr); + } + + const int vshift = 7 - (rasterX & 7); + if ((img->charData[chrbank].data[chroffs] >> vshift) & 1) + *col = img->color[cbank].data[scroffs] & 15; + else + *col = bgcolor & 15; + + return DMERR_OK; +} + + +int dmC64GetGenericCharMCPixel(Uint8 *col, + const DMC64Image *img, const int scroffs, const int rasterX, + const int chrbank, const size_t chroffs, const int chr, + const int cbank, const int bgcolor, + const int bgd022, const int bgd023) +{ + if (chroffs >= img->charData[chrbank].size) + { + return dmError(DMERR_INVALID_DATA, + "Character map index #%d out of bounds for char ROM data.\n", + chr); + } + + const int ccol = img->color[cbank].data[scroffs]; + if (ccol & 8) + { + const int vshift = 6 - (rasterX & 6); + switch ((img->charData[chrbank].data[chroffs] >> vshift) & 3) + { + case 0: *col = bgcolor & 15; break; + case 1: *col = bgd022 & 15; break; + case 2: *col = bgd023 & 15; break; + case 3: *col = ccol & 7; + } + } + else + { + const int vshift = 7 - (rasterX & 7); + if ((img->charData[chrbank].data[chroffs] >> vshift) & 1) + *col = ccol & 7; + else + *col = bgcolor & 15; + } + + return DMERR_OK; +} + + +int dmC64GetGenericCharECMPixel(Uint8 *col, + const DMC64Image *img, const int scroffs, const int rasterX, + const int chrbank, const size_t chroffs, const int chr, + const int cbank, const int bgcolor, + const int bgd022, const int bgd023, const int bgd024) +{ + if (chroffs >= img->charData[0].size) + { + return dmError(DMERR_INVALID_DATA, + "Character map index #%d out of bounds for char ROM data.\n", + chr); + } + + const int vshift = 7 - (rasterX & 7); + if ((img->charData[chrbank].data[chroffs] >> vshift) & 1) + *col = img->color[cbank].data[scroffs] & 15; + else + switch ((chr >> 6) & 3) + { + case 0: *col = bgcolor & 15; break; + case 1: *col = bgd022 & 15; break; + case 2: *col = bgd023 & 15; break; + case 3: *col = bgd024 & 15; break; + } + + return DMERR_OK; +} + + static int fmtGetGenericSCPixel(DMC64ScanLine *scan, const DMC64Image *img, const int rasterX, const int rasterY) { diff -r 13e54305e5fc -r fe025c461760 tools/lib64gfx.h --- a/tools/lib64gfx.h Wed Sep 25 12:13:28 2019 +0300 +++ b/tools/lib64gfx.h Tue Oct 08 14:49:00 2019 +0300 @@ -484,125 +484,33 @@ // -// Inline helper functions for pixel format decoding +// Pixel format helpers // -static inline int dmC64GetGenericSCPixel(Uint8 *col, +int dmC64GetGenericSCPixel(Uint8 *col, const DMC64Image *img, const int bmoffs, const int scroffs, - const int vshift, const int vbank, const int bitmap) -{ - if ((img->bitmap[bitmap].data[bmoffs] >> vshift) & 1) - *col = img->screen[vbank].data[scroffs] >> 4; - else - *col = img->screen[vbank].data[scroffs] & 15; + const int vshift, const int vbank, const int bitmap); - return DMERR_OK; -} - - -static inline int dmC64GetGenericMCPixel(Uint8 *col, +int dmC64GetGenericMCPixel(Uint8 *col, const DMC64Image *img, const int bmoffs, const int scroffs, const int vshift, const int vbank, const int bitmap, - const int cbank, const int bgcolor) -{ - switch ((img->bitmap[bitmap].data[bmoffs] >> vshift) & 3) - { - case 0: *col = bgcolor & 15; break; - case 1: *col = img->screen[vbank].data[scroffs] >> 4; break; - case 2: *col = img->screen[vbank].data[scroffs] & 15; break; - default: *col = img->color[cbank].data[scroffs] & 15; break; - } + const int cbank, const int bgcolor); - return DMERR_OK; -} - - -static inline int dmC64GetGenericCharSCPixel(Uint8 *col, +int dmC64GetGenericCharSCPixel(Uint8 *col, const DMC64Image *img, const int scroffs, const int rasterX, const int chrbank, const size_t chroffs, const int chr, - const int cbank, const int bgcolor) -{ - if (chroffs >= img->charData[chrbank].size) - { - return dmError(DMERR_INVALID_DATA, - "Character map index #%d out of bounds for char ROM data.\n", - chr); - } + const int cbank, const int bgcolor); - const int vshift = 7 - (rasterX & 7); - if ((img->charData[chrbank].data[chroffs] >> vshift) & 1) - *col = img->color[cbank].data[scroffs] & 15; - else - *col = bgcolor & 15; - - return DMERR_OK; -} - - -static inline int dmC64GetGenericCharMCPixel(Uint8 *col, +int dmC64GetGenericCharMCPixel(Uint8 *col, const DMC64Image *img, const int scroffs, const int rasterX, const int chrbank, const size_t chroffs, const int chr, const int cbank, const int bgcolor, - const int bgd022, const int bgd023) -{ - if (chroffs >= img->charData[chrbank].size) - { - return dmError(DMERR_INVALID_DATA, - "Character map index #%d out of bounds for char ROM data.\n", - chr); - } + const int bgd022, const int bgd023); - const int ccol = img->color[cbank].data[scroffs]; - if (ccol & 8) - { - const int vshift = 6 - (rasterX & 6); - switch ((img->charData[chrbank].data[chroffs] >> vshift) & 3) - { - case 0: *col = bgcolor & 15; break; - case 1: *col = bgd022 & 15; break; - case 2: *col = bgd023 & 15; break; - case 3: *col = ccol & 7; - } - } - else - { - const int vshift = 7 - (rasterX & 7); - if ((img->charData[chrbank].data[chroffs] >> vshift) & 1) - *col = ccol & 7; - else - *col = bgcolor & 15; - } - - return DMERR_OK; -} - - -static inline int dmC64GetGenericCharECMPixel(Uint8 *col, +int dmC64GetGenericCharECMPixel(Uint8 *col, const DMC64Image *img, const int scroffs, const int rasterX, const int chrbank, const size_t chroffs, const int chr, const int cbank, const int bgcolor, - const int bgd022, const int bgd023, const int bgd024) -{ - if (chroffs >= img->charData[0].size) - { - return dmError(DMERR_INVALID_DATA, - "Character map index #%d out of bounds for char ROM data.\n", - chr); - } - - const int vshift = 7 - (rasterX & 7); - if ((img->charData[chrbank].data[chroffs] >> vshift) & 1) - *col = img->color[cbank].data[scroffs] & 15; - else - switch ((chr >> 6) & 3) - { - case 0: *col = bgcolor & 15; break; - case 1: *col = bgd022 & 15; break; - case 2: *col = bgd023 & 15; break; - case 3: *col = bgd024 & 15; break; - } - - return DMERR_OK; -} + const int bgd022, const int bgd023, const int bgd024); static inline const DMC64EncDecOp * fmtGetEncDecOp(const DMC64ImageFormat *fmt, const int index)