From 46deaccf9638fa5de74e05db2a59bc01c7925ecd Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sun, 29 Nov 2020 16:54:22 +1000 Subject: [PATCH] Decompile objectiveInsert --- src/game/game_00c490.c | 8 ++++---- src/game/game_0109d0.c | 27 ++++++++------------------- src/include/game/game_0109d0.h | 2 +- src/include/types.h | 21 +++++++-------------- 4 files changed, 20 insertions(+), 38 deletions(-) diff --git a/src/game/game_00c490.c b/src/game/game_00c490.c index 8232a0975..7a4515eba 100644 --- a/src/game/game_00c490.c +++ b/src/game/game_00c490.c @@ -3228,13 +3228,13 @@ void setupParseObjects(s32 stagenum) break; case OBJTYPE_BEGINOBJECTIVE: { - struct beginobjectiveobj *objective = (struct beginobjectiveobj *)obj; + struct objective *objective = (struct objective *)obj; - func0f010a98(obj); + objectiveInsert(objective); - if (objective->index < 7) { + if ((u32)objective->index < 7) { g_Briefing.objectivenames[objective->index] = objective->text; - g_Briefing.objectivedifficulties[objective->index] = (s8)objective->difficulty; + g_Briefing.objectivedifficulties[objective->index] = objective->difficulties; } } break; diff --git a/src/game/game_0109d0.c b/src/game/game_0109d0.c index 5c9a10392..e4b528f69 100644 --- a/src/game/game_0109d0.c +++ b/src/game/game_0109d0.c @@ -69,25 +69,14 @@ void briefingInsert(struct briefingobj *briefing) g_BriefingObjs = briefing; } -GLOBAL_ASM( -glabel func0f010a98 -/* f010a98: 8c8e0004 */ lw $t6,0x4($a0) -/* f010a9c: 3c01800a */ lui $at,%hi(g_Objectives) -/* f010aa0: 3c038007 */ lui $v1,%hi(g_ObjectiveLastIndex) -/* f010aa4: 000e7880 */ sll $t7,$t6,0x2 -/* f010aa8: 002f0821 */ addu $at,$at,$t7 -/* f010aac: ac24d060 */ sw $a0,%lo(g_Objectives)($at) -/* f010ab0: 2463ae70 */ addiu $v1,$v1,%lo(g_ObjectiveLastIndex) -/* f010ab4: 8c780000 */ lw $t8,0x0($v1) -/* f010ab8: 8c820004 */ lw $v0,0x4($a0) -/* f010abc: 0302082a */ slt $at,$t8,$v0 -/* f010ac0: 10200002 */ beqz $at,.L0f010acc -/* f010ac4: 00000000 */ nop -/* f010ac8: ac620000 */ sw $v0,0x0($v1) -.L0f010acc: -/* f010acc: 03e00008 */ jr $ra -/* f010ad0: 00000000 */ nop -); +void objectiveInsert(struct objective *objective) +{ + g_Objectives[objective->index] = objective; + + if (g_ObjectiveLastIndex < objective->index) { + g_ObjectiveLastIndex = objective->index; + } +} void objectiveAddRoomEnteredCriteria(struct criteria_roomentered *criteria) { diff --git a/src/include/game/game_0109d0.h b/src/include/game/game_0109d0.h index b083e9f75..9ea534c12 100644 --- a/src/include/game/game_0109d0.h +++ b/src/include/game/game_0109d0.h @@ -6,7 +6,7 @@ void func0f0109d0(void); void tagInsert(struct tag *tag); void briefingInsert(struct briefingobj *obj); -void func0f010a98(struct defaultobj *obj); +void objectiveInsert(struct objective *objective); void objectiveAddRoomEnteredCriteria(struct criteria_roomentered *criteria); void objectiveAddMultiroomEnteredCriteria(struct criteria_multiroomentered *criteria); void objectiveAddHolographCriteria(struct criteria_holograph *criteria); diff --git a/src/include/types.h b/src/include/types.h index 6b643c37b..6100667c1 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -1375,11 +1375,13 @@ struct tag { // objtype 0x16 /*0x0c*/ struct defaultobj *obj; }; -struct beginobjectiveobj { // objtype 0x17 - u32 unk00; - u32 index; - u32 text; - u32 difficulty; +struct objective { // objtype 0x17 + /*0x00*/ u32 unk00; + /*0x04*/ s32 index; + /*0x08*/ u32 text; + /*0x0c*/ u16 unk0c; + /*0x0e*/ u8 unk0e; + /*0x0f*/ s8 difficulties; }; struct briefingobj { // objtype 0x23 @@ -4736,15 +4738,6 @@ struct activemenuthing { /*0x34*/ u8 unk34; }; -struct objective { // representation of setup file beginobjective macro - /*0x00*/ u32 unk00; - /*0x04*/ u32 unk04; - /*0x08*/ u32 text; - /*0x0c*/ u16 unk0c; - /*0x0e*/ u8 unk0e; - /*0x0f*/ s8 difficulties; -}; - struct briefing { u16 briefingtextnum; u16 objectivenames[6]; // index 0 is the briefing, and the rest are objectives