diff options
author | Ajarmar <axel.jarmar@gmail.com> | 2021-05-22 17:37:16 +0200 |
---|---|---|
committer | Ajarmar <axel.jarmar@gmail.com> | 2021-05-22 17:37:31 +0200 |
commit | af0e00cebe627fb41368d74a709327595b2eb3f1 (patch) | |
tree | 277d6df07bc995535b6d39750f8e4d575cbb7a63 | |
parent | 48ea51a8b9eab7d532cd9ef332a163d71b520b2b (diff) |
disable static music fix in most non-english versions
9 files changed, 53 insertions, 13 deletions
diff --git a/src/com/dabomstew/pkrandom/newgui/NewRandomizerGUI.java b/src/com/dabomstew/pkrandom/newgui/NewRandomizerGUI.java index a22b388..83ee828 100644 --- a/src/com/dabomstew/pkrandom/newgui/NewRandomizerGUI.java +++ b/src/com/dabomstew/pkrandom/newgui/NewRandomizerGUI.java @@ -2545,7 +2545,7 @@ public class NewRandomizerGUI { stpPercentageLevelModifierCheckBox.setEnabled(true); stpPercentageLevelModifierSlider.setVisible(true); stpPercentageLevelModifierSlider.setEnabled(false); - stpFixMusicCheckBox.setVisible(pokemonGeneration >= 3 && pokemonGeneration <= 5); + stpFixMusicCheckBox.setVisible(romHandler.hasStaticMusicFix()); stpFixMusicCheckBox.setEnabled(false); } else { stpSwapLegendariesSwapStandardsRadioButton.setVisible(false); diff --git a/src/com/dabomstew/pkrandom/romhandlers/Gen1RomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/Gen1RomHandler.java index 5026517..56843c2 100755 --- a/src/com/dabomstew/pkrandom/romhandlers/Gen1RomHandler.java +++ b/src/com/dabomstew/pkrandom/romhandlers/Gen1RomHandler.java @@ -1336,6 +1336,11 @@ public class Gen1RomHandler extends AbstractGBCRomHandler { }
@Override
+ public boolean hasStaticMusicFix() {
+ return false;
+ }
+
+ @Override
public List<TotemPokemon> getTotemPokemon() {
return new ArrayList<>();
}
diff --git a/src/com/dabomstew/pkrandom/romhandlers/Gen2RomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/Gen2RomHandler.java index 8aba59e..2b0fdcf 100755 --- a/src/com/dabomstew/pkrandom/romhandlers/Gen2RomHandler.java +++ b/src/com/dabomstew/pkrandom/romhandlers/Gen2RomHandler.java @@ -1179,6 +1179,11 @@ public class Gen2RomHandler extends AbstractGBCRomHandler { }
@Override
+ public boolean hasStaticMusicFix() {
+ return false;
+ }
+
+ @Override
public List<TotemPokemon> getTotemPokemon() {
return new ArrayList<>();
}
diff --git a/src/com/dabomstew/pkrandom/romhandlers/Gen3RomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/Gen3RomHandler.java index b827c96..84b3d16 100755 --- a/src/com/dabomstew/pkrandom/romhandlers/Gen3RomHandler.java +++ b/src/com/dabomstew/pkrandom/romhandlers/Gen3RomHandler.java @@ -2704,6 +2704,11 @@ public class Gen3RomHandler extends AbstractGBRomHandler { }
@Override
+ public boolean hasStaticMusicFix() {
+ return romEntry.codeTweaks.get("NewIndexToMusicTweak") != null;
+ }
+
+ @Override
public List<TotemPokemon> getTotemPokemon() {
return new ArrayList<>();
}
diff --git a/src/com/dabomstew/pkrandom/romhandlers/Gen4RomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/Gen4RomHandler.java index 1b2af9b..af888f4 100755 --- a/src/com/dabomstew/pkrandom/romhandlers/Gen4RomHandler.java +++ b/src/com/dabomstew/pkrandom/romhandlers/Gen4RomHandler.java @@ -4328,25 +4328,33 @@ public class Gen4RomHandler extends AbstractDSRomHandler { case Gen4Constants.Type_HGSS:
newIndexToMusicPrefix = romEntry.getString("IndexToMusicPrefix");
newIndexToMusicPoolOffset = find(arm9, newIndexToMusicPrefix);
- newIndexToMusicPoolOffset += newIndexToMusicPrefix.length() / 2;
- for (int oldStatic: specialMusicStaticChanges.keySet()) {
- int i = newIndexToMusicPoolOffset;
- int indexEtc = readWord(arm9, i);
- int index = indexEtc & 0x3FF;
- while (index != oldStatic || replaced.contains(i)) {
- i += 2;
- indexEtc = readWord(arm9, i);
- index = indexEtc & 0x3FF;
+ if (newIndexToMusicPoolOffset > 0) {
+ newIndexToMusicPoolOffset += newIndexToMusicPrefix.length() / 2;
+
+ for (int oldStatic: specialMusicStaticChanges.keySet()) {
+ int i = newIndexToMusicPoolOffset;
+ int indexEtc = readWord(arm9, i);
+ int index = indexEtc & 0x3FF;
+ while (index != oldStatic || replaced.contains(i)) {
+ i += 2;
+ indexEtc = readWord(arm9, i);
+ index = indexEtc & 0x3FF;
+ }
+ int newIndexEtc = specialMusicStaticChanges.get(oldStatic) | (indexEtc & 0xFC00);
+ writeWord(arm9, i, newIndexEtc);
+ replaced.add(i);
}
- int newIndexEtc = specialMusicStaticChanges.get(oldStatic) | (indexEtc & 0xFC00);
- writeWord(arm9, i, newIndexEtc);
- replaced.add(i);
}
break;
}
}
+ @Override
+ public boolean hasStaticMusicFix() {
+ return romEntry.tweakFiles.get("NewIndexToMusicTweak") != null || romEntry.romType == Gen4Constants.Type_HGSS;
+ }
+
private boolean genericIPSPatch(byte[] data, String ctName) {
String patchName = romEntry.tweakFiles.get(ctName);
if (patchName == null) {
diff --git a/src/com/dabomstew/pkrandom/romhandlers/Gen5RomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/Gen5RomHandler.java index 8375a23..22faac0 100755 --- a/src/com/dabomstew/pkrandom/romhandlers/Gen5RomHandler.java +++ b/src/com/dabomstew/pkrandom/romhandlers/Gen5RomHandler.java @@ -1756,6 +1756,11 @@ public class Gen5RomHandler extends AbstractDSRomHandler { }
@Override
+ public boolean hasStaticMusicFix() {
+ return romEntry.tweakFiles.get("NewIndexToMusicTweak") != null;
+ }
+
+ @Override
public List<TotemPokemon> getTotemPokemon() {
return new ArrayList<>();
}
diff --git a/src/com/dabomstew/pkrandom/romhandlers/Gen6RomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/Gen6RomHandler.java index 91db3d0..c548d01 100644 --- a/src/com/dabomstew/pkrandom/romhandlers/Gen6RomHandler.java +++ b/src/com/dabomstew/pkrandom/romhandlers/Gen6RomHandler.java @@ -2620,6 +2620,11 @@ public class Gen6RomHandler extends Abstract3DSRomHandler { } @Override + public boolean hasStaticMusicFix() { + return false; + } + + @Override public List<TotemPokemon> getTotemPokemon() { return new ArrayList<>(); } diff --git a/src/com/dabomstew/pkrandom/romhandlers/Gen7RomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/Gen7RomHandler.java index f868c7c..ed321d6 100644 --- a/src/com/dabomstew/pkrandom/romhandlers/Gen7RomHandler.java +++ b/src/com/dabomstew/pkrandom/romhandlers/Gen7RomHandler.java @@ -1755,6 +1755,11 @@ public class Gen7RomHandler extends Abstract3DSRomHandler { } @Override + public boolean hasStaticMusicFix() { + return false; + } + + @Override public List<TotemPokemon> getTotemPokemon() { List<TotemPokemon> totems = new ArrayList<>(); try { diff --git a/src/com/dabomstew/pkrandom/romhandlers/RomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/RomHandler.java index 81ecca0..9ca8efb 100755 --- a/src/com/dabomstew/pkrandom/romhandlers/RomHandler.java +++ b/src/com/dabomstew/pkrandom/romhandlers/RomHandler.java @@ -295,6 +295,8 @@ public interface RomHandler { void applyCorrectStaticMusic(Map<Integer,Integer> specialMusicStaticChanges);
+ boolean hasStaticMusicFix();
+
// Randomizer: Totem Pokemon
List<TotemPokemon> getTotemPokemon();
|