diff --git a/asm/code_801EE10.s b/asm/code_801EE10.s index a4fbcbac0..bbad0455e 100644 --- a/asm/code_801EE10.s +++ b/asm/code_801EE10.s @@ -319,7 +319,7 @@ _0801F074: movs r2, 0x34 ldrsh r0, [r1, r2] ldr r1, [r1, 0x10] - bl sub_8093400 + bl TryLinkMovesAfter movs r0, 0x6 bl PlayMenuSoundEffect movs r7, 0x1 @@ -1506,7 +1506,7 @@ sub_801F9A4: ldrh r1, [r3, 0x8] ldr r2, [r3, 0x5C] adds r3, 0x14 - bl sub_8093D9C + bl unk_MoveIDPrintMoveDescription ldr r1, [r5] str r0, [r1, 0x10] str r4, [r1, 0x24] @@ -2727,7 +2727,7 @@ _080203F8: adds r0, 0x24 ldr r1, [r1, 0x10] adds r1, 0x2C - bl sub_809401C + bl unk_CopyMoves4To8 ldr r0, [r5] movs r5, 0xC ldrsh r1, [r0, r5] @@ -3893,7 +3893,7 @@ _08020D14: adds r0, 0x24 ldr r1, [r1, 0x10] adds r1, 0x2C - bl sub_809401C + bl unk_CopyMoves4To8 movs r5, 0 adds r6, r4, 0 movs r4, 0x24 @@ -4249,7 +4249,7 @@ _0802101C: ldr r1, [r0] ldr r0, [r1, 0x18] adds r1, 0x24 - bl sub_8093400 + bl TryLinkMovesAfter b _08021068 .align 2, 0 _0802102C: .4byte 0x00000133 @@ -4365,7 +4365,7 @@ _08021108: adds r0, r1, 0 adds r0, 0x24 ldr r1, [r1, 0x18] - bl sub_8093CF8 + bl RemoveLinkSequenceFromMoves8 movs r0, 0x23 bl sub_801FDA8 b _0802112A diff --git a/asm/code_805D8C8.s b/asm/code_805D8C8.s index cf83e1123..b8760d992 100644 --- a/asm/code_805D8C8.s +++ b/asm/code_805D8C8.s @@ -11916,7 +11916,7 @@ _08063898: adds r0, r4, 0 movs r2, 0 mov r3, r10 - bl sub_8093DE8 + bl unk_PrintMoveDescription mov r8, r0 _080638FE: mov r0, r8 @@ -12167,7 +12167,7 @@ _08063AEC: movs r1, 0x8C lsls r1, 1 adds r0, r5, r1 - bl sub_80936D8 + bl unk_FixLinkedMovesSetEnabled4 ldrb r1, [r4, 0x1] movs r0, 0x2 orrs r0, r1 @@ -12240,7 +12240,7 @@ sub_8063B54: strb r0, [r4] adds r5, r6 adds r0, r5, 0 - bl sub_80936D8 + bl unk_FixLinkedMovesSetEnabled4 ldrb r1, [r4, 0x1] movs r0, 0x2 orrs r0, r1 @@ -12346,7 +12346,7 @@ _08063C42: bl sub_80928C0 _08063C5C: adds r0, r6, r4 - bl sub_80936D8 + bl unk_FixLinkedMovesSetEnabled4 ldr r0, _08063C84 bl PlaySoundEffect pop {r4-r7} @@ -12491,7 +12491,7 @@ _08063D70: movs r2, 0x8C lsls r2, 1 adds r0, r6, r2 - bl sub_80936D8 + bl unk_FixLinkedMovesSetEnabled4 ldr r0, _08063DA8 bl PlaySoundEffect mov r3, r10 @@ -12617,7 +12617,7 @@ _08063E44: ble _08063E44 _08063E62: adds r0, r5, 0 - bl sub_80936F4 + bl unk_FixLinkedMovesSetEnabled8 pop {r4-r7} pop {r0} bx r0 @@ -21995,7 +21995,7 @@ _08068922: add r0, r9 adds r0, 0x1C add r1, sp, 0x34 - bl sub_8093F50 + bl CopyAndResetMoves _08068A06: ldr r0, [r6] adds r0, r4 diff --git a/asm/code_80718D8.s b/asm/code_80718D8.s index fb2cc620b..72c4b2a72 100644 --- a/asm/code_80718D8.s +++ b/asm/code_80718D8.s @@ -1605,7 +1605,7 @@ _080727A8: lsls r1, 1 add r1, r8 adds r0, r4, 0 - bl sub_8093FC8 + bl unk_CopyMoves4To8AndClearFlag2Unk4 mov r10, r4 cmp r7, 0 beq _08072810 @@ -1811,7 +1811,7 @@ sub_8072938: lsls r1, 1 add r1, r8 mov r0, sp - bl sub_8093FC8 + bl unk_CopyMoves4To8AndClearFlag2Unk4 movs r3, 0 mov r4, sp mov r2, sp diff --git a/asm/friend_list_menu.s b/asm/friend_list_menu.s index 3b8746368..42a90fa43 100644 --- a/asm/friend_list_menu.s +++ b/asm/friend_list_menu.s @@ -1506,7 +1506,7 @@ _08026362: adds r0, 0x28 ldr r1, [r1, 0x18] adds r1, 0x2C - bl sub_809401C + bl unk_CopyMoves4To8 ldr r2, [r4] movs r0, 0xA ldrsh r1, [r2, r0] diff --git a/asm/moves_1.s b/asm/moves_1.s index 08495d3e5..4fe4296be 100644 --- a/asm/moves_1.s +++ b/asm/moves_1.s @@ -341,9 +341,9 @@ sub_8092F80: strb r1, [r0] adds r0, r7, 0 mov r1, sp - bl sub_8093784 + bl unk_GetLinkedSequences4 mov r0, sp - bl sub_8093744 + bl unk_FindMoveFlag2Unk80InLinkedSequences44 adds r3, r0, 0 cmp r3, 0x2 bhi _08092FCC @@ -367,7 +367,7 @@ _08092FBA: _08092FCC: adds r0, r7, 0 mov r1, sp - bl sub_80937E0 + bl unk_LinkedSequencesToMoves4 movs r3, 0 movs r5, 0x80 movs r4, 0x7F @@ -415,9 +415,9 @@ sub_8093008: strb r1, [r0] adds r0, r7, 0 mov r1, sp - bl sub_8093974 + bl unk_GetLinkedSequences8 mov r0, sp - bl sub_80938F4 + bl unk_FindMoveFlag2Unk80InLinkedSequences88 adds r3, r0, 0 cmp r3, 0x6 bhi _08093056 @@ -441,7 +441,7 @@ _08093044: _08093056: adds r0, r7, 0 mov r1, sp - bl sub_8093A2C + bl unk_LinkedSequencesToMoves8 movs r3, 0 movs r5, 0x80 movs r4, 0x7F @@ -493,9 +493,9 @@ sub_809309C: strb r1, [r0] adds r0, r7, 0 mov r1, sp - bl sub_80939D0 + bl unk_GetLinkedSequences8_v2 mov r0, sp - bl sub_8093934 + bl unk_FindMoveFlag2Unk80InLinkedSequences88_v2 adds r3, r0, 0 cmp r3, 0x6 bhi _080930EA @@ -519,7 +519,7 @@ _080930D8: _080930EA: adds r0, r7, 0 mov r1, sp - bl sub_8093B40 + bl unk_LinkedSequencesToMoves8_v2 movs r3, 0 movs r5, 0x80 movs r4, 0x7F @@ -570,9 +570,9 @@ sub_8093130: strb r1, [r0] adds r0, r7, 0 mov r1, sp - bl sub_8093784 + bl unk_GetLinkedSequences4 mov r0, sp - bl sub_8093744 + bl unk_FindMoveFlag2Unk80InLinkedSequences44 adds r1, r0, 0 subs r0, r1, 0x1 cmp r0, 0x2 @@ -596,7 +596,7 @@ _0809316A: _0809317C: adds r0, r7, 0 mov r1, sp - bl sub_80937E0 + bl unk_LinkedSequencesToMoves4 movs r1, 0 movs r5, 0x80 movs r4, 0x7F @@ -644,9 +644,9 @@ sub_80931B8: strb r1, [r0] adds r0, r7, 0 mov r1, sp - bl sub_8093974 + bl unk_GetLinkedSequences8 mov r0, sp - bl sub_80938F4 + bl unk_FindMoveFlag2Unk80InLinkedSequences88 adds r1, r0, 0 subs r0, r1, 0x1 cmp r0, 0x6 @@ -670,7 +670,7 @@ _080931F4: _08093206: adds r0, r7, 0 mov r1, sp - bl sub_8093A2C + bl unk_LinkedSequencesToMoves8 movs r1, 0 movs r5, 0x80 movs r4, 0x7F @@ -722,9 +722,9 @@ sub_809324C: strb r1, [r0] adds r0, r7, 0 mov r1, sp - bl sub_80939D0 + bl unk_GetLinkedSequences8_v2 mov r0, sp - bl sub_8093934 + bl unk_FindMoveFlag2Unk80InLinkedSequences88_v2 adds r1, r0, 0 subs r0, r1, 0x1 cmp r0, 0x6 @@ -748,7 +748,7 @@ _08093288: _0809329A: adds r0, r7, 0 mov r1, sp - bl sub_8093B40 + bl unk_LinkedSequencesToMoves8_v2 movs r1, 0 movs r5, 0x80 movs r4, 0x7F diff --git a/include/moves.h b/include/moves.h index 1663dd265..6deb5190a 100644 --- a/include/moves.h +++ b/include/moves.h @@ -29,7 +29,7 @@ bool8 MoveAffectedByMuzzled(u16 moveID); bool8 IsBlockedBySoundproof(struct PokemonMove *move); bool8 DoesMoveCharge(u16 move); -void sub_809371C(struct PokemonMove* move); +void unk_FixLinkedMovesSetEnabled8_v2(struct PokemonMove* move); void sub_8092D54(u8 *buffer, struct PokemonMove *move); extern void CopyAndResetMove(struct PokemonMove *, struct PokemonMove *); diff --git a/src/code_801AFA4.c b/src/code_801AFA4.c index e12bd0d84..2329f481e 100644 --- a/src/code_801AFA4.c +++ b/src/code_801AFA4.c @@ -27,7 +27,7 @@ extern u8 gAvailablePokemonNames[0x50]; extern u8 gUnknown_202E218[0x50]; extern void InitZeroedPPPokemonMove(struct PokemonMove*, u16); -extern void sub_809401C(struct PokemonMove *, struct PokemonMove *); +extern void unk_CopyMoves4To8(struct PokemonMove *, struct PokemonMove *); extern bool8 IsHMItem(u8); extern void DisplayGulpinDialogueSprite(u32, u32, void *); extern void sub_801B178(void); @@ -189,7 +189,7 @@ void sub_801B200(void) gUnknown_203B22C->chosenPokemon = gUnknown_203B22C->unk50[temp - 4]; gUnknown_203B22C->pokeStruct = &gRecruitedPokemonRef->pokemon[gUnknown_203B22C->chosenPokemon]; PrintPokeNameToBuffer(gUnknown_202E218, gUnknown_203B22C->pokeStruct); - sub_809401C(gUnknown_203B22C->moves, gUnknown_203B22C->pokeStruct->moves); + unk_CopyMoves4To8(gUnknown_203B22C->moves, gUnknown_203B22C->pokeStruct->moves); for(moveIndex = 0; moveIndex < MAX_MON_MOVES * 2; moveIndex++) { pokeMove = &gUnknown_203B22C->moves[moveIndex]; diff --git a/src/friend_area_action_menu.c b/src/friend_area_action_menu.c index d354f2d53..a3a67e0ab 100644 --- a/src/friend_area_action_menu.c +++ b/src/friend_area_action_menu.c @@ -35,7 +35,7 @@ extern void sub_801A8D0(u32); extern void sub_801A9E0(); extern void sub_801F1B0(u32, u32); extern void sub_801B3C0(struct ItemSlot *); -extern void sub_809401C(struct PokemonMove *, struct PokemonMove *); +extern void unk_CopyMoves4To8(struct PokemonMove *, struct PokemonMove *); extern void sub_801EE10(u32, s16, struct PokemonMove *, u32, u32, u32); extern void sub_8012CAC(struct UnkTextStruct2 *, struct MenuItem *); @@ -206,7 +206,7 @@ void sub_8027274(void) sub_801B3C0(&slot); break; case 0xe: - sub_809401C(gUnknown_203B2BC->moves,gUnknown_203B2BC->unk18->moves); + unk_CopyMoves4To8(gUnknown_203B2BC->moves,gUnknown_203B2BC->unk18->moves); sub_801EE10(3,gUnknown_203B2BC->targetPoke,gUnknown_203B2BC->moves,0,0,0); break; case 0xf: diff --git a/src/friend_list_menu_1.c b/src/friend_list_menu_1.c index 2eaf8e121..73ab17efd 100644 --- a/src/friend_list_menu_1.c +++ b/src/friend_list_menu_1.c @@ -87,7 +87,7 @@ extern void sub_801BEEC(s16); extern void sub_8023B7C(u32); extern void sub_8023DA4(void); -extern void sub_809401C(struct PokemonMove *, struct PokemonMove *); // TODO convert arg 0 to PokemonMove struct * +extern void unk_CopyMoves4To8(struct PokemonMove *, struct PokemonMove *); // TODO convert arg 0 to PokemonMove struct * extern void sub_801EE10(u32, s16, struct PokemonMove *, u32, u32, u32); extern void GetLinkedSequence(u32, struct PokemonMove *, u16*); extern void sub_801F808(u16 *); @@ -283,7 +283,7 @@ void sub_8025518(void) sub_80141B4(gUnknown_80DD270,0,0,0x101); break; case 0xf: - sub_809401C(gUnknown_203B2B4->moves,gUnknown_203B2B4->pokeStruct->moves); + unk_CopyMoves4To8(gUnknown_203B2B4->moves,gUnknown_203B2B4->pokeStruct->moves); sub_801EE10(3,gUnknown_203B2B4->unkE,gUnknown_203B2B4->moves,0,0,0); break; case 0x10: diff --git a/src/gulpin_shop_1.c b/src/gulpin_shop_1.c index 2ba6aebff..433335e4b 100644 --- a/src/gulpin_shop_1.c +++ b/src/gulpin_shop_1.c @@ -9,7 +9,7 @@ extern struct unkStruct_203B26C *gUnknown_203B26C; extern void UpdateGulpinShopState(u32); -extern void sub_8093CF8(struct PokemonMove *, u32); +extern void RemoveLinkSequenceFromMoves8(struct PokemonMove *, u32); extern void sub_801F214(void); extern s32 sub_80144A4(s32 *); extern u32 sub_801F890(void); @@ -67,7 +67,7 @@ void sub_801EDC0(void) { case 4: sub_801F214(); - sub_8093CF8(gUnknown_203B26C->unk10, gUnknown_203B26C->unk20); + RemoveLinkSequenceFromMoves8(gUnknown_203B26C->unk10, gUnknown_203B26C->unk20); gUnknown_203B26C->state = 5; break; case 1: diff --git a/src/moves_1.c b/src/moves_1.c index 3dabeb22e..17e2050a7 100644 --- a/src/moves_1.c +++ b/src/moves_1.c @@ -12,24 +12,24 @@ extern const char gUnknown_8109930[]; extern struct MoveData *gMovesData; u8 sub_8093468(int param_1, struct PokemonMove* src_struct); -u8 sub_8093400(int param_1, struct PokemonMove* src_struct); +u8 TryLinkMovesAfter(int param_1, struct PokemonMove* src_struct); u8 sub_80933D8(int param_1, void* src_struct); bool8 DoesMoveCharge(u16 move); -void sub_8093784(struct PokemonMove* moves, struct PokemonMove moveSets[4][4]); -void sub_80937E0(struct PokemonMove* moves, struct PokemonMove moveSets[4][4]); -void sub_8093974(struct PokemonMove* moves, struct PokemonMove moveSets[8][8]); -void sub_8093A2C(struct PokemonMove* moves, struct PokemonMove moveSets[8][8]); +void unk_GetLinkedSequences4(struct PokemonMove* moves, struct PokemonMove linkedSequences[4][4]); +void unk_LinkedSequencesToMoves4(struct PokemonMove* moves, struct PokemonMove linkedSequences[4][4]); +void unk_GetLinkedSequences8(struct PokemonMove* moves, struct PokemonMove linkedSequences[8][8]); +void unk_LinkedSequencesToMoves8(struct PokemonMove* moves, struct PokemonMove linkedSequences[8][8]); -void sub_80939D0(struct PokemonMove*, struct PokemonMove[8][8]); -void sub_8093B40(struct PokemonMove*, struct PokemonMove[8][8]); +void unk_GetLinkedSequences8_v2(struct PokemonMove*, struct PokemonMove[8][8]); +void unk_LinkedSequencesToMoves8_v2(struct PokemonMove*, struct PokemonMove[8][8]); -int sub_8093DE8(int, struct PokemonMove*, int, struct subStruct_203B240**); +int unk_PrintMoveDescription(int, struct PokemonMove*, int, struct subStruct_203B240**); extern void sub_80073B8(u32); void sub_80928C0(u8 *buffer, struct PokemonMove *move, struct unkStruct_80928C0 *param_3); extern void xxx_format_and_draw(u32, u32, const u8 *, u32, u32); -extern void sub_8093E90(struct PokemonMove*, int); // print something +extern void unk_MovePrintData(struct PokemonMove*, int); // print something extern void sub_80073E0(u32); extern u32 sub_8097DF0(char *, struct subStruct_203B240 **); @@ -61,7 +61,7 @@ int sub_8093318(int param_1, void* src_struct) { struct PokemonMove dest_struct[8]; MemoryCopy8((void*)dest_struct, src_struct, 64); - return sub_8093400(param_1, dest_struct); + return TryLinkMovesAfter(param_1, dest_struct); } int sub_809333C(int param_1, void* src_struct) @@ -107,7 +107,7 @@ u8 sub_80933D8(int param_1, void* src_struct) { int result; - if (!sub_8093400(param_1, src_struct)) { + if (!TryLinkMovesAfter(param_1, src_struct)) { result = sub_8093468(param_1, src_struct); } else { @@ -116,7 +116,7 @@ u8 sub_80933D8(int param_1, void* src_struct) return result; } -u8 sub_8093400(int index, struct PokemonMove* moves) { +u8 TryLinkMovesAfter(int index, struct PokemonMove* moves) { int i; const struct PokemonMove *move = &moves[index]; if (DoesMoveCharge(move->moveID)) { @@ -132,13 +132,14 @@ u8 sub_8093400(int index, struct PokemonMove* moves) { } if (!(moves[i].moveFlags & MOVE_FLAG_LINKED)) { moves[i].moveFlags |= MOVE_FLAG_LINKED; - sub_809371C(moves); + unk_FixLinkedMovesSetEnabled8_v2(moves); return 1; } } return 0; } +// unlinks move NAKED u8 sub_8093468(int index, struct PokemonMove* moves) { @@ -174,7 +175,7 @@ u8 sub_8093468(int index, struct PokemonMove* moves) " ble _08093480\n" "_080934A0:\n" " adds r0, r6, 0\n" -" bl sub_809371C\n" +" bl unk_FixLinkedMovesSetEnabled8_v2\n" " adds r0, r5, 0\n" " pop {r4-r7}\n" " pop {r1}\n" @@ -213,20 +214,20 @@ int ToggleSetMove(int index, struct PokemonMove* moves) { flags = move->moveFlags | MOVE_FLAG_SET; } move->moveFlags = flags; - sub_809371C(moves); + unk_FixLinkedMovesSetEnabled8_v2(moves); return 1; } void UnSetMove(int index, struct PokemonMove* moves) { struct PokemonMove* move = &moves[index]; move->moveFlags &= ~MOVE_FLAG_SET; - sub_809371C(moves); + unk_FixLinkedMovesSetEnabled8_v2(moves); } int ToggleMoveEnabled(int index, struct PokemonMove* moves) { struct PokemonMove* move = &moves[index]; move->moveFlags ^= MOVE_FLAG_ENABLED; - sub_809371C(moves); + unk_FixLinkedMovesSetEnabled8_v2(moves); return 1; } @@ -336,26 +337,30 @@ int sub_80935B8(struct PokemonMove *moves, int index) { } } -void sub_80936D8(struct PokemonMove* moves) { - struct PokemonMove someStruct[4][4]; - sub_8093784(moves, someStruct); - sub_80937E0(moves, someStruct); +void unk_FixLinkedMovesSetEnabled4(struct PokemonMove* moves) { + struct PokemonMove linkedSequences[4][4]; + + // all that doing these in a row seems to do is + // fix the set/enabled flags by moving them to + // the first move of every linked sequence + unk_GetLinkedSequences4(moves, linkedSequences); + unk_LinkedSequencesToMoves4(moves, linkedSequences); } -void sub_80936F4(struct PokemonMove* moves) { - struct PokemonMove moveSets[8][8]; - sub_8093974(moves, moveSets); - sub_8093A2C(moves, moveSets); +void unk_FixLinkedMovesSetEnabled8(struct PokemonMove* moves) { + struct PokemonMove linkedSequences[8][8]; + unk_GetLinkedSequences8(moves, linkedSequences); + unk_LinkedSequencesToMoves8(moves, linkedSequences); } -void sub_809371C(struct PokemonMove* moves) { - struct PokemonMove moveSets[8][8]; +void unk_FixLinkedMovesSetEnabled8_v2(struct PokemonMove* moves) { + struct PokemonMove linkedSequences[8][8]; - sub_80939D0(moves, moveSets); - sub_8093B40(moves, moveSets); + unk_GetLinkedSequences8_v2(moves, linkedSequences); + unk_LinkedSequencesToMoves8_v2(moves, linkedSequences); } -int sub_8093744(struct PokemonMove moves[4][4]) { +int unk_FindMoveFlag2Unk80InLinkedSequences44(struct PokemonMove moves[4][4]) { int i, j; for (i = 0; i < 4; i++) { @@ -368,14 +373,14 @@ int sub_8093744(struct PokemonMove moves[4][4]) { return -1; } -void sub_8093784(struct PokemonMove* moves, struct PokemonMove moveSets[4][4]) { +void unk_GetLinkedSequences4(struct PokemonMove* moves, struct PokemonMove linkedSequences[4][4]) { int i, j; int k; int moveSetIndex; for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { - moveSets[i][j].moveFlags = 0; + linkedSequences[i][j].moveFlags = 0; } } @@ -385,47 +390,48 @@ void sub_8093784(struct PokemonMove* moves, struct PokemonMove moveSets[4][4]) { moveSetIndex++; j = 0; } - moveSets[moveSetIndex][j] = moves[k]; - moveSets[moveSetIndex][j].moveFlags &= ~MOVE_FLAG_LINKED; + linkedSequences[moveSetIndex][j] = moves[k]; + linkedSequences[moveSetIndex][j].moveFlags &= ~MOVE_FLAG_LINKED; } } -void sub_80937E0(struct PokemonMove* moves, struct PokemonMove moveSets[4][4]) { +void unk_LinkedSequencesToMoves4(struct PokemonMove* moves, struct PokemonMove linkedSequences[4][4]) { int i, j; int movesCopied; - bool8 moveFlags8[4]; - bool8 moveFlags4[4]; + bool8 moves_set[4]; + bool8 moves_enabled[4]; movesCopied = 0; + // figure out which linked sequences contain set / enabled moves for (i = 0; i < 4; i++) { - moveFlags8[i] = 0; - moveFlags4[i] = 0; + moves_set[i] = 0; + moves_enabled[i] = 0; for (j = 0; j < 4; j++) { u8 flag; - if (!(moveSets[i][j].moveFlags & MOVE_FLAG_EXISTS)) { + if (!(linkedSequences[i][j].moveFlags & MOVE_FLAG_EXISTS)) { continue; } flag = MOVE_FLAG_SET; - flag &= moveSets[i][j].moveFlags; + flag &= linkedSequences[i][j].moveFlags; if (flag) { - moveFlags8[i] = TRUE; + moves_set[i] = TRUE; } - if (moveSets[i][j].moveFlags & MOVE_FLAG_ENABLED) { - moveFlags4[i] = TRUE; + if (linkedSequences[i][j].moveFlags & MOVE_FLAG_ENABLED) { + moves_enabled[i] = TRUE; } } } for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { - if (moveSets[i][j].moveFlags & MOVE_FLAG_EXISTS) { - moves[movesCopied] = moveSets[i][j]; + if (linkedSequences[i][j].moveFlags & MOVE_FLAG_EXISTS) { + moves[movesCopied] = linkedSequences[i][j]; if (j == 0) { moves[movesCopied].moveFlags &= ~MOVE_FLAG_LINKED; @@ -436,10 +442,10 @@ void sub_80937E0(struct PokemonMove* moves, struct PokemonMove moveSets[4][4]) { moves[movesCopied].moveFlags &= ~MOVE_FLAG_SET; moves[movesCopied].moveFlags &= ~MOVE_FLAG_ENABLED; - if (moveFlags8[i] && (j == 0)) { + if (moves_set[i] && (j == 0)) { moves[movesCopied].moveFlags |= MOVE_FLAG_SET; } - if (moveFlags4[i] && (j == 0)) { + if (moves_enabled[i] && (j == 0)) { moves[movesCopied].moveFlags |= MOVE_FLAG_ENABLED; } @@ -453,12 +459,12 @@ void sub_80937E0(struct PokemonMove* moves, struct PokemonMove moveSets[4][4]) { } // the next two functions are exactly the same -int sub_80938F4(struct PokemonMove moveSets[8][8]) { +int unk_FindMoveFlag2Unk80InLinkedSequences88(struct PokemonMove linkedSequences[8][8]) { int i, j; for (i = 0; i < 8; i++) { for (j = 0; j < 8; j++) { - if ((moveSets[i][j].moveFlags & MOVE_FLAG_EXISTS) && (moveSets[i][j].moveFlags & MOVE_FLAG_UNK80)) { + if ((linkedSequences[i][j].moveFlags & MOVE_FLAG_EXISTS) && (linkedSequences[i][j].moveFlags & MOVE_FLAG_UNK80)) { return i; } } @@ -469,12 +475,12 @@ int sub_80938F4(struct PokemonMove moveSets[8][8]) { // I expect the intent was to check for a different flag in this one // or the argument is a struct type that does hold the moves as a field -int sub_8093934(struct PokemonMove moveSets[8][8]) { +int unk_FindMoveFlag2Unk80InLinkedSequences88_v2(struct PokemonMove linkedSequences[8][8]) { int i, j; for (i = 0; i < 8; i++) { for (j = 0; j < 8; j++) { - if ((moveSets[i][j].moveFlags & MOVE_FLAG_EXISTS) && (moveSets[i][j].moveFlags & MOVE_FLAG_UNK80)) { + if ((linkedSequences[i][j].moveFlags & MOVE_FLAG_EXISTS) && (linkedSequences[i][j].moveFlags & MOVE_FLAG_UNK80)) { return i; } } @@ -484,38 +490,43 @@ int sub_8093934(struct PokemonMove moveSets[8][8]) { } // again, the next two functions are exactly the same -// they are also the same as sub_8093784 but for [8][8] moveSets instead of -// [4][4] moveSets -void sub_8093974(struct PokemonMove* moves, struct PokemonMove moveSets[8][8]) { +// they are also the same as unk_GetLinkedSequences4 but for [8][8] linkedSequences instead of +// [4][4] linkedSequences + +// it seems to find all the _actually_ separate moves, and split them +// out into link sequences in the destination linkedSequences +void unk_GetLinkedSequences8(struct PokemonMove* moves, struct PokemonMove linkedSequences[8][8]) { int i, j; int k; int moveSetIndex; + // clear out linkedSequences for (i = 0; i < 8; i++) { for (j = 0; j < 8; j++) { - moveSets[i][j].moveFlags = 0; + linkedSequences[i][j].moveFlags = 0; } } + moveSetIndex = -1; for (j = 0, k = 0; k < 8; j++, k++) { struct PokemonMove* move = &moves[k]; - if (k == 0 || !(move->moveFlags & 2)) { + if (k == 0 || !(move->moveFlags & MOVE_FLAG_LINKED)) { moveSetIndex++; j = 0; } - moveSets[moveSetIndex][j] = *move; - moveSets[moveSetIndex][j].moveFlags &= ~2; + linkedSequences[moveSetIndex][j] = *move; + linkedSequences[moveSetIndex][j].moveFlags &= ~MOVE_FLAG_LINKED; } } -void sub_80939D0(struct PokemonMove* moves, struct PokemonMove moveSets[8][8]) { +void unk_GetLinkedSequences8_v2(struct PokemonMove* moves, struct PokemonMove linkedSequences[8][8]) { int i, j; int k; int moveSetIndex; for (i = 0; i < 8; i++) { for (j = 0; j < 8; j++) { - moveSets[i][j].moveFlags = 0; + linkedSequences[i][j].moveFlags = 0; } } moveSetIndex = -1; @@ -525,15 +536,15 @@ void sub_80939D0(struct PokemonMove* moves, struct PokemonMove moveSets[8][8]) { moveSetIndex++; j = 0; } - moveSets[moveSetIndex][j] = *move; - moveSets[moveSetIndex][j].moveFlags &= ~2; + linkedSequences[moveSetIndex][j] = *move; + linkedSequences[moveSetIndex][j].moveFlags &= ~MOVE_FLAG_LINKED; } } // the next 2 functions are again exactly the same -// these functions are the same as sub_80937E0 but for [8][8] moveSets -// instead of [4][4] moveSets -void sub_8093A2C(struct PokemonMove* moves, struct PokemonMove moveSets[8][8]) { +// these functions are the same as unk_LinkedSequencesToMoves4 but for [8][8] linkedSequences +// instead of [4][4] linkedSequences +void unk_LinkedSequencesToMoves8(struct PokemonMove* moves, struct PokemonMove linkedSequences[8][8]) { int i, j; int movesCopied; @@ -549,16 +560,16 @@ void sub_8093A2C(struct PokemonMove* moves, struct PokemonMove moveSets[8][8]) { for (j = 0; j < 8; j++) { u8 flag; - if (!(moveSets[i][j].moveFlags & MOVE_FLAG_EXISTS)) { + if (!(linkedSequences[i][j].moveFlags & MOVE_FLAG_EXISTS)) { continue; } flag = MOVE_FLAG_SET; - flag &= moveSets[i][j].moveFlags; + flag &= linkedSequences[i][j].moveFlags; if (flag) { moveFlags8[i] = TRUE; } - if (moveSets[i][j].moveFlags & MOVE_FLAG_ENABLED) { + if (linkedSequences[i][j].moveFlags & MOVE_FLAG_ENABLED) { moveFlags4[i] = TRUE; } } @@ -566,8 +577,8 @@ void sub_8093A2C(struct PokemonMove* moves, struct PokemonMove moveSets[8][8]) { for (i = 0; i < 8; i++) { for (j = 0; j < 8; j++) { - if (moveSets[i][j].moveFlags & MOVE_FLAG_EXISTS) { - moves[movesCopied] = moveSets[i][j]; + if (linkedSequences[i][j].moveFlags & MOVE_FLAG_EXISTS) { + moves[movesCopied] = linkedSequences[i][j]; if (j == 0) { moves[movesCopied].moveFlags &= ~MOVE_FLAG_LINKED; @@ -594,7 +605,7 @@ void sub_8093A2C(struct PokemonMove* moves, struct PokemonMove moveSets[8][8]) { } } -void sub_8093B40(struct PokemonMove* moves, struct PokemonMove moveSets[8][8]) { +void unk_LinkedSequencesToMoves8_v2(struct PokemonMove* moves, struct PokemonMove linkedSequences[8][8]) { int i, j; int movesCopied; @@ -610,16 +621,16 @@ void sub_8093B40(struct PokemonMove* moves, struct PokemonMove moveSets[8][8]) { for (j = 0; j < 8; j++) { u8 flag; - if (!(moveSets[i][j].moveFlags & MOVE_FLAG_EXISTS)) { + if (!(linkedSequences[i][j].moveFlags & MOVE_FLAG_EXISTS)) { continue; } flag = MOVE_FLAG_SET; - flag &= moveSets[i][j].moveFlags; + flag &= linkedSequences[i][j].moveFlags; if (flag) { moveFlags8[i] = TRUE; } - if (moveSets[i][j].moveFlags & MOVE_FLAG_ENABLED) { + if (linkedSequences[i][j].moveFlags & MOVE_FLAG_ENABLED) { moveFlags4[i] = TRUE; } } @@ -627,8 +638,8 @@ void sub_8093B40(struct PokemonMove* moves, struct PokemonMove moveSets[8][8]) { for (i = 0; i < 8; i++) { for (j = 0; j < 8; j++) { - if (moveSets[i][j].moveFlags & MOVE_FLAG_EXISTS) { - moves[movesCopied] = moveSets[i][j]; + if (linkedSequences[i][j].moveFlags & MOVE_FLAG_EXISTS) { + moves[movesCopied] = linkedSequences[i][j]; if (j == 0) { moves[movesCopied].moveFlags &= ~MOVE_FLAG_LINKED; @@ -657,7 +668,7 @@ void sub_8093B40(struct PokemonMove* moves, struct PokemonMove moveSets[8][8]) { // the next two are again the same -void sub_8093C54(struct PokemonMove* moves, int index) { +void RemoveLinkSequenceFromMoves8_v2(struct PokemonMove* moves, int index) { int i; int copiedMoves; struct PokemonMove moveSet[8]; @@ -668,10 +679,10 @@ void sub_8093C54(struct PokemonMove* moves, int index) { // TODO: don't do this trickery asm(""); - if (!(move->moveFlags & 1)) { + if (!(move->moveFlags & MOVE_FLAG_EXISTS)) { break; } - if (!(move->moveFlags & 2)) { + if (!(move->moveFlags & MOVE_FLAG_LINKED)) { break; } @@ -680,7 +691,7 @@ void sub_8093C54(struct PokemonMove* moves, int index) { copiedMoves = 0; for (i = 0; i < 8; i++) { - if (moves[i].moveFlags & 1) { + if (moves[i].moveFlags & MOVE_FLAG_EXISTS) { moveSet[copiedMoves++] = moves[i]; } } @@ -694,56 +705,60 @@ void sub_8093C54(struct PokemonMove* moves, int index) { } } -void sub_8093CF8(struct PokemonMove* moves, int index) { +void RemoveLinkSequenceFromMoves8(struct PokemonMove* moves, int index) { int i; int copiedMoves; struct PokemonMove moveSet[8]; + // remove link sequence (set flags to 0) moves[index].moveFlags = 0; for (i = index + 1; i < 8; i++) { struct PokemonMove* move = &moves[i]; asm(""); - if (!(move->moveFlags & 1)) { + if (!(move->moveFlags & MOVE_FLAG_EXISTS)) { break; } - if (!(move->moveFlags & 2)) { + if (!(move->moveFlags & MOVE_FLAG_LINKED)) { break; } move->moveFlags = 0; } + // copy over other moves copiedMoves = 0; for (i = 0; i < 8; i++) { - if (moves[i].moveFlags & 1) { + if (moves[i].moveFlags & MOVE_FLAG_EXISTS) { moveSet[copiedMoves++] = moves[i]; } } + // fill with nonexistent moves while (copiedMoves < 8) { moveSet[copiedMoves++].moveFlags = 0; } + // copy back to original moves pointer for (i = 0; i < 8; i++) { moves[i] = moveSet[i]; } } -int sub_8093D9C(int a1, u16 moveID, int a3, struct subStruct_203B240** a4) { +int unk_MoveIDPrintMoveDescription(int a1, u16 moveID, int a3, struct subStruct_203B240** a4) { struct PokemonMove move; InitPokemonMove(&move, moveID); - return sub_8093DE8(a1, &move, a3, a4); + return unk_PrintMoveDescription(a1, &move, a3, a4); } -int sub_8093DC4(int a1, struct PokemonMove* move, int a3, struct subStruct_203B240** a4) { +int unk_MovePrintMoveDescription(int a1, struct PokemonMove* move, int a3, struct subStruct_203B240** a4) { struct PokemonMove newMove; CopyAndResetMove(&newMove, move); - return sub_8093DE8(a1, &newMove, a3, a4); + return unk_PrintMoveDescription(a1, &newMove, a3, a4); } -int sub_8093DE8(int x, struct PokemonMove* move, int a3, struct subStruct_203B240** a4) { +int unk_PrintMoveDescription(int x, struct PokemonMove* move, int a3, struct subStruct_203B240** a4) { char* moveDescription; int y; char buffer[800]; @@ -759,13 +774,13 @@ int sub_8093DE8(int x, struct PokemonMove* move, int a3, struct subStruct_203B24 ++moveDescription; } xxx_format_and_draw(4, y, moveDescription, a3, 0); - sub_8093E90(move, a3); + unk_MovePrintData(move, a3); sub_80073E0(a3); strcpy(buffer, gMovesData[move->moveID].descriptionPointer); return sub_8097DF0(buffer, a4); } -void sub_8093E90(struct PokemonMove* move, int y) { +void unk_MovePrintData(struct PokemonMove* move, int y) { u8 type; s32 power; const char* text; @@ -794,7 +809,7 @@ void CopyAndResetMove(struct PokemonMove* dest, struct PokemonMove* src) { } } -void sub_8093F50(struct PokemonMove *destMoves, struct PokemonMove *srcMoves) { +void CopyAndResetMoves(struct PokemonMove *destMoves, struct PokemonMove *srcMoves) { int i; for (i = 0; i < 4; i++) { @@ -816,7 +831,7 @@ void sub_8093F50(struct PokemonMove *destMoves, struct PokemonMove *srcMoves) { destMoves[4].moveFlags = 0; } -void sub_8093FA8(struct PokemonMove *destMoves, struct PokemonMove *srcMoves) { +void CopyBareMoveData(struct PokemonMove *destMoves, struct PokemonMove *srcMoves) { int i; for (i = 0; i < 4; i++) { @@ -826,7 +841,7 @@ void sub_8093FA8(struct PokemonMove *destMoves, struct PokemonMove *srcMoves) { } } -void sub_8093FC8(struct PokemonMove* destMoves, struct PokemonMove* srcMoves) { +void unk_CopyMoves4To8AndClearFlag2Unk4(struct PokemonMove* destMoves, struct PokemonMove* srcMoves) { int movesCopied; movesCopied = 0; @@ -844,7 +859,7 @@ void sub_8093FC8(struct PokemonMove* destMoves, struct PokemonMove* srcMoves) { } } -void sub_809401C(struct PokemonMove* destMoves, struct PokemonMove* srcMoves) { +void unk_CopyMoves4To8(struct PokemonMove* destMoves, struct PokemonMove* srcMoves) { int movesCopied; movesCopied = 0; @@ -868,7 +883,7 @@ void sub_8094060(struct PokemonMove* srcMoves, struct PokemonMove* destMoves) { for (i = 0; i < 8; i++) { struct PokemonMove* srcMove = &srcMoves[i]; struct PokemonMove* destMove; - if (!(srcMove->moveFlags & 1)) { + if (!(srcMove->moveFlags & MOVE_FLAG_EXISTS)) { continue; } diff --git a/src/pokemon_mid.c b/src/pokemon_mid.c index 29291938a..b8615ff11 100644 --- a/src/pokemon_mid.c +++ b/src/pokemon_mid.c @@ -33,7 +33,7 @@ extern void sub_80922B4(u8 *, u8 *, s32); extern int sprintf(char *, const char *, ...); extern u32 ReturnIntFromChar(u8 r0); extern void CopyStringtoBuffer(char *r0, char *r1); -extern void sub_8093F50(void*, void*); +extern void CopyAndResetMoves(void*, void*); extern void sub_80943A0(void*, s32); extern void xxx_pokemon2_to_pokemonstruct_808DF44(struct PokemonStruct*, struct PokemonStruct2*); extern u8* sub_8092B18(s16); @@ -542,7 +542,7 @@ void xxx_pokemonstruct_to_pokemon2_808DE50(struct PokemonStruct2 * a1, struct Po } a1->unk18 = pokemon->unk1C; - sub_8093F50(&a1->moves, &pokemon->moves); + CopyAndResetMoves(&a1->moves, &pokemon->moves); for (i = 0; i < POKEMON_NAME_LENGTH; i++) { a1->name[i] = pokemon->name[i]; @@ -570,7 +570,7 @@ void xxx_pokemon2_to_pokemonstruct_index_808DF2C(s32 a1, struct PokemonStruct2* xxx_pokemon2_to_pokemonstruct_808DF44(&a1[gRecruitedPokemonRef->pokemon], a2); } -extern void sub_8093FA8(struct PokemonMove*, struct unkStruct_8094184*); +extern void CopyBareMoveData(struct PokemonMove*, struct unkStruct_8094184*); void xxx_pokemon2_to_pokemonstruct_808DF44(struct PokemonStruct* pokemon, struct PokemonStruct2* a2) @@ -593,7 +593,7 @@ void xxx_pokemon2_to_pokemonstruct_808DF44(struct PokemonStruct* pokemon, struct } pokemon->unk1C = a2->unk18; - sub_8093FA8(pokemon->moves, &a2->moves); + CopyBareMoveData(pokemon->moves, &a2->moves); for (i = 0; i < POKEMON_NAME_LENGTH; i++) { pokemon->name[i] = a2->name[i];