# HG changeset patch # User Matti Hamalainen # Date 1562577946 -10800 # Node ID e798a41f27a5fe45b5af64f9a3de25039d705b8b # Parent 3bcad61594b44f53f31eb8712de99d4e2be171fd Clean up some code duplication. diff -r 3bcad61594b4 -r e798a41f27a5 tools/lib64fmts.c --- a/tools/lib64fmts.c Mon Jul 08 10:28:00 2019 +0300 +++ b/tools/lib64fmts.c Mon Jul 08 12:25:46 2019 +0300 @@ -1282,23 +1282,17 @@ static int fmtGetPixelFunPaint2(Uint8 *col, const DMC64Image *img, const int rasterX, const int rasterY) { - const int - x = rasterX / 8, - y = rasterY / 8, - yb = rasterY & 7, - yoffs = y * img->fmt->chWidth, - bmoffs = yoffs * 8 + yb + (x * 8), - scroffs = yoffs + x, - bitmap = rasterX & 1, - vbank = yb + (bitmap * 8), - vshift = 6 - (rasterX & 6); - + DM_C64_GENERIC_SC_PIXEL_DEFS(img) + const int bitmap = rasterX & 1; Uint8 bgcol = (unsigned) rasterY < img->extraData[0].size ? img->extraData[0].data[rasterY] : img->bgcolor; + (void) vshift; + return dmC64GetGenericMCPixel(col, img, bmoffs, scroffs, - vshift, vbank, + 6 - (rasterX & 6), + yb + (bitmap * 8), bitmap, 0, bgcol); } diff -r 3bcad61594b4 -r e798a41f27a5 tools/lib64gfx.h --- a/tools/lib64gfx.h Mon Jul 08 10:28:00 2019 +0300 +++ b/tools/lib64gfx.h Mon Jul 08 12:25:46 2019 +0300 @@ -433,8 +433,9 @@ const int \ x = rasterX / 8, \ y = rasterY / 8, \ + yb = rasterY & 7, \ yoffs = y * ximg->fmt->chWidth, \ - bmoffs = yoffs * 8 + (rasterY & 7) + (x * 8), \ + bmoffs = yoffs * 8 + yb + (x * 8), \ scroffs = yoffs + x, \ vshift = 7 - (rasterX & 7); @@ -443,8 +444,9 @@ const int \ x = rasterX / 4, \ y = rasterY / 8, \ + yb = rasterY & 7, \ yoffs = y * (ximg)->fmt->chWidth, \ - bmoffs = yoffs * 8 + (rasterY & 7) + (x * 8), \ + bmoffs = yoffs * 8 + yb + (x * 8), \ scroffs = yoffs + x, \ vshift = 6 - ((rasterX * 2) & 6);