ATB Processing
2025-03-28
The order of entity processing is randomly determined at the start of battle and stored in the iniative table, the index of the next entity to be processed is stored at $7EB185 (the initiative pointer). Also at the start of battle the minium ATB counter is found and that value is subtracted from every entities ATB, moving everyone’s turn up and ensuring that at least one entity is ready to act at the beginning of battle.
ATB is decremented for every active entity every frame. After the decrement each ATB’s are checked in iniative order to see if it is now 0, if so the entity is marked as ready to act and no additional ATBs are checked (only one entity can be active at a time). If the initiative pointer points to an FF, we’ve reached the end of the entity list, it is reset to 0 and no more entities are processed that frame. If a PC is ready to attack but has not yet entered a command, the processing will still stop when they are the next entity to be processed.
As a concrete example, in the speedrun the first encounter is the set of three Blue Imps in Truce Canyon once you go through the portal. This is a battle Crono fights alone.
The iniative table given the speedruns RNG value:
[0x05, 0x07, 0x00, 0x06, 0x0A, 0x04, 0x03, 0x08, 0x09, 0xFF, 0xFF]
^
Crono is entity 0x00, and the three Blue Imps are 0x03, 0x04, and 0x05
Crono has the lowest max ATB so his ATB is set to 0 and each enemies ATB is set to their max minus Crono’s max.
The first frame of combat the iniative pointer moves to Crono’s slot (Crono is PC 0, which is in slot 2), finds that he is ready to act, increments the iniative pointer and continues.
[0x05, 0x07, 0x00, 0x06, 0x0A, 0x04, 0x03, 0x08, 0x09, 0xFF, 0xFF]
^
On the next frame none of the entities from slot 4 to the end are ready to act, so the initiative pointer resets to 0
[0x05, 0x07, 0x00, 0x06, 0x0A, 0x04, 0x03, 0x08, 0x09, 0xFF, 0xFF]
^
Fast forward a few frames until a Blue Imp is ready to attack. On the previous frame Crono still hadn’t initiated an action, so the pointer stopped just after him
[0x05, 0x07, 0x00, 0x06, 0x0A, 0x04, 0x03, 0x08, 0x09, 0xFF, 0xFF]
^
04, 03, and 05 are all at ATB 0, but only one of them can be processed on this turn. 0x04 is marked as ready to act and the iniative pointer points to the slot just after 0x04.
[0x05, 0x07, 0x00, 0x06, 0x0A, 0x04, 0x03, 0x08, 0x09, 0xFF, 0xFF]
^
On the following frame 0x03 is marked as ready to act
[0x05, 0x07, 0x00, 0x06, 0x0A, 0x04, 0x03, 0x08, 0x09, 0xFF, 0xFF]
^
On the following frame 0x08 and 0x09 are checked but they are not active entities, 0xFF is found so the initiative pointer is reset to 0.
[0x05, 0x07, 0x00, 0x06, 0x0A, 0x04, 0x03, 0x08, 0x09, 0xFF, 0xFF]
^
Finally, 0x05 is marked as ready to act. By this point it has been 3 frames since 0x04 acted and 2 frames since 0x03 acted, both of those enemies have already started counting down their ATB timers again so they end up “faster” than 0x05 throughout the rest of the battle.