summaryrefslogtreecommitdiff
path: root/src/field_tasks.c
diff options
context:
space:
mode:
authorscnorton <scnorton@biociphers.org>2017-06-27 09:43:57 -0400
committerscnorton <scnorton@biociphers.org>2017-06-27 09:43:57 -0400
commit41cc0382a43161c0c66ddaf73742ecec8dcbdcc6 (patch)
tree8deae383568e4b087951b85ce40a0efac566fff9 /src/field_tasks.c
parent0687a65dc9b67d99d7bb8bdb656ce0c358a57f66 (diff)
Finish decompiling field_tasks.s
Diffstat (limited to 'src/field_tasks.c')
-rwxr-xr-xsrc/field_tasks.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/field_tasks.c b/src/field_tasks.c
index 8ddef126b..caf2ce6b9 100755
--- a/src/field_tasks.c
+++ b/src/field_tasks.c
@@ -794,3 +794,66 @@ void sub_806A18C(s16 *data, s16 x, s16 y)
CurrentMapDrawMetatileAt(x, y);
MapGridSetMetatileIdAt(x, y, 0xe8);
}
+
+void Task_MuddySlope(u8 taskId)
+{
+ s16 x, y, x2, y2;
+ int i;
+ u16 mapIndices;
+ s16 *data = gTasks[taskId].data;
+ PlayerGetDestCoords(&x, &y);
+ mapIndices = (gSaveBlock1.location.mapGroup << 8) | gSaveBlock1.location.mapNum;
+ switch (data[1])
+ {
+ case 0:
+ data[0] = mapIndices;
+ data[2] = x;
+ data[3] = y;
+ data[1] = 1;
+ data[4] = 0;
+ data[7] = 0;
+ data[10] = 0;
+ data[13] = 0;
+ break;
+ case 1:
+ if (data[2] != x || data[3] != y)
+ {
+ data[2] = x;
+ data[3] = y;
+ if (MetatileBehavior_IsMuddySlope(MapGridGetMetatileBehaviorAt(x, y)))
+ {
+ for (i=4; i<14; i+=3)
+ {
+ if (data[i] == 0)
+ {
+ data[i] = 32;
+ data[i + 1] = x;
+ data[i + 2] = y;
+ break;
+ }
+ }
+ }
+ }
+ break;
+ }
+ if (gUnknown_0202E844.field_0 && mapIndices != data[0])
+ {
+ data[0] = mapIndices;
+ x2 = gUnknown_0202E844.x;
+ y2 = gUnknown_0202E844.y;
+ }
+ else
+ {
+ x2 = 0;
+ y2 = 0;
+ }
+ 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]);
+ }
+ }
+}