From 6b0268e0c0fb98014cb72f8a918a33c0645162d2 Mon Sep 17 00:00:00 2001 From: Cameron Hall Date: Tue, 10 Jan 2017 23:15:38 -0500 Subject: finish decompiling field_control_avatar.c (#182) * start decompiling field_control_avatar.c * remove field_control_player_avatar.c * finish decompiling * cleanup * var and flag constants --- src/field_control_avatar.c | 806 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 759 insertions(+), 47 deletions(-) (limited to 'src/field_control_avatar.c') diff --git a/src/field_control_avatar.c b/src/field_control_avatar.c index 495327b9b..4b75c7a32 100644 --- a/src/field_control_avatar.c +++ b/src/field_control_avatar.c @@ -1,17 +1,116 @@ #include "global.h" #include "asm.h" +#include "battle_setup.h" +#include "event_data.h" #include "field_player_avatar.h" +#include "flags.h" #include "metatile_behavior.h" #include "rom4.h" +#include "safari_zone.h" #include "script.h" +#include "songs.h" #include "sound.h" #include "trainer_see.h" +#include "vars.h" +#include "wild_encounter.h" +struct Coords32 +{ + s32 x; + s32 y; +}; + +extern const struct Coords32 gUnknown_0821664C[]; +extern u16 gScriptLastTalked; +extern u16 gScriptFacing; +extern struct LinkPlayerMapObject gLinkPlayerMapObjects[]; +extern u16 gSpecialVar_0x8004; +extern u16 gSpecialVar_0x8005; +extern u8 gUnknown_0202E8C0; +extern u16 gUnknown_0202E8C2; + +//scripts +extern u8 gUnknown_081A2C51[]; extern u8 gUnknown_0815281E[]; extern u8 gUnknown_08152C39[]; extern u8 gUnknown_0815F36C[]; extern u8 gUnknown_0815F43A[]; extern u8 gUnknown_081A0009[]; +extern u8 gUnknown_081C6C02[]; +extern u8 HiddenItemScript[]; +extern u8 Event_TV[]; +extern u8 gUnknown_081A0009[]; +extern u8 ClosedSootopolisGymDoorScript[]; +extern u8 gUnknown_081A4363[]; +extern u8 gUnknown_081C346A[]; +extern u8 gUnknown_081616E1[]; +extern u8 Event_WorldMap[]; +extern u8 Event_RunningShoesManual[]; +extern u8 PictureBookShelfScript[]; +extern u8 BookshelfScript[]; +extern u8 PokemonCenterBookshelfScript[]; +extern u8 VaseScript[]; +extern u8 TrashCanScript[]; +extern u8 ShopShelfScript[]; +extern u8 BlueprintScript[]; +extern u8 gUnknown_0815F36C[]; +extern u8 gUnknown_0815F43A[]; +extern u8 gUnknown_0815F523[]; +extern u8 gUnknown_0815F528[]; +extern u8 UseSurfScript[]; +extern u8 UseWaterfallScript[]; +extern u8 CannotUseWaterfallScript[]; +extern u8 UseDiveScript[]; +extern u8 UnderwaterUseDiveScript[]; +extern u8 GraniteCave_B1F_EventScript_1C6BC5[]; +extern u8 gUnknown_081A14B8[]; +extern u8 Event_EggHatch[]; +extern u8 gUnknown_0815FD0D[]; +extern u8 gUnknown_081C6BDE[]; + +static void player_get_pos_to_and_height(struct MapPosition *); +static void player_get_next_pos_and_height(struct MapPosition *); +static u16 cur_mapdata_block_role_at_player_pos(int); +static bool8 sub_80681F0(struct MapPosition *position, u16 b, u8 c); +static u8 *TryGetScriptOnPressingA(struct MapPosition *position, u8 b, u8 c); +static u8 *sub_8068364(struct MapPosition *, u8, u8); +static u8 *TryGetInvisibleMapObjectScript(struct MapPosition *, u8, u8 c); +static u8 *sub_8068500(struct MapPosition *, u8, u8); +static u8 *TryGetFieldMoveScript(struct MapPosition *, u8, u8); +static bool32 sub_8068770(void); +static bool32 sub_80687A4(void); +static bool8 sub_80687E4(struct MapPosition *, u16, u16); +bool8 mapheader_trigger_activate_at__run_now(struct MapPosition *); +bool8 sub_8068870(u16 a); +bool8 sub_8068894(void); +static void happiness_algorithm_step(void); +static bool8 overworld_poison_step(void); +static bool8 is_it_battle_time_3(u16); +static bool8 mapheader_run_first_tag2_script_list_match_conditionally(struct MapPosition *, u16, u8); +bool8 sub_8068A64(struct MapPosition *, u16); +static bool8 sub_8068B30(u16); +static bool8 is_non_stair_warp_tile(u16, u8); +static s8 map_warp_check_packed(struct MapHeader *, struct MapPosition *); +static void sub_8068C30(struct MapHeader *, s8, struct MapPosition *); +static bool8 map_warp_consider_2_to_inside(struct MapPosition *, u16, u8); +static s8 map_warp_check(struct MapHeader *, u16, u16, u8); +static u8 *mapheader_trigger_activate_at(struct MapHeader *, u16, u16, u8); +static struct BgEvent *FindInvisibleMapObjectByPosition(struct MapHeader *, u16, u16, u8); +u8 sub_8068F18(void); + +extern u8 mapheader_run_first_tag2_script_list_match(void); +extern void sub_8071310(void); +extern int sub_80A6D1C(void); +extern u8 sub_80BC050(); +extern u8 sub_80422A0(void); +extern s32 overworld_poison(void); +extern void sub_8080E88(); +extern void walkrun_find_lowest_active_bit_in_bitfield(void); +extern void sub_8080F2C(u8); +extern void sub_8080F48(void); +extern void sub_8080F58(void); +extern void sub_80BC038(); +extern void DoCoordEventWeather(u8); __attribute__((naked)) void sub_8067EEC(struct UnkInputStruct *s) @@ -42,8 +141,6 @@ void sub_8067EEC(struct UnkInputStruct *s) .syntax divided\n"); } -extern u16 cur_mapdata_block_role_at_player_pos(int); - void process_overworld_input(struct UnkInputStruct *pStruct, u16 keys, u16 heldKeys) { u8 r6 = gPlayerAvatar.running1; @@ -86,26 +183,6 @@ void process_overworld_input(struct UnkInputStruct *pStruct, u16 keys, u16 heldK pStruct->input_field_2 = 4; } -struct MapPosition -{ - s16 x; - s16 y; - u8 height; -}; - -void player_get_pos_to_and_height(struct MapPosition *); -extern u8 mapheader_run_first_tag2_script_list_match(void); -extern int sub_80687A4(void); -extern u8 sub_80687E4(); -extern u8 is_it_battle_time_3(); -extern u8 mapheader_run_first_tag2_script_list_match_conditionally(); -void player_get_next_pos_and_height(struct MapPosition *); -u8 sub_80681F0(struct MapPosition *position, u16 b, u8 c); -extern u8 map_warp_consider_2_to_inside(); -extern int sub_8068770(void); -extern void sub_8071310(void); -extern int sub_80A6D1C(void); - int sub_8068024(struct UnkInputStruct *s) { struct MapPosition position; @@ -116,54 +193,53 @@ int sub_8068024(struct UnkInputStruct *s) player_get_pos_to_and_height(&position); r4 = MapGridGetMetatileBehaviorAt(position.x, position.y); if (CheckTrainers() == TRUE) - return 1; + return TRUE; if (mapheader_run_first_tag2_script_list_match() == 1) - return 1; + return TRUE; if (s->input_field_0_7 && sub_80687A4() == 1) - return 1; + return TRUE; if (s->input_field_0_6) { IncrementGameStat(5); if (sub_80687E4(&position, r4, r6) == 1) - return 1; + return TRUE; } if (s->input_field_0_1 && is_it_battle_time_3(r4) == 1) - return 1; + return TRUE; if (s->input_field_0_4 && s->input_field_2 == r6) { if (mapheader_run_first_tag2_script_list_match_conditionally(&position, r4, r6) == 1) - return 1; + return TRUE; } player_get_next_pos_and_height(&position); r4 = MapGridGetMetatileBehaviorAt(position.x, position.y); if (s->input_field_0_0 && sub_80681F0(&position, r4, r6) == 1) - return 1; + return TRUE; if (s->input_field_0_5 && s->input_field_2 == r6) { if (map_warp_consider_2_to_inside(&position, r4, r6) == 1) - return 1; + return TRUE; } if (s->input_field_0_0 && sub_8068770() == 1) - return 1; + return TRUE; if (s->input_field_0_2) { - PlaySE(6); + PlaySE(SE_WIN_OPEN); sub_8071310(); - return 1; + return TRUE; } - //_08068154 if (s->input_field_0_3 && sub_80A6D1C() == 1) - return 1; + return TRUE; return FALSE; } -void player_get_pos_to_and_height(struct MapPosition *position) +static void player_get_pos_to_and_height(struct MapPosition *position) { PlayerGetDestCoords(&position->x, &position->y); position->height = PlayerGetZCoord(); } -void player_get_next_pos_and_height(struct MapPosition *position) +static void player_get_next_pos_and_height(struct MapPosition *position) { s16 x, y; @@ -175,7 +251,7 @@ void player_get_next_pos_and_height(struct MapPosition *position) position->height = 0; } -u16 cur_mapdata_block_role_at_player_pos(int unused) +static u16 cur_mapdata_block_role_at_player_pos(int unused) { s16 x, y; @@ -183,9 +259,7 @@ u16 cur_mapdata_block_role_at_player_pos(int unused) return MapGridGetMetatileBehaviorAt(x, y); } -u8 *TryGetScriptOnPressingA(struct MapPosition *position, u8 b, u8 c); - -u8 sub_80681F0(struct MapPosition *position, u16 b, u8 c) +static bool8 sub_80681F0(struct MapPosition *position, u16 b, u8 c) { u8 *script = TryGetScriptOnPressingA(position, b, c); @@ -203,12 +277,7 @@ u8 sub_80681F0(struct MapPosition *position, u16 b, u8 c) return TRUE; } -u8 *sub_8068364(); -u8 *TryGetInvisibleMapObjectScript(); -u8 *sub_8068500(); -u8 *TryGetFieldMoveScript(); - -u8 *TryGetScriptOnPressingA(struct MapPosition *position, u8 b, u8 c) +static u8 *TryGetScriptOnPressingA(struct MapPosition *position, u8 b, u8 c) { u8 *script; @@ -227,3 +296,646 @@ u8 *TryGetScriptOnPressingA(struct MapPosition *position, u8 b, u8 c) return NULL; } + +u8 *sub_80682A8(struct MapPosition *position, u8 unused, u8 c) +{ + u8 r3; + s32 i; + + if (!MetatileBehavior_IsCounter(MapGridGetMetatileBehaviorAt(position->x, position->y))) + r3 = GetFieldObjectIdByXYZ(position->x, position->y, position->height); + else + r3 = GetFieldObjectIdByXYZ(position->x + gUnknown_0821664C[c].x, position->y + gUnknown_0821664C[c].y, position->height); + if (r3 == 16 || gMapObjects[r3].localId == 0xFF) + return NULL; + for (i = 0; i < 4; i++) + { + if (gLinkPlayerMapObjects[i].active == TRUE && gLinkPlayerMapObjects[i].mapObjId == r3) + return NULL; + } + gSelectedMapObject = r3; + gScriptLastTalked = gMapObjects[r3].localId; + gScriptFacing = c; + return GetFieldObjectScriptPointerByFieldObjectId(r3); +} + +static u8 *sub_8068364(struct MapPosition *position, u8 b, u8 c) +{ + u8 r3; + u8 *script; + + r3 = GetFieldObjectIdByXYZ(position->x, position->y, position->height); + if (r3 == 16 || gMapObjects[r3].localId == 0xFF) + { + if (MetatileBehavior_IsCounter(b) != TRUE) + return NULL; + r3 = GetFieldObjectIdByXYZ(position->x + gUnknown_0821664C[c].x, position->y + gUnknown_0821664C[c].y, position->height); + if (r3 == 16 || gMapObjects[r3].localId == 0xFF) + return NULL; + } + //_080683E8 + gSelectedMapObject = r3; + gScriptLastTalked = gMapObjects[r3].localId; + gScriptFacing = c; + script = GetFieldObjectScriptPointerByFieldObjectId(r3); + script = GetRamScript(gScriptLastTalked, script); + return script; +} + +static u8 *TryGetInvisibleMapObjectScript(struct MapPosition *position, u8 unused, u8 c) +{ + struct BgEvent *bgEvent = FindInvisibleMapObjectByPosition(&gMapHeader, position->x - 7, position->y - 7, position->height); + + if (bgEvent == NULL) + return NULL; + if (bgEvent->script == NULL) + return gUnknown_081C6C02; + switch (bgEvent->kind) + { + case 0: + default: + return bgEvent->script; + case 1: + if (c != 2) + return NULL; + break; + case 2: + if (c != 1) + return NULL; + break; + case 3: + if (c != 4) + return NULL; + break; + case 4: + if (c != 3) + return NULL; + break; + case 5: + case 6: + case 7: + gSpecialVar_0x8004 = ((u32)bgEvent->script >> 16) + 0x258; + gSpecialVar_0x8005 = (u32)bgEvent->script; + if (FlagGet(gSpecialVar_0x8004) == TRUE) + return NULL; + return HiddenItemScript; + case 8: + if (c == 2) + { + gSpecialVar_0x8004 = (u32)bgEvent->script; + if (sub_80BC050()) + return gUnknown_081A2C51; + } + return NULL; + } + return bgEvent->script; +} + +static u8 *sub_8068500(struct MapPosition *position, u8 b, u8 c) +{ + s8 height; + + if (MetatileBehavior_IsPlayerFacingTVScreen(b, c) == TRUE) + return Event_TV; + if (MetatileBehavior_IsPC(b) == TRUE) + return gUnknown_081A0009; + if (MetatileBehavior_IsClosedSootopolisGymDoor(b) == TRUE) + return ClosedSootopolisGymDoorScript; + if (is_tile_x84(b) == TRUE) + return gUnknown_081A4363; + if (MetatileBehavior_IsPokeblockFeeder(b) == TRUE) + return gUnknown_081C346A; + if (MetatileBehavior_IsTrickHousePuzzleDoor(b) == TRUE) + return gUnknown_081616E1; + if (MetatileBehavior_IsRegionMap(b) == TRUE) + return Event_WorldMap; + if (sub_805791C(b) == TRUE) + return Event_RunningShoesManual; + if (MetatileBehavior_IsPictureBookShelf(b) == TRUE) + return PictureBookShelfScript; + if (MetatileBehavior_IsBookShelf(b) == TRUE) + return BookshelfScript; + if (MetatileBehavior_IsPokeCenterBookShelf(b) == TRUE) + return PokemonCenterBookshelfScript; + if (MetatileBehavior_IsVase(b) == TRUE) + return VaseScript; + if (MetatileBehavior_IsTrashCan(b) == TRUE) + return TrashCanScript; + if (MetatileBehavior_IsShopShelf(b) == TRUE) + return ShopShelfScript; + if (MetatileBehavior_IsBlueprint(b) == TRUE) + return BlueprintScript; + height = position->height; + if (height == MapGridGetZCoordAt(position->x, position->y)) + { + if (MetatileBehavior_IsSecretBasePC(b) == TRUE) + return gUnknown_0815F36C; + if (sub_805724C(b) == TRUE) + return gUnknown_0815F43A; + if (sub_8057364(b) == TRUE) + return gUnknown_0815F523; + if (sub_8057378(b) == TRUE) + return gUnknown_0815F528; + } + return NULL; +} + +static u8 *TryGetFieldMoveScript(struct MapPosition *unused1, u8 b, u8 unused2) +{ + if (FlagGet(BADGE05_GET) == TRUE && PartyHasMonWithSurf() == TRUE && IsPlayerFacingSurfableFishableWater() == TRUE) + return UseSurfScript; + if (MetatileBehavior_IsWaterfall(b) == TRUE) + { + if (FlagGet(BADGE08_GET) == TRUE && IsPlayerSurfingNorth() == TRUE) + return UseWaterfallScript; + else + return CannotUseWaterfallScript; + } + return NULL; +} + +static bool32 sub_8068770(void) +{ + if (FlagGet(BADGE07_GET) && sub_8068F18() == 2) + { + ScriptContext1_SetupScript(UseDiveScript); + return TRUE; + } + return FALSE; +} + +static bool32 sub_80687A4(void) +{ + if (FlagGet(BADGE07_GET) && gMapHeader.mapType == 5 && sub_8068F18() == 1) + { + ScriptContext1_SetupScript(UnderwaterUseDiveScript); + return TRUE; + } + return FALSE; +} + +#ifdef NONMATCHING +static bool8 sub_80687E4(struct MapPosition *position, u16 b, u16 unused) +{ + if (mapheader_trigger_activate_at__run_now(position) != TRUE + && sub_8068A64(position, b) != TRUE && sub_8068870(b) != TRUE + && sub_8068894() != TRUE && UpdateRepelCounter() != TRUE) + return FALSE; + return TRUE; +} +#else +__attribute__((naked)) +static bool8 sub_80687E4(struct MapPosition *position, u16 b, u16 unused) +{ + asm(".syntax unified\n\ + push {r4-r6,lr}\n\ + adds r5, r0, 0\n\ + lsls r1, 16\n\ + lsrs r4, r1, 16\n\ + adds r6, r4, 0\n\ + bl mapheader_trigger_activate_at__run_now\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + cmp r0, 0x1\n\ + beq _08068834\n\ + adds r0, r5, 0\n\ + adds r1, r4, 0\n\ + bl sub_8068A64\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + cmp r0, 0x1\n\ + beq _08068834\n\ + adds r0, r6, 0\n\ + bl sub_8068870\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + cmp r0, 0x1\n\ + beq _08068834\n\ + bl sub_8068894\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + cmp r0, 0x1\n\ + beq _08068834\n\ + bl UpdateRepelCounter\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + cmp r0, 0x1\n\ + beq _08068834\n\ + movs r0, 0\n\ + b _08068836\n\ +_08068834:\n\ + movs r0, 0x1\n\ +_08068836:\n\ + pop {r4-r6}\n\ + pop {r1}\n\ + bx r1\n\ + .syntax divided\n"); +} +#endif + +bool8 mapheader_trigger_activate_at__run_now(struct MapPosition *position) +{ + u8 *script = mapheader_trigger_activate_at(&gMapHeader, position->x - 7, position->y - 7, position->height); + + if (script == NULL) + return FALSE; + ScriptContext1_SetupScript(script); + return TRUE; +} + +//can be u8, u16, or u32 +bool8 sub_8068870(u16 a) +{ + if (MetatileBehavior_IsCrackedFloorHole(a)) + { + ScriptContext1_SetupScript(GraniteCave_B1F_EventScript_1C6BC5); + return TRUE; + } + return FALSE; +} + +bool8 sub_8068894(void) +{ + sub_8082B78(); + happiness_algorithm_step(); + if (overworld_poison_step() == TRUE) + { + ScriptContext1_SetupScript(gUnknown_081A14B8); + return TRUE; + } + if (sub_80422A0()) + { + IncrementGameStat(13); + ScriptContext1_SetupScript(Event_EggHatch); + return TRUE; + } + if (SafariZoneTakeStep() == TRUE) + return TRUE; + if (sub_810D9B0(1) == TRUE) + { + ScriptContext1_SetupScript(gUnknown_0815FD0D); + return TRUE; + } + return FALSE; +} + +void unref_sub_80688F8(void) +{ + VarSet(VAR_HAPPINESS_STEP_COUNTER, 0); +} + +static void happiness_algorithm_step(void) +{ + u16 *ptr = GetVarPointer(VAR_HAPPINESS_STEP_COUNTER); + int i; + + (*ptr)++; + (*ptr) %= 128; + if (*ptr == 0) + { + struct Pokemon *pkmn = gPlayerParty; + + for (i = 5; i >= 0; i--) + { + AdjustFriendship(pkmn, 5); + pkmn++; + } + } +} + +void overworld_poison_timer_set(void) +{ + VarSet(VAR_POISON_STEP_COUNTER, 0); +} + +static bool8 overworld_poison_step(void) +{ + u16 *ptr; + + if (gMapHeader.mapType != 9) + { + ptr = GetVarPointer(VAR_POISON_STEP_COUNTER); + (*ptr)++; + (*ptr) %= 4; + if (*ptr == 0) + { + switch (overworld_poison()) + { + case 0: + return FALSE; + case 1: + return FALSE; + case 2: + return TRUE; + } + } + } + return FALSE; +} + +void prev_quest_postbuffer_cursor_backup_reset(void) +{ + gUnknown_0202E8C0 = 0; +} + +static bool8 is_it_battle_time_3(u16 a) +{ + if (gUnknown_0202E8C0 < 4) + { + gUnknown_0202E8C0++; + gUnknown_0202E8C2 = a; + return FALSE; + } + if (StandardWildEncounter(a, gUnknown_0202E8C2) == TRUE) + { + gUnknown_0202E8C0 = 0; + gUnknown_0202E8C2 = a; + return TRUE; + } + else + { + gUnknown_0202E8C2 = a; + return FALSE; + } +} + +static bool8 mapheader_run_first_tag2_script_list_match_conditionally(struct MapPosition *position, u16 b, u8 c) +{ + s8 r6 = map_warp_check_packed(&gMapHeader, position); + + if (is_non_stair_warp_tile(b, c) == TRUE && r6 != -1) + { + walkrun_find_lowest_active_bit_in_bitfield(); + sub_8068C30(&gMapHeader, r6, position); + sub_8080E88(); + return TRUE; + } + return FALSE; +} + +bool8 sub_8068A64(struct MapPosition *position, u16 b) +{ + s8 r4 = map_warp_check_packed(&gMapHeader, position); + + if (r4 != -1 && sub_8068B30(b) == TRUE) + { + walkrun_find_lowest_active_bit_in_bitfield(); + sub_8068C30(&gMapHeader, r4, position); + if (MetatileBehavior_IsEscalator(b) == TRUE) + { + sub_8080F2C(b); + return TRUE; + } + if (MetatileBehavior_IsLavaridgeB1FWarp(b) == TRUE) + { + sub_8080F48(); + return TRUE; + } + if (MetatileBehavior_IsLavaridge1FWarp(b) == TRUE) + { + sub_8080F58(); + return TRUE; + } + if (MetatileBehavior_IsAquaHideoutWarp(b) == TRUE) + { + sub_8080F68(); + return TRUE; + } + if (MetatileBehavior_IsMtPyreHole(b) == TRUE) + { + ScriptContext1_SetupScript(gUnknown_081C6BDE); + return TRUE; + } + sub_8080E88(); + return TRUE; + } + return FALSE; +} + +static bool8 sub_8068B30(u16 a) +{ + if (MetatileBehavior_IsWarpDoor(a) != TRUE + && MetatileBehavior_IsLadder(a) != TRUE + && MetatileBehavior_IsEscalator(a) != TRUE + && MetatileBehavior_IsNonAnimDoor(a) != TRUE + && MetatileBehavior_IsLavaridgeB1FWarp(a) != TRUE + && MetatileBehavior_IsLavaridge1FWarp(a) != TRUE + && MetatileBehavior_IsAquaHideoutWarp(a) != TRUE + && MetatileBehavior_IsMtPyreHole(a) != TRUE) + return FALSE; + return TRUE; +} + +static bool8 is_non_stair_warp_tile(u16 a, u8 b) +{ + switch (b) + { + case 2: + return MetatileBehavior_IsNorthArrowWarp(a); + case 1: + return MetatileBehavior_IsSouthArrowWarp(a); + case 3: + return MetatileBehavior_IsWestArrowWarp(a); + case 4: + return MetatileBehavior_IsEastArrowWarp(a); + } + return FALSE; +} + +static s8 map_warp_check_packed(struct MapHeader *mapHeader, struct MapPosition *position) +{ + return map_warp_check(mapHeader, position->x - 7, position->y - 7, position->height); +} + +static void sub_8068C30(struct MapHeader *unused, s8 b, struct MapPosition *position) +{ + struct WarpEvent *warpEvent = &gMapHeader.events->warps[b]; + + if (warpEvent->mapNum == 0x7F) + { + copy_saved_warp2_bank_and_enter_x_to_warp1(warpEvent->mapGroup); + } + else + { + struct MapHeader *mapHeader; + + warp1_set_2(warpEvent->unk7, warpEvent->mapNum, warpEvent->mapGroup); + sub_80535C4(position->x, position->y); + mapHeader = get_mapheader_by_bank_and_number(warpEvent->unk7, warpEvent->mapNum); + if (mapHeader->events->warps[warpEvent->mapGroup].mapNum == 0x7F) + saved_warp2_set(mapHeader->events->warps[b].mapGroup, gSaveBlock1.location.mapGroup, gSaveBlock1.location.mapNum, b); + } +} + +static bool8 map_warp_consider_2_to_inside(struct MapPosition *position, u16 b, u8 c) +{ + s8 r4; + + if (c == 2) + { + if (sub_80571C0(b) == TRUE) + { + sub_80BC038(position, gMapHeader.events); + return TRUE; + } + if (MetatileBehavior_IsWarpDoor(b) == TRUE) + { + r4 = map_warp_check_packed(&gMapHeader, position); + if (r4 != -1 && sub_8068B30(b) == TRUE) + { + walkrun_find_lowest_active_bit_in_bitfield(); + sub_8068C30(&gMapHeader, r4, position); + sub_8080EF0(); + return TRUE; + } + } + } + return FALSE; +} + +static s8 map_warp_check(struct MapHeader *mapHeader, u16 b, u16 c, u8 d) +{ + s32 i; + struct WarpEvent *warpEvent = mapHeader->events->warps; + u8 warpCount = mapHeader->events->warpCount; + + for (i = 0; i < warpCount; i++, warpEvent++) + { + if ((u16)warpEvent->x == b && (u16)warpEvent->y == c) + { + if ((u8)warpEvent->warpId == d || (u8)warpEvent->warpId == 0) + return i; + } + } + return -1; +} + +static u8 *trigger_activate(struct CoordEvent *coordEvent) +{ + if (coordEvent != NULL) + { + if (coordEvent->script == NULL) + { + DoCoordEventWeather(coordEvent->trigger); + return NULL; + } + if (coordEvent->trigger == 0) + { + ScriptContext2_RunNewScript(coordEvent->script); + return NULL; + } + if (VarGet(coordEvent->trigger) == (u8)coordEvent->index) + return coordEvent->script; + } + return NULL; +} + +static u8 *mapheader_trigger_activate_at(struct MapHeader *mapHeader, u16 b, u16 c, u8 d) +{ + s32 i; + struct CoordEvent *coordEvents = mapHeader->events->coordEvents; + u8 coordEventCount = mapHeader->events->coordEventCount; + u8 *script; + + for (i = 0; i < coordEventCount; i++) + { + if ((u16)coordEvents[i].x == b && (u16)coordEvents[i].y == c) + { + if (coordEvents[i].unk4 == d || coordEvents[i].unk4 == 0) + { + script = trigger_activate(&coordEvents[i]); + if (script != NULL) + return script; + } + } + } + return NULL; +} + +u8 *sub_8068E24(struct MapPosition *position) +{ + return mapheader_trigger_activate_at(&gMapHeader, position->x - 7, position->y - 7, position->height); +} + +static struct BgEvent *FindInvisibleMapObjectByPosition(struct MapHeader *mapHeader, u16 b, u16 c, u8 d) +{ + u8 i; + struct BgEvent *bgEvents = mapHeader->events->bgEvents; + u8 bgEventCount = mapHeader->events->bgEventCount; + + for (i = 0; i < bgEventCount; i++) + { + if ((u16)bgEvents[i].x == b && (u16)bgEvents[i].y == c) + { + if (bgEvents[i].unk4 == d || bgEvents[i].unk4 == 0) + return &bgEvents[i]; + } + } + return NULL; +} + +int dive_warp(struct MapPosition *position, u16 b) +{ + if (gMapHeader.mapType == 5 && sub_805750C(b) == 0) + { + if (sub_80538B0(position->x - 7, position->y - 7)) + { + walkrun_find_lowest_active_bit_in_bitfield(); + sp13E_warp_to_last_warp(); + PlaySE(SE_W291); + return TRUE; + } + } + else if (sub_80574EC(b) == TRUE) + { + if (sub_80538D0(position->x - 7, position->y - 7)) + { + walkrun_find_lowest_active_bit_in_bitfield(); + sp13E_warp_to_last_warp(); + PlaySE(SE_W291); + return TRUE; + } + } + return FALSE; +} + +u8 sub_8068F18(void) +{ + s16 x, y; + u8 r5; + + PlayerGetDestCoords(&x, &y); + r5 = MapGridGetMetatileBehaviorAt(x, y); + if (gMapHeader.mapType == 5 && sub_805750C(r5) == 0) + { + if (sub_80538B0(x - 7, y - 7) == TRUE) + return 1; + } + else if (sub_80574EC(r5) == TRUE) + { + if (sub_80538D0(x - 7, y - 7) == TRUE) + return 2; + } + return 0; +} + +u8 *GetFieldObjectScriptPointerForComparison(void) +{ + u8 r4; + struct MapPosition position; + + r4 = player_get_direction_upper_nybble(); + player_get_next_pos_and_height(&position); + return sub_8068364(&position, MapGridGetMetatileBehaviorAt(position.x, position.y), r4); +} + +int sub_8068FEC(void) +{ + struct MapPosition position; + + player_get_direction_upper_nybble(); //unnecessary + player_get_pos_to_and_height(&position); + MapGridGetMetatileBehaviorAt(position.x, position.y); //unnecessary + sub_8068C30(&gMapHeader, map_warp_check_packed(&gMapHeader, &position), &position); + return 0; +} -- cgit v1.2.3 From acf6f59e389aff6b11e8134095e25727d014bc0a Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Tue, 10 Jan 2017 22:19:12 -0800 Subject: make sub_80687E4 match --- src/field_control_avatar.c | 66 ++++++++-------------------------------------- 1 file changed, 11 insertions(+), 55 deletions(-) (limited to 'src/field_control_avatar.c') diff --git a/src/field_control_avatar.c b/src/field_control_avatar.c index 4b75c7a32..191316df6 100644 --- a/src/field_control_avatar.c +++ b/src/field_control_avatar.c @@ -474,64 +474,20 @@ static bool32 sub_80687A4(void) return FALSE; } -#ifdef NONMATCHING static bool8 sub_80687E4(struct MapPosition *position, u16 b, u16 unused) { - if (mapheader_trigger_activate_at__run_now(position) != TRUE - && sub_8068A64(position, b) != TRUE && sub_8068870(b) != TRUE - && sub_8068894() != TRUE && UpdateRepelCounter() != TRUE) - return FALSE; - return TRUE; -} -#else -__attribute__((naked)) -static bool8 sub_80687E4(struct MapPosition *position, u16 b, u16 unused) -{ - asm(".syntax unified\n\ - push {r4-r6,lr}\n\ - adds r5, r0, 0\n\ - lsls r1, 16\n\ - lsrs r4, r1, 16\n\ - adds r6, r4, 0\n\ - bl mapheader_trigger_activate_at__run_now\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - cmp r0, 0x1\n\ - beq _08068834\n\ - adds r0, r5, 0\n\ - adds r1, r4, 0\n\ - bl sub_8068A64\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - cmp r0, 0x1\n\ - beq _08068834\n\ - adds r0, r6, 0\n\ - bl sub_8068870\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - cmp r0, 0x1\n\ - beq _08068834\n\ - bl sub_8068894\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - cmp r0, 0x1\n\ - beq _08068834\n\ - bl UpdateRepelCounter\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - cmp r0, 0x1\n\ - beq _08068834\n\ - movs r0, 0\n\ - b _08068836\n\ -_08068834:\n\ - movs r0, 0x1\n\ -_08068836:\n\ - pop {r4-r6}\n\ - pop {r1}\n\ - bx r1\n\ - .syntax divided\n"); + if (mapheader_trigger_activate_at__run_now(position) == TRUE) + return TRUE; + if (sub_8068A64(position, b) == TRUE) + return TRUE; + if (sub_8068870(b) == TRUE) + return TRUE; + if (sub_8068894() == TRUE) + return TRUE; + if (UpdateRepelCounter() == TRUE) + return TRUE; + return FALSE; } -#endif bool8 mapheader_trigger_activate_at__run_now(struct MapPosition *position) { -- cgit v1.2.3 From d71d6fd384b6a5aa39f1da154708e2077c01dd5c Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Tue, 10 Jan 2017 22:21:52 -0800 Subject: clean up trailing whitespace --- src/field_control_avatar.c | 54 +++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 27 deletions(-) (limited to 'src/field_control_avatar.c') diff --git a/src/field_control_avatar.c b/src/field_control_avatar.c index 191316df6..e850a0125 100644 --- a/src/field_control_avatar.c +++ b/src/field_control_avatar.c @@ -146,7 +146,7 @@ void process_overworld_input(struct UnkInputStruct *pStruct, u16 keys, u16 heldK u8 r6 = gPlayerAvatar.running1; u8 r9 = gPlayerAvatar.running2; bool8 r7 = MetatileBehavior_IsMoveTile(cur_mapdata_block_role_at_player_pos(r9)); - + if ((r6 == 2 && r7 == FALSE) || r6 == 0) { if (sub_80E6034() != 4) @@ -242,7 +242,7 @@ static void player_get_pos_to_and_height(struct MapPosition *position) static void player_get_next_pos_and_height(struct MapPosition *position) { s16 x, y; - + GetXYCoordsOneStepInFrontOfPlayer(&position->x, &position->y); PlayerGetDestCoords(&x, &y); if (MapGridGetZCoordAt(x, y) != 0) @@ -254,7 +254,7 @@ static void player_get_next_pos_and_height(struct MapPosition *position) static u16 cur_mapdata_block_role_at_player_pos(int unused) { s16 x, y; - + PlayerGetDestCoords(&x, &y); return MapGridGetMetatileBehaviorAt(x, y); } @@ -262,17 +262,17 @@ static u16 cur_mapdata_block_role_at_player_pos(int unused) static bool8 sub_80681F0(struct MapPosition *position, u16 b, u8 c) { u8 *script = TryGetScriptOnPressingA(position, b, c); - + if (script == NULL) return FALSE; - + if (script != gUnknown_0815281E && script != gUnknown_08152C39 && script != gUnknown_0815F36C && script != gUnknown_0815F43A && script != gUnknown_081A0009) PlaySE(5); - + ScriptContext1_SetupScript(script); return TRUE; } @@ -280,7 +280,7 @@ static bool8 sub_80681F0(struct MapPosition *position, u16 b, u8 c) static u8 *TryGetScriptOnPressingA(struct MapPosition *position, u8 b, u8 c) { u8 *script; - + script = sub_8068364(position, b, c); if (script != NULL) return script; @@ -293,7 +293,7 @@ static u8 *TryGetScriptOnPressingA(struct MapPosition *position, u8 b, u8 c) script = TryGetFieldMoveScript(position, b, c); if (script != NULL) return script; - + return NULL; } @@ -301,7 +301,7 @@ u8 *sub_80682A8(struct MapPosition *position, u8 unused, u8 c) { u8 r3; s32 i; - + if (!MetatileBehavior_IsCounter(MapGridGetMetatileBehaviorAt(position->x, position->y))) r3 = GetFieldObjectIdByXYZ(position->x, position->y, position->height); else @@ -323,7 +323,7 @@ static u8 *sub_8068364(struct MapPosition *position, u8 b, u8 c) { u8 r3; u8 *script; - + r3 = GetFieldObjectIdByXYZ(position->x, position->y, position->height); if (r3 == 16 || gMapObjects[r3].localId == 0xFF) { @@ -345,7 +345,7 @@ static u8 *sub_8068364(struct MapPosition *position, u8 b, u8 c) static u8 *TryGetInvisibleMapObjectScript(struct MapPosition *position, u8 unused, u8 c) { struct BgEvent *bgEvent = FindInvisibleMapObjectByPosition(&gMapHeader, position->x - 7, position->y - 7, position->height); - + if (bgEvent == NULL) return NULL; if (bgEvent->script == NULL) @@ -394,7 +394,7 @@ static u8 *TryGetInvisibleMapObjectScript(struct MapPosition *position, u8 unuse static u8 *sub_8068500(struct MapPosition *position, u8 b, u8 c) { s8 height; - + if (MetatileBehavior_IsPlayerFacingTVScreen(b, c) == TRUE) return Event_TV; if (MetatileBehavior_IsPC(b) == TRUE) @@ -492,7 +492,7 @@ static bool8 sub_80687E4(struct MapPosition *position, u16 b, u16 unused) bool8 mapheader_trigger_activate_at__run_now(struct MapPosition *position) { u8 *script = mapheader_trigger_activate_at(&gMapHeader, position->x - 7, position->y - 7, position->height); - + if (script == NULL) return FALSE; ScriptContext1_SetupScript(script); @@ -544,13 +544,13 @@ static void happiness_algorithm_step(void) { u16 *ptr = GetVarPointer(VAR_HAPPINESS_STEP_COUNTER); int i; - + (*ptr)++; (*ptr) %= 128; if (*ptr == 0) { struct Pokemon *pkmn = gPlayerParty; - + for (i = 5; i >= 0; i--) { AdjustFriendship(pkmn, 5); @@ -567,7 +567,7 @@ void overworld_poison_timer_set(void) static bool8 overworld_poison_step(void) { u16 *ptr; - + if (gMapHeader.mapType != 9) { ptr = GetVarPointer(VAR_POISON_STEP_COUNTER); @@ -618,7 +618,7 @@ static bool8 is_it_battle_time_3(u16 a) static bool8 mapheader_run_first_tag2_script_list_match_conditionally(struct MapPosition *position, u16 b, u8 c) { s8 r6 = map_warp_check_packed(&gMapHeader, position); - + if (is_non_stair_warp_tile(b, c) == TRUE && r6 != -1) { walkrun_find_lowest_active_bit_in_bitfield(); @@ -632,7 +632,7 @@ static bool8 mapheader_run_first_tag2_script_list_match_conditionally(struct Map bool8 sub_8068A64(struct MapPosition *position, u16 b) { s8 r4 = map_warp_check_packed(&gMapHeader, position); - + if (r4 != -1 && sub_8068B30(b) == TRUE) { walkrun_find_lowest_active_bit_in_bitfield(); @@ -706,7 +706,7 @@ static s8 map_warp_check_packed(struct MapHeader *mapHeader, struct MapPosition static void sub_8068C30(struct MapHeader *unused, s8 b, struct MapPosition *position) { struct WarpEvent *warpEvent = &gMapHeader.events->warps[b]; - + if (warpEvent->mapNum == 0x7F) { copy_saved_warp2_bank_and_enter_x_to_warp1(warpEvent->mapGroup); @@ -714,7 +714,7 @@ static void sub_8068C30(struct MapHeader *unused, s8 b, struct MapPosition *posi else { struct MapHeader *mapHeader; - + warp1_set_2(warpEvent->unk7, warpEvent->mapNum, warpEvent->mapGroup); sub_80535C4(position->x, position->y); mapHeader = get_mapheader_by_bank_and_number(warpEvent->unk7, warpEvent->mapNum); @@ -726,7 +726,7 @@ static void sub_8068C30(struct MapHeader *unused, s8 b, struct MapPosition *posi static bool8 map_warp_consider_2_to_inside(struct MapPosition *position, u16 b, u8 c) { s8 r4; - + if (c == 2) { if (sub_80571C0(b) == TRUE) @@ -754,7 +754,7 @@ static s8 map_warp_check(struct MapHeader *mapHeader, u16 b, u16 c, u8 d) s32 i; struct WarpEvent *warpEvent = mapHeader->events->warps; u8 warpCount = mapHeader->events->warpCount; - + for (i = 0; i < warpCount; i++, warpEvent++) { if ((u16)warpEvent->x == b && (u16)warpEvent->y == c) @@ -792,7 +792,7 @@ static u8 *mapheader_trigger_activate_at(struct MapHeader *mapHeader, u16 b, u16 struct CoordEvent *coordEvents = mapHeader->events->coordEvents; u8 coordEventCount = mapHeader->events->coordEventCount; u8 *script; - + for (i = 0; i < coordEventCount; i++) { if ((u16)coordEvents[i].x == b && (u16)coordEvents[i].y == c) @@ -818,7 +818,7 @@ static struct BgEvent *FindInvisibleMapObjectByPosition(struct MapHeader *mapHea u8 i; struct BgEvent *bgEvents = mapHeader->events->bgEvents; u8 bgEventCount = mapHeader->events->bgEventCount; - + for (i = 0; i < bgEventCount; i++) { if ((u16)bgEvents[i].x == b && (u16)bgEvents[i].y == c) @@ -859,7 +859,7 @@ u8 sub_8068F18(void) { s16 x, y; u8 r5; - + PlayerGetDestCoords(&x, &y); r5 = MapGridGetMetatileBehaviorAt(x, y); if (gMapHeader.mapType == 5 && sub_805750C(r5) == 0) @@ -879,7 +879,7 @@ u8 *GetFieldObjectScriptPointerForComparison(void) { u8 r4; struct MapPosition position; - + r4 = player_get_direction_upper_nybble(); player_get_next_pos_and_height(&position); return sub_8068364(&position, MapGridGetMetatileBehaviorAt(position.x, position.y), r4); @@ -888,7 +888,7 @@ u8 *GetFieldObjectScriptPointerForComparison(void) int sub_8068FEC(void) { struct MapPosition position; - + player_get_direction_upper_nybble(); //unnecessary player_get_pos_to_and_height(&position); MapGridGetMetatileBehaviorAt(position.x, position.y); //unnecessary -- cgit v1.2.3 From beb36d26968604fbb9b8da433a4a78ada9092e11 Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Tue, 10 Jan 2017 22:28:02 -0800 Subject: decompile sub_8067EEC --- src/field_control_avatar.c | 38 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 25 deletions(-) (limited to 'src/field_control_avatar.c') diff --git a/src/field_control_avatar.c b/src/field_control_avatar.c index e850a0125..c68976cf9 100644 --- a/src/field_control_avatar.c +++ b/src/field_control_avatar.c @@ -112,33 +112,21 @@ extern void sub_8080F58(void); extern void sub_80BC038(); extern void DoCoordEventWeather(u8); -__attribute__((naked)) void sub_8067EEC(struct UnkInputStruct *s) { - asm(".syntax unified\n\ - push {r4,r5,lr}\n\ - movs r1, 0x2\n\ - negs r1, r1\n\ - movs r3, 0x3\n\ - negs r3, r3\n\ - movs r4, 0x5\n\ - negs r4, r4\n\ - movs r5, 0x9\n\ - negs r5, r5\n\ - movs r2, 0\n\ - strb r2, [r0]\n\ - ldrb r2, [r0, 0x1]\n\ - ands r1, r2\n\ - ands r1, r3\n\ - ands r1, r4\n\ - ands r1, r5\n\ - strb r1, [r0, 0x1]\n\ - movs r1, 0\n\ - strb r1, [r0, 0x2]\n\ - pop {r4,r5}\n\ - pop {r0}\n\ - bx r0\n\ - .syntax divided\n"); + s->input_field_0_0 = 0; + s->input_field_0_1 = 0; + s->input_field_0_2 = 0; + s->input_field_0_3 = 0; + s->input_field_0_4 = 0; + s->input_field_0_5 = 0; + s->input_field_0_6 = 0; + s->input_field_0_7 = 0; + s->input_field_1_0 = 0; + s->input_field_1_1 = 0; + s->input_field_1_2 = 0; + s->input_field_1_3 = 0; + s->input_field_2 = 0; } void process_overworld_input(struct UnkInputStruct *pStruct, u16 keys, u16 heldKeys) -- cgit v1.2.3 From ef82a98a1525f58d3a6c56194a42f7660cfc923b Mon Sep 17 00:00:00 2001 From: Cameron Hall Date: Sat, 21 Jan 2017 22:04:49 -0600 Subject: label a few things and put data in field_player_avatar.c (#212) --- src/field_control_avatar.c | 90 +++++++++++++++++++++++----------------------- 1 file changed, 45 insertions(+), 45 deletions(-) (limited to 'src/field_control_avatar.c') diff --git a/src/field_control_avatar.c b/src/field_control_avatar.c index c68976cf9..6f36ddb0f 100644 --- a/src/field_control_avatar.c +++ b/src/field_control_avatar.c @@ -112,66 +112,66 @@ extern void sub_8080F58(void); extern void sub_80BC038(); extern void DoCoordEventWeather(u8); -void sub_8067EEC(struct UnkInputStruct *s) +void FieldClearPlayerInput(struct FieldInput *input) { - s->input_field_0_0 = 0; - s->input_field_0_1 = 0; - s->input_field_0_2 = 0; - s->input_field_0_3 = 0; - s->input_field_0_4 = 0; - s->input_field_0_5 = 0; - s->input_field_0_6 = 0; - s->input_field_0_7 = 0; - s->input_field_1_0 = 0; - s->input_field_1_1 = 0; - s->input_field_1_2 = 0; - s->input_field_1_3 = 0; - s->input_field_2 = 0; + input->pressedAButton = 0; + input->input_field_0_1 = 0; + input->pressedStartButton = 0; + input->pressedSelectButton = 0; + input->input_field_0_4 = 0; + input->input_field_0_5 = 0; + input->input_field_0_6 = 0; + input->pressedBButton = 0; + input->input_field_1_0 = 0; + input->input_field_1_1 = 0; + input->input_field_1_2 = 0; + input->input_field_1_3 = 0; + input->dpadDirection = 0; } -void process_overworld_input(struct UnkInputStruct *pStruct, u16 keys, u16 heldKeys) +void FieldGetPlayerInput(struct FieldInput *input, u16 newKeys, u16 heldKeys) { u8 r6 = gPlayerAvatar.running1; u8 r9 = gPlayerAvatar.running2; - bool8 r7 = MetatileBehavior_IsMoveTile(cur_mapdata_block_role_at_player_pos(r9)); + bool8 forcedMove = MetatileBehavior_IsMoveTile(cur_mapdata_block_role_at_player_pos(r9)); - if ((r6 == 2 && r7 == FALSE) || r6 == 0) + if ((r6 == 2 && forcedMove == FALSE) || r6 == 0) { if (sub_80E6034() != 4) { - if (keys & START_BUTTON) - pStruct->input_field_0_2 = TRUE; - if (keys & SELECT_BUTTON) - pStruct->input_field_0_3 = TRUE; - if (keys & A_BUTTON) - pStruct->input_field_0_0 = TRUE; - if (keys & B_BUTTON) - pStruct->input_field_0_7 = TRUE; + if (newKeys & START_BUTTON) + input->pressedStartButton = TRUE; + if (newKeys & SELECT_BUTTON) + input->pressedSelectButton = TRUE; + if (newKeys & A_BUTTON) + input->pressedAButton = TRUE; + if (newKeys & B_BUTTON) + input->pressedBButton = TRUE; } if (heldKeys & (DPAD_UP | DPAD_DOWN | DPAD_LEFT | DPAD_RIGHT)) { - pStruct->input_field_0_4 = TRUE; - pStruct->input_field_0_5 = TRUE; + input->input_field_0_4 = TRUE; + input->input_field_0_5 = TRUE; } } - if (r7 == FALSE) + if (forcedMove == FALSE) { if (r6 == 2 && r9 == 2) - pStruct->input_field_0_6 = TRUE; - if (r7 == FALSE && r6 == 2) - pStruct->input_field_0_1 = TRUE; + input->input_field_0_6 = TRUE; + if (forcedMove == FALSE && r6 == 2) + input->input_field_0_1 = TRUE; } if (heldKeys & DPAD_UP) - pStruct->input_field_2 = 2; + input->dpadDirection = DIR_NORTH; else if (heldKeys & DPAD_DOWN) - pStruct->input_field_2 = 1; + input->dpadDirection = DIR_SOUTH; else if (heldKeys & DPAD_LEFT) - pStruct->input_field_2 = 3; + input->dpadDirection = DIR_WEST; else if (heldKeys & DPAD_RIGHT) - pStruct->input_field_2 = 4; + input->dpadDirection = DIR_EAST; } -int sub_8068024(struct UnkInputStruct *s) +int sub_8068024(struct FieldInput *input) { struct MapPosition position; u8 r6; @@ -184,39 +184,39 @@ int sub_8068024(struct UnkInputStruct *s) return TRUE; if (mapheader_run_first_tag2_script_list_match() == 1) return TRUE; - if (s->input_field_0_7 && sub_80687A4() == 1) + if (input->pressedBButton && sub_80687A4() == 1) return TRUE; - if (s->input_field_0_6) + if (input->input_field_0_6) { IncrementGameStat(5); if (sub_80687E4(&position, r4, r6) == 1) return TRUE; } - if (s->input_field_0_1 && is_it_battle_time_3(r4) == 1) + if (input->input_field_0_1 && is_it_battle_time_3(r4) == 1) return TRUE; - if (s->input_field_0_4 && s->input_field_2 == r6) + if (input->input_field_0_4 && input->dpadDirection == r6) { if (mapheader_run_first_tag2_script_list_match_conditionally(&position, r4, r6) == 1) return TRUE; } player_get_next_pos_and_height(&position); r4 = MapGridGetMetatileBehaviorAt(position.x, position.y); - if (s->input_field_0_0 && sub_80681F0(&position, r4, r6) == 1) + if (input->pressedAButton && sub_80681F0(&position, r4, r6) == 1) return TRUE; - if (s->input_field_0_5 && s->input_field_2 == r6) + if (input->input_field_0_5 && input->dpadDirection == r6) { if (map_warp_consider_2_to_inside(&position, r4, r6) == 1) return TRUE; } - if (s->input_field_0_0 && sub_8068770() == 1) + if (input->pressedAButton && sub_8068770() == 1) return TRUE; - if (s->input_field_0_2) + if (input->pressedStartButton) { PlaySE(SE_WIN_OPEN); sub_8071310(); return TRUE; } - if (s->input_field_0_3 && sub_80A6D1C() == 1) + if (input->pressedSelectButton && sub_80A6D1C() == 1) return TRUE; return FALSE; } -- cgit v1.2.3 From ed8f49d5e1418309cbc4f705a242d073258c8639 Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Sat, 28 Jan 2017 13:51:14 -0800 Subject: tabs to spaces --- src/field_control_avatar.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/field_control_avatar.c') diff --git a/src/field_control_avatar.c b/src/field_control_avatar.c index 6f36ddb0f..f05959a79 100644 --- a/src/field_control_avatar.c +++ b/src/field_control_avatar.c @@ -16,8 +16,8 @@ struct Coords32 { - s32 x; - s32 y; + s32 x; + s32 y; }; extern const struct Coords32 gUnknown_0821664C[]; -- cgit v1.2.3 From b6b5453431af46791fd9d211efac64464c1dff85 Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Sun, 29 Jan 2017 20:59:54 -0500 Subject: start decompiling mauville_old_man.c (#225) * some labels and enumerate player speeds * clear up speed enums * GetPlayerSpeed * oops * start decompiling mauville_old_man.c * formatting * decompile more of mauville_old_man.c * someone fix this please * formatting * make ROM build again * formatting again --- src/field_control_avatar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/field_control_avatar.c') diff --git a/src/field_control_avatar.c b/src/field_control_avatar.c index f05959a79..992e461eb 100644 --- a/src/field_control_avatar.c +++ b/src/field_control_avatar.c @@ -137,7 +137,7 @@ void FieldGetPlayerInput(struct FieldInput *input, u16 newKeys, u16 heldKeys) if ((r6 == 2 && forcedMove == FALSE) || r6 == 0) { - if (sub_80E6034() != 4) + if (GetPlayerSpeed() != 4) { if (newKeys & START_BUTTON) input->pressedStartButton = TRUE; -- cgit v1.2.3 From 6035511c139549a0291b6b3d43b9b080f792b2b6 Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Sat, 18 Mar 2017 04:00:15 +0100 Subject: reorganize and add new headers for many files --- src/field_control_avatar.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/field_control_avatar.c') diff --git a/src/field_control_avatar.c b/src/field_control_avatar.c index 992e461eb..a0485444a 100644 --- a/src/field_control_avatar.c +++ b/src/field_control_avatar.c @@ -13,6 +13,8 @@ #include "trainer_see.h" #include "vars.h" #include "wild_encounter.h" +#include "bike.h" +#include "field_control_avatar.h" struct Coords32 { -- cgit v1.2.3 From 225b5f891cb29cf756fcbed20b84cd2b34c1409d Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Wed, 22 Mar 2017 06:40:48 +0100 Subject: fix build --- src/field_control_avatar.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/field_control_avatar.c') diff --git a/src/field_control_avatar.c b/src/field_control_avatar.c index a0485444a..9bff65004 100644 --- a/src/field_control_avatar.c +++ b/src/field_control_avatar.c @@ -338,13 +338,13 @@ static u8 *TryGetInvisibleMapObjectScript(struct MapPosition *position, u8 unuse if (bgEvent == NULL) return NULL; - if (bgEvent->script == NULL) + if (bgEvent->bgUnion.script == NULL) return gUnknown_081C6C02; switch (bgEvent->kind) { case 0: default: - return bgEvent->script; + return bgEvent->bgUnion.script; case 1: if (c != 2) return NULL; @@ -364,21 +364,21 @@ static u8 *TryGetInvisibleMapObjectScript(struct MapPosition *position, u8 unuse case 5: case 6: case 7: - gSpecialVar_0x8004 = ((u32)bgEvent->script >> 16) + 0x258; - gSpecialVar_0x8005 = (u32)bgEvent->script; + gSpecialVar_0x8004 = ((u32)bgEvent->bgUnion.script >> 16) + 0x258; + gSpecialVar_0x8005 = (u32)bgEvent->bgUnion.script; if (FlagGet(gSpecialVar_0x8004) == TRUE) return NULL; return HiddenItemScript; case 8: if (c == 2) { - gSpecialVar_0x8004 = (u32)bgEvent->script; + gSpecialVar_0x8004 = (u32)bgEvent->bgUnion.script; if (sub_80BC050()) return gUnknown_081A2C51; } return NULL; } - return bgEvent->script; + return bgEvent->bgUnion.script; } static u8 *sub_8068500(struct MapPosition *position, u8 b, u8 c) -- cgit v1.2.3