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 java.io.IOException;
|
||||
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
|
||||
@ -35,6 +38,7 @@ import java.io.InputStream;
|
||||
*/
|
||||
@Stateful
|
||||
abstract public class RAM128k extends RAM {
|
||||
|
||||
@Stateful
|
||||
public PagedMemory mainMemory;
|
||||
@Stateful
|
||||
@ -73,13 +77,16 @@ abstract public class RAM128k extends RAM {
|
||||
}
|
||||
}
|
||||
|
||||
private final Semaphore configurationSemaphone = new Semaphore(1, true);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void configureActiveMemory() {
|
||||
log("MMU Switches");
|
||||
synchronized (this) {
|
||||
try {
|
||||
log("MMU Switches");
|
||||
configurationSemaphone.acquire();
|
||||
// First off, set up read/write for main memory (might get changed later on)
|
||||
activeRead.fillBanks(SoftSwitches.RAMRD.getState() ? getAuxMemory() : mainMemory);
|
||||
activeWrite.fillBanks(SoftSwitches.RAMWRT.getState() ? getAuxMemory() : mainMemory);
|
||||
@ -149,11 +156,11 @@ abstract public class RAM128k extends RAM {
|
||||
}
|
||||
|
||||
/*
|
||||
INTCXROM SLOTC3ROM C1,C2,C4-CF C3
|
||||
0 0 slot rom
|
||||
0 1 slot slot
|
||||
1 - rom rom
|
||||
*/
|
||||
INTCXROM SLOTC3ROM C1,C2,C4-CF C3
|
||||
0 0 slot rom
|
||||
0 1 slot slot
|
||||
1 - rom rom
|
||||
*/
|
||||
if (SoftSwitches.CXROM.getState()) {
|
||||
// Enable C1-CF to point to rom
|
||||
activeRead.setBanks(0, 0x0F, 0x0C1, cPageRom);
|
||||
@ -168,7 +175,7 @@ abstract public class RAM128k extends RAM {
|
||||
activeRead.set(i, blank.get(0));
|
||||
}
|
||||
} 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()) {
|
||||
// Enable C3 to point to internal ROM
|
||||
@ -179,9 +186,12 @@ abstract public class RAM128k extends RAM {
|
||||
activeRead.setBanks(7, 8, 0x0C8, cPageRom);
|
||||
}
|
||||
}
|
||||
// All ROM reads not intecepted will return 0xFF! (TODO: floating bus)
|
||||
activeRead.set(0x0c0, blank.get(0));
|
||||
configurationSemaphone.release();
|
||||
} catch (InterruptedException ex) {
|
||||
Logger.getLogger(RAM128k.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
// All ROM reads not intecepted will return 0xFF! (TODO: floating bus)
|
||||
activeRead.set(0x0c0, blank.get(0));
|
||||
}
|
||||
|
||||
public void log(String message) {
|
||||
@ -234,8 +244,11 @@ abstract public class RAM128k extends RAM {
|
||||
}
|
||||
|
||||
abstract public PagedMemory getAuxVideoMemory();
|
||||
|
||||
abstract public PagedMemory getAuxMemory();
|
||||
|
||||
abstract public PagedMemory getAuxLanguageCard();
|
||||
|
||||
abstract public PagedMemory getAuxLanguageCard2();
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user