From 7a7d7feee285b5d538227e3c9859d7fccf5431f6 Mon Sep 17 00:00:00 2001 From: SimoneN64 Date: Mon, 12 Jun 2023 10:14:15 +0200 Subject: [PATCH] small change --- src/backend/core/mmio/PI.cpp | 3 +-- src/backend/core/mmio/VI.cpp | 2 +- src/common.hpp | 17 +++++++++++++---- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/backend/core/mmio/PI.cpp b/src/backend/core/mmio/PI.cpp index 7afe10c0..e71ac64c 100644 --- a/src/backend/core/mmio/PI.cpp +++ b/src/backend/core/mmio/PI.cpp @@ -52,8 +52,7 @@ FORCE_INLINE u8 PIGetDomain(u32 address) { case CART_REGION_2_2: return 2; default: - //Util::panic("Unknown PI domain for address {:08X}!", address); - return 1; + Util::panic("Unknown PI domain for address {:08X}!", address); } } diff --git a/src/backend/core/mmio/VI.cpp b/src/backend/core/mmio/VI.cpp index 127732e3..9c65d477 100644 --- a/src/backend/core/mmio/VI.cpp +++ b/src/backend/core/mmio/VI.cpp @@ -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(isPal) / numHalflines; + cyclesPerHalfline = GetCyclesPerFrame(isPal) / numHalflines; } break; case 0x0440001C: { hsync = val & 0x3FF; diff --git a/src/common.hpp b/src/common.hpp index 652c68d1..91a365d4 100644 --- a/src/common.hpp +++ b/src/common.hpp @@ -15,8 +15,18 @@ using u128 = __uint128_t; using s128 = __int128_t; using m128i = __m128i; -#define N64_CPU_FREQ 93750000 -#define N64_CYCLES_PER_FRAME(pal) ((N64_CPU_FREQ) / (pal ? 50 : 60)) +#define FORCE_INLINE inline __attribute__((always_inline)) + +constexpr u32 N64_CPU_FREQ = 93750000; + +static FORCE_INLINE constexpr u32 GetCyclesPerFrame(bool pal) { + if (pal) { + return N64_CPU_FREQ / 50; + } else { + return N64_CPU_FREQ / 60; + } +} + #define HALF_ADDRESS(addr) ((addr) ^ 2) #define BYTE_ADDRESS(addr) ((addr) ^ 3) @@ -39,5 +49,4 @@ using m128i = __m128i; #define BYTE_INDEX(i) (15 - (i)) #define unlikely(exp) __builtin_expect(exp, 0) -#define likely(exp) __builtin_expect(exp, 1) -#define FORCE_INLINE inline __attribute__((always_inline)) \ No newline at end of file +#define likely(exp) __builtin_expect(exp, 1) \ No newline at end of file