diff options
7 files changed, 71 insertions, 0 deletions
diff --git a/src/com/dabomstew/pkrandom/MiscTweak.java b/src/com/dabomstew/pkrandom/MiscTweak.java index 5b95712..ee1b8c7 100755 --- a/src/com/dabomstew/pkrandom/MiscTweak.java +++ b/src/com/dabomstew/pkrandom/MiscTweak.java @@ -58,6 +58,7 @@ public class MiscTweak implements Comparable<MiscTweak> { public static final MiscTweak BALANCE_STATIC_LEVELS = new MiscTweak(1 << 16, "balanceStaticLevels",0); public static final MiscTweak RETAIN_ALT_FORMES = new MiscTweak(1 << 17, "retainAltFormes",0); public static final MiscTweak RUN_WITHOUT_RUNNING_SHOES = new MiscTweak(1 << 18, "runWithoutRunningShoes", 0); + public static final MiscTweak FASTER_HP_AND_EXP_BARS = new MiscTweak(1 << 19, "fasterHpAndExpBars", 0); /* @formatter:on */ private final int value; diff --git a/src/com/dabomstew/pkrandom/config/gen4_offsets.ini b/src/com/dabomstew/pkrandom/config/gen4_offsets.ini index 185353e..f7c9157 100755 --- a/src/com/dabomstew/pkrandom/config/gen4_offsets.ini +++ b/src/com/dabomstew/pkrandom/config/gen4_offsets.ini @@ -57,6 +57,7 @@ PokedexAreaDataDungeonSpecialPostNationalIndex=1984 PokedexAreaDataOverworldIndex=2479 PokedexAreaDataOverworldSpecialPreNationalIndex=3964 PokedexAreaDataOverworldSpecialPostNationalIndex=4459 +BattleOvlNumber=11 IntroOvlNumber=59 StaticPokemon{}={Species=[230:0x4AE, 230:0xE9A, 230:0xECE, 230:0x1201, 230:0x1235], Level=[230:0xEE4, 230:0x124B]} // Dialga StaticPokemon{}={Species=[230:0x4B4, 230:0xEA0, 230:0xED4, 230:0x1207, 230:0x123B], Level=[230:0xEE4, 230:0x124B]} // Palkia @@ -150,6 +151,7 @@ NationalDexScriptOffset=1064 PokemonGraphics=poketool/pokegra/pl_pokegra.narc PokedexAreaData=application/zukanlist/zkn_data/zukan_enc_platinum.narc FieldOvlNumber=5 +BattleOvlNumber=16 IntroOvlNumber=73 StaticPokemonSupport=1 StaticPokemon{}={Species=[291:0x43, 291:0x52, 389:0xCC, 389:0xDD], Level=[291:0x54, 389:0xDF]} // Giratina @@ -245,6 +247,7 @@ PokedexAreaDataDungeonIndex=2 PokedexAreaDataOverworldIndex=1487 PokedexAreaDataDungeonSpecialIndex=2972 PokedexAreaDataOverworldSpecialIndex=3467 +BattleOvlNumber=12 StaticPokemonSupport=1 StaticPokemon{}={Species=[104:0x108], Level=[104:0x138, 104:0x12C]} // Lugia StaticPokemon{}={Species=[21:0xD1], Level=[21:0xF5, 21:0x101]} // Ho-oh diff --git a/src/com/dabomstew/pkrandom/constants/Gen4Constants.java b/src/com/dabomstew/pkrandom/constants/Gen4Constants.java index e148ea7..f22752d 100644 --- a/src/com/dabomstew/pkrandom/constants/Gen4Constants.java +++ b/src/com/dabomstew/pkrandom/constants/Gen4Constants.java @@ -516,6 +516,8 @@ public class Gen4Constants { public static final List<String> dpptIntroPrefixes = Arrays.asList("381CF8BDC046", "08B0F8BD"); + public static final String hpBarSpeedPrefix = "0CD106200090", expBarSpeedPrefix = "011C00D101212E6C", bothBarsSpeedPrefix = "70BD90421DDA"; + private static final int trophyGardenGrassEncounterIndexDP = 304, trophyGardenGrassEncounterIndexPt = 308; private static final List<Integer> marshGrassEncounterIndicesDP = Arrays.asList(76, 82, 88, 94, 100, 102), marshGrassEncounterIndicesPt = Arrays.asList(76, 82, 88, 94, 100, 106); diff --git a/src/com/dabomstew/pkrandom/newgui/Bundle.properties b/src/com/dabomstew/pkrandom/newgui/Bundle.properties index b14b554..53e0eda 100644 --- a/src/com/dabomstew/pkrandom/newgui/Bundle.properties +++ b/src/com/dabomstew/pkrandom/newgui/Bundle.properties @@ -487,6 +487,8 @@ CodeTweaks.retainAltFormes.toolTipText=<html>Lets all party Pokemon that are in CodeTweaks.retainAltFormes.name=Don't Revert Temporary Alt Formes CodeTweaks.runWithoutRunningShoes.toolTipText=<html>Allows you to run before acquiring the Running Shoes. CodeTweaks.runWithoutRunningShoes.name=Run Without Running Shoes +CodeTweaks.fasterHpAndExpBars.toolTipText=<html>Doubles the scrolling speed of the HP and EXP bars that appear in battle.<br />In practice, this makes them scroll at the same speed as in the Gen 3 games. +CodeTweaks.fasterHpAndExpBars.name=Faster HP and EXP Bars CustomNamesEditorDialog.trainerNamesSP.TabConstraints.tabTitle=Trainer Names CustomNamesEditorDialog.title=Custom Names Editor CustomNamesEditorDialog.closeBtn.text=Close diff --git a/src/com/dabomstew/pkrandom/newgui/NewRandomizerGUI.form b/src/com/dabomstew/pkrandom/newgui/NewRandomizerGUI.form index 3c0d0be..f1f9161 100644 --- a/src/com/dabomstew/pkrandom/newgui/NewRandomizerGUI.form +++ b/src/com/dabomstew/pkrandom/newgui/NewRandomizerGUI.form @@ -3388,6 +3388,17 @@ <toolTipText resource-bundle="com/dabomstew/pkrandom/newgui/Bundle" key="CodeTweaks.runWithoutRunningShoes.toolTipText"/> </properties> </component> + <component id="52a" class="javax.swing.JCheckBox" binding="miscFasterHPAndEXPBarsCheckBox" default-binding="true"> + <constraints> + <grid row="5" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/> + <gridbag weightx="0.0" weighty="0.0"/> + </constraints> + <properties> + <enabled value="false"/> + <text resource-bundle="com/dabomstew/pkrandom/newgui/Bundle" key="CodeTweaks.fasterHpAndExpBars.name"/> + <toolTipText resource-bundle="com/dabomstew/pkrandom/newgui/Bundle" key="CodeTweaks.fasterHpAndExpBars.toolTipText"/> + </properties> + </component> </children> </grid> <hspacer id="c4e06"> diff --git a/src/com/dabomstew/pkrandom/newgui/NewRandomizerGUI.java b/src/com/dabomstew/pkrandom/newgui/NewRandomizerGUI.java index aebe816..4e98604 100644 --- a/src/com/dabomstew/pkrandom/newgui/NewRandomizerGUI.java +++ b/src/com/dabomstew/pkrandom/newgui/NewRandomizerGUI.java @@ -280,6 +280,7 @@ public class NewRandomizerGUI { private JCheckBox stpPercentageLevelModifierCheckBox; private JSlider stpPercentageLevelModifierSlider; private JCheckBox stpFixMusicCheckBox; + private JCheckBox miscFasterHPAndEXPBarsCheckBox; private static JFrame frame; diff --git a/src/com/dabomstew/pkrandom/romhandlers/Gen4RomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/Gen4RomHandler.java index ce03925..7c02d2d 100755 --- a/src/com/dabomstew/pkrandom/romhandlers/Gen4RomHandler.java +++ b/src/com/dabomstew/pkrandom/romhandlers/Gen4RomHandler.java @@ -3909,6 +3909,7 @@ public class Gen4RomHandler extends AbstractDSRomHandler { available |= MiscTweak.NATIONAL_DEX_AT_START.getValue();
}
available |= MiscTweak.RUN_WITHOUT_RUNNING_SHOES.getValue();
+ available |= MiscTweak.FASTER_HP_AND_EXP_BARS.getValue();
return available;
}
@@ -3927,6 +3928,8 @@ public class Gen4RomHandler extends AbstractDSRomHandler { patchForNationalDex();
} else if (tweak == MiscTweak.RUN_WITHOUT_RUNNING_SHOES) {
applyRunWithoutRunningShoesPatch();
+ } else if (tweak == MiscTweak.FASTER_HP_AND_EXP_BARS) {
+ patchFasterBars();
}
}
@@ -3986,6 +3989,54 @@ public class Gen4RomHandler extends AbstractDSRomHandler { }
}
+ private void patchFasterBars() {
+ // To understand what this code is patching, take a look at the CalcNewBarValue
+ // and MoveBattleBar functions in this file from the Emerald decompilation:
+ // https://github.com/pret/pokeemerald/blob/master/src/battle_interface.c
+ // The code in Gen 4 is almost identical outside of one single constant; the
+ // reason the bars scroll slower is because Gen 4 runs at 30 FPS instead of 60.
+ try {
+ byte[] battleOverlay = readOverlay(romEntry.getInt("BattleOvlNumber"));
+ int offset = find(battleOverlay, Gen4Constants.hpBarSpeedPrefix);
+ if (offset > 0) {
+ offset += Gen4Constants.hpBarSpeedPrefix.length() / 2; // because it was a prefix
+ // For the HP bar, the original game passes 1 for the toAdd parameter of CalcNewBarValue.
+ // We want to pass 2 instead, so we simply change the mov instruction at offset.
+ battleOverlay[offset] = 0x02;
+ }
+
+ offset = find(battleOverlay, Gen4Constants.expBarSpeedPrefix);
+ if (offset > 0) {
+ offset += Gen4Constants.expBarSpeedPrefix.length() / 2; // because it was a prefix
+ // For the EXP bar, the original game passes expFraction for the toAdd parameter. The
+ // game calculates expFraction by doing a division, and to do *that*, it has to load
+ // receivedValue into r0 so it can call the division function with it as the first
+ // parameter. It gets the value from r6 like so:
+ // add r0, r6, #0
+ // Since we ultimately want toAdd (and thus expFraction) to be doubled, we can double
+ // receivedValue when it gets loaded into r0 by tweaking the add to be:
+ // add r0, r6, r6
+ battleOverlay[offset] = (byte) 0xB0;
+ battleOverlay[offset + 1] = 0x19;
+ }
+
+ offset = find(battleOverlay, Gen4Constants.bothBarsSpeedPrefix);
+ if (offset > 0) {
+ offset += Gen4Constants.bothBarsSpeedPrefix.length() / 2; // because it was a prefix
+ // For both HP and EXP bars, a different set of logic is used when the maxValue has
+ // fewer pixels than the whole bar; this logic ignores the toAdd parameter entirely and
+ // calculates its *own* toAdd by doing maxValue << 8 / scale. If we instead do
+ // maxValue << 9, the new toAdd becomes doubled as well.
+ battleOverlay[offset] = 0x40;
+ }
+
+ writeOverlay(romEntry.getInt("BattleOvlNumber"), battleOverlay);
+
+ } catch (IOException e) {
+ throw new RandomizerIOException(e);
+ }
+ }
+
@Override
public void applyCorrectStaticMusic(Map<Integer,Integer> specialMusicStaticChanges) {
List<Integer> replaced = new ArrayList<>();
|