all repos — mgba @ 14b6393b51a3e8ea38e83d2bef8c30db7d83cae2

mGBA Game Boy Advance Emulator

Replace BGCNT with bitfield
Jeffrey Pfau jeffrey@endrift.com
Wed, 01 Oct 2014 02:50:10 -0700
commit

14b6393b51a3e8ea38e83d2bef8c30db7d83cae2

parent

0a5a099059f866d51a08a90c1d27a5a737c7f401

2 files changed, 15 insertions(+), 21 deletions(-)

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

@@ -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);
M src/gba/renderers/video-software.csrc/gba/renderers/video-software.c

@@ -532,14 +532,13 @@ }

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) {