diff --git a/src/nostalgia/modules/core/include/nostalgia/core/gfx.hpp b/src/nostalgia/modules/core/include/nostalgia/core/gfx.hpp index 2ac9ef9a..6ad7ec92 100644 --- a/src/nostalgia/modules/core/include/nostalgia/core/gfx.hpp +++ b/src/nostalgia/modules/core/include/nostalgia/core/gfx.hpp @@ -53,12 +53,16 @@ void setBgCbb(Context *ctx, unsigned bgIdx, unsigned cbb) noexcept; /** * @param section describes which section of the selected TileSheetSpace to use (e.g. MEM_PALLETE_BG[section]) */ -ox::Error loadBgTileSheet(Context *ctx, unsigned cbb, const ox::FileAddress &tilesheetAddr, - const ox::FileAddress &paletteAddr = nullptr) noexcept; +ox::Error loadBgTileSheet( + Context *ctx, + unsigned cbb, + ox::FileAddress const&tilesheetAddr, + ox::FileAddress const&paletteAddr = nullptr) noexcept; -ox::Error loadSpriteTileSheet(Context *ctx, - const ox::FileAddress &tilesheetAddr, - const ox::FileAddress &paletteAddr) noexcept; +ox::Error loadSpriteTileSheet( + Context *ctx, + ox::FileAddress const&tilesheetAddr, + ox::FileAddress const&paletteAddr) noexcept; ox::Error initConsole(Context *ctx) noexcept; @@ -73,7 +77,7 @@ void hideSprite(Context *ctx, unsigned) noexcept; void setSprite(Context *ctx, unsigned idx, int x, int y, unsigned tileIdx, unsigned spriteShape = 0, unsigned spriteSize = 0, unsigned flipX = 0) noexcept; -void setSprite(Context *ctx, const Sprite &s) noexcept; +void setSprite(Context *ctx, Sprite const&s) noexcept; } diff --git a/src/nostalgia/modules/core/src/gba/context.cpp b/src/nostalgia/modules/core/src/gba/context.cpp index 7d51c219..670da04e 100644 --- a/src/nostalgia/modules/core/src/gba/context.cpp +++ b/src/nostalgia/modules/core/src/gba/context.cpp @@ -11,9 +11,9 @@ namespace nostalgia::core { GbaContext::GbaContext(turbine::Context *tctx) noexcept: turbineCtx(tctx) { } -ox::Error initGfx(Context *ctx, const InitParams&) noexcept; +ox::Error initGfx(Context *ctx, InitParams const&) noexcept; -ox::Result> init(turbine::Context *tctx, const InitParams ¶ms) noexcept { +ox::Result> init(turbine::Context *tctx, InitParams const¶ms) noexcept { auto ctx = ox::make_unique(tctx); oxReturnError(initGfx(ctx.get(), params)); return ox::UPtr(ctx.release()); diff --git a/src/nostalgia/modules/core/src/gba/context.hpp b/src/nostalgia/modules/core/src/gba/context.hpp index b3cbf0fc..1347c773 100644 --- a/src/nostalgia/modules/core/src/gba/context.hpp +++ b/src/nostalgia/modules/core/src/gba/context.hpp @@ -15,7 +15,7 @@ struct GbaContext: public core::Context { explicit GbaContext(turbine::Context *tctx) noexcept; [[nodiscard]] - const auto &rom() const noexcept { + auto const&rom() const noexcept { return *turbine::rom(*turbineCtx); } diff --git a/src/nostalgia/modules/core/src/gba/gfx.cpp b/src/nostalgia/modules/core/src/gba/gfx.cpp index 93f131d6..9fadfb25 100644 --- a/src/nostalgia/modules/core/src/gba/gfx.cpp +++ b/src/nostalgia/modules/core/src/gba/gfx.cpp @@ -69,7 +69,7 @@ constexpr ox::Error model(auto *io, ox::CommonPtrWith auto *t) return io->template field("tileMap", handleTileMap); } -ox::Error initGfx(Context*, const InitParams&) noexcept { +ox::Error initGfx(Context*, InitParams const&) noexcept { for (auto bgCtl = ®_BG0CTL; bgCtl <= ®_BG3CTL; bgCtl += 2) { teagba::bgSetSbb(bgCtl, 28); } @@ -108,8 +108,8 @@ void setBgCbb(Context*, unsigned bgIdx, unsigned cbb) noexcept { static ox::Error loadBgTileSheet( const ox::MemFS &rom, unsigned cbb, - const ox::FileAddress &tilesheetAddr, - const ox::FileAddress &paletteAddr) noexcept { + ox::FileAddress const&tilesheetAddr, + ox::FileAddress const&paletteAddr) noexcept { oxRequire(tsStat, rom.stat(tilesheetAddr)); oxRequire(ts, rom.directAccess(tilesheetAddr)); GbaTileMapTarget target; @@ -136,8 +136,8 @@ static ox::Error loadBgTileSheet( ox::Error loadBgTileSheet( Context *ctx, unsigned cbb, - const ox::FileAddress &tilesheetAddr, - const ox::FileAddress &paletteAddr) noexcept { + ox::FileAddress const&tilesheetAddr, + ox::FileAddress const&paletteAddr) noexcept { auto &gctx = static_cast(*ctx); auto &rom = static_cast(gctx.rom()); return loadBgTileSheet(rom, cbb, tilesheetAddr, paletteAddr); @@ -145,8 +145,8 @@ ox::Error loadBgTileSheet( ox::Error loadSpriteTileSheet( Context *ctx, - const ox::FileAddress &tilesheetAddr, - const ox::FileAddress &paletteAddr) noexcept { + ox::FileAddress const&tilesheetAddr, + ox::FileAddress const&paletteAddr) noexcept { auto &gctx = static_cast(*ctx); auto &rom = static_cast(gctx.rom()); oxRequire(tsStat, gctx.rom().stat(tilesheetAddr)); @@ -164,7 +164,7 @@ ox::Error loadSpriteTileSheet( return {}; } -ox::Error loadBgPalette(Context *ctx, unsigned, const ox::FileAddress &paletteAddr) noexcept { +ox::Error loadBgPalette(Context *ctx, unsigned, ox::FileAddress const&paletteAddr) noexcept { auto &gctx = static_cast(*ctx); auto &rom = static_cast(gctx.rom()); GbaPaletteTarget target; @@ -175,7 +175,7 @@ ox::Error loadBgPalette(Context *ctx, unsigned, const ox::FileAddress &paletteAd return {}; } -ox::Error loadSpritePalette(Context *ctx, unsigned cbb, const ox::FileAddress &paletteAddr) noexcept { +ox::Error loadSpritePalette(Context *ctx, unsigned cbb, ox::FileAddress const&paletteAddr) noexcept { auto &gctx = static_cast(*ctx); auto &rom = static_cast(gctx.rom()); GbaPaletteTarget target; diff --git a/src/nostalgia/modules/core/src/gba/gfx.hpp b/src/nostalgia/modules/core/src/gba/gfx.hpp index 19e998eb..fbf4edbd 100644 --- a/src/nostalgia/modules/core/src/gba/gfx.hpp +++ b/src/nostalgia/modules/core/src/gba/gfx.hpp @@ -7,5 +7,5 @@ #include namespace nostalgia::core { -ox::Error initGfx(Context *ctx, const InitParams&) noexcept; +ox::Error initGfx(Context *ctx, InitParams const&) noexcept; } diff --git a/src/nostalgia/modules/core/src/gba/panic.cpp b/src/nostalgia/modules/core/src/gba/panic.cpp index 47c8d2cd..4657d800 100644 --- a/src/nostalgia/modules/core/src/gba/panic.cpp +++ b/src/nostalgia/modules/core/src/gba/panic.cpp @@ -15,7 +15,7 @@ namespace ox { using namespace nostalgia::core; -void panic(const char *file, int line, const char *panicMsg, const ox::Error &err) noexcept { +void panic(const char *file, int line, const char *panicMsg, ox::Error const&err) noexcept { oxIgnoreError(initGfx(nullptr, {})); oxIgnoreError(initConsole(nullptr)); // enable only BG 0 diff --git a/src/nostalgia/modules/core/src/opengl/context.cpp b/src/nostalgia/modules/core/src/opengl/context.cpp index 625cc332..fa097afc 100644 --- a/src/nostalgia/modules/core/src/opengl/context.cpp +++ b/src/nostalgia/modules/core/src/opengl/context.cpp @@ -16,7 +16,7 @@ GlContext::~GlContext() noexcept { shutdownGfx(*this); } -ox::Result> init(turbine::Context *tctx, const InitParams ¶ms) noexcept { +ox::Result> init(turbine::Context *tctx, InitParams const¶ms) noexcept { auto ctx = ox::make_unique(*tctx); oxReturnError(initGfx(ctx.get(), params)); return ox::UPtr(ctx.release()); diff --git a/src/nostalgia/modules/core/src/opengl/gfx.cpp b/src/nostalgia/modules/core/src/opengl/gfx.cpp index e7ca764e..6af4da2e 100644 --- a/src/nostalgia/modules/core/src/opengl/gfx.cpp +++ b/src/nostalgia/modules/core/src/opengl/gfx.cpp @@ -108,7 +108,7 @@ static void setSpriteBufferObject( memcpy(ebo, elms.data(), sizeof(elms)); } -static void setTileBufferObject( +void setTileBufferObject( unsigned vi, float x, float y, @@ -124,10 +124,10 @@ static void setTileBufferObject( y += 1.0f - ymod; const auto textureRowf = static_cast(textureRow); const ox::Array vertices { - x, y, 0, textureRowf + 1, // bottom left + x, y, 0, textureRowf + 1, // bottom left x + xmod, y, 1, textureRowf + 1, // bottom right x + xmod, y + ymod, 1, textureRowf + 0, // top right - x, y + ymod, 0, textureRowf + 0, // top left + x, y + ymod, 0, textureRowf + 0, // top left }; memcpy(vbo, vertices.data(), sizeof(vertices)); const ox::Array elms { @@ -204,8 +204,9 @@ static void initBackgroundBufferset( glVertexAttribPointer(posAttr, 2, GL_FLOAT, GL_FALSE, BgVertexVboRowLength * sizeof(float), nullptr); auto texCoordAttr = static_cast(glGetAttribLocation(shader, "vTexCoord")); glEnableVertexAttribArray(texCoordAttr); - glVertexAttribPointer(texCoordAttr, 2, GL_FLOAT, GL_FALSE, BgVertexVboRowLength * sizeof(float), - reinterpret_cast(2 * sizeof(float))); + glVertexAttribPointer( + texCoordAttr, 2, GL_FLOAT, GL_FALSE, BgVertexVboRowLength * sizeof(bg->vertices[0]), + reinterpret_cast(2 * sizeof(bg->vertices[0]))); } static glutils::GLTexture loadTexture( @@ -283,7 +284,7 @@ static void drawSprites(GlContext *gctx, ox::Size const&renderSz) noexcept { static void loadPalette( GLuint shaderPgrm, - const Palette &pal, + Palette const&pal, bool firstIsTransparent = false) noexcept { static constexpr std::size_t ColorCnt = 256; ox::Array palette{}; @@ -301,11 +302,11 @@ static void loadPalette( glUniform4fv(uniformPalette, ColorCnt, palette.data()); } -static void loadBgPalette(GlContext *gctx, const Palette &pal) noexcept { +static void loadBgPalette(GlContext *gctx, Palette const&pal) noexcept { loadPalette(gctx->bgShader, pal); } -static void loadSpritePalette(GlContext *gctx, const Palette &pal) noexcept { +static void loadSpritePalette(GlContext *gctx, Palette const&pal) noexcept { loadPalette(gctx->spriteShader, pal, true); } @@ -332,7 +333,7 @@ static void loadSpriteTexture( ox::Error initGfx( Context *ctx, - const InitParams &initParams) noexcept { + InitParams const&initParams) noexcept { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); const auto bgVshad = ox::sfmt(renderer::bgvshadTmpl, glutils::GlslVersion); @@ -364,8 +365,8 @@ struct TileSheetData { int height = 0; }; -ox::Result loadTileSheet( - Context *ctx, const CompactTileSheet &tilesheet) noexcept { +static ox::Result loadTileSheet( + Context *ctx, CompactTileSheet const&tilesheet) noexcept { auto &gctx = static_cast(*ctx); const unsigned bytesPerTile = tilesheet.bpp == 8 ? PixelsPerTile : PixelsPerTile / 2; const auto tiles = tilesheet.pixels.size() / bytesPerTile; @@ -391,8 +392,8 @@ ox::Result loadTileSheet( ox::Error loadBgTileSheet( Context *ctx, unsigned cbb, - const ox::FileAddress &tilesheetAddr, - const ox::FileAddress &paletteAddr) noexcept { + ox::FileAddress const&tilesheetAddr, + ox::FileAddress const&paletteAddr) noexcept { auto &gctx = static_cast(*ctx); auto &kctx = gctx.turbineCtx.keelCtx; oxRequire(tilesheet, readObj(&kctx, tilesheetAddr)); @@ -405,8 +406,8 @@ ox::Error loadBgTileSheet( ox::Error loadSpriteTileSheet( Context *ctx, - const ox::FileAddress &tilesheetAddr, - const ox::FileAddress &paletteAddr) noexcept { + ox::FileAddress const&tilesheetAddr, + ox::FileAddress const&paletteAddr) noexcept { auto &gctx = static_cast(*ctx); auto &kctx = gctx.turbineCtx.keelCtx; oxRequire(tilesheet, readObj(&kctx, tilesheetAddr)); @@ -428,7 +429,12 @@ ox::Error initConsole(Context *ctx) noexcept { void puts(Context *ctx, int column, int row, ox::CRStringView str) noexcept { const auto col = static_cast(column); for (auto i = 0u; i < str.bytes(); ++i) { - setTile(ctx, 0, static_cast(col + i), row, static_cast(charMap[static_cast(str[i])])); + setTile( + ctx, + 0, + static_cast(col + i), + row, + static_cast(charMap[static_cast(str[i])])); } } diff --git a/src/nostalgia/modules/core/src/opengl/gfx.hpp b/src/nostalgia/modules/core/src/opengl/gfx.hpp index 2f331482..1f71adb1 100644 --- a/src/nostalgia/modules/core/src/opengl/gfx.hpp +++ b/src/nostalgia/modules/core/src/opengl/gfx.hpp @@ -63,6 +63,6 @@ class Drawer: public turbine::gl::Drawer { } namespace nostalgia::core { -ox::Error initGfx(Context *ctx, const InitParams&) noexcept; +ox::Error initGfx(Context *ctx, InitParams const&) noexcept; void shutdownGfx(Context &ctx) noexcept; } \ No newline at end of file