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.
Functions
| Address | Function | Size | Status | Notes |
|---|---|---|---|---|
$C1:1FDD | BattleTgt_ | 13 | verified | Service 7 of the $C10045 service dispatcher (dispatch table at $C10051; reached only by same-bank JSR from bank $C1, see BattleMenu_EnqueueReadyBattler). |
$C1:1FEA | BattleTgt_ | 14 | verified | |
$C1:1FF8 | BattleTgt_ | 66 | verified | Target-mode handler table, indexed by (!BattleTgt_Mode & $7F) clamped to $20, called from BattleMenu_BuildTargetList. |
$C1:203A | BattleTgt_ | 11 | verified | Default mode: one PC (slots 0-2), cursor may cycle. |
$C1:2045 | BattleTgt_ | 85 | verified | |
$C1:209A | BattleTgt_ | 15 | verified | every PC |
$C1:20A9 | BattleTgt_ | 13 | verified | one enemy (3-10), cursor may cycle. |
$C1:20B6 | BattleTgt_ | 16 | verified | |
$C1:20C6 | BattleTgt_ | 16 | verified | all battlers 0-10 |
$C1:20D6 | BattleTgt_ | 10 | verified | the shown PC only |
$C1:20E0 | BattleTgt_ | 86 | verified | Lists the PCs whose BattlerStats.Status has bit 7 set — by context, KO'd allies, i.e. |
$C1:2136 | BattleTgt_ | 4 | verified | Targets the one party member whose !Pc_CharId equals !BattleTgt_WantedChar (5 for this entry, 4 via BattleTgt_PcByCharId4). |
$C1:213A | BattleTgt_ | 41 | verified | |
$C1:2163 | BattleTgt_ | 6 | verified | ; state as PcByCharId5 |
$C1:2169 | BattleTgt_ | 70 | verified | |
$C1:21AF | BattleTgt_ | 84 | verified | as above, but the source is the party member with character id 3 (!Pc_CharRobo, inferred: Robo; the name keeps the numeric id). |
$C1:2203 | BattleTgt_ | 72 | verified | same as EnemyLineFromCaster with !BattleTgt_AreaVariant = 1 |
$C1:224B | BattleTgt_ | 20 | verified | area $10 around the caster |
$C1:225F | BattleTgt_ | 69 | verified | area around a chosen enemy; size $19 for mode $1A, else $09 |
$C1:22A4 | BattleTgt_ | 47 | verified | area around party member id 3; size $19 for mode $14, else $10. |
$C1:22D3 | BattleTgt_ | 34 | verified | area $19 around party member id 6. |
$C1:22F5 | BattleTgt_ | 52 | verified | chosen enemy as anchor for BattleTgt_AreaRow (a +/-$20 band around the anchor's !Battler_ScreenY) |
$C1:2329 | BattleTgt_ | 9 | verified | enemies inside the triangle formed by the three PCs (BattleTgt_AreaPartyTriangle) |
$C1:2332 | BattleTgt_ | 114 | verified | "Row" area: every eligible battler on the scanned side whose screen y (!Battler_ScreenY) lies within +/-$20 of the centre battler's y. |
$C1:23A4 | BattleTgt_ | 511 | verified | Enemies inside the triangle whose corners are the screen positions of party slots 0, 1 and 2 (!Battler_ScreenX/Y for slots 0-2). |
$C1:25A3 | BattleTgt_ | 350 | verified | "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:2701 | BattleTgt_ | 172 | verified | "Circle" area around the centre battler (!BattleTgt_AreaCentre). |
$C1:27AD | BattleTgt_ | 24 | verified | Shared 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:27C5 | BattleTgt_ | 20 | verified | if the front slot is empty, shift the list left by one. |
$C1:27D9 | BattleTgt_ | 15 | verified | blank candidate and selection lists (12 entries each, one more than they use) |
$C1:27E8 | BattleTgt_ | 18 | verified | set target-all and copy the 11 candidates into the selection list |
$C1:27FA | BattleTgt_ | 26 | verified | advance !BattleTgt_Cursor to the next non-empty candidate (wrap at 11); no-op on an empty list. |
$C1:2814 | BattleTgt_ | 25 | verified | mirror of CycleNext |
$C1:282D | BattleTgt_ | 16 | verified | Z=1 if all 11 candidate slots are $FF, Z=0 as soon as one isn't |