diff options
author | Dabomstew <dbs.stew@gmail.com> | 2016-04-27 13:33:04 +1200 |
---|---|---|
committer | Dabomstew <dbs.stew@gmail.com> | 2016-04-27 13:33:04 +1200 |
commit | 7ccf5354bfd958883d8958fbe408c1d7e545fe96 (patch) | |
tree | cd5308b7c7e378cb1aef470e6ea715f5ab802888 | |
parent | f7635218d6a36b84f4a48345e416f3e62574959b (diff) |
Finish refactor of GBC text handling (particularly for starters)
4 files changed, 21 insertions, 2 deletions
diff --git a/src/com/dabomstew/pkrandom/config/gen1_offsets.ini b/src/com/dabomstew/pkrandom/config/gen1_offsets.ini index ffcd62a..0d0f0ee 100755 --- a/src/com/dabomstew/pkrandom/config/gen1_offsets.ini +++ b/src/com/dabomstew/pkrandom/config/gen1_offsets.ini @@ -32,6 +32,7 @@ StarterOffsets3=[0x1D115, 0x19599, 0x1CDD0, 0x1D130, 0x39CF2, 0x50FB1, 0x510DB, PatchPokedex=1 CanChangeStarterText=1 CanChangeTrainerText=1 +StarterTextOffsets=[0x94E07, 0x94E30, 0x94E58] StarterPokedexOnOffset=0x5C0DC StarterPokedexOffOffset=0x5C0E6 StarterPokedexBranchOffset=0x5E000 diff --git a/src/com/dabomstew/pkrandom/config/gen2_offsets.ini b/src/com/dabomstew/pkrandom/config/gen2_offsets.ini index 6a0faad..29c1a9b 100755 --- a/src/com/dabomstew/pkrandom/config/gen2_offsets.ini +++ b/src/com/dabomstew/pkrandom/config/gen2_offsets.ini @@ -25,6 +25,7 @@ StarterOffsets3=[0x180150, 0x180152, 0x180169, 0x180174] StarterHeldItems=[0x1800F8, 0x18013A, 0x180176] CanChangeStarterText=1 CanChangeTrainerText=1 +StarterTextOffsets=[0x1805F4, 0x180620, 0x18064D] TrainerClassAmount=0x42 TrainerDataTableOffset=0x3993E TrainerDataClassCounts=[1, 1, 1, 1, 1, 1, 1, 1, 15, 0, 1, 3, 1, 1, 1, 1, 1, 1, 1, 5, 1, 12, 18, 19, 15, 1, 19, 20, 16, 13, 31, 5, 2, 3, 1, 14, 22, 21, 19, 12, 12, 6, 2, 20, 9, 1, 3, 8, 5, 9, 4, 12, 21, 19, 2, 9, 7, 3, 12, 6, 8, 5, 1, 1, 2, 5] @@ -166,6 +167,7 @@ StarterOffsets2=[0x78CC1, 0x78CC3, 0x78CDA, 0x78CE5] StarterOffsets3=[0x78CFD, 0x78CFF, 0x78D16, 0x78D21] StarterHeldItems=[0x78CA5, 0x78CE7, 0x78D23] CanChangeStarterText=1 +StarterTextOffsets=[0x793D9, 0x79405, 0x79432] CanChangeTrainerText=1 TrainerClassAmount=0x43 TrainerDataTableOffset=0x39999 diff --git a/src/com/dabomstew/pkrandom/romhandlers/AbstractGBCRomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/AbstractGBCRomHandler.java index ef2aa3b..5ab33a9 100644 --- a/src/com/dabomstew/pkrandom/romhandlers/AbstractGBCRomHandler.java +++ b/src/com/dabomstew/pkrandom/romhandlers/AbstractGBCRomHandler.java @@ -179,5 +179,21 @@ public abstract class AbstractGBCRomHandler extends AbstractGBRomHandler { } } + + protected static boolean romCode(byte[] rom, String code) { + try { + int sigOffset = GBConstants.romCodeOffset; + byte[] sigBytes = code.getBytes("US-ASCII"); + for (int i = 0; i < sigBytes.length; i++) { + if (rom[sigOffset + i] != sigBytes[i]) { + return false; + } + } + return true; + } catch (UnsupportedEncodingException ex) { + return false; + } + + } } diff --git a/src/com/dabomstew/pkrandom/romhandlers/Gen2RomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/Gen2RomHandler.java index a6315da..6aa1f94 100755 --- a/src/com/dabomstew/pkrandom/romhandlers/Gen2RomHandler.java +++ b/src/com/dabomstew/pkrandom/romhandlers/Gen2RomHandler.java @@ -325,14 +325,14 @@ public class Gen2RomHandler extends AbstractGBCRomHandler { // Check for specific CRC first int crcInHeader = ((rom[GBConstants.crcOffset] & 0xFF) << 8) | (rom[GBConstants.crcOffset + 1] & 0xFF); for (RomEntry re : roms) { - if (romSig(rom, re.romCode) && re.version == version && re.nonJapanese == nonjap + if (romCode(rom, re.romCode) && re.version == version && re.nonJapanese == nonjap && re.crcInHeader == crcInHeader) { return re; } } // Now check for non-specific-CRC entries for (RomEntry re : roms) { - if (romSig(rom, re.romCode) && re.version == version && re.nonJapanese == nonjap && re.crcInHeader == -1) { + if (romCode(rom, re.romCode) && re.version == version && re.nonJapanese == nonjap && re.crcInHeader == -1) { return re; } } |