diff --git a/external/parallel-rdp/ParallelRDPWrapper.cpp b/external/parallel-rdp/ParallelRDPWrapper.cpp index 3cede6d7..b1046eae 100644 --- a/external/parallel-rdp/ParallelRDPWrapper.cpp +++ b/external/parallel-rdp/ParallelRDPWrapper.cpp @@ -114,6 +114,7 @@ WSI* LoadWSIPlatform(Vulkan::WSIPlatform* wsi_platform, std::unique_ptrset_backbuffer_srgb(false); wsi->set_platform(wsi_platform); + wsi->set_present_mode(PresentMode::SyncToVBlank); Context::SystemHandles handles; if (!wsi->init_simple(1, handles)) { util::panic("Failed to initialize WSI!"); @@ -140,8 +141,8 @@ void LoadParallelRDP(const u8* rdram) { fragLayout.sets[0].array_size[0] = 1; u32* fullscreenQuadVert, *fullscreenQuadFrag; - auto sizeVert = util::ReadFileBinary("external/vert.spv", fullscreenQuadVert); - auto sizeFrag = util::ReadFileBinary("external/frag.spv", fullscreenQuadFrag); + auto sizeVert = util::ReadFileBinary("resources/vert.spv", &fullscreenQuadVert); + auto sizeFrag = util::ReadFileBinary("resources/frag.spv", &fullscreenQuadFrag); fullscreen_quad_program = wsi->get_device().request_program(fullscreenQuadVert, sizeVert, fullscreenQuadFrag, sizeFrag, &vertLayout, &fragLayout); @@ -239,7 +240,7 @@ void UpdateScreen(Window& imguiWindow, Util::IntrusivePtr image) { cmd->begin_render_pass(wsi->get_device().get_swapchain_render_pass(SwapchainRenderPass::ColorOnly)); DrawFullscreenTexturedQuad(image, cmd); - ImGui_ImplVulkan_RenderDrawData(imguiWindow.Present(), cmd->get_command_buffer()); + //ImGui_ImplVulkan_RenderDrawData(imguiWindow.Present(), cmd->get_command_buffer()); cmd->end_render_pass(); wsi->get_device().submit(cmd); diff --git a/external/frag.spv b/resources/frag.spv similarity index 100% rename from external/frag.spv rename to resources/frag.spv diff --git a/external/shader.frag b/resources/shader.frag similarity index 100% rename from external/shader.frag rename to resources/shader.frag diff --git a/external/shader.vert b/resources/shader.vert similarity index 100% rename from external/shader.vert rename to resources/shader.vert diff --git a/external/vert.spv b/resources/vert.spv similarity index 100% rename from external/vert.spv rename to resources/vert.spv diff --git a/src/frontend/App.cpp b/src/frontend/App.cpp index cc45b6a9..cc4edfd2 100644 --- a/src/frontend/App.cpp +++ b/src/frontend/App.cpp @@ -1,5 +1,6 @@ #include #include +#include void App::Run() { // Main loop @@ -7,11 +8,24 @@ void App::Run() { while (!done) { SDL_Event event; while (SDL_PollEvent(&event)) { - ImGui_ImplSDL2_ProcessEvent(&event); + //ImGui_ImplSDL2_ProcessEvent(&event); if (event.type == SDL_QUIT) done = true; if (window.gotClosed(event)) done = true; + if(event.type == SDL_KEYDOWN) { + switch(event.key.keysym.sym) { + case SDLK_o: { + nfdchar_t* outpath; + const nfdu8filteritem_t filter {"Nintendo 64 roms", "n64,z64,v64,N64,Z64,V64"}; + nfdresult_t result = NFD_OpenDialog(&outpath, &filter, 1, nullptr); + if(result == NFD_OKAY) { + core.LoadROM(outpath); + NFD_FreePath(outpath); + } + } break; + } + } } if(core.initialized) @@ -19,5 +33,7 @@ void App::Run() { if(core.initialized) UpdateScreenParallelRdp(window, core.GetVI()); else UpdateScreenParallelRdpNoGame(window); + + SDL_Delay(16); } -} \ No newline at end of file +} diff --git a/src/frontend/imgui/Window.cpp b/src/frontend/imgui/Window.cpp index c0ef4c10..03b66870 100644 --- a/src/frontend/imgui/Window.cpp +++ b/src/frontend/imgui/Window.cpp @@ -7,7 +7,7 @@ Window::Window(const n64::Core& core) { InitSDL(); InitParallelRDP(core.GetRDRAM(), window); - InitImgui(); + //InitImgui(); } [[nodiscard]] bool Window::gotClosed(SDL_Event event) { @@ -168,22 +168,22 @@ void Window::InitImgui() { Window::~Window() { VkResult err = vkDeviceWaitIdle(device); check_vk_result(err); - ImGui_ImplVulkan_Shutdown(); - ImGui_ImplSDL2_Shutdown(); - ImGui::DestroyContext(); + //ImGui_ImplVulkan_Shutdown(); + //ImGui_ImplSDL2_Shutdown(); + //ImGui::DestroyContext(); vkDestroyDescriptorPool(device, descriptorPool, nullptr); vkDestroyDevice(device, nullptr); vkDestroyInstance(instance, nullptr); } ImDrawData* Window::Present() { - ImGui_ImplVulkan_NewFrame(); - ImGui_ImplSDL2_NewFrame(window); - ImGui::NewFrame(); - + //ImGui_ImplVulkan_NewFrame(); + //ImGui_ImplSDL2_NewFrame(window); + //ImGui::NewFrame(); +// Render(); - ImGui::Render(); + //ImGui::Render(); return ImGui::GetDrawData(); } diff --git a/src/n64/core/Mem.cpp b/src/n64/core/Mem.cpp index e1cc95d1..fc499478 100644 --- a/src/n64/core/Mem.cpp +++ b/src/n64/core/Mem.cpp @@ -19,19 +19,18 @@ void Mem::LoadROM(const std::string& filename) { util::panic("Unable to open {}!", filename); } - file.seekg(std::ios::end); + file.seekg(0, std::ios::end); auto size = file.tellg(); auto size_adjusted = util::NextPow2(size); romMask = size_adjusted - 1; - file.seekg(std::ios::beg); + file.seekg(0, std::ios::beg); - std::vector rom; - rom.reserve(size_adjusted); - file.read(reinterpret_cast(rom.data()), size); + cart.resize(size_adjusted); + file.read(reinterpret_cast(cart.data()), size); file.close(); - util::SwapN64Rom(size, rom.data()); - memcpy(dmem, rom.data(), 0x1000); + util::SwapN64Rom(size, cart.data()); + memcpy(mmio.rsp.dmem, cart.data(), 0x1000); } template diff --git a/src/n64/core/Mem.hpp b/src/n64/core/Mem.hpp index c43b2364..8c511eb7 100644 --- a/src/n64/core/Mem.hpp +++ b/src/n64/core/Mem.hpp @@ -27,7 +27,6 @@ private: friend struct Core; MMIO mmio; std::vector cart, rdram, sram; - u8 dmem[DMEM_SIZE]{}, imem[IMEM_SIZE]{}; u8 pifBootrom[PIF_BOOTROM_SIZE]{}; size_t romMask; }; diff --git a/src/util.hpp b/src/util.hpp index 3a2b20d5..5427ca00 100644 --- a/src/util.hpp +++ b/src/util.hpp @@ -146,7 +146,7 @@ inline size_t NextPow2(size_t num) { return num + 1; } -inline auto ReadFileBinary(const std::string& path, u32* buf) { +inline auto ReadFileBinary(const std::string& path, u32** buf) { std::ifstream file(path, std::ios::binary); file.unsetf(std::ios::skipws); if(!file.is_open()) { @@ -157,8 +157,8 @@ inline auto ReadFileBinary(const std::string& path, u32* buf) { size_t size = file.tellg(); file.seekg(0, std::ios::beg); - buf = (u32*)calloc(size, 1); - file.read(reinterpret_cast(buf), size); + *buf = (u32*)calloc(size, 1); + file.read(reinterpret_cast(*buf), size); file.close(); return size; }