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

Document system_vars.c #374

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft

Conversation

lhearachel
Copy link
Collaborator

@lhearachel lhearachel commented Feb 13, 2025

Leaving this one in draft mode until I can finish documenting/decorating where these functions are used in the code.

This chunk of the variables block in the save data is known to have 64 values because this file is the only code file making use of the (((0 + VARS_START) + 32) + 16) construction. All other references to variables are via scripts, which only use literal values at present. I continued up to 0x4070 and found that it is the variable used in Twinleaf Town's story progression, which signals to me that 0x4030 through 0x406F is the range in this chunk.

At some point we will want to assess whether moving all of the variables and flags to metang generation is sensible, but this feels out-of-scope at the moment.

@lhearachel lhearachel marked this pull request as ready for review February 14, 2025 05:39
@lhearachel
Copy link
Collaborator Author

lhearachel commented Feb 14, 2025

This is now ready for review.

I did not document ScrCmd_30F because it requires additional context for the other calling modes.

@lhearachel
Copy link
Collaborator Author

lhearachel commented Feb 14, 2025

Moving this back to draft while #377 is in review; it can be reviewed, but will likely have merge conflicts to address.

@lhearachel lhearachel marked this pull request as draft February 14, 2025 18:18
asm/macros/scrcmd.inc Outdated Show resolved Hide resolved
generated/hidden_locations.txt Outdated Show resolved Hide resolved
generated/distribution_events.txt Outdated Show resolved Hide resolved
include/constants/savedata/vars_flags.h Outdated Show resolved Hide resolved
include/unk_020480A8.h Outdated Show resolved Hide resolved
res/field/scripts/scripts_unk_0412.s Show resolved Hide resolved
src/unk_0204B830.c Outdated Show resolved Hide resolved
src/scrcmd.c Outdated Show resolved Hide resolved
src/system_vars.c Outdated Show resolved Hide resolved
- `resultVar` -> `destVarID`
- Clean up member names for `HiddenLocation` and `DistributionEvent`
- `Set/Clear` -> `Enable/Disable` for HiddenLocation script macros
- `ScrCmd_SetOrClearHiddenLocation` -> `ScrCmd_SetHiddenLocation`
- `SYSTEM_VARS_BLOCK_SIZE` -> `NUM_SYSTEM_VARS`
- Identify `scripts_unk_0412` -> `scripts_init_new_game`
- Add `SCRIPT_ID_OFFSET_INIT_NEW_GAME` constant definition
- Add `SCRIPT_ID` functional macro
- Use `SCRIPT_ID(INIT_NEW_GAME, 0)` in `FieldSystem_InitNewGameState`
- Promote `LCRNG_MULTIPLIER` in `math.c` from private to public
- Use private `LCRNG_INCREMENT` in `system_vars.c` for lottery sync
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