Replace BGCNT with bitfield

This commit is contained in:
Jeffrey Pfau 2014-10-01 02:50:10 -07:00
parent 0a5a099059
commit 14b6393b51
2 changed files with 15 additions and 21 deletions

View File

@ -141,19 +141,14 @@ DECL_BIT(GBARegisterDISPSTAT, HblankIRQ, 4);
DECL_BIT(GBARegisterDISPSTAT, VcounterIRQ, 5);
DECL_BITS(GBARegisterDISPSTAT, VcountSetting, 8, 8);
union GBARegisterBGCNT {
struct {
unsigned priority : 2;
unsigned charBase : 2;
unsigned : 2;
unsigned mosaic : 1;
unsigned multipalette : 1;
unsigned screenBase : 5;
unsigned overflow : 1;
unsigned size : 2;
};
uint16_t packed;
};
DECL_BITFIELD(GBARegisterBGCNT, uint16_t);
DECL_BITS(GBARegisterBGCNT, Priority, 0, 2);
DECL_BITS(GBARegisterBGCNT, CharBase, 2, 2);
DECL_BIT(GBARegisterBGCNT, Mosaic, 6);
DECL_BIT(GBARegisterBGCNT, 256Color, 7);
DECL_BITS(GBARegisterBGCNT, ScreenBase, 8, 5);
DECL_BIT(GBARegisterBGCNT, Overflow, 13);
DECL_BITS(GBARegisterBGCNT, Size, 14, 2);
struct GBAVideoRenderer {
void (*init)(struct GBAVideoRenderer* renderer);

View File

@ -532,14 +532,13 @@ static void GBAVideoSoftwareRendererUpdateDISPCNT(struct GBAVideoSoftwareRendere
static void GBAVideoSoftwareRendererWriteBGCNT(struct GBAVideoSoftwareRenderer* renderer, struct GBAVideoSoftwareBackground* bg, uint16_t value) {
UNUSED(renderer);
union GBARegisterBGCNT reg = { .packed = value };
bg->priority = reg.priority;
bg->charBase = reg.charBase << 14;
bg->mosaic = reg.mosaic;
bg->multipalette = reg.multipalette;
bg->screenBase = reg.screenBase << 11;
bg->overflow = reg.overflow;
bg->size = reg.size;
bg->priority = GBARegisterBGCNTGetPriority(value);
bg->charBase = GBARegisterBGCNTGetCharBase(value) << 14;
bg->mosaic = GBARegisterBGCNTGetMosaic(value);
bg->multipalette = GBARegisterBGCNTGet256Color(value);
bg->screenBase = GBARegisterBGCNTGetScreenBase(value) << 11;
bg->overflow = GBARegisterBGCNTGetOverflow(value);
bg->size = GBARegisterBGCNTGetSize(value);
}
static void GBAVideoSoftwareRendererWriteBGPA(struct GBAVideoSoftwareBackground* bg, uint16_t value) {