mirror of
https://github.com/badvision/jace.git
synced 2024-06-26 09:29:29 +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() {
|
||||||
log("MMU Switches");
|
try {
|
||||||
synchronized (this) {
|
log("MMU Switches");
|
||||||
|
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);
|
||||||
|
@ -149,11 +156,11 @@ abstract public class RAM128k extends RAM {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
INTCXROM SLOTC3ROM C1,C2,C4-CF C3
|
INTCXROM SLOTC3ROM C1,C2,C4-CF C3
|
||||||
0 0 slot rom
|
0 0 slot rom
|
||||||
0 1 slot slot
|
0 1 slot slot
|
||||||
1 - rom rom
|
1 - rom rom
|
||||||
*/
|
*/
|
||||||
if (SoftSwitches.CXROM.getState()) {
|
if (SoftSwitches.CXROM.getState()) {
|
||||||
// Enable C1-CF to point to rom
|
// Enable C1-CF to point to rom
|
||||||
activeRead.setBanks(0, 0x0F, 0x0C1, cPageRom);
|
activeRead.setBanks(0, 0x0F, 0x0C1, cPageRom);
|
||||||
|
@ -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)
|
||||||
|
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) {
|
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