diff --git a/src/nostalgia/core/CMakeLists.txt b/src/nostalgia/core/CMakeLists.txt index c904c3a4..6e1bb47e 100644 --- a/src/nostalgia/core/CMakeLists.txt +++ b/src/nostalgia/core/CMakeLists.txt @@ -1,35 +1,5 @@ -if(NOSTALGIA_BUILD_TYPE STREQUAL "GBA") - enable_language(C ASM) - set( - CPP - gba/core.cpp - gba/gfx.cpp - gba/media.cpp - gba/mem.cpp - gba/panic.cpp - ) -elseif(NOSTALGIA_BUILD_STUDIO) - set(CMAKE_INCLUDE_CURRENT_DIR ON) - set(CMAKE_AUTOMOC ON) - - set( - CPP - #qt/gfx.cpp - userland/media.cpp - userland/mem.cpp - ) -else() - set( - CPP - #qt/gfx.cpp # does not currently use any Qt stuff, but will need to replace with SDL version - userland/media.cpp - userland/mem.cpp - ) -endif() - add_library( NostalgiaCore - ${CPP} core.cpp ) @@ -39,8 +9,11 @@ target_link_libraries( OxFS ) -if(NOSTALGIA_BUILD_TYPE STREQUAL "Native") +if(NOSTALGIA_BUILD_TYPE STREQUAL "GBA") + add_subdirectory(gba) +elseif(NOSTALGIA_BUILD_TYPE STREQUAL "Native") add_subdirectory(sdl) + add_subdirectory(userland) endif() if(NOSTALGIA_BUILD_STUDIO) add_subdirectory(studio) @@ -49,10 +22,12 @@ endif() install( FILES consts.hpp + context.hpp core.hpp gfx.hpp media.hpp - gba/gba.hpp + mem.hpp + types.hpp DESTINATION include/nostalgia/core ) diff --git a/src/nostalgia/core/gba/CMakeLists.txt b/src/nostalgia/core/gba/CMakeLists.txt new file mode 100644 index 00000000..7072a6cb --- /dev/null +++ b/src/nostalgia/core/gba/CMakeLists.txt @@ -0,0 +1,22 @@ +add_library( + NostalgiaCore-GBA + core.cpp + gfx.cpp + media.cpp + mem.cpp + panic.cpp +) + +target_link_libraries( + NostalgiaCore-GBA PUBLIC + GbaStartup + OxFS + OxStd +) + +install( + TARGETS + NostalgiaCore-GBA + DESTINATION + include/nostalgia/core +) diff --git a/src/nostalgia/core/gba/core.cpp b/src/nostalgia/core/gba/core.cpp new file mode 100644 index 00000000..7d565127 --- /dev/null +++ b/src/nostalgia/core/gba/core.cpp @@ -0,0 +1,19 @@ +/* + * Copyright 2016 - 2019 gtalent2@gmail.com + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include + +namespace nostalgia::core { + +ox::Error run() { + while (1) { + } + return OxError(0); +} + +} diff --git a/src/nostalgia/core/gba/gfx.cpp b/src/nostalgia/core/gba/gfx.cpp index f0022b6f..480e2c53 100644 --- a/src/nostalgia/core/gba/gfx.cpp +++ b/src/nostalgia/core/gba/gfx.cpp @@ -215,7 +215,7 @@ ox::Error loadTileSheet(Context*, ox::FileAddress) { auto inode = tilesheetPath.getInode().value; ox::Error err(0); - const auto PaletteStart = sizeof(GbaImageDataHeader); + constexpr auto PaletteStart = sizeof(GbaImageDataHeader); GbaImageDataHeader imgData; ox::FileStore32 fs(loadRom(), 32 * 1024 * 1024); diff --git a/src/nostalgia/core/sdl/CMakeLists.txt b/src/nostalgia/core/sdl/CMakeLists.txt index 175c635e..cd42b454 100644 --- a/src/nostalgia/core/sdl/CMakeLists.txt +++ b/src/nostalgia/core/sdl/CMakeLists.txt @@ -9,11 +9,12 @@ target_link_libraries( SDL2::Main OxFS OxStd + NostalgiaCore-Userspace ) install( TARGETS NostalgiaCore-SDL DESTINATION - ${NOSTALGIA_DIST_PLUGIN} + include/nostalgia/core ) diff --git a/src/nostalgia/core/sdl/gfx.cpp b/src/nostalgia/core/sdl/gfx.cpp index b2dcdb72..8d2ebc9c 100644 --- a/src/nostalgia/core/sdl/gfx.cpp +++ b/src/nostalgia/core/sdl/gfx.cpp @@ -123,6 +123,7 @@ ox::Error loadTileSheet(Context *ctx, } void drawBackground(SDL_Texture *tex) { + constexpr auto DstSize = 32; //oxTrace("nostalgia::core::drawBackground") << "Drawing background"; SDL_Rect src = {}, dst = {}; src.x = 0; @@ -130,16 +131,16 @@ void drawBackground(SDL_Texture *tex) { src.h = 8; dst.x = 0; dst.y = 0; - dst.w = 64; - dst.h = 64; + dst.w = DstSize; + dst.h = DstSize; if (tex) { for (auto &m : bgTileMaps) { for (auto t : m) { src.y = t * 8; SDL_RenderCopy(renderer, tex, &src, &dst); - dst.y += 64; + dst.y += DstSize; } - dst.x += 64; + dst.x += DstSize; dst.y = 0; } } diff --git a/src/nostalgia/core/userland/CMakeLists.txt b/src/nostalgia/core/userland/CMakeLists.txt new file mode 100644 index 00000000..9a56db7d --- /dev/null +++ b/src/nostalgia/core/userland/CMakeLists.txt @@ -0,0 +1,18 @@ +add_library( + NostalgiaCore-Userspace + media.cpp + mem.cpp +) + +target_link_libraries( + NostalgiaCore-Userspace PUBLIC + OxFS + OxStd +) + +install( + TARGETS + NostalgiaCore-Userspace + DESTINATION + include/nostalgia/core +) diff --git a/src/nostalgia/player/CMakeLists.txt b/src/nostalgia/player/CMakeLists.txt index f6f1ab3f..f381bfa3 100644 --- a/src/nostalgia/player/CMakeLists.txt +++ b/src/nostalgia/player/CMakeLists.txt @@ -1,17 +1,12 @@ +add_executable( + nostalgia + main.cpp +) + if(NOSTALGIA_BUILD_TYPE STREQUAL "GBA") - enable_language(C ASM) - add_executable( - nostalgia - main.cpp - startup.s - ) - set(NOSTALGIA_PLAYER_DEPS "") + set(NOSTALGIA_PLAYER_DEPS "NostalgiaCore-GBA") else() - add_executable( - nostalgia - main.cpp - ) set(NOSTALGIA_PLAYER_DEPS "NostalgiaCore-SDL") endif()