# HG changeset patch # User Matti Hamalainen # Date 1569402695 -10800 # Node ID 94a653883a32f5e30e4a4039addf02a60e7ca217 # Parent a5c68b0d6e108f49546f32c0e4a2b02b2104b3d3 Change Uint8 pointer in getPixel functions to DMC64ScanLine pointer in preparation for future changes related to sprites on scanlines. diff -r a5c68b0d6e10 -r 94a653883a32 tools/lib64fmts.c --- a/tools/lib64fmts.c Wed Sep 25 11:45:21 2019 +0300 +++ b/tools/lib64fmts.c Wed Sep 25 12:11:35 2019 +0300 @@ -454,13 +454,13 @@ } -static int fmtGetPixelDrazLace(Uint8 *col, +static int fmtGetPixelDrazLace(DMC64ScanLine *scan, const DMC64Image *img, const int rasterX, const int rasterY) { DM_C64_GENERIC_SC_PIXEL_DEFS(img) (void) vshift; - return dmC64GetGenericMCPixel(col, img, + return dmC64GetGenericMCPixel(scan->col, img, bmoffs, scroffs, 6 - (rasterX & 6), 0, rasterX & 1, 0, img->bgcolor); @@ -677,12 +677,12 @@ } -static int fmtGetPixelFLIDesigner(Uint8 *col, +static int fmtGetPixelFLIDesigner(DMC64ScanLine *scan, const DMC64Image *img, const int rasterX, const int rasterY) { DM_C64_GENERIC_MC_PIXEL_DEFS(img) - return dmC64GetGenericMCPixel(col, img, + return dmC64GetGenericMCPixel(scan->col, img, bmoffs, scroffs, vshift, rasterY & 7, 0, 0, img->bgcolor); @@ -772,7 +772,7 @@ } -static int fmtGetPixelBlackMailFLI(Uint8 *col, +static int fmtGetPixelBlackMailFLI(DMC64ScanLine *scan, const DMC64Image *img, const int rasterX, const int rasterY) { DM_C64_GENERIC_MC_PIXEL_DEFS(img) @@ -780,20 +780,20 @@ Uint8 bgcol = (unsigned) rasterY < img->extraData[0].size ? img->extraData[0].data[rasterY] : img->bgcolor; - return dmC64GetGenericMCPixel(col, img, + return dmC64GetGenericMCPixel(scan->col, img, bmoffs, scroffs, vshift, rasterY & 7, 0, 0, bgcol); } -static int fmtGetPixelTruePaint(Uint8 *col, +static int fmtGetPixelTruePaint(DMC64ScanLine *scan, const DMC64Image *img, const int rasterX, const int rasterY) { DM_C64_GENERIC_SC_PIXEL_DEFS(img) (void) vshift; - return dmC64GetGenericMCPixel(col, img, + return dmC64GetGenericMCPixel(scan->col, img, bmoffs, scroffs, 6 - (rasterX & 6), 0, rasterX & 1, 0, img->bgcolor); @@ -930,7 +930,7 @@ } -static int fmtGetPixelFlinterlazer(Uint8 *col, +static int fmtGetPixelFlinterlazer(DMC64ScanLine *scan, const DMC64Image *img, const int rasterX, const int rasterY) { DM_C64_GENERIC_MC_PIXEL_DEFS(img) @@ -942,7 +942,7 @@ (res = dmC64GetGenericMCPixel(&color2, img, bmoffs, scroffs, vshift, vbank + 8, 1, 0, bgcol)) != DMERR_OK) return res; - *col = (color1 * D64_NCOLORS) + color2; + *(scan->col) = (color1 * D64_NCOLORS) + color2; return DMERR_OK; } @@ -1273,7 +1273,7 @@ } -static int fmtGetPixelFunPaint2(Uint8 *col, +static int fmtGetPixelFunPaint2(DMC64ScanLine *scan, const DMC64Image *img, const int rasterX, const int rasterY) { DM_C64_GENERIC_SC_PIXEL_DEFS(img) @@ -1283,7 +1283,7 @@ (void) vshift; - return dmC64GetGenericMCPixel(col, img, + return dmC64GetGenericMCPixel(scan->col, img, bmoffs, scroffs, 6 - (rasterX & 6), yb + (bitmap * 8), @@ -1291,21 +1291,21 @@ } -static int fmtGetPixelBFLI(Uint8 *col, +static int fmtGetPixelBFLI(DMC64ScanLine *scan, const DMC64Image *img, const int rasterX, const int rasterY) { DM_C64_GENERIC_MC_PIXEL_DEFS(img) const int vbb = rasterY < 200 ? 0 : 1; const int vbank = (rasterY & 7) + (vbb * 8); - return dmC64GetGenericMCPixel(col, img, + return dmC64GetGenericMCPixel(scan->col, img, bmoffs & 0x1fff, scroffs & 0x3ff, vshift, vbank, vbb, 0, img->bgcolor); } -static int fmtGetPixelPentelPaint(Uint8 *col, +static int fmtGetPixelPentelPaint(DMC64ScanLine *scan, const DMC64Image *img, const int rasterX, const int rasterY) { DM_C64_GENERIC_SC_PIXEL_DEFS(img) @@ -1324,7 +1324,7 @@ if ((res = dmC64GetGenericSCPixel(&color1, img, bmoffs, scroffs, vshift, 0, 0)) != DMERR_OK) return res; - *col = color3 ? color3 : ( color2 ? color2 : color1 ); + *(scan->col) = color3 ? color3 : ( color2 ? color2 : color1 ); return DMERR_OK; } @@ -1526,7 +1526,7 @@ } -static int fmtGetSpritePixelCrestSHFLI(Uint8 *col, +static int fmtGetSpritePixelCrestSHFLI(DMC64ScanLine *scan, const DMC64Image *img, const int sindex, const int cindex, const int spr_xd, const int spr_yd, const int mask) { @@ -1537,7 +1537,7 @@ if (img->extraData[14].data[offs] & mask) { - *col = img->extraData[15].data[cindex]; + *(scan->col) = img->extraData[15].data[cindex]; return DMERR_OK; } @@ -1545,7 +1545,7 @@ } -static int fmtGetPixelCrestSHFLI(Uint8 *col, +static int fmtGetPixelCrestSHFLI(DMC64ScanLine *scan, const DMC64Image *img, const int rasterX, const int rasterY) { DM_C64_GENERIC_SC_PIXEL_DEFS(img) @@ -1556,7 +1556,7 @@ if (rasterY / 8 >= DM_CREST_SHFLI_IMG_HEIGHT) { - *col = 0x0f; + *(scan->col) = 0x0f; return DMERR_OK; } @@ -1576,23 +1576,23 @@ const int spr_index1 = img->extraData[sbank].data[spr_offs]; const int spr_index2 = img->extraData[sbank].data[spr_offs + 4]; - if ((res = fmtGetSpritePixelCrestSHFLI(col, img, spr_index1, 0, spr_xd, spr_yd, mask)) == DMERR_OK || + if ((res = fmtGetSpritePixelCrestSHFLI(scan, img, spr_index1, 0, spr_xd, spr_yd, mask)) == DMERR_OK || res != -1) return res; - if ((res = fmtGetSpritePixelCrestSHFLI(col, img, spr_index2, 1, spr_xd, spr_yd, mask)) == DMERR_OK || + if ((res = fmtGetSpritePixelCrestSHFLI(scan, img, spr_index2, 1, spr_xd, spr_yd, mask)) == DMERR_OK || res != -1) return res; } - if ((res = dmC64GetGenericSCPixel(col, img, bmoffs, scroffs, vshift, nbank, 0)) != DMERR_OK) + if ((res = dmC64GetGenericSCPixel(scan->col, img, bmoffs, scroffs, vshift, nbank, 0)) != DMERR_OK) return res; return DMERR_OK; } -static int fmtGetPixelHCB(Uint8 *col, +static int fmtGetPixelHCB(DMC64ScanLine *scan, const DMC64Image *img, const int rasterX, const int rasterY) { DM_C64_GENERIC_MC_PIXEL_DEFS(img) @@ -1602,25 +1602,25 @@ Uint8 bgcol = (unsigned) ry < img->extraData[0].size ? img->extraData[0].data[ry] : img->bgcolor; - return dmC64GetGenericMCPixel(col, img, + return dmC64GetGenericMCPixel(scan->col, img, bmoffs, scroffs, vshift, vbank, 0, vbank, bgcol); } -static int fmtGetPixelCrestHIFLIorCDHM(Uint8 *col, +static int fmtGetPixelCrestHIFLIorCDHM(DMC64ScanLine *scan, const DMC64Image *img, const int rasterX, const int rasterY) { DM_C64_GENERIC_SC_PIXEL_DEFS(img) - return dmC64GetGenericSCPixel(col, img, + return dmC64GetGenericSCPixel(scan->col, img, bmoffs, scroffs, vshift, rasterY & 7, 0); } -static int fmtGetPixelECI(Uint8 *col, +static int fmtGetPixelECI(DMC64ScanLine *scan, const DMC64Image *img, const int rasterX, const int rasterY) { DM_C64_GENERIC_SC_PIXEL_DEFS(img) @@ -1632,7 +1632,7 @@ (res = dmC64GetGenericSCPixel(&color2, img, bmoffs, scroffs, vshift, vbank + 8, 1)) != DMERR_OK) return res; - *col = (color1 * D64_NCOLORS) + color2; + *(scan->col) = (color1 * D64_NCOLORS) + color2; return DMERR_OK; } diff -r a5c68b0d6e10 -r 94a653883a32 tools/lib64gfx.c --- a/tools/lib64gfx.c Wed Sep 25 11:45:21 2019 +0300 +++ b/tools/lib64gfx.c Wed Sep 25 12:11:35 2019 +0300 @@ -1330,32 +1330,32 @@ } -static int fmtGetGenericSCPixel(Uint8 *col, +static int fmtGetGenericSCPixel(DMC64ScanLine *scan, const DMC64Image *img, const int rasterX, const int rasterY) { DM_C64_GENERIC_SC_PIXEL_DEFS(img) return dmC64GetGenericSCPixel( - col, img, + scan->col, img, bmoffs, scroffs, vshift, 0, 0); } -static int fmtGetGenericMCPixel(Uint8 *col, +static int fmtGetGenericMCPixel(DMC64ScanLine *scan, const DMC64Image *img, const int rasterX, const int rasterY) { DM_C64_GENERIC_MC_PIXEL_DEFS(img) return dmC64GetGenericMCPixel( - col, img, + scan->col, img, bmoffs, scroffs, vshift, 0, 0, 0, img->bgcolor); } -static int fmtGetGenericCharPixel(Uint8 *col, +static int fmtGetGenericCharPixel(DMC64ScanLine *scan, const DMC64Image *img, const int rasterX, const int rasterY) { DM_C64_GENERIC_CHAR_PIXEL(img) @@ -1369,21 +1369,21 @@ { case D64_FMT_HIRES: return dmC64GetGenericCharSCPixel( - col, img, + scan->col, img, scroffs, rasterX, 0, (chr * D64_CHR_SIZE) + (rasterY & 7), chr, 0, img->bgcolor); case D64_FMT_MC: return dmC64GetGenericCharMCPixel( - col, img, + scan->col, img, scroffs, rasterX, 0, (chr * D64_CHR_SIZE) + (rasterY & 7), chr, 0, img->bgcolor, img->d022, img->d023); case D64_FMT_ECM: return dmC64GetGenericCharECMPixel( - col, img, + scan->col, img, scroffs, rasterX, 0, ((chr & 0x3f) * D64_CHR_SIZE) + (rasterY & 7), chr, 0, img->bgcolor, img->d022, img->d023, img->d024); @@ -1401,8 +1401,11 @@ static int dmC64ConvertGenericBMP2Image(DMImage *dst, const DMC64Image *src, const DMC64ImageConvSpec *spec) { DMC64GetPixelFunc getPixel; + DMC64ScanLine scan; + (void) spec; dmMemset(dst->data, 0, dst->size); + dmMemset(&scan, 0, sizeof(scan)); // Check pixel getter function if (src->fmt->getPixel != NULL) @@ -1424,11 +1427,11 @@ // Perform conversion for (int yc = 0; yc < dst->height; yc++) { - Uint8 *dp = dst->data + (yc * dst->pitch); - for (int xc = 0; xc < dst->width; xc++, dp++) + scan.col = dst->data + (yc * dst->pitch); + for (int xc = 0; xc < dst->width; xc++, scan.col++) { int res; - if ((res = getPixel(dp, src, xc, yc)) != DMERR_OK) + if ((res = getPixel(&scan, src, xc, yc)) != DMERR_OK) return res; } } diff -r a5c68b0d6e10 -r 94a653883a32 tools/lib64gfx.h --- a/tools/lib64gfx.h Wed Sep 25 11:45:21 2019 +0300 +++ b/tools/lib64gfx.h Wed Sep 25 12:11:35 2019 +0300 @@ -250,7 +250,13 @@ } DMC64Image; -typedef int (*DMC64GetPixelFunc)(Uint8 *col, +typedef struct +{ + Uint8 *col; +} DMC64ScanLine; + + +typedef int (*DMC64GetPixelFunc)(DMC64ScanLine *scan, const DMC64Image *img, const int rasterX, const int rasterY);