# Lane S75, run mg6: dScMgCurling2_c, actor id 0x177 (scene 375) -- the ADVANCED
# half of the curling pair whose basic half is scene 374, and the seventh ov006
# minigame class the port seats.
#
# ---- THE IDENTITY, AND THE ONE THING THE ROM DOES NOT SAY -----------------
#
# THE CLASS NAME IS THE ROM'S. The word before vtable slot 0 --
# data_ov006_0213c510[-1] = 0x0213c4bc -- is an mwcc typeinfo record whose three
# words are {0x0209a764 the __si_class_type_info vptr, 0x0213c4c8 the name,
# 0x020bbf6c the base}, and the bytes at 0x0213c4c8 read "15dScMgCurling2_c".
# The control is one table down: 0x0213c2c4 has the identical shape and names
# "14dScMgCurling_c" for the vtable at 0x0213c304, which is scene 374's. Both
# records carry the SAME base pointer, ov004's 0x020bbf6c, so this class's
# hierarchy is two deep and not three:
#
#     Scene -> dScMgBase_c (data_ov004_020bc0c0) -> dScMgCurling2_c (0213c510)
#
# There is no intermediate table to fill, which is the difference between this
# seat and dScMgFlower_c's and dScMgCup_c's.
#
# THE SPAWNINFO IS 0x0213c434 AND THE FACTORY IS 0x020e6bf4, derived by
# port/mg_fanout_costs.txt section 3's mechanical recipe: scan
# extracted/overlays/overlay_0006.bin for the doubled-id word 0x01770177 and
# take the word before it. It occurs EXACTLY ONCE in the overlay, at 0x0213c438,
# so the record is 0x0213c434 = {0x020e6bf4, 0x01770177} and there is no second
# candidate to choose between.
#
# THE PLAYER-FACING TITLE IS "SHELL SMASH", AND THE TREE ALREADY NAMED IT.
# The arm9 spawn table ACTOR_SPAWN_TABLE holds one record pointer per actor id;
# entry 0x177 sits at 0x02090e40 and holds 0x0213c434, which is this class's
# SpawnInfo, and config/arm9/overlays/ov098/symbols.txt:113 names that record
#
#     MgShellSmash_SpawnInfo kind:data(any) addr:0x0213c434 ambiguous
#
# It predates this lane -- it arrived with the 2026-07-10 spawn-table naming
# import (#211) -- and it is filed under ov098 rather than ov006 because the
# two overlays OVERLAP that address, which is what the `ambiguous` flag on the
# row records. THAT IS WHY THIS LANE DID NOT FIND IT AT FIRST and it is the
# method correction worth carrying forward: a sweep of ov006's own symbols.txt
# for Mg* spawn names cannot find a symbol filed under another overlay. Sweep
# the whole config for the ADDRESS, not one overlay for the name.
#
# THE ADDRESSING IS CHECKED RATHER THAN ASSUMED, and by controls rather than by
# arithmetic. The two neighbouring entries in the same table are
#
#     entry 0x176 at 0x02090e3c -> 0x0213c214   g_profile_MG_CURLING
#     entry 0x178 at 0x02090e44 -> 0x0213ebd0   g_profile_MG_SMARTBALL
#
# and both are exactly the addresses port/mg_fanout_costs.txt section 4 and
# section 11 independently give those two classes. Two known-good neighbours
# either side is a stronger check on the indexing than the multiplication is.
#
# AND THE ROM ITSELF STORES NO TITLE TEXT AT ALL. That is a separate finding
# and it survives the citation above rather than being replaced by it: a search
# of the whole 16 MB image for the ASCII and the UTF-16LE spelling of
# "Shuffle", "Trampoline", "Wiggler", "Bob-omb" and "Memory Ma" returns ZERO
# hits each; the five EUR language archives (ARCHIVE/cee|cef|ceg|cei|ces.narc)
# hold only battle-mode and option-screen tile sheets; data/DSMT/EUR/
# texBank_E.bmd holds the title and file-menu textures and nothing
# minigame-shaped; and MG/d_2d_mg_common_* (the one per-language MG sheet)
# decodes to "RULES", "TIME" and "HIGH SCORE". So NO lane can read a title out
# of this image, and every title in this port comes from the config. The right
# move when a title is missing is to search the config harder, not the ROM.
#
# THE HEADLINE OF THAT PARAGRAPH IS WRONG AND THE ADVICE IN IT IS RIGHT, run
# mg9 lane S371. The ROM stores every one of the thirty-six titles, and what
# defeated the search was TWO layers rather than one:
#
#   1. data/message/msg_data_eng.bin (NitroFS file id 643) is LZ77-COMPRESSED,
#      so no plaintext of any kind survives a raw image sweep.
#   2. The BMG inside it is not ASCII and not UTF-16. It is a GLYPH INDEX:
#      'A'..'Z' at 0x0a..0x23, 'a'..'z' at 0x2d..0x46, space 0x4d, '-' 0x47,
#      '.' 0x48, apostrophe 0x49, '?' 0x26, '!' 0x27, ',' 0x24, 0xfd a line
#      break and 0xff an end of message.
#
# So a sweep for the ASCII and the UTF-16LE spelling of "Shuffle" returns zero
# hits with the word sitting in the file, which is exactly what this paragraph
# measured and exactly why it drew the wrong conclusion from it.
#
# THE CHAIN, so it can be redone: the ov005 launch table row for the id gives a
# packed param; (param >> 0x10) & 0xff indexes data_ov004_020bc070, a table of
# 36 shorts in ov004, which gives a BMG message id; the message's first line is
# the title and the rest is its rules text. Decoded over all 36 rows it agrees
# EXACTLY with the config's own spawn symbol on all 25 rows that have one --
# including all three COMPOUND names splitting across their two rows
# (MgBingoBallSlotsShot -> "Bingo Ball" and "Slots Shot",
# MgPuzzlePanelPuzzlePanic -> "Puzzle Panel" and "Puzzle Panic",
# MgCoincentration -> "Coincentration" and "Intense Coincentration") -- and it
# names the seven ids that have no config symbol at all. This class's own
# "Shell Smash" comes back out of it, which is the control that matters here.
#
# THE ADVICE STANDS. The config is still the cheaper place to look and the
# ADDRESS sweep this file prescribes is still the right first move; the ROM is
# now a second source rather than a dead end. port/slice_s371.txt has the full
# derivation and the 25-way control.
#
# THE ASSET EVIDENCE CORROBORATES THE NAME AND IS KEPT FOR THAT REASON:
#
#   1. The class loads "/MG/d_2d_mg_bg_jokyu_curling_ncg.bin" -- the literal at
#      data_ov006_0213c5a0 that slot 0 hands to func_020adc74. JOKYU is the
#      developers' romanisation of the Japanese for ADVANCED, and it is the
#      overlay's own consistent marker for the harder half of a pair: the same
#      MG directory carries thum_shinkei/thum_jokyu_shinkei,
#      thum_trampoline/thum_jokyu_trampoline, thum_monte/thum_jokyu_monte and
#      thum_pachinko/thum_jokyu_pachinko.
#   2. In every pair where BOTH ids already carry a config spawn symbol, the
#      plain class is the first title and the *2 class is the second:
#        dScMgJump_c/dScMgJump2_c             Bounce and Pounce / and Trounce
#        dScMgTrampoline_c/dScMgTrampoline2_c Trampoline Time / Trampoline Terror
#        dScMgMemory_c/dScMgMemory2_c         Memory Match / Memory Master
#        dScMgPachinko_c/dScMgPachinko2_c     Bob-omb Squad / Lakitu Launch
#        dScMgMCarlo_c/dScMgMCarlo2_c         (Pair-a-Gone) / Pair-a-Gone and On
#      dScMgCurling_c is MgShuffleShell, so dScMgCurling2_c is the other half,
#      and MgShellSmash_SpawnInfo says which half by name.
#
# So the title is a CONFIG READ reached by ROM-verified addressing, with the
# asset naming agreeing independently. Everything else in this file is a
# straight ROM read.
#
# ---- THE WIDTH IS 36, ALL THREE CHECKS ------------------------------------
#
#   1. SPAN     data_ov006_0213c510 -> data_ov006_0213c5a0 in
#               config/arm9/overlays/ov006/symbols.txt: exactly 36 words.
#   2. SLOT 35  0x020ad660, the dScMgBase_c-derived terminal.
#   3. WORD 36  0x2f474d2f. Curling's control word is the same four bytes and
#               port/mg_fanout_costs.txt section 11 calls it "ASCII /MG/ -- a
#               file path". Here it is sharper than that: 0x0213c5a0 IS this
#               class's own path string, the one slot 0 opens the scene with.
#               A 37-slot fill would overwrite "/MG/" in the filename the class
#               needs on its first frame.
#
# AND THE SECTION-11 NEIGHBOUR HAZARD IS MEASURED RATHER THAN ASSUMED, because
# this table sits closer to curling's live data than any other class's does.
# Curling's vtable is 0x0213c304 and its 25 source pairs span
# 0x0213c1e4..0x0213c2bc; this table starts 0x20c words above the top of that
# span, so no fill of 36, 37 or even 100 words from 0x0213c510 can reach it.
# The hazard runs the other way and is also absent: this class's OWN 25 source
# pairs span 0x0213c3d4..0x0213c4b4, which ends 0x5c bytes BELOW slot 0, so the
# fill cannot touch its own constructor's inputs either.
#
# ---- THE STATE MACHINE: SEVEN TABLES, 25 SLOTS, ONE FLOOR -----------------
#
# __sinit_ov006_02130758 is this class's overlay constructor and its copied
# .data range brackets the SpawnInfo exactly the way section 4 says curling's
# does: the 25 source pairs run 0x0213c3d4..0x0213c4b4 and 0x0213c434 sits in
# the gap between the pairs at 0x0213c42c and 0x0213c43c. IT IS NOT SWEPT. Every
# pair below is the one the constructor NAMES, one assignment at a time, which
# is the only safe way to read this range.
#
#   table                n  arity  dispatched by
#   -------------------  -  -----  --------------------------------------------
#   data_ov006_02141978  2    0    func_ov006_020e6354
#   data_ov006_02141988  3    1    func_ov006_020e4800
#   data_ov006_021419a0  3    1    _ZN15dScMgCurling2_c9StepXAndYEi  (its second table)
#   data_ov006_021419b8  4    1    _ZN15dScMgCurling2_c9StepXOnlyEi
#   data_ov006_021419d8  4    1    func_ov006_020e6354  (its second table)
#   data_ov006_021419f8  4    1    _ZN15dScMgCurling2_c9StepXAndYEi
#   data_ov006_02141a18  5    0    _ZN15dScMgCurling2_c8BehaviorEv  (vtable slot 6)
#
# ALL 25 ADJUSTMENT WORDS ARE ZERO, read out of the image pair by pair.
#
# THE ARITY COLUMN IS NOT stategen's. stategen REFUSED this constructor --
# "no src TU declares data_ov006_02141a18 as a typed member-pointer array" --
# because the TU that dispatches it spells the pair as two plain ints. Forcing
# --arity 0 to get past the refusal produces the right ADDRESSES and the WRONG
# arity for five of the seven tables, and a switch built from that output would
# have dropped the index argument at nineteen of the twenty-five call sites.
# The arities above are read off the ROM instead -- 0x020e42b4 sets `mov r1,r5`
# before both of its `blx r2`, 0x020e4744 lets the incoming r1 ride through --
# and they agree with the matched src signatures at all 24 bodies that have one.
#
# ALL THREE OF THIS CLASS'S FLOORS ARE RETIRED, run mg7 lane L375. They were
# 0x020e4bd4 (slot 1 of data_ov006_02141978, a live state the address switch
# reported instead of calling), 0x020e513c and 0x020e5450 (both reached from
# bodies in this slice and neither in it). All three are now decompiled from
# extracted/overlays/overlay_0006.bin and are in the list below; all three ship
# NONMATCHING-bannered with the ROM read stated in the file header.
#
#   src/actors/dScMgCurling2_c.cpp   0x300  the stylus aim state; SIZE EXACT
#                                      192/192 words, register colouring only
#   src/func_ov006_020e513c.c   0x314  overlap depenetration over the eleven
#                                      0x30-stride shell records
#   src/func_ov006_020e5450.c   0x560  the shell-vs-shell elastic collision --
#                                      the body mg6's 1200-frame run asked for
#                                      6810 times with nothing behind it
#
# AND THE VENEER LANDMINE IS DEFUSED. src/func_ov006_020e5b70.c is the image's
# `ldr ip,[pc]; bx ip; .word 0x020e5450` tail jump; it used to declare the
# callee `(void)` and call it with no arguments, which was harmless only while
# 0x020e5450 was a port trap that ignored its parameters. It now takes
# (char *, int) and forwards both, and mwccarm 1.2/sp2p3 emits the SAME THREE
# WORDS either way, so the fix is a byte-gate-clean src correction and no host
# copy of the veneer is needed. The dispatch site in
# unmatched/MgCurling2_StateDispatch.cpp was dropping the arguments too and is
# fixed with it -- one half alone would not have been enough.
#
# ---- WHAT IS NOT IN THIS FILE ---------------------------------------------
#
# THE arm9 AND ov004 HALVES. Section 5's ruling and curling's precedent: the
# closure reaches them, they already have matched TUs in the build, and
# /OPT:REF brings them back for free the moment ov006 references them. Measured
# on this class rather than assumed -- of the 78 ov004/ov006 TUs the call
# closure reaches from the two roots, 29 are ALREADY defined in
# build/port/walk_window.map before this lane changed a line, and all 29 are
# ov004 or shared-ov006 bodies curling and the five other seated classes paid
# for. The 49 that are new are every one of them inside this class's own code
# block, 0x020e3854..0x020e6bf4.
#
# THE FIVE DISPATCHING TUs. They are host-copied in
# unmatched/MgCurling2_StateDispatch.cpp and are therefore OUT of the list
# below, which is the same trade MG2 made five times for curling. Listing them
# here as well would be a duplicate symbol.
#     src/_ZN15dScMgCurling2_c8BehaviorEv.cpp   slot 6 Behavior, table 02141a18
#     src/func_ov006_020e6354.cpp   tables 02141978 and 021419d8
#     src/actors/dScMgCurling2_c.cpp   table 02141988
#     src/actors/dScMgCurling2_c.cpp   tables 021419f8 and 021419a0
#     src/actors/dScMgCurling2_c.cpp   table 021419b8
#
# WHY ALL FIVE AND NOT JUST THE ONE THE LINK NAMES. port/mg_fanout_costs.txt
# section 4's rulebook corollary keys on the SPELLING: a pair whose consumer
# names a member-pointer type needs a host copy whether it is called or only
# copied. Four of the five name one (`typedef void (C::*PMF)(int);`), and two
# of those four declare it inside extern "C" so the global mangles as the plain
# C name the mount already defines and the LINK NEVER COMPLAINS. The fifth,
# 020e683c, names no member-pointer type at all and open-codes the Itanium
# sequence in plain ints -- lane FLW's third shape, which neither the link nor
# a `::*` sweep can see and only a run convicts.
#
# ONE LINE THE mg6 CLOSURE COULD NOT HAVE PREDICTED: src/_ZN15dScMgCurling2_c10SpawnValueEii.c.
# It is the contact-effect spawner, and BOTH of the newly decompiled collision
# bodies end their hit path with _ZN15dScMgCurling2_c10SpawnValueEii(c, idx, i). Nothing in the
# mg6 seat referenced it, because the two things that would have were the port
# traps and a trap calls nothing -- so the first link after the real bodies
# landed closed to LNK1120 on exactly this one symbol, in all three targets that
# host the slice. Its own callees (func_ov004_020adb1c, func_ov004_020adbc0) are
# already linked through port/slice_mg1.txt, so the line costs one TU. THE
# GENERAL POINT IS WORTH MORE THAN THE LINE: a trap-shaped floor hides its
# callees from every static closure the port has, so retiring a floor can widen
# the slice, and the widening only shows up at link time.
#
# ---- THE PADDLE DREW FROM ANOTHER OVERLAY'S BYTES (run mg8, lane SGX) --------
#
# The owner played this scene on the mg7 build and reported "I cant see the
# paddle if im suposed to". He is supposed to: it is the cue bar the aim state
# moves, and it was never being drawn.
#
# WHAT DRAWS IT. Slot 9 Render (_ZN15dScMgCurling2_c6RenderEv) calls six bodies and the
# last is src/actors/dScMgCurling2_c.cpp, eight lines: gate on the cue-visible byte
# at +0x55b9, read the cue's x at +0x5584 and y at +0x5588 -- the two fields
# _ZN15dScMgCurling2_c10DragUpdateEv, the stylus aim state this file's floor section named,
# writes -- and hand ONE OamAttr template to func_ov004_020afdd0 at
# (x >> 12) - 0x20, (y >> 12) - 8. The -0x20 is half of 64, which is the first
# thing that says the template is a 64-wide pair.
#
# THE TEMPLATE IT NAMES IS data_ov098_0213c4f0 AND THAT IS THE WRONG OVERLAY.
# 0x0213c4f0 has two occupants and both configs are right about their own image:
#
#   config/arm9/overlays/ov006/relocs.txt:3577
#     from:0x020e4bd0 kind:load to:0x0213c4f0 module:overlay(6)
#   config/arm9/overlays/ov098/relocs.txt:143
#     from:0x021388b4 kind:load to:0x0213c4f0 module:overlay(98)
#
# 0x020e4bd0 is func_ov006_020e4b78's OWN literal pool word -- the body runs
# 0x020e4b78..0x020e4bd4 -- so the load is internal to ov006 and dsd tagged it
# overlay(6) with no ambiguity flag. This is the same shape as the SpawnInfo
# trap at the top of this file: a symbol filed under ov098 for an address that
# is ov006's when ov006 is the overlay running. Sweep the config for the
# ADDRESS, not one overlay for the name.
#
# THE BYTES, read at each overlay's own OVT base out of extracted/overlays/:
#   ov006 (base 0x020bfec0)  80004000 00001008 80204000 0000100c
#     two OAM entries {0x4000,0x8000,0x1008} and {0x4000,0x8020,0x100c}: 32x16,
#     16-colour, palette 1, PRIORITY 0, tiles 0x008 and 0x00c, at x = 0 and
#     x = 0x20. A 64x16 bar. Scene 374's bumper is the same pair -- 32x16,
#     palette 1, priority 0, tiles 8 and 12 -- in its engine-B OAM, measured
#     with SM64DS_PPU_AUDIT, so a second scene corroborates the shape.
#   ov098 (base 0x02137be0)  00014000 00014000 00014000 0000f000
#     ov098's cannon data. Its first entry reads as a 16x8 sprite on TILE 0,
#     and tile 0 in this scene's OBJ VRAM is entirely transparent, which is why
#     the symptom was a missing paddle rather than a garbled one.
#
# WHY THE PORT LINKED THE WRONG ONE. ov098 is in PORT_ACTOR_OVERLAYS and is
# mounted, so data_ov098_0213c4f0 is a real host global and the reference
# resolved cleanly. Nothing in the link, the map or the byte gate can see it:
# both names exist, both are defined, and the wrong one is a quiet frame.
#
# FIXED port-side with a per-source COMPILE_DEFINITIONS in port/CMakeLists.txt,
# following run link60 lane A2's ov002/ov004 precedent -- and a -D rather than
# an /alternatename for A2's reason, that the ov098 name is DEFINED in this
# binary and an alias with a defined symbol on the left is defeated silently.
# Proof: scene 375's stacked capture gains 3736 host pixels at DS y 168,
# x 96..159, which is the bar, and no other scene moves.
#
# THE SRC TU'S OWN SPELLING IS A DECOMP DEFECT AND IS NOT FIXED HERE.
# src/actors/dScMgCurling2_c.cpp should name data_ov006_0213c4f0; the reloc row above
# is the whole argument and the two names share an address so no byte moves.
# ROUTED, because this is a port lane. A sweep of the other ov006 sources found
# five more files carrying a non-ov006 data name -- func_ov006_020cb16c,
# 020cd12c, 020cd6f4, 020d5e5c and 0210a708 -- none of them on a curling path,
# none of them checked by this lane, all of them the same question.
#
# ---- THE 48 LINES -----------------------------------------------------------
# UN-QUARANTINED, run link100 lane HOSTGEN2. unmatched/MgCurling2_StateDispatch.cpp
# host-copied _ZN15dScMgCurling2_c9StepXAndYEi and _ZN15dScMgCurling2_c9StepXOnlyEi
# out of this TU; both are commented out there now, because all four of this
# class's dispatch tables are seated with host addresses whose faces are
# __fastcall with a dead edx -- the shape MSVC's own member-pointer call makes
# under the /vmg /vmm pair -- so the matched TU's dispatch is already right.
src/actors/dScMgCurling2_c.cpp
# HELD, run link100 lane HOSTGEN2: main's consolidated TU above defines
# func_ov006_020e513c as well, and this file is the port's own NONMATCHING
# decompile of the same address. Taking both is a duplicate symbol, and the
# matched tree's body is the one to keep.
#src/func_ov006_020e513c.c
src/func_ov006_020e5450.c
src/func_ov006_020e59b0.c
src/func_ov006_020e5a0c.c
src/func_ov006_020e5b70.c
src/func_ov006_020e5b7c.c
src/func_ov006_020e5e3c.c
src/func_ov006_020e5ffc.c
src/func_ov006_020e6118.c
src/func_ov006_020e619c.c
src/func_ov006_020e61c0.c
src/func_ov006_020e61c4.c
src/func_ov006_020e628c.c
src/func_ov006_020e64e4.c
src/func_ov006_020e6528.c
src/func_ov006_020e667c.c
src/func_ov006_020e668c.c
src/_ZN15dScMgCurling2_c13OnYoshiTryEatEi.cpp
src/_ZN15dScMgCurling2_c6RenderEv.cpp
src/_ZN15dScMgCurling2_c13InitResourcesEv.cpp
src/d_s_mg_curling2.c
