Fix wolfenstein cheats for new version

This commit is contained in:
Brendan Robert 2024-07-01 11:29:24 -05:00
parent 2155fe02e6
commit e3b2484ec2
2 changed files with 35 additions and 39 deletions

View File

@ -38,7 +38,8 @@ public abstract class Cheats extends Device {
Metacheat("Metacheat", MetaCheat.class, MetaCheat::new), Metacheat("Metacheat", MetaCheat.class, MetaCheat::new),
MontezumasRevenge("Montezuma's Revenge", MontezumasRevengeCheats.class, MontezumasRevengeCheats::new), MontezumasRevenge("Montezuma's Revenge", MontezumasRevengeCheats.class, MontezumasRevengeCheats::new),
PrinceOfPersia("Prince of Persia", PrinceOfPersiaCheats.class, PrinceOfPersiaCheats::new), PrinceOfPersia("Prince of Persia", PrinceOfPersiaCheats.class, PrinceOfPersiaCheats::new),
ProgramIdentity("Identify program", ProgramIdentity.class, ProgramIdentity::new); ProgramIdentity("Identify program", ProgramIdentity.class, ProgramIdentity::new),
Wolfenstein(name:"Wolfenstein", WolfensteinCheats.class, WolfensteinCheats::new);
Supplier<Cheats> factory; Supplier<Cheats> factory;
String name; String name;

View File

@ -15,10 +15,9 @@
*/ */
package jace.cheat; package jace.cheat;
import jace.Emulator;
import jace.EmulatorUILogic; import jace.EmulatorUILogic;
import jace.apple2e.MOS65C02;
import jace.config.ConfigurableField; import jace.config.ConfigurableField;
import jace.core.Computer;
import jace.core.RAMEvent; import jace.core.RAMEvent;
import javafx.event.EventHandler; import javafx.event.EventHandler;
import javafx.scene.Node; import javafx.scene.Node;
@ -56,10 +55,6 @@ public class WolfensteinCheats extends Cheats {
static final int DOOR = 80; static final int DOOR = 80;
static final int NOTHING = 0; static final int NOTHING = 0;
public WolfensteinCheats(Computer computer) {
super(computer);
}
private EventHandler<MouseEvent> mouseListener = this::processMouseEvent; private EventHandler<MouseEvent> mouseListener = this::processMouseEvent;
@ConfigurableField(category = "Hack", name = "Beyond Wolfenstein", defaultValue = "false", description = "Make sure cheats work with Beyond Wolfenstein") @ConfigurableField(category = "Hack", name = "Beyond Wolfenstein", defaultValue = "false", description = "Make sure cheats work with Beyond Wolfenstein")
public static boolean _isBeyondWolfenstein = false; public static boolean _isBeyondWolfenstein = false;
@ -102,57 +97,57 @@ public class WolfensteinCheats extends Cheats {
if (_isBeyondWolfenstein) { if (_isBeyondWolfenstein) {
// Only work in Beyond Wolfenstein // Only work in Beyond Wolfenstein
if (rich) { if (rich) {
forceValue(MARKS, 255); forceValue("Wolfenstein Money cheat", MARKS, 255);
} }
if (dayAtTheOffice) { if (dayAtTheOffice) {
for (int i = 0x04080; i < 0x04100; i += 0x010) { for (int i = 0x04080; i < 0x04100; i += 0x010) {
addCheat(RAMEvent.TYPE.READ, this::allDesks, i); addCheat("Wolfenstein day at the office cheat " + i, RAMEvent.TYPE.READ, this::allDesks, i);
} }
} }
} else { } else {
// Only work in the first Wolfenstein game // Only work in the first Wolfenstein game
if (uniform) { if (uniform) {
forceValue(255, 0x04349); forceValue("Wolfenstein Uniform cheat", 255, 0x04349);
} }
if (vest) { if (vest) {
forceValue(255, 0x0434A); forceValue("Wolfenstein Vest cheat", 255, 0x0434A);
} }
if (fastOpen) { if (fastOpen) {
addCheat(RAMEvent.TYPE.WRITE, this::fastOpenHandler, 0x04351); addCheat("Wolfenstein FastOpen cheat (1)", RAMEvent.TYPE.WRITE, this::fastOpenHandler, 0x04351);
addCheat(RAMEvent.TYPE.WRITE, this::fastOpenHandler, 0x0587B); addCheat("Wolfenstein FastOpen cheat (2)", RAMEvent.TYPE.WRITE, this::fastOpenHandler, 0x0587B);
} }
} }
if (ammo) { if (ammo) {
forceValue(10, BULLETS); forceValue("Wolfenstein ammo cheat", 10, BULLETS);
if (!_isBeyondWolfenstein) { if (!_isBeyondWolfenstein) {
forceValue(9, GRENADES); forceValue("Wolfenstein grenades cheat", 9, GRENADES);
} }
} }
if (skeletonKey) { if (skeletonKey) {
if (_isBeyondWolfenstein) { if (_isBeyondWolfenstein) {
forceValue(255, PASSES); forceValue("Wolfenstein passes cheat", 255, PASSES);
forceValue(64, CLOSET_CONTENTS_CMP); // Fake it out so it thinks all doors are unlocked forceValue("Wolfenstein unlock closets cheat", 64, CLOSET_CONTENTS_CMP); // Fake it out so it thinks all doors are unlocked
} else { } else {
forceValue(255, KEYS); forceValue("Wolfenstein keys cheat", 255, KEYS);
} }
} }
if (allDead) { if (allDead) {
for (int i = 0x04080; i < 0x04100; i += 0x010) { for (int i = 0x04080; i < 0x04100; i += 0x010) {
addCheat(RAMEvent.TYPE.READ, this::allDead, i); addCheat("Wolfenstein all dead cheat " + i, RAMEvent.TYPE.READ, this::allDead, i);
} }
} }
if (sleepyTime) { if (sleepyTime) {
for (int i = 0x04080; i < 0x04100; i += 0x010) { for (int i = 0x04080; i < 0x04100; i += 0x010) {
forceValue(0, i + 2); forceValue("Wolfenstein sleep cheat (1)", 0, i + 2);
forceValue(0, i + 3); forceValue("Wolfenstein sleep cheat (2)", 0, i + 3);
// This makes them shout ACHTUNG over and over again... so don't do that. // This makes them shout ACHTUNG over and over again... so don't do that.
// forceValue(144, i+12); // forceValue(144, i+12);
forceValue(0, i + 12); forceValue("Wolfenstein sleep cheat (3)", 0, i + 12);
} }
} }
if (legendary) { if (legendary) {
for (int i = 0x04080; i < 0x04100; i += 0x010) { for (int i = 0x04080; i < 0x04100; i += 0x010) {
addCheat(RAMEvent.TYPE.READ, this::legendaryMode, i); addCheat("Wolfenstein legendary cheat", RAMEvent.TYPE.READ, this::legendaryMode, i);
} }
} }
@ -172,7 +167,7 @@ public class WolfensteinCheats extends Cheats {
private boolean isFinalRoom() { private boolean isFinalRoom() {
for (int i = 0x04080; i < 0x04100; i += 0x010) { for (int i = 0x04080; i < 0x04100; i += 0x010) {
int objectType = computer.getMemory().readRaw(i) & 0x0ff; int objectType = getMemory().readRaw(i) & 0x0ff;
if (objectType == BW_DOOR) { if (objectType == BW_DOOR) {
return true; return true;
} }
@ -181,14 +176,14 @@ public class WolfensteinCheats extends Cheats {
} }
private void allDesks(RAMEvent evt) { private void allDesks(RAMEvent evt) {
int location = computer.getMemory().readRaw(evt.getAddress() + 1); int location = getMemory().readRaw(evt.getAddress() + 1);
if (!isFinalRoom() || location < 32) { if (!isFinalRoom() || location < 32) {
int type = evt.getNewValue(); int type = evt.getNewValue();
if (type == GUARD) { if (type == GUARD) {
evt.setNewValue(SEATED_GUARD); evt.setNewValue(SEATED_GUARD);
// Reset the status flag to 0 to prevent the boss desk from rendering, but don't revive dead guards! // Reset the status flag to 0 to prevent the boss desk from rendering, but don't revive dead guards!
if (computer.getMemory().readRaw(evt.getAddress() + 4) != 4) { if (getMemory().readRaw(evt.getAddress() + 4) != 4) {
computer.getMemory().write(evt.getAddress() + 4, (byte) 0, false, false); getMemory().write(evt.getAddress() + 4, (byte) 0, false, false);
} }
} }
} }
@ -197,12 +192,12 @@ public class WolfensteinCheats extends Cheats {
private void allDead(RAMEvent evt) { private void allDead(RAMEvent evt) {
int type = evt.getNewValue(); int type = evt.getNewValue();
if (_isBeyondWolfenstein) { if (_isBeyondWolfenstein) {
int location = computer.getMemory().readRaw(evt.getAddress() + 1); int location = getMemory().readRaw(evt.getAddress() + 1);
if (!isFinalRoom() || location < 32) { if (!isFinalRoom() || location < 32) {
if (type == GUARD) { if (type == GUARD) {
evt.setNewValue(CORPSE); evt.setNewValue(CORPSE);
} else if (type == SEATED_GUARD) { } else if (type == SEATED_GUARD) {
computer.getMemory().write(evt.getAddress() + 4, (byte) 4, false, false); getMemory().write(evt.getAddress() + 4, (byte) 4, false, false);
} }
} }
} else { } else {
@ -240,13 +235,13 @@ public class WolfensteinCheats extends Cheats {
private void killEnemyAt(int location) { private void killEnemyAt(int location) {
System.out.println("Looking for bad guy at " + location); System.out.println("Looking for bad guy at " + location);
for (int i = 0x04080; i < 0x04100; i += 0x010) { for (int i = 0x04080; i < 0x04100; i += 0x010) {
int enemyLocation = computer.getMemory().readRaw(i + 1) & 0x0ff; int enemyLocation = getMemory().readRaw(i + 1) & 0x0ff;
System.out.print("Location " + enemyLocation); System.out.print("Location " + enemyLocation);
String type = ""; String type = "";
boolean isAlive = false; boolean isAlive = false;
boolean isSeatedGuard = false; boolean isSeatedGuard = false;
if (_isBeyondWolfenstein) { if (_isBeyondWolfenstein) {
switch (computer.getMemory().readRaw(i) & 0x0ff) { switch (getMemory().readRaw(i) & 0x0ff) {
case GUARD: case GUARD:
type = "guard"; type = "guard";
isAlive = true; isAlive = true;
@ -266,10 +261,10 @@ public class WolfensteinCheats extends Cheats {
type = "nothing"; type = "nothing";
break; break;
default: default:
type = "unknown type " + (computer.getMemory().readRaw(i) & 0x0ff); type = "unknown type " + (getMemory().readRaw(i) & 0x0ff);
} }
} else { } else {
switch (computer.getMemory().readRaw(i) & 0x0ff) { switch (getMemory().readRaw(i) & 0x0ff) {
case GUARD: case GUARD:
type = "guard"; type = "guard";
isAlive = true; isAlive = true;
@ -291,21 +286,21 @@ public class WolfensteinCheats extends Cheats {
type = "nothing"; type = "nothing";
break; break;
default: default:
type = "unknown type " + (computer.getMemory().readRaw(i) & 0x0ff); type = "unknown type " + (getMemory().readRaw(i) & 0x0ff);
} }
} }
System.out.println(" is a " + type); System.out.println(" is a " + type);
for (int j = 0x00; j < 0x0f; j++) { for (int j = 0x00; j < 0x0f; j++) {
int val = computer.getMemory().readRaw(i + j) & 0x0ff; int val = getMemory().readRaw(i + j) & 0x0ff;
System.out.print(Integer.toHexString(val) + " "); System.out.print(Integer.toHexString(val) + " ");
} }
System.out.println(); System.out.println();
if (isAlive && location == enemyLocation) { if (isAlive && location == enemyLocation) {
if (isSeatedGuard) { if (isSeatedGuard) {
computer.getMemory().write(i + 4, (byte) 4, false, false); getMemory().write(i + 4, (byte) 4, false, false);
} else { } else {
computer.getMemory().write(i, (byte) CORPSE, false, true); getMemory().write(i, (byte) CORPSE, false, true);
} }
System.out.println("*BLAM*"); System.out.println("*BLAM*");
@ -315,7 +310,7 @@ public class WolfensteinCheats extends Cheats {
} }
private void teleportTo(int location) { private void teleportTo(int location) {
computer.getMemory().write(0x04343, (byte) location, false, true); getMemory().write(0x04343, (byte) location, false, true);
} }
@Override @Override
@ -335,7 +330,7 @@ public class WolfensteinCheats extends Cheats {
if (debugTicks > 0) { if (debugTicks > 0) {
debugTicks--; debugTicks--;
if (debugTicks == 0) { if (debugTicks == 0) {
computer.getCpu().setTraceEnabled(false); Emulator.withComputer(c->c.getCpu().setTraceEnabled(false));
} }
} }
} }