[nostalgia/core] Cleanup
This commit is contained in:
parent
2c7e134606
commit
f63fe6c995
@ -1,5 +1,5 @@
|
|||||||
add_library(
|
add_library(
|
||||||
NostalgiaCore-Common OBJECT
|
NostalgiaCore
|
||||||
gfx.cpp
|
gfx.cpp
|
||||||
module.cpp
|
module.cpp
|
||||||
tilesheet.cpp
|
tilesheet.cpp
|
||||||
@ -7,56 +7,20 @@ add_library(
|
|||||||
typestore.cpp
|
typestore.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
add_library(NostalgiaCore)
|
if(NOSTALGIA_BUILD_TYPE STREQUAL "GBA")
|
||||||
|
add_subdirectory(gba)
|
||||||
if(NOT NOSTALGIA_BUILD_TYPE STREQUAL "GBA")
|
|
||||||
target_sources(
|
|
||||||
NostalgiaCore PRIVATE
|
|
||||||
glfw/clipboard.cpp
|
|
||||||
glfw/core.cpp
|
|
||||||
glfw/gfx.cpp
|
|
||||||
opengl/gfx.cpp
|
|
||||||
opengl/gfx_opengl.cpp
|
|
||||||
)
|
|
||||||
target_link_libraries(
|
|
||||||
NostalgiaCore PUBLIC
|
|
||||||
glad
|
|
||||||
glfw
|
|
||||||
imgui
|
|
||||||
OxEvent
|
|
||||||
NostalgiaGlUtils
|
|
||||||
)
|
|
||||||
else()
|
else()
|
||||||
enable_language(CXX ASM)
|
add_subdirectory(glfw)
|
||||||
set_source_files_properties(core.arm.cpp irq.arm.cpp PROPERTIES COMPILE_FLAGS -marm)
|
add_subdirectory(opengl)
|
||||||
target_sources(
|
|
||||||
NostalgiaCore PRIVATE
|
|
||||||
gba/bios.s
|
|
||||||
gba/core.arm.cpp
|
|
||||||
gba/core.cpp
|
|
||||||
gba/gfx.cpp
|
|
||||||
gba/irq.arm.cpp
|
|
||||||
gba/irq.s
|
|
||||||
gba/panic.cpp
|
|
||||||
)
|
|
||||||
target_link_libraries(
|
|
||||||
NostalgiaCore PUBLIC
|
|
||||||
GbaStartup
|
|
||||||
)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT MSVC)
|
if(NOT MSVC)
|
||||||
target_compile_options(NostalgiaCore-Common PUBLIC -Wsign-conversion)
|
target_compile_options(NostalgiaCore PUBLIC -Wsign-conversion)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(
|
|
||||||
NostalgiaCore-Common PUBLIC
|
|
||||||
Keel
|
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
NostalgiaCore PUBLIC
|
NostalgiaCore PUBLIC
|
||||||
NostalgiaCore-Common
|
Keel
|
||||||
)
|
)
|
||||||
|
|
||||||
if(NOSTALGIA_BUILD_STUDIO)
|
if(NOSTALGIA_BUILD_STUDIO)
|
||||||
|
@ -116,8 +116,6 @@ class Context: public keel::Context {
|
|||||||
#ifndef OX_BARE_METAL
|
#ifndef OX_BARE_METAL
|
||||||
int uninterruptedRefreshes = 3;
|
int uninterruptedRefreshes = 3;
|
||||||
ox::UPtr<BaseClipboardObject> clipboard;
|
ox::UPtr<BaseClipboardObject> clipboard;
|
||||||
#else
|
|
||||||
bool running = true;
|
|
||||||
#endif
|
#endif
|
||||||
protected:
|
protected:
|
||||||
#ifndef OX_BARE_METAL
|
#ifndef OX_BARE_METAL
|
||||||
|
16
src/nostalgia/core/gba/CMakeLists.txt
Normal file
16
src/nostalgia/core/gba/CMakeLists.txt
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
enable_language(CXX ASM)
|
||||||
|
set_source_files_properties(core.arm.cpp irq.arm.cpp PROPERTIES COMPILE_FLAGS -marm)
|
||||||
|
target_sources(
|
||||||
|
NostalgiaCore PRIVATE
|
||||||
|
bios.s
|
||||||
|
core.arm.cpp
|
||||||
|
core.cpp
|
||||||
|
gfx.cpp
|
||||||
|
irq.arm.cpp
|
||||||
|
irq.s
|
||||||
|
panic.cpp
|
||||||
|
)
|
||||||
|
target_link_libraries(
|
||||||
|
NostalgiaCore PUBLIC
|
||||||
|
GbaStartup
|
||||||
|
)
|
29
src/nostalgia/core/gba/context.hpp
Normal file
29
src/nostalgia/core/gba/context.hpp
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <ox/fs/fs.hpp>
|
||||||
|
#include <ox/model/desctypes.hpp>
|
||||||
|
#include <ox/std/buffer.hpp>
|
||||||
|
|
||||||
|
#include <keel/context.hpp>
|
||||||
|
#include <nostalgia/geo/size.hpp>
|
||||||
|
|
||||||
|
#include <nostalgia/core/context.hpp>
|
||||||
|
|
||||||
|
namespace nostalgia::core::gba {
|
||||||
|
|
||||||
|
class Context: public core::Context {
|
||||||
|
public:
|
||||||
|
bool running = true;
|
||||||
|
|
||||||
|
Context() noexcept = default;
|
||||||
|
Context(Context &other) noexcept = delete;
|
||||||
|
Context(const Context &other) noexcept = delete;
|
||||||
|
Context(const Context &&other) noexcept = delete;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -6,6 +6,7 @@
|
|||||||
#include <nostalgia/core/core.hpp>
|
#include <nostalgia/core/core.hpp>
|
||||||
|
|
||||||
#include "addresses.hpp"
|
#include "addresses.hpp"
|
||||||
|
#include "context.hpp"
|
||||||
#include "bios.hpp"
|
#include "bios.hpp"
|
||||||
#include "irq.hpp"
|
#include "irq.hpp"
|
||||||
#include "core.hpp"
|
#include "core.hpp"
|
||||||
@ -18,7 +19,8 @@ UpdateHandler g_updateHandler = nullptr;
|
|||||||
|
|
||||||
ox::Error run(Context *ctx) noexcept {
|
ox::Error run(Context *ctx) noexcept {
|
||||||
g_wakeupTime = 0;
|
g_wakeupTime = 0;
|
||||||
while (ctx->running) {
|
const auto gbaCtx = static_cast<gba::Context*>(ctx);
|
||||||
|
while (gbaCtx->running) {
|
||||||
if (g_wakeupTime <= g_timerMs && g_updateHandler) {
|
if (g_wakeupTime <= g_timerMs && g_updateHandler) {
|
||||||
auto sleepTime = g_updateHandler(ctx);
|
auto sleepTime = g_updateHandler(ctx);
|
||||||
if (sleepTime >= 0) {
|
if (sleepTime >= 0) {
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include "addresses.hpp"
|
#include "addresses.hpp"
|
||||||
#include "bios.hpp"
|
#include "bios.hpp"
|
||||||
#include "irq.hpp"
|
#include "irq.hpp"
|
||||||
|
#include "context.hpp"
|
||||||
#include "core.hpp"
|
#include "core.hpp"
|
||||||
|
|
||||||
extern "C" void isr();
|
extern "C" void isr();
|
||||||
@ -55,7 +56,7 @@ static ox::Result<std::size_t> findPreloadSection() noexcept {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ox::Result<ox::UniquePtr<Context>> init(ox::UniquePtr<ox::FileSystem> fs, ox::CRStringView appName) noexcept {
|
ox::Result<ox::UniquePtr<Context>> init(ox::UniquePtr<ox::FileSystem> fs, ox::CRStringView appName) noexcept {
|
||||||
auto ctx = ox::make_unique<Context>();
|
ox::UPtr<Context> ctx(ox::make<gba::Context>());
|
||||||
ctx->rom = std::move(fs);
|
ctx->rom = std::move(fs);
|
||||||
ctx->appName = appName;
|
ctx->appName = appName;
|
||||||
oxReturnError(initGfx(ctx.get()));
|
oxReturnError(initGfx(ctx.get()));
|
||||||
@ -78,7 +79,8 @@ bool buttonDown(Context*, Key k) noexcept {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void shutdown(Context *ctx) noexcept {
|
void shutdown(Context *ctx) noexcept {
|
||||||
ctx->running = false;
|
const auto gbaCtx = static_cast<gba::Context*>(ctx);
|
||||||
|
gbaCtx->running = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
11
src/nostalgia/core/glfw/CMakeLists.txt
Normal file
11
src/nostalgia/core/glfw/CMakeLists.txt
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
target_sources(
|
||||||
|
NostalgiaCore PRIVATE
|
||||||
|
clipboard.cpp
|
||||||
|
core.cpp
|
||||||
|
gfx.cpp
|
||||||
|
)
|
||||||
|
target_link_libraries(
|
||||||
|
NostalgiaCore PUBLIC
|
||||||
|
glfw
|
||||||
|
imgui
|
||||||
|
)
|
11
src/nostalgia/core/opengl/CMakeLists.txt
Normal file
11
src/nostalgia/core/opengl/CMakeLists.txt
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
target_sources(
|
||||||
|
NostalgiaCore PRIVATE
|
||||||
|
gfx.cpp
|
||||||
|
gfx_opengl.cpp
|
||||||
|
)
|
||||||
|
target_link_libraries(
|
||||||
|
NostalgiaCore PUBLIC
|
||||||
|
glad
|
||||||
|
imgui
|
||||||
|
NostalgiaGlUtils
|
||||||
|
)
|
Loading…
x
Reference in New Issue
Block a user