Skip to content

Commit

Permalink
Merge pull request #1795 from nicolasnoble/8mb-fixes
Browse files Browse the repository at this point in the history
Some more 8mb fixes.
  • Loading branch information
nicolasnoble authored Nov 5, 2024
2 parents b2af6d9 + b89e2aa commit f8f9025
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/core/DynaRec_x64/recompiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ void DynaRecCPU::handleKernelCall() {
return;
}

const uint32_t pc = m_pc & 0x1fffff;
const uint32_t pc = m_pc & PCSX::g_emulator->getRamMask();
const uint32_t base = (m_pc >> 20) & 0xffc;
if ((base != 0x000) && (base != 0x800) && (base != 0xa00))
return; // Mask out the segment, return if not a kernel call vector
Expand Down
6 changes: 2 additions & 4 deletions src/core/gpu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ void PCSX::GPU::dma(uint32_t madr, uint32_t bcr, uint32_t chcr) { // GPU
PSXDMA_LOG("*** DMA 2 - GPU dma chain *** %8.8lx addr = %lx size = %lx\n", chcr, madr, bcr);

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

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

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

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

const bool ramExpansion = PCSX::g_emulator->settings.get<PCSX::Emulator::Setting8MB>();

do {
addr &= ramExpansion ? 0x7ffffc : 0x1ffffc;
addr &= g_emulator->getRamMask<4>();

if (DMACommandCounter++ > 2000000) break;
if (CheckForEndlessLoop(addr)) break;
Expand Down
15 changes: 14 additions & 1 deletion src/core/psxemulator.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@

#pragma once

// Windows include on top
#include "support/windowswrapper.h"

// Normal includes
#include <assert.h>
#include <ctype.h>
#include <math.h>
Expand All @@ -45,7 +49,6 @@
#include "support/strings-helpers.h"

#ifndef MAXPATHLEN
#include "support/windowswrapper.h"
#if defined(MAX_PATH)
#define MAXPATHLEN MAX_PATH
#elif defined(PATH_MAX)
Expand Down Expand Up @@ -227,6 +230,16 @@ class Emulator {
uint32_t m_psxClockSpeed = 33868800 /* 33.8688 MHz */;
enum { BIAS = 2 };

template <unsigned alignment = 1>
requires((alignment == 1) || (alignment == 4))
constexpr uint32_t getRamMask() {
if constexpr (alignment == 1) {
return settings.get<PCSX::Emulator::Setting8MB>() ? 0x7fffff : 0x1fffff;
} else if constexpr (alignment == 4) {
return settings.get<PCSX::Emulator::Setting8MB>() ? 0x7ffffc : 0x1ffffc;
}
}

int init();
void reset();
void shutdown();
Expand Down
2 changes: 1 addition & 1 deletion src/core/r3000a.h
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ class R3000Acpu {
public:
template <bool checkPC = true>
inline void InterceptBIOS(uint32_t currentPC) {
const uint32_t pc = currentPC & 0x1fffff;
const uint32_t pc = currentPC & g_emulator->getRamMask();

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

0 comments on commit f8f9025

Please sign in to comment.