Wikifang:Telefang 1 Translation Patch/State Machine: Difference between revisions

From Wikifang, a definitive guide to Telefang, Dino Device and Bugsite
Jump to navigation Jump to search
(Created page with "Telefang's primary game loop is structured as a state machine. Each iteration of the game loop executes a handful of predefined tasks, and then indexes a jump table to load ot...")
 
No edit summary
Line 2: Line 2:


State machines are indexed through four primary SystemState variables, and two secondary state variables. The secondary state variables are used in certain states for various reasons - usually to prevent overwriting the state of another screen. (Why they didn't set up a proper state stack for this sort of thing is beyond me...)
State machines are indexed through four primary SystemState variables, and two secondary state variables. The secondary state variables are used in certain states for various reasons - usually to prevent overwriting the state of another screen. (Why they didn't set up a proper state stack for this sort of thing is beyond me...)
{| class="wikitable"
|-
! WRAM Addr !! Disassembly Symbol !!
|-
| $C3E0 || W_SystemState || First order state index
|-
| $C3E1 || W_SystemSubState || Second order state index
|-
| $C3E2 || W_SystemSubSubState || Third order state index (primary)
|-
| $C3E3 || (Not named) || Fourth order state index (presumed primary, not yet seen in practice)
|-
| $1:D400 || W_Battle_SubSubState || Third order state index (secondary)
|-
| $1:D401 || W_Battle_4thOrderSubState || Fourth order state index (secondary)
|}

Revision as of 11:22, 22 July 2017

Telefang's primary game loop is structured as a state machine. Each iteration of the game loop executes a handful of predefined tasks, and then indexes a jump table to load other screens' code. This indexing can be recursive, with individual states running their own predefined tasks before jumping into sub-states. This is known to recurse to at least fourth-order state machines.

State machines are indexed through four primary SystemState variables, and two secondary state variables. The secondary state variables are used in certain states for various reasons - usually to prevent overwriting the state of another screen. (Why they didn't set up a proper state stack for this sort of thing is beyond me...)

WRAM Addr Disassembly Symbol
$C3E0 W_SystemState First order state index
$C3E1 W_SystemSubState Second order state index
$C3E2 W_SystemSubSubState Third order state index (primary)
$C3E3 (Not named) Fourth order state index (presumed primary, not yet seen in practice)
$1:D400 W_Battle_SubSubState Third order state index (secondary)
$1:D401 W_Battle_4thOrderSubState Fourth order state index (secondary)