Yucky hack to reset ram pattern even on warm boot, fixes rebooting glitches due to uninitalized engine state variables.

This commit is contained in:
Brendan Robert 2020-06-01 09:10:45 -05:00
parent a81852294b
commit 68d12365d6
2 changed files with 19 additions and 14 deletions

View File

@ -31,7 +31,6 @@ import jace.core.RAM;
import jace.core.RAMEvent;
import jace.core.RAMListener;
import jace.core.Utility;
import jace.state.Stateful;
import jace.core.Video;
import jace.hardware.CardDiskII;
import jace.hardware.CardExt80Col;
@ -40,6 +39,7 @@ import jace.hardware.Joystick;
import jace.hardware.NoSlotClock;
import jace.hardware.ZipWarpAccelerator;
import jace.hardware.massStorage.CardMassStorage;
import jace.state.Stateful;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
@ -163,6 +163,8 @@ public class Apple2e extends Computer {
@Override
public void warmStart() {
boolean restart = pause();
// This isn't really authentic behavior but sometimes games like memory to have a consistent state when booting.
((RAM128k)getMemory()).zeroAllRam();
for (SoftSwitches s : SoftSwitches.values()) {
if (! (s.getSwitch() instanceof VideoSoftSwitch)) {
s.getSwitch().reset();

View File

@ -129,12 +129,7 @@ abstract public class RAM128k extends RAM {
activeRead = new PagedMemory(0x10000, PagedMemory.Type.RAM, computer);
activeWrite = new PagedMemory(0x10000, PagedMemory.Type.RAM, computer);
blank = new PagedMemory(0x100, PagedMemory.Type.RAM, computer);
// Format memory with FF FF 00 00 pattern
for (int i = 0; i < 0x0100; i++) {
blank.get(0)[i] = (byte) 0x0FF;
}
initMemoryPattern(mainMemory);
zeroAllRam();
}
public final void initMemoryPattern(PagedMemory mem) {
@ -147,6 +142,14 @@ abstract public class RAM128k extends RAM {
}
}
public final void zeroAllRam() {
// Format memory with FF FF 00 00 pattern
for (int i = 0; i < 0x0100; i++) {
blank.get(0)[i] = (byte) 0x0FF;
}
initMemoryPattern(mainMemory);
}
private final Semaphore configurationSemaphone = new Semaphore(1, true);
/**