From a78c5711380f5a683ad0c3180aafd6ae0c3a49e5 Mon Sep 17 00:00:00 2001 From: AnonymousRandomPerson Date: Thu, 19 Mar 2026 21:10:54 -0400 Subject: [PATCH] Decomped sub_0205C75C Decomped by @slaw-22 --- .../{main_0205C75C.inc => main_0205C854.inc} | 0 asm/{main_0205C75C.s => main_0205C854.s} | 73 +----- include/dungeon_mode.h | 5 +- include/enums.h | 34 --- include/main_0205C73C.h | 1 + include/mission.h | 207 ++++++++++++++++++ main.lsf | 2 +- src/main_0205C73C.c | 35 ++- 8 files changed, 246 insertions(+), 111 deletions(-) rename asm/include/{main_0205C75C.inc => main_0205C854.inc} (100%) rename asm/{main_0205C75C.s => main_0205C854.s} (99%) create mode 100644 include/mission.h diff --git a/asm/include/main_0205C75C.inc b/asm/include/main_0205C854.inc similarity index 100% rename from asm/include/main_0205C75C.inc rename to asm/include/main_0205C854.inc diff --git a/asm/main_0205C75C.s b/asm/main_0205C854.s similarity index 99% rename from asm/main_0205C75C.s rename to asm/main_0205C854.s index 23489054..1d3d33ab 100644 --- a/asm/main_0205C75C.s +++ b/asm/main_0205C854.s @@ -1,79 +1,8 @@ .include "asm/macros.inc" - .include "main_0205C75C.inc" + .include "main_0205C854.inc" .text - arm_func_start sub_0205C75C -sub_0205C75C: ; 0x0205C75C - stmdb sp!, {r3, r4, r5, lr} - ldr r4, _0205C850 ; =MISSION_DELIVER_LIST_PTR - mov r5, #0 -_0205C768: - ldr r1, [r4, #0x18] - mov r0, r5, lsl #0x18 - add r0, r1, r0, asr #19 - bl ClearMissionData - add r5, r5, #1 - cmp r5, #8 - blt _0205C768 - ldr r4, _0205C850 ; =MISSION_DELIVER_LIST_PTR - mov r5, #0 -_0205C78C: - ldr r1, [r4, #0x18] - mov r0, r5, lsl #0x18 - add r1, r1, #0x100 - add r0, r1, r0, asr #19 - bl ClearMissionData - add r5, r5, #1 - cmp r5, #8 - blt _0205C78C - ldr r4, _0205C850 ; =MISSION_DELIVER_LIST_PTR - mov r5, #0 -_0205C7B4: - ldr r1, [r4, #0x18] - mov r0, r5, lsl #0x18 - add r1, r1, #0x200 - add r0, r1, r0, asr #19 - bl ClearMissionData - add r5, r5, #1 - cmp r5, #8 - blt _0205C7B4 - ldr r0, _0205C850 ; =MISSION_DELIVER_LIST_PTR - ldr r0, [r0, #0x18] - add r0, r0, #0x300 - bl ClearMissionData - ldr r0, _0205C850 ; =MISSION_DELIVER_LIST_PTR - ldr r0, [r0, #0x18] - add r0, r0, #0x320 - bl ClearMissionData - mov r0, #0 - ldr r2, _0205C850 ; =MISSION_DELIVER_LIST_PTR - mov lr, #0xff - mov ip, #1 - mov r4, r0 - mov r1, #0xc -_0205C80C: - mul r5, r0, r1 - ldr r3, [r2, #0x18] - add r0, r0, #1 - add r3, r3, r5 - strb lr, [r3, #0x340] - ldr r3, [r2, #0x18] - cmp r0, #0x10 - add r3, r3, r5 - strb ip, [r3, #0x341] - ldr r3, [r2, #0x18] - add r3, r3, r5 - str r4, [r3, #0x344] - ldr r3, [r2, #0x18] - add r3, r3, r5 - str r4, [r3, #0x348] - blt _0205C80C - ldmia sp!, {r3, r4, r5, pc} - .align 2, 0 -_0205C850: .word MISSION_DELIVER_LIST_PTR - arm_func_end sub_0205C75C - arm_func_start IsMissionSuspendedAndValid IsMissionSuspendedAndValid: ; 0x0205C854 stmdb sp!, {r3, lr} diff --git a/include/dungeon_mode.h b/include/dungeon_mode.h index 0cd29012..4e686d30 100644 --- a/include/dungeon_mode.h +++ b/include/dungeon_mode.h @@ -3,9 +3,10 @@ #include "direction.h" #include "enums.h" -#include "item.h" -#include "move.h" #include "graphics.h" +#include "item.h" +#include "mission.h" +#include "move.h" #include "util.h" #define NUM_PICKED_IQ_SKILLS 3 diff --git a/include/enums.h b/include/enums.h index 9339e0ca..f0c00df8 100644 --- a/include/enums.h +++ b/include/enums.h @@ -2555,40 +2555,6 @@ enum status_blinker_id { STATUS_BLINKER_DROPEYE = 4, }; -// Mission type on a floor -enum mission_type { - MISSION_RESCUE_CLIENT = 0, - MISSION_RESCUE_TARGET = 1, - MISSION_ESCORT_TO_TARGET = 2, - MISSION_EXPLORE_WITH_CLIENT = 3, - MISSION_PROSPECT_WITH_CLIENT = 4, - MISSION_GUIDE_CLIENT = 5, - MISSION_FIND_ITEM = 6, - MISSION_DELIVER_ITEM = 7, - MISSION_SEARCH_FOR_TARGET = 8, - MISSION_TAKE_ITEM_FROM_OUTLAW = 9, - MISSION_ARREST_OUTLAW = 10, - MISSION_CHALLENGE_REQUEST = 11, - MISSION_TREASURE_MEMO = 12, - MISSION_TYPE_UNK_0xD = 13, - MISSION_SPECIAL_EPISODE = 14, -}; - -// Mission subtype for MISSION_ARREST_OUTLAW -// 0-3 all occur naturally in-game, the distinction is in intensity of the mission. -// Each uses a different table of outlaws of varying difficulties. -enum mission_subtype_outlaw { - MISSION_OUTLAW_NORMAL_0 = 0, // in mission_template, client is magnezone - MISSION_OUTLAW_NORMAL_1 = 1, // in mission_template, client is magnezone - MISSION_OUTLAW_NORMAL_2 = 2, // in mission_template, client is magnemite - MISSION_OUTLAW_NORMAL_3 = 3, // in mission_template, client is magnemite - MISSION_OUTLAW_ESCORT = 4, - MISSION_OUTLAW_FLEEING = 5, - // One of 30 specific pairings (IE: Vespiquen/Combee, Golduck/Psyduck, Cloyster/Clampearl) - MISSION_OUTLAW_HIDEOUT = 6, - MISSION_OUTLAW_MONSTER_HOUSE = 7, -}; - // Fixed room ID. Fixed rooms can be full floor layouts, like most end-of-dungeon boss chambers, // multi-room layouts in the case of Treasure Memos, or single rooms within a larger floor layout // like with key chambers. diff --git a/include/main_0205C73C.h b/include/main_0205C73C.h index 7ae3cb55..5423f7f1 100644 --- a/include/main_0205C73C.h +++ b/include/main_0205C73C.h @@ -2,5 +2,6 @@ #define PMDSKY_MAIN_0205C73C_H void sub_0205C73C(void); +void sub_0205C75C(void); #endif //PMDSKY_MAIN_0205C73C_H diff --git a/include/mission.h b/include/mission.h new file mode 100644 index 00000000..d4b25280 --- /dev/null +++ b/include/mission.h @@ -0,0 +1,207 @@ +#ifndef PMDSKY_MISSION_H +#define PMDSKY_MISSION_H + +#include "enums.h" +#include "item.h" + +// Represents the different statuses that a mission can have +enum mission_status { + MISSION_STATUS_INVALID = 0, // Used for empty mission slots + MISSION_STATUS_UNK_1 = 1, // The mission won't display a status + MISSION_STATUS_UNK_2 = 2, // The mission won't display a status + MISSION_STATUS_UNK_3 = 3, // The mission won't display a status + MISSION_STATUS_SUSPENDED = 4, + MISSION_STATUS_ACCEPTED = 5, + MISSION_STATUS_DONE = 6, + MISSION_STATUS_UNK_7 = 7, // Shows up as "accepted" + MISSION_STATUS_UNK_8 = 8, // Shows up as "accepted" +}; + +// Different types of rewards that a mission can have +enum mission_reward_type { + MISSION_REWARD_MONEY = 0, + MISSION_REWARD_MONEY_AND_MORE = 1, // Money + (?) + MISSION_REWARD_ITEM = 2, + MISSION_REWARD_ITEM_AND_MORE = 3, // Item + (?) + // Exclusive Item, displayed as "(?)" (Will be 1 star, and beneficial of the client/target) + // $SCENARIO_MAIN must be [8, 0] or above AND mission rank must be >=5 stars to be selected. + // Also used for the Togetic Wing given from the Gabite Scale mission. + MISSION_REWARD_EXCLUSIVE_ITEM = 4, + // Money, displayed as "(?)" + // $SCENARIO_MAIN must be [12, 0] or above to be selected. + MISSION_REWARD_MONEY_HIDDEN = 5, + // Either an egg or the client requests to join the team, displayed as "(?)" + // $SCENARIO_MAIN must be [6, 0] or above for this to be selected + MISSION_REWARD_SPECIAL = 6, +}; + +// Mission type on a floor +enum mission_type { + MISSION_RESCUE_CLIENT = 0, + MISSION_RESCUE_TARGET = 1, + MISSION_ESCORT_TO_TARGET = 2, + MISSION_EXPLORE_WITH_CLIENT = 3, + MISSION_PROSPECT_WITH_CLIENT = 4, + MISSION_GUIDE_CLIENT = 5, + MISSION_FIND_ITEM = 6, + MISSION_DELIVER_ITEM = 7, + MISSION_SEARCH_FOR_TARGET = 8, + MISSION_TAKE_ITEM_FROM_OUTLAW = 9, + MISSION_ARREST_OUTLAW = 10, + MISSION_CHALLENGE_REQUEST = 11, + MISSION_TREASURE_MEMO = 12, + MISSION_TYPE_UNK_0xD = 13, + MISSION_TYPE_CONSUMABLE = 14 // Used for SE3 wondermail and Seven Treasures! +}; + +// Mission subtype for MISSION_RESCUE_TARGET +// The distinction is mainly for dialogue +enum mission_subtype_rescue_target { + // Client and Target are randomly selected + MISSION_RESCUE_CLIENT_TARGET_RANDOM = 0, + // Client is the evolved form of the target + // (IE: Beedrill/Weedle, Aggron/Aron) + MISSION_RESCUE_CLIENT_TARGET_CHILD = 1, + // Client and Target are deeply similar + // (IE: Dodrio/Exeggutor, Muk/Swalot, Magikarp/Feebas) + MISSION_RESCUE_CLIENT_TARGET_SIMILAR_FRIENDS = 2, + // Client and Target are lovers or rivals + // (IE: Nidoking/Nidoqueen, Seviper/Zangoose, Volbeat/Illumise) + MISSION_RESCUE_CLIENT_TARGET_LOVERS_RIVALS = 3 +}; + +// Mission subtype for MISSION_ESCORT_TO_TARGET +enum mission_subtype_escort_to_target { + // Client and Target are randomly selected + MISSION_ESCORT_CLIENT_TARGET_RANDOM = 0, + // Client and Target are counterparts + // (IE: Nidoran-M/Nidoran-F, Volbeat/Illumise, Miltank/Tauros) + MISSION_ESCORT_CLIENT_TARGET_SPECIFIC = 1 +}; + +// Mission subtype for MISSION_EXPLORE_WITH_CLIENT +enum mission_subtype_explore { + MISSION_EXPLORE_NORMAL = 0, + MISSION_EXPLORE_SEALED_CHAMBER = 1, + MISSION_EXPLORE_GOLDEN_CHAMBER = 2, + MISSION_EXPLORE_NEW_DUNGEON = 3, +}; + +// Mission subtype for MISSION_FIND_ITEM +enum mission_subtype_find_item { + // In the template, pulls from the "common" table in rescue_item_tables. + // Client is random + MISSION_FIND_ITEM_COMMON_TABLE = 0, + // In the template, pulls from the "rare" table in rescue_item_tables. + // Client is random + MISSION_FIND_ITEM_RARE_TABLE = 1, + // Item is an evolution item for the client + // (IE: Gloom/Leaf Stone, Dusclops/Reaper Cloth, Magmar/Magmarizer) + MISSION_FIND_ITEM_EVOLVES_CLIENT = 2, + // Item is a gummi of one of the client's types + // (IE: Flaafy/Yellow Gummi, Baltoy/Brown Gummi, Dratini/Royal Gummi) + MISSION_FIND_ITEM_CLIENT_FAVORITE_GUMMI = 3, + // This is the special Togetic Mission that unlocks Labyrinth Cave + MISSION_TOGETIC_GABITE_SCALE = 4 +}; + +// Mission subtype for MISSION_TAKE_ITEM_FROM_OUTLAW +// Random Client and Outlaw. NOT Magnezone/Magnemite +enum mission_subtype_take_item { + MISSION_TAKE_ITEM_NORMAL_OUTLAW = 0, + MISSION_TAKE_ITEM_HIDDEN_OUTLAW = 1, + MISSION_TAKE_ITEM_FLEEING_OUTLAW = 2, +}; + +// Mission subtype for MISSION_ARREST_OUTLAW +// 0-3 all occur naturally in-game, the distinction is in intensity of the mission. +// Each uses a different table of outlaws of varying difficulties. +enum mission_subtype_outlaw { + MISSION_OUTLAW_NORMAL_0 = 0, // in mission_template, client is magnezone + MISSION_OUTLAW_NORMAL_1 = 1, // in mission_template, client is magnezone + MISSION_OUTLAW_NORMAL_2 = 2, // in mission_template, client is magnemite + MISSION_OUTLAW_NORMAL_3 = 3, // in mission_template, client is magnemite + MISSION_OUTLAW_ESCORT = 4, + MISSION_OUTLAW_FLEEING = 5, + // One of 30 specific pairings (IE: Vespiquen/Combee, Golduck/Psyduck, Cloyster/Clampearl) + MISSION_OUTLAW_HIDEOUT = 6, + MISSION_OUTLAW_MONSTER_HOUSE = 7, +}; + +// Mission subtype for MISSION_CHALLENGE_REQUEST +enum mission_subtype_challenge { + // One of 28 specific pairings + // (IE: Charizard/Blastoise/Venusaur, Hitmontop/Hitmonchan/HitmonLee, + // Nidoking/Nidorina/Nidorino) + MISSION_CHALLENGE_NORMAL = 0, + MISSION_CHALLENGE_MEWTWO = 1, + MISSION_CHALLENGE_ENTEI = 2, + MISSION_CHALLENGE_RAIKOU = 3, + MISSION_CHALLENGE_SUICUNE = 4, + MISSION_CHALLENGE_JIRACHI = 5, +}; + +// Mission subtype for MISSION_TYPE_CONSUMABLE +enum mission_subtype_consumable { + MISSION_CONSUMABLE_UNK_0 = 0, + // Subtype 0x1 is used in the template for seven-treasure missions + MISSION_SEVEN_TREASURE = 1, + // Subtype 0x2 is used by the SE3 wondermail + MISSION_SPECIAL_EPISODE = 2 +}; + +// The meaning of the mission subtype depends on the mission type +union mission_subtype { + enum mission_subtype_rescue_target rescue_target; + enum mission_subtype_escort_to_target escort; + enum mission_subtype_explore explore; + enum mission_subtype_find_item find_item; + enum mission_subtype_take_item take_item; + enum mission_subtype_outlaw outlaw; + enum mission_subtype_challenge challenge; + enum mission_subtype_consumable consumable; + u8 other; +}; + +// Different types of restrictions that a mission can have +enum mission_restriction_type { + MISSION_RESTRICTION_NONE = 0, + MISSION_RESTRICTION_TYPE = 1, // Requires a pokémon of a certain type on the team + MISSION_RESTRICTION_MONSTER = 2, // Requires a certain pokémon on the team +}; + +// The restriction of a mission can be a monster ID or a type ID +union mission_restriction { + enum monster_id monster_id; + enum type_id type_id; +}; + +// Contains the data for a single mission +struct mission { + enum mission_status status; // 0x0 + enum mission_type type; // 0x1 + union mission_subtype subtype; // 0x2 + enum dungeon_id dungeon_id; // 0x4 + u8 floor; // 0x5 + // 0x8: A random value determined by FUN_0205146C [EU], which is used to + // randomly generate the mission title and description. + s32 description_id; + u8 unique_map_id; // 0xC: for challenges/treasure hunts/certain outlaws + enum monster_id client; // 0xE: For challenge letter missions, stores the leader + // 0x10: For non-legendary challenge letter missions, stores the second team member + enum monster_id target; + // 0x12: For non-legendary challenge letter missions, stores the third team member + enum monster_id outlaw_backup_species; + enum item_id item_wanted; // 0x14 + enum mission_reward_type reward_type; // 0x16 + enum item_id item_reward; // 0x18 + enum mission_restriction_type restriction_type; // 0x1A + union mission_restriction restriction; // 0x1C +}; + +struct mission_deliver_list { + u8 unk0[0x18]; + u8* unk18; +}; + +#endif //PMDSKY_MISSION_H diff --git a/main.lsf b/main.lsf index 7dcaac7d..95b4d42f 100644 --- a/main.lsf +++ b/main.lsf @@ -162,7 +162,7 @@ Static main Object src/main_0205C440.o Object asm/main_0205C548.o Object src/main_0205C73C.o - Object asm/main_0205C75C.o + Object asm/main_0205C854.o Object src/dungeon_init_2.o Object asm/main_0206A750.o Object src/main_0206C98C.o diff --git a/src/main_0205C73C.c b/src/main_0205C73C.c index b2cb8dc3..63e35f9b 100644 --- a/src/main_0205C73C.c +++ b/src/main_0205C73C.c @@ -1,12 +1,43 @@ #include "main_0205C73C.h" +#include "mission.h" -extern u32 MISSION_DELIVER_LIST_PTR[]; +extern struct mission_deliver_list MISSION_DELIVER_LIST_PTR; extern u8 _022B6F10[]; extern void sub_020600CC(void); +extern void ClearMissionData(struct mission* mission); void sub_0205C73C(void) { - MISSION_DELIVER_LIST_PTR[6] = (u32)_022B6F10; + MISSION_DELIVER_LIST_PTR.unk18 = _022B6F10; sub_020600CC(); } + +void sub_0205C75C(void) +{ + for (s32 i = 0; i < 8; i++) + { + ClearMissionData((struct mission*) (MISSION_DELIVER_LIST_PTR.unk18 + (s32)(s8)i * 32)); + } + + for (s32 i = 0; i < 8; i++) + { + ClearMissionData((struct mission*) (MISSION_DELIVER_LIST_PTR.unk18 + 0x100 + (s32)(s8)i * 32)); + } + + for (s32 i = 0; i < 8; i++) + { + ClearMissionData((struct mission*) (MISSION_DELIVER_LIST_PTR.unk18 + 0x200 + (s32)(s8)i * 32)); + } + + ClearMissionData((struct mission*) (MISSION_DELIVER_LIST_PTR.unk18 + 0x300)); + ClearMissionData((struct mission*) (MISSION_DELIVER_LIST_PTR.unk18 + 0x320)); + + for (s32 i = 0; i < 16; i++) + { + MISSION_DELIVER_LIST_PTR.unk18[i * 12 + 0x340] = 0xFF; + MISSION_DELIVER_LIST_PTR.unk18[i * 12 + 0x341] = 1; + *(u32 *)&MISSION_DELIVER_LIST_PTR.unk18[i * 12 + 0x344] = 0; + *(u32 *)&MISSION_DELIVER_LIST_PTR.unk18[i * 12 + 0x348] = 0; + } +}