# RUNG W1 OF THE WIRELESS PLAN: LET THE ROM'S OWN WM_Init RUN.
# Run link100, lane WM2, on top of lane WM1's rung W0.
#
# The plan is lane WMSCOUT's (runs/link100/out/WMSCOUT/report.md section 3): the
# ROM's wireless chain is 260 matched, never-linked TUs and it comes back in
# eight rungs. W0 gave back the two state readers. W1 gives back the OPEN --
# src/func_020408b0.c and the eleven TUs its call closure reaches -- and the
# ARM7 still answers nothing.
#
# THE TWELVE, and what each one is:
#
#   src/func_020408b0.c    the bring-up itself. Writes the mode word, takes
#                          eight buffers off the game heap, reads the boot
#                          indicator, calls WM_Init.
#   src/func_020616e8.c    WM_Init. Checks the ARM7 holds channel 0xa, clears
#                          0x1300 of work buffer by DMA, lays out the command
#                          area / the 0xa00 status block / the reply message,
#                          zeroes sixteen port slots, enqueues ten 0x100 command
#                          buffers, and registers the ARM9's channel-0xa
#                          callback.
#   src/func_02061188.c    that callback: the reply dispatcher. Invalidates the
#                          two ARM7-owned regions and dispatches on the apiid.
#   src/func_0206116c.c    the 0x027fff96 acknowledge bit.
#   src/func_0206152c.c    "is WM initialised", the guard every entry takes.
#   src/func_02061674.c    WM_Finish's inner half (unregister, drop the work
#                          pointer). Reached from the dispatcher's apiid-2 arm.
#   src/func_02061c88.c    the per-port callback registrar, called sixteen times
#                          by WM_Init.
#   src/func_02058894.c    the OS queue PUT WM_Init enqueues its buffers with.
#   src/func_02058940.c    the same queue's initialiser.
#   src/func_020672d0.c    the multiboot parameter block builder. Reached only
#                          on the boot-indicator-2 branch; see BOOT INDICATOR
#                          below.
#   src/WM_CheckStateEx.c  reads the state halfword out of the status block.
#   src/WM_GetSystemWork.c returns the work-buffer pointer.
#
# COUNT: +12. Measured, not predicted: port/tools/closure.py over exactly these
# twelve against the pre-rung map reported nineteen unresolved externals, all of
# them DS bss (hosted at the foot of hal/comms_seam.cpp by the same commit), and
# ONE duplicate definition -- _func_020408b0, whose image copy came from
# comms_seam.cpp.obj. That face is retired in the same commit. Every other
# callee of the twelve was already in the image.
#
# THE ARM7 ANSWERS NOTHING ON THIS RUNG, AND NOTHING ASKS IT TO. This was the
# one thing worth checking rather than assuming, because WMSCOUT read "answers
# nothing" off the three gate bodies and not off WM_Init. Read off the twelve:
# nothing in this closure reaches WM_SendCommand. func_020616e8 sends no
# command, registers a callback and returns; func_02061188 only runs when a
# reply arrives, and none can. So the port's per-tag census
# (hal/boot2_ipc.cpp's exit report) must show ZERO words on tag 10 in a solo
# run, and that is the measurement this rung is gated on.
#
# WHAT MOVED IN THE PORT, and both are in the lane report with their reasoning:
#
#   THE OPEN. Retiring the host face deleted the port's only t->open(mode) call.
#   Its home is hal/boot2_ipc.cpp, the host ARM7, which opens the installed
#   transport when it sees the ROM claim channel 0xa -- the last thing WM_Init
#   does -- with data_020a0f14 as the mode word. The ROM writes that word in the
#   FIRST statement of func_020408b0 and registers the channel in the LAST
#   statement of WM_Init, so the mode is always already there.
#
#   THE WIDE RECORD CLEAR. records 4..15 at data_020a1154 are the port's, not
#   the cartridge's, and the retired face cleared them once per session arm.
#   That moved to hal/comms_conductor.cpp's comms_seat_session_request, which is
#   the one point every path to func_020408b0 passes through -- it is what seats
#   the data_02099e1c one-shot src/func_0203ea5c.c:137-140 tests -- and which
#   also covers the ROM-drops-to-solo re-seat the seam could no longer see.
#
# THE BOOT INDICATOR keeps this game on the dead branch. src/func_020408b0.c
# tests *(u16 *)0x027ffc40 == 2 and only then calls func_020672d0. The port
# comes up 0 (a cartridge boot; hal/comms_seam.h's THE ROLE IS NOT THE FLAG
# block, and comms_set_boot_indicator is the only way it becomes 2). So
# func_020672d0 never runs in this game's boot -- and it is SEATED anyway rather
# than faced off, because it closes: its only callee is CpuCopy8, which is
# already in the image, and closure.py reported no unresolved external for it.
# A face would have been a stand-in for a body that costs nothing to link.
#
# THE HEAP. func_020408b0 takes 0x1300 + 0x40 + 0x20 + 0xc0 + 0x420 + 0x100 +
# 0x220 + 0x480 = 0x25e0 bytes off the game heap and moves every later
# allocation. IT ONLY EVER RUNS IN A SESSION. In a solo boot the role byte
# data_020a0f04 never leaves 0, so src/func_0203df40.c takes its solo arm,
# data_02099e1c is never seated, and src/func_0203ea5c.c:137-140 never calls
# func_020408b0 at all -- and hal/comms_conductor.cpp's comms_wait_for_session
# returns before its own call when no transport is installed. So every
# single-player baseline in this tree, including the battery's 51 level and 36
# scene BMP rows, sees no allocation it did not see before.
#
# THE PROBE KEEPS THE FACE. tests/mp_comms_seam.cpp calls func_020408b0(2) to
# check the seam's solo answers and links neither a heap nor Memory::Allocate,
# so it keeps the retired stand-in under PORT_COMMS_SEAM_PROBE_FACE_020408B0 --
# the same shape mp_sleepwake uses for the retired OS_SleepThread pair. No
# shipped target compiles it.
src/func_020408b0.c
src/func_020616e8.c
src/func_02061188.c
src/func_0206116c.c
src/func_0206152c.c
src/func_02061674.c
src/func_02061c88.c
src/func_02058894.c
src/func_02058940.c
src/func_020672d0.c
src/WM_CheckStateEx.c
src/WM_GetSystemWork.c
