Skip to content

battle: matching functions related to battle tick processing/advancement - #312

Merged
Xeeynamo merged 8 commits into
Xeeynamo:mainfrom
GinNoOokami:battle_tick
Oct 12, 2026
Merged

Xeeynamo merged 8 commits into
Xeeynamo:mainfrom
GinNoOokami:battle_tick

Conversation

@GinNoOokami

Copy link
Copy Markdown
Contributor

This was a fun one. Matched functions that handle tick processing and accumulation, most notably: BattleAdvanceTimers and BattleProcessTimers. The accumulators are double buffered because the producers write from the VSync interrupt handler while the consumers may be in the middle of reading from the main loop. g_BattleTimerBufferIndex does need to be declared volatile to match, and it does make sense why it might have been in this context.

As usual with the core battle mechanics, I've cross referenced these with the FAQ and added comments to help explain what's going on in what is hopefully clear language. I've also added some macros to make the magic numbers for the fixed point accumulators and fractions (which use different precisions), and other bits easier to read.

Despite understanding most of what it does, I still have no idea what to name func_800B0234. Naming is hard. ☹️

Renames:

Functions

  • func_800B0170 -> BattleAdvanceTimers
  • func_800AFECC -> BattleProcessTimers
  • func_800AFE98 -> BattleUnitGetPendingConstTicks
  • BattleRecalcUnitSpeed -> BattleUnitCalcSpeed
  • BattleApplyRegenPoisonTick -> BattleUnitSetHpChangeRate

Fields

  • BattleTurnWork.unitSpeed -> varSpeed
  • BattleTurnWork.atbSpeedMultiplier -> constSpeed
  • BattleTurnWork.unk6 -> hpChangeRate

Globals

  • D_800F499C -> g_BattleTimerBufferIndex
  • D_800F49A0 -> g_BattleGlobalTimerAccum
  • D_800F49A8 -> g_BattleVarTimerAccum
  • D_800F49F8 -> g_BattleConstTimerAccum
  • D_800F4A48 -> g_BattleVarTimerFrac
  • D_800F4A70 -> g_BattleConstTimerFrac
  • D_800F4A98 -> g_BattleHpChangeFrac

@Xeeynamo
Xeeynamo merged commit 8a6872e into Xeeynamo:main Oct 12, 2026
1 check passed
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