From e2f1466e645fbd7bd446f03d10f60cee2b5ae57f Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sat, 18 Jul 2020 17:00:49 -0500 Subject: [PATCH] [nostalgia/core/gba] Cleanup --- src/nostalgia/core/gba/gfx.cpp | 24 +++--------------------- src/nostalgia/core/gba/gfx.hpp | 18 ++++++++++++++++++ src/nostalgia/core/gba/panic.cpp | 3 ++- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/src/nostalgia/core/gba/gfx.cpp b/src/nostalgia/core/gba/gfx.cpp index e4e00b41..91e120b7 100644 --- a/src/nostalgia/core/gba/gfx.cpp +++ b/src/nostalgia/core/gba/gfx.cpp @@ -27,24 +27,6 @@ constexpr uint16_t DispStat_irq_vblank = 1 << 3; constexpr uint16_t DispStat_irq_hblank = 1 << 4; constexpr uint16_t DispStat_irq_vcount = 1 << 5; -enum DispCtl { - DispCtl_Mode0 = 0, - DispCtl_Mode1 = 1, - DispCtl_Mode2 = 2, - DispCtl_Mode3 = 3, - DispCtl_Mode4 = 4, - DispCtl_Mode5 = 5, - - DispCtl_SpriteMap1D = 1 << 6, - - DispCtl_Bg0 = 1 << 8, - DispCtl_Bg1 = 1 << 9, - DispCtl_Bg2 = 1 << 10, - DispCtl_Bg3 = 1 << 11, - - DispCtl_Obj = 1 << 12, -}; - struct GbaPaletteTarget { static constexpr auto TypeName = NostalgiaPalette::TypeName; static constexpr auto Fields = NostalgiaPalette::Fields; @@ -153,9 +135,9 @@ ox::Error initConsole(Context *ctx) { } ox::Error loadBgTileSheet(Context *ctx, - int section, - ox::FileAddress tilesheetAddr, - ox::FileAddress paletteAddr) { + int section, + ox::FileAddress tilesheetAddr, + ox::FileAddress paletteAddr) { auto [tsStat, tsStatErr] = ctx->rom->stat(tilesheetAddr); oxReturnError(tsStatErr); auto [ts, tserr] = ctx->rom->read(tilesheetAddr); diff --git a/src/nostalgia/core/gba/gfx.hpp b/src/nostalgia/core/gba/gfx.hpp index e73c5afc..4a591fa5 100644 --- a/src/nostalgia/core/gba/gfx.hpp +++ b/src/nostalgia/core/gba/gfx.hpp @@ -15,6 +15,24 @@ namespace nostalgia::core { +enum DispCtl { + DispCtl_Mode0 = 0, + DispCtl_Mode1 = 1, + DispCtl_Mode2 = 2, + DispCtl_Mode3 = 3, + DispCtl_Mode4 = 4, + DispCtl_Mode5 = 5, + + DispCtl_SpriteMap1D = 1 << 6, + + DispCtl_Bg0 = 1 << 8, + DispCtl_Bg1 = 1 << 9, + DispCtl_Bg2 = 1 << 10, + DispCtl_Bg3 = 1 << 11, + + DispCtl_Obj = 1 << 12, +}; + struct OX_ALIGN8 GbaSpriteAttrUpdate { uint16_t attr0 = 0; uint16_t attr1 = 0; diff --git a/src/nostalgia/core/gba/panic.cpp b/src/nostalgia/core/gba/panic.cpp index 1cdbe07c..c12119de 100644 --- a/src/nostalgia/core/gba/panic.cpp +++ b/src/nostalgia/core/gba/panic.cpp @@ -13,6 +13,7 @@ #include "addresses.hpp" #include "bios.hpp" +#include "gfx.hpp" namespace ox { @@ -22,7 +23,7 @@ void panic(const char*, int, const char *msg, ox::Error err) { oxIgnoreError(initGfx(nullptr)); oxIgnoreError(initConsole(nullptr)); // enable only BG 0 - REG_DISPCTL = 0x0100; + REG_DISPCTL = DispCtl_Bg0; clearTileLayer(nullptr, 0); ox::BString<23> serr = "Error code: "; serr += err;