Skip to content

Commit f8f9025

Browse files
authored
Merge pull request #1795 from nicolasnoble/8mb-fixes
Some more 8mb fixes.
2 parents b2af6d9 + b89e2aa commit f8f9025

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

src/core/DynaRec_x64/recompiler.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ void DynaRecCPU::handleKernelCall() {
476476
return;
477477
}
478478

479-
const uint32_t pc = m_pc & 0x1fffff;
479+
const uint32_t pc = m_pc & PCSX::g_emulator->getRamMask();
480480
const uint32_t base = (m_pc >> 20) & 0xffc;
481481
if ((base != 0x000) && (base != 0x800) && (base != 0xa00))
482482
return; // Mask out the segment, return if not a kernel call vector

src/core/gpu.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ void PCSX::GPU::dma(uint32_t madr, uint32_t bcr, uint32_t chcr) { // GPU
533533
PSXDMA_LOG("*** DMA 2 - GPU dma chain *** %8.8lx addr = %lx size = %lx\n", chcr, madr, bcr);
534534

535535
size = gpuDmaChainSize(madr);
536-
chainedDMAWrite((uint32_t *)PCSX::g_emulator->m_mem->m_wram, madr & 0x1fffff);
536+
chainedDMAWrite((uint32_t *)PCSX::g_emulator->m_mem->m_wram, madr);
537537

538538
// Tekken 3 = use 1.0 only (not 1.5x)
539539

@@ -685,10 +685,8 @@ void PCSX::GPU::chainedDMAWrite(const uint32_t *memory, uint32_t hwAddr) {
685685

686686
s_usedAddr[0] = s_usedAddr[1] = s_usedAddr[2] = 0xffffff;
687687

688-
const bool ramExpansion = PCSX::g_emulator->settings.get<PCSX::Emulator::Setting8MB>();
689-
690688
do {
691-
addr &= ramExpansion ? 0x7ffffc : 0x1ffffc;
689+
addr &= g_emulator->getRamMask<4>();
692690

693691
if (DMACommandCounter++ > 2000000) break;
694692
if (CheckForEndlessLoop(addr)) break;

src/core/psxemulator.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424

2525
#pragma once
2626

27+
// Windows include on top
28+
#include "support/windowswrapper.h"
29+
30+
// Normal includes
2731
#include <assert.h>
2832
#include <ctype.h>
2933
#include <math.h>
@@ -45,7 +49,6 @@
4549
#include "support/strings-helpers.h"
4650

4751
#ifndef MAXPATHLEN
48-
#include "support/windowswrapper.h"
4952
#if defined(MAX_PATH)
5053
#define MAXPATHLEN MAX_PATH
5154
#elif defined(PATH_MAX)
@@ -227,6 +230,16 @@ class Emulator {
227230
uint32_t m_psxClockSpeed = 33868800 /* 33.8688 MHz */;
228231
enum { BIAS = 2 };
229232

233+
template <unsigned alignment = 1>
234+
requires((alignment == 1) || (alignment == 4))
235+
constexpr uint32_t getRamMask() {
236+
if constexpr (alignment == 1) {
237+
return settings.get<PCSX::Emulator::Setting8MB>() ? 0x7fffff : 0x1fffff;
238+
} else if constexpr (alignment == 4) {
239+
return settings.get<PCSX::Emulator::Setting8MB>() ? 0x7ffffc : 0x1ffffc;
240+
}
241+
}
242+
230243
int init();
231244
void reset();
232245
void shutdown();

src/core/r3000a.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ class R3000Acpu {
409409
public:
410410
template <bool checkPC = true>
411411
inline void InterceptBIOS(uint32_t currentPC) {
412-
const uint32_t pc = currentPC & 0x1fffff;
412+
const uint32_t pc = currentPC & g_emulator->getRamMask();
413413

414414
if constexpr (checkPC) {
415415
const uint32_t base = (currentPC >> 20) & 0xffc;

0 commit comments

Comments
 (0)