all repos — mgba @ 775f9db546e1123bfb213f21ee687868397abeeb

mGBA Game Boy Advance Emulator

Begin OBJ mosaic
Jeffrey Pfau jeffrey@endrift.com
Sun, 27 Oct 2013 03:12:55 -0700
commit

775f9db546e1123bfb213f21ee687868397abeeb

parent

3b0ee473d3a95b8894919a9bd74c422841dd0b93

1 files changed, 33 insertions(+), 7 deletions(-)

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

@@ -1181,6 +1181,21 @@ SPRITE_XBASE_ ## DEPTH(inX); \

SPRITE_DRAW_PIXEL_ ## DEPTH ## _ ## TYPE(inX); \ } +#define SPRITE_MOSAIC_LOOP(DEPTH, TYPE) \ + SPRITE_YBASE_ ## DEPTH(inY); \ + if (outX % mosaicH) { \ + outX += mosaicH - (outX % mosaicH); \ + inX += (mosaicH - (outX % mosaicH)) * xOffset; \ + } \ + for (; outX < condition; ++outX, inX += xOffset) { \ + if (!(renderer->row[outX] & FLAG_UNWRITTEN)) { \ + continue; \ + } \ + int localX = inX - xOffset * (outX % mosaicH); \ + SPRITE_XBASE_ ## DEPTH(localX); \ + SPRITE_DRAW_PIXEL_ ## DEPTH ## _ ## TYPE(localX); \ + } + #define SPRITE_TRANSFORMED_LOOP(DEPTH, TYPE) \ int outX; \ for (outX = x >= start ? x : start; outX < x + totalWidth && outX < end; ++outX) { \

@@ -1247,13 +1262,6 @@ flags |= FLAG_TARGET_1 * ((renderer->currentWindow.blendEnable && renderer->target1Obj && renderer->blendEffect == BLEND_ALPHA) || sprite->mode == OBJ_MODE_SEMITRANSPARENT);

flags |= FLAG_TARGET_2 *renderer->target2Obj; flags |= FLAG_OBJWIN * (sprite->mode == OBJ_MODE_OBJWIN); int x = sprite->x; - int inY = y - sprite->y; - if (sprite->y + height - 256 >= 0) { - inY += 256; - } - if (sprite->vflip) { - inY = height - inY - 1; - } unsigned charBase = BASE_TILE + sprite->tile * 0x20; int variant = renderer->target1Obj && renderer->currentWindow.blendEnable && sprite->mode != OBJ_MODE_SEMITRANSPARENT && (renderer->blendEffect == BLEND_BRIGHTEN || renderer->blendEffect == BLEND_DARKEN); color_t* palette = renderer->normalPalette;

@@ -1263,6 +1271,20 @@ }

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); + } + int inY = y - sprite->y; + if (sprite->y + height - 256 >= 0) { + inY += 256; + } + if (sprite->vflip) { + inY = height - inY - 1; + } if (end < condition) { condition = end; }

@@ -1275,12 +1297,16 @@ }

if (!sprite->multipalette) { if (flags & FLAG_OBJWIN) { SPRITE_NORMAL_LOOP(16, OBJWIN); + } else if (sprite->mosaic) { + SPRITE_MOSAIC_LOOP(16, NORMAL); } else { SPRITE_NORMAL_LOOP(16, NORMAL); } } else { if (flags & FLAG_OBJWIN) { SPRITE_NORMAL_LOOP(256, OBJWIN); + } else if (sprite->mosaic) { + SPRITE_MOSAIC_LOOP(256, NORMAL); } else { SPRITE_NORMAL_LOOP(256, NORMAL); }