diff options
Diffstat (limited to 'arm9/src')
-rw-r--r-- | arm9/src/msgdata.c | 166 | ||||
-rw-r--r-- | arm9/src/nutdata.c | 8 | ||||
-rw-r--r-- | arm9/src/pokemon.c | 5 |
3 files changed, 173 insertions, 6 deletions
diff --git a/arm9/src/msgdata.c b/arm9/src/msgdata.c index 007cb471..76d44338 100644 --- a/arm9/src/msgdata.c +++ b/arm9/src/msgdata.c @@ -4,6 +4,7 @@ #include "heap.h" #include "MI_memory.h" #include "string16.h" +#include "proto.h" #pragma thumb on @@ -18,6 +19,8 @@ void FUN_0200A648(NarcId narc_id, u32 group, u32 num, u32 heap_id, struct String void FUN_0200A670(NARC * narc, u32 group, u32 num, u32 heap_id, struct String * dest); struct String * FUN_0200A738(NarcId narc_id, u32 group, u32 num, u32 heap_id); struct String * FUN_0200A76C(NARC * narc, u32 group, u32 num, u32 heap_id); +u16 FUN_0200A848(struct UnkStruct_200A394 * tbl); +u16 FUN_0200A84C(NarcId narc_id, s32 file_id); void * LoadSingleElementFromNarc(NarcId narc_id, s32 file_id, u32 heap_id) { @@ -234,3 +237,166 @@ struct String * FUN_0200A76C(NARC * narc, u32 group, u32 num, u32 heap_id) return FUN_020219F4(4, heap_id); } } + +u16 FUN_0200A848(struct UnkStruct_200A394 * tbl) +{ + return tbl->unk0; +} + +u16 FUN_0200A84C(NarcId narc_id, s32 file_id) +{ + u16 n[2]; + ReadFromNarcMemberByIdPair(&n, narc_id, file_id, 0, 4); + return n[0]; +} + +struct MsgData * NewMsgDataFromNarc(u32 type, NarcId narc_id, s32 file_id, u32 heap_id) +{ + struct MsgData * msgData = AllocFromHeapAtEnd(heap_id, sizeof(struct MsgData)); + if (msgData != NULL) + { + if (type == 0) + { + msgData->data.raw = LoadSingleElementFromNarc(narc_id, file_id, heap_id); + if (msgData->data.raw == NULL) + { + FreeToHeap(msgData); + return NULL; + } + } + else + { + msgData->data.narc = NARC_ctor(narc_id, heap_id); + } + msgData->type = (u16)type; + msgData->narc_id = (u16)narc_id; + msgData->file_id = (u16)file_id; + msgData->heap_id = (u16)heap_id; + } + return msgData; +} + +void DestroyMsgData(struct MsgData * msgData) +{ + if (msgData != NULL) + { + switch (msgData->type) + { + case 0: + FreeMsgDataRawData(msgData->data.raw); + break; + case 1: + NARC_dtor(msgData->data.narc); + break; + } + FreeToHeap(msgData); + } +} + +void FUN_0200A8E0(struct MsgData * msgData, u32 msg_no, struct String * dest) +{ + switch (msgData->type) + { + case 0: + FUN_0200A4D4(msgData->data.raw, msg_no, dest); + break; + case 1: + FUN_0200A670(msgData->data.narc, msgData->file_id, msg_no, msgData->heap_id, dest); + break; + } +} + +struct String * FUN_0200A914(struct MsgData * msgData, u32 msg_no) +{ + switch (msgData->type) + { + case 0: + return FUN_0200A584(msgData->data.raw, msg_no, msgData->heap_id); + case 1: + return FUN_0200A76C(msgData->data.narc, msgData->file_id, msg_no, msgData->heap_id); + default: + return NULL; + } +} + +u16 FUN_0200A940(struct MsgData * msgData) +{ + switch (msgData->type) + { + case 0: + return FUN_0200A848(msgData->data.raw); + case 1: + return FUN_0200A84C((NarcId)msgData->narc_id, msgData->file_id); + default: + return 0; + } +} + +void DecryptCopyString(struct MsgData * msgData, u32 msg_no, u16 * dest) +{ + switch (msgData->type) + { + case 0: + DecryptMessageDirect(msgData->data.raw, msg_no, dest); + break; + case 1: + DecryptMessageViaNewNarcHandle((NarcId)msgData->narc_id, msgData->file_id, msg_no, msgData->heap_id, dest); + break; + } +} + +void GetSpeciesName(u16 species, u32 heap_id, u16 * dest) +{ + struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 362, heap_id); + DecryptCopyString(msgData, species, dest); + DestroyMsgData(msgData); +} + +struct String * FUN_0200A9C4(u32 * a0, struct MsgData * msgData, u32 msgno, struct String * a3) +{ + struct String * ret = NULL; + struct String * r4 = FUN_020219F4(1024, 0); + struct String * r5; + if (r4 != NULL) + { + r5 = FUN_0200A914(msgData, msgno); + if (r5 != NULL) + { + FUN_0200B7B8(a0, r4, r5); + ret = FUN_02021ACC(r4, a3); + FUN_02021A20(r5); + } + FUN_02021A20(r4); + } + return ret; +} + +struct String * FUN_0200AA14(u32 msg_no, u32 heapno) +{ + struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 588, heapno); + struct String * ret; + if (msgData != NULL) + { + ret = FUN_020219F4(16, heapno); + if (ret != NULL) + { + FUN_0200A8E0(msgData, msg_no, ret); + } + DestroyMsgData(msgData); + return ret; + } + return NULL; +} + +struct String * FUN_0200AA50(u16 species, u32 heap_id) +{ + struct String * ret; + struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 362, heap_id); + if (msgData != NULL) + { + ret = FUN_0200A914(msgData, species); + DestroyMsgData(msgData); + return ret; + } + return NULL; +} diff --git a/arm9/src/nutdata.c b/arm9/src/nutdata.c index 09542052..bce5c291 100644 --- a/arm9/src/nutdata.c +++ b/arm9/src/nutdata.c @@ -61,18 +61,18 @@ u32 GetNutAttr(struct NutData * nut, u32 attr) } } -u16 * GetNutName(u32 berry_idx, u32 heap_id) +struct String * GetNutName(u32 berry_idx, u32 heap_id) { struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 373, heap_id); - u16 * ret = FUN_0200A914(msgData, berry_idx); + struct String * ret = FUN_0200A914(msgData, berry_idx); DestroyMsgData(msgData); return ret; } -u16 * GetNutDesc(u32 berry_idx, u32 heap_id) +struct String * GetNutDesc(u32 berry_idx, u32 heap_id) { struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 372, heap_id); - u16 * ret = FUN_0200A914(msgData, berry_idx); + struct String * ret = FUN_0200A914(msgData, berry_idx); DestroyMsgData(msgData); return ret; } diff --git a/arm9/src/pokemon.c b/arm9/src/pokemon.c index 8df597a6..f3f094bb 100644 --- a/arm9/src/pokemon.c +++ b/arm9/src/pokemon.c @@ -10,6 +10,7 @@ #include "move_data.h" #include "string_util.h" #include "text.h" +#include "msg_data.h" #include "constants/abilities.h" #include "constants/items.h" #include "constants/moves.h" @@ -860,7 +861,7 @@ u32 GetBoxMonDataInternal(struct BoxPokemon * boxmon, int attr, void * dest) case MON_DATA_NICKNAME_3: if (boxmon->checksum_fail) { - u16 * buffer = FUN_0200AA50(SPECIES_MANAPHY_EGG, 0); + struct String * buffer = FUN_0200AA50(SPECIES_MANAPHY_EGG, 0); FUN_02021A74(dest, buffer); FUN_02021A20(buffer); } @@ -1090,7 +1091,7 @@ void SetBoxMonDataInternal(struct BoxPokemon * boxmon, int attr, void * value) u16 namebuf[POKEMON_NAME_LENGTH + 1]; u16 namebuf2[POKEMON_NAME_LENGTH + 1]; u16 namebuf3[POKEMON_NAME_LENGTH + 1]; - u16 * speciesName; + struct String * speciesName; PokemonDataBlockA *blockA = &GetSubstruct(boxmon, boxmon->pid, 0)->blockA; PokemonDataBlockB *blockB = &GetSubstruct(boxmon, boxmon->pid, 1)->blockB; |