Adjust behaviors during boot, also adjust joystick for Boulder Dash bugfix

This commit is contained in:
Brendan Robert 2024-03-24 16:38:18 -05:00
parent 9a38fe972b
commit 2ca93fc26e
7 changed files with 37 additions and 14 deletions

View File

@ -63,7 +63,7 @@ public class LawlessLegends extends Application {
}
primaryStage.show();
Platform.runLater(() -> new Thread(() -> {
new Thread(() -> {
Emulator.getInstance(getParameters().getRaw());
Emulator.withComputer(c-> {
((LawlessComputer)c).initLawlessLegendsConfiguration();
@ -84,7 +84,7 @@ public class LawlessLegends extends Application {
Thread.onSpinWait();
}
bootWatchdog();
}).start());
}).start();
primaryStage.setOnCloseRequest(event -> {
Emulator.withComputer(Computer::deactivate);
Platform.exit();
@ -188,6 +188,7 @@ public class LawlessLegends extends Application {
private void configureEmulatorForGame() {
Emulator.withComputer(c -> {
System.out.println("CONFIUGRE EMULATOR START");
c.enableHints = false;
c.clockEnabled = true;
c.joy1enabled = false;
@ -207,6 +208,7 @@ public class LawlessLegends extends Application {
if (c.PRODUCTION_MODE) {
((LawlessImageTool) c.getUpgradeHandler()).loadGame();
}
System.out.println("CONFIUGRE EMULATOR END");
});
}
}

View File

@ -63,7 +63,7 @@ public class Apple2e extends Computer {
static int IRQ_VECTOR = 0x003F2;
@ConfigurableField(name = "Production mode", shortName = "production")
public boolean PRODUCTION_MODE = false;
public boolean PRODUCTION_MODE = true;
@ConfigurableField(name = "Slot 1", shortName = "s1card")
public DeviceSelection<Cards> card1 = new DeviceSelection<>(Cards.class, null);
@ConfigurableField(name = "Slot 2", shortName = "s2card")

View File

@ -133,7 +133,6 @@ public abstract class Computer implements Reconfigurable {
getMotherboard().addChildDevice(video);
video.configureVideoMode();
video.reconfigure();
video.resume();
}
if (LawlessLegends.getApplication() != null) {
LawlessLegends.getApplication().reconnectUIHooks();

View File

@ -105,10 +105,6 @@ public abstract class Device implements Reconfigurable {
newDevices.stream().filter(d-> !children.contains(d)).forEach(this::addChildDevice);
}
public boolean getRunningProperty() {
return run;
}
public void addWaitCycles(int wait) {
waitCycles += wait;
}
@ -170,11 +166,19 @@ public abstract class Device implements Reconfigurable {
}
public final synchronized void setRun(boolean run) {
// if (this.run != run) {
// System.out.println(getDeviceName() + " " + (run ? "RUN" : "STOP"));
// Thread.dumpStack();
// }
this.run = run;
updateTickHandler();
}
public synchronized void setPaused(boolean paused) {
// if (this.paused != paused) {
// System.out.println(getDeviceName() + " " + (paused ? "PAUSED" : "UNPAUSED"));
// Thread.dumpStack();
// }
this.paused = paused;
updateTickHandler();
}

View File

@ -336,8 +336,8 @@ public class Joystick extends Device {
// We have to let the joystick go a little further in the positive direction
// because boulderdash is a little too sensitive!
x = Math.max(-1.0f, Math.min(1.1f, x * sensitivity));
y = Math.max(-1.0f, Math.min(1.1f, y * sensitivity));
x = Math.max(-1.0f, Math.min(1.0f, x * sensitivity));
y = Math.max(-1.0f, Math.min(1.0f, y * sensitivity));
joyX = (int) (x * 128.0 + 128.0);
joyY = (int) (y * 128.0 + 128.0);
@ -595,6 +595,14 @@ public class Joystick extends Device {
public void initJoystickRead(RAMEvent e) {
readJoystick();
xSwitch.setState(true);
// Some games just suck and don't want to read the joystick properly
// Use larger-than-necessary values to try to get around this
if (joyX >= 254) {
joyX = 280;
}
if (joyY >= 255) {
joyY = 280;
}
x = 10 + joyX * 11;
ySwitch.setState(true);
y = 10 + joyY * 11;

View File

@ -29,6 +29,7 @@ import java.util.logging.Logger;
import jace.Emulator;
import jace.apple2e.MOS65C02;
import jace.apple2e.SoftSwitches;
import jace.core.RAM;
import jace.hardware.ProdosDriver.MLI_COMMAND_TYPE;
@ -106,7 +107,7 @@ public class LargeDisk implements IDisk {
@Override
public void boot0(int slot) {
Emulator.withComputer(c->
c.getCpu().whileSuspended(()->{
c.getCpu().whilePaused(()->{
try {
// System.out.println("Loading boot0 to $800");
mliRead(0, 0x0800);
@ -117,6 +118,16 @@ public class LargeDisk implements IDisk {
// System.out.println("X = "+Integer.toHexString(slot16));
((MOS65C02) c.getCpu()).X = slot16;
RAM memory = c.getMemory();
SoftSwitches.AUXZP.getSwitch().setState(false);
SoftSwitches.LCBANK1.getSwitch().setState(false);
SoftSwitches.LCRAM.getSwitch().setState(false);
SoftSwitches.LCWRITE.getSwitch().setState(true);
SoftSwitches.RAMRD.getSwitch().setState(false);
SoftSwitches.RAMWRT.getSwitch().setState(false);
SoftSwitches.CXROM.getSwitch().setState(false);
SoftSwitches.SLOTC3ROM.getSwitch().setState(false);
SoftSwitches.INTC8ROM.getSwitch().setState(false);
memory.write(CardMassStorage.SLT16, slot16, false, false);
memory.write(MLI_COMMAND, (byte) MLI_COMMAND_TYPE.READ.intValue, false, false);
memory.write(MLI_UNITNUMBER, slot16, false, false);

View File

@ -39,7 +39,7 @@ public class LawlessComputer extends Apple2e {
this.cheatEngine.setValue(Cheats.Cheat.LawlessHacks);
}
blankTextPage1();
reconfigure();
reconfigure();
}
private void blankTextPage1() {
@ -109,9 +109,8 @@ public class LawlessComputer extends Apple2e {
Logger.getLogger(LawlessComputer.class.getName()).log(Level.SEVERE, null, ex);
}
}
getCpu().setPaused(false);
finishColdStart();
getCpu().setPaused(false);
}
private void renderWithMask(int... mask) throws InterruptedException {