Migrate mosaic to bitfields

This commit is contained in:
Jeffrey Pfau 2014-10-06 00:49:06 -07:00
parent 7d12de0cb9
commit 32bc6750c1
2 changed files with 14 additions and 16 deletions

View File

@ -96,7 +96,7 @@ static void GBAVideoSoftwareRendererInit(struct GBAVideoRenderer* renderer) {
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 @@ static uint16_t GBAVideoSoftwareRendererWriteVideoRegister(struct GBAVideoRender
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 @@ static void _drawScanline(struct GBAVideoSoftwareRenderer* renderer, int y) {
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 @@ static inline void _compositeNoBlendNoObjwin(struct GBAVideoSoftwareRenderer* re
#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 inline void _compositeNoBlendNoObjwin(struct GBAVideoSoftwareRenderer* re
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 @@ static int _preprocessSprite(struct GBAVideoSoftwareRenderer* renderer, struct G
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);
}

View File

@ -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 @@ struct GBAVideoSoftwareRenderer {
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;