Smarter handling of devices, fixes video lock-up issue when switching video drivers
This commit is contained in:
parent
b7b5fb2a97
commit
4031aecfc7
|
@ -29,7 +29,6 @@ import java.util.concurrent.TimeUnit;
|
|||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import jace.LawlessLegends;
|
||||
import jace.apple2e.softswitch.VideoSoftSwitch;
|
||||
import jace.cheat.Cheats;
|
||||
import jace.config.ConfigurableField;
|
||||
|
@ -247,10 +246,6 @@ public class Apple2e extends Computer {
|
|||
getMotherboard().whileSuspended(()-> {
|
||||
// System.err.println("Reconfiguring computer...");
|
||||
if (!isMemoryConfigurationCorrect()) {
|
||||
if (getVideo() != null) {
|
||||
getVideo().suspend();
|
||||
}
|
||||
setVideo(null);
|
||||
System.out.println("Creating new ram using " + getDesiredMemoryConfiguration().getName());
|
||||
setMemory(createMemory());
|
||||
}
|
||||
|
@ -305,19 +300,7 @@ public class Apple2e extends Computer {
|
|||
}
|
||||
|
||||
if (!isVideoConfigurationCorrect()) {
|
||||
boolean resumeVideo = false;
|
||||
if (getVideo() != null) {
|
||||
resumeVideo = getVideo().suspend();
|
||||
}
|
||||
setVideo(videoRenderer.getValue().create());
|
||||
getVideo().configureVideoMode();
|
||||
getVideo().reconfigure();
|
||||
if (LawlessLegends.getApplication() != null) {
|
||||
LawlessLegends.getApplication().reconnectUIHooks();
|
||||
}
|
||||
if (resumeVideo) {
|
||||
getVideo().resume();
|
||||
}
|
||||
}
|
||||
|
||||
// Add all new cards
|
||||
|
@ -366,8 +349,8 @@ public class Apple2e extends Computer {
|
|||
if (showSpeedMonitors) {
|
||||
newDeviceSet.add(fpsCounters);
|
||||
}
|
||||
getMotherboard().attach();
|
||||
getMotherboard().setAllDevices(newDeviceSet);
|
||||
getMotherboard().attach();
|
||||
getMotherboard().reconfigure();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -125,8 +125,18 @@ public abstract class Computer implements Reconfigurable {
|
|||
}
|
||||
|
||||
final public void setVideo(Video video) {
|
||||
if (this.video != null && this.video != video) {
|
||||
getMotherboard().removeChildDevice(this.video);
|
||||
}
|
||||
this.video = video;
|
||||
if (video != null) {
|
||||
getMotherboard().addChildDevice(video);
|
||||
video.configureVideoMode();
|
||||
video.reconfigure();
|
||||
video.resume();
|
||||
}
|
||||
if (LawlessLegends.getApplication() != null) {
|
||||
LawlessLegends.getApplication().reconnectUIHooks();
|
||||
LawlessLegends.getApplication().controller.connectVideo(video);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -261,6 +261,9 @@ public abstract class Device implements Reconfigurable {
|
|||
children.forEach(Device::suspend);
|
||||
children.forEach(Device::detach);
|
||||
Keyboard.unregisterAllHandlers(this);
|
||||
if (this.isRunning()) {
|
||||
this.suspend();
|
||||
}
|
||||
isAttached = false;
|
||||
_ram = null;
|
||||
}
|
||||
|
|
|
@ -296,9 +296,12 @@ public abstract class RAM implements Reconfigurable {
|
|||
}
|
||||
|
||||
public RAMListener addListener(final RAMListener l) {
|
||||
if (l == null || listeners.contains(l)) {
|
||||
if (l == null) {
|
||||
return l;
|
||||
}
|
||||
if (listeners.contains(l)) {
|
||||
removeListener(l);
|
||||
}
|
||||
listeners.add(l);
|
||||
Emulator.whileSuspended((c)->addListenerRange(l));
|
||||
return l;
|
||||
|
|
Loading…
Reference in New Issue