From fb49164b31537cf17b7a35642cc8b35927611e10 Mon Sep 17 00:00:00 2001 From: Jaby Date: Fri, 16 Dec 2022 03:20:08 +0100 Subject: [PATCH] Prepare save spot for booting --- include/PSX/jabyengine.h | 23 +++++++++++++++++++ include/PSX/jabyengine_defines.h | 6 ++--- .../include/BootLoader/boot_loader.hpp | 5 ++++ src/Library/src/BootLoader/start_boot.cpp | 9 +++----- src/Library/src/startup.cpp | 10 ++++++++ 5 files changed, 44 insertions(+), 9 deletions(-) create mode 100644 include/PSX/jabyengine.h create mode 100644 src/Library/src/startup.cpp diff --git a/include/PSX/jabyengine.h b/include/PSX/jabyengine.h new file mode 100644 index 00000000..0d17bfe2 --- /dev/null +++ b/include/PSX/jabyengine.h @@ -0,0 +1,23 @@ +#ifndef __JABYENGINE__H__ +#define __JABYENGINE__H__ +#include "../stdint.h" + +namespace JabyEngine { + struct NextRoutine { + typedef NextRoutine (*ExecutionFunction)(); + + uintptr_t value; + + static NextRoutine null() { + return {.value = 0}; + } + + static NextRoutine from(ExecutionFunction function) { + return {.value = reinterpret_cast(function)}; + } + }; + + typedef NextRoutine::ExecutionFunction ExecutionFunction; +} + +#endif //!__JABYENGINE__H__ \ No newline at end of file diff --git a/include/PSX/jabyengine_defines.h b/include/PSX/jabyengine_defines.h index a29d383e..7b4f2c44 100644 --- a/include/PSX/jabyengine_defines.h +++ b/include/PSX/jabyengine_defines.h @@ -1,5 +1,5 @@ -#ifndef __JABYENGINE_DEFINES__H -#define __JABYENGINE_DEFINES__H +#ifndef __JABYENGINE_DEFINES__H__ +#define __JABYENGINE_DEFINES__H__ #include "../stddef.h" #define __keep __attribute__((used)) @@ -13,4 +13,4 @@ #else #define __constexpr #endif -#endif //!__JABYENGINE_DEFINES__H \ No newline at end of file +#endif //!__JABYENGINE_DEFINES__H__ \ No newline at end of file diff --git a/src/Library/include/BootLoader/boot_loader.hpp b/src/Library/include/BootLoader/boot_loader.hpp index 7ee8bede..14becdf8 100644 --- a/src/Library/include/BootLoader/boot_loader.hpp +++ b/src/Library/include/BootLoader/boot_loader.hpp @@ -1,5 +1,6 @@ #ifndef BOOT_LOADER_HPP #define BOOT_LOADER_HPP +#include namespace GPU { void display_logo(); @@ -11,4 +12,8 @@ namespace SPU { void setup(); } +namespace Setup { + JabyEngine::NextRoutine start(); +} + #endif //!BOOT_LOADER_HPP \ No newline at end of file diff --git a/src/Library/src/BootLoader/start_boot.cpp b/src/Library/src/BootLoader/start_boot.cpp index 4e949a86..3b804362 100644 --- a/src/Library/src/BootLoader/start_boot.cpp +++ b/src/Library/src/BootLoader/start_boot.cpp @@ -2,15 +2,12 @@ #include #include -extern int main(); - -namespace JabyEngine { +namespace Setup { static void enable_DMA() { DMA::DPCR.write(DMA::DPCR.read() | DMA::DMAControlRegister::SPUEnable | DMA::DMAControlRegister::GPUEnable); } - void start() { - printf("Starting Planschbecken\n"); + JabyEngine::NextRoutine start() { enable_DMA(); SPU::stop_voices(); @@ -20,6 +17,6 @@ namespace JabyEngine { //Pause?? SPU::setup(); - printf("Setup done!\n"); + return JabyEngine::NextRoutine::null(); } } \ No newline at end of file diff --git a/src/Library/src/startup.cpp b/src/Library/src/startup.cpp new file mode 100644 index 00000000..117883f6 --- /dev/null +++ b/src/Library/src/startup.cpp @@ -0,0 +1,10 @@ +#include "../include/BootLoader/boot_loader.hpp" +#include + +namespace JabyEngine { + void start() { + printf("Starting Planschbecken\n"); + Setup::start(); + printf("Stop!\n"); + } +} \ No newline at end of file