ov006 and the Player state machine: where the seam actually is
==============================================================

Written for run linkw wave C, lane cat-ov006, at 459f21a07. Everything
below was read out of this worktree's own config, this worktree's own
extracted/ images, and this worktree's own walk_window.map (baseline
4888/11243 linked, battery ALL GREEN, exe sha256 27a7069b...).

The lane was briefed to seat "a large slab of Player state-machine
bodies (_ZN6Player St_* methods)" out of ov006. That slab is not in
ov006. This file is the evidence for that, plus the map of where the
player's dispatch really runs, so the next lane does not re-derive it.


0. THIS IS A REDISCOVERY. Main already fixed it
-----------------------------------------------

Commit 93a666154 (#1336, 2026-08-09, Andrew) moved St_Null_Init and
St_WallJump_Init off ov006's bytes onto the ov002 functions at the same
shared addresses, and St_InYoshiMouth_Cleanup went with them. Same
three addresses, same reasoning, six days before this lane ran.

This lane's base (459f21a07) predates that merge, so the config in this
worktree still shows the old names and everything in section 1 below
describes the PRE-#1336 state. On current main:

    ov006 carries exactly ONE _ZN6Player symbol,
      _ZN6Player29TryExitCharacterDoorWithIntroEv at 0x020ca78c
    ov002 carries 175 _ZN6Player*St_* symbols, including all three
      disputed addresses:
        func_ov006_020cac30            0x020cac30  size 0x8
        func_ov006_020d6084 0x020d6084  size 0x34
        func_ov006_020e17f8        0x020e17f8  size 0xb0
    the ov006 bodies at those addresses are now
      src/func_ov006_020cac30.cpp, src/actors/dScMgBomroom_c.cpp and
      src/func_ov006_020e17f8.cpp

MAIN GOT IT RIGHT AND THE PORT'S COMMENT HAS IT BACKWARDS. See section
1's closing note: the byte evidence gathered here sides with #1336, not
with the port's own annotation. The value left in this file is the seam
description in section 3 and the rebase hazard in section 6.


1. Pre-#1336: ov006 held six _ZN6Player names, three of them misnamed
---------------------------------------------------------------------

config/arm9/overlays/ov006/symbols.txt AT THIS LANE'S BASE, complete
list of _ZN6Player symbols (grep -c gives 6):

    _ZN6Player29TryExitCharacterDoorWithIntroEv  0x020ca78c  0x2c
    func_ov006_020cac30                   0x020cac30  0x6c
    func_ov006_020d6084        0x020d6084  0x14
    func_ov006_020e17f8               0x020e17f8  0x5c
    _ZN19cMgSmartball_slot_c14RestoreInitialEv                          0x02110154  0x68
    func_ov006_02110244                           0x02110244  0x27c

Three of those six carry a header in their own matched source saying
they are not Player methods at all:

  src/actors/dScMgBomroom_c.cpp -- writes this+0x62ad
    and this+0x62af. sizeof(Player) is 0x768. "the Player name is a
    community label applied to the wrong overlay's bytes."
  src/func_ov006_020e17f8.cpp -- reads this+0x4eb0/0x4eb4/
    0x4ee5, ~0x4700 past the end of a Player.
  src/_ZN6Player29TryExitCharacterDoorWithIntroEv.cpp -- constructor
    shape (base call, vptr store, member ctor at this+0x78), not a
    state handler.

A fourth, src/func_ov006_020cac30.cpp, reads data_ov006_021405bc
and walks an array of 0xdc-byte records at data_ov006_02140554. That is
ov006's own storage, not Player's.

port/hal/player_bridges.cpp:467 makes the opposite call for the same
three slots, saying the ov002 functions there are plain functions and
the St_ names belong to ov006. AN EARLIER DRAFT OF THIS FILE QUOTED
THAT APPROVINGLY. That was wrong, and the byte evidence collected here
is what refutes it.

ov002 lays the Null triple out as three eight-byte stubs:

    0x020cac20  _ZN6Player15St_Null_CleanupEv  size 0x8
    0x020cac28  _ZN6Player12St_Null_MainEv     size 0x8
    0x020cac30  (8 bytes)  0100a0e3 1eff2fe1 = MOV r0,#1 / BX lr

A trivial state's Init is exactly an eight-byte `return 1` sitting
third in that run. The ov002 body IS St_Null_Init. The ov006 body at
the same address is 0x6c bytes that walk an array of 0xdc-byte records
out of data_ov006_02140554, which is minigame work and nothing a
Player state does. #1336 assigned each name to the right side; the
port's annotation has not caught up.

So the Player-name overlap between ov002 and ov006 is a naming artifact
of a shared load window, main has resolved it, and the port still needs
to follow (section 6).


2. Why the names collide: ov002 and ov006 share DS address space
----------------------------------------------------------------

From extracted/dsd/arm9_overlays/overlays.yaml (base_address and
code_size in decimal there, hex here) plus the raw image lengths in
extracted/overlays/:

    ov002  base 0x020ad660  image 0x60340  ->  0x020ad660..0x0210d9a0
    ov003  base 0x020ad660  image  small
    ov004  base 0x020ad660  image 0x11500  ->  0x020ad660..0x020beb60
    ov006  base 0x020bfec0  image 0x80420  ->  0x020bfec0..0x021402e0
    ov007  base 0x020ad660  image 0x55ce0  ->  0x020ad660..0x02103340

These are alternate scene overlays for one DS window, never resident
together. ov002 is the main-game set. ov004+ov006 are the minigame
set, loaded as a pair (see section 4). ov007 is a third set.

Consequence for names: 0x020cac30 is a real address in BOTH ov002 and
ov006, holding different code in each. ov002 has an 8-byte stub there:

    ov002 @0x020cac30  0100a0e3 1eff2fe1     MOV r0,#1 / BX lr
    ov006 @0x020cac30  f0402de9 04d04de2 ... PUSH {r4-r7,lr} / SUB sp,#4

verified by reading both raw images at (addr - base). ov002's config
names it _ZN6Player12St_Null_InitEv size 8; ov006's config names it
func_ov006_020cac30 size 0x6c. Different sizes, different
prologues, different code. The 0x6c body is ov006's.


3. The real seam: how the player dispatches today
-------------------------------------------------

The player's state machine runs entirely out of ov002, and the ROM's
own dispatch does reach the matched bodies. The chain, in order:

  a. The State objects are ov002 DATA, mounted as host arrays.
     port/ov002_syms.txt lists data_ov002_0211013c, ...0211022c,
     ...0211067c, ...021106ac, ...02110364 and the rest; ovdata.py
     emits their ROM bytes. Each State object holds mwcc PMF words:
     the main fn at +0 and the exit fn at +0x10, both DS code
     addresses baked in the overlay image.

  b. port/unmatched/Player_ChangeState.cpp is a HOST COPY of the
     matched src/_ZN6Player11ChangeStateERNS_5StateE.cpp with exactly
     the two PMF dispatch sites replaced by hal_call_state_fn(self,
     ds_addr). Everything else in it is the matched source verbatim.
     It is tagged PORT_HOST_ABI (mwcc pointer-to-member).

  c. hal_call_state_fn lives in port/hal/player_bridges.cpp:499. It is
     a switch on the DS code address that #includes
     port/hal/player_states.inc, plus four hand-written cases at the
     bottom. 197 cases today.

  d. player_states.inc is GENERATED from
     config/arm9/overlays/ov002/symbols.txt -- its own header line says
     so. Each case turns a DS address into a real __thiscall call on
     the matched Player method, e.g.

         case 0x020d38c0: return ((Player*)self)->Player::St_Walk_Main();

  e. A state address with no case falls off the end, increments
     g_port_unhosted_hits, prints "unhosted state fn 0x%08x (no-op)"
     to stderr and returns 1. That counter is what the F3 overlay
     shows live.

So there is no "state table pointing at stand-ins". The table is the
ROM's own State objects; the only host artifact is the address ->
method translation, which exists because MSVC cannot call an mwcc PMF.

The three ov006-named addresses appear in that switch as ov002 bodies,
which is the correct ROM-faithful answer:

    player_states.inc:125  case 0x020d6084: _ZN6Player23St_InYoshiMouth_CleanupEv(...)
    player_states.inc:155  case 0x020cac30: _ZN6Player12St_Null_InitEv()
    player_states.inc:213  case 0x020e17f8: _ZN6Player16St_WallJump_InitEv(...)

Those three cases dispatch the OV002 body at the address, not the
ov006 body that carries the St_ name. That is right: the running
overlay is ov002, so ov002's bytes are what the PMF word means.


4. What ov006 actually is, and what reaches it today
----------------------------------------------------

Measured from this worktree's map with port/tools/linkage.py
--by-module:

    module   total  linked  unlinked
    ov006     1839       0      1839   0.0%
    ov004      276       3       273   1.1%
    ov007      528       0       528   0.0%

ov006's 1897 function symbols in config split 1825 func_ov006_* +
31 __sinit_ov006_* + 41 named. The named 41 are 22 Mg*_Spawn entry
points, the eight _ZN17MgBounceAndPounce* methods (the one minigame
class with real C++ names, plus its _Spawn already counted in the 22),
the six mislabelled Player names above, and a handful of others
(Camera_UpdateMatrices, Sound_PlayBank1Panned,
dScMgJump2_c_classInit, _ZN12dScMgSlot1_c6RenderEv,
_ZN24cMgSmartball_propeller_c12SaveSnapshotEv).

Reach today is zero, with one asterisk, and the whole entry chain is
unlinked. Checked by name against build/port/walk_window.map:
GetSceneOverlayID, IsMinigameActorID, func_0201a614, func_0201a694,
func_0201a798, func_0201a754, LoadOverlay and UnloadOverlay are all
absent.

THE ASTERISK: grepping that map for func_ov006_ returns exactly one
hit, _func_ov006_020e3078, and it is attributed to
func_ov002_020e3078.c.obj. It is not an ov006 TU. It is an
/alternatename alias, port/hal/cxx_aliases.cpp:864 and :908, pointing
the ov006 name at the ov002 body at the same shared address. The ov006
TU of that name, src/func_ov006_020e3078.cpp, is not linked, so
linkage.py's ov006 linked=0 is correct. Anyone auditing reach by
grepping the map needs to know that one name is an alias, and that the
alias is the shared-window artifact again in a third form.


5. Conclusion for the lane
--------------------------

There is no Player slab in ov006 to seat. Player state seating is
ov002 work and belongs to the ov002 category lane. Nothing in ov006
can be reached by the player's dispatch, because the player's
dispatch runs ov002 addresses and ov006 is a different overlay set
that is never resident at the same time.

The one honest ov006 statement about the player: seating an ov006
body at any of the three shared addresses would be WRONG under the
current boot, because walk_window runs the main-game overlay set and
0x020cac30 there means ov002's 8-byte stub, which is St_Null_Init.
Main's #1336 says the same thing by giving that body the name.

The minigame boot cost is scouted separately in
port/ov006_minigame_scout.txt.


6. HAZARD: rebasing the port onto main breaks this seam
-------------------------------------------------------

Read this before merging main into any port branch. It is the known
C-linkage flip, with three concrete addresses attached.

The seam in section 3 is held together by a name agreement that #1336
has already broken on main:

  port/hal/player_states.inc is GENERATED from
    config/arm9/overlays/ov002/symbols.txt. Regenerate it against
    main's config and 0x020cac30, 0x020d6084 and 0x020e17f8 stop
    emitting func_ov002_* calls and start emitting Player:: method
    calls, because on main ov002 owns those three names.

  port/hal/player_bridges.cpp still declares them at C linkage:
    line 470  extern "C" int _ZN6Player12St_Null_InitEv(void);
    line 471  extern "C" int _ZN6Player23St_InYoshiMouth_CleanupEv(char *c);
    line 472  extern "C" int _ZN6Player16St_WallJump_InitEv(void *c);
  and calls them at
    player_states.inc:125  case 0x020d6084
    player_states.inc:155  case 0x020cac30
    player_states.inc:213  case 0x020e17f8

  the matched sources moved too. On main the func_ov002_* stems for
  these three no longer exist; the bodies are
  src/func_ov006_020cac30.cpp,
  src/actors/dScMgBomroom_c.cpp and
  src/func_ov006_020e17f8.cpp, and the func_ov006_* stems
  now hold the ov006 bodies.

So a rebase that regenerates the .inc leaves three cases calling
three C-linkage declarations that nothing defines, and a rebase that
does NOT regenerate it leaves three cases naming stems that no longer
exist in src/. Either way the three states break, and the byte gate
never touches port/, so nothing in CI says so.

Propagate the renames BY ADDRESS, not by name: for each of
0x020cac30, 0x020d6084 and 0x020e17f8, look up what main's ov002
symbols.txt calls that address, and make the .inc case, the extern
declaration in player_bridges.cpp and the slice line agree on that one
answer. The three cases become ordinary Player method calls like every
other case in the .inc, which is what they should have been.

The ov006 side needs the mirror treatment whenever ov006 is sliced:
its three bodies are func_ov006_020cac30, func_ov006_020d6084 and
func_ov006_020e17f8 on main, not Player names.
