Moving Up And Down (0x3B30) Behavior first call (0x802EFCD0)


** Moving Up And Down (0x3B30) first call = process arguments **

802EFCD0: ADDIU SP, SP, 0xFFF8 
802EFCD4: LUI T6, 0x8036
802EFCD8: LW T6, 0x1160 (T6)       ; t6 = pointer to RAM object
802EFCDC: LW A0, 0x0144 (T6)       ; load arg (Param2) from 0x24 command in a0
802EFCE0: BEQ A0, R0, 0x802EFD08   ; if a0 == 0 -> 802efd08
802EFCE4: NOP
802EFCE8: ADDIU AT, R0, 0x0001
802EFCEC: BEQ A0, AT, 0x802EFD10   ; if a0 == 1 -> 802efd10
802EFCF0: NOP
802EFCF4: ADDIU AT, R0, 0x0002
802EFCF8: BEQ A0, AT, 0x802EFD48   ; if a0 == 2 -> 802efd48
802EFCFC: NOP
802EFD00: BEQ R0, R0, 0x802EFD7C   ; else -> 802efd7C
802EFD04: NOP

; (if Param 2 == 0)

802EFD08: BEQ R0, R0, 0x802EFD7C   ; break;
802EFD0C: NOP

; (if Param 2 == 1)

802EFD10: LUI T7, 0x8036
802EFD14: LW T7, 0x1160 (T7)        ; t7 = pointer to RAM object
802EFD18: LUI AT, 0x4380            ; at = 43800000
802EFD1C: MTC1 AT, F6               ; f6 = (float)43800000 [256 dec]
802EFD20: LWC1 F4, 0x00A4 (T7)      ; get y position (set by 0x24 command)
802EFD24: SUB.S F8, F4, F6          ; y -= 256
802EFD28: SWC1 F8, 0x00A4 (T7)      ; write new y position
802EFD2C: LUI T8, 0x8036
802EFD30: LW T8, 0x1160 (T8)
802EFD34: LW T9, 0x0154 (T8)        ; t9 = 0x154 from RAM object
802EFD38: ADDIU T0, T9, 0x0032      ; t9 = t9 + 0x32
802EFD3C: SW T0, 0x0154 (T8)        ; 0x154 (RAM object) = t9
802EFD40: BEQ R0, R0, 0x802EFD7C    ; break;
802EFD44: NOP

; (if Param 2 == 2)

802EFD48: LUI T1, 0x8036
802EFD4C: LW T1, 0x1160 (T1)        ; t1 = RAM object pointer
802EFD50: LUI AT, 0x4400
802EFD54: MTC1 AT, F16              ; f6 = (float)0x44000000 [512 dec]
802EFD58: LWC1 F10, 0x00A4 (T1)
802EFD5C: SUB.S F18, F10, F16       ; y -= 512
802EFD60: SWC1 F18, 0x00A4 (T1)     ; write new y
802EFD64: LUI T3, 0x8036
802EFD68: LW T3, 0x1160 (T3)        ; t6 = pointer for RAM object
802EFD6C: ADDIU T2, R0, 0x0001      ; t2 = 1
802EFD70: SW T2, 0x014C (T3)        ; Obj->0x14c (action) = 1
802EFD74: BEQ R0, R0, 0x802EFD7C    ; break;
802EFD78: NOP

; default (= do nothing)

802EFD7C: BEQ R0, R0, 0x802EFD84
802EFD80: NOP
802EFD84: JR RA
802EFD88: ADDIU SP, SP, 0x0008

---

Something like this in pseudo-C:

void InitMovingUpAndDown()
{

    switch (Param2) {
                    case 0x00:
                    break;

                    case 0x01:
                    obj->y -= 256;
                    obj->0x154 += 0x32;
                    break;

                    case 0x02:
                    obj->y -= 512;
                    obj->action = 1;
                    break;

                    default:
                    break;
     }

}
Comments