Ticket #4828: quaramonte-valgrind-debug.patch

File quaramonte-valgrind-debug.patch, 4.1 KB (added by digitall, 14 years ago)

Debug Patch for 2nd valgrind error - Mining Company, Quaramonte

  • render.cpp

     
    112112}
    113113
    114114void Screen::scaleImageGood(byte *dst, uint16 dstPitch, uint16 dstWidth, uint16 dstHeight, byte *src, uint16 srcPitch, uint16 srcWidth, uint16 srcHeight, byte *backbuf) {
     115        bool debug = false;
     116
     117        if (dstPitch == 39 && dstWidth == 39 && dstHeight == 173 && srcPitch == 33 && srcWidth == 33 && srcHeight == 145) {
     118                printf("Screen::scaleImageGood() Debug Triggered\r\n");
     119                fflush(stdout);
     120                printf("Screen::scaleImageGood(dstPitch = %d, dstWidth = %d, dstHeight = %d, srcPitch = %d, srcWidth = %d, srcHeight = %d)\r\n", dstPitch, dstWidth, dstHeight, srcPitch, srcWidth, srcHeight);
     121                fflush(stdout);
     122                debug = true;
     123        }
     124
    115125        for (int y = 0; y < dstHeight; y++) {
    116126                for (int x = 0; x < dstWidth; x++) {
    117127                        uint8 c1, c2, c3, c4;
     
    124134                        byte *srcPtr = src + yPos * srcPitch + xPos;
    125135                        byte *backPtr = backbuf + y * _screenWide + x;
    126136
     137                        if (debug && x == 0 && y == 161) {
     138                                printf("x: %d y: %d\r\n", x, y);
     139                                fflush(stdout);
     140                                printf("xPos: %lu yPos: %lu\r\n", xPos, yPos);
     141                                fflush(stdout);
     142                                printf("xFrac: %lu yFrac: %lu\r\n", xFrac, yFrac);
     143                                fflush(stdout);
     144                                printf("_screenWide: %lu\r\n", _screenWide);
     145                                fflush(stdout);
     146                        }
     147
    127148                        bool transparent = true;
    128149
    129150                        if (*srcPtr) {
    130151                                c1 = *srcPtr;
    131152                                transparent = false;
    132                         } else
     153                                if (debug && x == 0 && y == 161) {
     154                                        printf("pixel c1: %d\r\n", c1);
     155                                        fflush(stdout);
     156                                }
     157                        } else {
    133158                                c1 = *backPtr;
     159                                if (debug && x == 0 && y == 161) {
     160                                        printf("back c1: %d\r\n", c1);
     161                                        fflush(stdout);
     162                                }
     163                        }
    134164
    135165                        if (x < dstWidth - 1) {
    136166                                if (*(srcPtr + 1)) {
    137167                                        c2 = *(srcPtr + 1);
    138168                                        transparent = false;
    139                                 } else
     169                                        if (debug && x == 0 && y == 161) {
     170                                                printf("pixel c2: %d\r\n", c2);
     171                                                fflush(stdout);
     172                                        }
     173                                } else {
    140174                                        c2 = *(backPtr + 1);
     175                                        if (debug && x == 0 && y == 161) {
     176                                                printf("back c2: %d\r\n", c2);
     177                                                fflush(stdout);
     178                                        }
     179                                }
    141180                        } else
    142181                                c2 = c1;
    143182
     
    145184                                if (*(srcPtr + srcPitch)) {
    146185                                        c3 = *(srcPtr + srcPitch);
    147186                                        transparent = false;
    148                                 } else
     187                                        if (debug && x == 0 && y == 161) {
     188                                                printf("pixel c3: %d\r\n", c3);
     189                                                fflush(stdout);
     190                                        }
     191                                } else {
    149192                                        c3 = *(backPtr + _screenWide);
     193                                        if (debug && x == 0 && y == 161) {
     194                                                printf("back c3: %d\r\n", c3);
     195                                                fflush(stdout);
     196                                        }
     197                                }
    150198                        } else
    151199                                c3 = c1;
    152200
     
    154202                                if (*(srcPtr + srcPitch + 1)) {
    155203                                        c4 = *(srcPtr + srcPitch + 1);
    156204                                        transparent = false;
    157                                 } else
     205                                        if (debug && x == 0 && y == 161) {
     206                                                printf("pixel c4: %d\r\n", c4);
     207                                                fflush(stdout);
     208                                        }
     209                                } else {
    158210                                        c4 = *(backPtr + _screenWide + 1);
     211                                        if (debug && x == 0 && y == 161) {
     212                                                printf("back c4: %d\r\n", c4);
     213                                                fflush(stdout);
     214                                        }
     215                                }
    159216                        } else
    160217                                c4 = c3;
    161218
     219                        if (debug && x == 0 && y == 161) {
     220                                printf("c1: %d c2: %d\r\n", c1, c2);
     221                                fflush(stdout);
     222                                printf("c3: %d c4: %d\r\n", c3, c4);
     223                                fflush(stdout);
     224                                uint32 tempDebug = _palette[c3 * 4 + 0];
     225                                printf("_palette[c3 * 4 + 0] : %lu\r\n", tempDebug);
     226                                fflush(stdout);
     227                        }
     228
    162229                        if (!transparent) {
    163230                                uint32 r1 = _palette[c1 * 4 + 0];
    164231                                uint32 g1 = _palette[c1 * 4 + 1];
  • sprite.cpp

     
    700700
    701701                // We cannot use good scaling for PSX version, as we are missing
    702702                // some required data.
    703                 if (_renderCaps & RDBLTFX_EDGEBLEND && !Sword2Engine::isPsx())
     703                if (_renderCaps & RDBLTFX_EDGEBLEND && !Sword2Engine::isPsx()) {
     704                        printf("sprite backbuf => rd.top: %d rd.left: %d\r\n", rd.top, rd.left);
     705                        fflush(stdout);
    704706                        scaleImageGood(newSprite, s->scaledWidth, s->scaledWidth, s->scaledHeight, sprite, s->w, s->w, s->h, _buffer + _screenWide * rd.top + rd.left);
    705                 else
     707                } else
    706708                        scaleImageFast(newSprite, s->scaledWidth, s->scaledWidth, s->scaledHeight, sprite, s->w, s->w, s->h);
    707709
    708710                if (freeSprite)