Skip to content

Commit

Permalink
Passing VICE test REU/cpuport.prg
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkwhoffmann committed Sep 2, 2024
1 parent 8f1f46c commit 0689492
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
24 changes: 18 additions & 6 deletions Emulator/Media/Cartridges/CustomCartridges/Reu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,18 @@ Reu::poke(u16 addr, u8 value)
}
}

u8
Reu::readFromC64Ram(u16 addr)
{
return addr <= 2 ? mem.peek(addr, M_RAM) : mem.peek(addr);
}

void
Reu::writeToC64Ram(u16 addr, u8 value)
{
addr <= 2 ? mem.poke(addr, value, M_RAM) : mem.poke(addr, value);
}

u8
Reu::readFromReuRam(u32 addr)
{
Expand All @@ -328,7 +340,7 @@ Reu::writeToReuRam(u32 addr, u8 value)
}
}

void
void
Reu::prepareDma()
{
if (REU_DEBUG) { dump(Category::Dma, std::cout); }
Expand All @@ -353,7 +365,7 @@ Reu::doDma(EventID id)

case EXP_REU_STASH:

c64Val = mem.peek(c64Addr);
c64Val = readFromC64Ram(c64Addr);
writeToReuRam(reuAddr, c64Val);

// debug(REU_DEBUG,"(%x, %02x) -> %x\n", memAddr, c64Val, reuAddr);
Expand All @@ -365,7 +377,7 @@ Reu::doDma(EventID id)
case EXP_REU_FETCH:

reuVal = readFromReuRam(reuAddr);
mem.poke(c64Addr, reuVal);
writeToC64Ram(c64Addr, reuVal);

// debug(REU_DEBUG,"%x <- (%x, %02x)\n", memAddr, reuAddr, reuVal);

Expand All @@ -375,10 +387,10 @@ Reu::doDma(EventID id)

case EXP_REU_SWAP:

c64Val = mem.peek(c64Addr);
c64Val = readFromC64Ram(c64Addr);
reuVal = readFromReuRam(reuAddr);

mem.poke(c64Addr, reuVal);
writeToC64Ram(c64Addr, reuVal);
writeToReuRam(reuAddr, c64Val);

if (memStep()) incMemAddr(c64Addr);
Expand All @@ -387,7 +399,7 @@ Reu::doDma(EventID id)

case EXP_REU_VERIFY:

c64Val = mem.peek(c64Addr);
c64Val = readFromC64Ram(c64Addr);
reuVal = readFromReuRam(reuAddr);

if (c64Val != reuVal) {
Expand Down
5 changes: 4 additions & 1 deletion Emulator/Media/Cartridges/CustomCartridges/Reu.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class Reu final : public Cartridge {


//
// Accessing cartridge memory
// Accessing memory
//

public:
Expand All @@ -206,6 +206,9 @@ class Reu final : public Cartridge {

private:

u8 readFromC64Ram(u16 addr);
void writeToC64Ram(u16 addr, u8 value);

u8 readFromReuRam(u32 addr);
void writeToReuRam(u32 addr, u8 value);

Expand Down

0 comments on commit 0689492

Please sign in to comment.