# Gate MG1: the FIRST MINIGAME, and the ov004 framework under it. Run link60.
#
# dScMgCurling_c, actor id 0x176 (374). The peer screening named it
# MgShuffleShell after its spawn symbol; Shuffle Shell is the localised name of
# the curling minigame and the ROM's own RTTI string at 0x0213c2d0 reads
# "14dScMgCurling_c", so both names are right and the class name is the ROM's.
#
# WHAT IS IN HERE AND HOW IT WAS DERIVED. A relocation closure from TWO roots,
# not one: the SpawnInfo record at 0x0213c214, and the class's own overlay
# constructor __sinit_ov006_021304ac. The second root is the correction this
# lane owes port/ov006_minigame_scout.txt section 5, whose per-minigame ranking
# rooted each id at its SpawnInfo alone and therefore MISSED EVERY MINIGAME'S
# STATE MACHINE: the mwcc pointer-to-member pairs live in .data and are reached
# only from .init, and the .bss tables they are copied into carry no
# relocations at all. Measured on this class:
#
#     SpawnInfo root only      ov006  17 fn   ov004  97 fn   arm9 547 fn
#     + its own .init root     ov006  48 fn   ov004 160 fn   arm9 560 fn
#
# So the scout's "19 TUs" for this minigame is really ~205 ov006+ov004 TUs.
# port/mg_fanout_costs.txt re-ranks all thirty ids on the corrected walk.
#
# THE arm9 HALF IS NOT LISTED. 558 of the 560 arm9 functions the closure
# reaches already have matched TUs in the build and come back through /OPT:REF
# for free once ov004/ov006 reference them; listing them would be a slice line
# per TU that changes nothing. The two that do not are named at the bottom.
#
# SIX BODIES IN THE CLOSURE ARE GENUINELY UNMATCHED and are therefore NOT here.
# No block in config/arm9/overlays/ovNNN/delinks.txt covers any of the six and
# no src file defines them:
#     ov004  func_ov004_020ae858  func_ov004_020b1710  func_ov004_020b2220
#     ov006  func_ov006_020e1854  func_ov006_020e1dc8  func_ov006_020e20bc
# func_ov006_020e1854 is a LIVE STATE TARGET -- it is the code word of the
# pointer-to-member pair at 0x0213c2bc -- so this class cannot reach every one
# of its own states even once the dispatch exists.
#
# AMENDED, run mg5 lane WTIMER. FOUR OF THE SIX NOW HAVE HOST COPIES, and this
# is the running count rather than a rewrite of the paragraph above. Lane CT1
# transcribed func_ov006_020e1854, lane CUR2 transcribed func_ov006_020e1dc8
# and func_ov006_020e20bc, and this lane transcribed func_ov004_020b2220 into
# unmatched/MgHud_ScaledNumber.cpp -- it is the minigame HUD's scaled number
# drawer and it was why the "Wanted!" countdown never appeared on screen.
# WHAT DID NOT CHANGE: all six are still genuinely unmatched and still belong
# out of this list. No delink block covers any of them and no src file defines
# any of them. The four host copies carry port_ names precisely so that this
# paragraph stays true.
#
# AMENDED AGAIN, run mg12 lane PANEL. THE SENTENCE ABOVE IS NOW WRONG ABOUT ONE
# OF THE SIX and this is the correction rather than a rewrite. func_ov004_020ae858
# HAS a src file defining it -- src/func_ov004_020ae858.cpp, at the bottom of this
# slice -- and it is a real decompilation off the ROM, honestly NONMATCHING at 10
# of 118 words. It is still true of that body that NO DELINK BLOCK COVERS IT:
# config/arm9/overlays/ov004/delinks.txt runs to 0x020ae5c4 and resumes at
# 0x020aea30, and the line rasteriser plus this renderer fill that gap exactly.
# So the count now reads: of the six, ONE has a matched-tier src TU of its own
# (this one, NONMATCHING), FOUR have host copies under port_ names, and
# func_ov006_020e1854 is still the live pointer-to-member state target.
#
# FOUR LINES BELOW ALSO APPEAR IN ANOTHER SLICE, and that is correct rather
# than a mistake to clean up. src/func_ov004_020adc4c.c is in slice_2d1.txt
# (the LoadFont wedge, the one ov004 body the port could already reach), and
# src/func_ov004_020adc00.c, src/func_ov004_020adc1c.c and
# src/func_ov004_020ada40.c are in
# slice_gate192.txt, where Spindrift reaches them. CMake appends both lists to
# the same target and dedupes identical absolute paths, so each is compiled
# once. They are listed here anyway because this file is a statement about
# what dScMgCurling_c's closure REACHES, and dropping a line because someone
# else already needed it would make the closure unreadable as a closure.
# ONE OF THE FOUR WAS THE SPINDRIFT MISROUTE AND IT IS ALREADY FIXED. An
# earlier version of this block called it "a known live defect" in the present
# tense, on the strength of port/ov004_ov007_2d_map.txt section 6, which still
# reads as though the fix were pending. IT IS NOT: lane A2 landed it BEFORE
# this lane started, and the fix is in this lane's own base at
# port/CMakeLists.txt:902 -- a per-source COMPILE_DEFINITIONS on
# src/func_ov081_02123910.cpp that redirects the mangled Enemy name onto
# func_020ada40, the ov002 body, with the arity derived from the ROM in the
# comment above it. A -D rather than an alias, because the ov004 TU DEFINES the
# mangled name in this binary and an /alternatename with it on the left would
# be defeated silently. So Spindrift reaches the ov002 body today and this
# slice does not change that either way.
# WHAT DOES SURVIVE IS A NOTE ABOUT THE MAP'S REASONING, not about the bug.
# Section 6 argues partly from data_ov004_020beb68 being permanently zero, and
# that premise stops being true here: _ZN11dScMgBase_cC2Ev, dScMgBase_c's base
# constructor, writes data_ov004_020beb68 = self, so once a minigame scene has
# been constructed the ov004 body's opening guard passes. It cannot fire on a
# level, where no minigame is ever constructed, so nothing about the shipped
# behaviour changes. The map file is amended in the same commit as this one.

# TWELVE LINES BELOW ARE COMMENTED OUT AND SAY "HOST-COPIED (MG2)". Run link60
# lane MG2. They are the pointer-to-member DISPATCHERS, and the port cannot
# compile any of them: mwcc's member pointer is eight bytes where MSVC's is
# four, so the tables stride wrong, the object layouts that contain one shift,
# and the call sequence is a different shape. Their bodies live in
# port/unmatched/MgBase_StateDispatch.cpp (seven, ov004, paid once for all
# thirty) and port/unmatched/MgCurling_StateDispatch.cpp (five, ov006, this
# class's), each verbatim but for the table declaration and the call.
#
# ONLY SIX OF THE TWELVE WERE NAMED BY A LINK, and the other six are silent for
# two different reasons. TWO (func_ov006_020e1214, _020e3078) declare their PMF
# table inside extern "C", so the global mangles as the plain C name the mount
# already defines. FOUR (func_ov004_020b31b4, _020b321c, _020b8714, _020b8778)
# have NO PMF GLOBAL AT ALL -- the member pointer is a field of the object -- so
# no link can ever name them and their struct layouts are wrong as well as their
# dispatch. Whoever seats the next minigame sweeps for `::*` rather than
# trusting LNK1120; the two dispatch files' headers carry the full statement.
#
# /OPT:REF IS THE REFEREE. No /include:, and the only reference edges are the
# ROM's own: the ACTOR_SPAWN_TABLE record names the factory, the ROM's vtable
# names the thirty-six slot bodies, and the ROM's .ctor names all thirty-five
# constructors. Expect a large fraction of the lines below to be dropped; see
# port/mg_fanout_costs.txt for the split, which is the honest accounting.

# ---- the overlay constructors, ALL THIRTY-FIVE ----------------------------
#
# WAS THIRTY-THREE. The two holes this list used to carry --
# __sinit_ov004_020b955c and __sinit_ov006_0213014c, which had a config symbol
# but no delink block and no source when the minigame lane wrote this -- were
# matched on the decomp's main on 2026-08-06 (f410b0822, #1116) and 2026-08-07
# (817be2263, #1150), after this branch forked at 7b2f913fe. Run link60's
# port-catchup lane brought both across by address and re-verified them here
# with tools/match.py against extracted/overlays/overlay_0004.bin (base
# 0x020ad660) and overlay_0006.bin (base 0x020bfec0) rather than taking main's
# word. hal/scene_mg.cpp runs them in ROM .init order now and its section 3 is
# rewritten to say so.
src/__sinit_ov004_020b948c.c
src/__sinit_ov004_020b955c.c
src/__sinit_ov004_020b9ad0.c
src/__sinit_ov004_020b9b24.c
# THREE DESTRUCTOR CALLBACKS THE ov004 CONSTRUCTOR NAMES BY ADDRESS. 020b955c
# passes these to func_020731dc / __cxa_vec_ctor, so they enter the slice with
# it. That is the ROM's own reference edge, not a manufactured one: the three
# src TUs already existed on this branch and were absent from the binary only
# because nothing referenced them.
src/func_ov004_020b4a70.c
src/func_ov004_020b4a7c.c
src/func_ov004_020b4aa0.c
src/__sinit_ov006_0212f4c4.c
src/__sinit_ov006_0212f52c.c
src/__sinit_ov006_0212f660.c
src/__sinit_ov006_0212f6b4.c
src/__sinit_ov006_0212fc7c.c
src/__sinit_ov006_0212fd48.c
src/__sinit_ov006_021300b0.c
src/__sinit_ov006_0213014c.c
src/__sinit_ov006_021303d0.c
src/__sinit_ov006_021304ac.c
src/__sinit_ov006_02130758.c
src/__sinit_ov006_02130a04.c
src/__sinit_ov006_02130a08.c
src/__sinit_ov006_02130df8.c
src/__sinit_ov006_02130e9c.c
src/__sinit_ov006_02130f00.c
src/__sinit_ov006_02130f64.c
src/__sinit_ov006_021311c8.c
src/__sinit_ov006_021314e4.c
src/__sinit_ov006_021318a0.c
src/__sinit_ov006_0213195c.c
src/__sinit_ov006_02131a38.c
src/__sinit_ov006_02131cd0.c
src/__sinit_ov006_02131fa4.c
src/__sinit_ov006_021322bc.c
src/__sinit_ov006_02132894.c
src/__sinit_ov006_02132970.c
src/__sinit_ov006_02132f68.c
src/__sinit_ov006_0213322c.c
src/__sinit_ov006_0213326c.c
src/__sinit_ov006_021333e0.c

# ---- ov006: dScMgCurling_c's closure, 44 TUs ------------------------------
src/d_s_mg_curling.c
src/func_ov006_020e17f8.cpp
src/_ZN14dScMgCurling_cD1Ev.cpp
# RETIRED at SLICE1: body now in src/_ZN14dScMgCurling_cD1Ev.cpp. MSVC folds the ROM destructor variants into one symbol, so only one of a class two per-function destructor TUs can be compiled.
#src/_ZN14dScMgCurling_cD0Ev.cpp
src/func_ov006_020e0694.c
src/func_ov006_020e071c.c
src/func_ov006_020e07b0.c
src/func_ov006_020e0884.cpp
src/func_ov006_020e091c.c
src/func_ov006_020e0a24.c
src/func_ov006_020e0b64.c
src/func_ov006_020e0ca0.c
# HOST-COPIED (MG2): src/func_ov006_020e0d84.cpp
src/func_ov006_020e0e18.c
src/func_ov006_020e0edc.c
src/func_ov006_020e0ff0.c
src/func_ov006_020e1100.c
# HOST-COPIED (MG2): src/func_ov006_020e1214.cpp
src/func_ov006_020e1264.c
# HOST-COPIED (MG2): src/func_ov006_020e12d0.cpp
src/func_ov006_020e13a4.c
src/func_ov006_020e1554.c
src/func_ov006_020e1608.c
src/func_ov006_020e1680.c
src/func_ov006_020e1b54.c
src/func_ov006_020e1c68.c
src/func_ov006_020e269c.c
src/func_ov006_020e26f8.c
src/func_ov006_020e285c.c
src/func_ov006_020e2868.c
src/func_ov006_020e2c08.c
src/func_ov006_020e2dbc.c
src/func_ov006_020e2eb8.c
src/func_ov006_020e2ebc.c
src/func_ov006_020e2f78.c
# HOST-COPIED (MG2): src/func_ov006_020e3078.cpp
src/func_ov006_020e3210.c
src/func_ov006_020e3250.c
src/func_ov006_020e3378.c
src/func_ov006_020e3388.c
src/_ZN14dScMgCurling_c13OnYoshiTryEatEi.cpp
src/_ZN14dScMgCurling_c6RenderEv.cpp
# HOST-COPIED (MG2): src/_ZN14dScMgCurling_c8BehaviorEv.cpp
src/_ZN14dScMgCurling_c13InitResourcesEv.cpp

# ---- ov004: the dScMgBase_c framework, 152 TUs ----------------------------
# FOUR ov004 TUs ARE DELIBERATELY ABSENT from the block below -- slots 1, 7,
# 29 and 30 -- and it is a DECLARATION CONFLICT rather than a missing body.
# src/minigames/d_s_mg_base.cpp, _020b0620.cpp and _020aeed8.cpp define their
# single parameter char*, and src/_ZN11dScMgBase_c16OnAimedAtWithEggEv.cpp defines its Obj*,
# while include/decl_common.h declares all four void* -- and every one of the
# four includes that header, so MSVC refuses each with C2733 "you cannot
# overload a function with extern C linkage". mwccarm accepts it, which is why
# the ROM built and the byte gate has no opinion. The ov004 half of this slice
# was SWEPT for the pattern rather than found one build at a time, so these
# four are all of them.
# Slots 1 and 7 are host-copied in port/unmatched/MgBase_Slot1.cpp and
# MgBase_Slot7.cpp (slot 7 ALSO carries the dropped object pointer that
# include/decl_Scene.h's empty-paren declaration of Scene::BeforeBehavior
# causes). Slots 29 and 30 were in port/unmatched/MgBase_DeclConflict.cpp
# until lane LINKMG: they now compile FROM src through tools/hostgen.py's
# HEADER_SHADOW (the header's declaration of the TU's own name is hidden
# across the include, the same route func_ov002_020cfbdc and
# _ZN8daEyBm_c10HurtPlayerEv take), so they are still not lines here -- they are
# generated objects the CMake block after SCENE_MG_SOURCES appends -- but
# they are the matched TUs and count as such. The header fixes proper are
# multi-file changes inside the byte-gated tree and are routed, not taken.
# Twenty-three of these are the base class's own vtable slots and are paid
# ONCE for all thirty minigames. Twenty of those twenty-three carried the
# inferred-stub marker and all twenty were ruled REAL_DECOMP against the ROM
# before being seated; see port/tools/inferred_stub_adjudicated.txt.
src/DrawOamSprite.cpp
src/FreeGfxSlotsById.c
src/GetGameLanguage.c
src/Hud_RenderSprite.cpp
src/Ov004_Deallocate.c
src/RenderOamBothScreens.cpp
src/RenderOamMainScreen.cpp
src/func_ov004_020aea30.cpp
src/func_ov004_020ada40.c
src/_ZN11dScMgBase_c9Virtual8CEv.cpp
src/func_ov004_020ad6f4.c
src/func_ov004_020ad6fc.c
src/func_ov004_020ad90c.c
src/func_ov004_020ad940.cpp
src/func_ov004_020ada20.c
src/func_ov004_020adafc.c
src/func_ov004_020adb1c.c
src/func_ov004_020adbc0.c
src/func_ov004_020adbe0.c
src/func_ov004_020adc00.c
src/func_ov004_020adc1c.c
src/func_ov004_020adc3c.c
src/func_ov004_020adc4c.c
src/func_ov004_020adc68.c
src/func_ov004_020adc74.c
# HOST-COPIED (MG2): src/func_ov004_020add88.cpp
# HOST-COPIED (MG2): src/func_ov004_020adf2c.cpp
# The graphics block's four forwarders, added by the DUALSCREEN lane. They
# are data_ov004_020bc03c's words 0..3 -- dScMgBase_c::graphCallback_c's
# vtable -- and each forwards into the scene's own table at +0x5c, +0x58,
# +0x60 and +0x64 (slots 23, 22, 24 and 25). Nothing referenced them before
# because the port never dispatched the block; hal/scene_mg.cpp's
# port_scene_mg_gc_seat does now, through four calling-convention adapters.
src/_ZN11dScMgBase_c15graphCallback_c14GraphCallback3Ev.cpp
src/_ZN11dScMgBase_c15graphCallback_c14GraphCallback2Ev.cpp
src/_ZN11dScMgBase_c15graphCallback_c14GraphCallback1Ev.cpp
src/_ZN11dScMgBase_c15graphCallback_c14GraphCallback0Ev.cpp
src/_ZN11dScMgBase_c8OnPushedEv.cpp
src/_ZN11dScMgBase_c8OnKickedEv.cpp
src/_ZN11dScMgBase_c11OnAttacked1Ev.cpp
src/_ZN11dScMgBase_c11OnAttacked2Ev.cpp
src/func_ov004_020ae1cc.c
src/func_ov004_020ae1f0.c
src/func_ov004_020ae20c.c
src/func_ov004_020ae274.c
src/func_ov004_020ae2c8.cpp
src/func_ov004_020ae330.c
src/_ZN11dScMgBase_c9Virtual88Eiiii.cpp
src/func_ov004_020aea78.cpp
src/func_ov004_020aeb24.cpp
src/_ZN11dScMgBase_c19OnHitFromUnderneathEv.cpp
src/_ZN11dScMgBase_c15OnHitByMegaCharEv.cpp
src/func_ov004_020af5e0.c
src/func_ov004_020af868.cpp
src/func_ov004_020af948.cpp
src/func_ov004_020afc18.cpp
src/func_ov004_020afdd0.cpp
src/func_ov004_020b04c0.c
src/func_ov004_020b04d0.c
src/_ZN11dScMgBase_c24OnHitByCannonBlastedCharEv.cpp
src/minigames/d_s_mg_base.cpp
# Run mg5, lane BASESET. src/minigames/d_s_mg_base.cpp IS EXCLUDED, host-copied in
# port/unmatched/MgBase_Slot5.cpp. It is dScMgBase_c slot 5,
# AfterCleanupResources, and it declares func_0203cbc0 with NO parameter and
# calls it with none while the ROM has the pointer being freed live in r0 at
# 0x020b0898. The port's own func_0203cbc0 is operator delete, so the src form
# frees a stack slot. This is section 6c of port/mg_fanout_costs.txt, the second
# of the two argument ride-throughs that file named and left; slot 7 is the
# first and is MgBase_Slot7.cpp. ONE CALL differs from src.
# HOST-COPIED (BASESET): src/minigames/d_s_mg_base.cpp
src/func_ov004_020b0a54.cpp
src/func_ov004_020b0b1c.c
src/func_ov004_020b0cac.c
src/func_ov004_020b0d30.c
src/func_ov004_020b0d8c.c
src/func_ov004_020b0de0.c
src/func_ov004_020b14f0.c
# Lane LINKMG: the minigame HUD's HIGH SCORE drawer is BACK as the matched TU.
# Run mg5 lane HSDISP had excluded it and host-copied it in
# port/unmatched/MgHud_HighScore.cpp with its void * parameter retyped int,
# but that retype changes no host code: the TU is plain C and its one
# parameter and func_ov004_020b1ea4's third argument are 4-byte cdecl slots
# either way. The dropped-argument defect HSDISP fixed lives in the CALLER,
# src/func_ov006_020fba48.c (s8 at both ends, an invented parameter), and
# that caller alone stays host-copied, off slice_pch.txt, tagged PORT_HOST_ABI.
src/func_ov004_020b19f0.c
src/func_ov004_020b1c68.c
src/func_ov004_020b1cf0.c
src/func_ov004_020b1d60.c
src/func_ov004_020b1ea4.c
src/func_ov004_020b2444.c
src/_ZN11dScMgBase_c9Virtual84Ev.cpp
src/_ZN11dScMgBase_c9Virtual80Ev.cpp
src/_ZN11dScMgBase_c9Virtual7CEv.cpp
src/func_ov004_020b290c.c
src/func_ov004_020b2980.c
src/_ZN11dScMgBase_c15OnGroundPoundedEv.cpp
src/_ZN11dScMgBase_c9Virtual50Ev.cpp
src/_ZN11dScMgBase_c13OnTurnIntoEggEi.cpp
src/_ZN11dScMgBase_c13OnYoshiTryEatEi.cpp
src/func_ov004_020b29a0.cpp
# RETIRED at SLICE1: body now in src/_ZN11dScMgBase_cD0Ev.cpp. MSVC folds the ROM destructor variants into one symbol, so only one of a class two per-function destructor TUs can be compiled.
#src/_ZN11dScMgBase_cD2Ev.cpp
# RETIRED at SLICE1: body now in src/_ZN11dScMgBase_cD1Ev.cpp. MSVC folds the ROM destructor variants into one symbol, so only one of a class two per-function destructor TUs can be compiled.
#src/_ZN11dScMgBase_cD0Ev.cpp
src/_ZN11dScMgBase_cD1Ev.cpp
src/_ZN11dScMgBase_cC2Ev.cpp
src/func_ov004_020b2c84.c
# func_ov004_020b2cb8 is back (run linkfull, lane RS4PORT). MG2 host-copied it
#   into port/unmatched/MgBase_LangTable.cpp for a fabricated 29-entry
#   initializer; main #1557 replaced that with the ROM's template (entry 1 =
#   {0x140, &data_ov004_020b9f54}) and the port's src is main's blob, so the
#   host copy is retired.
src/func_ov004_020b2cb8.c
src/func_ov004_020b3194.c
# HOST-COPIED (MG2): src/func_ov004_020b31b4.cpp
# HOST-COPIED (MG2): src/func_ov004_020b321c.cpp
# HOST-COPIED (MG2): src/func_ov004_020b3278.cpp
# THE TWO SLOT-12 FRAMEWORK STATES, run mg5 lane FWK. Both are dispatched
# through unmatched/MgBase_StateDispatch.cpp's address switch, which had no
# case for either until that lane added one, so a scene 366 boot reported 174
# dispatches landing nowhere. 020b35d8 is the real body of the two (0xc0 bytes,
# a drawing state); 020b3698 is one `bx lr`. Derivation, the relocs.txt rows
# for both pair words and the disassembly of both call sites are in section 5
# of that file. func_ov004_020b1aec is 020b35d8's one callee the slice did not
# already carry: a five-line reader of data_ov004_020beb68, which the slice has.
src/func_ov004_020b1aec.c
src/func_ov004_020b35d8.c
# Run mg5, lane BASESET. THE OTHER TWENTY-TWO OF __sinit_ov004_020b955c'S
# TWENTY-FOUR. Lane FWK routed two of that constructor's distinct code words
# (0x020b35d8 and 0x020b3698, the line above and its neighbour) and left
# twenty-two with the note that each would report the day a scene reached it.
# Seating the framework state setter reached SEVEN of them on the first run,
# 2561 times over a scene 378 sweep, so the whole set is routed rather than the
# seven a run witnessed. The derivation, the departure from FWK's own rule and
# the per-slot table are in port/unmatched/MgBase_StateDispatch.cpp beside the
# cases. Every one is a matched src TU with a delink block, reached from a
# ZERO-ARGUMENT slot with `this` in r0, and none needed a host copy. They are
# here rather than anywhere else because these lines are what give them a
# caller: the pair words are mounted DATA holding DS addresses, so /OPT:REF had
# dropped all twenty-two.
src/func_ov004_020b3834.c
src/func_ov004_020b3888.c
src/func_ov004_020b3b38.cpp
src/func_ov004_020b3c58.c
src/func_ov004_020b3c9c.c
src/func_ov004_020b3cb8.c
src/func_ov004_020b3e9c.c
src/func_ov004_020b4080.cpp
src/func_ov004_020b40ac.c
src/func_ov004_020b433c.c
src/func_ov004_020b4360.c
src/func_ov004_020b45c0.c
src/func_ov004_020b4820.cpp
src/func_ov004_020b484c.c
src/func_ov004_020b49b8.c
src/func_ov004_020b49e4.c
src/func_ov004_020b49f0.c
src/func_ov004_020b4a1c.c
src/func_ov004_020b4a28.c
src/func_ov004_020b4a40.c
src/func_ov004_020b4a4c.c
src/func_ov004_020b4a64.c
src/func_ov004_020b3698.c
src/func_ov004_020b40c0.c
src/func_ov004_020b410c.c
src/func_ov004_020b4214.c
src/func_ov004_020b422c.c
src/func_ov004_020b42c0.c
src/func_ov004_020b68e8.c
src/func_ov004_020b6948.c
src/func_ov004_020b6ad8.c
# HOST-COPIED (run mg9 lane BOO): src/func_ov004_020b6b40.c and
# src/func_ov004_020b6c9c.c. Both call VTABLE SLOT 19 through a shadow array
# with a plain C function pointer, so MSVC compiles the call __cdecl and
# cleans eight bytes, while hal/scene_mg.cpp's mb_v19 is __fastcall with one
# stack parameter and cleans four of them itself -- `ret 4` in the image. Four
# bytes are cleaned twice on every call, and the body's own `pop esi / pop ebp
# / ret` then reads one slot too high and returns to whatever the next stack
# word is. On scene 387 that word was inside the live scene object and the
# process executed it. THE THUNK IS RIGHT: run mg5 lane BASESET added that
# parameter after a 14-site census of offset 0x4c found an argument count of
# ONE everywhere, and the ROM at 0x020b6cf4 passes the object in r0 and the
# int in r1. See port/unmatched/MgBase_ShadowSlot19.cpp, which is these two
# bodies verbatim with the pointer spelled __fastcall.
#
# NOTHING HAD REACHED THEM BEFORE. They are per-frame ticks the FRAMEWORK
# state machine installs, and no seated scene had ever entered
# _ZN10dMgState_c8SetStateEi -- section 13 reports zero framework calls on 363 and
# section 14 the same on 380. Scene 387 is the first that does.
#src/func_ov004_020b6b40.c
src/func_ov004_020b6c10.c
#src/func_ov004_020b6c9c.c
src/func_ov004_020b6d6c.c
src/func_ov004_020b6ddc.c
src/func_ov004_020b6f14.c
src/func_ov004_020b6f88.c
src/func_ov004_020b7020.c
src/func_ov004_020b70b4.c
src/func_ov004_020b7124.cpp
src/func_ov004_020b724c.c
src/func_ov004_020b72d4.cpp
src/func_ov004_020b743c.c
# The slot 12 tail-jump veneer (`ldr ip,[pc]; bx ip; .word 0x020b743c`), back
# on this slice (run linkfull, lane ASMCPORT): main #3166 spells it with the
# pointer its callers pass, so the host copy run mg5 lane BASESET kept in
# port/unmatched/MgBase_StateSetter.cpp for the old (void) spelling is retired.
src/func_ov004_020b7460.c
src/func_ov004_020b746c.cpp
src/func_ov004_020b7594.cpp
src/func_ov004_020b75e4.c
src/func_ov004_020b7744.c
src/func_ov004_020b77b4.cpp
src/func_ov004_020b7854.c
src/func_ov004_020b78f4.cpp
src/func_ov004_020b798c.c
src/func_ov004_020b79b0.c
src/func_ov004_020b7a18.cpp
src/func_ov004_020b7b20.c
src/func_ov004_020b7b90.c
src/func_ov004_020b7c04.c
src/func_ov004_020b7cd0.cpp
src/func_ov004_020b7e38.c
src/func_ov004_020b7eac.cpp
src/func_ov004_020b7f5c.c
src/func_ov004_020b7fec.cpp
src/func_ov004_020b8098.c
src/func_ov004_020b81f8.c
src/func_ov004_020b8284.cpp
src/func_ov004_020b83ac.c
src/func_ov004_020b841c.cpp
src/func_ov004_020b853c.c
src/func_ov004_020b8560.cpp
src/func_ov004_020b8688.c
# HOST-COPIED (MG2): src/_ZN10dMgState_c6RenderEv.cpp
# HOST-COPIED (MG2): src/_ZN10dMgState_c8BehaviorEv.cpp
src/_ZN10dMgState_cC1Ev.cpp
src/func_ov004_020b8a8c.c
src/_ZN10dMgPsOpt_c11TouchIcon_c6RenderEv.cpp
src/func_ov004_020b8dc0.c
src/func_ov004_020b8ee0.c
src/func_ov004_020b8f18.cpp
src/func_ov004_020b8f78.cpp
src/func_ov004_020b91fc.c
src/func_ov004_020b9220.c
src/_ZN10dMgPsOpt_c11TouchIcon_cD1Ev.cpp
src/_ZN10dMgPsOpt_cD1Ev.cpp
src/_ZN10dMgPsOpt_cC1Ev.cpp
src/_ZN10dMgPsOpt_c11TouchIcon_cC1Ev.cpp

# ---- SECOND WAVE: 33 TUs the first link named as unresolved --------------
# The two-wave method the ov007 slice uses. These are matched TUs the closure
# reaches that the first block did not list -- 20 arm9, 7 ov004, 6 ov006 --
# and they are here because the LINKER asked for them, not because a walk
# predicted them. The arm9 ones are the exception to "the arm9 half is not
# listed" above: those 20 had no other caller in the build, so /OPT:REF had
# already dropped them and they do not come back for free.
src/IsMinigameActorID.c
src/NoOpDestructor.c
src/NullDestructor_0203d47c.c
src/SetSubBg3Offset.c
src/_ZN5Sound12PlayBank2_2DEj.cpp
src/func_02012468.c
src/func_020126ac.c
src/func_020126e8.c
src/func_02012718.c
# src/func_02012dbc.c IS A WAVE-4 ADDITION, run mg10 lane WALKER, and it is here
# for exactly the reason this block exists: the LINKER asked for it. Seating
# src/func_ov006_020d27dc.c (dScMgAmida_c's walker tick) gave it its first
# caller in the build -- the ROM has one call site for it in the whole overlay,
# at 0x020d2da0 inside that body -- so /OPT:REF had dropped it and it did not
# come back for free. It is a four-line forwarder to func_0204f9c4(0xe, a),
# which is already in this slice eight lines below, so it costs one TU and
# pulls in nothing new.
src/func_02012dbc.c
src/func_02012dd0.c
src/func_02012e1c.c
src/func_02012e78.c
src/func_02013568.c
src/func_02013580.c
src/func_02017a0c.c
# src/func_02017a24.c IS OUT, run mg9 lane PSY. It is the fifth member of the
# SharedFilePtr construct-veneer catalogue in hal/cxx_aliases.cpp and the only
# one that was still compiled from src, where it spells one parameter and drops
# the fileID the ROM rides through in r1. Three more one-argument forwarders sit
# under it before anything stores the id, so what reached the file system was a
# return address. Its four siblings -- func_02017acc, func_02017b4c,
# func_020178cc and SharedFilePtr_Construct_TexSeq -- were already host veneers
# there; this one now is too, and hal/cxx_aliases.cpp carries the measurement.
src/func_020182bc.c
src/func_02019028.c
src/func_0202ec9c.cpp
src/func_0203b958.c
src/func_ov004_020ae104.c
src/func_ov004_020b2c58.c
src/func_ov004_020b2c7c.c
src/func_ov004_020b2c80.c
src/func_ov004_020b67bc.c
src/func_ov004_020b67e0.c
src/func_ov004_020b67e4.c
src/func_ov006_020c8da8.c
src/func_ov006_020c8dcc.c
src/func_ov006_020c8dd0.c
src/func_ov006_020d0fe4.c
src/func_ov006_020d1008.c
src/func_ov006_020d100c.c

# ---- THIRD WAVE: 11 more the second link named -----------------------------
# 7 arm9 and 4 ov001. The ov001 four are REAL FUNCTIONS at those addresses
# (config/arm9/overlays/ov001/symbols.txt sizes them 0x2c, 0x34, 0x48 and
# 0xfc), which is worth saying because the star-select seat met a DIFFERENT
# ov001 case -- twelve DATA tables the decomp spelled `func_020abXXXX` -- and
# these are not that. They are ov004's touch layer: TouchArea_Update is
# 0x020ab450, which port/ov004_ov007_2d_map.txt section 9 counted among ov004's
# cross wants into ov001.
src/TouchArea_Update.c
src/func_020127ec.c
src/func_02012860.c
src/func_02017a9c.c
src/func_02017ae4.c
src/func_020182ec.c
# src/func_02018e3c.c -- OUT, run link60 lane NFS. It is a RIDE-THROUGH and
# the host cannot express it. The ROM is `push {r4,lr}; bl func_0205d644`
# with r0 (the FSFileID out pointer) and r1 (the path) carried straight
# through in registers, so the decompilation names no parameters:
# `int func_02018e3c(void) { int r = func_0205d644(); ... }`. Its caller
# func_020182bc pushes both arguments and this callee forwards neither, so on
# a cdecl host func_0205d644 reads two stack words that are not them.
# MEASURED, not read off the page: with the archive registered, the ROM's own
# walker ran the whole root directory and matched nothing, while the same two
# names resolved correctly through a call that spells both arguments
# (SM64DS_NFS_PROBE=1). hal/fs_names.cpp carries the face, and it is the same
# trade hal/fs.cpp already made for SharedFilePtr::Construct.
src/func_0204f9c4.c
src/func_ov001_020ab3f0.c
src/func_ov001_020ab41c.c
src/func_ov001_020ab5b0.c

# ---- FOURTH WAVE: 3 more, all arm9 --------------------------------------
# Under the archive and file loader the two SharedFilePtr constructors reach.
src/func_0201834c.c
src/func_02018dc4.c
src/func_02018e68.c

# ---- SIXTH WAVE: 5 more, all arm9, and the wave MG1 never ran -------------
# Run link60 lane MG2. MG1 stopped after the fifth link, the one that found the
# wall rather than more slice lines, and review's independently wired link
# predicted a sixth wave of five matched TUs plus one hosted word. Both halves
# are confirmed here by this lane's own link, which named exactly these five
# and data_0208ec74 (hosted in hal/scene_mg_faces.cpp section 1b).
#
# All five hang off src/func_0201834c.c, one of the fourth wave's three: it is
# under the archive/file loader the two SharedFilePtr constructors reach, and
# it wants the open/close pair and the allocator that pair uses.
# _ZN6Memory8AllocateEji is the one C++ name in the set. facegen refused it --
# "reverse face with 2 args: hand-write it against the cxxname_bridge
# precedent" -- and the refusal is a category error the tool cannot see from a
# symbol alone: it is not a face at all, it is a matched TU nobody had listed.
# A slice line, not a bridge.
src/FS_CloseFile.c
src/_ZN6Memory8AllocateEji.cpp
src/func_02018568.c
src/func_02018770.c
src/func_02018d48.c

# ---- THE STATE BODIES, which no wave could ever have named ----------------
# Run link60 lane MG2. These four are dScMgBase_c's own state functions, the
# targets of the eight-byte pairs __sinit_ov004_020b948c copies into
# data_ov004_020beb88 and data_ov004_020beb98. Read out of
# extracted/overlays/overlay_0004.bin at 0x020bbf4c / 0x020bbf54 / 0x020bbf5c /
# 0x020bbf64, every pair {code, 0}.
#
# NO LINK WAVE COULD HAVE FOUND THEM and port/mg_fanout_costs.txt section 5
# says why in advance: the pair words are mounted DATA holding DS addresses, so
# no host symbol named these four and /OPT:REF had dropped all of them. They
# become reachable only once the address switch in
# port/unmatched/MgBase_StateDispatch.cpp names them, which is the same commit
# that adds these lines. That is the general shape for the fan-out: A SEAT'S
# STATE BODIES ARRIVE WITH THE DISPATCH, NOT WITH THE CLOSURE.
#
# The ov006 half of the same statement needs no lines here: all twenty-four of
# dScMgCurling_c's matched state bodies were already in the ov006 block above,
# because the vtable reaches them by other routes as well.
src/func_ov004_020adc80.c
src/func_ov004_020adcc8.cpp
src/func_ov004_020addcc.c
src/func_ov004_020adeb0.c

# ---- SEVENTH WAVE: 3 more, the closure of the two blocks above ------------
# Run link60 lane MG2. The sixth wave and the state bodies brought their own
# wants, which is the two-wave method doing exactly what it does. The second
# link named six: these three matched TUs, two hosted words (data_0208eb54 and
# data_0208edf8, in hal/scene_mg_faces.cpp section 1b) and one alias
# (_ZN6Memory8AllocateEji onto the MSVC mangle of its own matched body, section
# 2d).
#   UnloadArchive        wanted by src/func_02018770.c -- NOT TAKEN, faced
#                        instead; see below and hal/scene_mg_faces.cpp 2e
#   func_ov004_020b1b40  wanted by src/func_ov004_020addcc.c, a state body
#   func_0203d630        wanted by src/func_ov004_020adeb0.c, a state body
# The last two are the cost of reaching the states at all, and they are the
# first evidence of what the fan-out pays for a dispatch: the state bodies are
# not leaves. func_ov004_020b1b40 then wanted func_ov004_020b1ba0, which is the
# eighth wave's whole remainder and is here too.
#
# UnloadArchive IS FACED RATHER THAN LINKED, and the argument is not this
# lane's -- it is hal/scene_boot.cpp's, already made for LoadArchive and
# quoted here so the two stay one decision. Its body walks data_0208ecf4, the
# ROM's 13-entry archive-mount table WHOSE ENTRIES ARE DS STRING POINTERS, and
# calls func_02018908 into the card loader under it. The scene-1 seat looked at
# exactly that and declined: hosting a pointer-bearing ROM table to drive a
# mount the fs seam ignores is "a fake, not a fix". The port never mounts an
# archive, because hal/fs.cpp resolves archive-interior file ids lazily, so
# there is nothing for an unmount to undo.
src/func_0203d630.c
src/func_ov004_020b1b40.c
src/func_ov004_020b1ba0.c
# ---- BASESET WAVE 2 ----
# Run mg5, lane BASESET. The linker's own answer, which is the second wave
# port/slice_ov007.txt's two-wave method predicts and port/mg_fanout_costs.txt
# section 2 says to budget for. Routing the twenty-two framework state bodies
# above gave them a caller for the first time, and their own callees had none
# either. Nothing here was derived by a closure walk; each line is a symbol the
# link named, checked to have a matched src TU and a delink block before it was
# added.
src/func_ov004_020b37f0.c
src/func_ov004_020b39a4.c
src/func_0203d704.c
# Run mg5, lane BASESET, WAVE 3. The rest of the ov004 member-pointer
# universe (section 8 of port/unmatched/MgBase_StateSetter.cpp bounds it at
# sixty installs plus the setter's own twenty) and the two ordinary callees
# the linker asked for once they had a caller. Every line is a matched src TU
# with a delink block; none of them had a caller in the build before, because
# the pair words are mounted DATA holding DS addresses and /OPT:REF drops a
# body nothing names.
src/func_ov004_020b369c.c
src/func_ov004_020b37c4.cpp
src/func_ov004_020b38ac.c
src/func_ov004_020b3978.cpp
src/func_ov004_020b4aa4.c
src/func_ov004_020b4c30.c
src/func_ov004_020b4d50.c
src/func_ov004_020b4dfc.c
src/func_ov004_020b4f44.c
src/func_ov004_020b4ff0.c
src/func_ov004_020b5288.cpp
src/func_ov004_020b5334.c
src/func_ov004_020b51e4.c
# Run mg7, lane L369, WAVE 4. THE FIFTH OF THE SIX GENUINELY-UNMATCHED BODIES
# THIS FILE'S HEADER NAMES IS NOT UNMATCHED ANY MORE, and unlike the four host
# copies the amendment above records, this one is a real decompilation:
# src/func_ov004_020b1710.c byte-matches at mwccarm 1.2/base, 1.2/sp2 and
# 1.2/sp2p3 and carries its own delink block in
# config/arm9/overlays/ov004/delinks.txt, so it is an ordinary slice line and
# not a port_ host copy.
#
# It is the minigame HUD's mode-aware value drawer: the timer layout for game
# mode 5 (minutes, the language-table separator sprite, hundredths), the
# two-sprite label at x 0x58/0x68 for modes 1, 2 and 4, and the four-pixel
# shift plus the other drawer for mode 3. hal/scene_mg_faces.cpp's trap for it
# is DELETED in the same commit, which is why this line is not optional on any
# target that compiles the faces: the symbol is no longer defined anywhere
# else. A 3000-frame boot of scene 369 alone entered that trap 5657 times.
src/func_ov004_020b1710.c
# Run mg10, lane F371. THE SIXTH OF THE SIX GENUINELY-UNMATCHED BODIES THIS
# FILE'S HEADER NAMES IS NOW SEATED, and it is the one that was hiding a live
# host-ABI defect nobody could reach.
#
# func_ov004_020ae5c4 is the family's LINE RASTERISER: a Bresenham walk from
# (x0,y0) to (x1,y1) that stamps vtable slot 34 at every lattice point. Slot 34
# is the BRUSH -- the base's own body, src/_ZN11dScMgBase_c9Virtual88Eiiii.cpp at line 261
# above, writes an n-by-n block of `val` through MultiCopy_Int -- so the pair is
# "draw a line of thickness n in colour val", and the amidakuji board is drawn
# with it: four vertical rails at x = 0x20, 0x60, 0xa0, 0xe0 and horizontal
# rungs (x,y) -> (x+0x40,y), from src/func_ov006_020d3ba0.c.
#
# THE LINE IS NOT OPTIONAL ON ANY TARGET THAT COMPILES THE FACES, for
# func_ov004_020b1710's reason above: hal/scene_mg_faces.cpp's trap for this
# symbol is DELETED in the same commit and the symbol is defined nowhere else.
# Seven ov006 TUs across the family call it.
#
# AND SEATING IT MAKES SLOT 34 REACHABLE FOR THE FIRST TIME IN PORT HISTORY.
# This body is the tree's ONLY slot-34 dispatcher (eight `ldr Rd,[Rn,#0x88]`
# sites, all inside it, each with one word pushed before the blx). While it was
# trapped, hal/scene_mg.cpp's shared mb_v34 could declare the five-parameter
# base body with ONE parameter and call it with one argument and never be
# convicted. That thunk is repaired in the same commit, witnessed by a run.
#
# It is a .c compiled as C++ (a //cpp marker and a dummy 35-virtual struct is
# how the slot-34 dispatch is spelled), so it carries a LANGUAGE CXX row in
# port/CMakeLists.txt beside this slice's other C++ .c files.
src/func_ov004_020ae5c4.cpp

# Run mg12, lane PANEL. THE LAST OF THE SIX GENUINELY-UNMATCHED BODIES THIS
# FILE'S HEADER NAMES IS SEATED, and it is the one the owner has been reporting
# as "the play-again buttons never appear".
#
# func_ov004_020ae858 is the RESULTS PANEL's label renderer. It reads the three
# button labels out of three language-indexed tables (data_ov004_020bc020,
# data_ov004_020bbfbc, data_ov004_020bbfd0, all mounted by port/ov004_syms.txt),
# walks each label's 8-byte glyph records to the 0xffff terminator, and draws the
# selected one through a uniform 2x2 scale matrix built from
# 1 / (1.0 + sin(self->timer)/2) so the highlighted button pulses. Both arms then
# draw *data_ov006_021346bc -- the shared plate, mounted by port/ov006_syms.txt --
# at the same spot.
#
# IT IS THE WHOLE DRAW AND IT IS NOT OPTIONAL. dScMgBase_c::BeforeRender
# (src/minigames/d_s_mg_base.cpp) hands the ENTIRE frame to this body while the
# panel is up and returns 0, so nothing else in the family submits the buttons.
# hal/scene_mg_faces.cpp's trap for this symbol is DELETED in the same commit and
# the symbol is defined nowhere else.
#
# THE SIGNATURE IS VOID, not int. The ROM body sets r0 on no path that falls
# through; the trap's int was never the ROM's. include/decl_common.h is corrected
# in the same commit.
#
# HONESTLY NONMATCHING: 10 of 118 words differ at mwccarm 2004/b56 (closest of all
# 25 installed builds) on the base-materialization/addressing floor. Every reloc
# and the whole literal pool are identical. The banner in the TU carries the
# measurement and the ~170-candidate lever sweep behind it.
src/func_ov004_020ae858.cpp
