ditch multi-system idea
This commit is contained in:
@@ -3,10 +3,10 @@ project(natsukashii)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED true)
|
||||
|
||||
add_subdirectory(cores)
|
||||
add_subdirectory(n64)
|
||||
add_subdirectory(frontend)
|
||||
|
||||
add_executable(natsukashii main.cpp)
|
||||
|
||||
target_link_libraries(natsukashii PUBLIC frontend cores)
|
||||
target_link_libraries(natsukashii PUBLIC frontend n64)
|
||||
target_include_directories(natsukashii PUBLIC . ../external)
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
#pragma once
|
||||
#include <common.hpp>
|
||||
|
||||
enum class System {
|
||||
GameBoy, Nintendo64
|
||||
};
|
||||
|
||||
struct BaseCore {
|
||||
virtual ~BaseCore() = default;
|
||||
virtual void Run() {};
|
||||
virtual void PollInputs(u32) {};
|
||||
[[nodiscard]] bool& ShouldQuit() { return quit; }
|
||||
bool initialized = false;
|
||||
System system;
|
||||
private:
|
||||
bool quit = false;
|
||||
};
|
||||
@@ -1,14 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
project(cores CXX)
|
||||
|
||||
add_subdirectory(n64)
|
||||
|
||||
find_package(fmt REQUIRED)
|
||||
|
||||
add_library(cores
|
||||
common.hpp
|
||||
util.hpp
|
||||
BaseCore.hpp)
|
||||
|
||||
target_link_libraries(cores PUBLIC fmt::fmt n64)
|
||||
target_include_directories(cores PUBLIC . ../../external)
|
||||
@@ -1,18 +0,0 @@
|
||||
#pragma once
|
||||
#include <BaseCore.hpp>
|
||||
#include <n64/core/Cpu.hpp>
|
||||
#include <n64/core/Mem.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace n64 {
|
||||
struct Core : BaseCore {
|
||||
~Core() override = default;
|
||||
explicit Core(const std::string&);
|
||||
void Run() override;
|
||||
void PollInputs(u32) override;
|
||||
VI& GetVI() { return mem.mmio.vi; }
|
||||
private:
|
||||
Mem mem;
|
||||
Cpu cpu;
|
||||
};
|
||||
}
|
||||
@@ -10,7 +10,7 @@ add_library(frontend-imgui
|
||||
|
||||
target_include_directories(frontend-imgui PUBLIC
|
||||
.
|
||||
../../cores
|
||||
../../n64
|
||||
../../../external
|
||||
../../../external/parallel-rdp/parallel-rdp-standalone/vulkan
|
||||
../../../external/parallel-rdp/parallel-rdp-standalone/util
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
#include <Window.hpp>
|
||||
#include <util.hpp>
|
||||
#include <nfd.hpp>
|
||||
#include <n64/Core.hpp>
|
||||
#include <Core.hpp>
|
||||
#include <parallel-rdp/parallel-rdp-standalone/volk/volk.h>
|
||||
#include <parallel-rdp/ParallelRDPWrapper.hpp>
|
||||
#include <utility>
|
||||
|
||||
Window::Window(std::shared_ptr<BaseCore> core) : core(std::move(core)) {
|
||||
Window::Window(n64::Core& core) {
|
||||
InitSDL();
|
||||
LoadWSIPlatform();
|
||||
InitParallelRDP(core.GetRDRAM());
|
||||
InitImgui();
|
||||
}
|
||||
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL2/SDL_vulkan.h>
|
||||
#include <vulkan/vulkan.h>
|
||||
#include <BaseCore.hpp>
|
||||
#include <Core.hpp>
|
||||
#include <vector>
|
||||
|
||||
struct Window {
|
||||
explicit Window(std::shared_ptr<BaseCore> core);
|
||||
explicit Window(n64::Core& core);
|
||||
~Window();
|
||||
ImDrawData* Present();
|
||||
|
||||
@@ -20,7 +20,7 @@ struct Window {
|
||||
&& event.window.windowID == SDL_GetWindowID(window);
|
||||
}
|
||||
private:
|
||||
std::shared_ptr<BaseCore> core;
|
||||
n64::Core core;
|
||||
void InitSDL();
|
||||
void InitImgui();
|
||||
void Render();
|
||||
|
||||
@@ -8,10 +8,10 @@ add_library(n64
|
||||
Core.hpp
|
||||
memory_regions.hpp)
|
||||
|
||||
target_link_libraries(n64 PUBLIC n64-core)
|
||||
target_link_libraries(n64 PUBLIC core)
|
||||
target_include_directories(n64 PUBLIC
|
||||
.
|
||||
..
|
||||
../../../external
|
||||
../../../external/imgui/imgui
|
||||
../../../external/imgui/imgui/backends)
|
||||
../../external
|
||||
../../external/imgui/imgui
|
||||
../../external/imgui/imgui/backends)
|
||||
@@ -1,11 +1,9 @@
|
||||
#include <Core.hpp>
|
||||
#include <SDL2/SDL_events.h>
|
||||
#include "parallel-rdp/ParallelRDPWrapper.hpp"
|
||||
|
||||
namespace n64 {
|
||||
Core::Core(const std::string& rom) {
|
||||
mem.LoadROM(rom);
|
||||
LoadParallelRDP(mem.GetRDRAM());
|
||||
}
|
||||
|
||||
void Core::Run() {
|
||||
@@ -28,6 +26,5 @@ void Core::Run() {
|
||||
void Core::PollInputs(u32 windowID) {
|
||||
SDL_Event event;
|
||||
SDL_PollEvent(&event);
|
||||
ShouldQuit() = event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_CLOSE && event.window.windowID == windowID;
|
||||
}
|
||||
}
|
||||
18
src/n64/Core.hpp
Normal file
18
src/n64/Core.hpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
#include <Cpu.hpp>
|
||||
#include <Mem.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace n64 {
|
||||
struct Core {
|
||||
~Core() = default;
|
||||
explicit Core(const std::string&);
|
||||
void Run();
|
||||
void PollInputs(u32);
|
||||
VI& GetVI() { return mem.mmio.vi; }
|
||||
const u8* GetRDRAM() { return mem.rdram.data(); }
|
||||
private:
|
||||
Mem mem;
|
||||
Cpu cpu;
|
||||
};
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
project(n64-core)
|
||||
project(core)
|
||||
|
||||
add_subdirectory(cpu)
|
||||
|
||||
add_subdirectory(../../../../external/parallel-rdp temp)
|
||||
add_subdirectory(../../../external/parallel-rdp temp)
|
||||
|
||||
add_library(n64-core
|
||||
add_library(core
|
||||
Cpu.hpp
|
||||
Cpu.cpp
|
||||
Mem.cpp
|
||||
@@ -37,13 +37,13 @@ add_library(n64-core
|
||||
rsp/decode.cpp
|
||||
rsp/instructions.cpp)
|
||||
|
||||
target_include_directories(n64-core PUBLIC
|
||||
target_include_directories(core PUBLIC
|
||||
.
|
||||
..
|
||||
../..
|
||||
../../../../external
|
||||
../../../external
|
||||
../../../external/imgui/imgui
|
||||
../../../external/imgui/imgui/backends
|
||||
mmio)
|
||||
|
||||
target_link_libraries(n64-core PUBLIC n64-cpu parallel-rdp)
|
||||
target_link_libraries(core PUBLIC cpu parallel-rdp)
|
||||
@@ -1,7 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
project(n64-cpu)
|
||||
project(cpu)
|
||||
|
||||
add_library(n64-cpu
|
||||
add_library(cpu
|
||||
Registers.cpp
|
||||
Registers.hpp
|
||||
registers/Cop0.cpp
|
||||
@@ -13,5 +13,5 @@ add_library(n64-cpu
|
||||
registers/cop1instructions.cpp
|
||||
instructions.cpp)
|
||||
|
||||
target_include_directories(n64-cpu PUBLIC registers . .. ../../
|
||||
target_include_directories(cpu PUBLIC registers . .. ../../
|
||||
../../../../../external ../../../)
|
||||
Reference in New Issue
Block a user