Skip to content

Commit

Permalink
REU cleanup (Replaced TimeDelayed<bool> baLine by bool ba[2]
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkwhoffmann committed Sep 7, 2024
1 parent ce7f988 commit 6a34af0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
19 changes: 6 additions & 13 deletions Emulator/Media/Cartridges/CustomCartridges/Reu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ Reu::Reu(C64 &ref, isize kb) : Cartridge(ref), kb(kb)

traits.memory = KB(kb);
setRamCapacity(KB(kb));

baLine.setClock(&cpu.clock);
}

void
Expand Down Expand Up @@ -493,9 +491,10 @@ Reu::execute(EventID id)
case EXP_REU_SWAP:
case EXP_REU_VERIFY:
{
trace(REU_DEBUG > 3, "%d%d%d : ", baLine.readWithDelay(2), baLine.readWithDelay(1), baLine.readWithDelay(3));
trace(REU_DEBUG > 3, "%d%d : ", ba[1], ba[0]);

// Only proceed if the bus is available
if (!busIsAvailable(id)) { // baLine.readWithDelay(0) && baLine.readWithDelay(1)) {
if (!busIsAvailable(id)) {

if (REU_DEBUG > 3) printf("BLOCKED\n");
break;
Expand Down Expand Up @@ -555,10 +554,10 @@ Reu::execute(EventID id)
void
Reu::sniffBA()
{
// TODO: Eliminate static variable. Will break multiple emulator instances
static bool earlyDma = false;

// Scan the BA line
auto current = !!vic.baLine.current();
ba[0] = vic.baLine.readWithDelay(0);
ba[1] = vic.baLine.readWithDelay(1);

Expand All @@ -572,13 +571,7 @@ Reu::sniffBA()
* for CPU it doesn't matter, because it checks later in cycle.
* REU seems to check this sooner and can't recognize BA in this special cycle."
*/
if (c64.rasterCycle == 55 && earlyDma) { current = false; ba[0] = false; }

// Feed the pipe
baLine.write(current);

// Return delayed value
// return baLine.readWithDelay(1);
if (c64.rasterCycle == 55 && earlyDma) { ba[0] = false; }
}

bool
Expand All @@ -595,7 +588,7 @@ Reu::busIsAvailable(EventID id) const
case EXP_REU_SWAP:
case EXP_REU_VERIFY:

return !(baLine.readWithDelay(1));
return !ba[1];

default:
fatalError;
Expand Down
8 changes: 3 additions & 5 deletions Emulator/Media/Cartridges/CustomCartridges/Reu.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ class Reu final : public Cartridge {
// Flipflop used to control the swap operation
bool swapff = false;

// Experimental
TimeDelayed<bool,3> baLine = TimeDelayed <bool,3> ();

// Last to values of the BA line as seen by the REU
bool ba[2];

//
Expand Down Expand Up @@ -173,7 +171,7 @@ class Reu final : public Cartridge {
CLONE(c64Val)
CLONE(reuVal)
CLONE(swapff)
CLONE(baLine)
CLONE_ARRAY(ba)

CLONE(upperBankBits)
CLONE(bus)
Expand Down Expand Up @@ -208,7 +206,7 @@ class Reu final : public Cartridge {
<< c64Val
<< reuVal
<< swapff
<< baLine
<< ba

<< upperBankBits
<< bus
Expand Down

0 comments on commit 6a34af0

Please sign in to comment.