make menu bar disappear + change way scaling works
This commit is contained in:
@@ -75,7 +75,7 @@ void Core::Run(Window& window, float volumeL, float volumeR) {
|
||||
|
||||
UpdateScreenParallelRdp(*this, window, GetVI());
|
||||
|
||||
int missedCycles = N64_CYCLES_PER_FRAME - frameCycles;
|
||||
int missedCycles = N64_CYCLES_PER_FRAME(false) - frameCycles;
|
||||
mmio.ai.Step(mem, regs, missedCycles, volumeL, volumeR);
|
||||
} else if(pause && romLoaded) {
|
||||
UpdateScreenParallelRdp(*this, window, GetVI());
|
||||
|
||||
@@ -14,9 +14,16 @@
|
||||
#define ISVIEWER_SIZE (0x13FFFFFF - 0x13FF0020)
|
||||
#define ISVIEWER_DSIZE (ISVIEWER_SIZE - 1)
|
||||
|
||||
#define RDRAM_REGION 0 ... RDRAM_DSIZE
|
||||
#define DMEM_REGION 0x04000000 ... DMEM_DSIZE
|
||||
#define IMEM_REGION 0x04001000 ... IMEM_DSIZE
|
||||
#define RDRAM_REGION_START 0
|
||||
#define RDRAM_REGION_END RDRAM_DSIZE
|
||||
#define DMEM_REGION_START 0x4000000
|
||||
#define DMEM_REGION_END (DMEM_REGION_START + DMEM_DSIZE)
|
||||
#define IMEM_REGION_START 0x4001000
|
||||
#define IMEM_REGION_END (IMEM_REGION_START + IMEM_DSIZE)
|
||||
|
||||
#define RDRAM_REGION RDRAM_REGION_START ... RDRAM_REGION_END
|
||||
#define DMEM_REGION DMEM_REGION_START ... DMEM_REGION_END
|
||||
#define IMEM_REGION IMEM_REGION_START ... IMEM_REGION_END
|
||||
#define MMIO_REGION 0x04040000 ... 0x048FFFFF
|
||||
#define SP_REGION 0x04040000 ... 0x040FFFFF
|
||||
#define DP_CMD_REGION 0x04100000 ... 0x041FFFFF
|
||||
|
||||
@@ -108,10 +108,10 @@ u8 Mem::Read8(n64::Registers ®s, u64 vaddr, s64 pc) {
|
||||
case 0x00000000 ... 0x007FFFFF:
|
||||
return mmio.rdp.rdram[BYTE_ADDRESS(paddr)];
|
||||
case 0x04000000 ... 0x0403FFFF:
|
||||
if ((paddr >> 12) & 1)
|
||||
return mmio.rsp.imem[BYTE_ADDRESS(paddr) & IMEM_DSIZE];
|
||||
if (paddr & 0x1000)
|
||||
return mmio.rsp.imem[BYTE_ADDRESS(paddr) - IMEM_REGION_START];
|
||||
else
|
||||
return mmio.rsp.dmem[BYTE_ADDRESS(paddr) & DMEM_DSIZE];
|
||||
return mmio.rsp.dmem[BYTE_ADDRESS(paddr) - DMEM_REGION_START];
|
||||
case 0x04040000 ... 0x040FFFFF:
|
||||
case 0x04100000 ... 0x041FFFFF:
|
||||
case 0x04600000 ... 0x048FFFFF:
|
||||
@@ -159,7 +159,7 @@ u16 Mem::Read16(n64::Registers ®s, u64 vaddr, s64 pc) {
|
||||
case 0x00000000 ... 0x007FFFFF:
|
||||
return Util::ReadAccess<u16>(mmio.rdp.rdram.data(), HALF_ADDRESS(paddr));
|
||||
case 0x04000000 ... 0x0403FFFF:
|
||||
if ((paddr >> 12) & 1)
|
||||
if (paddr & 0x1000)
|
||||
return Util::ReadAccess<u16>(mmio.rsp.imem, HALF_ADDRESS(paddr) & IMEM_DSIZE);
|
||||
else
|
||||
return Util::ReadAccess<u16>(mmio.rsp.dmem, HALF_ADDRESS(paddr) & DMEM_DSIZE);
|
||||
@@ -205,7 +205,7 @@ u32 Mem::Read32(n64::Registers ®s, u64 vaddr, s64 pc) {
|
||||
case 0x00000000 ... 0x007FFFFF:
|
||||
return Util::ReadAccess<u32>(mmio.rdp.rdram.data(), paddr);
|
||||
case 0x04000000 ... 0x0403FFFF:
|
||||
if((paddr >> 12) & 1)
|
||||
if(paddr & 0x1000)
|
||||
return Util::ReadAccess<u32>(mmio.rsp.imem, paddr & IMEM_DSIZE);
|
||||
else
|
||||
return Util::ReadAccess<u32>(mmio.rsp.dmem, paddr & DMEM_DSIZE);
|
||||
@@ -245,7 +245,7 @@ u64 Mem::Read64(n64::Registers ®s, u64 vaddr, s64 pc) {
|
||||
case 0x00000000 ... 0x007FFFFF:
|
||||
return Util::ReadAccess<u64>(mmio.rdp.rdram.data(), paddr);
|
||||
case 0x04000000 ... 0x0403FFFF:
|
||||
if ((paddr >> 12) & 1)
|
||||
if (paddr & 0x1000)
|
||||
return Util::ReadAccess<u64>(mmio.rsp.imem, paddr & IMEM_DSIZE);
|
||||
else
|
||||
return Util::ReadAccess<u64>(mmio.rsp.dmem, paddr & DMEM_DSIZE);
|
||||
@@ -288,7 +288,7 @@ void Mem::Write8(Registers& regs, n64::JIT::Dynarec& dyn, u64 vaddr, u32 val, s6
|
||||
FireException(regs, GetTLBExceptionCode(regs.cop0.tlbError, LOAD), 0, false);
|
||||
}
|
||||
|
||||
dyn.InvalidatePage(paddr);
|
||||
dyn.InvalidatePage(BYTE_ADDRESS(paddr));
|
||||
|
||||
const auto page = paddr >> 12;
|
||||
auto offset = paddr & 0xFFF;
|
||||
@@ -349,7 +349,7 @@ void Mem::Write16(Registers& regs, n64::JIT::Dynarec& dyn, u64 vaddr, u32 val, s
|
||||
FireException(regs, GetTLBExceptionCode(regs.cop0.tlbError, STORE), 0, false);
|
||||
}
|
||||
|
||||
dyn.InvalidatePage(paddr);
|
||||
dyn.InvalidatePage(HALF_ADDRESS(paddr));
|
||||
|
||||
const auto page = paddr >> 12;
|
||||
auto offset = paddr & 0xFFF;
|
||||
|
||||
@@ -69,7 +69,7 @@ void VI::Write(MI& mi, Registers& regs, u32 paddr, u32 val) {
|
||||
case 0x04400018: {
|
||||
vsync = val & 0x3FF;
|
||||
numHalflines = vsync >> 1;
|
||||
cyclesPerHalfline = N64_CYCLES_PER_FRAME / numHalflines;
|
||||
cyclesPerHalfline = N64_CYCLES_PER_FRAME(false) / numHalflines;
|
||||
} break;
|
||||
case 0x0440001C: {
|
||||
hsync = val & 0x3FF;
|
||||
|
||||
@@ -14,7 +14,7 @@ using u128 = __uint128_t;
|
||||
using s128 = __int128_t;
|
||||
|
||||
#define N64_CPU_FREQ 93750000
|
||||
#define N64_CYCLES_PER_FRAME ((N64_CPU_FREQ) / 60)
|
||||
#define N64_CYCLES_PER_FRAME(pal) ((N64_CPU_FREQ) / (pal ? 50 : 60))
|
||||
#define HALF_ADDRESS(addr) ((addr) ^ 2)
|
||||
#define BYTE_ADDRESS(addr) ((addr) ^ 3)
|
||||
|
||||
|
||||
@@ -147,15 +147,15 @@ Window::~Window() {
|
||||
SDL_Quit();
|
||||
}
|
||||
|
||||
DrawData Window::Present(n64::Core& core) {
|
||||
ImDrawData* Window::Present(n64::Core& core) {
|
||||
ImGui_ImplVulkan_NewFrame();
|
||||
ImGui_ImplSDL2_NewFrame(window);
|
||||
ImGui::NewFrame();
|
||||
|
||||
float mainMenuBarHeight = Render(core);
|
||||
Render(core);
|
||||
|
||||
ImGui::Render();
|
||||
return {ImGui::GetDrawData(), mainMenuBarHeight};
|
||||
return ImGui::GetDrawData();
|
||||
}
|
||||
|
||||
void Window::LoadROM(n64::Core& core, const std::string &path) {
|
||||
@@ -192,23 +192,10 @@ void Window::LoadROM(n64::Core& core, const std::string &path) {
|
||||
}
|
||||
}
|
||||
|
||||
float Window::Render(n64::Core& core) {
|
||||
ImGui::PushFont(uiFont);
|
||||
|
||||
u32 ticks = SDL_GetTicks();
|
||||
static u32 lastFrame = 0;
|
||||
if(!core.pause && lastFrame < ticks - 1000) {
|
||||
lastFrame = ticks;
|
||||
windowTitle += fmt::format(" | {:02d} In-Game FPS", core.mem.mmio.vi.swaps);
|
||||
core.mem.mmio.vi.swaps = 0;
|
||||
SDL_SetWindowTitle(window, windowTitle.c_str());
|
||||
windowTitle = shadowWindowTitle;
|
||||
}
|
||||
|
||||
static bool showSettings = false;
|
||||
static float mainMenuBarHeight = 0;
|
||||
void Window::RenderMainMenuBar(n64::Core &core) {
|
||||
ImGui::BeginMainMenuBar();
|
||||
mainMenuBarHeight = ImGui::GetWindowSize().y;
|
||||
|
||||
if (ImGui::BeginMenu("File")) {
|
||||
if (ImGui::MenuItem("Open", "O")) {
|
||||
nfdchar_t *outpath;
|
||||
@@ -265,15 +252,33 @@ float Window::Render(n64::Core& core) {
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
ImGui::EndMainMenuBar();
|
||||
}
|
||||
|
||||
void Window::Render(n64::Core& core) {
|
||||
ImGui::PushFont(uiFont);
|
||||
|
||||
u32 ticks = SDL_GetTicks();
|
||||
static u32 lastFrame = 0;
|
||||
if(!core.pause && lastFrame < ticks - 1000) {
|
||||
lastFrame = ticks;
|
||||
windowTitle += fmt::format(" | {:02d} In-Game FPS", core.mem.mmio.vi.swaps);
|
||||
core.mem.mmio.vi.swaps = 0;
|
||||
SDL_SetWindowTitle(window, windowTitle.c_str());
|
||||
windowTitle = shadowWindowTitle;
|
||||
}
|
||||
|
||||
if(SDL_GetMouseFocus()) {
|
||||
RenderMainMenuBar(core);
|
||||
}
|
||||
|
||||
static std::string rom{};
|
||||
if(renderGameList && gameList.RenderWidget(mainMenuBarHeight, rom)) {
|
||||
LoadROM(core, rom);
|
||||
renderGameList = false;
|
||||
}
|
||||
|
||||
mainMenuBarHeight = 0;
|
||||
settings.RenderWidget(showSettings);
|
||||
|
||||
ImGui::PopFont();
|
||||
|
||||
return mainMenuBarHeight;
|
||||
}
|
||||
|
||||
@@ -10,15 +10,10 @@
|
||||
#include <frontend/imgui/Settings.hpp>
|
||||
#include <frontend/imgui/GameList.hpp>
|
||||
|
||||
struct DrawData {
|
||||
ImDrawData* first;
|
||||
float second;
|
||||
};
|
||||
|
||||
struct Window {
|
||||
explicit Window(n64::Core& core);
|
||||
~Window();
|
||||
DrawData Present(n64::Core& core);
|
||||
ImDrawData* Present(n64::Core& core);
|
||||
|
||||
[[nodiscard]] bool gotClosed(SDL_Event event);
|
||||
ImFont *uiFont{}, *codeFont{};
|
||||
@@ -28,13 +23,16 @@ struct Window {
|
||||
void LoadROM(n64::Core& core, const std::string& path);
|
||||
private:
|
||||
bool renderGameList = true;
|
||||
bool showSettings = false;
|
||||
float mainMenuBarHeight = 0;
|
||||
SDL_Window* window{};
|
||||
std::string windowTitle{"Gadolinium"};
|
||||
std::string shadowWindowTitle{windowTitle};
|
||||
std::string gameName{};
|
||||
void InitSDL();
|
||||
void InitImgui();
|
||||
float Render(n64::Core& core);
|
||||
void Render(n64::Core& core);
|
||||
void RenderMainMenuBar(n64::Core& core);
|
||||
|
||||
VkPhysicalDevice physicalDevice{};
|
||||
VkDevice device{};
|
||||
|
||||
Reference in New Issue
Block a user