Migrate mosaic to bitfields
Jeffrey Pfau jeffrey@endrift.com
Mon, 06 Oct 2014 00:49:06 -0700
2 files changed,
14 insertions(+),
16 deletions(-)
M
src/gba/renderers/video-software.c
→
src/gba/renderers/video-software.c
@@ -96,7 +96,7 @@ softwareRenderer->objwin = (struct WindowControl) { .priority = 2 };
softwareRenderer->winout = (struct WindowControl) { .priority = 3 }; softwareRenderer->oamMax = 0; - softwareRenderer->mosaic.packed = 0; + softwareRenderer->mosaic = 0; for (i = 0; i < 4; ++i) { struct GBAVideoSoftwareBackground* bg = &softwareRenderer->bg[i];@@ -301,7 +301,7 @@ softwareRenderer->winout.packed = value;
softwareRenderer->objwin.packed = value >> 8; break; case REG_MOSAIC: - softwareRenderer->mosaic.packed = value; + softwareRenderer->mosaic = value; break; case REG_GREENSWP: GBALog(0, GBA_LOG_STUB, "Stub video register write: 0x%03X", address);@@ -618,7 +618,7 @@ if (GBARegisterDISPCNTIsObjEnable(renderer->dispcnt)) {
if (renderer->oamDirty) { _cleanOAM(renderer); } - int mosaicV = renderer->mosaic.objV + 1; + int mosaicV = GBAMosaicControlGetObjV(renderer->mosaic) + 1; int mosaicY = y - (y % mosaicV); for (w = 0; w < renderer->nWindows; ++w) { renderer->start = renderer->end;@@ -1127,8 +1127,8 @@ }
#define DRAW_BACKGROUND_MODE_0(BPP, BLEND, OBJWIN) \ uint32_t* pixel = &renderer->row[outX]; \ - if (background->mosaic && renderer->mosaic.bgH) { \ - int mosaicH = renderer->mosaic.bgH + 1; \ + if (background->mosaic && GBAMosaicControlGetBgH(renderer->mosaic)) { \ + int mosaicH = GBAMosaicControlGetBgH(renderer->mosaic) + 1; \ int x; \ int mosaicWait = outX % mosaicH; \ int carryData = 0; \@@ -1171,7 +1171,7 @@
static void _drawBackgroundMode0(struct GBAVideoSoftwareRenderer* renderer, struct GBAVideoSoftwareBackground* background, int y) { int inX = renderer->start + background->x; if (background->mosaic) { - int mosaicV = renderer->mosaic.bgV + 1; + int mosaicV = GBAMosaicControlGetBgV(renderer->mosaic) + 1; y -= y % mosaicV; } int inY = y + background->y;@@ -1551,7 +1551,7 @@ int outX = x >= start ? x : start;
int condition = x + width; int mosaicH = 1; if (GBAObjAttributesAIsMosaic(sprite->a)) { - mosaicH = renderer->mosaic.objH + 1; + mosaicH = GBAMosaicControlGetObjH(renderer->mosaic) + 1; if (condition % mosaicH) { condition += mosaicH - (condition % mosaicH); }
M
src/gba/renderers/video-software.h
→
src/gba/renderers/video-software.h
@@ -86,6 +86,12 @@ DECL_BIT(GBAWindowControl, Bg3Enable, 3);
DECL_BIT(GBAWindowControl, ObjEnable, 4); DECL_BIT(GBAWindowControl, BlendEnable, 5); +DECL_BITFIELD(GBAMosaicControl, uint16_t); +DECL_BITS(GBAMosaicControl, BgH, 0, 4); +DECL_BITS(GBAMosaicControl, BgV, 4, 4); +DECL_BITS(GBAMosaicControl, ObjH, 8, 4); +DECL_BITS(GBAMosaicControl, ObjV, 12, 4); + struct WindowControl { GBAWindowControl packed; int8_t priority;@@ -123,15 +129,7 @@ uint16_t blda;
uint16_t bldb; uint16_t bldy; - union { - struct { - unsigned bgH : 4; - unsigned bgV : 4; - unsigned objH : 4; - unsigned objV : 4; - }; - uint16_t packed; - } mosaic; + GBAMosaicControl mosaic; struct WindowN { struct WindowRegion h;