all repos — mgba @ 8902635e3ab8a239541612b552e1ecd26c811350

mGBA Game Boy Advance Emulator

Fix bugs in OBJ mosaic
Jeffrey Pfau jeffrey@endrift.com
Sun, 27 Oct 2013 21:58:37 -0700
commit

8902635e3ab8a239541612b552e1ecd26c811350

parent

09888a885291817402034f25b65f0d8a95f4d7f4

1 files changed, 8 insertions(+), 4 deletions(-)

jump to
M src/gba/renderers/video-software.csrc/gba/renderers/video-software.c

@@ -1184,8 +1184,8 @@

#define SPRITE_MOSAIC_LOOP(DEPTH, TYPE) \ SPRITE_YBASE_ ## DEPTH(inY); \ if (outX % mosaicH) { \ - outX += mosaicH - (outX % mosaicH); \ inX += (mosaicH - (outX % mosaicH)) * xOffset; \ + outX += mosaicH - (outX % mosaicH); \ } \ for (; outX < condition; ++outX, inX += xOffset) { \ if (!(renderer->row[outX] & FLAG_UNWRITTEN)) { \

@@ -1251,6 +1251,10 @@ }

static int _preprocessSprite(struct GBAVideoSoftwareRenderer* renderer, struct GBAObj* sprite, int y) { int height = _objSizes[sprite->shape * 8 + sprite->size * 2 + 1]; + if (sprite->mosaic) { + int mosaicV = renderer->mosaic.objV + 1; + y -= y % mosaicV; + } if ((y < sprite->y && (sprite->y + height - 256 < 0 || y >= sprite->y + height - 256)) || y >= sprite->y + height) { return 0; }

@@ -1273,10 +1277,10 @@ int outX = x >= start ? x : start;

int condition = x + width; int mosaicH = 1; if (sprite->mosaic) { - int mosaicV = renderer->mosaic.objV + 1; mosaicH = renderer->mosaic.objH + 1; - y -= y % mosaicV; - condition += mosaicH - (condition % mosaicH); + if (condition % mosaicH) { + condition += mosaicH - (condition % mosaicH); + } } int inY = y - sprite->y; if (sprite->y + height - 256 >= 0) {