all repos — mgba @ 9dbd925d90f33f64b6370b135be02c01d4d4eaae

mGBA Game Boy Advance Emulator

Allow for negative-y sprites
Jeffrey Pfau jeffrey@endrift.com
Thu, 25 Apr 2013 00:11:27 -0700
commit

9dbd925d90f33f64b6370b135be02c01d4d4eaae

parent

4446e0dbded410e32bf8d5365c20722c2a2c0aee

2 files changed, 7 insertions(+), 6 deletions(-)

jump to
M src/gba/gba-video.hsrc/gba/gba-video.h

@@ -48,7 +48,7 @@ };

union GBAOAM { struct GBAObj { - int y : 8; + unsigned y : 8; unsigned transformed : 1; unsigned disable : 1; enum ObjMode mode : 2;

@@ -70,7 +70,7 @@ int : 16;

} obj[128]; struct GBATransformedObj { - int y : 8; + unsigned y : 8; unsigned transformed : 1; unsigned doublesize : 1; enum ObjMode mode : 2;
M src/gba/renderers/video-software.csrc/gba/renderers/video-software.c

@@ -208,9 +208,7 @@ struct GBAObj* sprite = &renderer->oam->obj[i];

if (sprite->transformed) { // TODO } else if (!sprite->disable) { - if (sprite->y <= y) { - _drawSprite(softwareRenderer, sprite, y); - } + _drawSprite(softwareRenderer, sprite, y); } } }

@@ -392,7 +390,7 @@

static void _drawSprite(struct GBAVideoSoftwareRenderer* renderer, struct GBAObj* sprite, int y) { int width = _objSizes[sprite->shape * 8 + sprite->size * 2]; int height = _objSizes[sprite->shape * 8 + sprite->size * 2 + 1]; - if (y >= sprite->y + height) { + if ((y < sprite->y && (sprite->y + height - 256 < 0 || y >= sprite->y + height - 256)) || y >= sprite->y + height) { return; } (void)(renderer);

@@ -404,6 +402,9 @@ .target2 = renderer->target2Obj

}; int inX = sprite->x; int inY = y - sprite->y; + if (sprite->y + height - 256 >= 0) { + inY += 256; + } unsigned charBase = BASE_TILE + sprite->tile * 0x20; unsigned yBase = (inY & ~0x7) * 0x80 + (inY & 0x7) * 4; for (int outX = inX >= 0 ? inX : 0; outX < inX + width && outX < VIDEO_HORIZONTAL_PIXELS; ++outX) {