Skip to content

Patterns

Mark Street edited this page Nov 9, 2020 · 11 revisions

b/nop

348:    bne     t8,at,380 ~>                      i 348:    bne     t8,at,378 ~>
34c:    nop                                         34c:    nop
350:    b       358 ~>                            <
354:    nop                                       <
358: ~> li      t9,0x20                             350:    li      t9,0x20
35c:    sh      t9,0x1c(sp)                         354:    sh      t9,0x1c(sp)
360:    lw      t0,0x2c(sp)                         358:    lw      t0,0x2c(sp)

This occurs when there is an if(0) {} statement with -g.

'arg0 + 0x10' when arg0 is a struct

func_8001C770(arg0 + 0x10);

becomes

func_8001C770(&arg0->unk10);

padded stacks

    u32 pad0;
    u8  pad1;
    u8  sp22;
    s8  sp21;
    s8  sp20;
    s32 sp1C;
    u16 pad2;
    s16 sp18;

    sp18 = 2;
    sp1C = 0;
    sp20 = arg1 | 0xB0;
    sp21 = 0xA;
    sp22 = arg2;

becomes (be aware of reversed ordering!)

typedef struct {
    s16 unk0;
    u16 unk2;
    s32 unk4;
    u8  unk8;
    u8  unk9;
    u8  unkA;
    u8  unkB;
    u32 unkC;
} struct33;

..

    struct33 tmp;

    tmp.unk0 = 2;
    tmp.unk4 = 0;
    tmp.unk8 = arg1 | 0xB0;
    tmp.unk9 = 0xA;
    tmp.unkA = arg2;

..

missing arg0

void func_80009600(? arg1) {
    func_85161334(0xFF, 1);
}

becomes

void func_80009600(s32 arg0, s32 arg1) {
    func_85161334(arg0, 0xFF, 1);
}

crazy struct offset

    temp_a0 = ((D_800BE9F0 * 4) + 0x80090000)->unk1C04;

becomes

    temp_a0 = D_80091C04[D_800BE9F0]

Clone this wiki locally