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

Last updated: October 9, 2026

Battle engine

Bank $C1 is the battle engine; nearly all of it is one system. The battle runs with DP=$0000 and DB=$7E, and keeps its state in bank-$7E WRAM (names in asm/include/ram_battle.inc, all starting with Battle, Battler, Pc, Enemy, Tech, Item or Sfx). Long helpers in bank $FD (BattleFD_*) do much of its setup and its ends.

This page covers the battle's structure and the shared services. The parts with their own pages: Battle actions (service 4 and the action scripts), Battle menu, Battle targeting and Status bar & text.

"Victory", "defeat", "attack", "tech", "item" and the like below follow the headers, which take them from the services' and records' known roles; where a header hedges, so does this page.

Entering and leaving

The field enters the battle with JSL $C10000 (in DefaultHandler, $C0:18A7). Per the headers that chain runs JMP $001B → JML $CF:FB65 (which clears the battle RAM) → $C1:8000 (BankC1_BattleStartVec) → BattleSys_Main. The battle leaves through BattleSys_ExitVec ($C1:0006 → $001F → JML $CF:FBE5); the vectors at $C1:0000–$0050 and the code in bank $CF are not matched yet. On the field side Scene_Unk0283 reads FieldBtl_Result to decide how to come back.

BattleSys_Main

BattleSys_Main ($C1:8006, 1,115 bytes) is the battle from its setup to its end; it never returns.

Setup. BattleFD_UnkA982, the random index, Battle_SetupBattle ($C1:FA8B: the battlers' records, the enemies' stats, the PCs' tech menus, the turn-list state, mostly through bank-$FD callees), then service 0. Then two shuffles with Battle_RandRange: Battle_SlotOrder, a random order of the battlers taking part, and Battle_EnemyOrder, the present enemies in a random order. Then BattleSys_Unk8C09, which runs the main part of each enemy's behaviour script once.

Each pass of the main loop: service 3 (BattleSys_UpkeepTwoFrames, two frames of upkeep), the KO checks (BattleSys_UnkB223), then the first of:

  • Battle_Unk24 set: the defeat end;
  • no enemy entry left: the victory end;
  • otherwise the low-HP bits and the turn-list membership of every battler (BattleSys_UnkB093, BattleSys_UnkB0B6), then by state: in wait mode (Battle_MenuTimeHold) only the PCs' pending commands; with Battle_Unk99CD set its end (probably running away; not traced); with Battle_UnkAF25 set the turn handler BattleSys_Unk8461 directly; else the turn lists.

Ends. Victory plays service 8 (BattleSys_VictoryPose), puts the max HP back and adds the gold and item rewards, then hands out the experience and tech points (BattleSys_AwardExpAndTp, see After a won battle); defeat runs service 3 eight times and then service 9 (BattleSys_DefeatPose). A dead debug check (.debug_check, pad 2) can end the battle as a win. The defeat, victory and Battle_Unk99CD ends clear the PCs' battle statuses (BattleSys_ClearPcStatuses: .Status2 and the eight .Unk4C bytes, everything in .Status but the KO bit; "so the battle statuses do not outlast it, probably"), and BattleSys_ClearPcKo then clears .Status altogether, KO bit included (after the victory messages, and on the end shared by defeat, the Battle_Unk99CD end and the bit-5 battle). All ends save the random index back and copy Battle_Unk1C48 entries to the PCs' BattlerStats.Unk56 before BattleFD_UnkAAB0.

Turn lists

Thirteen per-slot lists ($C1:8461–$C1:8C3D), each one byte per list and battler slot in four 13 × 11-byte arrays: Battle_ListTimers (countdowns), Battle_ListFlags (bit 7 due, low bits "takes part"), Battle_ListRuns (runs left) and Battle_ListReload (timer reload). BattleSys_Main counts the timers down each pass; every second pass it scans each list for the next due slot in Battle_SlotOrder and runs that list's entry of BattleSys_ListHandlerTable ($C1:B92D).

List Handler What it does
0, 2–5, 10 BattleSys_ListHandler0 … The usual handler: re-arm the entry, count its runs down, and at 0 clear one status bit of the slot and stop the entry
1 BattleSys_ListHandler1 A repeating hit on the slot (inferred from where the amount goes)
6, 7, 11 BattleSys_ListHandler6/7/11 Nothing (RTS)
8, 9 BattleSys_ListHandler8/9 Re-arm with the timer halved or doubled by status bits
12 BattleSys_Unk8461 The battlers' turns: a ready PC is queued for the command menu (service 1), a ready enemy acts (BattleAi_EnemyTurn), committed PC commands run (BattleSys_UnkB967), then the enemies' reaction scripts

The banner reads lists 0–5 and 8–10 as timed statuses from their shape; which status each list is, is not traced.

Enemy behaviour scripts

An enemy's script lives in bank $CC at the address !BattleRom_AiScriptPtrs gives for its id. It has two parts, each ended by $FF: the main part, run for each enemy by BattleSys_Unk8C09 / BattleAi_RunMainPart ($C1:AFD2), and the reaction part, run by BattleSys_Unk8461 after a turn (BattleAi_FindReactPart, $C1:B488). A part is a list of blocks; a block is one or two 4-byte test records ending in $FE, then action records ending in $FE. The first byte of a record is its code:

Table Address Entries Run by
BattleAi_TestTable $C1:B80D 41 test codes $00–$28 BattleAi_RunMainPart, the reaction loop
BattleAi_ChooseTable $C1:B85F 23 action codes $00–$16 BattleAi_TestPassed, as a block is chosen
BattleAi_RunTable $C1:B88D the same 23 action codes BattleAi_EnemyTurn, on the enemy's turn
BattleAi_TargetTable $C1:B8BB 57 target codes $00–$38 BattleAi_ReadTargets

A test that holds calls BattleAi_TestPassed ($C1:8C3E), which runs the block's next action through the choose table; on the enemy's turn BattleAi_EnemyTurn ($C1:8CF9) runs it again through the run table; the action block that service 4 plays is started by BattleAi_FillActBlock. Target codes fill the list BattleAi_Targets, with helpers that pick PCs by a stat-block byte, cut the list down to one, or keep the marked entries ($C1:AC14–$C1:AF21). The names "test", "action" and "target" are inferred from what the matched handlers do. The handlers themselves (BattleAi_TestNN etc., $C1:8EAB–$C1:AC13) are not matched yet, except test $00, which always holds.

PC commands and techs

BattleSys_UnkB967 ($C1:B967, the "PC command runner") runs the command a PC committed in the battle menu, from its BattleCmd record: an attack through BattleSys_RunPcAttack, an item as action kind 3, or a tech as kind 2 with its users' MP paid (BattleSys_PayTechMp); then it reloads the users' gauges (!Battler_UnkAFAB, probably the ATB gauge's reload value) and clears the records (BattleSys_UnkBCE1, BattleSys_ResetTechUsers).

Battle_SetupBattle builds each PC's 20 tech menu entries with BattleSys_UnkC96A, BattleSys_UnkCA1A and BattleSys_UnkCCCB ($C1:C96A–$C1:CDFE): single techs at entries 0–7, up to 6 double techs at 10–15 and a triple tech at 18, each only when all its users are in the party. A tech's record names its users and each user's part; BattleSys_TechMpCost1-3 read each part's MP cost and BattleSys_AdjustMpCost halves or quarters it by a per-PC byte.

Before a command runs, BattleSys_UnkC1DD ($C1:C1DD–$C1:C8F6) checks that the caster and its partners can act (not KO'd, no status that stops them) and resolves the targets into a list of slots from the tech's, item's or enemy action's target mode and area number; if that fails the action is dropped.

Effects and damage

A tech (or a PC's attack) runs as up to three parts, one per user. BattleSys_RunTechParts ($C1:D523) checks the MP, then for each part copies a 12-byte effect record whose byte 0, the effect type, picks a routine from BattleSys_EffectTable ($C1:D9D7, 45 words; types $09–$28 do nothing). An item runs one of types $29–$2B straight from BattleSys_UnkBF46, and the enemy runners BattleSys_UnkD7C4 / D8D1 use the same table. The effect routines ($C1:D221–$C1:D48E) work on the targets from the last to the first. Their headers read them, "probably", as: 0 restores HP / MP, 1 cures statuses, 2 sets statuses, 3 is a hit with damage, 5 drains HP / MP, 6 steals, 7 gives up the caster's HP, 8 repeats type 3.

The arithmetic they call ($C1:DA37–$C1:E89E, and BattleSys_StealItem at $C1:E9D5):

  • Restore (BattleSys_RestoreHpMp): HP by an amount × a factor plus a random part (for a PC capped at 999), or the full maximum for factor $0F; MP the same way, in tens.
  • Statuses: BattleSys_CureStatus clears them (KO too, with a flag) and the PC's turn-list flags; BattleSys_SetStatus sets status bits in one of six status bytes (for the first three, only when the target lacks those bits in a byte the header reads as "probably the target's protection"), and BattleSys_ArmStatusList starts the turn list that times the new status (lists 0, 3, 4 and 5 clear their bit when they run out).
  • Type 3, a hit: an enemy-only bit test ("probably an immunity"), then the hit roll (BattleSys_RollHit: chance = caster's value × 100 / target's value against a roll of 0–99, the two values first adjusted by statuses in BattleSys_AdjustHit / BattleSys_AdjustEvade), then the damage. BattleSys_CalcDamage picks a formula by an effect byte (kinds 1–7), each a mix of the caster's stats scaled by another effect byte, with a random part bounded by one of the fixed fractions (Battle_Scale*, $C1:C02A–$C1:C1DC: about x / 5, x × 3 / 10 and so on, built from shifts and subtractions); the caster's status bits then raise or cut the amount. BattleSys_AdjustDefence gives a defence out of 256 from an effect byte or the target's stats, cut by its statuses, and BattleSys_ApplyDamage takes (256 − defence) / 256 of the damage plus the random part, at least 1, runs the hit modifiers on it, then cuts it to 7/10 for two statuses (probably barriers) unless the effect pierces them, and caps it at 9999. A hit also clears two status bits that BattleSys_WakeTarget reads as a status a hit ends ("sleep, probably").
  • Drain (BattleSys_DrainHpMp, type 5): a share of the target's maximum HP or MP plus a random part, capped at what it has, taken from the target and given to the caster.
  • Steal (BattleSys_StealItem, type 6, or type 3 with an effect bit): "an item taken from the target enemy, probably". A roll of 0–99 against a chance from the effect record (tripled for one caster value); on success it runs the part's hit modifier, and one of the enemy's two reward items goes to the caster's item record or the inventory (the second item first when modifier $0C said so). Each of the two can be taken once.

Hit modifiers

The 21 routines BattleSys_HitMod* ($C1:ED89–$C1:F204) are picked through BattleSys_HitModTable ($C1:FA61, 21 words) by byte 0 of a 3-byte record in the ROM table !BattleRom_UnkCC2A05; bytes 1 and 2 are their two arguments. BattleSys_RunUnkB2CCHandler ($C1:EB1C) runs one record; BattleSys_RunUnkB2CCHandlers ($C1:EA6F) runs the action part's record and then, when effect byte 8 has bit 7 and the caster's .Unk74 bit 0 is set, the caster's own record (.Unk73). BattleSys_ApplyDamage runs them after it has worked out the damage and before the barrier cuts and the 9999 cap, so most of them change that amount; BattleSys_StealItem runs one too. Which techs or weapons use which record is not traced. "A roll" here is 0–99, and most chances pass at roll ≤ the argument.

Modifier Routine What it does
$00 BattleSys_HitModChanceMul On a roll (from the second random index, Battle_RandRangeAlt) at most the caster's .Unk72, multiplies the damage and sets a flag for $13; "together these look like a critical hit (probably ...), not proven"
$01 BattleSys_HitModNone Nothing
$02 BattleSys_HitModScale Damage × argument 1 / argument 2
$03 BattleSys_HitModUnk47Scale When the target's .Unk47 has one of the given bits, damage × argument 2 / 2
$04 BattleSys_HitModPerEmptyPc Damage × (1 + the number of empty PC slots)
$05 BattleSys_HitModPlayTime A factor picked by the play-time clock (its second byte mod 10): about / 10, halved, unchanged, see the quirk, doubled or tripled
$06 BattleSys_HitModRandomStatus Sets one of four .Status2 bits, picked by a roll
$07, $08 BattleSys_HitModUnk47Status, HitModChanceStatus On a roll, sets the given .Status2 bits ($07 only when the target's .Unk47 has one of the given bits, and on a fixed roll ≤ 80)
$09 BattleSys_HitModLeaveOneHp On a roll, the hit leaves the target 1 HP
$0A BattleSys_HitModUnk6CScale Scales the damage by one of four target bytes (.Unk6C–.Unk6F, 4 being normal) picked by the action's bits; a byte's bit 7 turns the hit into healing. "This looks like four resistances by element (probably), not proven"
$0B BattleSys_HitModScaleThenUnk6C $02, then $0A
$0C BattleSys_HitModRollDp1A For the steal: on a roll below argument 1, try the enemy's second item first
$0D BattleSys_HitModRestore By argument 1's bits: a full HP restore of the target ("probably"), and/or its statuses cleared
$0E BattleSys_HitModHalveHp Unless the target's .Unk46 bit 7 is set, on a roll the damage is half its current HP
$0F, $14 BattleSys_HitModClearBits, HitModSetBits Clear or set the given bits in the target's byte at BattlerStats.Unk2D + argument 1
$10 BattleSys_HitModHpDigit Damage × the last decimal digit of the caster's HP / argument 2
$11 BattleSys_HitModZeroHp Sets the caster's HP to 0 ("probably an attack that costs the user its life") or the target's
$12 BattleSys_HitModKoOrDrop Unless the target's .Unk46 bit 7 is set, on a roll its HP goes to 0; otherwise the target is dropped from the action
$13 BattleSys_HitModAltBoost After a $00 success: damage 9999, or doubled

Quirks the headers keep: for factors 5–6, HitModPlayTime adds half of the word at $0000 (whatever the caller left there) where "x 1.5" looks intended; HitModZeroHp does not check the slot, so for a PC target its KO mark lands in the three bytes below the enemy array.

Two routines in this stretch are never called: BattleSys_AddBattleItem ($C1:EFD3, one more of an item in the battle's item list, else the inventory) and BattleSys_ReviveHeal ($C1:EB49, which looks like "probably an older form" of BattleSys_UpdateKo's one-time revive).

The headers keep the quirks found here, among them BattleSys_CalcDamage's test for kind 8, which branches the wrong way so that its block runs for every kind but 1–8 and the code for kinds 9 and 10 is never reached.

Hit records

Amounts to take off HP or MP are 4-byte entries per battler slot, in sets of 11 ($C1:E89F–$C1:E8BF, $C1:EBF8–$C1:ED88): Battle_RecordHit stores one (negated, it heals), Battle_ClearCancelledHits drops the cancelled ones, and Battle_ApplyHits ($C1:EC7F) takes them off CurHp / CurMp, clamps to the maximum, and KOs a battler whose HP reaches 0 (an enemy adds its rewards first, BattleFD_AddEnemyRewards).

After a won battle

BattleSys_AwardExpAndTp ($C1:F93E) hands out two sums over the defeated enemies' reward records: Battle_UnkB28C and Battle_UnkB2DB. The headers read them as experience and tech points from what the code does with them: the first is added to a 24-bit total and, against a table of experience to the next level, raises PcStatBlk.Level; the second is paid against tech costs and sets the bits the tech menus read. The routines ($C1:F205–$C1:FA60) set the bits that BattleFD_UnkAD17 shows its end messages by.

  • Experience. For each PC in the battle that is not KO'd, BattleSys_AddExp adds the whole sum to .Exp (capped at 9,999,999), then BattleSys_LevelUpStep runs until the sum is used up: BattleSys_ApplyExpStep pays .ExpNeed from it and, when it covers the need, raises the level (to at most 99) and loads the next need. A level-up adds HP and MP from per-character growth rows (BattleSys_GrowHpMp, capped at 999 and 99) and recomputes six stats as a base plus a growth byte × (level − 1) / 100; the stat bytes are then capped at 99, one of them at 50.
  • Characters not in the battle (BattleSys_AwardReserveExp): each character whose bit is set in Menu_Unk29AF and who has no battle slot gets the sum × 15 / 20 and one level step.
  • Tech points. BattleSys_AwardTechPoints pays the points into each PC's next single tech (BattleSys_SpendTechPoints, BattleSys_TryNextTech), learning it when its cost is covered (BattleSys_LearnSingleTech); a tech whose record has bit 7 pays nothing until the character's bit in Battle_Unk7F01E0 is set ("not open to it yet; probably magic"). The points are also added to the PC's .TechPtTotal. Then BattleSys_BuildComboMasks forms the party's pairs and trio, and BattleSys_LearnComboTechs sets the double and triple techs whose members have each learned enough single techs.

Quirks the headers keep:

  • BattleSys_SpendTechPoints takes the award (or the last leftover) off the next tech's need a second time, so tech points are counted twice "as the code reads"; NEXT.md marks it as worth a check in an emulator.
  • A character not in the battle gains at most one level per battle, and the experience past that level is not carried into .ExpNeed.
  • The messages for new double and triple techs go to the last PC slot with a character, not to each member.
  • The 9,999,999 caps of .Exp and .TechPtTotal do not catch every overflow.

Battler upkeep

$C1:B093–$C1:B487: the low-HP bit (HP at most an eighth of the maximum), which turn lists a battler takes part in from its status bits, the KO check with a one-time revive (BattleSys_UpdateKo), and the copies back to the field at the end (FieldBtlObj flags, the character records). The turn helpers ($C1:B4E9–$C1:B80C) refund items, build the PCs' command groups from their partner bytes, and handle a battle with fixed commands (Battle_Unk2989 bit 5, "a demo, probably" in NEXT.md).

Bank $FD helpers

BattleFD_* ($FD:A982–$FD:B956, 40 routines) are the battle's long callees: clearing work RAM, restoring enemies, the end messages and rewards (BattleFD_AddEnemyRewards, BattleFD_AddItemEntry), the battlers' records, the enemies' stats, the turn-list timers and the first ATB values. They run in the battle's state and use bank $C1's direct-page scratch and math cells. Five JSR/RTL veneers at $C1:FDBF–$C1:FDD2 (Battle_Mul16Long, BankC1_AddItemLong, BattleSys_RunPcAttackLong, Battle_RandRangeLong, BattleSys_RefundItemLong) let them call back into bank $C1. Most keep Unk names because verified code calls them by name; NEXT.md lists better names for when those callers are reviewed again.

Shared services and helpers

  • Inventory and gold services for the field: BankC1_Entry8003 ($C1:8003) leads to BankC1_RunService ($C1:CFC2) and BankC1_ServiceTable ($C1:D126): 0 find an item, 1 add one, 2 remove one, 3 test the 24-bit gold against an amount, 4 add gold, 5 take gold off when there is that much. The event opcodes $C7, $C9–$CE use them (see Field event scripts).
  • The service dispatcher at $C1:0045 (table at $C1:0051, reached only by same-bank JSR): 1 enqueue a ready battler, 2 remove one, 3 two frames of upkeep, 4 play an action, 5 position queries (BattlePos_Query), 7 target area query, 8 victory pose, 9 defeat pose; service 0 ends in Battle_StartPose, service 6 is not analysed.
  • Frame wait: BattleSys_PumpFrames ($C1:007E), a frame wait by inference (see Frame cycle and NMI).
  • Maths: Battle_Mul8, Battle_Mul8x16 and Battle_Divide on the hardware maths unit ($C1:0089–$C1:010C), the overlapping shift tails ($C1:010D–$C1:011E), the shift-and-add Battle_Mul16 and Battle_Div32 ($C1:C90B–$C1:C95B), and Battle_RandRange ($C1:AF22), a random number in a range from RandomTableFD, and Battle_RandRangeAlt ($C1:AF79), the same with its own index into the table.
  • Geometry: Battle_SinLookup and Battle_CalcAngle ($C1:01F9–$C1:0298, 256 steps per turn); battler boxes and their collision tests ($C1:283D–$C1:2985); the position queries of service 5 ($C1:2986–$C1:2D9E: nearest or farthest PC or enemy, distance checks, a path check, screen-half tests).
  • Animation: the battler frame decoder (Battle_DrawBattlerFrameAnyLayout, $C1:1C55), the PC and enemy animation ticks, the status animation picker and its eight effect handlers ($C1:2F97–$C1:3233), the PC poses, and the enemy movers (see Battle actions).

What is not matched yet

From NEXT.md, in reach order: the script handlers BattleAi_TestNN / ChooseNN / RunNN / TargetNN ($C1:8EAB–$C1:AC13), three bank-$FD callees ($FD:A8A5, A93C, A95F), the vectors at $C1:0000–$C1:0050 and service 0. The headers also name calls from unmatched code just after the long veneers ($C1:FDD6–$C1:FDDE).

1,182functions matched
95,028code bytes matched
1,182readable
1,182verified

Functions

AddressFunctionSizeStatusNotes
$C1:0003BattleSys_RunServiceVec3verified
$C1:0006BattleSys_ExitVec3verified
$C1:0023BattleSys_SceneSetup34verifiedService 0 (!BattleSys_ServiceUnk0), the first service BattleSys_Main requests: the battle's display set-up, probably.
$C1:0045BattleSys_RunService11verifiedThe service dispatcher: runs BattleSys_ServiceTable entry A (JSR (T,X) with X = A * 2) and puts A, X and Y back as they were.
$C1:0050BattleSys_RunService_Rts1verified
$C1:0051BattleSys_ServiceTable20verifiedThe services of BattleSys_RunService, by number * 2.
$C1:006DBattleSys_Service65verifiedService 6 (!BattleSys_ServiceUnk6): JSL BattleCF_RemoveMarkedEnemies (the enemies marked in !Battle_UnkAEB3 leave, !Battler_Present cleared, except one with !Battler_Unk9FF7 0, !Battler_ActAttr...
$C1:007EBattleSys_PumpFrames11verifiedWaits for the next frame: sets !Battle_FramePending, then calls BattleSys_IdleVecCD0036 again and again until something else clears the flag.
$C1:0089Battle_Mul830verified8×8→16 HW multiply via WRMPYA/WRMPYB/RDMPYL.
$C1:00A7Battle_Mul8x1648verified8×16→24 multiply in two hardware passes (the top byte of the product is zeroed first, so nothing from the caller is accumulated): pass 1: Factor8 × low byte of Factor16 -> Product+0/+1 pass 2...
$C1:00D7Battle_Divide54verified16÷8 HW divide via WRDIVL/WRDIVH/WRDIVB, quotient from RDDIVL and remainder from RDMPYL.
$C1:010DBattle_ShiftLeft84verified$C1:010D–$C1:011E — Shift helpers (18 bytes, $010D–$011E) Overlapping fall-through stubs for power-of-2 left/right shifts on A.
$C1:0111Battle_ShiftLeft41verified
$C1:0112Battle_ShiftLeft34verified
$C1:0116Battle_ShiftRight82verified
$C1:0118Battle_ShiftRight61verified
$C1:0119Battle_ShiftRight51verified
$C1:011ABattle_ShiftRight41verified
$C1:011BBattle_ShiftRight34verified
$C1:01F9Battle_SinLookup41verifiedScaled sine: returns (sin(A) × !Battle_SinScale) >> 8 in A.
$C1:0222Battle_CalcAngle119verifiedDirection angle between two screen points (256 units per turn).
$C1:103EBattleSys_SlotMenuReadyPredicate16verifiedReturns A=0 if PC slot !BattleMenu_ReadySlotArg is menu-ready: in the roster (!BattleMenu_Roster entry not negative) and !Pc_LockStatus clear; nonzero otherwise.
$C1:106EBattleSys_UpkeepTwoFrames117verifiedService 3 of the same-bank $C10045 service dispatcher (reached only by JSR $0003/$0045 inside bank $C1; returns RTS; dispatch table at $C10051, entry 3 = $106E; searched: no JSR, JMP or JSL...
$C1:179CBattle_ClearPadEdges5verifiedClears both pad-edge bytes and returns.
$C1:1B55Battle_PlaySfx018verifiedAPU command !Sfx_CmdPlay with sound id 0: fills !Sfx_Command / !Sfx_Param1 / !Sfx_Param2 (the same command block bank $C0's Audio_PlayTileSfxA fills) and calls the audio driver entry.
$C1:1C4ABattle_DrawBattlerFrame11verifiedDecodes frame !Battle_FrameId of battler !Battle_FrameSlot into the battler's tile buffer in bank $7E, unless the battler uses frame layout 3 (!Battle_FrameLayoutStrip), which this entry leaves alone.
$C1:1C55Battle_DrawBattlerFrameAnyLayout804verifiedDecodes one animation frame of a battler into bank $7E tiles: 1.
$C1:283DBattle_CacheBattlerCoordsAll29verifiedCopies every present battler's screen position into its probe position and rebuilds its box.
$C1:285ABattle_CalcBattlerBox86verifiedBuilds battler X's box from its probe position: left = ProbeX - HalfWidth, clamped at 0 right = ProbeX + HalfWidth, clamped at $FF top = ProbeY - Height, clamped at 0 bottom = ProbeY + 8, or...
$C1:28B0Battle_BoxOverlapsOthers118verifiedTests the box of battler !Battle_BoxTestSlot against the box of every other present battler, skipping those with !Battler_Unk9FF7 or !Battler_UnkA5CD bit 7 set.
$C1:2926Battle_BoxHitsBlockedCell96verifiedTests whether the box of battler !Battle_BoxTestSlot covers a blocked cell of !Battle_CellMap (16x16-pixel cells, 16 per row).
$C1:2986BattlePos_Query44verifiedService 5 of the same-bank $C10045 service dispatcher (reached only by JSR $0003/$0045 inside bank $C1; returns RTS; dispatch table at $C10051, entry 5 = $2986; searched: no JSR, JMP or JSL...
$C1:29B2BattlePos_NearestPc73verified/ BattlePos_FarthestPc / BattlePos_NearestEnemy / BattlePos_FarthestEnemy ($C129B2–$C12AE2, 305 bytes; queries 0-3)
$C1:29FBBattlePos_FarthestPc72verified
$C1:2A43BattlePos_NearestEnemy85verified
$C1:2A98BattlePos_FarthestEnemy75verified
$C1:2AE3BattlePos_WithinDist40XY12verifiedBattlePos_WithinDist* ($C12AE3–$C12BBB, 217 bytes; queries 4 and 14)
$C1:2AEFBattlePos_WithinDist32XY12verified
$C1:2AFBBattlePos_WithinDist64XY12verified
$C1:2B07BattlePos_WithinDist4XY12verified
$C1:2B13BattlePos_WithinDist4XYTwin12verified
$C1:2B1FBattlePos_WithinDist16XY12verified
$C1:2B2BBattlePos_WithinDist4812verified
$C1:2B37BattlePos_WithinDist3210verified
$C1:2B41BattlePos_CheckPairDist8verified
$C1:2B49BattlePos_CheckDist115verified
$C1:2BBCBattlePos_SameRowBand30verified/ BattlePos_SubjectAbove / BattlePos_SubjectLeft ($C12BBC–$C12C01, 70 bytes; queries 5-7)
$C1:2BDABattlePos_SubjectAbove20verified
$C1:2BEEBattlePos_SubjectLeft20verified
$C1:2C02BattlePos_PathClear165verifiedPlaces the subject's probe position out from its screen position in the direction Battle_CalcAngle gives from the subject to the other battler, at a radius of !Battle_SinScale (see the quirk...
$C1:2CA7BattlePos_SubjectLowerHalf19verified/ BattlePos_SubjectUpperHalf / BattlePos_SubjectRightPart / BattlePos_SubjectLeftPart ($C12CA7–$C12CF2, 76 bytes; queries 9-12)
$C1:2CBABattlePos_SubjectUpperHalf19verified
$C1:2CCDBattlePos_SubjectRightPart19verified
$C1:2CE0BattlePos_SubjectLeftPart19verified
$C1:2CF3BattlePos_DistDifference142verifiedMeasures, from the other battler's screen position, the squared distance to the subject (d1) and to the battler in !BattlePos_Arg (d2), and stores |d2 - d1| / 256 (low byte) in !BattlePos_Found.
$C1:2D81BattlePos_ModeTable30verifiedquery handlers by !BattlePos_Mode, called from BattlePos_Query.
$C1:2D9FBattle_TickPcSlots384verifiedPer-frame animation step for the three PCs.
$C1:2F1FBattle_UnkThunk2F1F3verifieda lone JMP to the RTS that ends Battle_TickEnemyGroup ($C1:34A6).
$C1:2F22Battle_UpdatePcFacing117verifiedTurns PC !Battle_TickSlot toward its nearest enemy, one PC at a time: !Battle_FacingTurn holds the PC whose turn it is (bit 7 = the turn was handed on and has not been taken yet).
$C1:2F97Battle_PickStatusAnim197verifiedPicks the animation and the status effect for battler !Battle_TickSlot from its status bytes: - default animation 3 (!Battle_AnimDefault), or 0 for an untargetable battler; effect !Battle_FxNone...
$C1:305CBattle_PickNextStatusAnim48verifiedRuns Battle_PickStatusAnim for one battler per call, the slot in !Battle_StatusAnimNext (if present), and moves it on; past slot 10 it counts a wrap in !Battle_StatusAnimWraps and goes back to...
$C1:308CBattle_ApplyPendingEffect42verifiedFor battler !Battle_TickSlot, if present: when the effect picked (!Battler_FxWanted) differs from the one running (!Battler_FxApplied), records it, stops the overlay and the colour cycle, clears...
$C1:30B6Battle_FxReset43verifiedEffect 0 (none): clears the battler's effect flags; for a PC also copies the saved palette (!Battle_PaletteSaved, 26 bytes from !Battler_Palette * 16) back over the live one, undoing a tint or...
$C1:30E1Battle_FxOverlay2Tint96verifiedEffect 3: resets, starts overlay 2 and marks the battler tinted (!Battler_FxTinted); for a PC also restores the saved palette from byte 2 on (24 bytes) and then writes the 4 bytes at...
$C1:3141Battle_FxOverlay734verifiedEffect $0E: resets and starts overlay 7.
$C1:3163Battle_FxOverlay634verifiedEffect 9: resets and starts overlay 6.
$C1:3185Battle_FxColourCycle12verifiedEffects 6, 7, $0B, $0C and $0D: resets and starts the colour cycle from step 0.
$C1:3191Battle_FxOverlay131verifiedEffects 1, 2 and $0A: starts overlay 1.
$C1:31B0Battle_FxOverlay334verifiedEffect 4: resets and starts overlay 3.
$C1:31D2Battle_FxOverlay434verifiedEffect 5: resets and starts overlay 4.
$C1:31F4Battle_FxOverlay534verifiedEffect 8: resets and starts overlay 5.
$C1:3216Battle_FxHandlerTable30verifiedOne handler per status effect id 0-$0E, called from Battle_ApplyPendingEffect.
$C1:3234Battle_TickEnemyGroup627verifiedThe enemy counterpart of Battle_TickPcSlots, which jumps here instead of ticking the PCs while !Battle_UnkA4 is 1-3 (A = that value).
$C1:34A7Battle_DrawAllBattlerFrames52verifiedDraws the starting frame (!Battler_StartFrame) of every present battler, any frame layout (Battle_DrawBattlerFrameAnyLayout), then sets the three PC animation timers to 1, 2 and 3 so the PCs take...
$C1:34DBBattle_StartPose52verifiedThe last step of the battle set-up (service 0, which JMPs here): turns every PC toward its nearest enemy, then plays animation $0C on the targetable PCs (animation 0 on the others) through...
$C1:350FBattle_FaceAllPcsNearestEnemy62verifiedSets !Battler_Facing of PCs 2, 1, 0 from the angle to each one's nearest enemy (position query 2 through service 5, as in Battle_UpdatePcFacing, but for every PC at once and without the presence...
$C1:354DBattleSys_DefeatPose32verifiedService 9 of the same-bank $C10045 service dispatcher (reached only by JSR $0003/$0045 inside bank $C1; returns RTS; dispatch table at $C10051, entry 9 = $354D; no JSR, JMP or JSL reaches $354D...
$C1:356DBattleSys_VictoryPose112verifiedService 8 of the same-bank $C10045 service dispatcher (reached only by JSR $0003/$0045 inside bank $C1; returns RTS; dispatch table at $C10051, entry 8 = $356D; no JSR, JMP or JSL reaches $356D...
$C1:35DDBattle_RunPcPose189verifiedCopies, for each present PC, the first 8 entries of its pose list into !Pc_PoseTicks (durations, halved) and !Pc_PoseFrames (frame ids, for its current facing): the lists come from bank $E4 at...
$C1:369ABattle_PoseStep122verifiedOne pose step, run on every second call: !Battle_UnkE5 flips between 0 (set it, return) and 1 (clear it, step).
$C1:3714Battle_TickEnemyMovers39verifiedPer-frame enemy movement.
$C1:373BBattle_RunEnemyMover37verifiedRuns the mover of enemy !Battle_MoverEnemy, if that enemy is present: copies !Enemy_TargetWanted into !Enemy_MoveTarget, then, unless !Enemy_Anim is negative, stores the id in !Battle_MoverAnim...
$C1:3760Battle_EnemyMoverTable18verifiedOne mover per !BattleRom_EnemyMover entry, called from Battle_RunEnemyMover.
$C1:3772Battle_MoverIdle40verifiedMover 0 (move 4): stays put.
$C1:379ABattle_MoverApproach293verifiedMover 1: walks towards the target until within reach.
$C1:38BFBattle_MoverCharge154verifiedMover 2 (move 7): heads straight for the target from the enemy's position every time and starts the step, until a step is blocked by a blocking cell or another battler (the target included): then...
$C1:3959Battle_MoverAxis228verifiedMover 3: lines the enemy up with the target along one axis.
$C1:3A3DBattle_MoverKeepRange389verifiedMover 4 (moves 6 and $10): makes for the point on a ring around the target, radius $40 (move $10: $80), on the enemy's side of it.
$C1:3BC2Battle_MoverOrbit625verifiedMover 5 (moves $0D-$0F): circles the target on a ring of radius !Battle_OrbitRadius ($20; move $0E: $40).
$C1:3E33Battle_MoverLoop295verifiedMover 6 (moves $0A-$0C): flies round a loop near where it started.
$C1:3F5ABattle_MoverFixedDir199verifiedMover 7 (moves $11-$18): steps in a fixed direction from the enemy's position: $11 up, $12 down, $13 right, $14 left, $15 down-right, $16 down-left, $17 up-left, any other (move $18) up-right.
$C1:4021Battle_MoverToCentre55verifiedMover 8 (move $19): heads from the enemy's position for the middle of the screen (!Battle_ScreenCentreX/Y), faces that way and starts the step, with no probe and no collision test.
$C1:4058BattleSys_RunAction358verifiedService 4 of the $C10045 service API (dispatch table at $C10051, entry 4 = $4058; no JSR, JMP or JSL reaches $4058 directly; the one request found is LDA #4 / JSR $C1:0003 at $C1:BFA4, called from...
$C1:41BEBattleAct_FlagLethalPcHits84verifiedFor each PC 0-2, sets its !Battler_UnkA119 to 1 when its pending hit record (!Battle_ActPcHitAmount/Kind, 4 bytes per PC) has kind 3, the PC's HP is not 0, the amount is not 0 and the amount is at...
$C1:4212BattleAct_TickCalcs40verifiedFor each of the 6 entries of !Battle_ActCalcSel that is non-zero, runs handler (value - 1) of the unmatched table behind BattleAct_RunCalc and stores the two bytes it leaves in...
$C1:423ABattleAct_StepBattlerAnims214verifiedPlays the battlers' action animations, decoding at most one frame per call.
$C1:4310BattleAct_LoadScript28verifiedClears the 16-byte action parameter block (!Battle_ActScriptId .. $9886), sets !Battle_ActUnkArg987C to $FF (none) and calls the loader for !Battle_ActKind through BattleAct_LoaderTable (kinds 4...
$C1:432CBattleAct_LoadAttack628verifiedKind 1.
$C1:45A0BattleAct_LoadTech442verifiedKind 2: reads the 7-byte record !Battle_ActId of BattleRom_PcTechAct (PC caster) or BattleRom_EnemyTechAct (enemy caster), including !Battle_ActUnkArg987C, then: frames !BattleRom_ActFrames for...
$C1:475ABattleAct_LoadNone1verifiedKind 0 (and any kind of 4 and up): loads nothing, so no thread starts.
$C1:475BBattleAct_LoadKind3216verifiedKind 3: like the PC branch of BattleAct_LoadTech, for any caster, with record !Battle_ActId - $BC of BattleRom_Kind3Act; frames !BattleRom_ActFrames, palettes !BattleRom_Kind3Pals, objects...
$C1:4833BattleAct_LoadCommon185verifiedThe end of every loader: - loads graphics set !Battle_ActGfxSetA (BattleAnim_LoadGfx4Vec) and !Battle_ActGfxSetB (BattleAnim_LoadGfx2Vec) and waits a frame; - calls BattleAnim_UnkVecCD0018 with...
$C1:48ECBattleAct_IndexObjLists87verifiedSplits the 4-byte records at bank $CE + !Battle_ActObjPtr into the lists of the 16 action objects, by the top three bits of each record's first byte: 000 an ordinary record; 1xx ends the...
$C1:4943BattleAct_UnpackFrames188verifiedWaits a frame (BattleSys_PumpFrames, BattleMenu_RefreshIfDirtyAndTick) and builds up to 4 sprite frames from the unpacked data in !Battle_ActFrameBuf, going on from !Battle_ActFrameNum and...
$C1:49FFBattleAct_CheckReach114verifiedFor a PC caster: sets !Battle_ActNear to 1, then to 0 when the main target (entry 3 of !Battle_ActBattlers) is not within 40 pixels (BattlePos_WithinDist40XY), and turns the caster towards the...
$C1:4A71BattleAct_FindPath333verifiedBreadth-first search on !Battle_PathMap from the cell of the start point ($80, $81) to the cell of the goal point ($82, $83); the cell of a point is (y & $F0) | (x >> 4).
$C1:4BBEBattleAct_RunThreads224verifiedRuns one step of each live thread, in the order 0-4 then 8-15: thread n runs when its !Battle_ActThreadOn byte is non-zero, thread 4 only when !Battle_ActTargetMask is non-zero too, and threads...
$C1:4C9EBattleAct_RunThread82verifiedRuns one thread for this frame.
$C1:4CF0BattleAct_OpEndThread7verifiedOpcode $00: switches the thread off (!Battle_ActThreadOn = 0).
$C1:4CF7BattleAct_OpEndScript13verifiedOpcode $01, and the handler of every unused opcode in the table: counts !Battle_ActScriptDone up, which ends the action (service 4 waits for it).
$C1:4D04BattleAct_OpLoopAnim4verifiedOpcode $02 <n>: starts animation n of the thread's actor in mode 2 (loop) and goes on with the next opcode in the same frame; advances 2.
$C1:4D08BattleAct_StartAnim282verified
$C1:4E22BattleAct_OpPlayAnim128verifiedOpcode $03 <n>: plays animation n once and waits for it to end, then advances 2.
$C1:4EA2BattleAct_OpShowAnimFrame120verifiedOpcodes $04-$06 <n> (one handler; the opcode is not looked at): starts animation n with the actor's stop byte set to 1, so that BattleAct_StepBattlerAnims shows its entry 0 and switches it off...
$C1:4F1ABattleAct_OpResetSpeed58verifiedOpcode $07: sets the actor's move delay and speed (!Battle_ActorMoveDelay / !Battle_ActorMoveSpeed) back to the battler's defaults (!Battler_DefMoveDelay / !Battler_DefMoveSpeed, set at battle...
$C1:4F54BattleAct_OpSetSpeed107verifiedOpcodes $08-$0F (one handler): sets the actor's move delay and speed (!Battle_ActorMoveDelay / !Battle_ActorMoveSpeed) from entry (opcode - 8) of !BattleRom_ActMoveDelay / !BattleRom_ActMoveSpeed...
$C1:4FBFBattleAct_OpMoveTo18verifiedThe move opcodes: move the thread's actor in a straight line to a point, at its !Battle_ActorMoveSpeed pixels per step and !Battle_ActorMoveDelay frames per step, then go on.
$C1:4FD1BattleAct_OpMoveToUnkPoint18verified
$C1:4FE3BattleAct_OpMoveToCalc10verified
$C1:4FEDBattleAct_MoveToPoint328verified
$C1:5135BattleAct_StartBattlerMove185verifiedStarts a straight move of battler X to the point in !Battle_ActCalcOutA/B (x, y): keeps its position (!Battler_ScreenX/Y) in !Battle_ActorFromX/Y and the point in !Battle_ActorToX/Y, turns it...
$C1:51EEBattleAct_OpCurveTo23verifiedThe curving move opcodes: like the move opcodes $10-$12 (BattleAct_OpMoveTo) they move the thread's actor to a point and wait for it, but with mover kind !Battle_MoveKindCurve: the mover...
$C1:5205BattleAct_OpCurveToUnkPoint23verified
$C1:521CBattleAct_OpCurveToCalc15verified
$C1:522BBattleAct_CurveToPoint389verified
$C1:53B0BattleAct_CurveTurnDir89verifiedWhich way a curving move turns from heading DP $82 to the angle !Battle_GeoAngle (Battle_CalcAngle's, to the point): A = 0 (increase the angle) or 1 (decrease it), the shorter way.
$C1:5409BattleAct_OpPathTo18verifiedThe path-walk opcodes: a battler of threads 0-3 walks to a point cell by cell round what stands in the way, then the thread goes on.
$C1:541BBattleAct_OpPathToUnkPoint18verified
$C1:542DBattleAct_OpPathToCalc10verified
$C1:5437BattleAct_PathToPoint474verified
$C1:5611BattleAct_OpSetPos14verifiedThe place opcodes: put the thread's actor at a point at once (no move).
$C1:561FBattleAct_SetPosToPoint77verified
$C1:566CBattleAct_OpSetPosUnkPoint17verified
$C1:567DBattleAct_OpSetPosCalc23verified
$C1:5694BattleAct_OpFollow39verifiedOpcode $1C <n>: on an object thread, makes the object follow something: !Battle_ActObjFollow of the object = entry n of !Battle_ActBattlers (a battler slot) for n below !Battle_ActFollowFirstObj...
$C1:56BBBattleAct_OpUnfollow17verifiedOpcode $1D <j>: object thread j follows nothing any more (!Battle_ActObjFollow = !Battle_ActFollowNone), whatever thread runs it.
$C1:56CCBattleAct_OpCall47verifiedOpcode $1E <n>: calls subscript n: keeps the address after the opcode (pointer + 2, the carry going into the bank) in the thread's !Battle_ActThreadReturn / !Battle_ActThreadReturnBank and goes to...
$C1:56FBBattleAct_OpReturn25verifiedOpcode $1F: returns from a subscript (BattleAct_OpCall): the script pointer = the thread's !Battle_ActThreadReturn / ReturnBank, and the next opcode runs in the same frame.
$C1:5714BattleAct_OpPause14verifiedOpcode $20 <n>: ends the thread's turn for this frame and has BattleAct_RunThread only count !Battle_ActThreadWait = n down on the next n frames before running the next opcode; advances 2.
$C1:5722BattleAct_OpReturnIfVar1F010verifiedOpcode $21: when variable $1F (!Battle_ActUnkPointY) is 0, returns from the subscript like opcode $1F; otherwise advances 1 (and the thread waits for the next frame).
$C1:572CBattleAct_OpWaitVar23verifiedOpcode $22 <n> <v>: waits until variable n (!Battle_ActVars + n) is v: while it is not, stays on the opcode (advance 0); then goes on with the next opcode in the same frame, advancing 3.
$C1:5743BattleAct_OpWaitVar1C19verifiedOpcode $23 <v>: as opcode $22 for variable $1C (!Battle_ActVar1C); advances 2 when it is v.
$C1:5756BattleAct_OpWaitVar1D19verifiedOpcode $24 <v>: as opcode $23 for variable $1D (!Battle_ActVar1D).
$C1:5769BattleAct_OpEndIfNoTarget20verifiedOpcode $25 <i>: when entry i of !Battle_ActTargetSet is the end marker (bit 7 set: the set has fewer than i + 1 slots), switches the thread off (BattleAct_OpEndThread); otherwise goes on with the...
$C1:577DBattleAct_OpShowAnimEntry137verifiedOpcode $26 <n> <f>: like opcodes $04-$06 (BattleAct_OpShowAnimFrame) with the stop byte f from the operand: starts animation n with the actor's stop byte = f, so that BattleAct_StepBattlerAnims...
$C1:5806BattleAct_OpSetUnkA5CD4verifiedOpcodes $27 (BattleAct_OpSetUnkA5CD, value 1) and $28 (BattleAct_OpClearUnkA5CD, value 0): set !Battler_UnkA5CD of the thread's battler (threads 0-3) or of every slot of the target set (thread 4)...
$C1:580ABattleAct_StoreUnkA5CD54verified
$C1:5840BattleAct_OpClearUnkA5CD4verified
$C1:5844BattleAct_OpSetUnk9FF74verifiedOpcodes $29 (BattleAct_OpSetUnk9FF7, value 1) and $2A (BattleAct_OpClearUnk9FF7, value 0): as opcodes $27/$28 for !Battler_Unk9FF7 (bit 7: skipped by the target scans).
$C1:5848BattleAct_StoreUnk9FF749verified
$C1:5879BattleAct_OpClearUnk9FF74verified
$C1:587DBattleAct_OpClearUnkA4A446verifiedOpcode $2B: zeroes !Battler_UnkA4A4 and !Battler_UnkA4AF of the thread's battler (threads 0-3) or of every slot of the target set (thread 4); object threads change nothing.
$C1:58ABBattleAct_OpUnkRevive49verifiedOpcode $2C: for the thread's battler (threads 0-3) or every slot of the target set (thread 4): counts !Battler_Present up and zeroes !Battler_KoFlag; object threads change nothing.
$C1:58DCBattleAct_OpSetUnkCFFF8verifiedOpcode $2D: !BattleFx_HoldAnims = 1 (BattleFx_HoldAnimsTick holds the palette animations); advances 1.
$C1:58E4BattleAct_OpClearUnkCFFF8verifiedOpcode $2E: !BattleFx_HoldAnims = 0 (BattleFx_HoldAnimsTick lets the held palette animations run again); advances 1.
$C1:58ECBattleAct_OpSetVar18verifiedThe script variable opcodes ($C158EC–$C159B8): set, count and add to the bytes of !Battle_ActVars; variables $1C and $1D have opcodes of their own.
$C1:58FEBattleAct_OpSetVar1C14verifiedOpcode $31 <v>: !Battle_ActVar1C = v; advances 2.
$C1:590CBattleAct_OpSetVar1D14verifiedOpcode $32 <v>: !Battle_ActVar1D = v; advances 2.
$C1:591ABattleAct_OpCalcToUnkPoint23verifiedOpcode $33 <n>: runs BattleAct_RunCalc handler n and keeps its point in !Battle_ActUnkPointX/Y (variables $1E/$1F), for the "UnkPoint" move opcodes; advances 2, and the thread waits for the next...
$C1:5931BattleAct_OpIncVar15verifiedOpcode $34 <n>: variable n + 1; advances 2.
$C1:5940BattleAct_OpIncVar1C11verifiedOpcode $35: !Battle_ActVar1C + 1; advances 1.
$C1:594BBattleAct_OpIncVar1D11verifiedOpcode $36: !Battle_ActVar1D + 1; advances 1.
$C1:5956BattleAct_OpDecVar15verifiedOpcode $37 <n>: variable n - 1; advances 2.
$C1:5965BattleAct_OpDecVar1C11verifiedOpcode $38: !Battle_ActVar1C - 1; advances 1.
$C1:5970BattleAct_OpDecVar1D11verifiedOpcode $39: !Battle_ActVar1D - 1; advances 1.
$C1:597BBattleAct_OpAddVar22verifiedOpcode $3A <n> <v>: variable n + v (8-bit, wraps); advances 3.
$C1:5991BattleAct_OpAddVar1C18verifiedOpcode $3B <v>: !Battle_ActVar1C + v; advances 2.
$C1:59A3BattleAct_OpAddVarTo1C22verifiedOpcode $3C <n>: !Battle_ActVar1C + variable n; advances 2.
$C1:59B9BattleAct_OpCalcToResult43verifiedOpcodes $3D-$40 and $45-$46 <n> (one handler): runs BattleAct_RunCalc handler n once and stores its two results in entry k of !Battle_ActCalcResult: k = opcode - $3D for $3D-$40 (0-3), opcode...
$C1:59E4BattleAct_OpCopyVar22verifiedOpcode $41 <a> <b>: variable b = variable a; advances 3.
$C1:59FABattleAct_OpCopyVar1C18verifiedOpcode $42 <n>: variable n = !Battle_ActVar1C; advances 2.
$C1:5A0CBattleAct_OpOffsetToUnkPoint50verifiedOpcode $43 <n> <x> <y>: !Battle_ActUnkPointX/Y = (x, y) plus the point of BattleAct_RunCalc handler n (each 8-bit, wrapping); advances 4.
$C1:5A3EBattleAct_OpActorPosToUnkPoint50verifiedOpcode $44: !Battle_ActUnkPointX/Y = the position of the thread's actor: !Battler_ScreenX/Y of its !Battle_ActBattlers entry, or the object's !Battle_ActObjX/Y on threads 8-15.
$C1:5A70BattleAct_OpAddVarClamped41verifiedOpcode $49 <n> <d>: variable n + d, with d signed and the result clamped to 0-$FF (a carry out of a positive add gives $FF, a negative add with no carry gives 0); advances 3.
$C1:5A99BattleAct_OpSwapVar1C1D22verifiedOpcodes $4A and $4D: swaps !Battle_ActVar1C and !Battle_ActVar1D; advances 1.
$C1:5AAFBattleAct_OpSwapVar1C1E22verifiedOpcode $4E: swaps !Battle_ActVar1C and variable $1E (!Battle_ActUnkPointX); advances 1.
$C1:5AC5BattleAct_OpSwapVar1C1F22verifiedOpcode $4F: swaps !Battle_ActVar1C and variable $1F (!Battle_ActUnkPointY); advances 1.
$C1:5ADBBattleAct_OpShowHitNumbers534verifiedOpcodes $50-$55: shows the hit numbers of record set (opcode & 7) as digit sprites over the battlers and waits until they have bounced.
$C1:5CF1BattleAct_OpClearUnk9FF7Bit72verifiedOpcodes $5D (BattleAct_OpClearUnk9FF7Bit7, DP $8E = 0) and $5E (BattleAct_OpSetUnk9FF7Bit7, DP $8E = $80): sets bit 7 of the thread's battler's !Battler_Unk9FF7 (the target scans' skip bit) to...
$C1:5CF3BattleAct_StoreUnk9FF7Bit731verified
$C1:5D12BattleAct_OpSetUnk9FF7Bit76verified
$C1:5D18BattleAct_OpNop25verifiedOpcode $5F <x>: does nothing; advances 2 (over its operand).
$C1:5D1DBattleAct_OpLoadPalEntry118verifiedThe palette opcodes ($C15D1D–$C15FA4): colour sets from the action's palette list (!Battle_ActPalPtr) and its four palette sequences, opcode $69's special palette and its blink, and the colour...
$C1:5D93BattleAct_OpStartPalSeq46verifiedOpcodes $61-$64 <delay> <first> <last>: starts palette sequence opcode - $61 (0-3) for BattleAct_StepPalettes ($CC:F1E7): it loads the palette-list entries first..last in turn, one every delay...
$C1:5DC1BattleAct_OpStopPalSeq18verifiedOpcodes $65-$68: stops palette sequence opcode - $65 (0-3); the colours it last loaded stay.
$C1:5DD3BattleAct_OpSetSpecialPalette9verifiedOpcode $69 <n>: gives the thread's battler (threads 0-3) or every slot of the target set (threads 4-15, the object threads included) !Battler_Palette = !Battle_SpecialPalette, and fills that...
$C1:5DDCBattleAct_SpecialPaletteBody171verified
$C1:5E87BattleAct_OpRestorePalette4verifiedOpcode $6A: undoes opcode $69: gives the thread's battler (threads 0-3) or every slot of the target set (threads 4-15) its !Battler_BasePalette back.
$C1:5E8BBattleAct_RestorePaletteBody84verified
$C1:5EDFBattleAct_OpStartPalCycle52verifiedOpcode $6B <delay>: starts the colour rotation of BattleCF_FrameUpdate ($CF:E600 on): every delay frames it turns the colours of !Battle_PaletteLive+$82-$99 (the special palette's 12 colours) on...
$C1:5F13BattleAct_OpBlinkPalette135verifiedOpcode $6C <n> <frames>: blinks between opcode $69's special palette n and the battler's own palette.
$C1:5F9ABattleAct_OpStopPalCycle11verifiedOpcode $6D: stops opcode $6B's colour rotation (!Battle_UnkAB4E and !Battle_PalCycleLo = 0); the colours stay as they were turned.
$C1:5FA5BattleAct_OpIncAllObjUnkA1D814verifiedThe object counter opcodes ($C15FA5–$C15FDD): count !Battle_ActObjUnkA1D8 up or clear it, for all eight object threads or for the running one.
$C1:5FB3BattleAct_OpClearAllObjUnkA1D814verifiedOpcode $6F: zeroes !Battle_ActObjUnkA1D8 of object threads 0-7; advances 1.
$C1:5FC1BattleAct_OpIncObjUnkA1D82verifiedOpcode $70: counts !Battle_ActObjUnkA1D8 of the running object thread (!Battle_ActObjThread) up; advances 1.
$C1:5FC3BattleAct_Op70Body16verified
$C1:5FD3BattleAct_OpClearObjUnkA1D811verifiedOpcode $71: zeroes !Battle_ActObjUnkA1D8 of the running object thread; advances 1.
$C1:5FDEBattleAct_OpSetFacing123verifiedOpcode $72 <mode>: sets the facing of the thread's actor from BattleAct_CalcFacing with A = mode: !Battler_Facing of the thread's battler (threads 0-3) or of every slot of the target set (thread...
$C1:6059BattleAct_OpLinkObjBit76verifiedOpcodes $73 (BattleAct_OpLinkObjBit7, DP $8E = $80) and $74 (BattleAct_OpLinkObjBit6, DP $8E = $40) <n>: links the running object thread j (!Battle_ActObjThread) to the battler s in entry n of...
$C1:605FBattleAct_OpLinkObjBit64verified
$C1:6063BattleAct_LinkObjBody48verified
$C1:6093BattleAct_OpCopyHeading83verifiedThe heading opcodes ($C16093–$C1619D and $C16258): set !Battle_ActorUnkA5AA (the battlers) or !Battle_ActObjUnkA5B5 (the object threads), the heading a curving move with operand $FF starts from.
$C1:60E6BattleAct_OpHeadingFromCalc110verifiedOpcode $76 <a> <b>: runs BattleAct_RunCalc handler b and then a, takes each one's two results as a point's x/y, and stores the angle Battle_CalcAngle gives from point a (origin) to point b as the...
$C1:6154BattleAct_OpAddHeading74verifiedOpcode $77 <d>: adds d (mod 256, so a turn either way) to the heading of the same actors as opcode $75.
$C1:619EBattleAct_OpSound35verifiedThe sound opcodes ($C1619E–$C1621A): fill the APU command block (!Sfx_Command, !Sfx_Param1/2) and run Audio_ProcessEntry.
$C1:61C1BattleAct_OpSoundCalc42verifiedOpcodes $7A/$7B <id> <calc>: APU command $18 (opcode $7A) or $19 (opcode $7B) with !Sfx_Param1 = id and !Sfx_Param2 = the first result of BattleAct_RunCalc handler calc (probably an x, as opcodes...
$C1:61EBBattleAct_OpPcAttackSfxA10verifiedOpcodes $7C (BattleAct_OpPcAttackSfxA) and $7D (BattleAct_OpPcAttackSfxB): APU command $18 with !Sfx_Param1 = the sound of the PC attack record (!Battle_ActPcAttackRec) in !BattleRom_PcAttackSfxA...
$C1:61F5BattleAct_OpPcAttackSfxB8verified
$C1:61FDBattleAct_PlayPcAttackSfx30verified
$C1:621BBattleAct_OpRunVecCD001B33verifiedOpcode $80 <len> ...: copies len & $0F bytes of the script, from the length byte on, to !Battle_ActOp80Args (DP $53 on), runs BattleAct_UnkVecCD001B and advances by that count + 1 (the opcode and...
$C1:623CBattleAct_OpSetCalcSel28verifiedOpcodes $81-$84 (entries 0-3) and $47/$48 (entries 4 and 5) <n>: !Battle_ActCalcSel[entry] = n + 1, so BattleAct_TickCalcs runs BattleAct_RunCalc handler n for that entry every frame; advances 2.
$C1:6258BattleAct_OpSetHeading65verifiedOpcode $85 <h>: sets the heading (see the heading opcodes above) of the thread's battler (threads 0-3 and 5-7), of every slot of the target set (thread 4; the target set here, unlike opcodes...
$C1:6299BattleAct_OpArcToCalc2verifiedThe arc opcodes: like the move opcodes $10-$12 (BattleAct_OpMoveTo) they move the thread's actor in a straight line to a point and wait for it, but with mover kind !Battle_MoveKindArc...
$C1:629BBattleAct_ArcToCalcDir15verified
$C1:62AABattleAct_ArcToPoint671verified
$C1:6549BattleAct_ArcQuarterPoint113verifiedOpcodes $9C/$9D: moves !Battle_GeoPointX/Y to a quarter of the way from !Battle_GeoOriginX/Y: Origin + (|Point - Origin| / 4, rounded down) with the delta's sign, per axis (8-bit, no carry out).
$C1:65BABattleAct_CalcMoveStep183verifiedUnit step of a straight move from !Battle_GeoOriginX/Y to !Battle_GeoPointX/Y, as signed 8.8 pixels: the axis with the larger distance (x on a tie) moves 1.0 ($0100) per step, the other (smaller *...
$C1:6671BattleAct_CalcMidpointSteps189verifiedFrom !Battle_GeoOriginX/Y and !Battle_GeoPointX/Y: sets !Battle_ActMoveUnitX/Y to the delta * 4 with the delta's sign (as signed 8.8, 1/64 of the delta: probably a move of 64 steps)...
$C1:672EBattleAct_OpArcToUnkPoint2verifiedOpcodes $99/$9D <m>: the arc move (BattleAct_OpArcToCalc) to the point in !Battle_ActUnkPointX/Y, height subtracted; length 2.
$C1:6730BattleAct_ArcToUnkPointDir19verified
$C1:6743BattleAct_OpArcDownToCalc7verifiedOpcode $9A <mode> <n>: opcode $98 (BattleAct_OpArcToCalc) with the height added instead of subtracted (DP $8F = 1).
$C1:674ABattleAct_OpArcDownToUnkPoint7verifiedOpcode $9B <m>: opcode $99 (BattleAct_OpArcToUnkPoint) with the height added instead of subtracted (DP $8F = 1).
$C1:6751BattleAct_OpMoveAlongHeading458verifiedOpcode $A2: moves the thread's actor along its heading (!Battle_ActorUnkA5AA; for the objects !Battle_ActObjUnkA5B5) with mover kind !Battle_MoveKindHeading (BattleCF_MoveHeading; up to $FF steps...
$C1:691BBattleAct_OpStartPosHistory16verifiedOpcode $A4 <delay> <b>: starts the position history of the thread's battler (threads 0-3) or of every slot of !Battle_ActTargetSet (threads 4-7; unlike most opcodes, threads 5-7 take the set too)...
$C1:692BBattleAct_SetPosHistory143verified
$C1:69BABattleAct_OpStopPosHistory9verifiedOpcode $A5: !Battler_PosHistOn = 0 for the same battlers as opcode $A4 (BattleAct_OpStartPosHistory); advances 1.
$C1:69C3BattleAct_OpMoveHeadingSteps301verifiedOpcode $A8 <n>: moves the thread's actor along its heading (!Battle_ActorUnkA5AA; objects !Battle_ActObjUnkA5B5) with mover kind !Battle_MoveKindHeading for n steps (!Battle_ActorHeadSteps = n...
$C1:6AF0BattleAct_OpMoveHeadingChecked515verifiedOpcode $A9 <n>: opcode $A8 (BattleAct_OpMoveHeadingSteps) with opcode $A2's test of the cell ahead (BattleAct_OpMoveAlongHeading), and for the battlers also the box test: BattleAct_ProbeBoxOverlap...
$C1:6CF3BattleAct_OpCircleToCalc29verifiedOpcode $C0 <n> <r> <a> <q>: moves the thread's actor round a circle whose centre is the point left by BattleAct_RunCalc handler n, with mover kind !Battle_MoveKindCircle (BattleCF_MoveCircle; see...
$C1:6D10BattleAct_CircleMove4verified
$C1:6D14BattleAct_CircleMoveKind541verified
$C1:6F31BattleAct_OpCircleToUnkPoint34verifiedOpcode $C1 <r> <a> <q>: opcode $C0 (BattleAct_OpCircleToCalc) round the point in !Battle_ActUnkPointX/Y; length 4.
$C1:6F53BattleAct_OpEllipseToCalc34verifiedOpcode $C2 <n> <r> <a> <q>: opcode $C0 (BattleAct_OpCircleToCalc) with mover kind !Battle_MoveKindEllipse (BattleCF_MoveEllipse), which differs from the circle mover only in using half the radius...
$C1:6F75BattleAct_OpEllipseToUnkPoint37verifiedOpcode $C3 <r> <a> <q>: opcode $C2 (BattleAct_OpEllipseToCalc) round the point in !Battle_ActUnkPointX/Y; length 4.
$C1:6F9ABattleAct_OpStepUnkA4AF14verifiedOpcode $C4 <t> <d>: each frame adds d to the thread's battler's !Battler_UnkA4AF (the y offset the movers and the position history use) and waits (advance 0), until the value equals t, then...
$C1:6FA8BattleAct_StepUnkA4AF71verified
$C1:6FEFBattleAct_OpStepUnkA4AFTo013verifiedOpcode $C5 <d>: opcode $C4 (BattleAct_OpStepUnkA4AF) with t = 0: steps !Battler_UnkA4AF back to 0 by d per frame; length 2.
$C1:6FFCBattleAct_OpIncUnkA5D847verifiedOpcode $D0: counts the thread's battler's !Battler_UnkA5D8 up by 1 (no reader of it found); length 1.
$C1:702BBattleAct_OpClearUnkA5D847verifiedOpcode $D1: zeroes !Battler_UnkA5D8, for the same battlers as opcode $D0 (BattleAct_OpIncUnkA5D8); length 1.
$C1:705ABattleAct_OpMoveKind4ToCalc436verifiedOpcode $D2 <n>: sets up, without starting it, a move of the thread's actor to the point left by BattleAct_RunCalc handler n with mover kind !Battle_MoveKindUnk4 (BattleCF_MoveKind4); length 2; it...
$C1:720EBattleAct_OpMoveToMidpoint315verifiedOpcode $D3: sets up, without starting it, a straight move of the thread's actor to the raised midpoint opcode $D2 left (!Battle_ActUnkMidX/Y, copied to !Battle_ActCalcOutA/B); length 1; it...
$C1:7349BattleAct_OpRunMoveAfterUnkAAFC27verifiedOpcode $D4: waits (advance 0) while the 16-bit !Battle_ActUnkAAFC (with !Battle_ActUnkAAFD) is not 0, counting it down by 1 a frame; at 0 it goes on as opcode $D6.
$C1:7364BattleAct_OpRunMove63verified
$C1:73A3BattleAct_OpRunMove_Wait5verified
$C1:73A8BattleAct_OpRunMove_Done5verified
$C1:73ADBattleAct_OpRunMoveAfterMajorDist94verifiedOpcode $D5: opcode $D4 (BattleAct_OpRunMoveAfterUnkAAFC) with the other delay opcode $D3 leaves: waits while the 16-bit !Battle_MoveMajorDist is not 0, counting it down by 1 a frame; then sets the...
$C1:740BBattleAct_OpPointTowardCalc169verifiedOpcode $D7 <d> <n>: sets !Battle_ActUnkPointX/Y to the point d pixels (along the major axis) from the thread's actor towards the point left by BattleAct_RunCalc handler n: .along adds the unit...
$C1:74B4BattleAct_OpShake134verifiedOpcode $D8 <a> <p> <f>: starts mover kind !Battle_MoveKindShake (BattleCF_MoveShake) for the thread's battler and advances at once (length 4): !Battler_ShakeAmp = a, !Battler_ShakePeriod = p...
$C1:753ABattleAct_OpSetActAttr63verifiedOpcode $D9 <v>: sets the thread's actor's attribute value to v (!Battler_ActAttr for a battler, every slot of !Battle_ActTargetSet for thread 4, !Battle_ActObjAttr for object j; probably sprite...
$C1:7579BattleAct_OpResetActAttr66verifiedOpcode $DA: puts the thread's actor's attribute value back to its initial one (!Battler_ActAttrInit into !Battler_ActAttr, for thread 4 every slot of !Battle_ActTargetSet, !Battle_ActObjAttrInit...
$C1:75BBBattleAct_AdvanceScript17verifiedMoves the thread's script pointer !Battle_ActScriptPtr on by A bytes: a 16-bit add to the offset, with the carry going into the bank byte (added 16-bit, so DP $E9 takes part too).
$C1:75CCBattleAct_CalcFacing11verifiedRuns the BattleAct_FacingModeTable handler for mode A (0-$18), which leaves the facing in !Battle_ActFacingOut: modes 0-9 copy the facing of !Battle_ActBattlers entry A, $0A-$13 face entry A...
$C1:75D7BattleAct_FaceLikeEntry12verifiedFacing modes 0-9: the !Battler_Facing of !Battle_ActBattlers entry Y.
$C1:75E3BattleAct_FaceTowardEntry39verifiedFacing modes $0A-$13: the facing from the actor's point (DP $80/$81) toward the screen position of !Battle_ActBattlers entry Y - $0A, from Battle_CalcAngle and !BattleRom_FacingByAngle.
$C1:760ABattleAct_FaceFixed8verifiedFacing modes $14-$17: facing Y - $14 (!Battle_FacingUp, Down, Left, Right).
$C1:7612BattleAct_FaceTowardCentre28verifiedFacing mode $18: the facing from the actor's point (DP $80/$81) toward the middle of the screen (!Battle_ScreenCentreX/Y).
$C1:762EBattleAct_RunCalc11verifiedRuns the BattleAct_CalcTable handler for number A (0-$47), which leaves a point in !Battle_ActCalcOutA (x) and !Battle_ActCalcOutB (y) (two script variables for handlers $2A-$31; nothing for $12).
$C1:7639BattleAct_CalcEntryPos17verifiedHandlers 0-8: the screen position (!Battler_ScreenX/Y) of !Battle_ActBattlers entry Y.
$C1:764ABattleAct_CalcEntryOffsetPos51verifiedHandlers 9-$11: the screen position of !Battle_ActBattlers entry Y - 9 plus its !Battler_ScreenOffsetX/Y.
$C1:767DBattleAct_CalcNone1verifiedHandler $12: does nothing; !Battle_ActCalcOutA/B keep what the last handler left.
$C1:767EBattleAct_CalcMid038verifiedHandler $13: the midpoint of !Battle_ActBattlers entries 0 and 3 (the caster and the main target), through BattleAct_CalcMid02's BattleAct_CalcMidWithEntry0.
$C1:7686BattleAct_CalcMid018verifiedHandler $14: the midpoint of !Battle_ActBattlers entries 0 and 1, through BattleAct_CalcMid02's BattleAct_CalcMidWithEntry0.
$C1:768EBattleAct_CalcMid025verifiedHandler $15: the midpoint of the screen positions of two battler slots, (x1 + x2) / 2 and (y1 + y2) / 2 worked out 16-bit.
$C1:7693BattleAct_CalcMidWithEntry04verified
$C1:7697BattleAct_CalcMidFromSlot65verified
$C1:76D8BattleAct_CalcCentroid118verifiedHandler $16: meant as the centre of !Battle_ActBattlers entries 0-2 (the caster and its two partners): sums the three screen x and the three screen y 16-bit and divides by 3 with Battle_Divide.
$C1:774EBattleAct_CalcAheadOfActor131verifiedHandler $17: the point $18 pixels from the thread's actor along its move angle: y + the sine of the angle and x + the sine of the angle + $40, each from Battle_SinLookup with scale $18 (a signed...
$C1:77D1BattleAct_CalcFixedPoint9verifiedHandler $18: the point ($80, $80).
$C1:77DABattleAct_CalcSavedPos18verifiedHandlers $19-$1B: the position saved for !Battle_ActBattlers entry Y - $19 (0-2) in !Battle_ActSavedX/Y.
$C1:77ECBattleAct_CalcObjOffset31verifiedHandlers $1C-$23: the position of object Y - $1C (0-7) plus its !Battle_ActObjOfsX/Y, 16-bit, stored 16-bit.
$C1:780BBattleAct_CalcLerpToTarget246verifiedHandlers $24-$29 and $32-$3F: a point on the line from one battler to the main target (!Battle_ActMainTarget): (w1 * P + w2 * T) >> 3 per coordinate, with the weight pair (w1, w2) k of...
$C1:7901BattleAct_CalcVarPair19verifiedHandlers $2A-$31: script variables 2k and 2k + 1 of !Battle_ActVars, k = n - $2A (0-7), as the pair (not necessarily a point).
$C1:7914BattleAct_CalcMid1212verifiedHandler $40: the midpoint of !Battle_ActBattlers entries 1 and 2 (the two partners), through BattleAct_CalcMid02's BattleAct_CalcMidFromSlot.
$C1:7920BattleAct_CalcLerpToObj0129verifiedHandlers $41-$47: a point on the line from !Battle_ActBattlers entry 0 (the caster) to object 0 (the low bytes of !Battle_ActObjX/Y), (w1 * P + w2 * O) >> 3 with weight pair n - $41 of...
$C1:79A1BattleAct_FacingModeTable50verifiedBattleAct_CalcFacing's handler per facing mode 0-$18, called through JSR (BattleAct_FacingModeTable,X) with X = mode * 2.
$C1:79D3BattleAct_CalcTable144verifiedBattleAct_RunCalc's handler per number 0-$47, called through JSR (BattleAct_CalcTable,X) with X = number * 2.
$C1:7A63BattleAct_LoaderTable8verifiedAction loader per !Battle_ActKind 0-3, called by BattleAct_LoadScript through JSR (BattleAct_LoaderTable,X) with X = kind * 2 (kinds 4 and up are taken as 0).
$C1:7A6BBattleAct_OpcodeTable448verifiedHandler per action-script opcode, called by BattleAct_RunThread through JSR (BattleAct_OpcodeTable,X) with X = opcode * 2.
$C1:7C2BBattleAct_ProbeBoxOverlap18verifiedPuts battler X's probe (!Battler_ProbeX/Y) at its screen position, builds its box (Battle_CalcBattlerBox) and tests it against the other battlers' boxes (Battle_BoxOverlapsOthers, tail JMP).
$C1:8006BattleSys_Main1,115verifiedThe battle from its setup to its end; it never returns, leaving through BattleSys_ExitVec ($C1:0006 -> $001F -> JML $CF:FBE5).
$C1:8461BattleSys_Unk8461988verifiedHandler of turn list 12, the battlers' turns (inferred: a ready PC is queued for the command menu by service 1, BattleMenu_EnqueueReadyBattler; a ready enemy's !Battler_UnkAFAB, probably its ATB...
$C1:883DBattleSys_Unk883D37verifiedFor each PC slot 0-2 whose !Battler_UnkAF0A entry is not $FF: DP $14 (16-bit) = the slot, BattleSys_UnkB575, then BattleSys_UnkB3F9 with X = the slot.
$C1:8862BattleSys_ClearUnkB19220verifiedZeroes the 4-byte !Battle_UnkB192 record of battler slot !Battle_UnkB18B.
$C1:8876BattleSys_ListHandler079verifiedTurn list 0 (BattleSys_ListHandlerTable entry 0): the usual handler (see the banner); at the end of its runs it clears BattlerStats.Status2 bit 7 of the slot.
$C1:88C5BattleSys_ListHandler1150verifiedTurn list 1: a repeating hit on the slot (inferred from the amount going to !Battle_ActPcHitAmount with kind 3, which BattleAct_FlagLethalPcHits checks as damage; probably poison).
$C1:895BBattleSys_Unk895B26verifiedSets up the action block for a kind-2 action (BattleAct_LoaderTable's loader 2; the tech loader, inferred in !Battle_ActId's note) with record A, caster slot 0, no flags and the main-target mask...
$C1:8975BattleSys_ListHandler268verifiedTurn list 2: the usual handler, but after its last run it only stops the entry: no status bit is cleared.
$C1:89B9BattleSys_ListHandler376verifiedTurn list 3: the usual handler; at the end of its runs it clears bit 7 of the slot's BattlerStats.Unk4C+1 (+$4D).
$C1:8A05BattleSys_ListHandler476verifiedTurn list 4: the usual handler; at the end of its runs it clears bit 6 of the slot's BattlerStats.Unk4C+1 (+$4D).
$C1:8A51BattleSys_ListHandler576verifiedTurn list 5: the usual handler; at the end of its runs it clears bit 6 of the slot's BattlerStats.Unk4C+2 (+$4E).
$C1:8A9DBattleSys_ListHandler61verifiedTurn list 6: does nothing (RTS).
$C1:8A9EBattleSys_ListHandler71verifiedTurn list 7: does nothing (RTS), like list 6.
$C1:8A9FBattleSys_ListHandler8113verifiedTurn list 8: re-arms the entry (flags = 1) with the timer = reload, halved when bit 7 of the slot's BattlerStats.Unk4C+1 or Unk4C+6 (+$4D, +$52) is set, doubled (from the reload, so this wins)...
$C1:8B10BattleSys_ListHandler9169verifiedTurn list 9: re-arms the entry with the timer halved / doubled as list 8 does, clears the list's !Battle_ListDue bit and counts !Battle_ListRuns down; at 0 (set back to 10), unless the slot is...
$C1:8BB9BattleSys_ListHandler1079verifiedTurn list 10: the usual handler; at the end of its runs it clears bit 2 of the slot's BattlerStats.Unk4C+2 (+$4E).
$C1:8C08BattleSys_ListHandler111verifiedTurn list 11: does nothing (RTS), like lists 6 and 7.
$C1:8C09BattleSys_Unk8C0953verifiedRuns BattleAi_RunMainPart (probably an enemy's behaviour script: it reads a pointer from the $CC:8B08 table by the id in A) for each enemy entry 0-7 with !Battle_UnkB2B6 0 whose !Battle_UnkAF15...
$C1:8C3EBattleAi_TestPassed187verifiedCalled by a test handler whose test holds (42 JSR sites from $C1:8EA7 to $C1:9803, all in the test handlers): records the test code and runs the block's next action through BattleAi_ChooseTable.
$C1:8CF9BattleAi_EnemyTurn430verifiedRuns the action an enemy's script chose, on its turn (BattleSys_Unk8461) or as a reaction (!Battle_UnkB2C0 set).
$C1:8EA7BattleAi_Test004verifiedTest code $00: always holds (BattleAi_TestPassed at once).
$C1:8EABBattleAi_TestHpHalfOrLess102verifiedBattleAi_TestTable entry $01.
$C1:8F11BattleAi_TestStatusBits118verifiedBattleAi_TestTable entry $02.
$C1:8F87BattleAi_TestTargetId83verifiedBattleAi_TestTable entry $03.
$C1:8FDABattleAi_TestEnemyIdPresent57verifiedBattleAi_TestTable entry $04.
$C1:9013BattleAi_TestEnemyCountAtMost50verifiedBattleAi_TestTable entry $05.
$C1:9045BattleAi_TestTimeAtLeast61verifiedBattleAi_TestTable entry $06.
$C1:9082BattleAi_TestUnkB32060verifiedBattleAi_TestTable entry $07.
$C1:90BEBattleAi_TestHpAtMost114verifiedBattleAi_TestTable entry $08.
$C1:9130BattleAi_TestStatByteAtLeast94verifiedBattleAi_TestTable entry $09.
$C1:918EBattleAi_TestStatByteBits107verifiedBattleAi_TestTable entry $0A.
$C1:91F9BattleAi_TestStatByteAtMost100verifiedBattleAi_TestTable entry $0B.
$C1:925DBattleAi_TestTargetWithin3270verifiedBattleAi_TestTable entry $0C.
$C1:92A3BattleAi_TestAnySameRow113verifiedBattleAi_TestTable entry $0D.
$C1:9314BattleAi_TestAnyAboveOrLeft121verifiedBattleAi_TestTable entry $0E.
$C1:938DBattleAi_TestPathClear89verifiedBattleAi_TestTable entry $0F.
$C1:93E6BattleAi_TestScreenArea68verifiedBattleAi_TestTable entry $10.
$C1:942ABattleAi_TestB19EKind74verifiedBattleAi_TestTable entry $11.
$C1:9474BattleAi_TestB19EKindAndId94verifiedBattleAi_TestTable entry $12.
$C1:94D2BattleAi_TestB19EBit466verifiedBattleAi_TestTable entry $13.
$C1:9514BattleAi_TestB19ESlot134verifiedBattleAi_TestTable entry $14.
$C1:959ABattleAi_TestB19EByte2Bits60verifiedBattleAi_TestTable entry $15.
$C1:95D6BattleAi_TestAlways164verifiedBattleAi_TestTable entry $16: always holds (BattleAi_TestPassed at once), as test $00.
$C1:95DABattleAi_TestChance32verifiedBattleAi_TestTable entry $17.
$C1:95FABattleAi_TestStatByteEquals88verifiedBattleAi_TestTable entries $18 and $23-$28.
$C1:9652BattleAi_TestAlways194verifiedBattleAi_TestTable entry $19: always holds (BattleAi_TestPassed at once), as test $00.
$C1:9656BattleAi_TestOtherEnemy79verifiedBattleAi_TestTable entry $1A.
$C1:96A5BattleAi_TestPcCountAtMost47verifiedBattleAi_TestTable entry $1B.
$C1:96D4BattleAi_TestUnkAF0AMatch84verifiedBattleAi_TestTable entry $1C.
$C1:9728BattleAi_TestTargetGone52verifiedBattleAi_TestTable entry $1D.
$C1:975CBattleAi_TestChooseAndGoOn9verifiedBattleAi_TestTable entry $1E: BattleAi_TestPassed (the action is chosen), then !Battle_UnkAF24 = !BattleAi_TestFailed, so the caller still goes on to the next block.
$C1:9765BattleAi_TestTargetWithin4870verifiedBattleAi_TestTable entry $1F.
$C1:97ABBattleAi_TestUnkAEB3Set21verifiedBattleAi_TestTable entry $20.
$C1:97C0BattleAi_TestUnkAF15Set21verifiedBattleAi_TestTable entry $21.
$C1:97D5BattleAi_TestUnkB15859verifiedBattleAi_TestTable entry $22.
$C1:9810BattleAi_ChooseAnimTarget42verifiedBattleAi_ChooseTable entry $00.
$C1:983ABattleAi_ChooseTarget138verifiedBattleAi_ChooseTable entries $01 and $02.
$C1:98C4BattleAi_ChooseNop031verifiedBattleAi_ChooseTable entry $03: does nothing (RTS).
$C1:98C5BattleAi_ChooseByChance155verifiedBattleAi_ChooseTable entry $04 (!BattleAi_ActRestart).
$C1:9960BattleAi_ChooseNop051verifiedBattleAi_ChooseTable entry $05: does nothing (RTS).
$C1:9961BattleAi_ChooseNop061verifiedBattleAi_ChooseTable entry $06: does nothing (RTS).
$C1:9962BattleAi_ChooseClear074verifiedBattleAi_ChooseTable entry $07: !Battle_UnkAF24 = 0.
$C1:9966BattleAi_ChooseNop081verifiedBattleAi_ChooseTable entry $08: does nothing (RTS).
$C1:9967BattleAi_ChooseActId17verifiedBattleAi_ChooseTable entry $09: !BattleAi_ActId = record byte 1.
$C1:9978BattleAi_ChooseNop0A1verifiedBattleAi_ChooseTable entry $0A: does nothing (RTS).
$C1:9979BattleAi_ChooseClear0B4verifiedBattleAi_ChooseTable entry $0B: !Battle_UnkAF24 = 0.
$C1:997DBattleAi_ChooseNop0C1verifiedBattleAi_ChooseTable entry $0C: does nothing (RTS).
$C1:997EBattleAi_ChooseNop0D1verifiedBattleAi_ChooseTable entry $0D: does nothing (RTS).
$C1:997FBattleAi_ChooseNop0E1verifiedBattleAi_ChooseTable entry $0E: does nothing (RTS).
$C1:9980BattleAi_ChooseNop0F1verifiedBattleAi_ChooseTable entry $0F: does nothing (RTS).
$C1:9981BattleAi_ChooseIfGoneEnemy51verifiedBattleAi_ChooseTable entries $10 and $16.
$C1:99B4BattleAi_ChooseClear114verifiedBattleAi_ChooseTable entries $11-$15: !Battle_UnkAF24 = 0.
$C1:99B8BattleAi_RunNothing6verifiedBattleAi_RunTable entry $00: !BattleAi_RunMode = !BattleAi_RunNone (the enemy does nothing this turn; choose handler $00 has only set its animation and target).
$C1:99BEBattleAi_RunAttack123verifiedBattleAi_RunTable entry $01.
$C1:9A39BattleAi_RunTech269verifiedBattleAi_RunTable entry $02.
$C1:9B46BattleAi_RunNop031verifiedBattleAi_RunTable entry $03: RTS; !BattleAi_RunMode is left as it was.
$C1:9B47BattleAi_RunNop041verifiedBattleAi_RunTable entry $04 (!BattleAi_ActRestart): RTS; !BattleAi_RunMode is left as it was.
$C1:9B48BattleAi_RunChooseRepeat68verifiedBattleAi_RunTable entry $05.
$C1:9B8CBattleAi_RunNop061verifiedBattleAi_RunTable entry $06: RTS; !BattleAi_RunMode is left as it was.
$C1:9B8DBattleAi_RunSwapInEnemy225verifiedBattleAi_RunTable entry $07.
$C1:9C6EBattleAi_RunNop081verifiedBattleAi_RunTable entry $08: RTS; !BattleAi_RunMode is left as it was.
$C1:9C6FBattleAi_RunLeave68verifiedBattleAi_RunTable entry $09.
$C1:9CB3BattleAi_RunKoSelf104verifiedBattleAi_RunTable entry $0A.
$C1:9D1BBattleAi_RunSetStatByte87verifiedBattleAi_RunTable entry $0B.
$C1:9D72BattleAi_RunAddStatByte92verifiedBattleAi_RunTable entry $0C.
$C1:9DCEBattleAi_RunSetFlags148verifiedBattleAi_RunTable entry $0D.
$C1:9E62BattleAi_RunNop0E1verifiedBattleAi_RunTable entry $0E: RTS; !BattleAi_RunMode is left as it was.
$C1:9E63BattleAi_RunMessage21verifiedBattleAi_RunTable entry $0F.
$C1:9E78BattleAi_RunRestoreEnemies226verifiedBattleAi_RunTable entry $10.
$C1:9F5ABattleAi_RunSetStatBytes120verifiedBattleAi_RunTable entry $11.
$C1:9FD2BattleAi_RunSetStatsTech380verifiedBattleAi_RunTable entry $12.
$C1:A14EBattleAi_RunAddUnkB15858verifiedBattleAi_RunTable entry $13.
$C1:A188BattleAi_RunAddStatBytes131verifiedBattleAi_RunTable entry $14.
$C1:A20BBattleAi_RunAddStatsTech395verifiedBattleAi_RunTable entry $15.
$C1:A396BattleAi_RunRestoreAndSetStats59verifiedBattleAi_RunTable entry $16.
$C1:A3D1BattleAi_AddStatByteAtY37verifiedAdds DP $10 to the byte at (DP $0E),Y (a stat-block byte: DP $0E/$0F = the offset, Y = the block address): bit 7 (!BattleAi_StatDeltaSub) set subtracts the low 7 bits, with 0 as the floor; else...
$C1:A3F6BattleAi_TargetNone1verifiedBattleAi_TargetTable entry $00: returns at once, so the list stays as it was (all $FF) and !BattleAi_TargetCount is not written.
$C1:A3F7BattleAi_TargetPcs26verifiedBattleAi_TargetTable entry $01: lists PC slots 0-2 whose !Battler_UnkAEFF is not $FF (present), in slot order, from entry 0; !BattleAi_TargetCount = how many (0-3).
$C1:A411BattleAi_TargetAll29verifiedBattleAi_TargetTable entry $02: the present PCs (BattleAi_TargetPcs), then each enemy slot 3-10 whose !Battler_UnkAEFF is not $FF, appended in slot order; !BattleAi_TargetCount = the total.
$C1:A42EBattleAi_TargetSelf15verifiedBattleAi_TargetTable entry $03: the acting enemy itself, !BattleAi_Targets[0] = !Battle_UnkB252 + 3 (its slot), present or not; !BattleAi_TargetCount = 1.
$C1:A43DBattleAi_TargetFromUnkB19E21verifiedBattleAi_TargetTable entry $04: !BattleAi_Targets[0] = the low nibble of the first byte of the acting enemy's 4-byte !Battle_UnkB19E record (offset !Battle_UnkB252 * 4), taken as a slot without...
$C1:A452BattleAi_TargetRandomPc93verifiedBattleAi_TargetTable entry $05: one random present PC.
$C1:A4AFBattleAi_TargetNearestPc49verifiedBattleAi_TargetTable entry $06: !BattleAi_TargetCount = 0, then position query !BattlePos_QueryNearestPc (service 5) from the acting enemy (!BattlePos_Subject = !Battle_UnkB252 + 3).
$C1:A4E0BattleAi_TargetFarthestPc40verifiedBattleAi_TargetTable entry $07: as BattleAi_TargetNearestPc with position query !BattlePos_QueryFarthestPc, but only !BattlePos_Found not negative is checked (no !Battler_UnkAEFF test).
$C1:A508BattleAi_TargetLowestHpPc57verifiedBattleAi_TargetTable entry $08: the PC with the lowest non-zero BattlerStats.CurHp, meant over PC slots 0-2; presence is not checked.
$C1:A541BattleAi_TargetPcStatus10verifiedBattleAi_TargetTable entry $09: BattleAi_TargetsByPcByte with DP $0A = PcStatBlk.Status: the present PCs whose Status byte is non-zero (any status), not KO'd, cut to one by BattleAi_PickPcTarget.
$C1:A54BBattleAi_TargetPcStatus210verifiedBattleAi_TargetTable entry $0A: as BattleAi_TargetPcStatus with PcStatBlk.Status2 (any bit set).
$C1:A555BattleAi_TargetPcUnk1F10verifiedBattleAi_TargetTable entry $0B: as BattleAi_TargetPcStatus with PcStatBlk.Unk1F (= BattlerStats.Unk4C; any bit set).
$C1:A55FBattleAi_TargetPcUnk2010verifiedBattleAi_TargetTable entry $0C: as BattleAi_TargetPcStatus with PcStatBlk.Unk20 (= BattlerStats.Unk4C+1; any bit set).
$C1:A569BattleAi_TargetPcUnk2110verifiedBattleAi_TargetTable entry $0D: as BattleAi_TargetPcStatus with PcStatBlk.Unk21 (= BattlerStats.Unk4C+2; any bit set).
$C1:A573BattleAi_TargetPcStatus2Bit148verifiedBattleAi_TargetTable entry $0E: the PCs (slots 0-2) whose PcStatBlk.Status2 has bit 1 (!BattleAi_PcByteMask = $02), through BattleAi_AddPcByByte (present, not KO'd, marked by .Unk20), cut to one...
$C1:A5A3BattleAi_TargetPcStatus2Bit748verifiedBattleAi_TargetTable entry $0F: as BattleAi_TargetPcStatus2Bit1 with PcStatBlk.Status2 bit 7 (mask $80).
$C1:A5D3BattleAi_TargetPcStatus2Bit248verifiedBattleAi_TargetTable entry $10: as BattleAi_TargetPcStatus2Bit1 with PcStatBlk.Status2 bit 2 (mask $04).
$C1:A603BattleAi_TargetPcUnk21Bit248verifiedBattleAi_TargetTable entry $11: as BattleAi_TargetPcStatus2Bit1 with PcStatBlk.Unk21 (= BattlerStats.Unk4C+2) bit 2 (mask $04).
$C1:A633BattleAi_TargetPcUnk21Bit648verifiedBattleAi_TargetTable entry $12: as BattleAi_TargetPcStatus2Bit1 with PcStatBlk.Unk21 (= BattlerStats.Unk4C+2) bit 6 (mask $40).
$C1:A663BattleAi_TargetPcUnk20Bit448verifiedBattleAi_TargetTable entry $13: as BattleAi_TargetPcStatus2Bit1 with PcStatBlk.Unk20 (= BattlerStats.Unk4C+1) bit 4 (mask $10).
$C1:A693BattleAi_TargetPcUnk01Bit348verifiedBattleAi_TargetTable entry $14: as BattleAi_TargetPcStatus2Bit1 with PcStatBlk.Unk01 (= BattlerStats.Unk2E) bit 3 (mask $08).
$C1:A6C3BattleAi_TargetOtherEnemies42verifiedBattleAi_TargetTable entry $15: the enemy slots 3-10 whose !Battler_UnkAEFF is not $FF (present), in slot order, leaving out the acting enemy (slot !Battle_UnkB252 + 3, kept in DP $0A/$0B)...
$C1:A6EDBattleAi_TargetEnemies28verifiedBattleAi_TargetTable entry $16: the enemy slots 3-10 whose !Battler_UnkAEFF is not $FF (present), in slot order, the acting enemy included; !BattleAi_TargetCount = how many.
$C1:A709BattleAi_TargetNearestEnemy46verifiedBattleAi_TargetTable entry $17: position query !BattlePos_QueryNearestEnemy (service 5) from the acting enemy (!BattlePos_Subject = !Battle_UnkB252 + 3).
$C1:A737BattleAi_TargetFarthestEnemy46verifiedBattleAi_TargetTable entry $18: as BattleAi_TargetNearestEnemy with position query !BattlePos_QueryFarthestEnemy.
$C1:A765BattleAi_TargetLowestHpEnemy68verifiedBattleAi_TargetTable entry $19: the present enemy (slots 3-10, !Battler_UnkAEFF not $FF) with the lowest non-zero HP (PcStatBlk.CurHp through !BattleRom_PcStatBlock), the acting enemy included...
$C1:A7A9BattleAi_TargetOtherEnemyStatus60verifiedBattleAi_TargetTable entry $1A: the enemies (slots 3-10, through BattleAi_AddPcByByte: present, not KO'd, marked by .Unk20) whose PcStatBlk.Status byte is non-zero (!BattleAi_PcByteMask =...
$C1:A7E5BattleAi_TargetEnemyStatus52verifiedBattleAi_TargetTable entry $1B: as BattleAi_TargetOtherEnemyStatus with PcStatBlk.Status non-zero, self (slot !Battle_UnkB18B) included.
$C1:A819BattleAi_TargetOtherEnemyStatus260verifiedBattleAi_TargetTable entry $1C: as BattleAi_TargetOtherEnemyStatus with PcStatBlk.Status2 non-zero, leaving out slot !Battle_UnkB18B.
$C1:A855BattleAi_TargetEnemyStatus252verifiedBattleAi_TargetTable entry $1D: as BattleAi_TargetOtherEnemyStatus with PcStatBlk.Status2 non-zero, self (slot !Battle_UnkB18B) included.
$C1:A889BattleAi_TargetOtherEnemyUnk1F60verifiedBattleAi_TargetTable entry $1E: as BattleAi_TargetOtherEnemyStatus with PcStatBlk.Unk1F (= BattlerStats.Unk4C) non-zero, leaving out slot !Battle_UnkB18B.
$C1:A8C5BattleAi_TargetEnemyUnk1F52verifiedBattleAi_TargetTable entry $1F: as BattleAi_TargetOtherEnemyStatus with PcStatBlk.Unk1F (= BattlerStats.Unk4C) non-zero, self (slot !Battle_UnkB18B) included.
$C1:A8F9BattleAi_TargetOtherEnemyStatus2Bit160verifiedBattleAi_TargetTable entry $20: as BattleAi_TargetOtherEnemyStatus with PcStatBlk.Status2 bit 1 (mask $02), leaving out slot !Battle_UnkB18B.
$C1:A935BattleAi_TargetOtherEnemyStatus2Bit760verifiedBattleAi_TargetTable entry $21: as BattleAi_TargetOtherEnemyStatus with PcStatBlk.Status2 bit 7 (mask $80), leaving out slot !Battle_UnkB18B.
$C1:A971BattleAi_TargetOtherEnemyStatus2Bit260verifiedBattleAi_TargetTable entry $22: as BattleAi_TargetOtherEnemyStatus with PcStatBlk.Status2 bit 2 (mask $04), leaving out slot !Battle_UnkB18B.
$C1:A9ADBattleAi_TargetOtherEnemyUnk21Bit660verifiedBattleAi_TargetTable entry $23: as BattleAi_TargetOtherEnemyStatus with PcStatBlk.Unk21 (= BattlerStats.Unk4C+2) bit 6 (mask $40), leaving out slot !Battle_UnkB18B.
$C1:A9E9BattleAi_TargetOtherEnemyStatusBit160verifiedBattleAi_TargetTable entry $24: as BattleAi_TargetOtherEnemyStatus with PcStatBlk.Status bit 1 (mask $02), leaving out slot !Battle_UnkB18B.
$C1:AA25BattleAi_TargetOtherEnemyUnk19Bit060verifiedBattleAi_TargetTable entry $25: as BattleAi_TargetOtherEnemyStatus with PcStatBlk.Unk19 (= BattlerStats.Unk46) bit 0 (mask $01), leaving out slot !Battle_UnkB18B.
$C1:AA61BattleAi_TargetLowestHpOtherEnemy74verifiedBattleAi_TargetTable entry $26: as BattleAi_TargetLowestHpEnemy, but slot !Battle_UnkB18B ("self"; see the BattleAi_TargetTable banner for whose slot it holds in each pass) is left out.
$C1:AAABBattleAi_TargetEnemy011verifiedBattleAi_TargetTable entry $27: !BattleAi_Targets[0] = slot 3 (enemy entry 0), present or not; !BattleAi_TargetCount = 1.
$C1:AAB6BattleAi_TargetEnemy111verifiedBattleAi_TargetTable entry $28: as BattleAi_TargetEnemy0 with slot 4 (entry 1).
$C1:AAC1BattleAi_TargetEnemy211verifiedBattleAi_TargetTable entry $29: as BattleAi_TargetEnemy0 with slot 5 (entry 2).
$C1:AACCBattleAi_TargetEnemy311verifiedBattleAi_TargetTable entry $2A: as BattleAi_TargetEnemy0 with slot 6 (entry 3).
$C1:AAD7BattleAi_TargetEnemy411verifiedBattleAi_TargetTable entry $2B: as BattleAi_TargetEnemy0 with slot 7 (entry 4).
$C1:AAE2BattleAi_TargetEnemy511verifiedBattleAi_TargetTable entry $2C: as BattleAi_TargetEnemy0 with slot 8 (entry 5).
$C1:AAEDBattleAi_TargetEnemy611verifiedBattleAi_TargetTable entry $2D: as BattleAi_TargetEnemy0 with slot 9 (entry 6).
$C1:AAF8BattleAi_TargetEnemy711verifiedBattleAi_TargetTable entry $2E: as BattleAi_TargetEnemy0 with slot 10 (entry 7).
$C1:AB03BattleAi_TargetRandomUnkAF1575verifiedBattleAi_TargetTable entry $2F: lists the enemy entries n (0-7) whose !Battle_UnkAF15 byte has bit 7 (!Battle_AF15Bit7; such an enemy is out of the fight, probably: BattleSys_UpdateKo treats it as...
$C1:AB4EBattleAi_TargetSlot011verifiedBattleAi_TargetTable entry $30: as BattleAi_TargetEnemy0 with slot 0.
$C1:AB59BattleAi_TargetSlot111verifiedBattleAi_TargetTable entry $31: as BattleAi_TargetEnemy0 with slot 1.
$C1:AB64BattleAi_TargetSlot211verifiedBattleAi_TargetTable entry $32: as BattleAi_TargetEnemy0 with slot 2.
$C1:AB6FBattleAi_TargetSlot311verifiedBattleAi_TargetTable entry $33: as BattleAi_TargetEnemy0 with slot 3.
$C1:AB7ABattleAi_TargetSlot411verifiedBattleAi_TargetTable entry $34: as BattleAi_TargetEnemy0 with slot 4.
$C1:AB85BattleAi_TargetSlot511verifiedBattleAi_TargetTable entry $35: as BattleAi_TargetEnemy0 with slot 5.
$C1:AB90BattleAi_TargetSlot611verifiedBattleAi_TargetTable entry $36: as BattleAi_TargetEnemy0 with slot 6.
$C1:AB9BBattleAi_TargetHighestHpPc46verifiedBattleAi_TargetTable entry $37: the PC (slots 0-2) with the highest BattlerStats.CurHp; presence and KO are not checked.
$C1:ABC9BattleAi_TargetRandomOtherEnemy75verifiedBattleAi_TargetTable entry $38: lists the present enemy slots 3-10 other than the acting enemy (as BattleAi_TargetOtherEnemies), then, with two or more, Battle_RandRange (0 to count - 1) picks one...
$C1:AC14BattleAi_ReadTargets24verifiedReads the target code of a script record and fills !BattleAi_Targets: BattleAi_ClearTargets first, then !Battle_UnkB1D2 + 1 and the code at that address.
$C1:AC2CBattleAi_ReadTargets_Code19verified
$C1:AC3FBattleAi_ReadTargets_Done7verified
$C1:AC46BattleAi_ClearTargets17verifiedSets the 11 bytes of !BattleAi_Targets and of !Battle_UnkAD8E to $FF (empty).
$C1:AC57BattleSys_UnkAC577verifiedBattleSys_UnkBFA4 (it requests service 4, BattleSys_RunAction, which plays the action block), then BattleSys_UnkAC85.
$C1:AC5EBattleSys_UnkAC5E39verifiedIf !Battle_UnkAEB2 is set: !Battle_UnkAE85[n] = 1 for each enemy n (0-7) whose !Battle_UnkAEB3 entry is non-zero, then, unless !Battle_Unk2989 has bit 5, service !BattleSys_ServiceUnk6...
$C1:AC85BattleSys_UnkAC854verifiedCalls Battle_ApplyHits.
$C1:AC89BattleAi_SetCmdBits69verifiedORs the slot A + 3 (an enemy entry + 3) into !Battle_UnkB18E and zeroes !Battle_UnkB191, then by !BattleAi_ActCode: 0: !Battle_UnkB18F = 0; 1: !Battle_UnkB18E |= $80, !Battle_UnkB18F = 0...
$C1:ACCEBattleAi_ArgToDp0E36verifiedDP $0E = !BattleAi_ActArg mapped: 1 and 2 give 4, 3 and 4 give $0D, any other value stays as it is.
$C1:ACF2BattleAi_FillActBlock23verifiedStarts the action block for the acting battler: !Battle_UnkAE90 = 0, !Battle_ActCaster = !Battle_UnkB18B, !Battle_ActKind = !BattleAi_ActCode, !Battle_ActId = !BattleAi_ActId.
$C1:AD09BattleAi_SetMainMask44verified!Battle_ActMainMask = 0, then, if !BattleAi_TargetCount is non-zero and !BattleAi_Targets[0] is a slot (not $FF), the bit of that slot (!BattleAi_MaskSlot0 >> slot, bit 15 = slot 0) is ORed in.
$C1:AD35BattleAi_SetTargetMask51verified!Battle_ActTargetMask = the bits of !BattleAi_Targets entries 1 to !BattleAi_TargetCount - 1 (entry 0 is the main target, see BattleAi_SetMainMask; !BattleAi_MaskSlot0 >> slot, bit 15 = slot 0).
$C1:AD68BattleAi_TargetsByPcByte57verifiedLists each present, not KO'd PC whose stat-block byte at offset DP $0A (from !BattleRom_PcStatBlock) is non-zero, through BattleAi_AddPcByByte for PCs 0, 1, 2 with !BattleAi_PcByteMask = $FF, then...
$C1:ADA1BattleAi_PickPcTarget128verifiedCuts a list built by BattleAi_AddPcByByte down to one target: - !BattleAi_TargetCount 0: nothing.
$C1:AE21BattleAi_PickMarkedTarget79verifiedAfter a test has marked the entries of !BattleAi_Targets it accepts (!BattleAi_TargetMarked), cuts the list down to one target: - !BattleAi_TargetCount 0: the test fails (!Battle_UnkAF24 + 1).
$C1:AE70BattleAi_AddPcByByte99verifiedAdds PC slot !BattleAi_PcSlot to !BattleAi_Targets when it is present (!Battler_UnkAEFF not $FF), the byte at offset DP $0A in its stat block (address from !BattleRom_PcStatBlock[X]) has any of...
$C1:AED3BattleAi_UnkAED342verifiedNo caller found (no JSR, JSL or pointer to $AED3 in the ROM; maybe dead).
$C1:AEFDBattleAi_NoteFirstTest37verifiedRun by a test handler that holds, just before BattleAi_TestPassed: - !Battle_UnkB1CF has !BattleAi_SecondTest (this is the first of a block's two tests): !BattleAi_FirstTarget = the slot (low...
$C1:AF22Battle_RandRange87verifiedA random number from the low bound X (low byte) up to, but not including, the high bound A: low + (RandomTableFD[!Battle_RandIdx] mod (high - low)), then !Battle_RandIdx + 1.
$C1:AF79Battle_RandRangeAlt89verifiedBattle_RandRange with its own index: the same code, but the entry of RandomTableFD is taken at !Battle_UnkB3E6 (not !Battle_RandIdx), and !Battle_UnkB3E6 is the counter stepped.
$C1:AFD2BattleAi_RunMainPart193verifiedRuns the main part of an enemy's script: block after block until one holds or the part ends.
$C1:B093BattleSys_UnkB09335verifiedBattlerStats.Unk2F bit 0 = (.CurHp <= .MaxHp / 8): set when the HP is down to an eighth or less, cleared otherwise (the bit Battle_PickStatusAnim tests, so probably the low-HP pose).
$C1:B0B6BattleSys_UnkB0B6365verifiedSets which turn lists battler Y takes part in from its status bits: bit 0 (!Battle_ListPartBit) of its !Battle_ListFlags byte in list n = Status2 bit 7 (list 0), bit 6 (1), bit 5 (2), bit 4 (8)...
$C1:B223BattleSys_UnkB22386verifiedBattleSys_UpdateKo for each slot 0-10 (counter !Battle_UnkB2D3); after it, an enemy slot whose entry is empty ($FF) and whose !Enemy_TargetWanted slot is empty too gets !Battle_UnkB242 = $FF and...
$C1:B279BattleSys_UpdateKo322verifiedThe KO check of battler Y.
$C1:B3BBBattleSys_UnkB3BB23verifiedKeeps only bit 6 (!FieldBtl_ObjKind6Flag) of the 8 FieldBtlObj.Flags bytes, so after the battle FieldBtl_RestoreObj removes every saved field object (Flags 0) except those with that bit.
$C1:B3D2BattleSys_UnkB3D239verifiedFor each enemy entry n (0-7) still present (!Battler_UnkAF0A not $FF) without !Battle_UnkAF15 bit 7: FieldBtlObj[n].Flags = $40 (only !FieldBtl_ObjKind6Flag), so FieldBtl_RestoreObj puts that...
$C1:B3F9BattleSys_UnkB3F973verifiedDrops the latched command of PC X when the PC cannot act: KO'd (Status bit 7), BattlerStats.Unk4C+2 | +7 bit 7, or Status2 bits 7, 2 or 1 (!Battle_NoActMask2).
$C1:B442BattleSys_UnkB44270verifiedCopies each PC's 80-byte block from its BattlerStats record (.Unk2D on, the !BattleRom_PcStatBlock bytes) back to its character's record in !Menu_CharRecords ($50 bytes per !Pc_CharId); slots...
$C1:B488BattleAi_FindReactPart34verifiedFinds the reaction part of an enemy's script: the script is !BattleRom_AiScriptPtrs[id], BattleAi_PickScript may swap in a fixed one, and from there it skips to the byte after the first $FF (the...
$C1:B4AABattleAi_PickScript63verified!Battle_UnkB1D2 = X, the enemy's own script address, unless the BattlerStats record of the enemy (slot !Battle_UnkB252 + 3) says otherwise: - .Unk4C+2 or .Unk4C+7 has bit 7 (!BattleAi_Unk4CBit7)...
$C1:B4E9BattleSys_UnkB4E9140verifiedPuts the battle's item list back into the inventory (probably what !Battle_InvIds / InvCounts are): first BattleSys_RefundItem for PCs 0, 1, 2; then for each of the 256 Item_BattleList records...
$C1:B575BattleSys_UnkB575348verifiedBuilds !Battle_CmdGroups from the three BattleCmd.Partners bytes (row p holds p and each other PC named in p's nibbles, $FF elsewhere; a nibble naming p itself, $F or any other value adds...
$C1:B6D1BattleSys_RefundItem61verifiedIf the BattleCmd.Kind of PC DP $14 has bit 6 (an item command still pending), clears the bit and gives the item back: the first Item_BattleList record (of 256) whose .Id is the command's .ActionId...
$C1:B70EBattleSys_UnkB70E23verifiedFor the !Battle_Unk2989 bit-5 battle: all three PCs latched and queued at once: !Battle_UnkB188-B18A = $81 (bit 7 | 1), each BattleCmd.State = $41 (bit 6, "queued", | 1).
$C1:B725BattleSys_UnkB72561verifiedFor the !Battle_Unk2989 bit-5 battle: !Battle_CmdQueue[0] = PC 0, !Battle_CmdQueueLen = 1, each !Pc_AtbCur = 0 and !Pc_AtbMax = $30, and the three BattleCmd records (21 bytes) are copied from bank...
$C1:B762BattleSys_UnkB762144verifiedKeeps the 8 !Battle_UnkAEB3 bytes in !Battle_UnkAE65 and zeroes them and !Battle_UnkAEB2, then for each of the 8 entries of !Battle_UnkB3AC (the slots of the last action, per BattleSys_Unk8461)...
$C1:B7F2BattleSys_UnkB7F227verifiedService !BattleSys_ServiceRemoveReady (BattleMenu_RemoveBattlerFromReady) for PC slots 0, 1 and 2 in turn: takes every PC out of the menu's ready state.
$C1:B80DBattleAi_TestTable82verifiedHandlers of the script's test codes $00-$28, by code * 2: JSR (T,X) in BattleAi_RunMainPart ($C1:B006, $C1:B021) and BattleSys_Unk8461 ($C1:874E, $C1:8769).
$C1:B85FBattleAi_ChooseTable46verifiedHandlers of the action codes $00-$16 as a block is chosen, by code * 2: JSR (T,X) in BattleAi_TestPassed ($C1:8CE7).
$C1:B88DBattleAi_RunTable46verifiedHandlers of the same action codes $00-$16 on the enemy's turn, by code * 2: JSR (T,X) in BattleAi_EnemyTurn ($C1:8D88).
$C1:B8BBBattleAi_TargetTable114verifiedHandlers of the script's target codes $00-$38, by code * 2: JSR (T,X) in BattleAi_ReadTargets ($C1:AC2E).
$C1:B92DBattleSys_ListHandlerTable26verifiedHandler of each turn list, indexed by list number * 2: BattleSys_Main runs entry n (JSR (T,X) at $C1:8333) for each list whose !Battle_ListDue bit is set.
$C1:B947BattleSys_ListOffsetTable26verifiedAddress of each turn list's !Battle_ListFlags bytes (list * 11 past the start), indexed by list number * 2; BattleSys_Main's scan reads it with LDA.l at $C1:82C5.
$C1:B961BattleSys_RemoveReadyLong6verifiedService !BattleSys_ServiceRemoveReady (BattleMenu_RemoveBattlerFromReady) for bank-$FD code: a long-callable wrapper.
$C1:B967BattleSys_UnkB967761verifiedRuns a PC's committed command.
$C1:BC60BattleSys_UnkBC60129verifiedDoes nothing: its first instruction branches to its RTS, so the rest ($C1:BC62-$BCDF) is dead.
$C1:BCE1BattleSys_UnkBCE123verifiedEnds a PC's turn: reloads the gauge of the PC !Battle_UnkB18B (!Battler_UnkAFAB = !Battle_UnkB158, then BattleSys_UnkBD6F), sets its turn-list-12 byte to 1 if it was non-zero (re-armed, not due).
$C1:BCF8BattleSys_UnkBCE1_ClearRecords115verified
$C1:BD6BBattleSys_UnkBCE1_Done4verified
$C1:BD6FBattleSys_UnkBD6F68verifiedApplies the battler's speed bits to its !Battler_UnkAFAB (the gauge reload): halved when BattlerStats.Unk4C+1 or +6 has bit 7 (!Battle_ListHalveBit), then doubled, at most $FF, when .Status2 has...
$C1:BDB3BattleSys_ResetTechUsers403verifiedAfter a tech (BattleSys_UnkB967's tech path, played or skipped): clears the BattleCmd record of the first user's slot (.State, .Kind, .Menu, .Target, .ActionId = 0; slot = !Battle_UnkB1BE of...
$C1:BF46BattleSys_UnkBF4651verifiedBy byte 0 of record !Battle_UnkB18C of !BattleRom_UnkCC05CC (4 B each): bit 7 -> BattleSys_Effect29, else bit 2 -> BattleSys_Effect2A, else bit 6 -> BattleSys_Effect2B, else nothing.
$C1:BF79BattleSys_UnkBF798verified!Battle_UnkAF23 = 0, then BattleSys_RunTechParts (which adds 1 to it when a PC's attack-kind part finds no enemy).
$C1:BF81BattleSys_UnkBF8135verifiedCopies the 17 bytes of record !Battle_UnkB18C of !BattleRom_UnkCC213F to !Battle_UnkAEE6.
$C1:BFA4BattleSys_UnkBFA46verifiedService !BattleSys_ServiceRunAction (BattleSys_RunAction), which plays the action block.
$C1:BFAABattleSys_RunPcAttack128verifiedPlays the attack of battler !Battle_UnkB18B on the slot in !Battle_UnkAD8E: !Battle_UnkB1FC bit 1 is set over it; the action block is cleared (id, flags, both masks, !Battle_ActUnkAE9B = 0...
$C1:C02ABattle_ScaleByte2057verifiedDP $30/$31 = about x / 5: x * 64 - x * 8 - x * 4 - x / 2 - x / 4 (= x * 51.25), / 256.
$C1:C063Battle_ScaleByte3055verifiedDP $30/$31 = about x * 3 / 10: x * 128 - x * 32 - x * 16 - x * 2 - x (= x * 77), / 256.
$C1:C09ABattle_ScaleByte6066verifiedDP $30/$31 = about x * 3 / 5: x * 256 - x * 64 - x * 32 - x * 4 - x * 2 - x / 4 (= x * 153.75), / 256.
$C1:C0DCBattle_ScaleWord6061verifiedDP $30/$31 = about x * 3 / 5: x - x / 4 - x / 8 - x / 64 - x / 128 - x / 1024, all 16 bits.
$C1:C119Battle_ScaleByte8055verifiedDP $30/$31 = about x * 4 / 5: x * 256 - x * 32 - x * 16 - x * 2 - x (= x * 205), / 256.
$C1:C150Battle_ScaleWord8050verifiedDP $30/$31 = about x * 4 / 5: x - x / 8 - x / 16 - x / 128 - x / 256, all 16 bits.
$C1:C182Battle_ScaleByte1048verifiedDP $30/$31 = about x / 10: x * 32 - x * 4 - x * 2 - x / 4 (= x * 25.75), / 256.
$C1:C1B2Battle_ScaleWord1043verifiedDP $30/$31 = about x / 10: x / 8 - x / 64 - x / 128 - x / 1024, all 16 bits.
$C1:C1DDBattleSys_UnkC1DD1,818verifiedChecks that the users of the action !Battle_UnkB18C (a tech, an item, or an enemy's action) can act and resolves its targets into !Battle_UnkAD8E (slots, $FF-ended) and !Battle_UnkAD8D (their count).
$C1:C8F7BattleSys_MapEmptyTarget20verifiedA battler slot for a target: $FF stays $FF; a slot whose !Battler_UnkAEFF entry is present comes back as it is; an empty one comes back as its !Battle_UnkAE6D entry (BattleFD_UnkB223 fills that...
$C1:C90BBattle_Mul1631verified16 x 16 -> 32-bit unsigned shift-and-add multiply: !Battle_MathHi:MathLo = !Battle_MathA * !Battle_MathB.
$C1:C92ABattle_Div3250verified32 / 16-bit unsigned restoring divide of !Battle_MathHi:MathA by !Battle_MathB: !Battle_MathRem = the remainder, !Battle_MathLo = the quotient's low word.
$C1:C95CBattleSys_AreaParamTable14verifiedThe area parameter routines of BattleSys_UnkC1DD, by bits 6-0 of an area record entry's byte 1 (JSR (BattleSys_AreaParamTable,X) at $C1:C732).
$C1:C96ABattleSys_UnkC96A176verifiedSingle techs of PC DP $06: for each tech id from !BattleRom_CharFirstTech[character] up to the next character's first (8 techs), whose bit in !Battle_TechBits1[character] is set (bit 7 first)...
$C1:CA1ABattleSys_UnkCA1A302verifiedDouble techs of PC DP $06: for each tech $39-$65 whose bit in !Battle_TechBits2 is set (3 techs per byte, bit 7 first), whose two users are both in the party (!Battle_UnkB1BE not negative) and one...
$C1:CB48BattleSys_TechMpCost125verifiedA = the MP cost of the first user's part of tech A: !BattleRom_TechMpCost[BattleRom_TechRec[A].Part1 & $7F].
$C1:CB61BattleSys_TechMpCost225verifiedAs BattleSys_TechMpCost1, for the second user (.Part2).
$C1:CB7ABattleSys_TechMpCost325verifiedAs BattleSys_TechMpCost1, for the third user (.Part3).
$C1:CB93BattleSys_LoadTechUsers48verified!Battle_TechUsers = the three character ids of the user set of tech A (BattleRom_TechRec[A].UserSet & $7F, 3 bytes each in !BattleRom_TechUserSets; $FF = no user).
$C1:CBC3BattleSys_StoreMpCost51verifiedY = the cost Y as BattleSys_AdjustMpCost cuts it for the PC of character id A (slot !Battle_UnkB1BE[A], its !Pc_UnkB3BA), stored to the tech menu entry at the address in DP $04: .MpCost0 for slot...
$C1:CBF6BattleSys_AdjustMpCost21verifiedCuts the MP cost in Y's low byte by A, the PC's !Pc_UnkB3BA: $A2 halves it, $A3 quarters it (each halving rounds up); any other value leaves it.
$C1:CC0BBattleSys_StoreMpCost1051verifiedAs BattleSys_StoreMpCost, into the entry 10 records past the address in DP $04 (TechMenuRec[10]).
$C1:CC3EBattleSys_StoreMpCost1851verifiedAs BattleSys_StoreMpCost, into the entry 18 records past the address in DP $04 (TechMenuRec[18]).
$C1:CC71BattleSys_PayTechMp90verifiedTakes cost Y, cut by BattleSys_AdjustMpCost, off BattlerStats.CurMp of the PC with character id A (slot !Battle_UnkB1BE[A]: 0, 1, any other value as 2).
$C1:CCCBBattleSys_UnkCCCB308verifiedTriple tech of PC DP $06: the first tech $66-$74 whose bit in !Battle_TechBits3 is set (one tech per byte, bit 7) and whose three users are all in the party gets entry 18 (TechMenuRec[18]): tech...
$C1:CDFFBattleSys_UnkCDFF55verifiedBuilds the battle's item list: zeroes the 256 Item_BattleList records ($500 bytes), then walks the inventory from entry DP $00 = 0: an empty entry (!Battle_InvIds 0) goes to...
$C1:CE36BattleSys_UnkCE364verifiedBattleFD_UnkAEF2, then falls into BattleSys_UnkCE3A.
$C1:CE3ABattleSys_UnkCE3A219verifiedSets up the stat block (!BattleRom_PcStatBlock) of PC DP $02, if the slot has an entry: .Unk0B-.Unk11 are copied to .Unk36-.Unk3C, then for each of three records in bank $CC, 6 bytes each, DP $08...
$C1:CF15BattleSys_UnkCF1561verifiedFor each PC slot 0-2 (present or not), with Y = its stat block address (!BattleRom_PcStatBlock): BattleFD_ItemRecOffset with A = the block's byte at offset DP $06 (LDA (DP $06),Y), then DP $0A...
$C1:CF52BattleSys_UnkCF5223verifiedX = (B : DP $06) * 4 (16-bit), A = 0: it loads DP $06 into A (the incoming A is not used), tests it for $29, but both branches do the same (REP, ASL, ASL, CLC), so the test has no effect.
$C1:CF69BattleSys_UnkCF6985verifiedAdds a record's bonus to the stat block at DP $00: byte 5 of the bank-$CC record at offset DP $08 (!BattleRom_EquipBonus); if it is not 0, its low nibble is added to PcStatBlk.Unk3F, .Unk40...
$C1:CFBEBattleAi_EnemyTurnJsr4verifiedBattleAi_EnemyTurn through a JSR of its own.
$C1:D132BattleSys_EffRecArgsUnk6629verifiedDP $16 = the caster's BattlerStats.Unk66 (!Battle_UnkB1F4), DP $18 = effect byte 1 & $1F, DP $1A = effect byte 2 (DP $17/$19/$1B = 0).
$C1:D14FBattleSys_EffRecArgs1217verifiedDP $16 = effect byte 1, DP $18 = effect byte 2 (DP $17/$19 = 0).
$C1:D160BattleSys_EffRecArg10Unk4620verifiedDP $16 = effect byte 10, DP $18 = the target's BattlerStats.Unk46 (!Battle_UnkB1F6) (DP $17/$19 = 0).
$C1:D174BattleSys_EffRecStatPair44verifiedTwo stat bytes picked by the effect record: DP $16 = the caster's BattlerStats byte at .Unk2D + effect byte 3, DP $18 = the target's at .Unk2D + effect byte 4 (DP $17/$19 = 0).
$C1:D1A0BattleSys_EffRecArgs12B4verifiedBattleSys_EffRecArgs12 through a JSR of its own.
$C1:D1A4BattleSys_EffRecArgs5617verifiedDP $16 = effect byte 5 (!Battle_UnkAEEB), DP $18 = effect byte 6 (DP $17/$19 = 0).
$C1:D1B5BattleSys_EffRecArg116verifiedDP $1A = effect byte 11 (8-bit; DP $1B left alone): the bits BattleSys_RecordMiss reads.
$C1:D1BBBattleSys_CasterUnk7320verifiedDP $20 = the caster's BattlerStats.Unk73, DP $1E = its .Unk74 (DP $1F/$21 = 0).
$C1:D1CFBattleSys_EffRecArgs12C4verifiedBattleSys_EffRecArgs12 through a JSR of its own, as BattleSys_EffRecArgs12B (two identical unreferenced copies).
$C1:D1D3BattleSys_LoadEffectArgs38verifiedFrom the !BattleRom_UnkCC05CC record of !Battle_UnkB18C: DP $16 = byte 3 & $3F, DP $18 = byte 2 & $0F, DP $1A = byte 1 (each 16-bit, high byte 0): BattleSys_RestoreHpMp's amount base, factor and bits.
$C1:D1F9BattleSys_LoadEffectArg317verifiedDP $16 = byte 3 of the !BattleRom_UnkCC05CC record of !Battle_UnkB18C, all of it (16-bit, high byte 0).
$C1:D20ABattleSys_LoadEffectArgs1223verifiedDP $16 = byte 1 and DP $18 = byte 2 of the !BattleRom_UnkCC05CC record of !Battle_UnkB18C, whole.
$C1:D221BattleSys_Effect0029verifiedEffect type 0: BattleSys_LoadCasterStats, then per target BattleSys_LoadTargetStats, BattleSys_EffRecArgsUnk66, BattleSys_RestoreHpMp, BattleSys_StoreTargetCmd; then !Battle_UnkB200 = 0.
$C1:D23EBattleSys_Effect0141verifiedEffect type 1: as BattleSys_Effect00, but per target BattleSys_EffRecArgs12 and BattleSys_CureStatus, and when bit 6 of effect byte 1 (DP $16) is set also BattleSys_EffRecArgsUnk66 and...
$C1:D267BattleSys_Effect02119verifiedEffect type 2, per target: unless !Battle_UnkAE4D has !Battle_AE4DBit5, a percentage roll: the chance is effect byte 5 + the caster's BattlerStats.Unk66 / effect byte 6 (Battle_Div32, 8-bit sum)...
$C1:D2DEBattleSys_Effect03146verifiedEffect type 3, per target: - unless !Battle_UnkAE4D has !Battle_AE4DBit4: BattleSys_EffRecArg10Unk46 and BattleSys_TestEnemyUnk46; DP $16 non-zero = a miss (BattleSys_EffRecArg11, DP $1C = 1...
$C1:D370BattleSys_Effect041verifiedEffect type 4: does nothing.
$C1:D371BattleSys_Effect0578verifiedEffect type 5: DP $20 = effect byte 1 (not read here nor by BattleSys_DrainHpMp), BattleSys_LoadCasterStats; per target: BattleSys_LoadTargetStats, DP $1E = effect byte 1, !Battle_UnkAD9B = 0...
$C1:D3BFBattleSys_Effect0653verifiedEffect type 6, for the last target only: BattleSys_LoadCasterStats, BattleSys_LoadTargetStats, BattleSys_EffRecArgs12, BattleSys_StealItem; DP $16 = $FE after it = a miss (BattleSys_EffRecArg11...
$C1:D3F4BattleSys_Effect0761verifiedEffect type 7: BattleSys_Effect00, then the caster's BattlerStats.CurHp goes into !Battle_UnkAD89 and is recorded as a hit on the caster (Battle_RecordHit, Y = !Battle_UnkB18B, !Battle_UnkB202 =...
$C1:D431BattleSys_Effect0894verifiedEffect type 8: BattleSys_Effect03 run effect byte 1 times (!Battle_UnkB2D0 counts down; 0 would mean 256), each time with !Battle_UnkAD8D put back to the count it came with (!Battle_UnkB2ED) and...
$C1:D48FBattleSys_EffectNone1verifiedEffect types $09-$28 of BattleSys_EffectTable: does nothing.
$C1:D490BattleSys_Effect2929verifiedEffect type $29; also an item whose !BattleRom_UnkCC05CC byte 0 has bit 7 (BattleSys_UnkBF46).
$C1:D4ADBattleSys_Effect2A41verifiedEffect type $2A; also an item whose !BattleRom_UnkCC05CC byte 0 has bit 2 (and not bit 7).
$C1:D4D6BattleSys_Effect2B29verifiedEffect type $2B; also an item whose !BattleRom_UnkCC05CC byte 0 has bit 6 (and not bits 7 or 2).
$C1:D4F3BattleSys_Effect2C21verifiedEffect type $2C: clears bit 6 (!Battle_StatusBit6) of the BattlerStats.Status of the last target only (BattleSys_LoadTargetStats), and !Battle_UnkB200 = 0.
$C1:D508BattleSys_StoreTargetCmd27verifiedCopies the four bytes !Battle_UnkB18E-!Battle_UnkB191 (the action's command bytes, see !Battle_UnkB18E) into the !Battle_UnkB192 record of the current target, !Battle_UnkAD8E[!Battle_UnkAD8D - 1].
$C1:D523BattleSys_RunTechParts556verifiedRuns the parts of tech !Battle_UnkB18C (on the attack path the !BattleRom_PcAttackNum number) for its users.
$C1:D74FBattleSys_CheckTechMp117verifiedWhether every user of tech !Battle_UnkB18C (!Battle_TechUsers, as loaded) can take part: for each of users 0-2 (!Battle_UnkB2D0 the index; a $FF id is skipped and the loop goes on), the user's...
$C1:D7C4BattleSys_UnkD7C4269verifiedAn enemy's action for action code 2 (BattleAi_EnemyTurn): the enemy counterpart of BattleSys_RunTechParts with one part.
$C1:D8D1BattleSys_UnkD8D1262verifiedAn enemy's action for the action codes other than 2: BattleSys_UnkD7C4 with the records at !BattleRom_UnkCC88CB (the ones BattleFD_LoadUnkB18E2 reads) and the effect records at...
$C1:D9D7BattleSys_EffectTable90verifiedThe effect routines by effect type (byte 0 of the effect record in !Battle_UnkAEE6), called with JSR (BattleSys_EffectTable,X) by BattleSys_RunTechParts ($C1:D704), BattleSys_UnkD7C4 ($C1:D893)...
$C1:DA31BattleSys_TechMpCostTable6verifiedThe MP cost routine of each user (0-2) of a tech, called by BattleSys_CheckTechMp with JSR (BattleSys_TechMpCostTable,X) at $C1:D783.
$C1:DA37BattleSys_RestoreHpMp295verifiedRestores the current target's HP and/or MP, by the bits of DP $1A: - bit 7 (!Battle_RestoreHpBit), HP: the amount is DP $16 * DP $18 (Battle_Mul16), plus a random 0 ..
$C1:DB5EBattleSys_CureStatus76verifiedClears the current target's statuses: .Status keeps only bits 7-6 (bit 7, KO, is cleared first when DP $16 has bit 7, !Battle_CureKoBit), .Status2 is cleared (with an AND #0), and .Unk4C keeps...
$C1:DBAABattleSys_SetStatus186verifiedSets the status bits DP $18 in status byte DP $16 of the current target (BattlerStats.Status + DP $16): - DP $16 = $FF (!Battle_StatusIdxNone): nothing; DP $16 stays $FF.
$C1:DC64BattleSys_RollHit73verifiedThe hit roll of BattleSys_Effect03: with DP $16 = the caster's stat and DP $18 = the target's (BattleSys_EffRecStatPair, then BattleSys_AdjustHit and BattleSys_AdjustEvade), the chance is DP $16 *...
$C1:DCADBattleSys_ApplyDamage474verifiedApplies BattleSys_Effect03's damage to the current target: - the target's .Status2 bits 1-2 (!Battle_Status2Bits12) are cleared; - !Battle_UnkAD89 = (256 - DP $18) * DP $16 / 256 (DP $16 the...
$C1:DE87BattleSys_TestEnemyUnk4623verifiedBattleSys_Effect03's first test: DP $16 = 1 when the target is an enemy (slot 3 or more) and DP $16 (effect byte 10) has a bit in common with DP $18 (its BattlerStats.Unk46...
$C1:DE9EBattleSys_AdjustHit82verifiedLowers the caster's value for BattleSys_RollHit (DP $16, from BattleSys_EffRecStatPair) by the caster's .Status2: bits 0 or 2 (!Battle_Status2Bits02) make it DP $16 * 5 / 20 + 1, else bit 6...
$C1:DEF0BattleSys_AdjustEvade278verifiedChanges the target's value for BattleSys_RollHit (DP $18, from BattleSys_EffRecStatPair) by its statuses, the first that applies: - .Unk4C+1 | .Unk4C+6 bit 6 (!Battle_List4StatusBit): DP $18 * 5 /...
$C1:E006BattleSys_ArmStatusList239verifiedStarts the turn list that times a status bit BattleSys_SetStatus has just set in byte DP $16 of the target !Battle_UnkB1FD: for the first of these bits in DP $18 the list's !Battle_ListTimers...
$C1:E0F5BattleSys_CalcDamage1,350verifiedBattleSys_Effect03's damage, by the formula kind DP $16 (effect byte 5, BattleSys_EffRecArgs56).
$C1:E63BBattleSys_WakeTarget36verifiedWhen the current target's .Status2 has bit 1 or 2 (!Battle_Status2Bits12), clears them and restarts its turn: its turn-list-12 flags = !Battle_ListPartBit, !Battler_UnkAFAB (the gauge reload) =...
$C1:E65FBattleSys_AdjustDefence271verifiedThe defence BattleSys_ApplyDamage takes off the damage (DP $18, 0-255, out of 256), from DP $18 = effect byte 6 (BattleSys_EffRecArgs56): $3E (!Battle_DefUnk6B) means the target's...
$C1:E76EBattleSys_RollUpTo1A13verifiedDP $1A = a random number from 0 to DP $1A (Battle_RandRange with the high bound DP $1A + 1); X is kept.
$C1:E77BBattleSys_DrainHpMp292verifiedBattleSys_Effect05's drain, probably: DP $1A = 3 (!Battle_Eff05Bit7Arg) works on HP, 7 (!Battle_Eff05Bit6Arg) on MP.
$C1:E89FBattle_HitEntryOffset33verifiedDP $0E = !Battle_UnkAD9B * !Battle_HitSetSize + !Battle_UnkB1FD * 4: the offset of slot !Battle_UnkB1FD's entry in set !Battle_UnkAD9B of the !Battle_ActPcHitAmount records (the callers index...
$C1:E8C0BattleSys_CasterHitOffset34verifiedDP $10 = !Battle_UnkAD9B * !Battle_HitSetSize + !Battle_UnkB18B * 4: the offset of the caster's entry in set !Battle_UnkAD9B of the !Battle_ActPcHitAmount records (Battle_HitEntryOffset's...
$C1:E8E2BattleSys_RecordMiss148verifiedRecords a miss on the current target !Battle_UnkB1FD, probably: its !Battle_ActPcHitAmount entry in set !Battle_UnkAD9B gets amount 0 and kind 5 (!Battle_ActHitKind5, drawn as tiles, not a...
$C1:E976BattleSys_UnkE97645verifiedA percentage roll (0-99, kept in DP $0E) against DP $16 (effect byte 1 as BattleSys_Effect03 passes it): when DP $16 is at least the roll, DP $16 = 1 and BattleSys_SetStatus runs (status byte 1...
$C1:E9A3BattleSys_LoadCasterStats21verified!Battle_UnkB1F4 = the BattlerStats offset of the acting battler !Battle_UnkB18B (slot * $80).
$C1:E9B8BattleSys_LoadTargetStats29verifiedThe current target, !Battle_UnkAD8E[!Battle_UnkAD8D - 1]: its slot goes to !Battle_UnkB1FD and its BattlerStats offset (slot * $80) to !Battle_UnkB1F6.
$C1:E9D5BattleSys_StealItem154verifiedAn item taken from the target enemy, probably (BattleSys_Effect06; BattleSys_Effect03 with !Battle_AE4DBit1).
$C1:EA6FBattleSys_RunUnkB2CCHandlers46verifiedRuns BattleSys_RunUnkB2CCHandler for the part's !Battle_UnkB2CC when it is not 0, then, when !Battle_UnkAE4E (effect byte 8) has bit 7 (!Battle_AE4EBit7), loads the caster's .Unk73 / .Unk74...
$C1:EA9DBattleSys_ClearPcStatuses75verifiedFor PC slots 0-2 (!Battle_UnkB18B = the slot, BattleSys_LoadCasterStats): .Status2 and .Unk4C-.Unk4C+7 = 0, .Status keeps only bit 7 (!Battle_StatusKo), .Unk2F bit 0 (!Battle_StatsUnk2FBit) is...
$C1:EAE8BattleSys_ClearPcKo38verifiedFor PC slots 0-2 (!Battle_UnkB18B = the slot): BattleSys_UnkBC60 (which does nothing), BattleSys_LoadCasterStats, then .Status = 0, so the KO bit BattleSys_ClearPcStatuses kept goes too.
$C1:EB0EBattleSys_CopyEffectBytes7814verified!Battle_UnkAE4D = byte 7 and !Battle_UnkAE4E = byte 8 of the effect record in !Battle_UnkAEE6 (meaning unknown).
$C1:EB1CBattleSys_RunUnkB2CCHandler45verifiedReads record !Battle_UnkB2CC of !BattleRom_UnkCC2A05 (3 bytes): DP $1C = byte 1, DP $1E = byte 2, DP $20 = byte 0, and runs entry byte 0 of BattleSys_HitModTable (JSR (table,X), X = byte 0 * 2, 8...
$C1:EB49BattleSys_ReviveHeal31verifiedNot called (xref finds no call; no table entry is known).
$C1:EB68Battle_SumHitSets144verifiedFolds the enemy entries (slots 3-10) of the !Battle_ActPcHitAmount sets 1 to DP $1A into set 0: for set n from DP $1A down to 1, each entry's amount is added to set n - 1's (16-bit, carry...
$C1:EBF8Battle_RecordHit65verifiedStores !Battle_UnkAD89 as slot Y's amount in !Battle_HitAmount set !Battle_UnkB2C7, and !Battle_UnkB202 as the high byte of its !Battle_HitFlags (the low byte is left alone).
$C1:EC39Battle_ClearCancelledHits70verifiedFor each battler slot whose entry has !Battle_HitCancelBitHi in any of the 3 !Battle_HitAmount sets, zeroes its amount in all three; for an enemy slot also !Battle_UnkAEB2, its !Battle_UnkAEB3...
$C1:EC7FBattle_ApplyHits266verifiedBattle_ClearCancelledHits, then for each battler slot (X = its BattlerStats offset, Y = its entry): - HP, skipped when the entry of set 0 has the MP bit in its flags (the HP amounts of sets 1 and...
$C1:ED89BattleSys_HitModChanceMul48verifiedModifier $00.
$C1:EDB9BattleSys_HitModNone1verifiedModifier $01: does nothing.
$C1:EDBABattleSys_HitModScale32verifiedModifier $02: !Battle_UnkAD89 = !Battle_UnkAD89 x DP $1C / DP $1E (Battle_Mul16, then Battle_Div32 of the 32-bit product; the low 16 bits of the quotient are kept).
$C1:EDDABattleSys_HitModUnk47Scale35verifiedModifier $03: when the target's BattlerStats.Unk47 has any of the bits DP $1C, !Battle_UnkAD89 = !Battle_UnkAD89 x DP $1E / 2 (16-bit product, halved).
$C1:EDFDBattleSys_HitModPerEmptyPc42verifiedModifier $04: !Battle_UnkAD89 x (1 + the number of PC slots 0-2 whose !Battler_UnkAEFF is $FF, no PC there).
$C1:EE27BattleSys_HitModPlayTime120verifiedModifier $05: a factor picked by the play-time clock.
$C1:EE9FBattleSys_HitModRandomStatus49verifiedModifier $06: sets one of four .Status2 bits on the target, picked by a roll from 0 to 100 (BattleSys_RollUpTo1A with 100): below 40 bit 2 ($04), 40-64 bit 7 ($80), 65-89 bit 1 ($02), 90-99 bit 6...
$C1:EED0BattleSys_HitModUnk47Status39verifiedModifier $07: on a roll <= 80, and when the target's BattlerStats.Unk47 has any of the bits DP $1C, sets the .Status2 bits DP $1E (BattleSys_SetStatus, DP $16 = 1).
$C1:EEF7BattleSys_HitModChanceStatus29verifiedModifier $08: on a roll <= DP $1C, sets the .Status2 bits DP $1E on the target (BattleSys_SetStatus, DP $16 = 1).
$C1:EF14BattleSys_HitModLeaveOneHp37verifiedModifier $09: on a roll <= DP $1C, !Battle_UnkAD89 = the target's .CurHp - 1 (so the hit leaves it 1 HP) and !Battle_UnkB1FC bit 0 (!Battle_B1FCBit0) is set, so BattleSys_ApplyDamage skips its x 7...
$C1:EF39BattleSys_HitModUnk6CScale131verifiedModifier $0A: the first of bits 7, 6, 5, 4 set in !Battle_UnkB190 (byte 1 of the action's !Battle_UnkB18C record) picks n = 0-3 (!Battle_Unk6CIndex); with none of them, nothing happens.
$C1:EFBCBattleSys_HitModScaleThenUnk6C7verifiedModifier $0B: BattleSys_HitModScale (x DP $1C / DP $1E), then BattleSys_HitModUnk6CScale.
$C1:EFC3BattleSys_HitModRollDp1A16verifiedModifier $0C: DP $1A = 1 when a roll is below DP $1C (strictly, unlike the others), else 0.
$C1:EFD3BattleSys_AddBattleItem99verifiedAdds one of item DP $06 to the battle's item list (Item_BattleList): when an entry holds the id, its .Quantity + 1 (capped at 99).
$C1:F036BattleSys_HitModRestore95verifiedModifier $0D, by the bits of DP $1C: - bit 7: a full HP restore of the target, probably: !Battle_UnkAD89 = its .MaxHp, recorded by Battle_RecordHit for slot !Battle_UnkB1FD with !Battle_UnkB202 =...
$C1:F095BattleSys_HitModHalveHp40verifiedModifier $0E: unless the target's BattlerStats.Unk46 has bit 7 (!Battle_Unk46Bit7: probably a resistance to this kind of attack), on a roll <= DP $1C !Battle_UnkAD89 = the target's .CurHp / 2.
$C1:F0BDBattleSys_HitModClearBits28verifiedModifier $0F: clears the bits DP $1E in the target's byte at BattlerStats.Unk2D + DP $1C.
$C1:F0D9BattleSys_HitModHpDigit52verifiedModifier $10: !Battle_UnkAD89 = !Battle_UnkAD89 x (the caster's .CurHp mod 10, its last decimal digit) / DP $1E.
$C1:F10DBattleSys_HitModZeroHp37verifiedModifier $11: sets an HP to 0.
$C1:F132BattleSys_HitModKoOrDrop149verifiedModifier $12: unless the target's BattlerStats.Unk46 has bit 7 (!Battle_Unk46Bit7), on a roll <= DP $1C its .CurHp = 0.
$C1:F1C7BattleSys_HitModAltBoost40verifiedModifier $13: only when !Battle_ActUnkAE9B bit 7 (!Battle_ActAltFlag, set by BattleSys_HitModChanceMul) is set: DP $1E = 1 makes !Battle_UnkAD89 9999 (!Battle_HitAmountMax), anything else doubles...
$C1:F1EFBattleSys_HitModSetBits22verifiedModifier $14: sets the bits DP $1E in the target's byte at BattlerStats.Unk2D + DP $1C (the counterpart of BattleSys_HitModClearBits).
$C1:F205BattleSys_AwardTechPoints214verifiedThe tech points and the techs they teach.
$C1:F2DBBattleSys_BuildComboMasks191verified!Battle_ComboPcBit+n = $80 >> the character id of PC slot n (0 for an empty slot, !Battler_UnkAEFF $FF), the three sorted from low to high (three compare-and-swap steps); then !Battle_ComboMasks =...
$C1:F39ABattleSys_SpendTechPoints197verifiedPays the battle's tech points into character !Battle_TpCharId's single techs (the PC whose BattlerStats offset is DP $00): the award !Battle_UnkB2DB is kept in DP $30, then BattleSys_TryNextTech...
$C1:F45FBattleSys_TryNextTech128verifiedDP $3B = the character's first single tech id (!BattleRom_CharTechs); the next tech is DP $3B + its !Battle_TechCount.
$C1:F4DFBattleSys_LearnSingleTech84verifiedThe character learns its next single tech: bit ($80 >> its !Battle_TechCount) is set in its !Battle_TechBits1 byte, the PC's !Battle_UnkB2B3 entry (!Battle_UnkB1F4) gets bit 3 (message 5), the...
$C1:F533BattleSys_LearnComboTechs240verifiedThe double or triple techs of one !BattleRom_ComboTechs record.
$C1:F623BattleSys_LevelUpStep406verifiedOne level step for the block at !Battle_ExpRec: BattleSys_ApplyExpStep; when it raised the level (!Battle_NoLevelUp = 0), BattleSys_GrowHpMp, then the stats from the character's 7-byte...
$C1:F7B9BattleSys_ApplyExpStep184verified!Battle_NoLevelUp = $FF; then, unless the block's .Status has bit 7 (KO'd; BattleSys_AwardExpAndTp never gets there, as a KO'd PC's !Battler_UnkAEFF is $FF): - level 99 or more: !Battle_UnkB28C =...
$C1:F871BattleSys_GrowHpMp151verified.MaxHp of the block at !Battle_ExpRec + the HP gain of the first pair in the character's !BattleRom_HpGrowth row (8 bytes: (top level, gain) pairs) whose top level is at least .Level, capped at...
$C1:F908BattleSys_AddExp54verifiedAdds !Battle_UnkB28C to the 24-bit .Exp of the block at X (carry into the high byte); when the high byte is then $98 or more it is set to $98, and a low word of $9680 or more to $967F (so at most...
$C1:F93EBattleSys_AwardExpAndTp173verifiedThe experience and tech points of a won battle.
$C1:F9EBBattleSys_AwardReserveExp118verifiedExperience for the characters not in the battle: !Battle_UnkB1F4 = 3, !Battle_RosterBits = the low byte of !Menu_Unk29AF (bit 7 = character 0, shifted left per id); for each character id 0-6 whose...
$C1:FA61BattleSys_HitModTable42verifiedThe hit modifiers BattleSys_RunUnkB2CCHandler runs, by byte 0 of a !BattleRom_UnkCC2A05 record (JSR (BattleSys_HitModTable,X) at $C1:EB45); see the banner before BattleSys_HitModChanceMul.
$C1:FA8BBattle_SetupBattle803verifiedBattleSys_Main's first step: builds the battle state before the shuffles.
$C1:FDAEBattle_CalcUnk5617verifiedA / 24 + $44: Battle_SetupBattle's BattlerStats.Unk56 from .Unk3F for a PC whose .Unk2D is 5.
$C1:FDBFBattle_Mul16Long4verifiedJSL form of Battle_Mul16.
$C1:FDC7BattleSys_RunPcAttackLong4verifiedJSL form of BattleSys_RunPcAttack.
$C1:FDCBBattle_RandRangeLong4verifiedJSL form of Battle_RandRange.
$C1:FDCFBattleSys_RefundItemLong4verifiedJSL form of BattleSys_RefundItem.
$CC:E000Battle_InitUploadStep558verifiedOne stage of the battle's opening VRAM uploads, run once per call while !Battle_InitUploadStage is 1-3 (each stage counts it up; 0 and 4 on do nothing).
$CC:E22EBattle_InitUploadObjTiles98verifiedSends the first two 64-byte pieces of !BattleRom_ObjTilePieces (the four pieces bank $C0's Field_UploadUnk0000 sends) to VRAM $0000 and $0100 over DMA channel 7, which it first sets itself to mode...
$CC:E290Battle_InitUploadObjTilesDead84verifiedNever reached (no call or jump to it was found; Battle_InitUploadObjTiles returns just before it): the uploads of pieces 3 and 4 of !BattleRom_ObjTilePieces to VRAM $0060 and $0160 (bank $C0 sends...
$CC:E2E4Battle_InitScene2,723verifiedBattle set-up: the scene ($CC:E2E4–$CC:F06A)
$CC:ED87Battle_InitSceneGfx732verifiedThe fourth step of BattleSys_SceneSetup: sprite and tile set-up, then the VRAM uploads.
$CC:F063Battle_ReencodeText8verifiedRe-encodes the text in !BattleMsg_TextTiles into its two tile rows: BankC1_LongDispatch entry 0 (BattleMsg_ReencodeTextBuffer) through the bank-$C1 vector, with A = 0.
$CC:F06BBattleAct_ResetState151verifiedAction helpers ($CC:F06B–$CC:F364)
$CC:F102BattleAct_ResetFxApplied14verifiedSets !Battler_FxApplied of all 11 battler slots to !Battle_FxAppliedStale ($55, a value no effect has), so the next effect picked is applied again.
$CC:F110Battle_BuildOccupiedCellMap70verifiedCopies !Battle_CellMap to !Battle_PathMap (MVN, 256 B) and marks with !Battle_CellBlocked ($40) the cell under each present battler ((y & $F0) | x / 16).
$CC:F156BattleAct_BuildBattlerList145verifiedBuilds the action's battler lists from the action block: !Battle_ActBattlers = caster, !Battle_ActUnkAE97, !Battle_ActUnkAE98 (for a PC caster a negative one becomes one of the other two PCs...
$CC:F1E7BattleAct_StepPalettes145verifiedSteps the four palette sequences: for each one on, counts its timer down; at 0 reloads it from the delay, moves the step on (back to the first entry past the last) and copies the entry's colour...
$CC:F278BattleAct_TickUnkA1A849verifiedFor the 8 object threads: counts down !Battle_ActObjAnimTimer of each whose !Battle_ActUnkA1A8 is set; then runs BattleAct_StepObjAnim for each set one whose timer is 0.
$CC:F2A9BattleAct_StepObjAnim188verifiedMoves object thread DP $80 to the next record of its object list: the record (4 B in bank $CE, BattleRom_ActObjRec) is entry !Battle_ActObjAnimEntry + 1 of the facing's block (facing *...
$CC:F365Battle_Mul8CC30verifiedA byte-identical copy of Battle_Mul8 ($C1:0089): 8×8→16 hardware multiply through WRMPYA/WRMPYB/RDMPYL.
$CD:0000BattleSys_VecCD00003verifiedThe bank's entry block: 19 three-byte JMPs, all but two ($000F and $001E, see the Callers note) reached by JSL from other banks (their targets end in RTL).
$CD:0003BattleSys_VecCD00033verified
$CD:0006BattleSys_VecCD00063verified
$CD:0009BattleSys_FrameTickVec3verified
$CD:000CBattleSys_VecCD000C3verified
$CD:000FBattleSys_VecCD000F3verified
$CD:0012BattleSys_VecCD00123verified
$CD:0015BattleAnim_LoadGfx4Vec3verified
$CD:0018BattleAnim_UnkVecCD00183verified
$CD:001BBattleAct_UnkVecCD001B3verified
$CD:001EBattleSys_VecCD001E3verified
$CD:0021BattleSys_UnkVecCD00213verified
$CD:0024BattleSys_VecCD00243verified
$CD:002ABattleAnim_LoadGfx2Vec3verified
$CD:0036BattleSys_IdleVecCD00363verified
$CD:0039BattleCD_EnterBattle5verifiedThe bank-$CD step of the battle's start: JSL BattleFx_Init ($D1:F1B0: it sets DB=$7E and DP=0, installs JML $D1:E77C / JML $D1:FE97 (BattleFx_Nmi / BattleFx_Irq) as the NMI and IRQ trampolines at...
$CD:003EBattleCD_ActOp805verifiedAction opcode $80's long call (BattleAct_OpRunVecCD001B, after it copied its operand bytes to !Battle_ActOp80Args): JSL BattleFx_Op80Dispatch ($D1:F67A), then RTL.
$CD:0043BattleCD_EnemyDissolve93verifiedTakes an enemy off the screen, for BattleCF_RemoveMarkedEnemies (A = its battler slot, after that moved it to the special palette).
$CD:00A0BattleCD_EnemyDissolveFx106verified
$CD:010ABattleCD_DissolveStep147verifiedOne step of BattleCD_EnemyDissolve: advances !Battle_DissolvePhase by the !BattleRom_DissolvePhaseStep entry !Battle_DissolvePattern & 7 ($17 for the pattern 7 the dissolve uses: odd, so 64 steps...
$CD:019DBattleCD_MsgTimeTable8verifiedFrames a battle message stays up, by the message-speed setting (BattleCD_GetMsgTime: bits 3-5 of config byte $2991): $20, $40, ..., $E0, then $FF.
$CD:01A5BattleCD_GetMsgTime14verifiedA = BattleCD_MsgTimeTable entry by bits 3-5 of !Menu_Config+1: the frames a message stays up at the configured speed (inferred from the uses: BattleCD_ShowMessage waits that long, the others load...
$CD:01B3BattleCD_ShowMessage87verifiedShows battle message A (string A of !BattleRom_MsgStrings, its arguments at $0200, BattleMsg_InfoArgs / !Battle_MsgArg0) and waits for it: plays the message's sound (BattleFx_MsgSfx entry A...
$CD:020ABattleCD_Wait16Frames11verifiedWaits 16 frames (BattleCD_WaitFrameRefresh 16 times).
$CD:0215BattleCD_ShowMessageTimed32verifiedAs BattleCD_ShowMessage without the sound and without waiting: starts message A of !BattleRom_MsgStrings (BattleCD_StartText, BattleCD_ShowText), loads !Battle_MsgTimer with BattleCD_GetMsgTime...
$CD:0235BattleCD_ClearTextGfxL4verifiedBattleCD_ClearTextGfx as a long call (JSL from BattleFx_Init at $D1:F3FE).
$CD:0239BattleCD_ClearTextGfx37verifiedZeroes the message graphics buffer !Battle_TextGfxBuf ($7E:B400-$B7FF, $400 bytes) by words: eight stores per pass, each covering one $80-byte eighth of it, for X = $80 down to 2.
$CD:025EBattleCD_StartText33verifiedStarts string A of the table the caller put in TextWin_StrTable: TextWin_StrIndex = A, !Battle_MsgTiming = 0, !Battle_TextUnkA1 = 0, TextWin_GfxBuf = !Battle_TextGfxBuf (bank $7E), TextWin_Mode =...
$CD:027FBattleCD_ShowText22verifiedDraws the started string: TextWin_StepCount = A (the callers pass !BattleCD_TextStepCount from BattleCD_StartText), one TextWin_Step (through BankC2_Entry0009), two BattleCD_WaitFrame, then...
$CD:0295BattleCD_ShowScriptMessage54verifiedAn enemy script's message (the run handlers pass a script byte in A: most pass !Battle_UnkB3C7; BattleAi_RunTech, BattleAi_RunSetFlags and BattleAi_RunMessage pass one read straight from the...
$CD:02CBBattleCD_ShowEnemyInfo13verifiedThe battle menu's info panel for the highlighted enemy target (BattleMenu_UpdateCursorOverlay; BattleMenu_ChooseAttack also calls BattleCD_ShowTargetInfo): A = a key, the target slot...
$CD:02D8BattleCD_ShowTargetInfo56verified
$CD:0310BattleCD_ShowTechInfo48verifiedThe info panel for the tech (or item) under the menu cursor: A = the key, string A of !BattleRom_TechInfoStrings.
$CD:0340BattleCD_PadRepeat89verifiedTurns the held buttons into presses with auto-repeat, once a frame (BattleCD_NmiMain runs it on both its paths, after BankC2_Entry8002 read the pad), all 16-bit: !Battle_PadPrev = the last frame's...
$CD:0399BattleCD_SetNmiMode15verified!Battle_NmiMode = 1: from the next NMI, BattleCD_NmiDispatch runs BattleCD_NmiMain instead of BattleCD_NmiSetup (service 0's first bank-$CD step).
$CD:039EBattleCD_ApuCmd8122verifiedSends APU command !Audio_CmdUnk81 with arguments !BattleCD_Cmd81Arg1 and 0 (Audio_ProcessEntry; the field's AudioFadeDispatch sends the same command with other arguments around its music changes...
$CD:03B4BattleCD_ExitBattle150verifiedThe bank-$CD part of the battle's end (BattleCF_ExitBattle runs it just before it returns to the field).
$CD:044ABattleCD_WaitNmiAck9verifiedDP $47 = 1, then waits until something else sets it back to 0 (at both call sites the NMI handler is BattleFx_NmiAlt, which BattleCD_ExitBattle installs just before and which zeroes DP $47).
$CD:0453BattleCD_EndLayerFx83verifiedEnds a layer effect (BattleCD_FrameTick runs it when the effect is done, !Battle_BgFxEnded set, and no action runs; BattleCD_ExitBattle when one is still loaded): puts layer 3's tiles back (the...
$CD:04A6BattleCD_IdleTick4verifiedBattleSys_PumpFrames' long call while it waits for the frame: BattleCD_PauseWait, RTL.
$CD:04AABattleCD_FrameTick53verifiedThe bank's per-frame work outside the NMI (BattleSys_FrameTickVec, and JSL from this bank's own waits): unless !Battle_Paused, the pending sound (BattleCD_PlayPendingSfx); BattleCD_PauseWait...
$CD:04DFBattleCD_StepText30verifiedWhen !Battle_TextStepping is set: one TextWin_Step (through BankC2_Entry0009) with TextWin_StepCount = 1; !Battle_TextStepping = TextWin_Status after it (0 once the string is done, so the stepping...
$CD:04FDBattleCD_StartOpenWipe25verifiedService 0's start of the opening wipe: sound !BattleCD_SfxWipe (BattleCD_ApuCmd18, X = !BattleCD_SfxArgCentre), a frame, !Battle_WipeSteps = !BattleCD_WipeSteps and !Battle_WipeMode =...
$CD:0516BattleCD_StartCloseWipe30verifiedThe battle end's closing wipe: !Battle_UnkCE16 = 1, a frame, !BattleFx_CeSetBase = !BattleCD_CA25Unk0C and !BattleFx_CeSetReload + 1, a frame, !Battle_WipeSteps = !BattleCD_WipeSteps...
$CD:0534BattleCD_WipeRunning8verifiedA = 1 while a wipe has steps left (!Battle_WipeSteps non-zero), else 0; Z set iff 0 (BattleSys_SceneSetup and BattleCD_ExitBattle loop on it).
$CD:053CBattleCD_WipeStepOpen59verifiedOne step of the opening wipe in all nine tables: entry 1's line count - 1, entry 2's + 2, entry 3's - 1; then the entry-2 data addresses of tables 5 and 3 (!Battle_HdmaTables+$E8 and +$8E) - 4.
$CD:0577BattleCD_WipeStepClose59verifiedThe opposite step: entry 1's line count + 1, entry 2's - 2, entry 3's + 1 in all nine tables; tables 3 and 5's entry-2 data addresses + 4.
$CD:05B2BattleCD_StepWipe77verifiedOne step of the wipe in progress (BattleCD_NmiMain runs it twice a frame), by !Battle_WipeMode: - 0: nothing; - !BattleCD_WipeOpen ($FF, set by BattleCD_StartOpenWipe): first !BattleFx_CeSetBase =...
$CD:05FFBattleCD_TileUploadVram8verifiedVRAM word addresses for BattleCD_NmiUploadText's tilemap-page upload, by !Battle_TilePageSlot * 2: $7C00, $7C10, $7E00, $7E10.
$CD:0607BattleCD_NmiUploadText171verifiedBattleCD_NmiMain's uploads while no wipe runs: - a tilemap page requested by the layer-effect script (!Battle_TilePageReq, set by BattleCD_RunFxScript): unless it is the same slot...
$CD:06B2BattleCD_ZeroWord2verifiedThe fixed DMA source BattleCD_NmiUploadText clears VRAM from.
$CD:06B4BattleCD_NmiLayerScroll8verifiedRuns the BattleCD_ScrollModeTable entry !Battle_LayerFxMode (0-3; set to 0 or 1 by BattleCD_StepFxChannels and 0 by BattleCD_EndLayerFx; who sets 2 and 3 is not traced): the HDMA scroll data for...
$CD:06BCBattleCD_ScrollModeTable8verifiedBattleCD_NmiLayerScroll's handlers by !Battle_LayerFxMode.
$CD:06C4BattleCD_ScrollPlain66verifiedFills the HDMA scroll data of layers 1-3 (!Battle_HdmaScroll1-3, 32 entries of 4 bytes, an x and a y word, each) with one x/y pair per layer: FieldBtlPpu.Scroll2's words (the battle's layer...
$CD:0706BattleCD_ScrollFill102verified
$CD:076CBattleCD_ScrollFxBg377verifiedAs BattleCD_ScrollPlain, but layer 3's pair is the effect's scroll: !BattleFx_ShakeX + !Battle_FxScrollAddX + !Battle_ShakeOfs3X and !BattleFx_ShakeY + !BattleFx_BounceOut + !Battle_ShakeOfs3Y...
$CD:07B9BattleCD_ScrollWavesBg341verifiedBattleCD_ScrollWaves, then a second run of 32 entries for layer 3 only (X from $80 up to the 8-bit wrap): x = layer 3's x pair, plus the per-line offset in !Battle_WaveOffsets (the same X) when...
$CD:07E2BattleCD_ScrollWaves171verifiedThe pairs as BattleCD_ScrollFxBg3 computes them (in DP $45-$4F); then for each of the 32 entries the x of a layer gets the entry's per-line offset from !Battle_WaveOffsets (bank $7E, by the...
$CD:088DBattleCD_NmiMain321verifiedThe NMI's work in modes 1 and 2 (BattleCD_NmiDispatch), entered with DB=$00: - with !Battle_CgramPending ($7E:CE0F) set: the palette (BattleCD_UploadCgram), DB=$7E, the queued VRAM upload...
$CD:09CEBattleCD_UploadCgram35verifiedCopies the whole palette, !Battle_CgramBytes bytes of !Battle_PaletteLiveLo (bank $7E), to CGRAM from colour 0 by DMA on channel 7 (one register written twice: CGDATA).
$CD:09F1BattleCD_NmiSetup237verifiedThe NMI's work in mode 0 (the first frames, until BattleCD_SetNmiMode1): the palette (BattleCD_UploadCgram); HDMA channels 0-6 set up as indirect channels on the first seven tables of...
$CD:0ADEBattleCD_TickCDC916verifiedWhile FieldAnimB[0].Unk4 (palette animation record 0's frame counter) is 0: !BattleFx_GradStart counts down and wraps from below 0 to !BattleCD_CDC9Period (a 14-frame cycle, 13 down to 0...
$CD:0AEEBattleCD_SetWh0Table40verifiedPoints HDMA channel 7 at one of the last two tables of !Battle_HdmaTables (indirect, 4 registers from WH0, line data in bank $7E): table 8 on odd frames of !Battle_FrameCount, table 7 on even ones...
$CD:0B16BattleCD_RandByte8verifiedA = RandomTable entry (A + !Battle_FrameCount + C) & $FF: a byte of the field's random table picked by the frame count.
$CD:0B1EBattleCD_ClampPalAnims51verifiedWith !Battle_Unk99D2 positive and non-zero: for each of the palette animation records 8-11 (FieldAnimB, 12 bytes each, the ones the battle fills) with a kind (.Unk0 non-zero) and a first colour...
$CD:0B51BattleCD_StepShake306verifiedThe screen shake, once a frame, for two axes: - x (!Battle_ShakeXOn): every !Battle_ShakeXRandPeriod frames a new random byte (BattleCD_RandByte) in !Battle_ShakeXRand; every...
$CD:0C83BattleCD_NmiTable6verifiedBattleCD_NmiDispatch's handler by !Battle_NmiMode.
$CD:0C89BattleCD_ScrollStepL12verifiedThe field's ScrollStepAccum (through ReentryVectors vector [1]: the drift of layers 2 and 3 in FieldBtlPpu.Scroll2) between PHB/PHD/PHP and PLP/PLD/PLB, then A = D (TDC) and RTL.
$CD:0C95BattleCD_NmiDispatch8verifiedThe NMI's bank-$CD work: runs BattleCD_NmiTable entry !Battle_NmiMode (0 BattleCD_NmiSetup, 1 and 2 BattleCD_NmiMain), then RTL.
$CD:0C9DBattleCD_InitHdmaDataL4verifiedBattleCD_InitHdmaData as a long call (JSL from BattleFx_Init at $D1:F1DB).
$CD:0CA1BattleCD_InitHdmaData85verifiedSets the HDMA line data from the screen the field left (FieldBtlPpu): the tilemap bytes of channel 0 (!Battle_HdmaTilemaps: BG1SC, BG2SC, BG4SC from .Tilemap1, .Tilemap2, .Unk59; BG2SC's bit 0...
$CD:0CF6BattleCD_RestoreScreen50verified
$CD:0D28BattleCD_StartLayerFx11verifiedAction set-up's call (BattleAct_LoadCommon, A = !Battle_ActUnkArg987C): !Battle_Unk5D9B = 0, loads layer effect A (BattleCD_LoadLayerFx) and starts its channels (BattleCD_StartFxChannels); RTL.
$CD:0D33BattleCD_StartFxChannels47verifiedClears the three 32-byte channel blocks from !Battle_FxChannels ($CA32-$CA91, by words), then starts channel 0 (X = 0) with script !Battle_FxScriptIds+0 and channel 1 (X = $10) with +1, each...
$CD:0D62BattleCD_RunEndFx49verifiedThe battle end's effect X (BattleCD_LayerFx84 / BattleCD_LayerFx87): APU command !BattleCD_ApuCmd80 (arguments 0, $FF), a frame, then !Audio_CmdPlayMusic with !BattleCD_EndSong (bank $C7 loads...
$CD:0D93BattleCD_LayerFx8730verifiedOne of the battle end's effects (BattleCD_ExitBattle): !Battle_Unk99D2 = 0, BattleCD_ApuCmd81, frames until APUIO1 reads 0, effect !BattleCD_FxEnd87 (BattleCD_RunEndFx), then frames until...
$CD:0DB1BattleCD_LayerFx8473verifiedThe other end effect: BattleCD_ApuCmd81, frames until APUIO1 reads 0, !BattleFx_GradTickMask = 3, !BattleFx_GradForce = $80; the wait below once; 128 more frames; effect !BattleCD_FxEnd84...
$CD:0DFABattleCD_WaitLayerFxIdle11verifiedWaits (BattleCD_WaitFrameRefresh) while !Battle_Unk5D9B is set.
$CD:0E05BattleCD_RunLayerFx30verifiedRuns layer effect A to its end: waits for the one before (BattleCD_WaitLayerFxIdle), loads A (BattleCD_LoadLayerFx), starts its channels, !Battle_Unk5D9B + 1, then frames...
$CD:0E23BattleCD_RestorePalRows18verifiedCopies the 16 bytes at !Battle_PalRowSave (colours 24-31, saved by BattleFx_Init) back to bytes $30-$3F of both !Battle_PaletteSavedLo and !Battle_PaletteLiveLo.
$CD:0E35BattleCD_FxRecSetup44verifiedShared start of BattleCD_LoadFxPalA/B: the palette rows back (BattleCD_RestorePalRows); DP $55 = 1 when FieldBtlPpu.ColorMath bit 6 (!BattleCD_CgadsubHalf, half colour math, if it is a CGADSUB...
$CD:0E61BattleCD_LoadFxPalA24verifiedUnless the half-colour-math flag of BattleCD_FxRecSetup (DP $55) is set: copies 8 bytes of !BattleRom_FxRecA (from the setup's offset X) to !Battle_PalAnimRec10+1, !Battle_PalAnimRec10 = DP $53...
$CD:0E79BattleCD_LoadFxPalB36verified
$CD:0E9DBattleCD_LayerFxSetsScreen32verifiedC=0 and A = 0 when the current layer effect (!Battle_LayerFxId) is !BattleCD_FxPlain86 or !BattleCD_FxPlainFirst-!BattleCD_FxPlainLast ($7B-$7F); else C=1 with A = the id.
$CD:0EBDBattleCD_LoadLayerFx327verifiedLoads layer effect X (0-$FF; X = !BattleCD_FxByBattle stays when !Battle_UnkA018 is 7, else becomes +1 when !Battle_UnkA017 is 7, else +2: a variant by the battle, probably): - !Battle_LayerFxId =...
$CD:1004BattleCD_LoadLayerFx_colours78verified
$CD:1052BattleCD_FillFxTilemaps43verifiedFills the effect's tilemap pages !Battle_FxTilemaps ($7E:D000-$FFFF) with the entry !BattleCD_FxBlankEntry (tile $EE, attribute 0), by words: .fill (JSR'd with X = 0 and $1000, run with X = $2000)...
$CD:107DBattleCD_BuildFxTilemap315verifiedBuilds the effect's tilemap pages into !Battle_FxTilemaps, one page of $200 bytes per block, !Battle_FxRecord's low 6 bits of blocks (the count byte is cut to them), from map !Battle_FxRecMap on...
$CD:11B8BattleCD_LoadFxRecord44verifiedCopies the 6-byte !BattleRom_FxRecords entry X & $7FFF to !Battle_FxRecord ($C9FC-$CA01: the block count byte, the tile set, the first map word, !Battle_FxRecUnkCA00 and the rows per block), using...
$CD:11E4BattleCD_LoadFxTiles53verifiedBuilds one set of 64 2bpp tiles (16 bytes each, $400 bytes) in !Battle_ActFrameBuf ($7E:2D00, from Y = 0): the set's 64 entry words are at $CF:8000 + X * 64 (DP $53-$55); each names a source tile...
$CD:1219BattleCD_TileHandlers28verifiedBattleCD_LoadFxTiles' tile copiers by the entry's flip bits (bit 14 = 2, bit 15 = 4).
$CD:1221BattleCD_TileVHFlip28verifiedA 2bpp tile flipped both ways: BattleCD_TileVFlip2 at Y, then the horizontal flip of BattleCD_TileHFlip2 (JMP BattleCD_TileReverse2) at the same Y.
$CD:1229BattleCD_TileVFlip276verifiedA 2bpp tile flipped vertically: BattleCD_TileCopy2, then the eight row words swapped end for end (row 0 with 7, 1 with 6, ...), using DP $69.
$CD:1275BattleCD_TileHFlip25verifiedA 2bpp tile flipped horizontally: BattleCD_TileCopy2, then its 16 bytes at Y through BitReverseTable (each byte's bits reversed: the row mirrored), 4 a pass with the count in DP $61.
$CD:127ABattleCD_TileReverse262verified
$CD:12B8BattleCD_TileCopy272verifiedCopies the entry's 2bpp tile: 16 bytes from $CF:0000 + (entry AND $1FFF) * 8 (!BattleRom_FxTileGfx) to !Battle_ActFrameBuf + Y, a word at a time (in the order 0, 8, 2, $A, ...), then Y + 16.
$CD:1300BattleCD_PlaneMasks8verifiedMasks for the upper two bit planes of a 4bpp tile built from a 2bpp one (BattleCD_Tile4Planes): by a 2-bit value, none, plane 2, plane 3, both (the pixels' colour + 0, 4, 8 or 12).
$CD:1308BattleCD_FxGfxVram12verifiedVRAM word addresses of the six graphics parts BattleCD_LoadFxGfx2/4 upload, $400 bytes each: $0C00, $0E00, ..., $1600.
$CD:1314BattleCD_LoadFxGfx215verifiedLoads the action's graphics sets (BattleAct_LoadCommon, A = !Battle_ActGfxSetB): sets A and A+1 as parts 4 and 5.
$CD:1323BattleCD_LoadFxGfx469verified
$CD:1368BattleCD_ConvertFxGfx98verifiedBuilds DP $67 (the callers pass 32) 4bpp tiles of graphics set X in !Battle_ActFrameBuf from Y = 0: the set's entry words are at !BattleRom_FxGfxLists + X * 64 (DP $53-$55, bank $CF); the set's...
$CD:13CABattleCD_PickPlaneBits10verifiedA = 2 * the 2-bit field (DP $5B AND 6) / 2 of the colour byte in DP $5D, through BattleCD_FieldShifts (a JMP into the shift chain BattleCD_ShiftField6, whose RTS returns for it).
$CD:13D4BattleCD_FieldShifts8verifiedBattleCD_PickPlaneBits' entry points into the shift chain: field 0 (bits 0-1, no shift), 1 (bits 2-3), 2 (bits 4-5), 3 (bits 6-7).
$CD:13DCBattleCD_ShiftField62verifiedA = (A >> 6 AND 3) * 2; the entries BattleCD_ShiftField4 ($13DE), BattleCD_ShiftField2 ($13E0) and BattleCD_ShiftField0 ($13E2) shift 4, 2 and 0 bits before the same AND and ASL.
$CD:13DEBattleCD_ShiftField42verified
$CD:13E0BattleCD_ShiftField22verified
$CD:13E2BattleCD_ShiftField04verified
$CD:13E6BattleCD_TileHandlers48verifiedBattleCD_ConvertFxGfx's tile builders by the entry's flip bits (bit 14 = 2, bit 15 = 4).
$CD:13EEBattleCD_Tile4VHFlip8verifiedA 4bpp tile flipped both ways: BattleCD_Tile4VFlip at Y, then the horizontal flip (JMP BattleCD_TileReverse4) at the same Y.
$CD:13F6BattleCD_Tile4VFlip79verifiedA 4bpp tile flipped vertically: BattleCD_Tile4Copy, then the eight row words of planes 0-1 swapped end for end (.rows, JSR'd), and those of planes 2-3 (.rows again, falling in, at Y + 16), using...
$CD:1445BattleCD_Tile4HFlip5verifiedA 4bpp tile flipped horizontally: BattleCD_Tile4Copy, then its 32 bytes through BitReverseTable, 4 a pass (DP $61 counts 8 passes).
$CD:144ABattleCD_TileReverse462verified
$CD:1488BattleCD_Tile4Planes129verifiedOne 4bpp tile from a 2bpp one: for each of the 8 row words w at !BattleRom_FxGfxSrc + X (bank $D0): planes 0-1 = w, and planes 2-3 (16 bytes on) = (w with its bytes swapped OR w) AND the plane...
$CD:1509BattleCD_Tile4Copy204verifiedBuilds the entry's 4bpp tile at Y from !BattleRom_FxGfxSrc + (entry AND $1FFF) * 8 (the entry word is kept in DP $65): - entry bit 13 set: BattleCD_Tile4Planes (a 2bpp source); - clear...
$CD:15D5BattleCD_StartFxChannel52verifiedStarts channel X (0 or $10) on script A: the pointer from !BattleRom_FxScriptPtrs entry A (bank $D1, through DP $53-$55), the period = its first byte AND $0F, the countdown + 1 (from 0: the first...
$CD:1609BattleCD_StepFxChannels75verifiedThe channels' tick (BattleCD_NmiMain, once a frame): nothing while !Battle_BgFxEnded is set or !Battle_Unk5D9B is 0.
$CD:1654BattleCD_RunFxScript82verifiedOne step of channel X's script (see the banner), with the pointer in DP $40-$42: opcodes ($80-$FE) run (BattleCD_RunFxOp) and the pointer moves past their operand byte, until a page byte, $7F or...
$CD:16A6BattleCD_RunFxOp15verifiedRuns script opcode A ($80-$FE): DP $43 = X (the channel), the pointer in DP $40 past the opcode, then BattleCD_FxOpTable entry A - $80 (the 8-bit ASL drops bit 7; the handlers start at $CD:17A9...
$CD:16B5BattleCD_FxOpTable244verifiedThe handler of each script opcode $80-$F9, by (opcode - $80) * 2 (JSR (T,X) in BattleCD_RunFxOp).
$CD:17A9BattleCD_FxOpPokeByte21verifiedOpcode $F9 (value, address word): stores the value at that address in bank $7E.
$CD:17BEBattleCD_FxOpCopyColour33verifiedOpcode $F8 (source, destination): copies colour source to colour destination (0-255) in both !Battle_PaletteSavedLo and !Battle_PaletteLiveLo.
$CD:17DFBattleCD_FxOpSetCE0E6verifiedOpcode $F7 (value): !BattleFx_GradForce = the value.
$CD:17E5BattleCD_FxOpWaitCE1026verifiedOpcode $F6 (n): while !BattleFx_GradRotRaw is 0, branches back n (see the banner); then (and always) !BattleFx_GradRotRaw = 0.
$CD:17FFBattleCD_FxOpSetCD466verifiedOpcode $F5 (value): !BattleFx_UnkCD46 = the value.
$CD:1805BattleCD_FxOpSwayQuad5verifiedOpcode $F4 (quad): JSL BattleFx_SwayQuad, which reads the operand through DP $40: fills that quad of !BattleFx_Quads with a beam from the top of the screen, swaying with the frame count, down to...
$CD:180ABattleCD_FxOpRequestBgSet9verifiedOpcode $F2 (value): asks BattleCD_FrameTick for one JSL BattleFx_LoadBgSet with A = the value (!Battle_UnkCD45 = the value, !BattleFx_BgRequest + 1).
$CD:1813BattleCD_FxOpWaitBgSet23verifiedOpcode $F1 (n): while !BattleFx_BgRequest is set (the call opcode $F2 asked for has not run yet), branches back n (see the banner).
$CD:182ABattleCD_FxOpValueFromVar0F10verifiedOpcode $F0 (n): !Battle_FxValues entry n = variable $0F (!Battle_ActVars).
$CD:1834BattleCD_FxOpCountCD3C23verifiedOpcode $EF (no operand): !Battle_UnkCD3C + 1; when it wraps to 0, the palette animation records 8-11 are stopped (FieldAnimB .Unk0 = 0).
$CD:184BBattleCD_FxOpWaveWindowB5verifiedOpcode $F3 (step): JSL BattleFx_WaveWindowB, which reads the operand through DP $40: !BattleFx_CountA grows by it and window table 0 gets wavy edges (angles from !BattleFx_CountB, which counts up).
$CD:1850BattleCD_FxOpGrowBand5verifiedOpcode $EE (kind): JSL BattleFx_GrowBand, which reads the operand through DP $40: a band around the point in !Battle_ActCalcResult, one step wider per run, into this frame's window table (0 a...
$CD:1855BattleCD_FxOpWaveWindowA5verifiedOpcode $ED (step): JSL BattleFx_WaveWindowA, which reads the operand through DP $40: !BattleFx_CountA grows by it and window table 0 gets wavy edges (angles from the frame count).
$CD:185ABattleCD_FxOpRampWin25verifiedOpcode $EC (one operand byte, which nothing reads): JSL BattleFx_RampWin2 (a ramp of left edges into the second pairs of window table 0, up from line !BattleFx_RampBottom - !BattleFx_CountA...
$CD:185FBattleCD_FxOpWaveWindowBByFrame5verifiedOpcode $EB (step): JSL BattleFx_WaveWindowB_ByFrame (BattleFx_WaveWindowB with the angles from the frame count), which reads the operand through DP $40.
$CD:1864BattleCD_FxOpSetBackdrop16verifiedOpcode $EA (colour word): colour 0 (the backdrop) of both !Battle_PaletteSavedLo and !Battle_PaletteLiveLo = the word.
$CD:1874BattleCD_FxOpGrowBox5verifiedOpcode $E8 (step): JSL BattleFx_GrowBox, which reads the operand through DP $40: !BattleFx_BoxHalfHeight grows by it and this frame's window table gets a box centred on line 106.
$CD:1879BattleCD_FxOpAddBoxInset5verifiedOpcode $E9 (step): JSL BattleFx_AddBoxInset, which adds the operand (read through DP $40) to !BattleFx_BoxInset.
$CD:187EBattleCD_FxOpWaveBg368verifiedOpcode $E7 (n): layer 3's wave scroll.
$CD:18C2BattleCD_FxOpSetHoldAnims6verifiedOpcode $E6 (value): !BattleFx_HoldAnims = the value (non-zero holds the palette animations, BattleFx_HoldAnimsTick; action opcodes $2D/$2E set it too).
$CD:18C8BattleCD_FxOpIncVar7verifiedOpcode $E5 (n): variable n (!Battle_ActVars) + 1.
$CD:18CFBattleCD_FxOpSoundAtCalc16verifiedOpcode $E4 (sound): leaves the sound pending for BattleCD_PlayPendingSfx (BattleCD_FrameTick) with X = the first byte of !Battle_ActCalcResult (an x, probably: the pan).
$CD:18DFBattleCD_FxOpCalcToTriangle40verifiedOpcode $E3 (object 0/1): the object's three screen points (!Battle_FxTriX0-Y2) = the six bytes of !Battle_ActCalcResult entries 0-2 (x, y of each).
$CD:1907BattleCD_FxOpSetCD2E6verifiedOpcode $E2 (value): !Battle_UnkCD2E = the value (non-zero: the NMI skips its BattleCD_WaitScanline).
$CD:190DBattleCD_FxOpSetCD2D6verifiedOpcode $E0 (value): !Battle_UnkCD2D = the value (non-zero: the NMI skips BattleCE_UnkF066).
$CD:1913BattleCD_FxOpRandomShake5verifiedOpcode $DF (base x, base y, mask): JSL BattleFx_RandomShake, which reads the three operand bytes through DP $40 (and moves DP $40 on by 2): the channel's !BattleFx_ShakeX/Y = -(random & mask + base).
$CD:1918BattleCD_FxOpSetCD296verifiedOpcode $DE (value): !Battle_UnkCD29 = the value (the NMI copies it to !Battle_UnkA028 every frame).
$CD:191EBattleCD_FxOpSaveCalcPoints5verifiedOpcode $DD (object): JSL BattleFx_SaveCalcPoints, which reads the operand through DP $40: the object's triangle (!Battle_FxTriX0-Y2) = the six bytes of !Battle_ActCalcResult.
$CD:1923BattleCD_FxOpSound15verifiedOpcode $DC (sound): leaves the sound pending for BattleCD_PlayPendingSfx with X = !BattleCD_SfxArgCentre.
$CD:1932BattleCD_FxOpCopyWin1ToWin25verifiedOpcode $DB (one operand byte, which nothing reads): JSL BattleFx_CopyWin1ToWin2 (the other window table's first pairs into this frame's table's second pairs).
$CD:1937BattleCD_FxOpWedge122verifiedOpcode $DA (unused byte, pair n): fills a triangle (BattleCD_FillTriangle, object 0, DP $20 = 0) from the point P = !Battle_ActCalcResult entry 2n to the two points Q +/- w at right angles to...
$CD:19B1BattleCD_FxOpBeamFromPair17verifiedOpcode $D9 (object, pair n): as opcode $AC (BattleCD_FxOpBeam), but the angle is taken from the points of pair n itself: entries 2n and 2n+1 of !Battle_ActCalcResult clamped to the screen...
$CD:19C2BattleCD_FxOpAddVar35verifiedOpcode $D8 (n, value): variable n (!Battle_ActVars) + value; with n's bit 7 set, variable n AND $7F = 0 instead (the value is skipped).
$CD:19E5BattleCD_FxOpDrift108verifiedOpcode $D7 (b), on the channel's !Battle_FxChanWork bytes: - b bit 7 set: six random values 0-31 (BattleCD_RandByte, each seeded with the one before, the first with b) into work bytes 0-5; - else...
$CD:1A51BattleCD_FxBranchBack221verifiedThe taken branch of the two-operand tests (opcodes $D6 and $D5): branches back by the second operand n (DP $40 - n with DP $40 at the first operand; see the banner).
$CD:1A66BattleCD_FxOpWaitValueIsVar0E20verifiedOpcode $D6 (index, n): while !Battle_FxValues entry index differs from variable $0E, branches back n (BattleCD_FxBranchBack2); else skips both operands.
$CD:1A7ABattleCD_FxOpWaitValueZero17verifiedOpcode $D5 (index, n): while !Battle_FxValues entry index is not 0, branches back n (BattleCD_FxBranchBack2); else skips both operands.
$CD:1A8BBattleCD_FxOpValueSubVar0917verifiedOpcode $D4 (index): !Battle_FxValues entry index - variable $09, not below 0.
$CD:1A9CBattleCD_FxOpValueAddVar0C22verifiedOpcode $D3 (index): !Battle_FxValues entry index + variable $0C, at most variable $0E (the 8-bit sum is compared: a sum past $FF wraps first).
$CD:1AB2BattleCD_FxOpColoursFromVar0A12verifiedOpcode $D2 (one operand byte, not read): both colour sets (!Battle_FxScriptIds+2/+3) = variable $0A, then the colour copy of BattleCD_LoadLayerFx (BattleCD_LoadLayerFx_colours, tail jump): colours...
$CD:1ABEBattleCD_FxOpSwitchHigh13verifiedOpcode $D1 (n, then a list of script addresses): jumps to the address in word (variable n's high nibble) of the list after the operand (DP $40 = that word - 1; see the banner).
$CD:1ACBBattleCD_FxOpSwitchLow22verified
$CD:1AE1BattleCD_FxOpMirrorWin1ToWin25verifiedOpcode $CF (offset): JSL BattleFx_MirrorWin1ToWin2, which reads the operand through DP $40: as opcode $DB, mirrored left to right, for 28 lines of each 28-line block, starting at byte offset the...
$CD:1AE6BattleCD_FxOpStepBounce5verifiedOpcode $CE (one operand byte, which nothing reads): JSL BattleFx_StepBounce, one step of the channel's bounce (set up by opcode $CD): !BattleFx_BounceOut moves.
$CD:1AEBBattleCD_FxOpSetupBounce52verifiedOpcode $CD (d): sets up the channel's bounce for BattleFx_StepBounce (opcode $CE): !BattleFx_BounceDir = 0 (rising), !BattleFx_BounceBase = the channel's !BattleFx_BounceOut, !BattleFx_BounceSpeed...
$CD:1B1FBattleCD_ClampCalcAngle3verifiedClamps the points of !Battle_ActCalcResult entries 0 and 1 to the screen (BattleCD_ClampCalcPair), then falls into BattleCD_CalcAngle ($1B22): DP $23-$26 = the two points at...
$CD:1B22BattleCD_CalcAngle32verified
$CD:1B42BattleCD_ClampX14verifiedA clamped to !BattleCD_ScreenXMin-!BattleCD_ScreenXMax (8-$F8).
$CD:1B50BattleCD_ClampY14verifiedA clamped to !BattleCD_ScreenYMin-!BattleCD_ScreenYMax (8-$D4).
$CD:1B5EBattleCD_FxOpJumpIf99D2Is115verifiedOpcode $CB (address word): with !Battle_Unk99D2 AND $7F = 1, jumps to the address (BattleCD_FxOpJump); else skips it.
$CD:1B6DBattleCD_FxOpJump11verifiedOpcode $CA (address word): jumps to the script address (in the script's bank; DP $40 = the address - 1, see the banner).
$CD:1B78BattleCD_FxOpSwapPalettes34verifiedOpcode $C9 (no operand): !Battle_UnkA101 + 1, and bit 3 of the eleven battlers' !Battler_Palette and of !BattleMenu_CursorPalette flipped (palette number +/- 8).
$CD:1B9ABattleCD_FxOpSwapObjPalettes5verifiedOpcode $E1 (no operand: BattleFx_SwapObjPalettes moves DP $40 back by one): JSL BattleFx_SwapObjPalettes, which swaps OBJ palette rows 1-3 with rows 5-7 (live and saved).
$CD:1B9FBattleCD_FxOpScrollYToEnemy12verifiedOpcode $C8 (one operand byte, not read): the channel's !BattleFx_BounceOut + (!BattleCD_FxEnemyLine - slot 3's !Battler_ScreenY) (DP $45, 16-bit), through BattleCD_FxAddScrollY (tail jump).
$CD:1BABBattleCD_FxOpObjYToEnemy21verifiedOpcode $C7 (object): the object's !Battle_FxObjCentreY - (!BattleCD_FxEnemyLine - slot 3's !Battler_ScreenY).
$CD:1BC0BattleCD_SinMul4514verifiedA = DP $45 * sin(A) / 256 (BattleCD_SinMul with Y = DP $45) for 16-bit-index callers: X and Y are saved at 16 bits around the SEP #$10.
$CD:1BCEBattleCD_FxOpWobble100verifiedOpcode $C6 (object, three phase steps, three angle bases): the object's phases !Battle_FxObjPhaseA/B/C + the steps; then its angles !Battle_FxObjAngleX = base 1 + $20 * sin(phase A) / 256...
$CD:1C32BattleCD_FxOpScrollToCalc2verifiedOpcode $AA (n): layer 3 scrolled so that the point of !Battle_ActCalcResult entry n is its origin: the channel's !BattleFx_ShakeX/Y = -x, -y (16-bit).
$CD:1C34BattleCD_ScrollToCalc39verified
$CD:1C5BBattleCD_FxCircleRadii8verifiedRadius sets of BattleCD_FxCircleFromTable, 4 bytes each: the first circle's x and y radius, the second's x and y radius.
$CD:1C63BattleCD_FxOpCircleAtCalc24verifiedOpcode $C5 (radius set): layer 3 circles around the point of !Battle_ActCalcResult entry 0: the point (BattleCD_ScrollToCalc, A = 0) as the centre (DP $4D/$4E, the scroll negated back), then...
$CD:1C7BBattleCD_FxOpCircleGrow68verifiedOpcode $C4 (k): layer 3 circles around !BattleCD_FxCircleX/Y.
$CD:1CBFBattleCD_FxCircleFromTable22verifiedDP $49-$4C = BattleCD_FxCircleRadii set k (the script's operand), then falls into BattleCD_FxCircleStep ($1CD5): the channel's angles (!Battle_FxChanWork bytes 5, 6, 7) + 2, + 5, + 6; the point x...
$CD:1CD5BattleCD_FxCircleStep120verified
$CD:1D4DBattleCD_FxOpIncVar0F9verifiedOpcode $C3 (no operand): variable $0F + 1.
$CD:1D56BattleCD_FxOpObjStepCapped61verifiedOpcode $C2 (object, limit, three steps): the object's !Battle_FxObjUnkDA/DC/DE each + its step, stored only while the 8-bit sum stays below the limit.
$CD:1D93BattleCD_FxOpWaitLine5verifiedOpcode $C1 (line): busy-waits for that scanline (BattleCD_WaitScanline, tail jump).
$CD:1D98BattleCD_FxOpShake111verifiedOpcode $C0 (flag, then seven bytes): the screen shake (BattleCD_StepShake).
$CD:1E07BattleCD_FxOpWaitPalAnims32verifiedOpcode $BF (n): while any of the palette animation records 8-11 runs (FieldAnimB .Unk0 non-zero), branches back n (see the banner).
$CD:1E27BattleCD_FxOpDrawModel215verifiedOpcode $BE (object): draws model 2 (DP $4F = $20) for the object with its !Battle_FxObjDepth (BattleCD_FxDrawModel, tail jump).
$CD:1E36BattleCD_FxOpSetObjD115verifiedOpcode $BD (b): !Battle_FxObjUnkD1 of object (b AND 1) = b >> 4: the kind of shape slot b AND 1 (BattleCD_FxDrawShape; opcode $8A sets it too).
$CD:1E45BattleCD_FxOpTurnObj55verifiedOpcode $BC (object, four steps): the object's !Battle_FxObjAngleX, !Battle_FxObjAngleY, !Battle_FxObjAngleZ and !Battle_FxObjDepth each + its step.
$CD:1E7CBattleCD_FxOpDrawModel21verifiedOpcode $BB (b): draws model (b AND $0F) (DP $4F = b << 4, 8-bit) for object (b AND 1) with its !Battle_FxObjDepth (BattleCD_FxDrawModel, tail jump).
$CD:1E91BattleCD_FxOpSpinModel25verifiedOpcode $BA (b): turns object b (the whole byte as the index; the scripts presumably pass 0 or 1) a step (!Battle_FxObjAngleY + 1, !Battle_FxObjAngleX + 2, !Battle_FxObjAngleZ + 1) and draws model...
$CD:1EAABattleCD_FxDrawModel77verified
$CD:1EF7BattleCD_FxRotateVertex69verifiedRotates vertex A (0-2) of a model of BattleFx_FxModels (16 bytes per model, DP $4F = its offset; 4 bytes per vertex: x, y, z, unused) by object X's angles: !Battle_FxRotInX/Y = the vertex's x and...
$CD:1F3CBattleCD_FxOpColours11verifiedOpcode $B9 (set): both colour sets (!Battle_FxScriptIds+2/+3) = the operand, then the colour copy of BattleCD_LoadLayerFx (BattleCD_LoadLayerFx_colours, tail jump): colours 25-27 and 29-31 of both...
$CD:1F47BattleCD_FxOpFillHangingTriangle6verifiedOpcode $B8 (object): BattleCD_FillHangingTriangle with A = the object (0 or 1): its right triangle hanging from the top of the screen.
$CD:1F4DBattleCD_FxOpTilePageSlot6verifiedOpcode $B7 (slot): !Battle_TilePageSlot = the slot (which BattleCD_TileUploadVram address the script's tilemap pages go to).
$CD:1F53BattleCD_FxOpWindowBand77verifiedOpcodes $B5 and $B6 (index): a band of !Battle_FxWinLines around the middle line.
$CD:1FA0BattleCD_FxOpCentreAndScroll40verifiedOpcode $B4 (object): the object's centre from its triangle (BattleCD_FxOpTriCentre, same operand), then layer 3 scrolled so that the centre is its origin: the channel's !BattleFx_ShakeX/Y =...
$CD:1FC8BattleCD_FxOpWaveTable131verifiedOpcode $B3 (an operand byte, stored to DP $45 and overwritten: not used): fills the 106 entries of !Battle_FxWaveTable (8 bytes each: an x word and a y word, twice) for this frame.
$CD:204BBattleCD_FxWaveStoreX102verifiedBattleCD_FxOpWaveTable's x: stores A (signed, widened to 16 bits) as entry Y's two x words, then starts |sin(DP $45)| * !BattleCD_FxWaveAmpY on the multiplier for the y and returns C=1 when that...
$CD:20B1BattleCD_FxWaveStoreY34verifiedBattleCD_FxOpWaveTable's y: A + $20, widened to 16 bits as signed, plus DP $49, stored as entry Y's two y words.
$CD:20D3BattleCD_FxOpCopyWindowEdges5verifiedOpcode $B2 (one operand byte, not read here; BattleCE_CopyWindowEdges reads it): JSL BattleCE_CopyWindowEdges, which copies one window's edge pair of lines s/4 to s/4 + 215, with s = the operand x...
$CD:20D8BattleCD_FxOpScaleObj21verifiedOpcode $B1 (object, step): the object's !Battle_FxObjScale + step.
$CD:20EDBattleCD_FxOpBgMode6verifiedOpcode $B0 (value): !Battle_HdmaMode (the BGMODE line data) = the value.
$CD:20F3BattleCD_FxOpTriangleOfPcs40verifiedOpcode $AF (object): the object's triangle (!Battle_FxTriX0-Y2) = the screen positions of PC slots 0, 1 and 2 (!Battler_ScreenX/Y).
$CD:211BBattleCD_ScaleToCentre88verifiedA = c + (A - c) * DP $21 / 256, with c = DP $47 (the centre): moves a coordinate towards the centre by the scale (BattleCD_FxOpFillTriangle).
$CD:2173BattleCD_FxOpFillTriangle77verifiedOpcode $AE (b): fills the triangle of object (b AND 1) (!BattleFx_QuadSlot = it): its three points, each moved towards !Battle_FxObjCentreX/Y by !Battle_FxObjScale (BattleCD_ScaleToCentre), into...
$CD:21C0BattleCD_FxOpTriCentre461verifiedOpcode $AD (object): the object's !Battle_FxObjScale = $FF and its centre !Battle_FxObjCentreX/Y = where two medians of its triangle meet (the centroid): the line from the midpoint of points 0-1...
$CD:238DBattleCD_NormaliseDiv166verifiedPrepares BattleCD_Div16 for a quotient scaled by 256: shifts the dividend DP $23 left by n, its leading zero bits (at most 8), and the divisor DP $25 right by 8 - n.
$CD:2433BattleCD_ClampCalcPair3verifiedClamps the two points at !Battle_ActCalcResult+X (x, y, x, y) to the screen: the x bytes with BattleCD_ClampX (8-$F8), the y bytes with BattleCD_ClampY (8-$D4).
$CD:2436BattleCD_ClampCalcPair0142verified
$CD:2460BattleCD_FxOpBeam6verifiedOpcode $AC (object, pair n): a beam of half-width w (variable $0E, signed) between P = !Battle_ActCalcResult entry 2n and Q = entry 2n+1, at right angles to !Battle_FxAngle (from entries 2 and 3...
$CD:2466BattleCD_FxOpBeamQuad141verified
$CD:24F3BattleCD_FxOpCalcToValues37verifiedOpcode $AB (b): the point of !Battle_ActCalcResult entry (b AND $7F) (entries 0 and 1 clamped to the screen first, BattleCD_ClampCalcPair01) into !Battle_FxValues: x to entry 2 and y to entry 4...
$CD:2518BattleCD_FxOpWaitVarSet35verifiedOpcode $A9 (n, back): while variable n (!Battle_ActVars) is 0, branches back by the second operand (see the banner); else skips both operands.
$CD:253BBattleCD_FxOpWaves293verifiedOpcode $8F (layers, amplitude, speed): the per-line wave offsets (!Battle_WaveOffsets) of the wave scroll.
$CD:2660BattleCD_FxOpSetObjAngles39verifiedOpcode $A7 (object, three angles): the object's !Battle_FxObjAngleX/Y/Z = the angles, !Battle_FxObjDepth = 0, !Battle_FxObjScale = $FF.
$CD:2687BattleCD_FxOpReloadCeSet9verifiedOpcode $87 (value): !BattleFx_CeSetBase = the value and !BattleFx_CeSetReload + 1 (as the message and wipe code bump them), so BattleFx_ReloadCeSet reloads the set.
$CD:2690BattleCD_FxOpSaveObjs32verifiedOpcode $A5 (slot 0-7): copies the two objects' fields (!Battle_FxObjCentreX on, !BattleCD_FxObjBytes bytes) to save slot slot of !Battle_FxObjSaves (offset from BattleCD_FxObjSaveOfs).
$CD:26B0BattleCD_FxObjSaveOfs16verifiedOffset of each save slot in !Battle_FxObjSaves (slot * !BattleCD_FxObjBytes).
$CD:26C0BattleCD_FxOpLoadObjs32verifiedOpcode $A6 (slot 0-7): the two objects' fields back from save slot slot (the reverse of BattleCD_FxOpSaveObjs).
$CD:26E0BattleCD_FxOpSetObjPhases55verifiedOpcode $A4 (object, six values): the object's !Battle_FxObjPhaseA/B/C and !Battle_FxObjUnkDA/DC/DE (the radii of the ring opcodes) = the values.
$CD:2717BattleCD_FxOpStepEllipse119verifiedOpcode $A3 (object, then dx, dy, dr, dsx, dsy, dphase): steps the object's flat ring: !Battle_FxObjCentreX/Y + dx/dy, the three radii !Battle_FxObjUnkDA/DC/DE each + dr, !Battle_FxObjSquashX/Y +...
$CD:278EBattleCD_FxOpSetEllipse60verifiedOpcode $A2 (object, x, y, radius): the object's flat ring: !Battle_FxObjCentreX/Y = x, y; the three radii !Battle_FxObjUnkDA/DC/DE = radius; phases !Battle_FxObjPhaseA/B/C = !BattleCD_FxPhaseA/B/C...
$CD:27CABattleCD_FxOpStepRing3d121verifiedOpcode $A8 (object, then dx, dy, dz, dr, dax, day, daz, dscale): steps the object's turning ring: !Battle_FxObjCentreX/Y and !Battle_FxObjDepth + dx/dy/dz, the three radii !Battle_FxObjUnkDA/DC/DE...
$CD:2843BattleCD_FxRing3dTriangle94verifiedThe object's triangle from its turning ring: for each of the three vertices, radius !Battle_FxObjUnkDA/DC/DE and phase !Battle_FxObjPhaseA/B/C, the point BattleCD_FxRingVertex rotates, plus...
$CD:28A1BattleCD_FxRingVertex49verifiedOne ring vertex of object X at phase A, radius DP $47: !Battle_FxRotInX = sin(phase) / 2 * radius / 256 and !Battle_FxRotInY = the same with cos (BattleCD_HalfSinMul), !Battle_FxRotInZ = the...
$CD:28D2BattleCD_FxEllipseTriangle128verifiedThe object's triangle from its flat ring: for each vertex k (radius !Battle_FxObjUnkDA/DC/DE, phase !Battle_FxObjPhaseA/B/C), y = !Battle_FxObjCentreY + cos(phase) / 2 * radius / 256 * |sin(squash...
$CD:2952BattleCD_FxOpFillObjTriangle6verifiedOpcode $A1 (object): BattleCD_FillObjTriangle with A = the object (0 or 1): its triangle filled as it is, without the scaling of opcode $AE.
$CD:2958BattleCD_FxOpRegToWork9verifiedOpcode $8C (n, 0-3): the channel's !Battle_FxChanReg word to its work word n (!Battle_FxChanWork + 2n), through BattleCD_FxRegToWorkTable (JMP (T,X); a larger n would read the handler code as...
$CD:2961BattleCD_FxRegToWorkTable8verifiedBattleCD_FxOpRegToWork's handler per work word.
$CD:2969BattleCD_FxRegToWork012verifiedWork word 0 (!Battle_FxChanWork) of channel Y = its !Battle_FxChanReg.
$CD:2975BattleCD_FxRegToWork112verifiedWork word 1 (!Battle_FxChanWork+2) of channel Y = its !Battle_FxChanReg.
$CD:2981BattleCD_FxRegToWork212verifiedWork word 2 (!Battle_FxChanWork+4) of channel Y = its !Battle_FxChanReg.
$CD:298DBattleCD_FxRegToWork312verifiedWork word 3 (!Battle_FxChanWork+6) of channel Y = its !Battle_FxChanReg.
$CD:2999BattleCD_FxOpWorkToReg9verifiedOpcode $8D (n, 0-3): the channel's work word n to its !Battle_FxChanReg, through BattleCD_FxWorkToRegTable (JMP (T,X)).
$CD:29A2BattleCD_FxWorkToRegTable8verifiedBattleCD_FxOpWorkToReg's handler per work word.
$CD:29AABattleCD_FxWork0ToReg12verified!Battle_FxChanReg of channel Y = its work word 0 (!Battle_FxChanWork).
$CD:29B6BattleCD_FxWork1ToReg12verified!Battle_FxChanReg of channel Y = its work word 1 (!Battle_FxChanWork+2).
$CD:29C2BattleCD_FxWork2ToReg12verified!Battle_FxChanReg of channel Y = its work word 2 (!Battle_FxChanWork+4).
$CD:29CEBattleCD_FxWork3ToReg12verified!Battle_FxChanReg of channel Y = its work word 3 (!Battle_FxChanWork+6).
$CD:29DABattleCD_FxOpFillWindow9verifiedOpcode $88 (n): JSL BattleFx_FillWindow with A and X = n * 2: this frame's window table all empty (0), first pairs empty (1), second pairs empty (2) or first pairs full (3).
$CD:29E3BattleCD_FxOpPalAnim95verifiedOpcode $8E (seven bytes b0-b6): fills a palette animation record (FieldAnimB, 4-11, picked by b5 AND 7 through BattleCD_FxPalAnimRecs: 0 is record 11, 7 is record 4): .Unk0 = b0 AND $F0 (the...
$CD:2A42BattleCD_FxPalAnimRecs8verifiedOffset from palette animation record 4 (FieldAnimB[4]) of the record BattleCD_FxOpPalAnim fills, by b5 AND 7: records 11 down to 4.
$CD:2A4ABattleCD_FxOpMisc7verifiedOpcode $80 (sub-op): jumps to BattleCD_FxMiscTable entry sub-op.
$CD:2A51BattleCD_FxMiscTable58verifiedThe sub-handlers of script opcode $80, by sub-op * 2.
$CD:2A8BBattleCD_FxMiscIncEnemy9FF712verifiedSub-op $1B: !Battler_Unk9FF7 + 1 for battler slots 3-10 (the eight enemies).
$CD:2A97BattleCD_FxMiscWhitenObjRows5verifiedSub-op $1C: JSL BattleFx_WhitenObjRows5To7 (OBJ palette rows 5-7, saved and live, white).
$CD:2A9CBattleCD_FxMiscWhitenRows5verifiedSub-op $1A: JSL BattleFx_WhitenRows (background palette rows 2-7 and OBJ rows 1-3, saved and live, white).
$CD:2AA1BattleCD_FxMiscIncGradRot4verifiedSub-op $19: !BattleFx_GradRotRaw + 1 (what script opcode $F6 waits for).
$CD:2AA5BattleCD_FxMiscMoveBgRows5verifiedSub-op $18: JSL BattleFx_MoveBgRowsUp (background palette rows 2-4 and their animations moved to rows 5-7).
$CD:2AAABattleCD_FxMiscLoadBgRows5verifiedSub-op $17: JSL BattleFx_LoadBgRows2To4 (background palette rows 2-4 loaded again, their animations moved back).
$CD:2AAFBattleCD_FxMarkRandomDrop23verifiedMarks a random entry of !BattleFx_WaveMoving: the RandomTable byte at !BattleFx_CountB (which counts up) picks the word, which gets + 1.
$CD:2AC6BattleCD_FxMiscDropWaveBase41verifiedSub-op $16: three random entries marked (BattleCD_FxMarkRandomDrop), then every one of the 212 !BattleFx_WaveBaseX words (4 bytes apart: the words BattleFx_WaveWindowA adds its wave to) whose...
$CD:2AEFBattleCD_FxMiscClearWaveBase22verifiedSub-op $15: zeroes !BattleFx_WaveBaseX and the !BattleFx_WaveMoving marks after it ($7E:E500-$EB9F, !BattleCD_FxWaveClearBytes).
$CD:2B05BattleCD_FxMiscResetWave13verifiedSub-op $14: !BattleFx_CountA = !BattleFx_WaveRadius and !BattleFx_CountB = 0 (one word: the wave windows' radius r1 = !BattleFx_WaveRadius - !BattleFx_CountA is then 0), and !Battle_FrameCount =...
$CD:2B12BattleCD_FxMiscClampCalcY21verifiedSub-op $12: the y of !Battle_ActCalcResult entry 0 clamped to !BattleCD_FxCalcYMin-!BattleCD_ScreenYMax.
$CD:2B27BattleCD_FxMiscAnimFrom99D330verifiedSub-op $11: !Battle_Unk99D2 bit 7 set, and palette animation records 10 and 11 (FieldAnimB) set to work on colours !Battle_Unk99D3 up to 127 (.Unk1 = !Battle_Unk99D3, .Unk2 = !BattleCD_BgColours...
$CD:2B45BattleCD_FxMiscBlackBands23verifiedSub-op $10: the value byte of each of the 32 entries of !Battle_FxBandsBlue, !Battle_FxBandsGreen and !Battle_FxBandsRed = !BattleCD_ColDataBlack (all three channels, intensity 0); the line counts...
$CD:2B5CBattleCD_FxMiscClearExitAttr8verifiedSub-op $0F: !Battler_ActAttr of the battler in !Battle_ExitFxSlot (the enemy BattleCD_EnemyDissolve takes off) = 0.
$CD:2B64BattleCD_FxMiscAddLineOffsets5verifiedSub-op $0D: JSL BattleFx_AddLineOffsets (the bytes at $7E:0A00, from sub-op $0C for one, added to lines 48-175 of this frame's window table), with C = 0 for its first ADC (the dispatcher's ASL).
$CD:2B69BattleCD_FxMiscSineOffsets63verifiedSub-op $0C: fills the 256 bytes of !Battle_WaveOffsets ($7E:0A00) with a sine of amplitude !BattleCD_FxSineAmp: byte n = !BattleRom_AbsSine entry (4n AND $FF) x 12 / 256, negated for entries...
$CD:2BA8BattleCD_FxMiscBobSub42verifiedSub-op $0B: the channel's !BattleFx_BounceOut - the signed byte !BattleRom_FxBobSteps entry !Battle_FxBobStep (the channel's), which then counts up (wrapping after 256 runs).
$CD:2BD2BattleCD_FxMiscBobAdd42verifiedSub-op $0A: as sub-op $0B (BattleCD_FxMiscBobSub), but the step is added to the channel's !BattleFx_BounceOut.
$CD:2BFCBattleCD_FxMiscSprites131verifiedSub-op $09: puts 16 sprites from !Battle_FxSprTemplate into OAM entries 4-19 of the shadow (!Oam_LowTable), after moving entries 4-111 down to 20-127 (MVP, low table and high-table bytes; the...
$CD:2C7FBattleCD_FxMiscClearPhases12verifiedSub-op $08: !Battle_FxObjPhaseA, PhaseB and PhaseC of both objects = 0 (one word each).
$CD:2C8BBattleCD_FxMiscNarrowTri13verifiedSub-op $07: object 0's triangle: first point's y + 2, second point's y - 2 (the side between them shrinks by 4).
$CD:2C98BattleCD_FxMiscSetTri27verifiedSub-op $06: object 0's triangle = (0, 1), (0, !BattleCD_FxTriLowY), (!BattleCD_FxTriTipX, !BattleCD_FxTriTipY): a wedge from the left edge of the screen.
$CD:2CB3BattleCD_FxMiscRotateTri41verifiedSub-op $05: object 0's points move round one place: the first point to the second, the second to the third, the third to the first.
$CD:2CDCBattleCD_FxMiscClearWaveTable25verifiedSub-op $04: zeroes !BattleFx_WinTableBytes bytes from !Battle_FxWaveTable ($7E:C15D-$C4DC, which window table 0 overlaps from $C161) and !Battle_WavePhase.
$CD:2CF5BattleCD_FxMiscCentreLine23verifiedSub-op $02: object 0's triangle = (!BattleCD_FxScreenMidX, 0) and twice (!BattleCD_FxScreenMidX, !BattleCD_ScreenYMax): a vertical line down the middle (sub-op $03 then widens its base).
$CD:2D0CBattleCD_FxMiscWidenTri19verifiedSub-op $03: object 0's triangle: second point's x + 2, third point's x - 2 (no carry or limit).
$CD:2D1FBattleCD_FxMiscRotateBands26verifiedSub-op $01: the value bytes of the 96 band entries (!Battle_FxBandsBlue, Green and Red one after the other, 4 bytes apart) move one entry back, the first going to the last.
$CD:2D39BattleCD_FxMiscTallBands11verifiedSub-op $13: !Battle_Unk5D9A = 1 and the colour bands built with !BattleCD_FxBandLinesTall lines each.
$CD:2D44BattleCD_FxMiscBandsStep6verified
$CD:2D4ABattleCD_FxMiscBands129verified
$CD:2DCBBattleCD_FxOpSetPeriod11verifiedOpcode $81 (n): the channel's period and countdown (its block's bytes +6 and +7, see BattleCD_StartFxChannel) = n: the script then steps every n frames, the next step n frames on.
$CD:2DD6BattleCD_FxOpScrollStep20verifiedOpcode $82 (b): moves the channel's layer-3 scroll additions by d = (b AND $1F) + 1 in the direction b / 32 (0-7), through BattleCD_FxScrollDirTable (JMP (T,X)); "X" is the channel's...
$CD:2DEABattleCD_FxScrollDirTable16verifiedBattleCD_FxOpScrollStep's helpers, by direction (b / 32) * 2.
$CD:2DFABattleCD_FxScrollAddYSubX25verifiedThe channel's !BattleFx_BounceOut + the word at DP $45 and its !Battle_FxScrollAddX - it (direction 7 of script opcode $82).
$CD:2E13BattleCD_FxAddScrollY16verifiedThe channel's !BattleFx_BounceOut + the word at DP $45 (direction 6 of script opcode $82; also called by script opcodes $C8 and $D7).
$CD:2E23BattleCD_FxScrollAddYAddX25verifiedThe channel's !BattleFx_BounceOut and its !Battle_FxScrollAddX + the word at DP $45 (direction 5 of script opcode $82).
$CD:2E3CBattleCD_FxSubScrollX17verifiedThe channel's !Battle_FxScrollAddX - the word at DP $45 (direction 4 of script opcode $82; also script opcode $D7's tail jump).
$CD:2E4DBattleCD_FxAddScrollX17verifiedThe channel's !Battle_FxScrollAddX + the word at DP $45 (direction 3 of script opcode $82; also script opcode $D7's tail jump).
$CD:2E5EBattleCD_FxScrollSubYSubX26verifiedThe channel's !BattleFx_BounceOut and its !Battle_FxScrollAddX - the word at DP $45 (direction 2 of script opcode $82).
$CD:2E78BattleCD_FxSubScrollY17verifiedThe channel's !BattleFx_BounceOut - the word at DP $45 (direction 1 of script opcode $82; also called by script opcode $D7).
$CD:2E89BattleCD_FxScrollSubYAddX25verifiedThe channel's !Battle_FxScrollAddX + the word at DP $45 and its !BattleFx_BounceOut - it (direction 0 of script opcode $82).
$CD:2EA2BattleCD_FxOpLoopStart19verifiedOpcode $83 (n): starts a loop of the channel: its !Battle_FxLoopCount = n + 1 and !Battle_FxLoopPtr = DP $40 (this operand), so that opcode $84 runs the bytes after the operand n + 1 times (n =...
$CD:2EB5BattleCD_FxOpLoopEnd19verifiedOpcode $84 (no operand): the channel's !Battle_FxLoopCount - 1; while it is not 0, DP $40 = !Battle_FxLoopPtr (the next byte read is the loop's first); at 0 the script goes on (DP $40 - 1).
$CD:2EC8BattleCD_FxOpPageLoopStart22verifiedOpcode $85 (n): as opcode $83 (BattleCD_FxOpLoopStart), and the channel's tile page base (its block's byte +8, added to the script's page bytes) = 0.
$CD:2EDEBattleCD_FxOpPageLoopEnd25verifiedOpcode $86 (no operand): as opcode $84 (BattleCD_FxOpLoopEnd), and the channel's tile page base + 1 each time round, 0 when the loop ends: the loop's page bytes show the next pages each time.
$CD:2EF7BattleCD_FxOpMosaic87verifiedOpcode $90 (b): the MOSAIC byte of channel 6's line data (!Battle_HdmaMode+1, MOSAIC probably): its layer bits (0-3) = b's high nibble, its size (bits 4-7) the old size + (b AND $0F), at most...
$CD:2F4EBattleCD_FxOpCall19verifiedOpcode $91 (address word): a call in the script's bank: the channel's !Battle_FxReturnPtr = DP $40 + 1 (the operand's last byte), DP $40 = the address - 1 (the next byte read is at the address).
$CD:2F61BattleCD_FxOpReturn13verifiedOpcode $92 (no operand): DP $40 = the channel's !Battle_FxReturnPtr: the script goes on after the last opcode $91.
$CD:2F6EBattleCD_FxOpColourMath29verifiedOpcode $93 (TS, CGWSEL, CGADSUB): the line data's TS byte (!Battle_HdmaScreens+1) = the first operand, CGWSEL (!Battle_HdmaColour) the second, CGADSUB (!Battle_HdmaColour+1) the third AND...
$CD:2F8BBattleCD_FxOpW12Sel32verifiedOpcode $94 (b): W12SEL (!Battle_WinRegs) = b, and !Battle_UnkC155 and !Battle_UnkC157 both = !BattleCD_FxEdgesNone ($00FF) when b bit 3 is set, else !BattleCD_FxEdgesAll ($FF00).
$CD:2FABBattleCD_FxOpW34Sel6verifiedOpcode $95 (b): W34SEL (!Battle_WinRegs+1) = b.
$CD:2FB1BattleCD_FxOpWObjSel6verifiedOpcode $96 (b): WOBJSEL (!Battle_WinRegs+2) = b.
$CD:2FB7BattleCD_FxOpDrawShape5verifiedOpcode $8B (slot): BattleCD_FxDrawShape with A = the slot (tail jump).
$CD:2FBCBattleCD_FxOpStepShape49verifiedOpcode $89 (slot, dx, dy, dsize): steps shape slot's values in !Battle_FxValues (see BattleCD_FxDrawShape): the centre x (entry slot + 2) + dx, the centre y (slot + 4) + dy, at most...
$CD:2FEDBattleCD_FxOpSetShape42verifiedOpcode $8A (b, x, y, size): shape slot b AND 1: its kind (!Battle_FxObjUnkD1 entry slot, 0-5 for BattleCD_FxShapeTable) = b / 16, and its centre x, centre y and size in !Battle_FxValues (entries...
$CD:3017BattleCD_FxOpSubWinScreens9verifiedOpcode $A0 (b): the line data's TSW byte (!Battle_HdmaScreens+3) = b AND !BattleFx_UnkCD46.
$CD:3020BattleCD_FxOpMainWinScreens9verifiedOpcode $9F (b): the line data's TMW byte (!Battle_HdmaScreens+2) = b AND !BattleFx_UnkCD46.
$CD:3029BattleCD_FxOpSubScreens9verifiedOpcode $9E (b): the line data's TS byte (!Battle_HdmaScreens+1) = b AND !BattleFx_UnkCD46.
$CD:3032BattleCD_FxOpMainScreens9verifiedOpcode $9D (b): the line data's TM byte (!Battle_HdmaScreens) = b AND !BattleFx_UnkCD46.
$CD:303BBattleCD_FxOpColData72verifiedOpcode $9C (value, step): the COLDATA value !Battle_WinRegs+5.
$CD:3083BattleCD_FxOpCgAddSub9verifiedOpcode $9B (b): the line data's CGADSUB byte (!Battle_HdmaColour+1) = b AND !BattleFx_UnkCD46.
$CD:308CBattleCD_FxOpCgWSel6verifiedOpcode $9A (b): the line data's CGWSEL byte (!Battle_HdmaColour) = b.
$CD:3092BattleCD_FxOpWBgLog38verifiedOpcode $98 (b): WBGLOG (!Battle_WinRegs+3) = b AND $3F; before it, with b bit 7 set !Battle_UnkC157 = !BattleCD_FxEdgesFF and !Battle_UnkC155 = !BattleCD_FxEdgesAll; else with bits 4-5 both set...
$CD:30B8BattleCD_FxOpWObjLog6verifiedOpcode $99 (b): WOBJLOG (!Battle_WinRegs+4) = b.
$CD:30BEBattleCD_FxOpHalfPlane118verifiedOpcode $97 (angle, step, flags): one window of this frame's window table becomes the half of the screen on one side of a line through the centre (BattleCE_DrawHalfPlane).
$CD:3134BattleCD_FxLineDeltas85verifiedThe deltas of the line from !BattleCE_LineP1 to !BattleCE_LineP2 for BattleCE_DrawHalfPlane: !BattleCE_LineDirX = $FF (P2 left of P1), 0 or 1 (right), !BattleCE_LineAbsDX = |x2 - x1|, and the same...
$CD:3189BattleCD_FxDrawShape21verifiedDraws shape slot A: !Battle_FxShapeSlot = A, the half widths of a circle of its size (BattleCD_FxCircleHalfWidths); with size AND $7F = 0 nothing more.
$CD:319EBattleCD_FxShapeTable12verifiedBattleCD_FxDrawShape's handler of each shape kind, by kind * 2.
$CD:31AABattleCD_FxCircleHalfWidths84verifiedWith r = the size of shape slot !Battle_FxShapeSlot AND $7F: r = 0 returns C=0.
$CD:31FEBattleCD_FxBuildCircle117verifiedBuilds a circle centred on x = the slot's centre x (!Battle_FxValues entry slot + 2) into !Battle_FxWinLines from the half widths (BattleCD_FxCircleHalfWidths, which aimed WMADD at the middle...
$CD:3273BattleCD_FxBuildDome196verifiedAs BattleCD_FxBuildCircle, but only every other line (the first, the third, ...: DP $4F counts them) is also written through WMDATA: the upper half is a half circle, the lower half one half as tall.
$CD:3337BattleCD_FxBuildWide126verifiedAs BattleCD_FxBuildCircle with every half width doubled (DP $51): an ellipse twice as wide as it is tall.
$CD:33B5BattleCD_FxShapeCircle6verifiedShape kind 0: a circle (BattleCD_FxBuildCircle, BattleCD_FxCopyShape).
$CD:33BBBattleCD_FxShapeDome6verifiedShape kind 1: a circle with its lower half squashed to half height (BattleCD_FxBuildDome, BattleCD_FxCopyShapeDome).
$CD:33C1BattleCD_FxShapeHanging6verifiedShape kind 2: kind 1's shape hanging from the top of the screen (BattleCD_FxBuildDome, BattleCD_FxCopyShapeHanging).
$CD:33C7BattleCD_FxShapeTall6verifiedShape kind 3: an ellipse twice as tall as wide (BattleCD_FxBuildCircle, BattleCD_FxCopyShapeTall).
$CD:33CDBattleCD_FxShapeWide6verifiedShape kind 4: an ellipse twice as wide as tall (BattleCD_FxBuildWide, BattleCD_FxCopyShape).
$CD:33D3BattleCD_FxShapeBig6verifiedShape kind 5: a circle of twice the size (BattleCD_FxBuildWide, then each line twice: BattleCD_FxCopyShapeTall).
$CD:33D9BattleCD_FxCopyShapeTall164verifiedCopies the 2r words of !Battle_FxWinLines from word $80 - r (r = the slot's size byte, bit 7 included) into the slot's window of this frame's table, each word to two lines, from line y - 2r (y =...
$CD:347DBattleCD_FxCopyShapeHanging176verifiedAs BattleCD_FxCopyShapeDome, then lines 0 to y - 1 of the slot's window (y = its centre y) all get the middle line's pair (!Battle_FxWinLinesMid): a column from the top of the screen down to the...
$CD:352DBattleCD_FxCopyShapeDome120verifiedCopies the words of !Battle_FxWinLines from word $80 - r to $80 + r / 2 (r = the slot's size byte, bit 7 included; the full upper half and the squashed lower half BattleCD_FxBuildDome wrote) into...
$CD:35A5BattleCD_FxCopyShape113verifiedCopies the 2r words of !Battle_FxWinLines from word $80 - r (r = the size byte of shape slot !Battle_FxShapeSlot, bit 7 included) into the slot's window of this frame's table from line y - r (y =...
$CD:3616BattleCD_FxCopyLines65verifiedCopies n = (DP $4B - Y) / 2 words of !Battle_FxWinLines from offset Y on into this frame's window table (!BattleFx_WinTable1 when bit 0 of !Battle_FrameCount is set, else !BattleFx_WinTable0) from...
$CD:3657BattleCD_FillObjTriangle37verifiedFills the triangle of object A (0 or 1) as it is in !Battle_FxTriX0 on (no scaling): !BattleFx_QuadSlot = A, DP $20 = 0, the three points into DP $12-$17, then falls into BattleCD_FillTriangle.
$CD:367CBattleCD_FillTriangle558verifiedFills the triangle of the points in DP $12-$17 (x, y each) into the edge pair !BattleFx_QuadSlot picks of this frame's window table, with DB=$00 (PHB, TDC / PHA / PLB, then PLB).
$CD:38AABattleCD_WinLineBases8verifiedBattleCD_AimWinLine's and BattleCD_AimWinTopFill's base addresses, by (frame bit 0 * 2 + !BattleFx_QuadSlot bit 0) * 2: window table 0's first and second pair, then table 1's.
$CD:38B2BattleCD_AimWinLineL4verifiedJSL entry of BattleCD_AimWinLine (BattleFx_RasterQuad's).
$CD:38B6BattleCD_AimWinLine47verifiedAims the WRAM port at line A of this frame's window table, at the edge pair !BattleFx_QuadSlot bit 0 picks: WMADD = $7E:(BattleCD_WinLineBases entry + 4A).
$CD:38E5BattleCD_EdgeSlope63verifiedY = (DP $0B - DP $0C) * 256 / DP $0D, signed (the hardware divides the size of the difference; a negative one negates the quotient): with x's and a line count, an edge's x step per line in 8.8...
$CD:3924BattleCD_FillHangingTriangle492verifiedFills a right triangle of object A (0 or 1) hanging from the top of the screen: !BattleFx_QuadSlot = A, DP $20 = 0, the object's first two points into DP $12-$15 and its third point replaced by...
$CD:3B10BattleCD_AimWinTopFill79verifiedAims the WRAM port at line 0 of this frame's window table, at the pair !BattleFx_QuadSlot bit 0 picks (BattleCD_WinLineBases), then writes the pair (X's high byte, Y's high byte) on A lines...
$CD:3B5FBattleCD_PlayPendingSfx18verifiedPlays the sound a script opcode left pending: when !Battle_SfxPending is set, clears it and sends !Battle_SfxPendingId with X = !Battle_SfxPendingArg through BattleCD_ApuCmd18 (tail jump).
$CD:3B71BattleCD_ApuCmd1817verifiedSends APU command !Sfx_CmdUnk18 (Audio_ProcessEntry) with !Sfx_Param1 = A and !Sfx_Param2 = X's low byte: a sound, probably (the callers pass the dissolve's and the wipe's sounds and the script...
$CD:3B82BattleCD_WaitScanline41verifiedBusy-waits for scanline A: past the vertical blank (HVBJOY bit 7), then into an H-blank and out of it; then, skipping H-blanks, latches the counters (SLHV, STAT78 resets the read order) and reads...
$CD:3BABBattleCD_Div1641verified16-bit unsigned division by shift and subtract: !BattleCD_MathOut = !BattleCD_MathA / !BattleCD_MathB, !BattleCD_MathOutHi the remainder.
$CD:3BD4BattleCD_Mul8x1641verified8 x 16-bit unsigned multiplication on the CPU's multiplier: the 24-bit DP $27-$29 = DP $23 (a byte) * the word at DP $25, as $23 * $25 plus $23 * $26 shifted left 8.
$CD:3BFDBattleCD_CosMul3verifiedA = Y * cos(A) / 256: adds a quarter turn ($40) and falls into BattleCD_SinMul ($3C00), which gives A = Y * sin(A) / 256 with the sine from !BattleRom_AbsSine (255 for 1; table index bit 7 = the...
$CD:3C00BattleCD_SinMul85verified
$CD:3C55BattleCD_CosMulStart3verifiedThe first half of BattleCD_CosMul / BattleCD_SinMul for BattleCD_Rotate3d: adds a quarter turn and falls into BattleCD_SinMulStart ($3C58), which starts |sin(A)| * |Y| on the multiplier and...
$CD:3C58BattleCD_SinMulStart55verified
$CD:3C8FBattleCD_Rotate3d257verifiedRotates the point !Battle_FxRotInX/Y/Z (signed bytes) into !Battle_FxRotOutX/Y/Z: first by the angle in DP $4B about the y axis (x' = cos*x + sin*z, z' = cos*z - sin*x), then by DP $49 about the x...
$CD:3D90BattleCD_HalfSinMul51verifiedA = sin(A) / 2 * DP $47 / 256: the |sin| entry halved (LSR) times the unsigned byte at DP $47 on the multiplier, the high byte, negated for angles $80-$FF.
$CD:3DC3BattleCD_HalfSinMul294verifiedAs BattleCD_HalfSinMul, then the result's magnitude times |sin(DP $45)| (DP $49) / 256: A = sin(A) / 2 * DP $47 / 256 * |sin(DP $45)| / 256, negated for angles A of $80-$FF (the sign of sin(DP...
$CD:3E21BattleCD_Mul8Unused26verifiedDP $49 = DP $45 * DP $47 (8 x 8-bit, on the multiplier).
$CD:3E3BBattleCD_WaitFrames9verifiedWaits A frames: BattleCD_WaitFrameRefresh A times (A = 0 waits 256).
$CD:3E44BattleCD_PauseWait49verifiedHolds the battle while !Battle_Paused is set: APU command !BattleCD_ApuCmdPause with argument !BattleCD_ApuCmdPause (and !Field_FadeBusy set to the same value), then frame by frame...
$CD:3E75BattleCD_WaitFrameRefresh8verifiedOne frame (BattleCD_WaitFrame), then the battle menu's refresh (BankC1_VecRefreshMenu: BattleMenu_RefreshIfDirtyL).
$CD:3E7DBattleCD_WaitFrame17verifiedWaits for the next frame: !BattleFx_FrameWait + 1, then BattleCD_PauseWait until it is back to 0 (BattleFx_Nmi, $D1:E77C, clears it at the end of its work: TDC, STA.l $7E:CA20; BattleFx_Init also...
$CD:3E8EBattleCD_DmaToVram38verifiedDMA channel 7 from A:X to VRAM word address Y, DP $45 bytes (mode 1: VMDATAL/VMDATAH), with DB = $00 inside and put back.
$CD:3EB4BattleCD_RunQueuedDma26verifiedThe NMI's half of BattleCD_QueueVramDma: when !Battle_DmaQueueReq is set, sends the queued piece (!Battle_DmaQueueSrc / Bank to !Battle_DmaQueueVram, !Battle_DmaQueuePiece bytes) through...
$CD:3ECEBattleCD_QueueVramDmaL4verifiedBattleCD_QueueVramDma for long callers (bank $D1), RTL.
$CD:3ED2BattleCD_QueueVramDma204verifiedUploads A:X to VRAM word address Y, DP $53 bytes, through the NMI (BattleCD_RunQueuedDma), in pieces of at most $1000 bytes while !Battle_CgramPending is set and $400 bytes else (re-checked before...
$CD:3F9EBattleCD_OldBuildLeftovers98verifiedNo code reaches these bytes.
$CE:E000BattleCE_CopyWindowEdges142verifiedCopies one window's edge pair of 216 lines from the window table not written this frame into the one that is: from !BattleFx_WinTable0 into !BattleFx_WinTable1 when bit 0 of !Battle_FrameCount is...
$CE:E08EBattleCE_WaveTable256verified128 signed words: a coarse wave of amplitude 2 (0, 1, 2, 1, 0, -1, -2, -1, each held for several words) with a period of 64 words, written twice so that any 64-word window of the first half reads...
$CE:E18EBattleCE_UnkE18E57verifiedThe layer-2 wave, a frame's step (the name is the stub's: matched bank-$CD code calls it so).
$CE:E1C7BattleCE_CopyWordsToLines1,537verified256 unrolled pairs LDA (2k),Y / STA (4k),X for k = 255 down to 0, then RTS.
$CE:E7C8BattleCE_RunCopyWords7verifiedJSL entry for BattleCE_CopyWordsToLines: JSR to a JMP (!BattleCE_CopyEntry), so that the copy's RTS comes back here for the RTL.
$CE:E7CFBattleCE_CalcAngle182verifiedThe direction from the second point to the first, 256 per turn, as Battle_CalcAngle (bank $C1) works it out: the signed differences dx = AX - BX and dy = AY - BY, the base angle from...
$CE:E885BattleCE_PresetWinEdges505verifiedThe first step of BattleCE_DrawHalfPlane: sets the edge the line will not draw, on all 224 lines of this frame's window table (WinTable1 when bit 0 of !Battle_FrameCount is set), for the window...
$CE:EA7EBattleCE_DrawHalfPlane1,008verifiedLayer-effect opcode $97's drawing: one window of this frame's window table (WinTable1 when bit 0 of !Battle_FrameCount is set, else WinTable0; the two halves of the code are the same but for the...
$CE:EE6EBattleCE_UnkEE6E163verifiedLoads HDMA set A (the name is the stub's: matched bank-$CD and bank-$D1 code calls it so): the first !BattleCE_HdmaHeadBytes (30) bytes, ten entries, of each of the nine indirect HDMA tables at...
$CE:F066BattleCE_UnkF066128verifiedParks sprites 4-127 (the name is the stub's: matched bank-$CD code calls it so): their y in BattleOam = !BattleOam_OffscreenY, and the high-table bytes 1-31 (!BattleOam_HighTable+1 on) =...
$CF:E300BattleCF_VblankUploads650verifiedCopies the battle's buffers to the PPU by DMA on channel 7, which needs vertical blank or forced blank: hence "vblank", inferred (the caller, BattleCD_NmiMain at $CD:08B4, is the NMI's work).
$CF:E58ABattleCF_FrameUpdate503verifiedThe battle's once-a-frame work behind the vector $C1:000C.
$CF:E781BattleCF_BounceHitNumbers86verifiedBounces the hit numbers BattleAct_OpShowHitNumbers built: while !Battle_HitNumActive is set, takes step !Battle_HitNumStep of the bounce table for each battler slot (!BattleRom_HitNumBounceAlt for...
$CF:E7D7BattleCF_StepFxColourCycle99verifiedThe status colour cycle (Battle_FxColourCycle turns it on): for PC slots 2, 1, 0 whose !Battler_FxCycleOn is set, unless !Battle_UnkA101 is set or the PC uses !Battle_SpecialPalette, copies the...
$CF:E83ABattleCF_BuildSprites242verifiedBuilds the battle's sprites, front to back: 1.
$CF:E92CBattleCF_DrawPosHistory112verifiedDraws the four position-history records BattleCF_RecordPosHistory keeps for the battler at sprite index X: every !Battler_PosHistUnkAB7D frames (!Battler_PosHistUnkAB88 counts them down) it draws...
$CF:E99CBattleCF_DrawPosHistRecord238verifiedDraws one copy of the battler !BattleSpr_Index at the history position in !BattleSpr_HistX/Y (low bytes) and !BattleSpr_HistXHi/YHi (only their sign is used: negative = the high byte is $FF): its...
$CF:EA8ABattleCF_DrawUnkA5D8Sprite59verifiedFor the battler at sprite index X whose !Battler_UnkA5D8 is non-zero (opcodes $D0/$D1 set and clear it) and whose !Battler_Unk9FF7 is 0: puts one sprite, tile !Battle_UnkA5D8Tile, at its screen...
$CF:EAC5BattleCF_DrawBattler207verifiedPlaces the sprites of the battler !BattleSpr_Index whose tile words BattleCF_CopySprTiles has just put in OAM: its position is !Battler_ScreenX/Y plus the signed display offsets...
$CF:EB94BattleCF_CopySprTiles228verifiedCopies the tile/attribute words (bytes 2-3 of each 4-byte sprite record) of four sprites per group from the list at X to the OAM entries at Y, !BattleSpr_Groups groups: it returns after a group...
$CF:EC78BattleCF_StepPathWalks74verifiedSteps the path walks BattleAct_PathToPoint starts: for each battler slot whose !Battler_PathWalking is set and whose step is not done (!Battler_PathStepFrame not negative), adds entry...
$CF:ECC2BattleCF_FollowObjects86verifiedMoves the action objects that follow something (!Battle_ActObjFollow, set by the action opcodes): for object threads 7 down to 0, a value with bit 7 clear and !Battle_ActFollowObj clear is a...
$CF:ED18BattleCF_RecordPosHistory160verifiedKeeps the position history of opcodes $A4/$A5: for battler slots 10 down to 0 whose !Battler_PosHistOn is set, every !Battler_PosHistDelay frames (!Battler_PosHistTimer counts them) shifts records...
$CF:EDB8BattleCF_DrawFrontLayer63verifiedCalled by BattleCF_BuildSprites just before a battler's own sprites, so what it adds shows in front of the battler.
$CF:EDF7BattleCF_DrawBackObjects53verifiedCalled by BattleCF_BuildSprites just after a battler's own sprites, so these show behind it: while an action runs and !Battle_ActUnkA3D1 is clear, draws every action object linked to this battler...
$CF:EE2CBattleCF_DrawFxOverlay115verifiedThe status overlay (Battle_FxOverlay* turn it on): for the battler !BattleSpr_Index with !Battler_FxOverlayOn set, steps its frame (0-3, every !Battler_FxOverlayPeriod frames...
$CF:EE9FBattleCF_DrawHitNumbers76verifiedPuts the four hit-number sprites (Battle_HitNumSprite) of the battler !BattleSpr_Index into OAM, when !Battler_HitNumShown is set, and stores its !Battle_HitNumHigh byte as the whole OAM...
$CF:EEEBBattleCF_DrawActObj196verifiedDraws one action object: the thread in bits 0-2 of !Battle_ActObjLinks entry X.
$CF:EFAFBattleCF_RunMovers111verifiedWhile an action runs: for battler slots 10 down to 0 with !Battle_ActorMoving set, counts !Battle_ActorMoveTimer down and at 0 reloads it from !Battle_ActorMoveDelay and runs mover...
$CF:F01EBattleCF_MoverTable16verifiedThe battlers' movers by !Battle_ActorMoveKind (BattleCF_RunMovers).
$CF:F02EBattleCF_ObjMoverTable16verifiedThe object threads' movers by their !Battle_ActorMoveKind entry.
$CF:F03EBattleCF_MoveStraight73verifiedMover kind 0: unless the battler's !Battler_MoveDone is set, adds !Battle_ActorStepX/Y to !Battle_ActorOfsX/Y (8.8) and puts the battler at !Battle_ActorFromX/Y + the offsets' high bytes; counts...
$CF:F087BattleCF_MoveArc269verifiedMover kind 1, the arc moves (see the arc notes at !Battle_ActorArcSteps in ram_battle.inc): steps the offset like BattleCF_MoveStraight, then !Battle_ActorMoveSpeed times steps the arc's speed and...
$CF:F194BattleCF_MoveHeading100verifiedMover kind 2, the heading moves: ends the move (!Battler_MoveDone) when the battler's 16-pixel cell (BattleCF_PixelToCell of its screen y, then x) is in row 0 or !Battle_CellRowBottom or column 0...
$CF:F1F8BattleCF_MoveCircle69verifiedMover kind 3: unless done, adds !Battle_ActorCircleStep to !Battle_ActorCircleAngle and writes radius * sin(angle) to !Battler_UnkA4AF and radius * cos(angle) to !Battler_UnkA4A4 (the display...
$CF:F23DBattleCF_MoveKind4279verifiedMover kind 4 (opcode $D2's move, a jump that lands on the point, probably; see BattleAct_OpMoveKind4ToCalc).
$CF:F354BattleCF_MoveEllipse75verifiedMover kind 5: BattleCF_MoveCircle with half the radius for the sine (y) part: !Battler_UnkA4AF = radius / 2 * sin(angle), !Battler_UnkA4A4 = radius * cos(angle).
$CF:F39FBattleCF_MoveShake27verifiedMover kind 6 (opcode $D8): BattleCF_ShakeStep, then, for battler slot !Battle_PartMainSlot (3) with !Battle_UnkA113 set, copies its display offsets !Battler_UnkA4A4/A4AF to slot...
$CF:F3BABattleCF_ShakeStep75verifiedThe shake: counts !Battler_ShakeFrames down; at 0 zeroes the display offsets and !Battle_ActorMoving (the move ends without the done flag).
$CF:F405BattleCF_MoveCurve173verifiedMover kind 7, the curving move: when the battler is within 16 pixels of !Battle_ActorToX/Y in both axes (BattleCF_PointsNear) counts !Battler_MoveDone up and returns.
$CF:F4B2BattleCF_ObjMoveStraight81verifiedObject kind 0: BattleCF_MoveStraight for an object: the offset steps, !Battle_ActObjX/Y = start + the offsets' high bytes (high bytes 0), !Battle_ActObjMoveDone set when the steps run out.
$CF:F503BattleCF_ObjMoveArc284verifiedObject kind 1: BattleCF_MoveArc for an object.
$CF:F61FBattleCF_ObjMoveHeading110verifiedObject kind 2: BattleCF_MoveHeading for an object (its cell from !Battle_ActObjY/X, the distance in !Battle_ActObjUnkA31C, the angle in !Battle_ActObjMoveAngle copied to !Battle_ActObjUnkA5B5)...
$CF:F68DBattleCF_ObjMoveCircle85verifiedObject kind 3: unlike the battlers' BattleCF_MoveCircle, it moves the object itself: adds the step to its angle and puts !Battle_ActObjX/Y (low bytes only) at the centre (!Battle_ActorCircleX/Y) +...
$CF:F6E2BattleCF_ObjMoveKind4282verifiedObject kind 4: BattleCF_MoveKind4 for an object, with these differences: the first test once falling uses a 24-pixel margin (!Battle_ObjNearMargin) and no height test (it counts...
$CF:F7FCBattleCF_ObjMoveOrbit136verifiedObject kind 5: the ellipse of BattleCF_MoveEllipse, moving the object itself around the centre (!Battle_ActObjX/Y low bytes = centre + radius * cos, radius / 2 * sin), and first re-linking it to...
$CF:F884BattleCF_ObjMoveCurve211verifiedObject kind 7: BattleCF_MoveCurve for an object.
$CF:F957BattleCF_PointsNear33verifiedSets !BattleCF_Near to 1 when the points (!BattleCF_NearX1, NearY1) and (!BattleCF_NearX2, NearY2) are less than !BattleCF_NearMargin apart in x and in y, else to 0.
$CF:F978BattleCF_StepEnemies91verifiedThe enemy stepper of the enemy movers (run while no action runs): for enemies 7 down to 0 with !Enemy_Stepping set, every !Battler_DefMoveDelay frames (!Enemy_StepTimer counts them) adds the...
$CF:F9D3BattleCF_PlaceEnemyParts36verifiedKeeps the enemies at fixed offsets from one of them: for each present enemy, !Battler_ScreenX/Y = the screen position of enemy !Battle_PartsAnchor + its !Enemy_PartOfsX/Y (8-bit adds; the anchor...
$CF:F9FBBattle_SinLookupCF28verifiedBank $CF's own scaled sine: returns (sin(A) × !BattleCF_SinScale) >> 8 in A.
$CF:FA17Battle_Mul8x16CF44verified
$CF:FA43Battle_CalcAngleCF154verifiedBank $CF's copy of Battle_CalcAngle ($C1:0222), working on WRAM instead of the direct page: the angle (256 units per turn) between !BattleCF_GeoOriginX/Y and !BattleCF_GeoPointX/Y, from dx =...
$CF:FADDBattleCF_PixelToCell5verifiedA / 16: a screen coordinate to its 16-pixel cell (the !Battle_CellMap grid); the heading movers test the result for the edge cells.
$CF:FAE2Battle_MergePendingEntries1580131verifiedFor the highest PC slot (2, 1, 0) whose !Pc_UnkA0B5 is set, merges its Battle_PcItem record into the battle item list (Item_BattleList, 256 records of 5 bytes): a record with the same .Id gets one...
$CF:FB65BattleCF_EnterBattle128verifiedThe battle's start, reached from EngCall_BattleMain ($C1:0000, JSL from the field's DefaultHandler) through the JML at $C1:001B.
$CF:FBE5BattleCF_ExitBattle273verifiedThe battle's end, reached through the JML at $C1:001F when BattleSys_Main JMPs to BattleSys_ExitVec.
$CF:FCF6BattleCF_PixelToTile5verifiedA / 16: a screen coordinate to the field's 16-pixel tile (the Battle_FieldPc / Battle_FieldObj .TileX/.TileY); the same code as BattleCF_PixelToCell.
$CF:FCFBBattleCF_WaitFrame7verifiedWaits one frame: counts !Battle_FramePending up and loops until the frame update (BattleCF_FrameUpdate) clears it.
$CF:FD02Battle_QueueVramUpload_0CC052verifiedDescribes the upload of the status-bar map (BattleUI_StatusTile(0, 0), $00:0CC0, $180 bytes) to VRAM word !Battle_PanelMapVram in the queue bytes !Battle_VramQDmap.., and sets !Battle_VramQPending...
$CF:FD36Battle_QueueVramUpload_A6E152verifiedThe same for the tech window map (BattleMenu_TechTile(0, 0), $7E:A6E1, $180 bytes) to the same VRAM address.
$CF:FD6ABattle_QueueVramUpload_0E8052verifiedThe same for the item list map (BattleMenu_ItemTile(0, 0), $00:0E80, $180 bytes) to the same VRAM address.
$CF:FD9EBattleFx_SetPtrA2FromTable15verifiedA = battler slot: stores !BattleRom_StatsOffset[slot] (the slot's BattlerStats offset, 2 B per slot) in DP $A2 (!BattleTmp_A2, which its callers read as !Battle_PoseStatsOffset and the like) and...
$CF:FE20BattleCF_RemoveMarkedEnemies101verifiedService 6 (BattleSys_Service6): for enemy slots 10 down to 3 marked in !Battle_UnkAEB3 (BattleSys_Main's debug win marks each enemy it removes), by path: - !Battler_Unk9FF7 set: only...
$CF:FFFDBattleCF_ActForceBytes3verifiedThe three bytes service 4 reads as !BattleRom_ActForceNone ($FFFD), !BattleRom_ActForceSecond ($FFFE) and !BattleRom_ActForceAlt ($FFFF): non-zero would force !Battle_ActUnkAE9B / !Battle_ActFlags...
$D1:E70ABattleFx_SwapObjPalettes114verifiedSwaps OBJ palette rows 1-3 with rows 5-7, colour for colour, in both the live (!Battle_PaletteLive) and the saved (!Battle_PaletteSaved) palette.
$D1:E77CBattleFx_Nmi285verifiedThe battle's NMI handler while this engine runs: BattleFx_Init writes JML $D1:E77C into !NmiTrampoline.
$D1:E899BattleFx_WhitenRows40verifiedFills background palette rows 2-7 ($2040-$20FF of !Battle_PaletteSavedLo and $2240-$22FF of !Battle_PaletteLiveLo) and OBJ palette rows 1-3 (saved and live) with !BattleFx_White ($7FFF).
$D1:E8C1BattleFx_WhitenObjRows5To724verifiedFills OBJ palette rows 5-7 (saved and live) with !BattleFx_White.
$D1:E8D9BattleFx_UploadMapBlock65verifiedSends a 16 x 16 block of map words to VRAM by DMA on channel 7: 16 rows of !BattleFx_MapRowBytes (32 bytes) from A:X, one after the other in the source, to VRAM word address DP $45, $45 + $20, $45...
$D1:E91ABattleFx_MoveBgRowsUp106verifiedMoves background palette rows 2-4 to rows 5-7, with the palette animations that work on them: - rows 2-4 of !Battle_PaletteSavedLo are copied to rows 5-7 of both the saved and the live palette...
$D1:E984BattleFx_LoadBgRows2To4107verifiedCounts up !BattleFx_UnkCDC8 and !Battle_CgramPending, loads background palette rows 2-4 (saved and live) from !BattleRom_BgRows2To4 ($D0:FD00, 48 colours), copies FieldAnimB records 0-2 over...
$D1:E9EFBattleFx_GradLevelOfs18verifiedByte offset into !BattleRom_GradColours of the 14 colours of each gradient level 0-8 (BattleFx_HpGradientTick indexes it with the level * 2).
$D1:EA01BattleFx_FindGradStart32verifiedLooks for the first colour of !BattleRom_GradColours among colours 1-14 of saved background palette row 5 and stores the colour number less 1 (0-13) to !BattleFx_GradStart; 0 when none matches.
$D1:EA21BattleFx_GradRotA14verifiedThree rotation tables of BattleFx_HpGradientTick, indexed by !BattleFx_GradStart (0-13): the rotation of background row 5 (A), 6 (B) and 7 (C).
$D1:EA2FBattleFx_GradRotB14verifiedRow 6's start (see BattleFx_GradRotA).
$D1:EA3DBattleFx_GradRotC14verifiedRow 7's start (see BattleFx_GradRotA).
$D1:EA4BBattleFx_HpGradientTick389verifiedOne step of a background colour gradient that follows the HP of battler slot 3 (the first enemy).
$D1:EBD0BattleFx_GradRotation15verifiedA = DP $45 (a row's rotation from BattleFx_GradRotA/B/C) when !BattleFx_GradRotRaw is non-zero, else !BattleFx_GradCount - DP $45.
$D1:EBDFBattleFx_GradWriteRow32verifiedWrites the 14 colours !BattleFx_GradColours + A * 2 on to colours 1-14 of the background palette row at Y ($20 per row, from row 5), in the saved and the live palette.
$D1:EBFFBattleFx_SwayQuad96verifiedFills quad X (X = the argument byte) of !BattleFx_Quads and draws it: a beam from the top of the screen down to the point in !Battle_ActCalcResult.
$D1:EC5FBattleFx_FxModels112verifiedThe 3D models of the layer-effect objects, read by bank $CD (BattleCD_FxRotateVertex, $CD:1EFE on: bytes 0, 1 and 2 of entry A * 4 + DP $4F into !Battle_FxRotInX/Y/Z, z plus DP $51): seven models...
$D1:ECCFBattleFx_BgSetPalOfs12verifiedPer background set 0-5 (BattleFx_LoadBgSet, index = set * 2): byte offset into !BattleRom_BgSetPalettes of the set's three palette rows ($60 bytes).
$D1:ECDBBattleFx_BgSetPacks24verifiedPer background set 0-5 (BattleFx_LoadBgSet, index = set * 4): the four graphics pack ids (!LocGfx_PackPtrs entries) unpacked to VRAM $2000, $2800, $3000 and $3800 (words); !BattleFx_BgPackNone...
$D1:ECF3BattleFx_LoadBgSet218verifiedLoads background set A (0-5): with !BattleFx_BgLoading set meanwhile, for each of the set's four entries in BattleFx_BgSetPacks that is not !BattleFx_BgPackNone, unpacks that graphics pack...
$D1:EDCDBattleFx_GrowBand204verifiedDraws a band around the point in !Battle_ActCalcResult into the window table of this frame (!BattleFx_WinTable1 when bit 0 of !Battle_FrameCount is set, else !BattleFx_WinTable0), one step wider...
$D1:EE99BattleFx_MsgSfx12verified1 byte per battle message: the sound BattleCD_ShowMessage plays for it (through BattleCD_ApuCmd18, unless !BattleCD_MsgNoSfx, $FF).
$D1:EEA5BattleFx_RampWin231verifiedWith n = !BattleFx_RampBottom ($C0) - !BattleFx_CountA (an 8-bit subtraction, so n is 0-255), stores the words 0, 1, 2, ...
$D1:EEC4BattleFx_WaveWindowA159verifiedWrites wavy edges into !BattleFx_WinTable0, two lines at a time, for Y = 0 to !BattleFx_WinUsedBytes - 8 in steps of 8 (the pairs at !BattleFx_WinTable0-4 + Y and + Y: the line before line 0 to...
$D1:EF63BattleFx_WaveLeftA109verifiedBattleFx_WaveWindowA's first pair: A (8-bit, its sign in N) is sign- extended, added to the word at !BattleFx_WaveBaseX + Y and stored to !BattleFx_WinTable0-4 + Y and !BattleFx_WinTable0 + Y.
$D1:EFD0BattleFx_WaveWindowB19verifiedLike BattleFx_WaveWindowA, but with r1 = r2 = !BattleFx_WaveRadius - !BattleFx_CountA, and the first pair is r1 x the sine plus (!BattleFx_ShakeX + !Battle_FxScrollAddX) instead of the $7E:E500...
$D1:EFE3BattleFx_WaveWindowB_ByFrame155verified
$D1:F07EBattleFx_WaveLeftB107verifiedBattleFx_WaveLeftA with DP $4F (the word BattleFx_WaveWindowB formed) in place of the !BattleFx_WaveBaseX words.
$D1:F0E9BattleFx_WaveRight31verifiedThe second pair of the wave windows: A (8-bit, its sign in N) sign- extended, plus DP $51, stored to !BattleFx_WinTable0-2 + Y and !BattleFx_WinTable0+2 + Y.
$D1:F108BattleFx_AddLineOffsets168verifiedAdds per-line bytes from $7E:0A00 (DP=$0A00 meanwhile) to lines 48-111 and 112-175 of this frame's window table (by bit 0 of !Battle_FrameCount): for n = 0-63, line 48 + n and line 112 + n each...
$D1:F1B0BattleFx_Init609verifiedThis engine's set-up at the start of a battle (bank $CD's vector $CD:0000, which BattleCF_EnterBattle calls as BattleSys_VecCD0000 before it clears the battle RAM $7E:2D01-$ACEC).
$D1:F411BattleFx_SaveAnimKinds21verifiedCopies .Unk0 (the kind) of FieldAnimB records 0-7 to !BattleFx_SavedKinds+0..7.
$D1:F426BattleFx_HoldAnimsTick78verifiedHolds and releases the palette animations around bank $CD's PalAnim_TickAll call (its callers run FdVec_FFF7 right after): - !BattleFx_HoldAnims non-zero, !BattleFx_AnimsHeld still 0: sets...
$D1:F474BattleFx_RandomByte8verifiedA = RandomTable entry A + !Battle_FrameCount (low byte) + C.
$D1:F47CBattleFx_RandomShake68verifiedPicks a random shake from three argument bytes (base x, base y, mask): x = (random byte & mask) + base x, y = (random byte & mask) + base y, and stores -x and -y (16-bit) to !BattleFx_ShakeX and...
$D1:F4C0BattleFx_NmiAlt153verifiedA second NMI handler of the battle: BattleCD_ExitBattle installs it at the battle's end, after the closing wipe (the STX at $CD:0420 stores its address to !NmiTrampoline+1, the STA at $CD:041A the...
$D1:F559BattleFx_StepBounce116verifiedOne step of a bounce for record X = !BattleFx_RecOfs (16-bit fields): - !BattleFx_BounceDir non-zero (falling): !BattleFx_BounceSpeed += !BattleFx_BounceAccel, unless that overflows, which zeroes...
$D1:F5CDBattleFx_SaveCalcPoints40verifiedCopies the six bytes of !Battle_ActCalcResult to !BattleFx_CalcCopy + X (X = the argument byte), two bytes apart: bytes 0, 2, 4 (the x of the three points, probably) to +0, +4, +8, bytes 1, 3, 5...
$D1:F5F5BattleFx_CopyWin1ToWin2133verifiedCopies the first pair of every line (0-223) of one window table into the second pair of the other: table 0 into table 1 when bit 0 of !Battle_FrameCount is set (the table this frame writes), table...
$D1:F67ABattleFx_Op80Dispatch12verifiedRuns the handler of BattleFx_Op80Table picked by the high nibble of !Battle_ActOp80Args (the bytes battle-script opcode $80 copied; its first byte's low nibble is their count).
$D1:F686BattleFx_Op80Table12verifiedBattleFx_Op80Dispatch's handlers, by the high nibble of !Battle_ActOp80Args (0-5).
$D1:F692BattleFx_Op80Clear10verifiedOp80 handler 5 (BattleFx_Op80Table), also run first by BattleFx_Op80Kind4: zeroes !Battle_ShakeXOn, !Battle_ShakeYOn and !Battle_ShakeLayers (the screen shake off).
$D1:F69CBattleFx_Op80Bits88verifiedBattleFx_Op80Kind4: the value for bits 2-4 of an argument byte (0-7): 1, 2, 3, 4, then single bits 8, $10, $20, $40.
$D1:F6A4BattleFx_Op80BitsHi8verifiedBattleFx_Op80Kind4: the value for bits 5-7 of an argument byte (0-7): the single bits 1 to $80.
$D1:F6ACBattleFx_Op80OrA4verifiedBattleFx_Op80Kind4: by bits 0-1 of the first argument byte, the bits ORed into !Battle_ShakeLayers ($00, $28, $A0, $A8).
$D1:F6B0BattleFx_Op80OrB4verifiedThe same by bits 0-1 of the third argument byte ($00, $14, $50, $54: BattleFx_Op80OrA's values shifted right once).
$D1:F6B4BattleFx_Op80Kind4153verifiedOp80 handler 4: BattleFx_Op80Clear, then fills the two 8-byte groups from !Battle_ShakeXOn (x) and !Battle_ShakeYOn (y) from the argument bytes 1-4 (!Battle_ActOp80Args+1 to +4).
$D1:F74DBattleFx_Op80Kind0240verifiedOp80 handlers 0-3: builds the two FieldAnimB records of !Battle_PalAnimRecs89 (record 8 at +0, record 9 at +12; offsets below are within each record).
$D1:F83DBattleFx_BuildGradHdma174verifiedZeroes !BattleFx_GradHdmaBytes from !BattleFx_GradHdmaA-1 and builds four lists of 4-byte entries, two bytes used in each: - !BattleFx_GradHdmaA: 24 entries (1, v) with v the high byte of a 16-bit...
$D1:F8EBBattleFx_SortQuadByY50verifiedSorts the four points of BattleFx_DrawQuad (DP $12-$19, x then y) by y, top first: four passes of three compare-and-swaps of neighbours (equal y also swap), each swap moving a whole point with...
$D1:F91DBattleFx_QuadSlopes85verified!BattleFx_QuadTop = y0, and the four edge slopes of the sorted quad (BattleFx_EdgeSlope): !BattleFx_Slope02 (point 0 to 2), !BattleFx_Slope23, !BattleFx_Slope01 and !BattleFx_Slope13.
$D1:F972BattleFx_EdgeSlope61verifiedY = (!BattleFx_SlopeXTo - !BattleFx_SlopeXFrom) * 256 / !BattleFx_SlopeDy, signed (the hardware divides the size of the difference; a negative difference negates the quotient): the x step per line...
$D1:F9AFBattleFx_DrawQuad56verifiedDraws quad X of !BattleFx_Quads into this frame's window table: !BattleFx_QuadSlot = X, the quad's eight coordinate bytes (two bytes apart from !BattleFx_Quads + X: x0, y0, x1, y1, x2, y2, x3, y3)...
$D1:F9E7BattleFx_RasterQuad385verifiedRasterises the y-sorted quad in DP $12-$19 into the window table through the WRAM port: BattleFx_QuadSlopes, then JSL BattleCD_AimWinLineL with A = !BattleFx_QuadTop aims WMADD at that line of the...
$D1:FB68BattleFx_AddBoxInset10verifiedAdds the argument byte to !BattleFx_BoxInset.
$D1:FB72BattleFx_GrowBox92verifiedAdds the argument byte to !BattleFx_BoxHalfHeight (h), then sets the first pair of lines !BattleFx_BoxCentre ($6A, line 106) - h to $6A + h - 1 of this frame's window table to left =...
$D1:FBCEBattleFx_FillWindow4verifiedRuns BattleFx_FillTable's handler X: 0 all empty, 2 first pairs empty, 4 second pairs empty, 6 first pairs full (in this frame's table).
$D1:FBD2BattleFx_FillTable8verifiedBattleFx_FillWindow's handlers, by X = 0, 2, 4, 6.
$D1:FBDABattleFx_FillWin1Full94verifiedSets the first pair of lines 0-223 of this frame's window table to !BattleFx_WinFull (left 0, right 255): eight blocks of 28 lines, X from $70 down to 4.
$D1:FC38BattleFx_FillWin1Empty94verifiedSets the first pair of lines 0-223 of this frame's window table to !BattleFx_WinEmpty (left 255, right 0).
$D1:FC96BattleFx_FillWin2Empty94verifiedSets the second pair of lines 0-223 of this frame's window table to !BattleFx_WinEmpty.
$D1:FCF4BattleFx_FillAllEmpty138verifiedSets both pairs of lines 0-223 of this frame's window table to !BattleFx_WinEmpty: sixteen blocks of 14 lines, X from $38 down to 2 in steps of 2 (every word).
$D1:FD7EBattleFx_MirrorWin1ToWin2206verifiedLike BattleFx_CopyWin1ToWin2 (first pairs of the other table into the second pairs of this frame's table), but mirrored left to right (the word is inverted and its bytes swapped: left = 255...
$D1:FE4CBattleFx_ReloadCeSet37verifiedWhen !BattleFx_CeSetWant differs from !BattleFx_CeSet (which then takes it), or else when !BattleFx_CeSetReload is set: JSL BattleCE_UnkEE6E with A = !BattleFx_CeSetBase + !BattleFx_CeSet +...
$D1:FE71BattleFx_RestoreMathRegs38verifiedWrites the math unit's operands again from their mirrors: the dividend and divisor (!Battle_DivMirrorLo/Hi/Divisor, which restarts the division) when !Battle_DivBusy is set, else the two factors...
$D1:FE97BattleFx_Irq93verifiedThe battle's IRQ handler while this engine runs: BattleFx_Init writes JML $D1:FE97 into !IrqTrampoline and sets the V-count IRQ at line !BattleFx_IrqLine (211).
$FD:A8A5BattleFD_UnkA8A541verifiedChecks whether PC A can act on its command: !Battle_UnkB3EA = 1 when its BattlerStats.Status has bit 7 (KO'd), its .Unk4C+2 or .Unk4C+7 has bit 7 (!Battle_AutoEnemyBit, the bit that makes...
$FD:A8CEBattleFD_DropPcCommand48verifiedDrops the command of PC DP $14: BattleSys_RefundItemLong (gives back an item the command had taken), then its BattleCmd .State and .Kind = 0 and .Partners = $FF, and its gauge restarts as in...
$FD:A8FEBattleFD_DropLatchedPcCommand62verifiedAs BattleFD_DropPcCommand, but only when !Battle_UnkB188[pc] (the latched BattleCmd.State) is non-zero, and it ends with !Battle_ArgSlot = the PC and BattleSys_RemoveReadyLong (service 2: the PC...
$FD:A93CBattleFD_UnkA93C35verifiedBattleFD_DropPcCommand for each PC 0, 1, 2 whose !Battle_CmdPcs byte is non-zero (the PCs of the command BattleSys_UnkB967 drops).
$FD:A95FBattleFD_UnkA95F35verifiedBattleFD_DropLatchedPcCommand for each PC 0, 1, 2 whose !Battle_CmdPcs byte is non-zero (the PCs of the groups BattleSys_UnkB575 marked).
$FD:A982BattleFD_UnkA98214verifiedZeroes $7E:AD89-$B3F4: the battle's working variables from !Battle_UnkAD89 to !Battle_UnkB3F4 (the turn lists, the action block, the reward sums and most of the other !Battle_Unk* bytes this file...
$FD:A990BattleFD_RestoreEnemies264verifiedProbably a script command that brings removed enemies back: the caller (BattleAi_RunRestoreAndSetStats, run handler $16, at $C1:A3B6) leaves the script read address in !Battle_UnkB1D2 (bank $CC)...
$FD:AA98BattleFD_UnkAA9824verifiedSets BattlerStats.Status of all 8 enemy slots (3-10) to !Battle_StatusKo ($80, the other status bits cleared).
$FD:AAB0BattleFD_UnkAAB034verifiedBuilds !Battle_Unk7F01EE: bit n set for each enemy entry n (0-7) whose !Battle_UnkAE85 byte is non-zero.
$FD:AAD2BattleFD_LoadUnkB18E47verifiedFills the 4 bytes !Battle_UnkB18E-B191 from the 11-byte record !Battle_UnkB18C of !BattleRom_UnkCC6FCB: B18E = record byte 0, B18F = the record number, B190 = record byte 1, B191 = 0...
$FD:AB01BattleFD_LoadUnkB18E247verifiedBattleFD_LoadUnkB18E with the records of !BattleRom_UnkCC88CB.
$FD:AB30BattleFD_UnkAB30114verifiedRun by BattleSys_Unk8461 for a PC whose turn is due, before the menu: decides whether the PC acts on its own.
$FD:ABA2BattleFD_AddEnemyRewards204verifiedAdds the rewards of the enemy in slot DP $0E to the battle's sums, unless its !Battle_UnkAF15 bit 6 is set (!Battle_AF15NotCounted) or its !Battler_UnkAF0A entry is empty.
$FD:AC6EBattleFD_UnkAC6E128verifiedRun by BattleSys_Unk8461 after a turn when !Battle_UnkB2C0 is 0 (no enemy reaction scripts): probably the PCs' counter-attacks.
$FD:ACEEBattleFD_UnkACEE15verifiedZeroes !Battle_UnkAD9B and the $B0 bytes from !Battle_ActPcHitAmount ($AD9C-$AE4B: the first four of the $2C-byte record sets the hit opcodes read).
$FD:ACFDBattleFD_UnkACFD12verifiedZeroes the $84 bytes from !Battle_HitAmount ($B328-$B3AB): the three $2C-byte hit sets (!Battle_HitAmount/!Battle_HitFlags per battler slot) that Battle_RecordHit fills and Battle_ApplyHits...
$FD:AD09BattleFD_UnkAD0914verifiedSets the three PCs' Tech_MenuEntry blocks ($1A80-$1C23, 3 x $8C bytes) to $FF.
$FD:AD17BattleFD_UnkAD17315verifiedBattleSys_Main's victory path, after the gold: shows the end-of-battle messages, each one a JSL BattleSys_UnkVecCD0021 with A = the message and its arguments in !Battle_MsgArg0..
$FD:AE52BattleFD_UnkAE5271verifiedBuilds a PC's stat block from its character record: for PC slot Y with a character id in !Battler_UnkAEFF (not negative), copies the id's $50-byte record at !Menu_CharRecords + id * $50 to the...
$FD:AE99BattleFD_UnkAE9943verifiedCopies BattlerStats.Unk57 of PCs 0-2 to !Battle_UnkB3BA-B3BC and counts in !Battle_UnkB3BD how many of them are !Battle_Unk57CountId ($A9).
$FD:AEC4BattleFD_UnkAEC446verifiedFor each PC 0-2 whose BattlerStats.Unk57 is !Battle_Unk57FlagId ($AB), sets bit 2 of its BattlerStats.Unk4C+4 (+$50).
$FD:AEF2BattleFD_UnkAEF2142verifiedFills the 5-byte records of !Battle_Unk1C48 (15 bytes, one record per PC 0-2) from the PCs' stat blocks.
$FD:AF80BattleFD_AddItemEntry156verifiedAdds item A to the battle item list (Item_BattleList) at offset DP $04, with quantity DP $0E, when the item is one the list takes: an id of $BC or more whose byte 0 in !BattleRom_ItemUseFlags (3 B...
$FD:B01CBattleFD_AddItemEntry_Skip23verified
$FD:B033BattleFD_ItemRecOffset162verifiedOffset in bank $CC of item A's record, by id range: below $5A: id * 5 + $0262; $5A-$7A: (id - $5A) * 3 + $047E; $7B-$93: (id - $7B) * 3 + $04E1; $94-$BB: (id - $94) * 4 + $052C; $BC-$F1: (id...
$FD:B0D5BattleFD_UnkB0D576verifiedTurn-list and panel setup: zeroes the flags of all 13 turn lists (!Battle_ListFlags), sets every !Battle_ListRuns entry to 10 (!Battle_ListRunsReset: this is where the runs are first set), zeroes...
$FD:B121BattleFD_UnkB12132verifiedCopies bits 0-1 of each enemy's BattlerStats.Unk47 (slots 3-10) to !Battle_UnkA020 (one byte per enemy entry).
$FD:B141BattleFD_ApplyRecBoost12verifiedApplies the stat boost an item record names: byte 4 of the record at DP $08 (an address in bank $CC; BattleSys_UnkCE3A points it at three equipment records of a PC, probably the weapon, armour and...
$FD:B14DBattleFD_UnkB14D179verifiedApplies stat boost A to the stat block at DP $00: its 2-byte entry in bank $CC at DP $0E + A * 2 has a stat mask (byte 0) and an amount (byte 1); for each mask bit set, the amount is added to one...
$FD:B200BattleFD_UnkB14D_Done1verified
$FD:B201BattleFD_UnkB20134verifiedBattleSys_Main's victory path, before the gold is paid: when a PC has BattlerStats.Unk57 = $A9 (!Battle_UnkB3BD non-zero, BattleFD_UnkAE99), adds the !Battle_UnkB28C sum to !Battle_RewardGold...
$FD:B223BattleFD_UnkB22311verifiedSets !Battle_UnkAE6D entry n to n for n = 0-10.
$FD:B22EBattleFD_UnkB22E176verifiedBattle_SetupBattle's second step: the battlers' entries.
$FD:B2DEBattleFD_UnkB2DE97verifiedBattle_SetupBattle's first step.
$FD:B33FBattleFD_UnkB33F36verifiedBattleFD_UnkB2DE's helper: !Battle_UnkAF1D = 0, !Battle_PcCount = 3, copies $230 bytes from !MenuRom_CharRecordInit ($CC:0000, the new-game records Menu_InitNewGameData copies) to...
$FD:B363BattleFD_UnkB363136verifiedFor PC slot Y with an id in !Battler_UnkAEFF: - BattlerStats.Unk79 bit 7 set: ORs .Unk7B into the byte at BattlerStats.Status + .Unk7A (a status byte picked by .Unk7A); - BattlerStats.Unk57 = $A0...
$FD:B3EBBattleFD_UnkB3EB19verifiedSets BattlerStats.Unk72 of the slot at X to $32 when its .Unk56 is $3D or $42.
$FD:B3FEBattleFD_UnkB3FE58verifiedFor PC X with an id in !Battler_UnkAEFF: sets the 4 bytes of its BattlerStats.Unk6C to 4, then the byte picked by the highest of BattlerStats.Unk2E bits 7-4 (bit 7: +0, 6: +1, 5: +2, 4: +3) to 5...
$FD:B438BattleFD_UnkB438158verifiedBuilds an enemy's stat record from ROM: for enemy entry X (also in DP $02), with the id in its !Battler_UnkAF0A entry, the 23-byte record at BattleRom_EnemyStats + id * 23 fills BattlerStats[entry...
$FD:B4D6BattleFD_ZeroStatBlock17verifiedZeroes $80 bytes from BattlerStats[3].Unk2D + Y (an enemy's stat block, running into the next record's first $2D bytes).
$FD:B4E7BattleFD_UnkB4E7110verifiedSets the starting values of the turn lists for all 11 slots: the reload value (!Battle_ListReload) and the countdown (!Battle_ListTimers) of lists 0-11 get the same number per list: 0: 60, 1: 150...
$FD:B555BattleFD_UnkB555256verifiedOne of Battle_SetupBattle's last steps: - zeroes !Battle_UnkAEE6 (17 B), !Battle_UnkB19E (32 B) and the 32 bytes from !Enemy_AnimWanted ($5E0D-$5E2C); - BattleFD_UnkB3EB for each PC whose...
$FD:B655BattleFD_UnkB655221verifiedPuts item DP $06 in the 4-byte record of slot !Battle_UnkB18B in !Battle_PcItem (8 B per slot) when it is an item the battle list takes (as BattleFD_AddItemEntry: id $BC or more with bit 7 of its...
$FD:B732BattleFD_UnkB732185verifiedClears the battle's per-battle state (Battle_SetupBattle): - DP $16-$21 and !Battle_UnkAF25 (16-bit) = 0; !Battle_UnkB1FC, !Battle_UnkB253, !Battle_UnkAECB, !Battle_UnkB2C0, !Battle_UnkB3B9 = 0...
$FD:B7EBBattleFD_UnkB7EB364verifiedThe battlers' first turn values (Battle_SetupBattle): - each PC with an id in !Battler_UnkAEFF, and each enemy entry below !Battle_EnemyCount with an id in !Battler_UnkAF0A: its stat block's...
$FD:B957BattleFD_FixedCmdPtrs6verified!BattleRom_FixedCmdPtrs: one word per !Battle_Unk29AC value (0-2), the bank-$FD address of the 21 bytes BattleSys_UnkB725 copies over the three BattleCmd records ($93EE-$9402) in the bit-5 battle.
$FD:B95DBattleFD_FixedCmds63verifiedThe three sets, 21 bytes each: a BattleCmd record (.State, .Kind, .Menu, .Target, .Unk4, .Partners, .ActionId) for PCs 0, 1 and 2.
$FD:B99CBattleFD_FixedPartyPtrs6verified!BattleRom_UnkFDB99C: one word per !Menu_Config+28 value (0-2), the bank-$FD address BattleFD_UnkB2DE reads its 8 x 4 words from.
$FD:B9A2BattleFD_FixedParty168verifiedBattleFD_UnkB2DE's four words per character record: Menu_CharRec .Word3, .Word5, .Word7 and .Word9 (probably current HP, maximum HP, MP and maximum MP: 800, 800, 80, 80 in every entry but one).
$FD:BA4ABattleFD_AiActLength23verified!BattleRom_AiActLength: one byte per enemy script action code $00-$16, the bytes of its action record; BattleAi_EnemyTurn and BattleAi_ChooseByChance step through an action part by it.

Generated from functions.csv. Do not edit.