decomp(system): warning_run in C (asm placeholder removed) (worker d00a2f20)

This commit is contained in:
coah
2026-10-09 19:18:45 +00:00
parent c628bab36c
commit aa671fa7de
4 changed files with 151 additions and 224 deletions

View File

@@ -1,7 +1,7 @@
# Assembly inventory
4.3U, 2026-10-09. 164 functions contain 166 assembly
bodies/blocks: 162 ORIGINAL functions and 2 PLACEHOLDER functions.
4.3U, 2026-10-09. 163 functions contain 165 assembly
bodies/blocks: 162 ORIGINAL functions and 1 PLACEHOLDER function.
Run `python3 tools/check_asm_inventory.py`. Completion requires exit 0, complete
coverage and zero placeholders. The checker also rejects stale/duplicate rows,
@@ -185,13 +185,11 @@ found. Historical logs absent from this branch have commit IDs and excerpts in
| `src/BS2/BS2Start.c` | `__start` | ORIGINAL | Runs before the C stack and ABI registers exist; constructs the initial stack. |
| `src/BS2/BS2Start.c` | `__init_registers` | ORIGINAL | Initializes GPRs, r1, r2, and r13 for the C runtime. |
| `src/scene/nakamuraTest/gamespy/common/gsPlatformUtil.c` | `GetTicks` | ORIGINAL | Inactive PS2 branch reads the CP0 Count register with mfc0 $9. |
| `src/system/iplSystem.cpp` | `System::warning_run` | PLACEHOLDER | Scene/render calls; best C 98.66477%, 176/176 instructions, 47 saved-register differences, [rx17][rx17]. |
| `src/system/rvl_dec.c` | `Rvl_decode` | ORIGINAL | Direct beq decoder entries preserve r3/r4 and LR; lis/ori builds the format signatures. |
| `src/system/rvl_dec.c` | `Rvl_decode_szs` | ORIGINAL | Original SZS decoder convention: nofralloc, r0 retains output length, fixed r3..r10/CTR byte-copy pipeline. |
| `src/system/rvl_dec.c` | `Rvl_decode_ash` | ORIGINAL | nofralloc hand-built 0x40 frame saves r21..31 with stmw; work address uses lis @h/ori @l. |
| `src/system/rvl_dec.c` | `Rvl_decode_asr` | ORIGINAL | nofralloc hand-built 0x40 frame saves r21..31 with stmw; work address uses lis @h/ori @l. |
[rx17]: ../tools/decomp-assist/rx36.attempts.md#rx17
[rx24]: ../tools/decomp-assist/rx36.attempts.md#rx24
[rx36-osinit]: ../tools/decomp-assist/rx36.attempts.md#osinit
[sdk-init]: https://github.com/doldecomp/ogws/blob/master/src/revolution/OS/__ppc_eabi_init.c

View File

@@ -190,6 +190,7 @@ namespace ipl {
PointerCore mCore; // 0x40
friend class System;
friend class PointerCoreObject;
friend class PointerCore;
friend class utility::BScroller;

View File

@@ -36,8 +36,6 @@
#include <revolution/rso.h>
#ifdef __MWERKS__
extern "C" ipl::System::Arg smArg__Q23ipl6System;
extern "C" ipl::snd::System sSystem__Q23ipl3snd;
extern "C" void initOnMemory__Q33ipl3snd6SystemFPCvPQ23EGG4HeapUl();
extern "C" const f32 scOrthoLeft;
extern "C" const f32 scOrthoRight;
@@ -45,34 +43,6 @@ extern "C" const f32 scOrthoBottom;
extern "C" const f32 scOrthoTop;
extern "C" const f32 scWideOrthoLeft;
extern "C" const f32 scWideOrthoRight;
extern "C" void* m_handle__Q23ipl11TVRCManager;
extern "C" void _savegpr_27();
extern "C" void _restgpr_27();
extern "C" void reset_run__Q23ipl6SystemFv();
extern "C" void check__Q23ipl14WarningHandlerFv();
extern "C" void check__Q23ipl12ResetHandlerFv();
extern "C" void update__Q23ipl12ResetHandlerFv();
extern "C" void check__Q23ipl12ErrorHandlerFv();
extern "C" void endFrame__Q23ipl9FrameworkFv();
extern "C" void calc__Q23ipl14WarningHandlerFv();
extern "C" void calc__Q23ipl7PointerFv();
extern "C" void calc__Q23ipl14HomeButtonMenuFv();
extern "C" void update__Q33ipl7channel7ManagerFv();
extern "C" void set__Q23ipl12ErrorHandlerFQ33ipl12ErrorHandler4TypeUlPCcii();
extern "C" void update__Q33ipl3bs27ManagerFv();
extern "C" void read__Q33ipl10controller7ManagerFv();
extern "C" void setToday___Q23ipl6SystemFv();
extern "C" void update__Q23ipl11TVRCManagerFv();
extern "C" void endRender__Q23ipl9FrameworkFv();
extern "C" void draw__Q23ipl7PointerFv();
extern "C" void draw__Q23ipl14HomeButtonMenuFv();
extern "C" void draw__Q23ipl14WarningHandlerFv();
extern "C" void draw__Q23ipl12DialogWindowFv();
extern "C" void draw__Q33ipl5scene7ManagerFv();
extern "C" void makeRawData__Q33ipl7utility11JpegDecoderFv();
extern "C" void makeIcon__Q33ipl6nigaoe7ManagerFv();
extern "C" void beginRender__Q23ipl9FrameworkFv();
extern "C" void beginFrame__Q23ipl9FrameworkFv();
#endif
namespace ipl {
@@ -1084,197 +1054,95 @@ namespace ipl {
}
}
asm void System::warning_run() {
nofralloc
stwu r1, -0x40(r1)
mflr r0
stw r0, 0x44(r1)
stfd f31, 0x30(r1)
psq_st f31, 0x38(r1), 0, 0
addi r11, r1, 0x30
bl _savegpr_27
lis r3, smArg__Q23ipl6System@ha
addi r28, r3, smArg__Q23ipl6System@l
lwz r3, 0x9c(r28)
lwz r3, 4(r3)
addic r0, r3, -1
subfe. r0, r0, r3
bne warning_run_done
li r3, 0
bl VISetBlack
lwz r3, 0xb0(r28)
li r0, 1
lfd f31, scOrthoLeft-0xc
lis r30, 0x4330
lbz r29, 0x3d(r3)
lis r31, sSystem__Q23ipl3snd@ha
stb r0, 0x3d(r3)
warning_run_loop:
lwz r3, 0x74(r28)
bl beginFrame__Q23ipl9FrameworkFv
lwz r3, 0x74(r28)
bl beginRender__Q23ipl9FrameworkFv
lbz r0, 0x2b2(r28)
cmpwi r0, 0
beq warning_run_no_mii
lwz r3, 0x70(r28)
bl makeIcon__Q33ipl6nigaoe7ManagerFv
warning_run_no_mii:
lbz r0, 0x2b2(r28)
cmpwi r0, 0
beq warning_run_no_jpeg
lwz r3, 0xbc(r28)
bl makeRawData__Q33ipl7utility11JpegDecoderFv
warning_run_no_jpeg:
lwz r3, 0x74(r28)
lfs f1, scOrthoLeft-0x14
lwz r27, 0(r3)
stw r30, 8(r1)
fmr f2, f1
lhz r3, 4(r27)
fmr f5, f1
lhz r0, 6(r27)
stw r3, 0xc(r1)
lfs f6, scOrthoLeft-0x4
lfd f0, 8(r1)
stw r0, 0x14(r1)
fsubs f3, f0, f31
stw r30, 0x10(r1)
lfd f0, 0x10(r1)
fsubs f4, f0, f31
bl GXSetViewport
lhz r5, 4(r27)
li r3, 0
lhz r6, 6(r27)
li r4, 0
bl GXSetScissor
lwz r3, 0x64(r28)
bl draw__Q33ipl5scene7ManagerFv
lbz r0, 0x2b2(r28)
cmpwi r0, 0
beq warning_run_no_keyboard
lwz r3, 0x90(r28)
lwz r12, 0(r3)
lwz r12, 0x14(r12)
mtctr r12
bctrl
lwz r3, 0xac(r28)
bl draw__Q23ipl12DialogWindowFv
warning_run_no_keyboard:
lwz r3, 0xa0(r28)
bl draw__Q23ipl14WarningHandlerFv
lbz r0, 0x2b2(r28)
cmpwi r0, 0
beq warning_run_no_home
lwz r3, 0xb4(r28)
bl draw__Q23ipl14HomeButtonMenuFv
warning_run_no_home:
lbz r0, 0x2b2(r28)
cmpwi r0, 0
beq warning_run_no_pointer
lwz r3, 0xb0(r28)
bl draw__Q23ipl7PointerFv
warning_run_no_pointer:
lwz r3, 0xc4(r28)
lwz r12, 0(r3)
lwz r12, 0x1c(r12)
mtctr r12
bctrl
lwz r3, 0xc8(r28)
lwz r12, 0(r3)
lwz r12, 0x1c(r12)
mtctr r12
bctrl
lwz r3, 0x74(r28)
bl endRender__Q23ipl9FrameworkFv
lwz r3, m_handle__Q23ipl11TVRCManager
bl update__Q23ipl11TVRCManagerFv
bl setToday___Q23ipl6SystemFv
lwz r3, 0x68(r28)
bl read__Q33ipl10controller7ManagerFv
lwz r3, 0xa8(r28)
bl update__Q33ipl3bs27ManagerFv
cmpwi r3, 0xa
bne warning_run_no_dvd
lwz r3, 0x98(r28)
li r4, 1
li r5, 0
li r6, 0
li r7, 0
li r8, -1
bl set__Q23ipl12ErrorHandlerFQ33ipl12ErrorHandler4TypeUlPCcii
warning_run_no_dvd:
lwz r3, 0x84(r28)
bl update__Q33ipl7channel7ManagerFv
lbz r0, 0x2b2(r28)
cmpwi r0, 0
beq warning_run_no_calc
lwz r3, 0xb4(r28)
bl calc__Q23ipl14HomeButtonMenuFv
lwz r3, 0xb0(r28)
bl calc__Q23ipl7PointerFv
lwz r3, 0xc4(r28)
lwz r12, 0(r3)
lwz r12, 0x18(r12)
mtctr r12
bctrl
lwz r3, 0xc8(r28)
lwz r12, 0(r3)
lwz r12, 0x18(r12)
mtctr r12
bctrl
lwz r3, 0xa0(r28)
bl calc__Q23ipl14WarningHandlerFv
addi r3, r31, sSystem__Q23ipl3snd@l
lwz r12, 0(r3)
lwz r12, 0xc(r12)
mtctr r12
bctrl
warning_run_no_calc:
lwz r3, 0x74(r28)
bl endFrame__Q23ipl9FrameworkFv
lbz r0, 0x2b2(r28)
cmpwi r0, 0
beq warning_run_no_error
lwz r3, 0x98(r28)
bl check__Q23ipl12ErrorHandlerFv
warning_run_no_error:
lwz r3, 0x9c(r28)
bl update__Q23ipl12ResetHandlerFv
lwz r3, 0x9c(r28)
bl check__Q23ipl12ResetHandlerFv
lwz r3, 0xa0(r28)
bl check__Q23ipl14WarningHandlerFv
cmpwi r3, -1
beq warning_run_loop
cmpwi r29, 0
beq warning_run_pointer_hidden
lwz r3, 0xb0(r28)
li r0, 1
stb r0, 0x3d(r3)
b warning_run_pointer_done
warning_run_pointer_hidden:
lwz r3, 0xb0(r28)
li r0, 0
stb r0, 0x3d(r3)
warning_run_pointer_done:
lis r3, smArg__Q23ipl6System@ha
addi r3, r3, smArg__Q23ipl6System@l
lwz r3, 0xa0(r3)
lwz r0, 0(r3)
cmpwi r0, 2
bne warning_run_done
bl reset_run__Q23ipl6SystemFv
warning_run_done:
psq_l f31, 0x38(r1), 0, 0
addi r11, r1, 0x30
lfd f31, 0x30(r1)
bl _restgpr_27
lwz r0, 0x44(r1)
mtlr r0
addi r1, r1, 0x40
blr
// MWCC needs dead-assignment elimination off to keep the inline temporaries that set this loop's register order.
#pragma push
#pragma opt_dead_assignments off
void System::warning_run() {
if (getResetHandler()->isResetting()) {
return;
}
VISetBlack(FALSE);
u8 visible = getPointer()->mbVisible;
getPointer()->setVisible(true);
do {
// Start rendering
smArg.mpFramework->beginFrame();
smArg.mpFramework->beginRender();
// Setup data
if (hasCreatedAfter()) {
getMiiManager()->makeIcon();
}
if (hasCreatedAfter()) {
getJpegDecoder()->makeRawData();
}
// Setup view
GXRenderModeObj* rMode = System::getRenderModeObj();
GXSetViewport(0.0f, 0.0f, rMode->fbWidth, rMode->efbHeight, 0.0f, 1.0f);
GXSetScissor(0, 0, rMode->fbWidth, rMode->efbHeight);
// Drawing
getSceneManager()->draw();
if (hasCreatedAfter()) {
getKeyboard()->draw();
getDialog()->draw();
}
getWarningHandler()->draw();
if (hasCreatedAfter()) {
getHomeButtonMenu()->draw();
}
if (hasCreatedAfter()) {
getPointer()->draw();
}
getFader()->draw();
getResetFader()->draw();
// End of rendering
smArg.mpFramework->endRender();
// Update logic
TVRCManager::getHandle()->update();
setToday_();
getControllerManager()->read();
if (getBS2Manager()->update() == bs2::IPL_STATE_FATAL) {
IPLErrorDisplay(MESG_ERR_DVD);
}
getChannelManager()->update();
if (hasCreatedAfter()) {
getHomeButtonMenu()->calc();
getPointer()->calc();
getFader()->calc();
getResetFader()->calc();
getWarningHandler()->calc();
snd::getSystem()->calc();
}
smArg.mpFramework->endFrame();
// Error handling
if (hasCreatedAfter()) {
getErrorHandler()->check();
}
// Reset handling
getResetHandler()->update();
getResetHandler()->check();
} while (getWarningHandler()->check() == -1);
if (visible) {
getPointer()->setVisible(true);
} else {
getPointer()->setVisible(false);
}
if (getWarningHandler()->resetting()) {
reset_run();
}
}
#pragma pop
void System::reinit() {
getMem2App()->dump();

View File

@@ -0,0 +1,60 @@
# a2c-warn2 attempts
Owned function: `System::warning_run` in `src/system/iplSystem.cpp` (asm placeholder).
Worktree `data-d10`, branch `agent/w1009/a2c-warn2`, base `ec965ad5`.
Prior state: rx17 C 47/176, a2c-warn C + `opt_dead_assignments off` 42/176 (smArg/visibility swap).
## Tooling
- `/tmp/a2c-warn2-try.py <fragment>`: splices a `warning_run` body into the unit, compiles with the unit's
real flags (1.2 s), diffs against the target, prints saved-register mismatches.
- `/tmp/a2c-warn2-cap.sh <full source> <name>`: mwdbg capture of a reduced unit (warning_run +
getRenderModeObj only, 39 s instead of 105 s). The reduced unit reproduces the full-unit graph exactly.
- `/tmp/a2c-warn2-vals.py <capture>`: vreg map (name, degree, color, defining PCode).
- `/tmp/a2c-warn2-hyp.py`: replays the capture with relabelled vregs (what-if numbering).
## Allocator facts (from captures, confirmed against the MWCC decomp sources)
- Numbering: named locals (reverse declaration order), then `@` temps, then codegen temps in creation order.
`&smArg` is the backend CSE of the first `lis/addi` in the reset check, so every frontend local is
numbered below it.
- Target colour order is snd r31, 0x4330 r30, visibility r29, smArg r28, rMode r27. That needs numbering
rMode < smArg < visibility < 0x4330 < snd with smArg not deferred. smArg has degree 32 (12 precoloured), so
at least 4 of its neighbours must be numbered below it.
- Simulation on the captured graphs: any layout with visibility between smArg and 0x4330 plus two more
frontend neighbours below smArg reproduces the target colours exactly.
## Results
| variant | diffs | note |
|---|---|---|
| rx17 C (bool visible) | 47 | baseline |
| `u8 visible` | 47 | visibility becomes a codegen temp (clrlwi from bool->u8 folds away), but smArg still deferred (2 below) |
| `u8 visible` + dead_assignments off | 42 | survivors below smArg, but the value moves back into isVisible's `@` return temp |
| `const bool& visible` + dead_assignments off | 7 | smArg r28, rMode r27 correct; visibility is a stack temp promoted after codegen, numbered last |
| `volatile` mbVisible + dead_assignments off (diagnostic only) | 5 | all registers right; only the volatile load/store scheduling differs |
| `Arg& arg = smArg;` + dead_assignments off | 47 | arg keeps the target `lis r3; addi rX, r3` form (only while rMode comes from getRenderModeObj) |
| pragma single/pair sweeps on u8, const-ref and Arg& variants | >= 7 | nothing below 7 |
| `u8 visible = getPointer()->mbVisible;` + dead_assignments off (`friend class System;` in Pointer) | **0** | exact |
## Why the exact form works
- `opt_dead_assignments off` keeps the inline `this` temporaries (framework, pointer, reset handler) and the
rMode return temp alive. They are frontend values numbered below `&smArg`, so smArg is no longer deferred.
- Reading the field straight into a `u8` adds a bool->u8 conversion at the load. The load goes into a fresh
codegen temp, the clrlwi folds into a copy and copy propagation keeps the temp, so the saved visibility is
numbered between `&smArg` and the 0x4330 constant. Any accessor call (`isVisible()`) puts the value back in
an inline return temp (42 diffs); `bool`/`BOOL`/`int`/`u16`/`u32` locals give 47, `char`/`s8` add an extsb.
- `friend class System;` follows the existing `friend class System;` in WarningHandler. No other unit changes.
## Final verification
- `ninja build/43U/src/src/system/iplSystem.o`: odiff 0/176, ctxdiff `diffs 0`, 176/176 instructions.
- pool_diff: POOL IDENTICAL up to 52 (mine=52 base=52).
- Unit report: 63/63 functions, code/data/complete 100%, every owned section 100%.
- Full build PASS, `main.dol` SHA1 `26116613f624061ba99c8d1a299aaa6efa85670d`.
- `check_decomp_complete.py`: DECOMPLETE_OK.
- `check_asm_inventory.py`: 164 functions, 166 blocks, 162 ORIGINAL, 2 PLACEHOLDER (the remaining failure is
only the two placeholders owned by other workers; no stale rows). Row and `[rx17]` link removed, header counts fixed.
- `gate.py src/system/iplSystem --quick`: GATE PASS, 0 regressions, 0 forbidden, 0 readability warnings; review
note for the scoped `opt_dead_assignments` pragma (allowed by the 2026-10-09 rules).