diff --git a/src/nostalgia/core/CMakeLists.txt b/src/nostalgia/core/CMakeLists.txt index 1131fc73..bf5ec097 100644 --- a/src/nostalgia/core/CMakeLists.txt +++ b/src/nostalgia/core/CMakeLists.txt @@ -46,13 +46,23 @@ else() endif() add_library( - NostalgiaCore + NostalgiaCore gfx.cpp media.cpp typeconv.cpp ${NOSTALGIA_CORE_IMPL_SRC} ) +add_library( + NostalgiaCore-Headless + gfx.cpp + media.cpp + typeconv.cpp + headless/core.cpp + headless/gfx.cpp + headless/media.cpp +) + if(NOT MSVC) target_compile_options(NostalgiaCore PUBLIC -Wsign-conversion) endif() @@ -64,6 +74,12 @@ target_link_libraries( ${NOSTALGIA_CORE_IMPL_LIBS} ) +target_link_libraries( + NostalgiaCore-Headless PUBLIC + OxClaw + OxFS +) + if(NOSTALGIA_BUILD_STUDIO) add_subdirectory(studio) endif() @@ -88,6 +104,7 @@ install( install( TARGETS NostalgiaCore + NostalgiaCore-Headless DESTINATION LIBRARY DESTINATION lib/nostalgia ARCHIVE DESTINATION lib/nostalgia diff --git a/src/nostalgia/core/headless/core.cpp b/src/nostalgia/core/headless/core.cpp new file mode 100644 index 00000000..63954fb0 --- /dev/null +++ b/src/nostalgia/core/headless/core.cpp @@ -0,0 +1,25 @@ +/* + * Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved. + */ + +#include +#include + +namespace nostalgia::core { + +ox::Result> init(ox::UniquePtr, const char*) noexcept { + return OxError(1); +} + +void setEventHandler(Context*, event_handler) noexcept { +} + +uint64_t ticksMs(Context*) noexcept { + return 0; +} + +bool buttonDown(Context*, Key) noexcept { + return false; +} + +} diff --git a/src/nostalgia/core/headless/gfx.cpp b/src/nostalgia/core/headless/gfx.cpp new file mode 100644 index 00000000..66ec931b --- /dev/null +++ b/src/nostalgia/core/headless/gfx.cpp @@ -0,0 +1,102 @@ +/* + * Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved. + */ + +#include +#include + +namespace nostalgia::core { + +ox::Error initGfx(Context*) noexcept { + return OxError(0); +} + +ox::Error shutdownGfx(Context*) noexcept { + return OxError(0); +} + +void setWindowTitle(Context*, const char*) noexcept { +} + +void focusWindow(Context*) noexcept { +} + +int getScreenWidth(Context*) noexcept { + return 0; +} + +int getScreenHeight(Context*) noexcept { + return 0; +} + +geo::Size getScreenSize(Context*) noexcept { + return {0, 0}; +} + +uint8_t bgStatus(Context*) noexcept { + return 0; +} + +void setBgStatus(Context*, uint32_t) noexcept { +} + +bool bgStatus(Context*, unsigned) noexcept { + return false; +} + +void setBgStatus(Context*, unsigned, bool) noexcept { +} + +// Do NOT rely on Context in the GBA version of this function. +ox::Error initConsole(Context*) noexcept { + return OxError(0); +} + +ox::Error loadBgTileSheet(Context*, + int, + const ox::FileAddress&, + const ox::FileAddress&) noexcept { + return OxError(0); +} + +ox::Error loadSpriteTileSheet(Context*, + int, + const ox::FileAddress&, + const ox::FileAddress&) noexcept { + return OxError(0); +} + +ox::Error loadBgPalette(Context*, int, const ox::FileAddress&) noexcept { + return OxError(0); +} + +ox::Error loadSpritePalette(Context*, int, const ox::FileAddress&) noexcept { + return OxError(0); +} + +// Do NOT use Context in the GBA version of this function. +void puts(Context*, int, int, const char*) noexcept { +} + +void setTile(Context*, int, int, int, uint8_t) noexcept { +} + +// Do NOT use Context in the GBA version of this function. +void clearTileLayer(Context*, int) noexcept { +} + +[[maybe_unused]] +void hideSprite(Context*, unsigned) noexcept { +} + +void setSprite(Context*, + unsigned, + unsigned, + unsigned, + unsigned, + unsigned, + unsigned, + unsigned) noexcept { +} + +} diff --git a/src/nostalgia/core/headless/media.cpp b/src/nostalgia/core/headless/media.cpp new file mode 100644 index 00000000..9edf68c1 --- /dev/null +++ b/src/nostalgia/core/headless/media.cpp @@ -0,0 +1,18 @@ +/* + * Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved. + */ + +#include + +#include "../media.hpp" + +namespace nostalgia::core { + +ox::Result loadRom(const char*) noexcept { + return OxError(1); +} + +void unloadRom(char*) noexcept { +} + +} diff --git a/src/nostalgia/tools/pack/CMakeLists.txt b/src/nostalgia/tools/pack/CMakeLists.txt index a7c1fa2e..82211382 100644 --- a/src/nostalgia/tools/pack/CMakeLists.txt +++ b/src/nostalgia/tools/pack/CMakeLists.txt @@ -8,7 +8,7 @@ target_link_libraries( NostalgiaPack PUBLIC OxClaw OxFS - NostalgiaCore + NostalgiaCore-Headless NostalgiaGeo )