Kajar notes of ChronoRET, rebuilding Chrono Trigger one matched routine at a time

Last updated: October 9, 2026

Battle targeting

Choosing who an action hits ($C1:1FDD–$C1:283C): the table of target modes and their handlers, the four area shapes, and the candidate-list helpers. The menu side that drives it (BattleMenu_BuildTargetList, the target-select input and the commit) is on the Battle menu page; the position queries of service 5 are on Battle engine.

See also: Battle menu, Battle actions.

Target modes

BattleMenu_BuildTargetList ($C1:1F79) records the caster, blanks the candidate and selection lists (!BattleTgt_Candidates, !BattleTgt_Selected, battler slots 0–2 for the PCs and 3–10 for the enemies), and runs the handler for !BattleTgt_Mode & $7F (clamped to $20) from BattleTgt_ModeTable ($C1:1FF8, 33 words). Each handler fills the candidates, seeds the selection from the cursor, and says whether the player may move the cursor (!BattleTgt_CanCycle) or the action hits the whole list (!BattleTgt_TargetAll = $80). An empty selection means "no valid target".

Modes Handler Targets
others BattleTgt_SingleAlly One PC, cursor may cycle (the default)
$01, $04 BattleTgt_AllAllies All PCs
$02 BattleTgt_Self The caster
$03 BattleTgt_SingleKoAlly One PC whose status bit 7 is set (by context, a KO'd ally)
$05, $06 BattleTgt_PcByCharId5 / 4 The party member with a given character id
$07 BattleTgt_SingleEnemy One enemy, cursor may cycle
$08, $0A BattleTgt_AllEnemies All enemies
$09 BattleTgt_Everyone Everyone
$0B–$0D BattleTgt_EnemyLineFrom* Enemies on a line from a PC toward a chosen enemy
$0F, $11–$14, $18, $1A, $1B radius, row and triangle handlers Enemies inside a circle, a row band, or the triangle of the three PCs

Area shapes

The area modes pick an anchor (the caster, a chosen enemy, or a particular party member), fill the area parameter block (!BattleTgt_AreaCentre, AreaAim, AreaSize, AreaVariant, AreaSide), run one geometry routine that writes the battlers it hits into the candidates, and select the whole list:

Routine Address Shape
BattleTgt_AreaRow $C1:2332 A band of ±$20 around the anchor's screen Y
BattleTgt_AreaPartyTriangle $C1:23A4 Inside the triangle whose corners are the three PCs
BattleTgt_AreaLine $C1:25A3 Along the line from a source toward the aimed-at battler
BattleTgt_AreaCircle $C1:2701 Within a radius of the centre battler

Some handlers look for a specific party member: BattleTgt_EnemyLineFromChar3 and BattleTgt_Char3Radius use the member with character id 3 (!Pc_CharRobo, inferred: Robo), and BattleTgt_Char6Radius the member with id 6; they return early when no PC has that id. The enemy-anchored modes let the D-pad move the aim, with a sound on each step.

Service 7 (BattleTgt_RunAreaQuery, $C1:1FDD) runs one of the same geometry routines by !BattleTgt_AreaType through BattleTgt_AreaTable (7 entries). Its header reads it as "presumably" how code outside the menu (enemy scripts, scripted attacks) asks which battlers an area hits.

Candidate-list helpers

$C1:27AD–$C1:283C: BattleTgt_AreaAddAnchor (put the anchor first), CompactCandidates, ClearLists, SelectAllCandidates, CycleNext / CyclePrev (move the cursor to the next non-empty candidate, wrapping at 11) and AnyCandidate.

34functions matched
2,064code bytes matched
34readable
34verified

Functions

AddressFunctionSizeStatusNotes
$C1:1FDDBattleTgt_RunAreaQuery13verifiedService 7 of the $C10045 service dispatcher (dispatch table at $C10051; reached only by same-bank JSR from bank $C1, see BattleMenu_EnqueueReadyBattler).
$C1:1FEABattleTgt_AreaTable14verified
$C1:1FF8BattleTgt_ModeTable66verifiedTarget-mode handler table, indexed by (!BattleTgt_Mode & $7F) clamped to $20, called from BattleMenu_BuildTargetList.
$C1:203ABattleTgt_SingleAlly11verifiedDefault mode: one PC (slots 0-2), cursor may cycle.
$C1:2045BattleTgt_CollectValidTargets85verified
$C1:209ABattleTgt_AllAllies15verifiedevery PC
$C1:20A9BattleTgt_SingleEnemy13verifiedone enemy (3-10), cursor may cycle.
$C1:20B6BattleTgt_AllEnemies16verified
$C1:20C6BattleTgt_Everyone16verifiedall battlers 0-10
$C1:20D6BattleTgt_Self10verifiedthe shown PC only
$C1:20E0BattleTgt_SingleKoAlly86verifiedLists the PCs whose BattlerStats.Status has bit 7 set — by context, KO'd allies, i.e.
$C1:2136BattleTgt_PcByCharId54verifiedTargets the one party member whose !Pc_CharId equals !BattleTgt_WantedChar (5 for this entry, 4 via BattleTgt_PcByCharId4).
$C1:213ABattleTgt_FindPcByCharId41verified
$C1:2163BattleTgt_PcByCharId46verified; state as PcByCharId5
$C1:2169BattleTgt_EnemyLineFromCaster70verified
$C1:21AFBattleTgt_EnemyLineFromChar384verifiedas above, but the source is the party member with character id 3 (!Pc_CharRobo, inferred: Robo; the name keeps the numeric id).
$C1:2203BattleTgt_EnemyLineFromCaster272verifiedsame as EnemyLineFromCaster with !BattleTgt_AreaVariant = 1
$C1:224BBattleTgt_CasterRadius20verifiedarea $10 around the caster
$C1:225FBattleTgt_EnemyRadius69verifiedarea around a chosen enemy; size $19 for mode $1A, else $09
$C1:22A4BattleTgt_Char3Radius47verifiedarea around party member id 3; size $19 for mode $14, else $10.
$C1:22D3BattleTgt_Char6Radius34verifiedarea $19 around party member id 6.
$C1:22F5BattleTgt_EnemyRow52verifiedchosen enemy as anchor for BattleTgt_AreaRow (a +/-$20 band around the anchor's !Battler_ScreenY)
$C1:2329BattleTgt_PartyTriangle9verifiedenemies inside the triangle formed by the three PCs (BattleTgt_AreaPartyTriangle)
$C1:2332BattleTgt_AreaRow114verified"Row" area: every eligible battler on the scanned side whose screen y (!Battler_ScreenY) lies within +/-$20 of the centre battler's y.
$C1:23A4BattleTgt_AreaPartyTriangle511verifiedEnemies inside the triangle whose corners are the screen positions of party slots 0, 1 and 2 (!Battler_ScreenX/Y for slots 0-2).
$C1:25A3BattleTgt_AreaLine350verified"Line" area from the source battler (!BattleTgt_AreaCentre) towards the aimed-at battler (!BattleTgt_AreaAim), half-width r = AreaSize * 8 (passed to Battle_SinLookup as !Battle_SinScale; AreaSize...
$C1:2701BattleTgt_AreaCircle172verified"Circle" area around the centre battler (!BattleTgt_AreaCentre).
$C1:27ADBattleTgt_AreaAddAnchor24verifiedShared tail of the area scans: puts !BattleTgt_Anchor at the front of !BattleTgt_Candidates if it belongs to the scanned side (see the AreaCircle header), then falls into BattleTgt_CompactCandidates.
$C1:27C5BattleTgt_CompactCandidates20verifiedif the front slot is empty, shift the list left by one.
$C1:27D9BattleTgt_ClearLists15verifiedblank candidate and selection lists (12 entries each, one more than they use)
$C1:27E8BattleTgt_SelectAllCandidates18verifiedset target-all and copy the 11 candidates into the selection list
$C1:27FABattleTgt_CycleNext26verifiedadvance !BattleTgt_Cursor to the next non-empty candidate (wrap at 11); no-op on an empty list.
$C1:2814BattleTgt_CyclePrev25verifiedmirror of CycleNext
$C1:282DBattleTgt_AnyCandidate16verifiedZ=1 if all 11 candidate slots are $FF, Z=0 as soon as one isn't

Generated from functions.csv. Do not edit.