From 125e094860babfc2b2302bed9a8cb9541b2d767a Mon Sep 17 00:00:00 2001 From: Dennis Date: Wed, 1 Feb 2023 11:50:51 +0100 Subject: [PATCH] update types to bool8 for some functions, and uncomment the dungeon.s function --- asm/dungeon.s | 60 ----------------------------------------- ld_script.txt | 1 - src/dungeon_2.c | 27 ++++++++++--------- src/moves_1.c | 72 ++++++++++++++++++++++++------------------------- 4 files changed, 50 insertions(+), 110 deletions(-) delete mode 100644 asm/dungeon.s diff --git a/asm/dungeon.s b/asm/dungeon.s deleted file mode 100644 index 2e786f92e..000000000 --- a/asm/dungeon.s +++ /dev/null @@ -1,60 +0,0 @@ - #include "asm/constants/gba_constants.inc" - #include "asm/macros.inc" - - .syntax unified - - .text - - thumb_func_start sub_809017C -sub_809017C: - push {r4-r6,lr} - sub sp, 0x4 - adds r1, r0, 0 - mov r0, sp - bl sub_80901D8 - movs r5, 0 - ldr r2, _080901AC - ldrb r0, [r2] - cmp r0, 0x3F - beq _080901C6 - mov r3, sp - ldrb r6, [r3] - movs r4, 0 - adds r1, r2, 0 -_0809019A: - ldrb r0, [r1] - cmp r6, r0 - bne _080901B0 - ldrb r0, [r3, 0x1] - ldrb r2, [r1, 0x1] - cmp r0, r2 - bne _080901B0 - movs r0, 0x1 - b _080901C8 - .align 2, 0 -_080901AC: .4byte gUnknown_8107828 -_080901B0: - adds r4, 0x4 - adds r1, 0x4 - adds r5, 0x1 - ldr r0, _080901D0 - cmp r5, r0 - bgt _080901C6 - ldr r2, _080901D4 - adds r0, r4, r2 - ldrb r0, [r0] - cmp r0, 0x3F - bne _0809019A -_080901C6: - movs r0, 0 -_080901C8: - add sp, 0x4 - pop {r4-r6} - pop {r1} - bx r1 - .align 2, 0 -_080901D0: .4byte 0x000003e6 -_080901D4: .4byte gUnknown_8107828 - thumb_func_end sub_809017C - - .align 2, 0 @ Don't pad with nop. diff --git a/ld_script.txt b/ld_script.txt index df41ec1ec..148c88d39 100755 --- a/ld_script.txt +++ b/ld_script.txt @@ -292,7 +292,6 @@ SECTIONS { src/pokemon_3.o(.text); asm/pokemon_3.o(.text); src/dungeon.o(.text); - asm/dungeon.o(.text); src/dungeon_2.o(.text); asm/dungeon_2.o(.text); src/dungeon_2_1.o(.text); diff --git a/src/dungeon_2.c b/src/dungeon_2.c index ce7b68476..a118188cb 100644 --- a/src/dungeon_2.c +++ b/src/dungeon_2.c @@ -12,19 +12,20 @@ extern struct DungeonLocation gUnknown_8107828[]; extern u8 gDungeonFloorCount[]; extern u8 gUnknown_81077E8[]; -// this one just does not want to get right -// int sub_809017C(int a1) { -// struct DungeonLocation location; -// int i; -// sub_80901D8(&location, a1); -// for (i = 0; i < 999 && gUnknown_8107828[i].dungeonIndex != 63; ++i) { -// if (location.dungeonIndex == gUnknown_8107828[i].dungeonIndex && -// location.dungeonFloor == gUnknown_8107828[i].dungeonFloor) { -// return 1; -// } -// } -// return 0; -// } +void sub_80901D8(struct DungeonLocation *param_1,struct DungeonLocation *param_2); + +int sub_809017C(struct DungeonLocation* a1) { + struct DungeonLocation location; + int i; + sub_80901D8(&location, a1); + for (i = 0; i < 999 && gUnknown_8107828[i].id != 63; ++i) { + if (location.id == gUnknown_8107828[i].id && + location.floor == gUnknown_8107828[i].floor) { + return 1; + } + } + return 0; +} void sub_80901D8(struct DungeonLocation *param_1,struct DungeonLocation *param_2) { diff --git a/src/moves_1.c b/src/moves_1.c index 4bc343898..19f6b0ea8 100644 --- a/src/moves_1.c +++ b/src/moves_1.c @@ -11,9 +11,9 @@ extern u8 gAvailablePokemonNames[]; extern const char gUnknown_8109930[]; extern struct MoveDataEntry *gMovesData; -u8 sub_8093468(int param_1, struct Move* src_struct); -u8 TryLinkMovesAfter(int param_1, struct Move* src_struct); -u8 sub_80933D8(int param_1, void* src_struct); +bool8 sub_8093468(int param_1, struct Move* src_struct); +bool8 TryLinkMovesAfter(int param_1, struct Move* src_struct); +bool8 sub_80933D8(int param_1, void* src_struct); bool8 DoesMoveCharge(u16 move); void unk_GetLinkedSequences4(struct Move* moves, struct Move linkedSequences[4][4]); @@ -41,37 +41,37 @@ extern u8* gPtrTypeText; // "Type" extern u8* gUnknown_810CF00; // "Range#=@.$m0 " -int IsMoveSet(int index, struct Move* struct_ptr) +bool8 IsMoveSet(int index, struct Move* struct_ptr) { if ((struct_ptr[index].moveFlags & MOVE_FLAG_SET) != 0) { - return 1; + return TRUE; } - return 0; + return FALSE; } -int IsMoveEnabled(int index, struct Move* struct_ptr) +bool8 IsMoveEnabled(int index, struct Move* struct_ptr) { if ((struct_ptr[index].moveFlags & MOVE_FLAG_ENABLED_FOR_AI) != 0) { - return 1; + return TRUE; } - return 0; + return FALSE; } -int sub_8093318(int param_1, void* src_struct) +bool8 sub_8093318(int param_1, void* src_struct) { struct Move dest_struct[8]; MemoryCopy8((void*)dest_struct, src_struct, 64); return TryLinkMovesAfter(param_1, dest_struct); } -int sub_809333C(int param_1, void* src_struct) +bool8 sub_809333C(int param_1, void* src_struct) { struct Move dest_struct[8]; MemoryCopy8((void*)dest_struct, src_struct, 64); return sub_8093468(param_1, dest_struct); } -int sub_8093360(int param_1, void* src_struct) +bool8 sub_8093360(int param_1, void* src_struct) { u8 dest_struct[64]; MemoryCopy8(dest_struct, src_struct, 64); @@ -79,15 +79,15 @@ int sub_8093360(int param_1, void* src_struct) } // appears unused -int IsMoveNotSet(int index, struct Move* struct_ptr) +bool8 IsMoveNotSet(int index, struct Move* struct_ptr) { if ((struct_ptr[index].moveFlags & MOVE_FLAG_SET) != 0) { - return 0; + return FALSE; } - return 1; + return TRUE; } -int IsAnyMoveLinked(int unused, struct Move* moves) { +bool8 IsAnyMoveLinked(int unused, struct Move* moves) { int i; int counter; @@ -98,12 +98,12 @@ int IsAnyMoveLinked(int unused, struct Move* moves) { } } if (counter > 1) { - return 1; + return TRUE; } - return 0; + return FALSE; } -u8 sub_80933D8(int param_1, void* src_struct) +bool8 sub_80933D8(int param_1, void* src_struct) { int result; @@ -111,37 +111,37 @@ u8 sub_80933D8(int param_1, void* src_struct) result = sub_8093468(param_1, src_struct); } else { - result = 1; + result = TRUE; } return result; } -u8 TryLinkMovesAfter(int index, struct Move* moves) { +bool8 TryLinkMovesAfter(int index, struct Move* moves) { int i; const struct Move *move = &moves[index]; if (DoesMoveCharge(move->id)) { - return 0; + return FALSE; } for (i = index + 1; i < 8; i++) { if (!(moves[i].moveFlags & MOVE_FLAG_EXISTS)) { - return 0; + return FALSE; } if (DoesMoveCharge(moves[i].id)) { - return 0; + return FALSE; } if (!(moves[i].moveFlags & MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN)) { moves[i].moveFlags |= MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN; unk_FixLinkedMovesSetEnabled8_v2(moves); - return 1; + return TRUE; } } - return 0; + return FALSE; } // unlinks move NAKED -u8 sub_8093468(int index, struct Move* moves) +bool8 sub_8093468(int index, struct Move* moves) { asm_unified( " push {r4-r7,lr}\n" @@ -182,20 +182,20 @@ u8 sub_8093468(int index, struct Move* moves) " bx r1\n"); } -u8 IsNextMoveLinked(int index, struct Move* moves) { +bool8 IsNextMoveLinked(int index, struct Move* moves) { struct Move* move; if (index + 1 >= 8) { - return 0; + return FALSE; } move = &moves[index + 1]; if (!(move->moveFlags & MOVE_FLAG_EXISTS)) - return 0; + return FALSE; if ((move->moveFlags & MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN)) - return 1; - return 0; + return TRUE; + return FALSE; } -int ToggleSetMove(int index, struct Move* moves) { +bool8 ToggleSetMove(int index, struct Move* moves) { struct Move* move; u8 flags; int i; @@ -215,7 +215,7 @@ int ToggleSetMove(int index, struct Move* moves) { } move->moveFlags = flags; unk_FixLinkedMovesSetEnabled8_v2(moves); - return 1; + return TRUE; } void UnSetMove(int index, struct Move* moves) { @@ -224,11 +224,11 @@ void UnSetMove(int index, struct Move* moves) { unk_FixLinkedMovesSetEnabled8_v2(moves); } -int ToggleMoveEnabled(int index, struct Move* moves) { +bool8 ToggleMoveEnabled(int index, struct Move* moves) { struct Move* move = &moves[index]; move->moveFlags ^= MOVE_FLAG_ENABLED_FOR_AI; unk_FixLinkedMovesSetEnabled8_v2(moves); - return 1; + return TRUE; } int GetLinkedSequence(int index, struct Move* moves, u16* sequenceMoveIDs) {