Skip to content
Snippets Groups Projects
Commit 688bc87f authored by Geo Ster's avatar Geo Ster
Browse files

Fix bugged scratchpad reads/writes

* Looking at the console output introduced in the previous commit, it
was obvious that it was very wrong. Booting the same BIOS file with PCSX2
reports: Initialize memory (rev:3.17, ctm:393Mhz, cpuclk:295Mhz )

* It turns out that the problem wasn't with the CPU, but the string printing
function. The BIOS writes the numbers it calculates to the scratchpad and
the print function reads them from there. But there were 2 issues with the
current implementation

1. addr & 0x3FFC is ignoring the last 2 bits which makes 8bit writes/reads
broken.

2. Always casting to uint32_t* instead of the type provided T* results in
byte write overriding whole 32bit sections of the scratchpad, destroying
critical data.
parent c4c3a1ff
No related branches found
No related tags found
No related merge requests found
......@@ -104,7 +104,7 @@ template <typename T>
T EmotionEngine::read(uint32_t addr)
{
if (addr >= 0x70000000 && addr < 0x70004000) /* Read from scratchpad */
return *(uint32_t*)&scratchpad[addr & 0x3FFC];
return *(T*)&scratchpad[addr & 0x3FFF];
else
return manager->read<T>(addr);
}
......@@ -113,7 +113,7 @@ template <typename T>
void EmotionEngine::write(uint32_t addr, T data)
{
if (addr >= 0x70000000 && addr < 0x70004000)
*(uint32_t*)&scratchpad[addr & 0x3FFC] = data;
*(T*)&scratchpad[addr & 0x3FFF] = data;
else
manager->write<T>(addr, data);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment