From 064d0e992bf6e74e8b4dd206f4f6d52de707ce70 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Wed, 21 Oct 2020 21:32:08 -0700 Subject: [PATCH] GB: Add enum for the layer names --- include/mgba/gb/interface.h | 6 ++++++ src/gb/core.c | 18 +++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/include/mgba/gb/interface.h b/include/mgba/gb/interface.h index 390e9e8cb..e963bd563 100644 --- a/include/mgba/gb/interface.h +++ b/include/mgba/gb/interface.h @@ -42,6 +42,12 @@ enum GBMemoryBankControllerType { GB_UNL_HITEK = 0x221, }; +enum GBVideoLayer { + GB_LAYER_BACKGROUND = 0, + GB_LAYER_WINDOW, + GB_LAYER_OBJ +}; + struct GBSIODriver { struct GBSIO* p; diff --git a/src/gb/core.c b/src/gb/core.c index 15f5248d5..cddd3104f 100644 --- a/src/gb/core.c +++ b/src/gb/core.c @@ -26,9 +26,9 @@ #include static const struct mCoreChannelInfo _GBVideoLayers[] = { - { 0, "bg", "Background", NULL }, - { 1, "bgwin", "Window", NULL }, - { 2, "obj", "Objects", NULL }, + { GB_LAYER_BACKGROUND, "bg", "Background", NULL }, + { GB_LAYER_WINDOW, "bgwin", "Window", NULL }, + { GB_LAYER_OBJ, "obj", "Objects", NULL }, }; static const struct mCoreChannelInfo _GBAudioChannels[] = { @@ -916,13 +916,13 @@ static size_t _GBCoreListAudioChannels(const struct mCore* core, const struct mC static void _GBCoreEnableVideoLayer(struct mCore* core, size_t id, bool enable) { struct GB* gb = core->board; switch (id) { - case 0: + case GB_LAYER_BACKGROUND: gb->video.renderer->disableBG = !enable; break; - case 1: + case GB_LAYER_WINDOW: gb->video.renderer->disableWIN = !enable; break; - case 2: + case GB_LAYER_OBJ: gb->video.renderer->disableOBJ = !enable; break; default: @@ -947,15 +947,15 @@ static void _GBCoreEnableAudioChannel(struct mCore* core, size_t id, bool enable static void _GBCoreAdjustVideoLayer(struct mCore* core, size_t id, int32_t x, int32_t y) { struct GBCore* gbcore = (struct GBCore*) core; switch (id) { - case 0: + case GB_LAYER_BACKGROUND: gbcore->renderer.offsetScx = x; gbcore->renderer.offsetScy = y; break; - case 1: + case GB_LAYER_WINDOW: gbcore->renderer.offsetWx = x; gbcore->renderer.offsetWy = y; break; - case 2: + case GB_LAYER_OBJ: gbcore->renderer.objOffsetX = x; gbcore->renderer.objOffsetY = y; break;