Updated packer to build on modern java

This commit is contained in:
brobert@adobe.com 2025-03-10 17:37:01 -05:00
parent c88c6affd7
commit 8a57e7e2d5
8 changed files with 57 additions and 24 deletions

4
.gitignore vendored
View File

@ -64,6 +64,10 @@ error_stack.txt
# Hey, don't include the commercial game data you ninny!
/Platform/Apple/tools/jace/src/main/resources/jace/data/game.2mg
Platform/Apple/tools/PackPartitions/game*
Platform/Apple/tools/PackPartitions/font*
Platform/Apple/tools/PackPartitions/pack_report.txt
Platform/Apple/tools/PackPartitions/world.xml
# Ignore NetBeans project files
Platform/Apple/tools/jace/nb-configuration.xml

View File

@ -5,7 +5,7 @@
<!-- override javasdoc target, since we have no Java sources -->
<target depends="init" description="Don't build Javadoc." name="javadoc"/>
<!-- use local groovy jar instead of NetBeans' version -->
<property name="libs.groovy-all.classpath" value="./lib/groovy-4.0.13.jar:./lib/groovy-ant-4.0.13.jar:./lib/groovy-xml-4.0.13.jar:./lib/groovy-json-4.0.13.jar"/>
<property name="libs.groovy-all.classpath" value="./lib/groovy-4.0.24.jar:./lib/groovy-ant-4.0.24.jar:./lib/groovy-xml-4.0.24.jar:./lib/groovy-json-4.0.24.jar"/>
<!-- put the current time/date into a file for engine timestamping -->
<exec executable="date" output="dist/tstamp.txt">
<arg value="+%s000"/>
@ -19,9 +19,9 @@
<zipfileset src="../ACME/src/acme.jar"/>
<zipfileset src="../A2Copy/dist/A2Copy.jar"/>
<zipfileset src="../A2Copy/lib/ac.jar"/>
<zipfileset src="./lib/groovy-4.0.13.jar"/>
<zipfileset src="./lib/groovy-xml-4.0.13.jar"/>
<zipfileset src="./lib/groovy-json-4.0.13.jar"/>
<zipfileset src="./lib/groovy-4.0.24.jar"/>
<zipfileset src="./lib/groovy-xml-4.0.24.jar"/>
<zipfileset src="./lib/groovy-json-4.0.24.jar"/>
<zipfileset src="dist/${application.title}-thin.jar" />
<manifest>
<attribute name="Main-Class" value="org.badvision.A2PackPartitions"/>

View File

@ -136,7 +136,10 @@ public abstract class TimedDevice extends Device {
}
public final void setSpeedInHz(long newSpeed) {
// System.out.println("Raw set speed for " + getName() + " to " + cyclesPerSecond + "hz");
// If the speed has actually changed, log it
// if (newSpeed != cyclesPerSecond) {
// System.out.println("Raw set speed for " + getName() + " to " + cyclesPerSecond + "hz");
// }
// Thread.dumpStack();
cyclesPerSecond = newSpeed;
speedRatio = (int) Math.round(cyclesPerSecond * 100.0 / defaultCyclesPerSecond());

View File

@ -17,6 +17,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import jace.Emulator;
import jace.apple2e.MOS65C02;
import jace.apple2e.SoftSwitches;
import jace.apple2e.VideoDHGR;
import jace.cheat.Cheats;
@ -35,6 +36,7 @@ public class LawlessHacks extends Cheats {
int MODE_SOFTSWITCH_MIN = 0x0C049;
int MODE_SOFTSWITCH_MAX = 0x0C04F;
int SFX_TRIGGER = 0x0C069;
double PORTRAIT_SPEED = 1.0;
public LawlessHacks() {
super();
@ -123,8 +125,11 @@ public class LawlessHacks extends Cheats {
long lastKeyStatus = 0;
long lastKnownSpeed = -1;
boolean isCurrentlyMaxSpeed = false;
long keyEventTraceDuration = 0;
private void adjustAnimationSpeed(RAMEvent e) {
int pc = Emulator.withComputer(c->c.getCpu().getProgramCounter(), 0);
int eventAddress = e.getAddress();
if (DEBUG) {
keyReadAddresses.put(pc, keyReadAddresses.getOrDefault(pc, 0) + 1);
if ((System.currentTimeMillis() - lastKeyStatus) >= 10000) {
@ -135,29 +140,50 @@ public class LawlessHacks extends Cheats {
});
}
}
Motherboard m = Emulator.withComputer(Computer::getMotherboard, null);
long currentSpeed = m.getSpeedInHz();
if (pc == 0x0D5FE) {
long slowerSpeed = (long) (TimedDevice.NTSC_1MHZ * 1.5);
// We are waiting for a key in portait mode, slow to 1.5x
if (currentSpeed > slowerSpeed || m.isMaxSpeedEnabled()) {
lastKnownSpeed = currentSpeed;
isCurrentlyMaxSpeed = m.isMaxSpeedEnabled();
m.setSpeedInHz(slowerSpeed);
m.setMaxSpeed(false);
m.cancelSpeedRequest(this);
}
} else {
// We're in some other mode, go back the default speed
if (currentSpeed < lastKnownSpeed || isCurrentlyMaxSpeed) {
m.setSpeedInHz(lastKnownSpeed);
m.setMaxSpeed(isCurrentlyMaxSpeed);
isCurrentlyMaxSpeed = false;
lastKnownSpeed = -1;
if (eventAddress == 0x0c000 && pc == 0x0D5FE) {
// We are waiting for a key in portait mode
// Check where we were called from in the stack
MOS65C02 cpu = (MOS65C02) Emulator.withComputer(c->c.getCpu(), null);
int stackAddr1 = 0x0100 + cpu.STACK;
int lastStackByte = Emulator.withMemory(ram-> ram.readRaw(stackAddr1), (byte) 0) & 0x0ff;
if (lastStackByte == 0x09b) {
// Turns out the last value on the stack is consistently
// the same value whenever we also want to be running in a
// slower speed for animation, but not in other key read
// routines where we're needing more speed. Convenient!
beginSlowdown();
} else {
endSlowdown();
}
}
}
public void beginSlowdown() {
Motherboard m = Emulator.withComputer(Computer::getMotherboard, null);
long slowerSpeed = (long) (TimedDevice.NTSC_1MHZ * PORTRAIT_SPEED);
long currentSpeed = m.getSpeedInHz();
if (currentSpeed > slowerSpeed || m.isMaxSpeedEnabled()) {
lastKnownSpeed = currentSpeed;
isCurrentlyMaxSpeed = m.isMaxSpeedEnabled();
m.setSpeedInHz(slowerSpeed);
m.setMaxSpeed(false);
m.cancelSpeedRequest(this);
}
}
public void endSlowdown() {
Motherboard m = Emulator.withComputer(Computer::getMotherboard, null);
long currentSpeed = m.getSpeedInHz();
if ((currentSpeed < lastKnownSpeed || isCurrentlyMaxSpeed)) {
m.setSpeedInHz(lastKnownSpeed);
m.setMaxSpeed(isCurrentlyMaxSpeed);
isCurrentlyMaxSpeed = false;
lastKnownSpeed = -1;
}
}
public static final String SCORE_NONE = "none";
public static final String SCORE_COMMON = "common";
public static final String SCORE_ORCHESTRAL = "8-bit orchestral samples";