mirror of
https://github.com/badvision/jace.git
synced 2024-11-28 10:52:33 +00:00
Switched synchronization to use a semaphore when reconfiguring memory banks
This commit is contained in:
parent
4c073cca6a
commit
98fd203305
@ -26,6 +26,9 @@ import jace.core.RAM;
|
|||||||
import jace.state.Stateful;
|
import jace.state.Stateful;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.util.concurrent.Semaphore;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of a 128k memory space and the MMU found in an Apple //e. The
|
* Implementation of a 128k memory space and the MMU found in an Apple //e. The
|
||||||
@ -35,6 +38,7 @@ import java.io.InputStream;
|
|||||||
*/
|
*/
|
||||||
@Stateful
|
@Stateful
|
||||||
abstract public class RAM128k extends RAM {
|
abstract public class RAM128k extends RAM {
|
||||||
|
|
||||||
@Stateful
|
@Stateful
|
||||||
public PagedMemory mainMemory;
|
public PagedMemory mainMemory;
|
||||||
@Stateful
|
@Stateful
|
||||||
@ -73,13 +77,16 @@ abstract public class RAM128k extends RAM {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final Semaphore configurationSemaphone = new Semaphore(1, true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void configureActiveMemory() {
|
public void configureActiveMemory() {
|
||||||
|
try {
|
||||||
log("MMU Switches");
|
log("MMU Switches");
|
||||||
synchronized (this) {
|
configurationSemaphone.acquire();
|
||||||
// First off, set up read/write for main memory (might get changed later on)
|
// First off, set up read/write for main memory (might get changed later on)
|
||||||
activeRead.fillBanks(SoftSwitches.RAMRD.getState() ? getAuxMemory() : mainMemory);
|
activeRead.fillBanks(SoftSwitches.RAMRD.getState() ? getAuxMemory() : mainMemory);
|
||||||
activeWrite.fillBanks(SoftSwitches.RAMWRT.getState() ? getAuxMemory() : mainMemory);
|
activeWrite.fillBanks(SoftSwitches.RAMWRT.getState() ? getAuxMemory() : mainMemory);
|
||||||
@ -168,7 +175,7 @@ abstract public class RAM128k extends RAM {
|
|||||||
activeRead.set(i, blank.get(0));
|
activeRead.set(i, blank.get(0));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
getCard(getActiveSlot()).ifPresent(c -> activeRead.setBanks(0,8,0x0c8, c.getC8Rom()));
|
getCard(getActiveSlot()).ifPresent(c -> activeRead.setBanks(0, 8, 0x0c8, c.getC8Rom()));
|
||||||
}
|
}
|
||||||
if (SoftSwitches.SLOTC3ROM.isOff()) {
|
if (SoftSwitches.SLOTC3ROM.isOff()) {
|
||||||
// Enable C3 to point to internal ROM
|
// Enable C3 to point to internal ROM
|
||||||
@ -179,9 +186,12 @@ abstract public class RAM128k extends RAM {
|
|||||||
activeRead.setBanks(7, 8, 0x0C8, cPageRom);
|
activeRead.setBanks(7, 8, 0x0C8, cPageRom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// All ROM reads not intecepted will return 0xFF! (TODO: floating bus)
|
// All ROM reads not intecepted will return 0xFF! (TODO: floating bus)
|
||||||
activeRead.set(0x0c0, blank.get(0));
|
activeRead.set(0x0c0, blank.get(0));
|
||||||
|
configurationSemaphone.release();
|
||||||
|
} catch (InterruptedException ex) {
|
||||||
|
Logger.getLogger(RAM128k.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void log(String message) {
|
public void log(String message) {
|
||||||
@ -234,8 +244,11 @@ abstract public class RAM128k extends RAM {
|
|||||||
}
|
}
|
||||||
|
|
||||||
abstract public PagedMemory getAuxVideoMemory();
|
abstract public PagedMemory getAuxVideoMemory();
|
||||||
|
|
||||||
abstract public PagedMemory getAuxMemory();
|
abstract public PagedMemory getAuxMemory();
|
||||||
|
|
||||||
abstract public PagedMemory getAuxLanguageCard();
|
abstract public PagedMemory getAuxLanguageCard();
|
||||||
|
|
||||||
abstract public PagedMemory getAuxLanguageCard2();
|
abstract public PagedMemory getAuxLanguageCard2();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user