summaryrefslogtreecommitdiff
path: root/src/com/dabomstew
diff options
context:
space:
mode:
authortom-overton <tom.overton@outlook.com>2021-03-04 19:42:25 -0800
committertom-overton <tom.overton@outlook.com>2021-03-04 19:42:25 -0800
commit4260e2d9eb2ede77d8c86e20431ee91b34afe050 (patch)
tree5cd5b8631436ce004717209225ac8f242b12cabf /src/com/dabomstew
parentbdbe53cd8874a5a29f07e4f4f05a6b888826aa75 (diff)
XY: Enable National Dex at Start
Diffstat (limited to 'src/com/dabomstew')
-rw-r--r--src/com/dabomstew/pkrandom/constants/Gen6Constants.java2
-rw-r--r--src/com/dabomstew/pkrandom/romhandlers/Gen6RomHandler.java23
2 files changed, 21 insertions, 4 deletions
diff --git a/src/com/dabomstew/pkrandom/constants/Gen6Constants.java b/src/com/dabomstew/pkrandom/constants/Gen6Constants.java
index 8a2ee23..554d24b 100644
--- a/src/com/dabomstew/pkrandom/constants/Gen6Constants.java
+++ b/src/com/dabomstew/pkrandom/constants/Gen6Constants.java
@@ -229,7 +229,7 @@ public class Gen6Constants {
public static final int[] boxLegendaryCodeOffsetsXY = new int[]{ 144, 300, 584 };
public static final String rayquazaFunctionPrefixORAS = "0900A0E1F08FBDE8";
public static final int[] rayquazaScriptOffsetsORAS = new int[]{ 3334, 14734 }, rayquazaCodeOffsetsORAS = new int[]{ 136, 292, 576 };
- public static final String nationalDexFunctionLocator = "080094E5010000E21080BDE8170F122F";
+ public static final String nationalDexFunctionLocator = "080094E5010000E21080BDE8170F122F", xyGetDexFlagFunctionLocator = "000055E30100A0030A00000A";
public static String getIngameTradesPrefix(int romType) {
if (romType == Type_XY) {
diff --git a/src/com/dabomstew/pkrandom/romhandlers/Gen6RomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/Gen6RomHandler.java
index 3758e60..13b0bc9 100644
--- a/src/com/dabomstew/pkrandom/romhandlers/Gen6RomHandler.java
+++ b/src/com/dabomstew/pkrandom/romhandlers/Gen6RomHandler.java
@@ -2192,9 +2192,7 @@ public class Gen6RomHandler extends Abstract3DSRomHandler {
available |= MiscTweak.FASTEST_TEXT.getValue();
available |= MiscTweak.BAN_LUCKY_EGG.getValue();
available |= MiscTweak.RETAIN_ALT_FORMES.getValue();
- if (romEntry.romType == Gen6Constants.Type_ORAS) {
- available |= MiscTweak.NATIONAL_DEX_AT_START.getValue();
- }
+ available |= MiscTweak.NATIONAL_DEX_AT_START.getValue();
return available;
}
@@ -2247,6 +2245,25 @@ public class Gen6RomHandler extends Abstract3DSRomHandler {
code[offset + 2] = (byte) 0xA0;
code[offset + 3] = (byte) 0xE3;
}
+
+ if (romEntry.romType == Gen6Constants.Type_XY) {
+ offset = find(code, Gen6Constants.xyGetDexFlagFunctionLocator);
+ if (offset > 0) {
+ // In addition to the code listed above, XY also use a function that I'm
+ // calling Savedata::ZukanData::GetDexFlag(int) to determine what Pokedexes
+ // the player owns. It can be called with 0 (Central), 1 (Coastal), 2 (Mountain),
+ // or 3 (National). Since the player *always* has the Central Dex, the code has
+ // a short-circuit for it that looks like this:
+ // cmp r5, #0x0
+ // moveq r0, #0x1
+ // beq returnFromFunction
+ // The below code nops out that comparison and makes the move and branch instructions
+ // non-conditional; no matter what's on the save file, the player will have all dexes.
+ FileFunctions.writeFullIntLittleEndian(code, offset, 0);
+ code[offset + 7] = (byte) 0xE3;
+ code[offset + 11] = (byte) 0xEA;
+ }
+ }
}
@Override