[nostalgia/core] Cleanup
This commit is contained in:
@@ -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
|
||||
)
|
||||
@@ -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 "addresses.hpp"
|
||||
#include "context.hpp"
|
||||
#include "bios.hpp"
|
||||
#include "irq.hpp"
|
||||
#include "core.hpp"
|
||||
@@ -18,7 +19,8 @@ UpdateHandler g_updateHandler = nullptr;
|
||||
|
||||
ox::Error run(Context *ctx) noexcept {
|
||||
g_wakeupTime = 0;
|
||||
while (ctx->running) {
|
||||
const auto gbaCtx = static_cast<gba::Context*>(ctx);
|
||||
while (gbaCtx->running) {
|
||||
if (g_wakeupTime <= g_timerMs && g_updateHandler) {
|
||||
auto sleepTime = g_updateHandler(ctx);
|
||||
if (sleepTime >= 0) {
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "addresses.hpp"
|
||||
#include "bios.hpp"
|
||||
#include "irq.hpp"
|
||||
#include "context.hpp"
|
||||
#include "core.hpp"
|
||||
|
||||
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 {
|
||||
auto ctx = ox::make_unique<Context>();
|
||||
ox::UPtr<Context> ctx(ox::make<gba::Context>());
|
||||
ctx->rom = std::move(fs);
|
||||
ctx->appName = appName;
|
||||
oxReturnError(initGfx(ctx.get()));
|
||||
@@ -78,7 +79,8 @@ bool buttonDown(Context*, Key k) noexcept {
|
||||
}
|
||||
|
||||
void shutdown(Context *ctx) noexcept {
|
||||
ctx->running = false;
|
||||
const auto gbaCtx = static_cast<gba::Context*>(ctx);
|
||||
gbaCtx->running = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user