diff options
Diffstat (limited to 'src/field_tasks.c')
-rw-r--r-- | src/field_tasks.c | 63 |
1 files changed, 35 insertions, 28 deletions
diff --git a/src/field_tasks.c b/src/field_tasks.c index ce5fc6c0e..8b736c949 100644 --- a/src/field_tasks.c +++ b/src/field_tasks.c @@ -171,19 +171,19 @@ void DummyPerStepCallback(u8 taskId) {} const struct MetatileOffset *sub_80695E0(const struct MetatileOffset a0[][2], s8 a1) { - if (sub_80576A0(a1)) + if (MetatileBehavior_IsPacifidlogVerticalLog1(a1)) { return a0[0]; } - else if (sub_80576B4(a1)) + else if (MetatileBehavior_IsPacifidlogVerticalLog2(a1)) { return a0[1]; } - else if (sub_80576C8(a1)) + else if (MetatileBehavior_IsPacifidlogHorizontalLog1(a1)) { return a0[2]; } - else if (sub_80576DC(a1)) + else if (MetatileBehavior_IsPacifidlogHorizontalLog2(a1)) { return a0[3]; } @@ -213,7 +213,7 @@ void sub_8069638(const struct MetatileOffset offsets[][2], s16 x, s16 y, bool32 } } #else -__attribute__((naked)) +NAKED void sub_8069638(const struct MetatileOffset offsets[][2], s16 x, s16 y, bool32 flag) { asm_unified("\tpush {r4-r7,lr}\n" @@ -301,28 +301,28 @@ void sub_8069708(s16 x, s16 y, bool32 flag) bool32 sub_806972C(s16 x1, s16 y1, s16 x2, s16 y2) { s8 metatileBehavior = MapGridGetMetatileBehaviorAt(x2, y2); - if (sub_80576A0(metatileBehavior)) + if (MetatileBehavior_IsPacifidlogVerticalLog1(metatileBehavior)) { if (y1 > y2) { return FALSE; } } - else if (sub_80576B4(metatileBehavior)) + else if (MetatileBehavior_IsPacifidlogVerticalLog2(metatileBehavior)) { if (y1 < y2) { return FALSE; } } - else if (sub_80576C8(metatileBehavior)) + else if (MetatileBehavior_IsPacifidlogHorizontalLog1(metatileBehavior)) { if (x1 > x2) { return FALSE; } } - else if (sub_80576DC(metatileBehavior)) + else if (MetatileBehavior_IsPacifidlogHorizontalLog2(metatileBehavior)) { if (x1 < x2) { @@ -335,28 +335,28 @@ bool32 sub_806972C(s16 x1, s16 y1, s16 x2, s16 y2) bool32 sub_80697C8(s16 x1, s16 y1, s16 x2, s16 y2) { s8 metatileBehavior = MapGridGetMetatileBehaviorAt(x1, y1); - if (sub_80576A0(metatileBehavior)) + if (MetatileBehavior_IsPacifidlogVerticalLog1(metatileBehavior)) { if (y1 < y2) { return FALSE; } } - else if (sub_80576B4(metatileBehavior)) + else if (MetatileBehavior_IsPacifidlogVerticalLog2(metatileBehavior)) { if (y1 > y2) { return FALSE; } } - else if (sub_80576C8(metatileBehavior)) + else if (MetatileBehavior_IsPacifidlogHorizontalLog1(metatileBehavior)) { if (x1 < x2) { return FALSE; } } - else if (sub_80576DC(metatileBehavior)) + else if (MetatileBehavior_IsPacifidlogHorizontalLog2(metatileBehavior)) { if (x1 > x2) { @@ -611,8 +611,8 @@ bool32 sub_8069D34(s16 x, s16 y) void SetSootopolisGymCrackedIceMetatiles(void) { s32 x, y; - s32 width = gMapHeader.mapData->width; - s32 height = gMapHeader.mapData->height; + s32 width = gMapHeader.mapLayout->width; + s32 height = gMapHeader.mapLayout->height; for (x = 0; x < width; x++) { for (y = 0; y < height; y++) @@ -713,11 +713,11 @@ void PerStepCallback_8069F64(u8 taskId) { if (MapGridGetMetatileIdAt(x, y) == 0x20a) { - ash(x, y, 0x212, 4); + StartAshFieldEffect(x, y, 0x212, 4); } else { - ash(x, y, 0x206, 4); + StartAshFieldEffect(x, y, 0x206, 4); } if (CheckBagHasItem(ITEM_SOOT_SACK, 1)) { @@ -782,24 +782,29 @@ void PerStepCallback_806A07C(u8 taskId) } } -const u16 gUnknown_08376418[] = {0xe8, 0xeb, 0xea, 0xe9}; +static const u16 sMuddySlopeAnimationMetatiles[] = {0xe8, 0xeb, 0xea, 0xe9}; -void sub_806A18C(s16 *data, s16 x, s16 y) +static void SetMuddySlopeAnimatedMetatile(s16 *counter, s16 x, s16 y) { u16 tile; - if ((--data[0]) == 0) - { + if (--(*counter) == 0) tile = 0xe8; - } else - { - tile = gUnknown_08376418[data[0] / 8]; - } + tile = sMuddySlopeAnimationMetatiles[*counter / 8]; + MapGridSetMetatileIdAt(x, y, tile); CurrentMapDrawMetatileAt(x, y); + + // Immediately set the metatile back to the original muddy slope metatile + // but don't actualy draw it on the screen. This is so the underlying metatile + // behvior on the map is not changed. MapGridSetMetatileIdAt(x, y, 0xe8); } +// Checks for the player traversing on muddy slope metatiles. +// When the player walks or slides on one, it executes a short animation to +// make it look like a small mudslide. A maximum of 4 mudslide animations can +// exist simultaneously. void Task_MuddySlope(u8 taskId) { s16 x, y, x2, y2; @@ -827,7 +832,7 @@ void Task_MuddySlope(u8 taskId) data[3] = y; if (MetatileBehavior_IsMuddySlope(MapGridGetMetatileBehaviorAt(x, y))) { - for (i=4; i<14; i+=3) + for (i = 4; i < 14; i += 3) { if (data[i] == 0) { @@ -841,6 +846,7 @@ void Task_MuddySlope(u8 taskId) } break; } + if (gCamera.field_0 && mapIndices != data[0]) { data[0] = mapIndices; @@ -852,13 +858,14 @@ void Task_MuddySlope(u8 taskId) x2 = 0; y2 = 0; } - for (i=4; i<14; i+=3) + + for (i = 4; i < 14; i += 3) { if (data[i]) { data[i + 1] -= x2; data[i + 2] -= y2; - sub_806A18C(&data[i], data[i + 1], data[i + 2]); + SetMuddySlopeAnimatedMetatile(&data[i], data[i + 1], data[i + 2]); } } } |