# run linkw wave 18 (lane w18): ov035's LEVEL DATA, per symbol -- the mount the
# ov065 Tick Tock Clock cluster is blocked on.
#
# ov035 (level 27, Tick Tock Clock, data/stage/clock_tower, course 13) is
# already mounted WHOLE in PORT_LEVEL_OVERLAYS -- wave 17 landed that with the
# level-27 row. This is the SECOND mount of the same overlay, per symbol, and
# the two do not conflict: tools/ovdata.py --whole emits port_ov035_image /
# _patch / _at and NOTHING by name, while --from-list --pack emits the named
# arrays plus port_ov035_syms_patch. ov009/ov010/ov012/ov013/ov014/ov015/ov016/
# ov018/ov019/ov020/ov021/ov022/ov031/ov045 are dual-mounted the same way today;
# this is the fifteenth, and ov022 is the worked example.
#
# ==== WHY, AND WHAT WAVE 17 MEASURED ========================================
#
# Every Ttc class in ov065 reaches a CLPS collision block and an animation
# descriptor that live in whichever LEVEL overlay is loaded -- ov035 on level
# 27. Those are cross-overlay relocations, and ovdata.py's cross pass
# DELIBERATELY refuses to rebase into a whole-image mount ("a whole-image mount
# PROVIDES NOTHING to the cross pass ... which is what keeps the level overlays
# honest"), so with only the whole mount the words stay DS addresses and a
# seated Ttc class hands MovingMeshCollider::SetFile a DS pointer as its
# CLPS_Block. Wave 17 seated the whole cluster and measured the consequence:
# ids 108 (x8) and 114 (x5) ticked 300 frames WITHOUT faulting, silently, on a
# garbage CLPS, and id 112 divided by zero in Animation::Advance because its
# animation descriptor read zero frames. The quiet two are the worse half, and
# they are why that seat came back out. This file is the remedy.
#
# ==== THE SEEDS: EVERY ov065 -> LEVEL-WINDOW RELOCATION, NOT A SAMPLE =======
#
# Wave 17's note lists FIVE such relocations. There are TWELVE. The five it
# names are the ones its seated classes happened to trip over; the list below is
# every `to:` in config/arm9/overlays/ov065/relocs.txt that lands in
# [0x021111a0, 0x02112ce0) with an `overlays(...)` candidate list -- the
# candidate lists are over-broad because every level overlay shares the load
# window at base 0x021111a0, and ov035 is in all twelve.
#
#   from 0x0211d16c -> 0x0211208c   animation descriptor   (w17 had this)
#   from 0x0211d170 -> 0x021120a4   animation descriptor
#   from 0x0211d19c -> 0x021120d8   CLPS
#   from 0x0211d364 -> 0x021120f8   CLPS                   (w17 had this)
#   from 0x0211c03c -> 0x02112118   CLPS
#   from 0x0211cfd8 -> 0x02112138   CLPS                   (w17 had this)
#   from 0x0211d370 -> 0x02112158   CLPS
#   from 0x0211cfe4 -> 0x02112178   CLPS                   (w17 had this)
#   from 0x0211a454 -> 0x02112198   CLPS
#   from 0x0211bb68 -> 0x021121b8   CLPS                   (w17 had this)
#   from 0x0211d1a8 -> 0x021121f8   CLPS
#   from 0x0211b314 -> 0x02112258   CLPS
#
# So it is TEN CLPS blocks and TWO animation descriptors, not "four CLPS and two
# BTA". Mounting only w17's five would have left five more classes reading DS
# addresses just as silently as ids 108 and 114 did.
#
# ==== THE WIDTHS, PINNED THREE WAYS, AND TWO ROUTES LIE =====================
#
# A CLPS block is self-describing:
#
#     u32 'CLPS' (0x53504c43) / u16 entrySize / u16 count
#     count * entrySize of entries / a run of 0xffffffff filling the block out
#
# Every block here reads entrySize 8 and count 1 or 2, and every one is 0x20
# bytes. Three routes were run against all ten:
#
#   ROUTE A, the next-symbol landing from config/arm9/overlays/ov035/symbols.txt
#     -- agrees on eight, UNDER-READS on two, because dsd split the block and
#     named a symbol inside it:
#         0x021120f8  next symbol 0x02112104  ->  0xc  against a real 0x20
#         0x021121b8  next symbol 0x021121c0  ->  0x8  against a real 0x20
#     Both of those dsd names carry `ambiguous`, and so do eight others in this
#     window, so the flag does not separate the split ones from the good ones.
#
#   ROUTE B, scanning forward to the next 'CLPS' magic -- agrees on eight and
#     OVER-READS on two, because what follows is a FILE TABLE rather than
#     another block:
#         0x021121f8  next magic at 0x02112238  ->  0x40  against a real 0x20
#         0x02112258  next magic far away       -> 0x114  against a real 0x20
#     0x02112218 and 0x02112278 are {count, pointer} file tables belonging to
#     the level overlay's own whole mount. Route B would have mounted them a
#     second time and let this mount's pointer pass rewrite words the whole
#     mount owns -- two mounts fighting over the same storage, which is the
#     failure this file exists to avoid.
#
#   ROUTE C, the block's OWN header: 8 + count*entrySize, then extended over the
#     trailing 0xffffffff run. Self-contained, depends on nothing that follows,
#     and gives 0x20 on all ten. THIS IS THE INVARIANT. The 0xffffffff run is
#     the terminator and it lives INSIDE the block, which is what makes it
#     immune to both a split symbol and a following table.
#
# The two animation descriptors are 0x18 each and all three routes agree
# (0x0211208c -> 0x021120a4 -> 0x021120bc, and 0x021120bc is the LVL_Overlay
# record wave 17 read the level-27 row out of, so the run terminates there for a
# reason that is independent of dsd).
#
# ==== CLOSURE: THE POINTERS INSIDE THE MOUNTED BLOCKS =======================
#
# The ten CLPS blocks carry ZERO relocations -- plain data, nothing to rebase.
# The two animation descriptors carry FOUR each, all into ov035's own .rodata
# (data, not code, so the mount's pointer pass can rebase them; the ov073 case
# where the words pointed into .text and needed a seat does not arise here).
# Those eight targets are pulled in, and one of them (0x02111bfc) points at a
# ninth (0x02112064). The closure is fixed at 21 blocks / 824 bytes; running it
# again adds nothing.
#
# Note what closure does to a wrong width: under ROUTE B's 0x40 for 0x021121f8
# and 0x114 for 0x02112258 the closure pulled in FIVE MORE blocks
# (0x021122a8, 0x021122d8, 0x02112318, 0x021123ec, 0x021124e4) that nothing
# actually reads -- the over-read manufactures its own false evidence, because
# the swallowed file table's pointers look exactly like real closure. A width
# error here is not inert.
#
# ---- the two animation descriptors, and the .rodata they point at ----------
data_ov035_0211208c data_ov035_021120a4
data_ov035_02111bd0 data_ov035_02111bd4 data_ov035_02111bd8 data_ov035_02111bdc
data_ov035_02111be0 data_ov035_02111bfc data_ov035_02111c18 data_ov035_02111d84
data_ov035_02112064
#
# ---- the ten CLPS collision blocks, 0x20 each by their own headers ---------
# The two pinned explicitly are the two ROUTE A under-reads; the other eight
# would take the same 0x20 from the next-symbol delta, and are left bare so the
# diff shows exactly which widths dsd got wrong.
data_ov035_021120d8
data_ov035_021120f8:0x20
data_ov035_02112118
data_ov035_02112138
data_ov035_02112158
data_ov035_02112178
data_ov035_02112198
data_ov035_021121b8:0x20
data_ov035_021121f8
data_ov035_02112258
#
# ============================================================================
# RUN REL0215 WAVE 1 (lane cast-sweep1): OV035'S OWN CAST joins this mount.
# ============================================================================
#
# The list above is wave 18's: the twelve blocks the ov065 Ttc cluster reads
# ACROSS overlays. This section adds what ov035's OWN four actor classes reach
# by name. Nothing above is changed and nothing below overlaps it.
#
# FIRST, A CORRECTION TO WAVE 18. Nothing in the tree calls
# port_ov035_pack_check() or port_ov035_syms_patch() -- grep both across
# port/*.cpp on tip f77f01169 and the only hit is this file's own header. The
# mount emitted storage and its pointer pass had never run. It runs now, from
# port_ov35_bringup() in hal/actor_classes_ov035.cpp (the ov025/ov045
# lane-ownership shape).
#
# ==== THE CAST: FOUR IDS, NOT THREE, both attribution routes ================
#
#   id   arm9 slot   SpawnInfo   word[0]     factory                  +4   x L27
#   119  0x02090a40  0x02112aa4  0x021116bc  daObjCtMecha10_c_classInit_CT_MECHA10  119   2
#   120  0x02090a44  0x02112ba8  0x02111b98  daObjCtMecha11_c_classInit   120  13
#   121  0x02090a4c  0x02112ac0  0x0211168c  daObjCtMecha10_c_classInit_CT_MECHA12L      121   2
#   122  0x02090a4c  0x02112adc  0x0211165c  daObjCtMecha10_c_classInit_CT_MECHA12S   122   2
#
# ROUTE 1: every record's word[0] lands inside ov035's own image
# [0x021111a0, 0x02112c60) and is one of this overlay's four factory bodies.
# ROUTE 2: every record reads its own id back at +4 (the halfword the registry
# re-checks at install). Both routes are required because the level overlays
# share the load window at 0x021111a0 and the arm9 relocs' candidate lists are
# over-broad -- slot 119's reads overlays(10,18,22,24,26,29,32,35,36,45,56).
#
# ID 121 IS REAL AND IT IS OV035's. symbols/overlay_actors.md lists three
# classes for ov035, and symbols/actor_renames_report.txt resolves
# "AMBIG actor 121 ROTATING_COG_BIG: ['ov010','ov035'] -> ov010". That
# resolution is about the SYMBOL NAME at 0x02112ac0, not about the id. The
# address holds two different records in two different overlays:
#     ov010's image  0x02112ac0 = g_profile_C1_TRAP, id 36,  factory 0x02111998
#     ov035's image  0x02112ac0 = (unnamed),      id 121, factory 0x0211168c
# and arm9 slots 36 AND 121 both point there. Which one is live is decided by
# which overlay is loaded. On level 27 it is ov035's, and the class's own
# InitResources proves it: it branches on the actor id, CMP r0,#0x79 at
# 0x02111280 (0x79 = 121), to pick the id-121 model file. Two instances are
# placed on level 27 and the baseline census skips them by number.
#
# ==== THE DSD CLASS-IDENTITY SHIFT, verified by disassembly =================
#
# dsd's two vtable labels are on the wrong tables. Disassembled from
# extracted/overlays/overlay_0035.bin (T4 -- never the dsd copies):
#
#   0x0211165c daObjCtMecha10_c_classInit_CT_MECHA12S   alloc 0x330  installs 0x02112b00
#   0x0211168c daObjCtMecha10_c_classInit_CT_MECHA12L      alloc 0x330  installs 0x02112b00
#   0x021116bc daObjCtMecha10_c_classInit_CT_MECHA10  alloc 0x330  installs 0x02112b00
#   0x02111b98 daObjCtMecha11_c_classInit   alloc 0x380  installs 0x02112bcc
#                                       + ShadowModel ctor at this+0x328
#
# So THREE ids share the table dsd named _ZTV16RotatingCogSmall, and the table
# dsd named _ZTV17RotatingClockHand belongs to SPINNING_PLATFORM alone. The
# method bodies agree with the tables they sit in, not with the ids: the
# _ZN16RotatingCogSmall* bodies serve 119/121/122 and the
# _ZN17RotatingClockHand* bodies serve 120. Everything downstream is wired BY
# ADDRESS. The RTTI at vtable[-1] confirms two distinct classes:
#   0x02112b00 -> typeinfo 0x02112a84 -> name 0x02112a90 "16daObjCtMecha10_c"
#   0x02112bcc -> typeinfo 0x02112b88 -> name 0x02112b94 "16daObjCtMecha11_c"
#
# ==== BOTH WIDTHS ARE 32 AND NEITHER NAIVE READ GETS THERE =================
#
# _ZTV16RotatingCogSmall  0x02112b00, 32 slots, ends 0x02112b80.
#   next dsd symbol 0x02112b08 -- INTERIOR (slot 2). The landing reads TWO.
# _ZTV17RotatingClockHand 0x02112bcc, 32 slots, ends 0x02112c4c.
#   next dsd symbol 0x02112bdc -- INTERIOR (slot 4); 0x02112bec, 0x02112c08,
#   0x02112c18 and 0x02112c44 are interior splits too. The landing reads FOUR.
# The pin on both is the ROM's own close, read slot by slot out of
# config/arm9/overlays/ov035/relocs.txt:
#     slot 29  0x02010124  _ZN8dActor_c16OnAimedAtWithEggEv
#     slot 30  0x020100dc  _ZN8dActor_c25OnAimedAtWithEggReturnVecEv
#     slot 31  0x020ee55c  _ZN10dBgActor_c4KillEv   (ov002 symbols.txt:1175)
# the 32-slot Platform close ov025's two, ov045's six, ov052's two and ov056's
# one all end on. Both tables are EXCLUDED from this mount and hosted as
# arrays hal/actor_classes_ov035.cpp fills.
#
# ==== FIVE T3 WIDTH PINS IN .data, and each is a real mis-read =============
#
#   g_profile_CT_MECHA10  natural next-symbol delta 0x4 (dsd named
#     0x02112aa8 INSIDE the record). A record is 0x1c. Unpinned this mounts
#     FOUR bytes of a twenty-eight byte record -- and the registry's own
#     "SpawnInfo says id N" check reads +4, inside those four bytes, so it
#     would have passed while the other six words belonged to somebody else.
#   g_profile_CT_MECHA12S   natural 0x24: the usual eight bytes of the
#     next vtable's Itanium prologue past the end. Pinned back to 0x1c.
#   g_profile_CT_MECHA11   natural 0x24, same over-read, same pin.
#   g_profile_CT_MECHA12L (id 121) natural 0x1c already; pinned anyway so all
#     four records read identically in the diff.
#   data_ov035_021121d8  natural 0x4 (dsd named 0x021121dc). It is a CLPS
#     block -- 'CLPS' magic 0x53504c43, entrySize 8, count 1, 0xffffffff fill
#     out to 0x20 -- handed to MovingMeshCollider::SetFile by id 119's
#     InitResources. Unpinned: four bytes of a thirty-two byte block, and the
#     collider reads its entry count out of a second word it does not own.
#   data_ov035_02112238  natural 0x20 and already correct; the CLPS block id
#     120's InitResources passes (entrySize 8, count 2). Pinned for symmetry.
#     This is the block wave 18's ROUTE B analysis names as "the next CLPS
#     magic" while sizing 0x021121f8 -- it is a real block, it simply was not
#     in the ov065-driven seed set.
#   data_ov035_02112b80  natural 0x4 (dsd named 0x02112b84). decl_common.h
#     declares it `short []` and id 120's Behavior indexes it with
#     data_0209f2c0[0], the 0..3 selector: FOUR shorts, 0x8. The eight bytes
#     after that are the typeinfo record at 0x02112b88, which is why the pin
#     is 0x8 and not more.
#
# ==== FOUR MORE T3 PINS IN .bss ============================================
#
# .bss is 0x02112c60..0x02112ce0: four SharedFilePtrs and four destructor
# chain nodes. func_020731dc writes THREE words through its node argument
# (src/func_020731dc.c: node[0]=head, node[1]=dtor, node[2]=object), so every
# chain node is 0xc. Four of them read short from the next-symbol delta,
# because dsd named a word inside each:
#   data_ov035_02112c80  natural 0x8  (0x02112c88 named inside)  -> pin 0xc
#   data_ov035_02112ca4  natural 0x4  (0x02112ca8 named inside)  -> pin 0xc
#   data_ov035_02112cc0  natural 0x8  (0x02112cc8 named inside)  -> pin 0xc
#   data_ov035_02112ccc  natural 0x4  (0x02112cd0 named inside)  -> pin 0xc
# data_ov035_02112c8c and _02112c98 already read 0xc and are left bare, so the
# diff shows exactly which four dsd got wrong. All four SharedFilePtrs are
# eight bytes and every one reads eight from its neighbour, so none is pinned.
#
# WHICH SINIT BUILDS WHAT, read off the two matched bodies:
#   __sinit_ov035_02111f04   02112c78 file 1486 model  node 02112c80   id 119
#                            02112c68 file 1487 clsn   node 02112ca4   id 119
#                            02112c60 file 1491 model  node 02112c98   id 122
#                            02112c70 file 1490 model  node 02112c8c   id 121
#   __sinit_ov035_02111fc0   02112cb0 file 1488 model  node 02112cc0   id 120
#                            02112cb8 file 1489 clsn   node 02112ccc   id 120
#
# ==== TWO LIVE ALIAS RACES AT THE SHARED WINDOW (T6) =======================
#
# Two of the linked TUs spell ov035's own bytes with a SIBLING OVERLAY's name,
# because ov017/ov023/ov035/ov045/ov055/ov056 and the rest all link at
# 0x021111a0 and the decomp was written against whichever export won the race:
#
#   src/__sinit_ov035_02111fc0.c              data_ov045_02112cb0
#   src/_ZN16RotatingCogSmall16Cleanup....cpp data_ov056_02112c68
#
# data_ov045_02112cb0 IS DEFINED IN THIS LINK -- port/ov045_syms.txt:123 mounts
# it -- so an /alternatename with that name on the left is defeated silently,
# the R3 ov071/ov073 failure. Left alone, ov035's sinit would construct a
# SharedFilePtr over LEVEL 37's mounted data. Both spellings are routed with a
# per-source -D instead (port/CMakeLists.txt), which is the remedy T6
# prescribes. data_ov056_02112c68 happens to be undefined today and is routed
# the same way so the two cannot drift apart.

# ---- .rodata: the id-119/121/122 tuning tables ----------------------------
data_ov035_02111ef0 data_ov035_02111ef4

# ---- .data: the two CLPS blocks the InitResources bodies hand the collider -
data_ov035_021121d8:0x20 data_ov035_02112238:0x20

# ---- .data: the four SpawnInfo records, all pinned to the ROM's 0x1c ------
g_profile_CT_MECHA10:0x1c g_profile_CT_MECHA12L:0x1c
g_profile_CT_MECHA12S:0x1c g_profile_CT_MECHA11:0x1c

# ---- .data: id 120's four-short Behavior table ---------------------------
data_ov035_02112b80:0x8

# ---- .bss: four SharedFilePtrs and their four chain nodes ----------------
data_ov035_02112c60 data_ov035_02112c68 data_ov035_02112c70 data_ov035_02112c78
data_ov035_02112c80:0xc data_ov035_02112c8c data_ov035_02112c98
data_ov035_02112ca4:0xc
data_ov035_02112cb0 data_ov035_02112cb8
data_ov035_02112cc0:0xc data_ov035_02112ccc:0xc
