ditch multi-system idea
This commit is contained in:
@@ -4,4 +4,4 @@
|
|||||||
[](https://www.codefactor.io/repository/github/cocosimone/natsukashii/overview/master)
|
[](https://www.codefactor.io/repository/github/cocosimone/natsukashii/overview/master)
|
||||||
[](https://github.com/CocoSimone/natsukashii/actions/workflows/build.yml)
|
[](https://github.com/CocoSimone/natsukashii/actions/workflows/build.yml)
|
||||||
|
|
||||||
Multi-system emulator in its infancy
|
Rewrite of my Nintendo 64 emulator "[shibumi](https://github.com/CocoSimone/shibumi)".
|
||||||
|
|||||||
13
external/parallel-rdp/ParallelRDPWrapper.cpp
vendored
13
external/parallel-rdp/ParallelRDPWrapper.cpp
vendored
@@ -12,6 +12,7 @@ using namespace RDP;
|
|||||||
|
|
||||||
static CommandProcessor* command_processor;
|
static CommandProcessor* command_processor;
|
||||||
static WSI* wsi;
|
static WSI* wsi;
|
||||||
|
static std::unique_ptr<ParallelRdpWindowInfo> windowInfo;
|
||||||
|
|
||||||
std::vector<Semaphore> acquire_semaphore;
|
std::vector<Semaphore> acquire_semaphore;
|
||||||
|
|
||||||
@@ -109,14 +110,17 @@ public:
|
|||||||
|
|
||||||
Program* fullscreen_quad_program;
|
Program* fullscreen_quad_program;
|
||||||
|
|
||||||
void LoadWSIPlatform() {
|
WSI* LoadWSIPlatform(Vulkan::WSIPlatform* wsi_platform, std::unique_ptr<ParallelRdpWindowInfo>&& newWindowInfo) {
|
||||||
wsi = new WSI();
|
wsi = new WSI();
|
||||||
wsi->set_backbuffer_srgb(false);
|
wsi->set_backbuffer_srgb(false);
|
||||||
wsi->set_platform(new SDLWSIPlatform());
|
wsi->set_platform(wsi_platform);
|
||||||
Context::SystemHandles handles;
|
Context::SystemHandles handles;
|
||||||
if (!wsi->init_context_from_platform(1, handles)) {
|
if (!wsi->init_context_from_platform(1, handles)) {
|
||||||
util::panic("Failed to initialize WSI!");
|
util::panic("Failed to initialize WSI!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
windowInfo = std::move(newWindowInfo);
|
||||||
|
return wsi;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadParallelRDP(const u8* rdram) {
|
void LoadParallelRDP(const u8* rdram) {
|
||||||
@@ -161,6 +165,11 @@ void LoadParallelRDP(const u8* rdram) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InitParallelRDP(const u8* rdram) {
|
||||||
|
LoadWSIPlatform(new SDLWSIPlatform(), std::make_unique<SDLParallelRdpWindowInfo>());
|
||||||
|
LoadParallelRDP(rdram);
|
||||||
|
}
|
||||||
|
|
||||||
void DrawFullscreenTexturedQuad(Util::IntrusivePtr<Image> image, Util::IntrusivePtr<CommandBuffer> cmd) {
|
void DrawFullscreenTexturedQuad(Util::IntrusivePtr<Image> image, Util::IntrusivePtr<CommandBuffer> cmd) {
|
||||||
cmd->set_texture(0, 0, image->get_view(), Vulkan::StockSampler::LinearClamp);
|
cmd->set_texture(0, 0, image->get_view(), Vulkan::StockSampler::LinearClamp);
|
||||||
cmd->set_program(fullscreen_quad_program);
|
cmd->set_program(fullscreen_quad_program);
|
||||||
|
|||||||
27
external/parallel-rdp/ParallelRDPWrapper.hpp
vendored
27
external/parallel-rdp/ParallelRDPWrapper.hpp
vendored
@@ -1,12 +1,30 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <n64/Core.hpp>
|
#include <Core.hpp>
|
||||||
#include <wsi.hpp>
|
#include <wsi.hpp>
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include <n64/core/mmio/VI.hpp>
|
#include <n64/core/mmio/VI.hpp>
|
||||||
|
|
||||||
struct Window;
|
struct Window;
|
||||||
|
|
||||||
static SDL_Window* window;
|
static SDL_Window* window;
|
||||||
|
|
||||||
|
class ParallelRdpWindowInfo {
|
||||||
|
public:
|
||||||
|
struct CoordinatePair {
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
};
|
||||||
|
virtual CoordinatePair get_window_size() = 0;
|
||||||
|
virtual ~ParallelRdpWindowInfo() = default;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SDLParallelRdpWindowInfo : public ParallelRdpWindowInfo {
|
||||||
|
CoordinatePair get_window_size() {
|
||||||
|
int width, height;
|
||||||
|
SDL_GetWindowSize(window, &width, &height);
|
||||||
|
return CoordinatePair{ width, height };
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
static u32 windowID;
|
static u32 windowID;
|
||||||
VkQueue GetGraphicsQueue();
|
VkQueue GetGraphicsQueue();
|
||||||
VkInstance GetVkInstance();
|
VkInstance GetVkInstance();
|
||||||
@@ -16,11 +34,10 @@ uint32_t GetVkGraphicsQueueFamily();
|
|||||||
VkFormat GetVkFormat();
|
VkFormat GetVkFormat();
|
||||||
VkCommandBuffer GetVkCommandBuffer();
|
VkCommandBuffer GetVkCommandBuffer();
|
||||||
void SubmitRequestedVkCommandBuffer();
|
void SubmitRequestedVkCommandBuffer();
|
||||||
void LoadWSIPlatform();
|
void InitParallelRDP(const u8* rdram);
|
||||||
void LoadParallelRDP(const u8* rdram);
|
|
||||||
void UpdateScreenParallelRdp(Window& imguiWindow, const n64::VI& vi);
|
void UpdateScreenParallelRdp(Window& imguiWindow, const n64::VI& vi);
|
||||||
void ParallelRdpEnqueueCommand(int command_length, u32* buffer);
|
void ParallelRdpEnqueueCommand(int command_length, u32* buffer);
|
||||||
void ParallelRdpOnFullSync();
|
void ParallelRdpOnFullSync();
|
||||||
void UpdateScreenParallelRdpNoGame(Window& imguiWindow);
|
void UpdateScreenParallelRdpNoGame(Window& imguiWindow);
|
||||||
bool IsFramerateUnlocked();
|
bool IsFramerateUnlocked();
|
||||||
void SetFramerateUnlocked(bool unlocked);
|
void SetFramerateUnlocked(bool unlocked);
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ project(natsukashii)
|
|||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED true)
|
set(CMAKE_CXX_STANDARD_REQUIRED true)
|
||||||
|
|
||||||
add_subdirectory(cores)
|
add_subdirectory(n64)
|
||||||
add_subdirectory(frontend)
|
add_subdirectory(frontend)
|
||||||
|
|
||||||
add_executable(natsukashii main.cpp)
|
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)
|
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
|
target_include_directories(frontend-imgui PUBLIC
|
||||||
.
|
.
|
||||||
../../cores
|
../../n64
|
||||||
../../../external
|
../../../external
|
||||||
../../../external/parallel-rdp/parallel-rdp-standalone/vulkan
|
../../../external/parallel-rdp/parallel-rdp-standalone/vulkan
|
||||||
../../../external/parallel-rdp/parallel-rdp-standalone/util
|
../../../external/parallel-rdp/parallel-rdp-standalone/util
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
#include <Window.hpp>
|
#include <Window.hpp>
|
||||||
#include <util.hpp>
|
#include <util.hpp>
|
||||||
#include <nfd.hpp>
|
#include <nfd.hpp>
|
||||||
#include <n64/Core.hpp>
|
#include <Core.hpp>
|
||||||
#include <parallel-rdp/parallel-rdp-standalone/volk/volk.h>
|
#include <parallel-rdp/parallel-rdp-standalone/volk/volk.h>
|
||||||
#include <parallel-rdp/ParallelRDPWrapper.hpp>
|
#include <parallel-rdp/ParallelRDPWrapper.hpp>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
Window::Window(std::shared_ptr<BaseCore> core) : core(std::move(core)) {
|
Window::Window(n64::Core& core) {
|
||||||
InitSDL();
|
InitSDL();
|
||||||
LoadWSIPlatform();
|
InitParallelRDP(core.GetRDRAM());
|
||||||
InitImgui();
|
InitImgui();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,11 +6,11 @@
|
|||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include <SDL2/SDL_vulkan.h>
|
#include <SDL2/SDL_vulkan.h>
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
#include <BaseCore.hpp>
|
#include <Core.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
struct Window {
|
struct Window {
|
||||||
explicit Window(std::shared_ptr<BaseCore> core);
|
explicit Window(n64::Core& core);
|
||||||
~Window();
|
~Window();
|
||||||
ImDrawData* Present();
|
ImDrawData* Present();
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ struct Window {
|
|||||||
&& event.window.windowID == SDL_GetWindowID(window);
|
&& event.window.windowID == SDL_GetWindowID(window);
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<BaseCore> core;
|
n64::Core core;
|
||||||
void InitSDL();
|
void InitSDL();
|
||||||
void InitImgui();
|
void InitImgui();
|
||||||
void Render();
|
void Render();
|
||||||
|
|||||||
@@ -8,10 +8,10 @@ add_library(n64
|
|||||||
Core.hpp
|
Core.hpp
|
||||||
memory_regions.hpp)
|
memory_regions.hpp)
|
||||||
|
|
||||||
target_link_libraries(n64 PUBLIC n64-core)
|
target_link_libraries(n64 PUBLIC core)
|
||||||
target_include_directories(n64 PUBLIC
|
target_include_directories(n64 PUBLIC
|
||||||
.
|
.
|
||||||
..
|
..
|
||||||
../../../external
|
../../external
|
||||||
../../../external/imgui/imgui
|
../../external/imgui/imgui
|
||||||
../../../external/imgui/imgui/backends)
|
../../external/imgui/imgui/backends)
|
||||||
@@ -1,11 +1,9 @@
|
|||||||
#include <Core.hpp>
|
#include <Core.hpp>
|
||||||
#include <SDL2/SDL_events.h>
|
#include <SDL2/SDL_events.h>
|
||||||
#include "parallel-rdp/ParallelRDPWrapper.hpp"
|
|
||||||
|
|
||||||
namespace n64 {
|
namespace n64 {
|
||||||
Core::Core(const std::string& rom) {
|
Core::Core(const std::string& rom) {
|
||||||
mem.LoadROM(rom);
|
mem.LoadROM(rom);
|
||||||
LoadParallelRDP(mem.GetRDRAM());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Run() {
|
void Core::Run() {
|
||||||
@@ -28,6 +26,5 @@ void Core::Run() {
|
|||||||
void Core::PollInputs(u32 windowID) {
|
void Core::PollInputs(u32 windowID) {
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
SDL_PollEvent(&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)
|
cmake_minimum_required(VERSION 3.20)
|
||||||
project(n64-core)
|
project(core)
|
||||||
|
|
||||||
add_subdirectory(cpu)
|
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.hpp
|
||||||
Cpu.cpp
|
Cpu.cpp
|
||||||
Mem.cpp
|
Mem.cpp
|
||||||
@@ -37,13 +37,13 @@ add_library(n64-core
|
|||||||
rsp/decode.cpp
|
rsp/decode.cpp
|
||||||
rsp/instructions.cpp)
|
rsp/instructions.cpp)
|
||||||
|
|
||||||
target_include_directories(n64-core PUBLIC
|
target_include_directories(core PUBLIC
|
||||||
.
|
.
|
||||||
..
|
..
|
||||||
../..
|
../..
|
||||||
../../../../external
|
../../../external
|
||||||
../../../external/imgui/imgui
|
../../../external/imgui/imgui
|
||||||
../../../external/imgui/imgui/backends
|
../../../external/imgui/imgui/backends
|
||||||
mmio)
|
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)
|
cmake_minimum_required(VERSION 3.20)
|
||||||
project(n64-cpu)
|
project(cpu)
|
||||||
|
|
||||||
add_library(n64-cpu
|
add_library(cpu
|
||||||
Registers.cpp
|
Registers.cpp
|
||||||
Registers.hpp
|
Registers.hpp
|
||||||
registers/Cop0.cpp
|
registers/Cop0.cpp
|
||||||
@@ -13,5 +13,5 @@ add_library(n64-cpu
|
|||||||
registers/cop1instructions.cpp
|
registers/cop1instructions.cpp
|
||||||
instructions.cpp)
|
instructions.cpp)
|
||||||
|
|
||||||
target_include_directories(n64-cpu PUBLIC registers . .. ../../
|
target_include_directories(cpu PUBLIC registers . .. ../../
|
||||||
../../../../../external ../../../)
|
../../../../../external ../../../)
|
||||||
Reference in New Issue
Block a user