Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mods folder and fast_gauge.md #322

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# Pokémon Platinum

This is a WIP decompilation of Pokémon Platinum. For instructions on how to set up the repository, please read [INSTALL.md](INSTALL.md).
This is a WIP branched fork of [pret/pokeplatinum](https://github.com/pret/pokeplatinum) dedicated to making a mod/hack friendly base.

This repository builds the following ROMs:

* [**pokeplatinum.us.nds**](https://datomatic.no-intro.org/index.php?page=show_record&s=28&n=3541) `sha1: ce81046eda7d232513069519cb2085349896dec7`

For contacts and other pret projects, see [pret.github.io](https://pret.github.io/). In addition to the pret Discord, also see the [VoidMatrix Discord (#decomp)](https://discord.gg/prUAgd5).
There will be a goals folder, modding info in the docs folder, and a changelog folder describing the changes made to pokeplatinum.
4 changes: 4 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ For more detailed information about the project as a whole, please refer to its

- [2D Graphics](2d_rendering.md)
- [3D Graphics](3d_rendering.md)

## Mods

- [Fast Gauge](mods/fast_gauge.md)
18 changes: 18 additions & 0 deletions docs/mods/fast_gauge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Fast Gauge

This is a quick tutorial on how to modify the gauge of exp and health bars of Plat so that the bar visually updates in subpixels per second instead of points per second.

This mod is a backport of the healthbar fix made by the contributors of [pret/pokeheartgold](https://github.com/pret/pokeheartgold/blob/src/battle/battle_hp_bar.c#L1497) for the heartgold/soulsilver decomp.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that this is the correct link.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The USE_SUBPIXEL_TEST definition is just an abstraction of a common comparison in the pokeheartgold code. The main difference in pokeplatinum is that we don't use the same variable names in all cases where that comparison is used. Regardless, that comparison is still in the pokeplatinum codebase when dealing with guages. However, the difference is is that pokeplat calculates adjusts the bar at a constant rate of 0x100, while the pokeheartgold uses bit shifting in order to standardize the rate in which health bars increase and decrease, regardless of size.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bitshift in pokeheartgold is in the opposite direction (leftward instead of the rightward shift listed in this document below), and is functionally equivalent to multiplying by 0x100. To illustrate:

15 * 0x100 = 0xF * 0x100
           = 0xF00
           = 3840

15 << 8    = 3840

So, I guess that I am confused... how does this mod work? What change does it institute? It may be worthwhile to further document the tiling system used by the HP bar as part of this PR.


Fixes are written in the `diff` format, as mentioned in [Bugs and Glitches](../bugs_and_glitches.md).

## Edit

1. Go to [/src/battle/healthbar.c](/src/battle/healthbar.c)
2. Go to the ``UpdateGauge`` function.
3. Edit the function like so:
```diff
if (max < corrected) {
- ratio = max * 0x100 / corrected;
+ ratio = (max << 8) / corrected;
```