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 4 commits into
base: main
Choose a base branch
from

Conversation

DylanDoesProgramming664

Adds docs/mods folder, docs/mods/fast_gauge.md to explain a possible edit to src/battle/healthbar.c for faster exp and hp bars, and added a link to the file in docs/index.md.

docs/index.md Outdated

## Mods

- [Fast Guage](mods/fast_guage.md)
Copy link
Collaborator

Choose a reason for hiding this comment

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

typo: Guage -> Gauge (applies to the file-name as well)


This is a quick tutorial on how to modify the guage 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) 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.

style: Provide a perma-link to the original fix in pokeheartgold.

Choose a reason for hiding this comment

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

I fixed the typos and provided a direct link to the line that's changed in pret/pokeheartgold.

Fixed typos and gave a link to the exact line in pret/pokeheartgold that changed hp bars to be faster if max hp is less than pixel width. The macro in line 22 is irrelevant to what actually is changed. Line 1497 is all that matters here.
Comment on lines 15 to 17
if (max < corrected) {
- ratio = max * 0x100 / corrected;
+ ratio = (max >> 8) / corrected;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you show a video of the difference here, by-chance?

Choose a reason for hiding this comment

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

Will do. Also noticed that I made a typo. Will fix that.


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
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.

Corrected bitshift
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants