diff --git a/CMakeLists.txt b/CMakeLists.txt index 71151830..2993d084 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,10 +45,9 @@ add_subdirectory(deps/ox) include_directories( deps/ox/src ) +add_subdirectory(deps/teagba) -if(BUILDCORE_TARGET STREQUAL "gba") - add_subdirectory(deps/teagba) -else() +if(NOT BUILDCORE_TARGET STREQUAL "gba") include_directories( SYSTEM deps/glfw/deps diff --git a/src/nostalgia/modules/core/src/CMakeLists.txt b/src/nostalgia/modules/core/src/CMakeLists.txt index 1a676eb9..2ee95a1a 100644 --- a/src/nostalgia/modules/core/src/CMakeLists.txt +++ b/src/nostalgia/modules/core/src/CMakeLists.txt @@ -3,9 +3,8 @@ add_library( gfx.cpp ) -if(TURBINE_BUILD_TYPE STREQUAL "GBA") - add_subdirectory(gba) -else() +add_subdirectory(gba) +if(NOT TURBINE_BUILD_TYPE STREQUAL "GBA") add_subdirectory(opengl) endif() diff --git a/src/nostalgia/modules/core/src/gba/CMakeLists.txt b/src/nostalgia/modules/core/src/gba/CMakeLists.txt index 338541b0..32c22d3c 100644 --- a/src/nostalgia/modules/core/src/gba/CMakeLists.txt +++ b/src/nostalgia/modules/core/src/gba/CMakeLists.txt @@ -1,12 +1,20 @@ -enable_language(CXX ASM) -set_source_files_properties(gfx.cpp PROPERTIES COMPILE_FLAGS -marm) -target_sources( - NostalgiaCore PRIVATE +add_library( + NostalgiaCore-GBA OBJECT context.cpp gfx.cpp panic.cpp ) +target_include_directories( + NostalgiaCore-GBA PUBLIC + ../../include +) target_link_libraries( - NostalgiaCore PUBLIC + NostalgiaCore-GBA PUBLIC TeaGBA -) \ No newline at end of file + Keel +) + +if(TURBINE_BUILD_TYPE STREQUAL "GBA") + set_source_files_properties(gfx.cpp PROPERTIES COMPILE_FLAGS -marm) + target_link_libraries(NostalgiaCore PUBLIC NostalgiaCore-GBA) +endif() \ No newline at end of file diff --git a/src/nostalgia/modules/core/src/gba/gfx.cpp b/src/nostalgia/modules/core/src/gba/gfx.cpp index c0496a3b..110e33cb 100644 --- a/src/nostalgia/modules/core/src/gba/gfx.cpp +++ b/src/nostalgia/modules/core/src/gba/gfx.cpp @@ -197,7 +197,7 @@ ox::Error loadSpritePalette(Context *ctx, unsigned cbb, const ox::FileAddress &p 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++) { - const auto c = charMap[static_cast(str[i])]; + const auto c = charMap[static_cast(str[i])]; setTile(ctx, 0, static_cast(col + i), row, static_cast(c)); } } diff --git a/src/turbine/CMakeLists.txt b/src/turbine/CMakeLists.txt index 47cd4f16..de321b7d 100644 --- a/src/turbine/CMakeLists.txt +++ b/src/turbine/CMakeLists.txt @@ -3,9 +3,8 @@ add_library( event.cpp ) -if(TURBINE_BUILD_TYPE STREQUAL "GBA") - add_subdirectory(gba) -else() +add_subdirectory(gba) +if(NOT TURBINE_BUILD_TYPE STREQUAL "GBA") add_subdirectory(glfw) endif() diff --git a/src/turbine/gba/CMakeLists.txt b/src/turbine/gba/CMakeLists.txt index 769ec8fa..0a1db860 100644 --- a/src/turbine/gba/CMakeLists.txt +++ b/src/turbine/gba/CMakeLists.txt @@ -1,16 +1,33 @@ -enable_language(CXX ASM) -set_source_files_properties(turbine.arm.cpp irq.arm.cpp PROPERTIES COMPILE_FLAGS -marm) +if(TURBINE_BUILD_TYPE STREQUAL "GBA") + enable_language(CXX ASM) +endif() + +add_library(Turbine-GBA OBJECT) target_sources( - Turbine PRIVATE + Turbine-GBA PRIVATE clipboard.cpp gfx.cpp irq.arm.cpp - irq.s turbine.arm.cpp turbine.cpp ) +if(TURBINE_BUILD_TYPE STREQUAL "GBA") + set_source_files_properties(turbine.arm.cpp irq.arm.cpp PROPERTIES COMPILE_FLAGS -marm) + target_sources( + Turbine-GBA PRIVATE + irq.s + ) + target_link_libraries(Turbine PUBLIC Turbine-GBA) +else() + target_sources( + Turbine-GBA PRIVATE + irqstub.cpp + ) +endif() + target_link_libraries( - Turbine PUBLIC + Turbine-GBA PUBLIC TeaGBA + Keel ) diff --git a/src/turbine/gba/irqstub.cpp b/src/turbine/gba/irqstub.cpp new file mode 100644 index 00000000..e163b99f --- /dev/null +++ b/src/turbine/gba/irqstub.cpp @@ -0,0 +1,8 @@ +/* + * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. + */ + +// stub for building TeaGBA for PC targets, for purposes of not having to +// switch back and forth between builds when editing GBA files + +extern "C" void turbine_isr() {} diff --git a/src/turbine/gba/turbine.cpp b/src/turbine/gba/turbine.cpp index 8e43a651..3d39ce91 100644 --- a/src/turbine/gba/turbine.cpp +++ b/src/turbine/gba/turbine.cpp @@ -36,6 +36,7 @@ static void initTimer() noexcept { REG_IE = REG_IE | teagba::Int_timer0; } +[[maybe_unused]] static ox::Result findPreloadSection() noexcept { // put the header in the wrong order to prevent mistaking this code for the // media section @@ -55,7 +56,9 @@ static ox::Result findPreloadSection() noexcept { ox::Result> init(ox::UPtr fs, ox::CRStringView appName) noexcept { oxRequireM(ctx, keel::init(std::move(fs), appName)); +#ifdef OX_BARE_METAL oxReturnError(findPreloadSection().moveTo(&ctx->preloadSectionOffset)); +#endif oxReturnError(initGfx(*ctx)); initTimer(); initIrq();