mirror of
https://github.com/badvision/lawless-legends.git
synced 2025-01-18 19:31:49 +00:00
Tweak startup behavior to prevent deadlocks on startup
This commit is contained in:
parent
99e57454d5
commit
aaa234e278
@ -131,12 +131,12 @@ public class LawlessLegends extends Application {
|
||||
observe(RAMEvent.TYPE.EXECUTE, 0x0c700, (e) -> {
|
||||
romStarted = true;
|
||||
});
|
||||
Emulator.computer.coldStart();
|
||||
Emulator.computer.invokeColdStart();
|
||||
try {
|
||||
Thread.sleep(10000);
|
||||
Thread.sleep(7500);
|
||||
if (!romStarted) {
|
||||
Logger.getLogger(getClass().getName()).log(Level.WARNING, "Boot not detected, performing a cold start");
|
||||
Emulator.computer.coldStart();
|
||||
Emulator.computer.invokeColdStart();
|
||||
}
|
||||
} catch (InterruptedException ex) {
|
||||
Logger.getLogger(LawlessLegends.class.getName()).log(Level.SEVERE, null, ex);
|
||||
|
@ -40,7 +40,7 @@ import java.util.logging.Logger;
|
||||
* @author Brendan Robert (BLuRry) brendan.robert@gmail.com
|
||||
*/
|
||||
public class Motherboard extends TimedDevice {
|
||||
|
||||
|
||||
final public Set<Device> miscDevices = Collections.synchronizedSet(new LinkedHashSet<>());
|
||||
@ConfigurableField(name = "Enable Speaker", shortName = "speaker", defaultValue = "true")
|
||||
public static boolean enableSpeaker = true;
|
||||
@ -97,11 +97,9 @@ public class Motherboard extends TimedDevice {
|
||||
clockCounter = cpuPerClock;
|
||||
computer.getVideo().doTick();
|
||||
for (Optional<Card> card : cards) {
|
||||
card.ifPresent(c -> c.doTick());
|
||||
card.ifPresent(Card::doTick);
|
||||
}
|
||||
miscDevices.stream().forEach((m) -> {
|
||||
m.doTick();
|
||||
});
|
||||
miscDevices.forEach(Device::doTick);
|
||||
} catch (Throwable t) {
|
||||
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, t);
|
||||
}
|
||||
|
@ -58,10 +58,11 @@ public abstract class TimedDevice extends Device {
|
||||
public boolean suspend() {
|
||||
disableTempMaxSpeed();
|
||||
boolean result = super.suspend();
|
||||
if (worker != null && worker.isAlive()) {
|
||||
Thread w = worker;
|
||||
if (w != null && w.isAlive()) {
|
||||
try {
|
||||
worker.interrupt();
|
||||
worker.join(1000);
|
||||
w.interrupt();
|
||||
w.join(1000);
|
||||
} catch (InterruptedException ex) {
|
||||
}
|
||||
}
|
||||
@ -118,22 +119,22 @@ public abstract class TimedDevice extends Device {
|
||||
public final int getSpeedRatio() {
|
||||
return speedRatio;
|
||||
}
|
||||
|
||||
|
||||
public final void setMaxSpeed(boolean enabled) {
|
||||
maxspeed = enabled;
|
||||
if (!enabled) {
|
||||
disableTempMaxSpeed();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public final boolean isMaxSpeed() {
|
||||
return maxspeed;
|
||||
}
|
||||
|
||||
|
||||
public final long getSpeedInHz() {
|
||||
return cyclesPerInterval * 100L;
|
||||
}
|
||||
|
||||
|
||||
public final void setSpeedInHz(long cyclesPerSecond) {
|
||||
// System.out.println("Raw set speed for " + getName() + " to " + cyclesPerSecond + "hz");
|
||||
speedRatio = (int) Math.round(cyclesPerSecond * 100.0 / defaultCyclesPerSecond());
|
||||
@ -143,16 +144,16 @@ public abstract class TimedDevice extends Device {
|
||||
cycleTimer = 0;
|
||||
resetSyncTimer();
|
||||
}
|
||||
|
||||
|
||||
public final void setSpeedInPercentage(int ratio) {
|
||||
// System.out.println("Setting " + getName() + " speed ratio to " + speedRatio);
|
||||
cyclesPerSecond = defaultCyclesPerSecond() * ratio / 100;
|
||||
if (cyclesPerSecond == 0) {
|
||||
cyclesPerSecond = defaultCyclesPerSecond();
|
||||
}
|
||||
setSpeedInHz(cyclesPerSecond);
|
||||
setSpeedInHz(cyclesPerSecond);
|
||||
}
|
||||
|
||||
|
||||
long skip = 0;
|
||||
long wait = 0;
|
||||
|
||||
|
@ -169,9 +169,8 @@ public class LawlessComputer extends Apple2e {
|
||||
try {
|
||||
for (Optional<Card> c : getMemory().getAllCards()) {
|
||||
c.ifPresent(Card::reset);
|
||||
waitForVBL();
|
||||
}
|
||||
getCpu().resume();
|
||||
waitForVBL();
|
||||
reboot();
|
||||
} catch (InterruptedException ex) {
|
||||
Logger.getLogger(LawlessComputer.class.getName()).log(Level.SEVERE, null, ex);
|
||||
|
Loading…
x
Reference in New Issue
Block a user