From 6fb1c66ce30c0ea133d8acc8c67ea18eb27cb595 Mon Sep 17 00:00:00 2001 From: Drew T <50529377+Druthulu@users.noreply.github.com> Date: Tue, 11 Aug 2026 22:53:22 -0600 Subject: [PATCH] feat(phase-30 S48-T6): propagate func_8017DF40 to its zero-crack siblings --- src/md_SC03_076/md_SC03_076.c | 58 ++++++++++++++++++++++++++++++++++- src/md_SC03_135/md_SC03_135.c | 58 ++++++++++++++++++++++++++++++++++- src/md_SC04_027/md_SC04_027.c | 58 ++++++++++++++++++++++++++++++++++- src/md_SC05_026/md_SC05_026.c | 58 ++++++++++++++++++++++++++++++++++- 4 files changed, 228 insertions(+), 4 deletions(-) diff --git a/src/md_SC03_076/md_SC03_076.c b/src/md_SC03_076/md_SC03_076.c index 97b990f4fe..f1e7ba28dc 100644 --- a/src/md_SC03_076/md_SC03_076.c +++ b/src/md_SC03_076/md_SC03_076.c @@ -277,7 +277,63 @@ INCLUDE_ASM("asm/md_SC03_076/nonmatchings/md_SC03_076", func_801F1520); INCLUDE_ASM("asm/md_SC03_076/nonmatchings/md_SC03_076", func_801F1710); -INCLUDE_ASM("asm/md_SC03_076/nonmatchings/md_SC03_076", func_801F1738); + +/* 152-byte engine block, copied whole (struct assignment -> 9x16B block move + 8B tail). + * Uniquely suffixed: the host TU already sees `Blk152` from engine_types.h, and a C89 + * re-typedef of a visible name is a redefinition error. Same layout, same codegen. */ +typedef struct { u32 w[38]; } Blk152_8017DF40_801F1738; +/* ALIGN-1 4-byte element => lwl/lwr + swl/swr (cookbook §160a); a u32[] loop is wrong. */ +typedef struct { u8 b[4]; } Blk4_8017DF40_801F1738; + + + +/* Param is declared s32 by the host TU's file-scope prototype (:3695); the true test is + * 16-bit (`sll $a0,$a0,16 ; bnez`, no sra), so the truncation lives in the test instead. */ +void func_801F1738(s32 arg0) { + + extern u8 D_80078E78[]; /* live: 152-byte block (host TU declares this identically) */ + extern u16 D_800A6588[]; /* live: u16[64] */ + extern u8 D_800AE648[]; /* live: u8[64] */ + extern u8 D_800BA1B8[]; /* live: u8[256] */ + extern u8 D_800BA2B8[]; /* live: 4-byte struct[24], align 1 */ + extern u8 D_801F9AE8[]; /* shadow: +0x000 */ + extern u16 D_801F9B80[]; /* shadow: +0x098 */ + extern u8 D_801F9C00[]; /* shadow: +0x118 */ + extern u8 D_801F9C40[]; /* shadow: +0x158 */ + extern u8 D_801F9D40[]; /* shadow: +0x258 */ + s16 i; + + if ((s16)arg0 == 0) { + *(Blk152_8017DF40_801F1738 *)D_80078E78 = *(Blk152_8017DF40_801F1738 *)D_801F9AE8; + for (i = 0; i < 64; i++) { + D_800A6588[i] = D_801F9B80[i]; + } + for (i = 0; i < 64; i++) { + D_800AE648[i] = D_801F9C00[i]; + } + for (i = 0; i < 256; i++) { + D_800BA1B8[i] = D_801F9C40[i]; + } + for (i = 0; i < 24; i++) { + ((Blk4_8017DF40_801F1738 *)D_800BA2B8)[i] = ((Blk4_8017DF40_801F1738 *)D_801F9D40)[i]; + } + } else { + *(Blk152_8017DF40_801F1738 *)D_801F9AE8 = *(Blk152_8017DF40_801F1738 *)D_80078E78; + for (i = 0; i < 64; i++) { + D_801F9B80[i] = D_800A6588[i]; + } + for (i = 0; i < 64; i++) { + D_801F9C00[i] = D_800AE648[i]; + } + for (i = 0; i < 256; i++) { + D_801F9C40[i] = D_800BA1B8[i]; + } + for (i = 0; i < 24; i++) { + ((Blk4_8017DF40_801F1738 *)D_801F9D40)[i] = ((Blk4_8017DF40_801F1738 *)D_800BA2B8)[i]; + } + } +} + extern void func_8014B00C(void); extern void func_80029344(void); diff --git a/src/md_SC03_135/md_SC03_135.c b/src/md_SC03_135/md_SC03_135.c index cd3b9d6bf4..aee892cb44 100644 --- a/src/md_SC03_135/md_SC03_135.c +++ b/src/md_SC03_135/md_SC03_135.c @@ -277,7 +277,63 @@ INCLUDE_ASM("asm/md_SC03_135/nonmatchings/md_SC03_135", func_801E46A0); INCLUDE_ASM("asm/md_SC03_135/nonmatchings/md_SC03_135", func_801E4890); -INCLUDE_ASM("asm/md_SC03_135/nonmatchings/md_SC03_135", func_801E48B8); + +/* 152-byte engine block, copied whole (struct assignment -> 9x16B block move + 8B tail). + * Uniquely suffixed: the host TU already sees `Blk152` from engine_types.h, and a C89 + * re-typedef of a visible name is a redefinition error. Same layout, same codegen. */ +typedef struct { u32 w[38]; } Blk152_8017DF40_801E48B8; +/* ALIGN-1 4-byte element => lwl/lwr + swl/swr (cookbook §160a); a u32[] loop is wrong. */ +typedef struct { u8 b[4]; } Blk4_8017DF40_801E48B8; + + + +/* Param is declared s32 by the host TU's file-scope prototype (:3695); the true test is + * 16-bit (`sll $a0,$a0,16 ; bnez`, no sra), so the truncation lives in the test instead. */ +void func_801E48B8(s32 arg0) { + + extern u8 D_80078E78[]; /* live: 152-byte block (host TU declares this identically) */ + extern u16 D_800A6588[]; /* live: u16[64] */ + extern u8 D_800AE648[]; /* live: u8[64] */ + extern u8 D_800BA1B8[]; /* live: u8[256] */ + extern u8 D_800BA2B8[]; /* live: 4-byte struct[24], align 1 */ + extern u8 D_801EA984[]; /* shadow: +0x000 */ + extern u16 D_801EAA1C[]; /* shadow: +0x098 */ + extern u8 D_801EAA9C[]; /* shadow: +0x118 */ + extern u8 D_801EAADC[]; /* shadow: +0x158 */ + extern u8 D_801EABDC[]; /* shadow: +0x258 */ + s16 i; + + if ((s16)arg0 == 0) { + *(Blk152_8017DF40_801E48B8 *)D_80078E78 = *(Blk152_8017DF40_801E48B8 *)D_801EA984; + for (i = 0; i < 64; i++) { + D_800A6588[i] = D_801EAA1C[i]; + } + for (i = 0; i < 64; i++) { + D_800AE648[i] = D_801EAA9C[i]; + } + for (i = 0; i < 256; i++) { + D_800BA1B8[i] = D_801EAADC[i]; + } + for (i = 0; i < 24; i++) { + ((Blk4_8017DF40_801E48B8 *)D_800BA2B8)[i] = ((Blk4_8017DF40_801E48B8 *)D_801EABDC)[i]; + } + } else { + *(Blk152_8017DF40_801E48B8 *)D_801EA984 = *(Blk152_8017DF40_801E48B8 *)D_80078E78; + for (i = 0; i < 64; i++) { + D_801EAA1C[i] = D_800A6588[i]; + } + for (i = 0; i < 64; i++) { + D_801EAA9C[i] = D_800AE648[i]; + } + for (i = 0; i < 256; i++) { + D_801EAADC[i] = D_800BA1B8[i]; + } + for (i = 0; i < 24; i++) { + ((Blk4_8017DF40_801E48B8 *)D_801EABDC)[i] = ((Blk4_8017DF40_801E48B8 *)D_800BA2B8)[i]; + } + } +} + extern void func_8014B00C(void); extern void func_80029344(void); diff --git a/src/md_SC04_027/md_SC04_027.c b/src/md_SC04_027/md_SC04_027.c index 78270a1202..505dfa8ab4 100644 --- a/src/md_SC04_027/md_SC04_027.c +++ b/src/md_SC04_027/md_SC04_027.c @@ -277,7 +277,63 @@ INCLUDE_ASM("asm/md_SC04_027/nonmatchings/md_SC04_027", func_801E9BE0); INCLUDE_ASM("asm/md_SC04_027/nonmatchings/md_SC04_027", func_801E9DD0); -INCLUDE_ASM("asm/md_SC04_027/nonmatchings/md_SC04_027", func_801E9DF8); + +/* 152-byte engine block, copied whole (struct assignment -> 9x16B block move + 8B tail). + * Uniquely suffixed: the host TU already sees `Blk152` from engine_types.h, and a C89 + * re-typedef of a visible name is a redefinition error. Same layout, same codegen. */ +typedef struct { u32 w[38]; } Blk152_8017DF40_801E9DF8; +/* ALIGN-1 4-byte element => lwl/lwr + swl/swr (cookbook §160a); a u32[] loop is wrong. */ +typedef struct { u8 b[4]; } Blk4_8017DF40_801E9DF8; + + + +/* Param is declared s32 by the host TU's file-scope prototype (:3695); the true test is + * 16-bit (`sll $a0,$a0,16 ; bnez`, no sra), so the truncation lives in the test instead. */ +void func_801E9DF8(s32 arg0) { + + extern u8 D_80078E78[]; /* live: 152-byte block (host TU declares this identically) */ + extern u16 D_800A6588[]; /* live: u16[64] */ + extern u8 D_800AE648[]; /* live: u8[64] */ + extern u8 D_800BA1B8[]; /* live: u8[256] */ + extern u8 D_800BA2B8[]; /* live: 4-byte struct[24], align 1 */ + extern u8 D_801F21B8[]; /* shadow: +0x000 */ + extern u16 D_801F2250[]; /* shadow: +0x098 */ + extern u8 D_801F22D0[]; /* shadow: +0x118 */ + extern u8 D_801F2310[]; /* shadow: +0x158 */ + extern u8 D_801F2410[]; /* shadow: +0x258 */ + s16 i; + + if ((s16)arg0 == 0) { + *(Blk152_8017DF40_801E9DF8 *)D_80078E78 = *(Blk152_8017DF40_801E9DF8 *)D_801F21B8; + for (i = 0; i < 64; i++) { + D_800A6588[i] = D_801F2250[i]; + } + for (i = 0; i < 64; i++) { + D_800AE648[i] = D_801F22D0[i]; + } + for (i = 0; i < 256; i++) { + D_800BA1B8[i] = D_801F2310[i]; + } + for (i = 0; i < 24; i++) { + ((Blk4_8017DF40_801E9DF8 *)D_800BA2B8)[i] = ((Blk4_8017DF40_801E9DF8 *)D_801F2410)[i]; + } + } else { + *(Blk152_8017DF40_801E9DF8 *)D_801F21B8 = *(Blk152_8017DF40_801E9DF8 *)D_80078E78; + for (i = 0; i < 64; i++) { + D_801F2250[i] = D_800A6588[i]; + } + for (i = 0; i < 64; i++) { + D_801F22D0[i] = D_800AE648[i]; + } + for (i = 0; i < 256; i++) { + D_801F2310[i] = D_800BA1B8[i]; + } + for (i = 0; i < 24; i++) { + ((Blk4_8017DF40_801E9DF8 *)D_801F2410)[i] = ((Blk4_8017DF40_801E9DF8 *)D_800BA2B8)[i]; + } + } +} + extern void func_8014B00C(void); extern void func_80029344(void); diff --git a/src/md_SC05_026/md_SC05_026.c b/src/md_SC05_026/md_SC05_026.c index ed79def435..7ac1dba1bc 100644 --- a/src/md_SC05_026/md_SC05_026.c +++ b/src/md_SC05_026/md_SC05_026.c @@ -277,7 +277,63 @@ INCLUDE_ASM("asm/md_SC05_026/nonmatchings/md_SC05_026", func_801EFA40); INCLUDE_ASM("asm/md_SC05_026/nonmatchings/md_SC05_026", func_801EFC30); -INCLUDE_ASM("asm/md_SC05_026/nonmatchings/md_SC05_026", func_801EFC58); + +/* 152-byte engine block, copied whole (struct assignment -> 9x16B block move + 8B tail). + * Uniquely suffixed: the host TU already sees `Blk152` from engine_types.h, and a C89 + * re-typedef of a visible name is a redefinition error. Same layout, same codegen. */ +typedef struct { u32 w[38]; } Blk152_8017DF40_801EFC58; +/* ALIGN-1 4-byte element => lwl/lwr + swl/swr (cookbook §160a); a u32[] loop is wrong. */ +typedef struct { u8 b[4]; } Blk4_8017DF40_801EFC58; + + + +/* Param is declared s32 by the host TU's file-scope prototype (:3695); the true test is + * 16-bit (`sll $a0,$a0,16 ; bnez`, no sra), so the truncation lives in the test instead. */ +void func_801EFC58(s32 arg0) { + + extern u8 D_80078E78[]; /* live: 152-byte block (host TU declares this identically) */ + extern u16 D_800A6588[]; /* live: u16[64] */ + extern u8 D_800AE648[]; /* live: u8[64] */ + extern u8 D_800BA1B8[]; /* live: u8[256] */ + extern u8 D_800BA2B8[]; /* live: 4-byte struct[24], align 1 */ + extern u8 D_801F8040[]; /* shadow: +0x000 */ + extern u16 D_801F80D8[]; /* shadow: +0x098 */ + extern u8 D_801F8158[]; /* shadow: +0x118 */ + extern u8 D_801F8198[]; /* shadow: +0x158 */ + extern u8 D_801F8298[]; /* shadow: +0x258 */ + s16 i; + + if ((s16)arg0 == 0) { + *(Blk152_8017DF40_801EFC58 *)D_80078E78 = *(Blk152_8017DF40_801EFC58 *)D_801F8040; + for (i = 0; i < 64; i++) { + D_800A6588[i] = D_801F80D8[i]; + } + for (i = 0; i < 64; i++) { + D_800AE648[i] = D_801F8158[i]; + } + for (i = 0; i < 256; i++) { + D_800BA1B8[i] = D_801F8198[i]; + } + for (i = 0; i < 24; i++) { + ((Blk4_8017DF40_801EFC58 *)D_800BA2B8)[i] = ((Blk4_8017DF40_801EFC58 *)D_801F8298)[i]; + } + } else { + *(Blk152_8017DF40_801EFC58 *)D_801F8040 = *(Blk152_8017DF40_801EFC58 *)D_80078E78; + for (i = 0; i < 64; i++) { + D_801F80D8[i] = D_800A6588[i]; + } + for (i = 0; i < 64; i++) { + D_801F8158[i] = D_800AE648[i]; + } + for (i = 0; i < 256; i++) { + D_801F8198[i] = D_800BA1B8[i]; + } + for (i = 0; i < 24; i++) { + ((Blk4_8017DF40_801EFC58 *)D_801F8298)[i] = ((Blk4_8017DF40_801EFC58 *)D_800BA2B8)[i]; + } + } +} + extern void func_8014B00C(void); extern void func_80029344(void);