Squashed 'deps/nostalgia/' changes from 161640fa..a75c4a11
a75c4a11 [nfde] Address CMake warning, remove unwanted logging 347a1657 [sample_project] Update type descriptors fd64bfae [keel] Fix a use after free, cleanup aaeec20a [nostalgia/player] Fix build 37030f9c [keel] Cleanup pack tool 462f2bca [nostalgia,olympic] Change macro names to comply with broader conventions dc72500b [glutils] Change macro names to comply with broader conventions 962fe8bc [ox] Change macro names to comply with broader conventions 305eb626 [studio] Fix build 4754359a [ox/std] Cleanup Vec2 dc07f3d5 [studio] Change FilePicker consturctor to take StringParams fcdcfd10 [ox/std] Run liccor b74f6a7a [studio,turbine] Run liccor ac7e5be1 [ox] Remove OxException ed910c0b [nostalgia/core/studio/tilesheeteditor] Fix access overflow on out of bounds Fill command 345fb038 [ox] Remove OxError 9881253f [glutils] Cleanup OxError 96d27eec [nostalgia,olympic] Cleanup 28ebe93b [ox/std] Make source_location::current only init if valid e849e7a3 [ox/std] Add source_location e6777b0a [cityhash] Add install rule c488c336 [turbine/glfw] Fix mandatoryRefreshPeriodEnd tracking 003f9720 [turbine/glfw] Move MandatoryRefreshPeriod to config.hpp d85a10af [nostalgia/core/studio] Cleanup ff05d860 [turbine/glfw] Replace uninterruptedRefreshes with mandatoryRefreshPeriodEnd 76794037 [turbine] Add init wrapper that takes FS path c51a45e1 [olympic] Cleanup a6e24ff2 [ox/std] Add CString type alias e0ec9e0c [nostalgia,olympic] Move olympic::run to global namespace 9a42a9b9 [nfde] Fix Windows warnings 03a05c51 Merge commit '4ccdfc3a6e5bd501968903a01f7d8141b6f88375' bd91137d [nostalgia,olympic] Fix pack tool build for Windows 2b7d1294 [nostalgia/core/studio] Fix MSVC build git-subtree-dir: deps/nostalgia git-subtree-split: a75c4a11d3c555f4d3bed1ea1f70bb29fe49e99c
This commit is contained in:
@@ -38,7 +38,7 @@ ox::Result<BaseClipboardObject*> getClipboardData(Context &ctx, ox::StringView t
|
||||
|
||||
template<typename T>
|
||||
ox::Result<T*> getClipboardObject(Context &ctx) noexcept {
|
||||
oxRequire(p, getClipboardData(ctx, ox::ModelTypeId_v<T>));
|
||||
OX_REQUIRE(p, getClipboardData(ctx, ox::ModelTypeId_v<T>));
|
||||
return dynamic_cast<T*>(p);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@ using TimeMs = uint64_t;
|
||||
|
||||
ox::Result<ContextUPtr> init(ox::UPtr<ox::FileSystem> &&fs, ox::StringViewCR appName) noexcept;
|
||||
|
||||
ox::Result<ContextUPtr> init(ox::StringViewCR fsPath, ox::StringViewCR appName) noexcept;
|
||||
|
||||
ox::Error run(Context &ctx) noexcept;
|
||||
|
||||
// Returns the number of milliseconds that have passed since the start of the
|
||||
|
||||
@@ -18,6 +18,11 @@ target_include_directories(
|
||||
../include
|
||||
)
|
||||
|
||||
target_sources(
|
||||
Turbine PUBLIC
|
||||
turbine.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
Turbine PUBLIC
|
||||
Keel
|
||||
|
||||
@@ -44,7 +44,7 @@ ox::Bounds getWindowBounds(Context&) noexcept {
|
||||
}
|
||||
|
||||
ox::Error setWindowBounds(Context&, ox::Bounds const&) noexcept {
|
||||
return OxError(1, "setWindowBounds not supported on GBA");
|
||||
return ox::Error(1, "setWindowBounds not supported on GBA");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -55,17 +55,17 @@ OX_ALLOW_UNSAFE_BUFFERS_BEGIN
|
||||
}
|
||||
}
|
||||
OX_ALLOW_UNSAFE_BUFFERS_END
|
||||
return OxError(1);
|
||||
return ox::Error(1);
|
||||
}
|
||||
|
||||
ox::Result<ContextUPtr> init(
|
||||
ox::UPtr<ox::FileSystem> &&fs, ox::StringViewCR appName) noexcept {
|
||||
auto ctx = ox::make_unique<Context>();
|
||||
oxReturnError(keel::init(ctx->keelCtx, std::move(fs), appName));
|
||||
OX_RETURN_ERROR(keel::init(ctx->keelCtx, std::move(fs), appName));
|
||||
#ifdef OX_BARE_METAL
|
||||
oxReturnError(findPreloadSection().moveTo(ctx->keelCtx.preloadSectionOffset));
|
||||
OX_RETURN_ERROR(findPreloadSection().moveTo(ctx->keelCtx.preloadSectionOffset));
|
||||
#endif
|
||||
oxReturnError(initGfx(*ctx));
|
||||
OX_RETURN_ERROR(initGfx(*ctx));
|
||||
initTimer();
|
||||
initIrq();
|
||||
return ox::UPtr<turbine::Context, ContextDeleter>(std::move(ctx));
|
||||
|
||||
@@ -30,7 +30,7 @@ ox::Result<BaseClipboardObject*> getClipboardData(Context &ctx, ox::StringView t
|
||||
if (ctx.clipboard && ctx.clipboard->typeId() == typeId) {
|
||||
return ctx.clipboard.get();
|
||||
}
|
||||
return OxError(1);
|
||||
return ox::Error(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,8 +4,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <turbine/turbine.hpp>
|
||||
|
||||
namespace turbine::config {
|
||||
|
||||
constexpr bool GlFpsPrint = TURBINE_GL_FPS_PRINT;
|
||||
inline constexpr bool GlFpsPrint = TURBINE_GL_FPS_PRINT;
|
||||
inline constexpr TimeMs MandatoryRefreshPeriod = 168;
|
||||
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ class Context {
|
||||
ox::AnyPtr applicationData;
|
||||
|
||||
// GLFW impl data ////////////////////////////////////////////////////////
|
||||
int uninterruptedRefreshes = 3;
|
||||
TimeMs mandatoryRefreshPeriodEnd{};
|
||||
ox::UPtr<BaseClipboardObject> clipboard;
|
||||
struct GLFWwindow *window = nullptr;
|
||||
int refreshWithinMs = 0;
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#include <imgui_impl_opengl3.h>
|
||||
#endif
|
||||
|
||||
#include "config.hpp"
|
||||
|
||||
#include <ox/std/span.hpp>
|
||||
|
||||
#include "context.hpp"
|
||||
@@ -62,10 +64,13 @@ static void handleKeyPress(Context &ctx, int key, bool down) noexcept {
|
||||
return map;
|
||||
}();
|
||||
auto const eventHandler = keyEventHandler(ctx);
|
||||
auto const k = keyMap[static_cast<std::size_t>(key)];
|
||||
setKeyDownStatus(ctx, k, down);
|
||||
if (eventHandler) {
|
||||
eventHandler(ctx, k, down);
|
||||
auto const keyIdx = static_cast<std::size_t>(key);
|
||||
if (keyIdx < keyMap.size()) {
|
||||
auto const k = keyMap[keyIdx];
|
||||
setKeyDownStatus(ctx, k, down);
|
||||
if (eventHandler) {
|
||||
eventHandler(ctx, k, down);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,17 +78,17 @@ static void handleGlfwCursorPosEvent(GLFWwindow*, double, double) noexcept {
|
||||
}
|
||||
|
||||
static void handleGlfwMouseButtonEvent(GLFWwindow *window, int, int, int) noexcept {
|
||||
auto const ctx = static_cast<Context*>(glfwGetWindowUserPointer(window));
|
||||
ctx->uninterruptedRefreshes = 25;
|
||||
auto &ctx = *static_cast<Context*>(glfwGetWindowUserPointer(window));
|
||||
ctx.mandatoryRefreshPeriodEnd = ticksMs(ctx) + config::MandatoryRefreshPeriod;
|
||||
}
|
||||
|
||||
static void handleGlfwKeyEvent(GLFWwindow *window, int key, int, int action, int) noexcept {
|
||||
auto const ctx = static_cast<Context*>(glfwGetWindowUserPointer(window));
|
||||
ctx->uninterruptedRefreshes = 25;
|
||||
auto &ctx = *static_cast<Context*>(glfwGetWindowUserPointer(window));
|
||||
ctx.mandatoryRefreshPeriodEnd = ticksMs(ctx) + config::MandatoryRefreshPeriod;
|
||||
if (action == GLFW_PRESS) {
|
||||
handleKeyPress(*ctx, key, true);
|
||||
handleKeyPress(ctx, key, true);
|
||||
} else if (action == GLFW_RELEASE) {
|
||||
handleKeyPress(*ctx, key, false);
|
||||
handleKeyPress(ctx, key, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,7 +204,7 @@ ox::Error initGfx(Context &ctx) noexcept {
|
||||
ctx.window = glfwCreateWindow(240 * Scale, 160 * Scale, ctx.keelCtx.appName.c_str(), nullptr, nullptr);
|
||||
//ctx.window = glfwCreateWindow(876, 743, ctx.keelCtx.appName.c_str(), nullptr, nullptr);
|
||||
if (ctx.window == nullptr) {
|
||||
return OxError(1, "Could not open GLFW window");
|
||||
return ox::Error(1, "Could not open GLFW window");
|
||||
}
|
||||
glfwSetCursorPosCallback(ctx.window, handleGlfwCursorPosEvent);
|
||||
glfwSetMouseButtonCallback(ctx.window, handleGlfwMouseButtonEvent);
|
||||
@@ -207,7 +212,7 @@ ox::Error initGfx(Context &ctx) noexcept {
|
||||
glfwSetWindowUserPointer(ctx.window, &ctx);
|
||||
glfwMakeContextCurrent(ctx.window);
|
||||
if (!gladLoadGLES2Loader(reinterpret_cast<GLADloadproc>(glfwGetProcAddress))) {
|
||||
return OxError(2, "Could not init Glad");
|
||||
return ox::Error(2, "Could not init Glad");
|
||||
}
|
||||
#if TURBINE_USE_IMGUI
|
||||
IMGUI_CHECKVERSION();
|
||||
|
||||
@@ -43,12 +43,12 @@ static void draw(GLFWwindow *window, int, int) noexcept {
|
||||
ox::Result<ContextUPtr> init(
|
||||
ox::UPtr<ox::FileSystem> &&fs, ox::StringViewCR appName) noexcept {
|
||||
auto ctx = ox::make_unique<Context>();
|
||||
oxReturnError(keel::init(ctx->keelCtx, std::move(fs), appName));
|
||||
OX_RETURN_ERROR(keel::init(ctx->keelCtx, std::move(fs), appName));
|
||||
using namespace std::chrono;
|
||||
ctx->startTime = static_cast<TimeMs>(
|
||||
duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count());
|
||||
glfwInit();
|
||||
oxReturnError(initGfx(*ctx));
|
||||
OX_RETURN_ERROR(initGfx(*ctx));
|
||||
glfwSetWindowSizeCallback(ctx->window, draw);
|
||||
return ox::UPtr<Context, ContextDeleter>(ctx.release());
|
||||
}
|
||||
@@ -88,12 +88,8 @@ ox::Error run(Context &ctx) noexcept {
|
||||
tickFps(ctx, ticks);
|
||||
draw(ctx);
|
||||
auto const realSleepTime = ox::min(static_cast<uint64_t>(ctx.refreshWithinMs), sleepTime);
|
||||
if (realSleepTime) {
|
||||
if (ctx.uninterruptedRefreshes) {
|
||||
--ctx.uninterruptedRefreshes;
|
||||
} else {
|
||||
glfwWaitEventsTimeout(static_cast<double>(realSleepTime) / 1000);
|
||||
}
|
||||
if (realSleepTime && ctx.mandatoryRefreshPeriodEnd <= ticks) {
|
||||
glfwWaitEventsTimeout(static_cast<double>(realSleepTime) / 1000);
|
||||
}
|
||||
}
|
||||
shutdown(ctx);
|
||||
|
||||
16
src/olympic/turbine/src/turbine.cpp
Normal file
16
src/olympic/turbine/src/turbine.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright 2016 - 2024 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#include <keel/keel.hpp>
|
||||
|
||||
#include <turbine/turbine.hpp>
|
||||
|
||||
namespace turbine {
|
||||
|
||||
ox::Result<ContextUPtr> init(ox::StringViewCR fsPath, ox::StringViewCR appName) noexcept {
|
||||
OX_REQUIRE_M(fs, keel::loadRomFs(fsPath));
|
||||
return init(std::move(fs), appName);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user