summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortom-overton <tom.overton@outlook.com>2022-03-31 00:58:46 -0700
committertom-overton <tom.overton@outlook.com>2022-03-31 00:58:46 -0700
commit99ad0cd402b09dc324ae4b2a5a57b94fd236086a (patch)
tree05f626d6cd2fda089118e5ee1b9973de99766b7b /src
parent651ba2651305191a0349c9ae4b7c8e39cf830d8a (diff)
Gen 5: Add support for randomizing egg moves
Diffstat (limited to 'src')
-rwxr-xr-xsrc/com/dabomstew/pkrandom/config/gen5_offsets.ini2
-rwxr-xr-xsrc/com/dabomstew/pkrandom/romhandlers/Gen5RomHandler.java36
-rw-r--r--src/com/dabomstew/pkrandom/romhandlers/Gen6RomHandler.java1
3 files changed, 35 insertions, 4 deletions
diff --git a/src/com/dabomstew/pkrandom/config/gen5_offsets.ini b/src/com/dabomstew/pkrandom/config/gen5_offsets.ini
index 9e666e4..e346bee 100755
--- a/src/com/dabomstew/pkrandom/config/gen5_offsets.ini
+++ b/src/com/dabomstew/pkrandom/config/gen5_offsets.ini
@@ -16,6 +16,7 @@ File<Scripts>=<a/0/5/7, 0D4E6B38>
File<TrainerTextBoxes>=<a/0/9/0, DB72FD1A>
File<TrainerData>=<a/0/9/2, BF203832>
File<TrainerPokemon>=<a/0/9/3, A0C7D342>
+File<EggMoves>=<a/1/2/3, 784B2D4F>
File<MapFiles>=<a/1/2/5, 6B00C87E>
File<WildPokemon>=<a/1/2/6, 4B3B1CF6>
File<InGameTrades>=<a/1/6/5, 42F5F462>
@@ -177,6 +178,7 @@ File<Scripts>=<a/0/5/6, EA1E0890>
File<TrainerTextBoxes>=<a/0/8/9, C73441C5>
File<TrainerData>=<a/0/9/1, 0852918C>
File<TrainerPokemon>=<a/0/9/2, 9435BD3C>
+File<EggMoves>=<a/1/2/4, 784B2D4F>
File<MapFiles>=<a/1/2/6, FE1792B9>
File<WildPokemon>=<a/1/2/7, 7EAF56BE>
File<InGameTrades>=<a/1/6/3, 15ED8FFA>
diff --git a/src/com/dabomstew/pkrandom/romhandlers/Gen5RomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/Gen5RomHandler.java
index 9168617..0822a19 100755
--- a/src/com/dabomstew/pkrandom/romhandlers/Gen5RomHandler.java
+++ b/src/com/dabomstew/pkrandom/romhandlers/Gen5RomHandler.java
@@ -1714,13 +1714,43 @@ public class Gen5RomHandler extends AbstractDSRomHandler {
@Override
public Map<Integer, List<Integer>> getEggMoves() {
- // Not currently implemented
- return new TreeMap<>();
+ Map<Integer, List<Integer>> eggMoves = new TreeMap<>();
+ try {
+ NARCArchive eggMovesNarc = this.readNARC(romEntry.getFile("EggMoves"));
+ for (int i = 1; i <= Gen5Constants.pokemonCount; i++) {
+ Pokemon pkmn = pokes[i];
+ byte[] movedata = eggMovesNarc.files.get(i);
+ int numberOfEggMoves = readWord(movedata, 0);
+ List<Integer> moves = new ArrayList<>();
+ for (int j = 0; j < numberOfEggMoves; j++) {
+ int move = readWord(movedata, 2 + (j * 2));
+ moves.add(move);
+ }
+ eggMoves.put(pkmn.number, moves);
+ }
+ } catch (IOException e) {
+ throw new RandomizerIOException(e);
+ }
+ return eggMoves;
}
@Override
public void setEggMoves(Map<Integer, List<Integer>> eggMoves) {
- // Not currently implemented
+ try {
+ NARCArchive eggMovesNarc = this.readNARC(romEntry.getFile("EggMoves"));
+ for (int i = 1; i <= Gen5Constants.pokemonCount; i++) {
+ Pokemon pkmn = pokes[i];
+ byte[] movedata = eggMovesNarc.files.get(i);
+ List<Integer> moves = eggMoves.get(pkmn.number);
+ for (int j = 0; j < moves.size(); j++) {
+ writeWord(movedata, 2 + (j * 2), moves.get(j));
+ }
+ }
+ // Save
+ this.writeNARC(romEntry.getFile("EggMoves"), eggMovesNarc);
+ } catch (IOException e) {
+ throw new RandomizerIOException(e);
+ }
}
private static class FileEntry {
diff --git a/src/com/dabomstew/pkrandom/romhandlers/Gen6RomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/Gen6RomHandler.java
index 3d827a1..2a80788 100644
--- a/src/com/dabomstew/pkrandom/romhandlers/Gen6RomHandler.java
+++ b/src/com/dabomstew/pkrandom/romhandlers/Gen6RomHandler.java
@@ -3872,7 +3872,6 @@ public class Gen6RomHandler extends Abstract3DSRomHandler {
long expectedCRC32 = romEntry.files.get(fileKey).expectedCRC32s[index];
long actualCRC32 = actualFileCRC32s.get(fileKey);
if (expectedCRC32 != actualCRC32) {
- System.out.println(fileKey + " " + actualCRC32);
return false;
}
}