summaryrefslogtreecommitdiff
path: root/src/field
diff options
context:
space:
mode:
Diffstat (limited to 'src/field')
-rw-r--r--src/field/berry.c529
-rw-r--r--src/field/bike.c598
-rw-r--r--src/field/daycare.c7
-rw-r--r--src/field/field_camera.c7
-rw-r--r--src/field/field_control_avatar.c6
-rw-r--r--src/field/field_effect.c28
-rw-r--r--src/field/field_map_obj.c39
-rw-r--r--src/field/field_player_avatar.c202
-rw-r--r--src/field/field_special_scene.c83
-rw-r--r--src/field/field_specials.c24
-rw-r--r--src/field/item_use.c2
-rw-r--r--src/field/map_obj_lock.c2
-rw-r--r--src/field/party_menu.c2
-rw-r--r--src/field/script_movement.c20
-rw-r--r--src/field/secret_base.c355
15 files changed, 899 insertions, 1005 deletions
diff --git a/src/field/berry.c b/src/field/berry.c
index d82eab2a6..cd1fc5c94 100644
--- a/src/field/berry.c
+++ b/src/field/berry.c
@@ -12,10 +12,16 @@
#include "text.h"
#define BERRY_NAME_LENGTH 6
+#define BERRY_REGROW_LIMIT 10
+#define MAX_BERRY_TREES 128
+#define BERRY_NONE 0
#define FIRST_BERRY ITEM_CHERI_BERRY
#define LAST_BERRY ITEM_ENIGMA_BERRY
+#define GETBERRYID(berry) ((berry - FIRST_BERRY) + 1)
+#define GETITEMID(berry) ((berry + FIRST_BERRY) - 1)
+
#ifdef ENGLISH
#define NAME_CHERI_BERRY _("CHERI")
#define NAME_CHESTO_BERRY _("CHESTO")
@@ -61,92 +67,92 @@
#define NAME_STARF_BERRY _("STARF")
#define NAME_ENIGMA_BERRY _("ENIGMA")
-const u8 gBerryDescriptionPart1_Cheri[] = _("Blooms with delicate pretty flowers.");
-const u8 gBerryDescriptionPart2_Cheri[] = _("The bright red BERRY is very spicy.");
-const u8 gBerryDescriptionPart1_Chesto[] = _("The BERRY’s thick skin and fruit are");
-const u8 gBerryDescriptionPart2_Chesto[] = _("very tough. It is dry-tasting all over.");
-const u8 gBerryDescriptionPart1_Pecha[] = _("Very sweet and delicious.");
-const u8 gBerryDescriptionPart2_Pecha[] = _("Also very tender - handle with care.");
-const u8 gBerryDescriptionPart1_Rawst[] = _("If the leaves grow long and curly,");
-const u8 gBerryDescriptionPart2_Rawst[] = _("the BERRY seems to grow very bitter.");
-const u8 gBerryDescriptionPart1_Aspear[] = _("The hard BERRY is dense with a rich");
-const u8 gBerryDescriptionPart2_Aspear[] = _("juice. It is quite sour.");
-const u8 gBerryDescriptionPart1_Leppa[] = _("Grows slower than CHERI and others.");
-const u8 gBerryDescriptionPart2_Leppa[] = _("The smaller the BERRY, the tastier.");
-const u8 gBerryDescriptionPart1_Oran[] = _("A peculiar BERRY with a mix of flavors.");
-const u8 gBerryDescriptionPart2_Oran[] = _("BERRIES grow in half a day.");
-const u8 gBerryDescriptionPart1_Persim[] = _("Loves sunlight. The BERRY’s color");
-const u8 gBerryDescriptionPart2_Persim[] = _("grows vivid when exposed to the sun.");
-const u8 gBerryDescriptionPart1_Lum[] = _("Slow to grow. If raised with loving");
-const u8 gBerryDescriptionPart2_Lum[] = _("care, it may grow two BERRIES.");
-const u8 gBerryDescriptionPart1_Sitrus[] = _("Closely related to ORAN. The large");
-const u8 gBerryDescriptionPart2_Sitrus[] = _("BERRY has a well-rounded flavor.");
-const u8 gBerryDescriptionPart1_Figy[] = _("The BERRY, which looks chewed up,");
-const u8 gBerryDescriptionPart2_Figy[] = _("brims with spicy substances.");
-const u8 gBerryDescriptionPart1_Wiki[] = _("The BERRY is said to have grown lumpy");
-const u8 gBerryDescriptionPart2_Wiki[] = _("to help POKéMON grip it.");
-const u8 gBerryDescriptionPart1_Mago[] = _("The BERRY turns curvy as it grows.");
-const u8 gBerryDescriptionPart2_Mago[] = _("The curvier, the sweeter and tastier.");
-const u8 gBerryDescriptionPart1_Aguav[] = _("The flower is dainty. It is rare in its");
-const u8 gBerryDescriptionPart2_Aguav[] = _("ability to grow without light.");
-const u8 gBerryDescriptionPart1_Iapapa[] = _("The BERRY is very big and sour.");
-const u8 gBerryDescriptionPart2_Iapapa[] = _("It takes at least a day to grow.");
-const u8 gBerryDescriptionPart1_Razz[] = _("The red BERRY tastes slightly spicy.");
-const u8 gBerryDescriptionPart2_Razz[] = _("It grows quickly in just four hours.");
-const u8 gBerryDescriptionPart1_Bluk[] = _("The BERRY is blue on the outside, but");
-const u8 gBerryDescriptionPart2_Bluk[] = _("it blackens the mouth when eaten.");
-const u8 gBerryDescriptionPart1_Nanab[] = _("This BERRY was the seventh");
-const u8 gBerryDescriptionPart2_Nanab[] = _("discovered in the world. It is sweet.");
-const u8 gBerryDescriptionPart1_Wepear[] = _("The flower is small and white. It has a");
-const u8 gBerryDescriptionPart2_Wepear[] = _("delicate balance of bitter and sour.");
-const u8 gBerryDescriptionPart1_Pinap[] = _("Weak against wind and cold.");
-const u8 gBerryDescriptionPart2_Pinap[] = _("The fruit is spicy and the skin, sour.");
-const u8 gBerryDescriptionPart1_Pomeg[] = _("However much it is watered,");
-const u8 gBerryDescriptionPart2_Pomeg[] = _("it only grows up to six BERRIES.");
-const u8 gBerryDescriptionPart1_Kelpsy[] = _("A rare variety shaped like a root.");
-const u8 gBerryDescriptionPart2_Kelpsy[] = _("Grows a very large flower.");
-const u8 gBerryDescriptionPart1_Qualot[] = _("Loves water. Grows strong even in");
-const u8 gBerryDescriptionPart2_Qualot[] = _("locations with constant rainfall.");
-const u8 gBerryDescriptionPart1_Hondew[] = _("A BERRY that is very valuable and");
-const u8 gBerryDescriptionPart2_Hondew[] = _("rarely seen. It is very delicious.");
-const u8 gBerryDescriptionPart1_Grepa[] = _("Despite its tenderness and round");
-const u8 gBerryDescriptionPart2_Grepa[] = _("shape, the BERRY is unimaginably sour.");
-const u8 gBerryDescriptionPart1_Tamato[] = _("The BERRY is lip-bendingly spicy.");
-const u8 gBerryDescriptionPart2_Tamato[] = _("It takes time to grow.");
-const u8 gBerryDescriptionPart1_Cornn[] = _("A BERRY from an ancient era. May not");
-const u8 gBerryDescriptionPart2_Cornn[] = _("grow unless planted in quantity.");
-const u8 gBerryDescriptionPart1_Magost[] = _("A BERRY that is widely said to have");
-const u8 gBerryDescriptionPart2_Magost[] = _("a finely balanced flavor.");
-const u8 gBerryDescriptionPart1_Rabuta[] = _("A rare variety that is overgrown with");
-const u8 gBerryDescriptionPart2_Rabuta[] = _("hair. It is quite bitter.");
-const u8 gBerryDescriptionPart1_Nomel[] = _("Quite sour. Just one bite makes it");
-const u8 gBerryDescriptionPart2_Nomel[] = _("impossible to taste for three days.");
-const u8 gBerryDescriptionPart1_Spelon[] = _("The vividly red BERRY is very spicy.");
-const u8 gBerryDescriptionPart2_Spelon[] = _("Its warts secrete a spicy substance.");
-const u8 gBerryDescriptionPart1_Pamtre[] = _("Drifts on the sea from somewhere.");
-const u8 gBerryDescriptionPart2_Pamtre[] = _("It is thought to grow elsewhere.");
-const u8 gBerryDescriptionPart1_Watmel[] = _("A huge BERRY, with some over 20");
-const u8 gBerryDescriptionPart2_Watmel[] = _("inches discovered. Exceedingly sweet.");
-const u8 gBerryDescriptionPart1_Durin[] = _("Bitter to even look at. It is so");
-const u8 gBerryDescriptionPart2_Durin[] = _("bitter, no one has ever eaten it as is.");
-const u8 gBerryDescriptionPart1_Belue[] = _("It is glossy and looks delicious, but");
-const u8 gBerryDescriptionPart2_Belue[] = _("it is awfully sour. Takes time to grow.");
-const u8 gBerryDescriptionPart1_Liechi[] = _("A mysterious BERRY. It is rumored to");
-const u8 gBerryDescriptionPart2_Liechi[] = _("contain the power of the sea.");
-const u8 gBerryDescriptionPart1_Ganlon[] = _("A mysterious BERRY. It is rumored to");
-const u8 gBerryDescriptionPart2_Ganlon[] = _("contain the power of the land.");
-const u8 gBerryDescriptionPart1_Salac[] = _("A mysterious BERRY. It is rumored to");
-const u8 gBerryDescriptionPart2_Salac[] = _("contain the power of the sky.");
-const u8 gBerryDescriptionPart1_Petaya[] = _("A mysterious BERRY. It is rumored to");
-const u8 gBerryDescriptionPart2_Petaya[] = _("contain the power of all living things.");
-const u8 gBerryDescriptionPart1_Apicot[] = _("A very mystifying BERRY. No telling");
-const u8 gBerryDescriptionPart2_Apicot[] = _("what may happen or how it can be used.");
-const u8 gBerryDescriptionPart1_Lansat[] = _("Said to be a legendary BERRY.");
-const u8 gBerryDescriptionPart2_Lansat[] = _("Holding it supposedly brings joy.");
-const u8 gBerryDescriptionPart1_Starf[] = _("So strong, it was abandoned at the");
-const u8 gBerryDescriptionPart2_Starf[] = _("world’s edge. Considered a mirage.");
-const u8 gBerryDescriptionPart1_Enigma[] = _("A completely enigmatic BERRY.");
-const u8 gBerryDescriptionPart2_Enigma[] = _("Appears to have the power of stars.");
+static const u8 gBerryDescriptionPart1_Cheri[] = _("Blooms with delicate pretty flowers.");
+static const u8 gBerryDescriptionPart2_Cheri[] = _("The bright red BERRY is very spicy.");
+static const u8 gBerryDescriptionPart1_Chesto[] = _("The BERRY’s thick skin and fruit are");
+static const u8 gBerryDescriptionPart2_Chesto[] = _("very tough. It is dry-tasting all over.");
+static const u8 gBerryDescriptionPart1_Pecha[] = _("Very sweet and delicious.");
+static const u8 gBerryDescriptionPart2_Pecha[] = _("Also very tender - handle with care.");
+static const u8 gBerryDescriptionPart1_Rawst[] = _("If the leaves grow long and curly,");
+static const u8 gBerryDescriptionPart2_Rawst[] = _("the BERRY seems to grow very bitter.");
+static const u8 gBerryDescriptionPart1_Aspear[] = _("The hard BERRY is dense with a rich");
+static const u8 gBerryDescriptionPart2_Aspear[] = _("juice. It is quite sour.");
+static const u8 gBerryDescriptionPart1_Leppa[] = _("Grows slower than CHERI and others.");
+static const u8 gBerryDescriptionPart2_Leppa[] = _("The smaller the BERRY, the tastier.");
+static const u8 gBerryDescriptionPart1_Oran[] = _("A peculiar BERRY with a mix of flavors.");
+static const u8 gBerryDescriptionPart2_Oran[] = _("BERRIES grow in half a day.");
+static const u8 gBerryDescriptionPart1_Persim[] = _("Loves sunlight. The BERRY’s color");
+static const u8 gBerryDescriptionPart2_Persim[] = _("grows vivid when exposed to the sun.");
+static const u8 gBerryDescriptionPart1_Lum[] = _("Slow to grow. If raised with loving");
+static const u8 gBerryDescriptionPart2_Lum[] = _("care, it may grow two BERRIES.");
+static const u8 gBerryDescriptionPart1_Sitrus[] = _("Closely related to ORAN. The large");
+static const u8 gBerryDescriptionPart2_Sitrus[] = _("BERRY has a well-rounded flavor.");
+static const u8 gBerryDescriptionPart1_Figy[] = _("The BERRY, which looks chewed up,");
+static const u8 gBerryDescriptionPart2_Figy[] = _("brims with spicy substances.");
+static const u8 gBerryDescriptionPart1_Wiki[] = _("The BERRY is said to have grown lumpy");
+static const u8 gBerryDescriptionPart2_Wiki[] = _("to help POKéMON grip it.");
+static const u8 gBerryDescriptionPart1_Mago[] = _("The BERRY turns curvy as it grows.");
+static const u8 gBerryDescriptionPart2_Mago[] = _("The curvier, the sweeter and tastier.");
+static const u8 gBerryDescriptionPart1_Aguav[] = _("The flower is dainty. It is rare in its");
+static const u8 gBerryDescriptionPart2_Aguav[] = _("ability to grow without light.");
+static const u8 gBerryDescriptionPart1_Iapapa[] = _("The BERRY is very big and sour.");
+static const u8 gBerryDescriptionPart2_Iapapa[] = _("It takes at least a day to grow.");
+static const u8 gBerryDescriptionPart1_Razz[] = _("The red BERRY tastes slightly spicy.");
+static const u8 gBerryDescriptionPart2_Razz[] = _("It grows quickly in just four hours.");
+static const u8 gBerryDescriptionPart1_Bluk[] = _("The BERRY is blue on the outside, but");
+static const u8 gBerryDescriptionPart2_Bluk[] = _("it blackens the mouth when eaten.");
+static const u8 gBerryDescriptionPart1_Nanab[] = _("This BERRY was the seventh");
+static const u8 gBerryDescriptionPart2_Nanab[] = _("discovered in the world. It is sweet.");
+static const u8 gBerryDescriptionPart1_Wepear[] = _("The flower is small and white. It has a");
+static const u8 gBerryDescriptionPart2_Wepear[] = _("delicate balance of bitter and sour.");
+static const u8 gBerryDescriptionPart1_Pinap[] = _("Weak against wind and cold.");
+static const u8 gBerryDescriptionPart2_Pinap[] = _("The fruit is spicy and the skin, sour.");
+static const u8 gBerryDescriptionPart1_Pomeg[] = _("However much it is watered,");
+static const u8 gBerryDescriptionPart2_Pomeg[] = _("it only grows up to six BERRIES.");
+static const u8 gBerryDescriptionPart1_Kelpsy[] = _("A rare variety shaped like a root.");
+static const u8 gBerryDescriptionPart2_Kelpsy[] = _("Grows a very large flower.");
+static const u8 gBerryDescriptionPart1_Qualot[] = _("Loves water. Grows strong even in");
+static const u8 gBerryDescriptionPart2_Qualot[] = _("locations with constant rainfall.");
+static const u8 gBerryDescriptionPart1_Hondew[] = _("A BERRY that is very valuable and");
+static const u8 gBerryDescriptionPart2_Hondew[] = _("rarely seen. It is very delicious.");
+static const u8 gBerryDescriptionPart1_Grepa[] = _("Despite its tenderness and round");
+static const u8 gBerryDescriptionPart2_Grepa[] = _("shape, the BERRY is unimaginably sour.");
+static const u8 gBerryDescriptionPart1_Tamato[] = _("The BERRY is lip-bendingly spicy.");
+static const u8 gBerryDescriptionPart2_Tamato[] = _("It takes time to grow.");
+static const u8 gBerryDescriptionPart1_Cornn[] = _("A BERRY from an ancient era. May not");
+static const u8 gBerryDescriptionPart2_Cornn[] = _("grow unless planted in quantity.");
+static const u8 gBerryDescriptionPart1_Magost[] = _("A BERRY that is widely said to have");
+static const u8 gBerryDescriptionPart2_Magost[] = _("a finely balanced flavor.");
+static const u8 gBerryDescriptionPart1_Rabuta[] = _("A rare variety that is overgrown with");
+static const u8 gBerryDescriptionPart2_Rabuta[] = _("hair. It is quite bitter.");
+static const u8 gBerryDescriptionPart1_Nomel[] = _("Quite sour. Just one bite makes it");
+static const u8 gBerryDescriptionPart2_Nomel[] = _("impossible to taste for three days.");
+static const u8 gBerryDescriptionPart1_Spelon[] = _("The vividly red BERRY is very spicy.");
+static const u8 gBerryDescriptionPart2_Spelon[] = _("Its warts secrete a spicy substance.");
+static const u8 gBerryDescriptionPart1_Pamtre[] = _("Drifts on the sea from somewhere.");
+static const u8 gBerryDescriptionPart2_Pamtre[] = _("It is thought to grow elsewhere.");
+static const u8 gBerryDescriptionPart1_Watmel[] = _("A huge BERRY, with some over 20");
+static const u8 gBerryDescriptionPart2_Watmel[] = _("inches discovered. Exceedingly sweet.");
+static const u8 gBerryDescriptionPart1_Durin[] = _("Bitter to even look at. It is so");
+static const u8 gBerryDescriptionPart2_Durin[] = _("bitter, no one has ever eaten it as is.");
+static const u8 gBerryDescriptionPart1_Belue[] = _("It is glossy and looks delicious, but");
+static const u8 gBerryDescriptionPart2_Belue[] = _("it is awfully sour. Takes time to grow.");
+static const u8 gBerryDescriptionPart1_Liechi[] = _("A mysterious BERRY. It is rumored to");
+static const u8 gBerryDescriptionPart2_Liechi[] = _("contain the power of the sea.");
+static const u8 gBerryDescriptionPart1_Ganlon[] = _("A mysterious BERRY. It is rumored to");
+static const u8 gBerryDescriptionPart2_Ganlon[] = _("contain the power of the land.");
+static const u8 gBerryDescriptionPart1_Salac[] = _("A mysterious BERRY. It is rumored to");
+static const u8 gBerryDescriptionPart2_Salac[] = _("contain the power of the sky.");
+static const u8 gBerryDescriptionPart1_Petaya[] = _("A mysterious BERRY. It is rumored to");
+static const u8 gBerryDescriptionPart2_Petaya[] = _("contain the power of all living things.");
+static const u8 gBerryDescriptionPart1_Apicot[] = _("A very mystifying BERRY. No telling");
+static const u8 gBerryDescriptionPart2_Apicot[] = _("what may happen or how it can be used.");
+static const u8 gBerryDescriptionPart1_Lansat[] = _("Said to be a legendary BERRY.");
+static const u8 gBerryDescriptionPart2_Lansat[] = _("Holding it supposedly brings joy.");
+static const u8 gBerryDescriptionPart1_Starf[] = _("So strong, it was abandoned at the");
+static const u8 gBerryDescriptionPart2_Starf[] = _("world’s edge. Considered a mirage.");
+static const u8 gBerryDescriptionPart1_Enigma[] = _("A completely enigmatic BERRY.");
+static const u8 gBerryDescriptionPart2_Enigma[] = _("Appears to have the power of stars.");
#elif defined(GERMAN)
#define NAME_CHERI_BERRY _("AMRENA")
#define NAME_CHESTO_BERRY _("MARON")
@@ -192,92 +198,92 @@ const u8 gBerryDescriptionPart2_Enigma[] = _("Appears to have the power of stars
#define NAME_STARF_BERRY _("KRAMBO")
#define NAME_ENIGMA_BERRY _("ENIGMA")
-const u8 gBerryDescriptionPart1_Cheri[] = _("Erblüht mit hübschen, zarten Blumen.");
-const u8 gBerryDescriptionPart2_Cheri[] = _("Diese knallrote BEERE ist sehr scharf.");
-const u8 gBerryDescriptionPart1_Chesto[] = _("Diese BEERE hat eine dicke Haut und");
-const u8 gBerryDescriptionPart2_Chesto[] = _("hartes Fruchtfleisch. Trocken!");
-const u8 gBerryDescriptionPart1_Pecha[] = _("Sehr süß und delikat.");
-const u8 gBerryDescriptionPart2_Pecha[] = _("Sehr zart. Vorsichtig anfassen!");
-const u8 gBerryDescriptionPart1_Rawst[] = _("Wenn die Blätter lang und wellig sind,");
-const u8 gBerryDescriptionPart2_Rawst[] = _("wird die BEERE sehr bitter.");
-const u8 gBerryDescriptionPart1_Aspear[] = _("Diese harte BEERE ist sehr");
-const u8 gBerryDescriptionPart2_Aspear[] = _("saftig und sauer im Geschmack!");
-const u8 gBerryDescriptionPart1_Leppa[] = _("Wächst langsamer als AMRENA und");
-const u8 gBerryDescriptionPart2_Leppa[] = _("andere. Je kleiner, desto delikater.");
-const u8 gBerryDescriptionPart1_Oran[] = _("Eine BEERE unterschiedlichsten Ge-");
-const u8 gBerryDescriptionPart2_Oran[] = _("schmacks. Wächst an einem halben Tag.");
-const u8 gBerryDescriptionPart1_Persim[] = _("Liebt Sonnenlicht. Die BEERE");
-const u8 gBerryDescriptionPart2_Persim[] = _("wächst im Sonnenlicht sehr schnell.");
-const u8 gBerryDescriptionPart1_Lum[] = _("Langsamer Wuchs. Wird sie liebevoll ge-");
-const u8 gBerryDescriptionPart2_Lum[] = _("pflegt, kann sie 2 BEEREN tragen.");
-const u8 gBerryDescriptionPart1_Sitrus[] = _("Eng verwandt mit SINEL. Diese große");
-const u8 gBerryDescriptionPart2_Sitrus[] = _("BEERE ist von rundem Geschmack.");
-const u8 gBerryDescriptionPart1_Figy[] = _("Die BEERE sieht angekaut aus. Sie ist");
-const u8 gBerryDescriptionPart2_Figy[] = _("voller scharfer Substanzen.");
-const u8 gBerryDescriptionPart1_Wiki[] = _("Die BEERE wächst unförmig,");
-const u8 gBerryDescriptionPart2_Wiki[] = _("damit PKMN sie besser greifen können.");
-const u8 gBerryDescriptionPart1_Mago[] = _("Die BEERE hat Ausbeulungen. Je mehr");
-const u8 gBerryDescriptionPart2_Mago[] = _("Beulen, desto schmackhafter ist sie.");
-const u8 gBerryDescriptionPart1_Aguav[] = _("Die Blume ist zart. Sie ist fähig,");
-const u8 gBerryDescriptionPart2_Aguav[] = _("ohne Licht wachsen zu können.");
-const u8 gBerryDescriptionPart1_Iapapa[] = _("Die BEERE ist groß und sauer.");
-const u8 gBerryDescriptionPart2_Iapapa[] = _("Sie braucht einen Tag zum Wachsen.");
-const u8 gBerryDescriptionPart1_Razz[] = _("Diese rote BEERE schmeckt etwas");
-const u8 gBerryDescriptionPart2_Razz[] = _("scharf. Sie wächst in nur 4 Stunden.");
-const u8 gBerryDescriptionPart1_Bluk[] = _("Die BEERE ist außen blau, verfärbt");
-const u8 gBerryDescriptionPart2_Bluk[] = _("sich im Mund aber schwarz.");
-const u8 gBerryDescriptionPart1_Nanab[] = _("Diese BEERE war die 7., die auf der");
-const u8 gBerryDescriptionPart2_Nanab[] = _("Welt entdeckt wurde. Sie ist süß.");
-const u8 gBerryDescriptionPart1_Wepear[] = _("Die Blume ist klein und weiß. Angenehm");
-const u8 gBerryDescriptionPart2_Wepear[] = _("bitter und sauer zugleich.");
-const u8 gBerryDescriptionPart1_Pinap[] = _("Wind und Kälte verträgt sie nicht.");
-const u8 gBerryDescriptionPart2_Pinap[] = _("Fruchtfleisch: Scharf. Haut: Sauer.");
-const u8 gBerryDescriptionPart1_Pomeg[] = _("Egal wie viel Wasser sie bekommt, sie");
-const u8 gBerryDescriptionPart2_Pomeg[] = _("trägt immer bis zu 6 BEEREN.");
-const u8 gBerryDescriptionPart1_Kelpsy[] = _("Eine Seltenheit. Geformt wie eine");
-const u8 gBerryDescriptionPart2_Kelpsy[] = _("Wurzel. Hat eine große Blume.");
-const u8 gBerryDescriptionPart1_Qualot[] = _("Liebt das Wasser. Wächst besonders");
-const u8 gBerryDescriptionPart2_Qualot[] = _("gut in regenreichen Gegenden.");
-const u8 gBerryDescriptionPart1_Hondew[] = _("Eine wertvolle und seltene BEERE.");
-const u8 gBerryDescriptionPart2_Hondew[] = _("Sie ist sehr schmackhaft.");
-const u8 gBerryDescriptionPart1_Grepa[] = _("Die BEERE ist zart und von runder");
-const u8 gBerryDescriptionPart2_Grepa[] = _("Form. Aber sie ist unglaublich sauer!");
-const u8 gBerryDescriptionPart1_Tamato[] = _("Die Schärfe der BEERE verbrennt die");
-const u8 gBerryDescriptionPart2_Tamato[] = _("Lippen. Sie braucht Zeit zum Wachsen.");
-const u8 gBerryDescriptionPart1_Cornn[] = _("Eine BEERE aus alten Zeiten. Wächst");
-const u8 gBerryDescriptionPart2_Cornn[] = _("nur, wenn in großen Mengen gepflanzt.");
-const u8 gBerryDescriptionPart1_Magost[] = _("Eine BEERE, die für ihren feinen, aus-");
-const u8 gBerryDescriptionPart2_Magost[] = _("gewogenen Geschmack bekannt ist.");
-const u8 gBerryDescriptionPart1_Rabuta[] = _("Eine Seltenheit, die über und über mit");
-const u8 gBerryDescriptionPart2_Rabuta[] = _("Haaren bewachsen ist. Sehr bitter!");
-const u8 gBerryDescriptionPart1_Nomel[] = _("Sehr sauer. Ein Biss betäubt die");
-const u8 gBerryDescriptionPart2_Nomel[] = _("Geschmacksnerven für 3 Tage!");
-const u8 gBerryDescriptionPart1_Spelon[] = _("Die leuchtend rote BEERE ist sehr");
-const u8 gBerryDescriptionPart2_Spelon[] = _("scharf. Gibt scharfe Substanzen ab!");
-const u8 gBerryDescriptionPart1_Pamtre[] = _("Wird vom Meer angespült. Sie wächst");
-const u8 gBerryDescriptionPart2_Pamtre[] = _("an einem anderen Ort.");
-const u8 gBerryDescriptionPart1_Watmel[] = _("Eine große BEERE, 25 cm groß.");
-const u8 gBerryDescriptionPart2_Watmel[] = _("Außergewöhnlich süß.");
-const u8 gBerryDescriptionPart1_Durin[] = _("Bitter schon ihr Anblick! Sie ist so");
-const u8 gBerryDescriptionPart2_Durin[] = _("bitter, dass niemand sie pur isst.");
-const u8 gBerryDescriptionPart1_Belue[] = _("Sie glänzt, sieht zart aus, ist extrem");
-const u8 gBerryDescriptionPart2_Belue[] = _("sauer und braucht Zeit zum Wachsen.");
-const u8 gBerryDescriptionPart1_Liechi[] = _("Eine geheimnisvolle BEERE. Man sagt,");
-const u8 gBerryDescriptionPart2_Liechi[] = _("sie enthalte die Kraft des Meeres.");
-const u8 gBerryDescriptionPart1_Ganlon[] = _("Eine geheimnisvolle BEERE. Man sagt,");
-const u8 gBerryDescriptionPart2_Ganlon[] = _("sie enthalte die Kraft des Landes.");
-const u8 gBerryDescriptionPart1_Salac[] = _("Eine geheimnisvolle BEERE. Man sagt,");
-const u8 gBerryDescriptionPart2_Salac[] = _("sie enthalte die Kraft des Himmels.");
-const u8 gBerryDescriptionPart1_Petaya[] = _("Eine geheimnisvolle BEERE. Man sagt,");
-const u8 gBerryDescriptionPart2_Petaya[] = _("sie enthalte die Kraft allen Lebens.");
-const u8 gBerryDescriptionPart1_Apicot[] = _("Eine rätselhafte BEERE. Man kann");
-const u8 gBerryDescriptionPart2_Apicot[] = _("nicht sagen, wie und was sie ist.");
-const u8 gBerryDescriptionPart1_Lansat[] = _("Eine legendäre BEERE. Sie zu");
-const u8 gBerryDescriptionPart2_Lansat[] = _("tragen bringt Freude.");
-const u8 gBerryDescriptionPart1_Starf[] = _("So stark, dass sie an den Rand der");
-const u8 gBerryDescriptionPart2_Starf[] = _("Welt verbannt wurde. Ein Märchen?");
-const u8 gBerryDescriptionPart1_Enigma[] = _("Eine enigmatische BEERE. Sie scheint");
-const u8 gBerryDescriptionPart2_Enigma[] = _("die Macht der Sterne zu besitzen.");
+static const u8 gBerryDescriptionPart1_Cheri[] = _("Erblüht mit hübschen, zarten Blumen.");
+static const u8 gBerryDescriptionPart2_Cheri[] = _("Diese knallrote BEERE ist sehr scharf.");
+static const u8 gBerryDescriptionPart1_Chesto[] = _("Diese BEERE hat eine dicke Haut und");
+static const u8 gBerryDescriptionPart2_Chesto[] = _("hartes Fruchtfleisch. Trocken!");
+static const u8 gBerryDescriptionPart1_Pecha[] = _("Sehr süß und delikat.");
+static const u8 gBerryDescriptionPart2_Pecha[] = _("Sehr zart. Vorsichtig anfassen!");
+static const u8 gBerryDescriptionPart1_Rawst[] = _("Wenn die Blätter lang und wellig sind,");
+static const u8 gBerryDescriptionPart2_Rawst[] = _("wird die BEERE sehr bitter.");
+static const u8 gBerryDescriptionPart1_Aspear[] = _("Diese harte BEERE ist sehr");
+static const u8 gBerryDescriptionPart2_Aspear[] = _("saftig und sauer im Geschmack!");
+static const u8 gBerryDescriptionPart1_Leppa[] = _("Wächst langsamer als AMRENA und");
+static const u8 gBerryDescriptionPart2_Leppa[] = _("andere. Je kleiner, desto delikater.");
+static const u8 gBerryDescriptionPart1_Oran[] = _("Eine BEERE unterschiedlichsten Ge-");
+static const u8 gBerryDescriptionPart2_Oran[] = _("schmacks. Wächst an einem halben Tag.");
+static const u8 gBerryDescriptionPart1_Persim[] = _("Liebt Sonnenlicht. Die BEERE");
+static const u8 gBerryDescriptionPart2_Persim[] = _("wächst im Sonnenlicht sehr schnell.");
+static const u8 gBerryDescriptionPart1_Lum[] = _("Langsamer Wuchs. Wird sie liebevoll ge-");
+static const u8 gBerryDescriptionPart2_Lum[] = _("pflegt, kann sie 2 BEEREN tragen.");
+static const u8 gBerryDescriptionPart1_Sitrus[] = _("Eng verwandt mit SINEL. Diese große");
+static const u8 gBerryDescriptionPart2_Sitrus[] = _("BEERE ist von rundem Geschmack.");
+static const u8 gBerryDescriptionPart1_Figy[] = _("Die BEERE sieht angekaut aus. Sie ist");
+static const u8 gBerryDescriptionPart2_Figy[] = _("voller scharfer Substanzen.");
+static const u8 gBerryDescriptionPart1_Wiki[] = _("Die BEERE wächst unförmig,");
+static const u8 gBerryDescriptionPart2_Wiki[] = _("damit PKMN sie besser greifen können.");
+static const u8 gBerryDescriptionPart1_Mago[] = _("Die BEERE hat Ausbeulungen. Je mehr");
+static const u8 gBerryDescriptionPart2_Mago[] = _("Beulen, desto schmackhafter ist sie.");
+static const u8 gBerryDescriptionPart1_Aguav[] = _("Die Blume ist zart. Sie ist fähig,");
+static const u8 gBerryDescriptionPart2_Aguav[] = _("ohne Licht wachsen zu können.");
+static const u8 gBerryDescriptionPart1_Iapapa[] = _("Die BEERE ist groß und sauer.");
+static const u8 gBerryDescriptionPart2_Iapapa[] = _("Sie braucht einen Tag zum Wachsen.");
+static const u8 gBerryDescriptionPart1_Razz[] = _("Diese rote BEERE schmeckt etwas");
+static const u8 gBerryDescriptionPart2_Razz[] = _("scharf. Sie wächst in nur 4 Stunden.");
+static const u8 gBerryDescriptionPart1_Bluk[] = _("Die BEERE ist außen blau, verfärbt");
+static const u8 gBerryDescriptionPart2_Bluk[] = _("sich im Mund aber schwarz.");
+static const u8 gBerryDescriptionPart1_Nanab[] = _("Diese BEERE war die 7., die auf der");
+static const u8 gBerryDescriptionPart2_Nanab[] = _("Welt entdeckt wurde. Sie ist süß.");
+static const u8 gBerryDescriptionPart1_Wepear[] = _("Die Blume ist klein und weiß. Angenehm");
+static const u8 gBerryDescriptionPart2_Wepear[] = _("bitter und sauer zugleich.");
+static const u8 gBerryDescriptionPart1_Pinap[] = _("Wind und Kälte verträgt sie nicht.");
+static const u8 gBerryDescriptionPart2_Pinap[] = _("Fruchtfleisch: Scharf. Haut: Sauer.");
+static const u8 gBerryDescriptionPart1_Pomeg[] = _("Egal wie viel Wasser sie bekommt, sie");
+static const u8 gBerryDescriptionPart2_Pomeg[] = _("trägt immer bis zu 6 BEEREN.");
+static const u8 gBerryDescriptionPart1_Kelpsy[] = _("Eine Seltenheit. Geformt wie eine");
+static const u8 gBerryDescriptionPart2_Kelpsy[] = _("Wurzel. Hat eine große Blume.");
+static const u8 gBerryDescriptionPart1_Qualot[] = _("Liebt das Wasser. Wächst besonders");
+static const u8 gBerryDescriptionPart2_Qualot[] = _("gut in regenreichen Gegenden.");
+static const u8 gBerryDescriptionPart1_Hondew[] = _("Eine wertvolle und seltene BEERE.");
+static const u8 gBerryDescriptionPart2_Hondew[] = _("Sie ist sehr schmackhaft.");
+static const u8 gBerryDescriptionPart1_Grepa[] = _("Die BEERE ist zart und von runder");
+static const u8 gBerryDescriptionPart2_Grepa[] = _("Form. Aber sie ist unglaublich sauer!");
+static const u8 gBerryDescriptionPart1_Tamato[] = _("Die Schärfe der BEERE verbrennt die");
+static const u8 gBerryDescriptionPart2_Tamato[] = _("Lippen. Sie braucht Zeit zum Wachsen.");
+static const u8 gBerryDescriptionPart1_Cornn[] = _("Eine BEERE aus alten Zeiten. Wächst");
+static const u8 gBerryDescriptionPart2_Cornn[] = _("nur, wenn in großen Mengen gepflanzt.");
+static const u8 gBerryDescriptionPart1_Magost[] = _("Eine BEERE, die für ihren feinen, aus-");
+static const u8 gBerryDescriptionPart2_Magost[] = _("gewogenen Geschmack bekannt ist.");
+static const u8 gBerryDescriptionPart1_Rabuta[] = _("Eine Seltenheit, die über und über mit");
+static const u8 gBerryDescriptionPart2_Rabuta[] = _("Haaren bewachsen ist. Sehr bitter!");
+static const u8 gBerryDescriptionPart1_Nomel[] = _("Sehr sauer. Ein Biss betäubt die");
+static const u8 gBerryDescriptionPart2_Nomel[] = _("Geschmacksnerven für 3 Tage!");
+static const u8 gBerryDescriptionPart1_Spelon[] = _("Die leuchtend rote BEERE ist sehr");
+static const u8 gBerryDescriptionPart2_Spelon[] = _("scharf. Gibt scharfe Substanzen ab!");
+static const u8 gBerryDescriptionPart1_Pamtre[] = _("Wird vom Meer angespült. Sie wächst");
+static const u8 gBerryDescriptionPart2_Pamtre[] = _("an einem anderen Ort.");
+static const u8 gBerryDescriptionPart1_Watmel[] = _("Eine große BEERE, 25 cm groß.");
+static const u8 gBerryDescriptionPart2_Watmel[] = _("Außergewöhnlich süß.");
+static const u8 gBerryDescriptionPart1_Durin[] = _("Bitter schon ihr Anblick! Sie ist so");
+static const u8 gBerryDescriptionPart2_Durin[] = _("bitter, dass niemand sie pur isst.");
+static const u8 gBerryDescriptionPart1_Belue[] = _("Sie glänzt, sieht zart aus, ist extrem");
+static const u8 gBerryDescriptionPart2_Belue[] = _("sauer und braucht Zeit zum Wachsen.");
+static const u8 gBerryDescriptionPart1_Liechi[] = _("Eine geheimnisvolle BEERE. Man sagt,");
+static const u8 gBerryDescriptionPart2_Liechi[] = _("sie enthalte die Kraft des Meeres.");
+static const u8 gBerryDescriptionPart1_Ganlon[] = _("Eine geheimnisvolle BEERE. Man sagt,");
+static const u8 gBerryDescriptionPart2_Ganlon[] = _("sie enthalte die Kraft des Landes.");
+static const u8 gBerryDescriptionPart1_Salac[] = _("Eine geheimnisvolle BEERE. Man sagt,");
+static const u8 gBerryDescriptionPart2_Salac[] = _("sie enthalte die Kraft des Himmels.");
+static const u8 gBerryDescriptionPart1_Petaya[] = _("Eine geheimnisvolle BEERE. Man sagt,");
+static const u8 gBerryDescriptionPart2_Petaya[] = _("sie enthalte die Kraft allen Lebens.");
+static const u8 gBerryDescriptionPart1_Apicot[] = _("Eine rätselhafte BEERE. Man kann");
+static const u8 gBerryDescriptionPart2_Apicot[] = _("nicht sagen, wie und was sie ist.");
+static const u8 gBerryDescriptionPart1_Lansat[] = _("Eine legendäre BEERE. Sie zu");
+static const u8 gBerryDescriptionPart2_Lansat[] = _("tragen bringt Freude.");
+static const u8 gBerryDescriptionPart1_Starf[] = _("So stark, dass sie an den Rand der");
+static const u8 gBerryDescriptionPart2_Starf[] = _("Welt verbannt wurde. Ein Märchen?");
+static const u8 gBerryDescriptionPart1_Enigma[] = _("Eine enigmatische BEERE. Sie scheint");
+static const u8 gBerryDescriptionPart2_Enigma[] = _("die Macht der Sterne zu besitzen.");
#endif
const struct Berry gBerries[] =
@@ -972,7 +978,7 @@ const struct Berry gBerries[] =
},
};
-const struct BerryTree gBlankBerryTree = {0};
+static const struct BerryTree gBlankBerryTree = {0};
extern u8 S_BerryTree[];
extern u16 gScriptLastTalked;
@@ -980,7 +986,21 @@ extern u16 gSpecialVar_0x8004;
extern u16 gSpecialVar_0x8005;
extern u16 gSpecialVar_0x8006;
+/*
+ An enigma berry is a type of berry which functions
+ as though it is a custom berry. Because it behaves
+ like its a custom berry, it doesn't hold an identity
+ represented in its icons or descriptions, leaving its
+ information to be decided by the e-reader cards
+ which were intended to deliver these custom
+ berries.
+*/
+
+static u8 CalcBerryYield(struct BerryTree *tree);
+static u16 GetStageDurationByBerryType(u8 berry);
+
// unused
+// this could be static, but making it so causes a compile-time warning.
void ClearEnigmaBerries(void)
{
CpuFill16(0, &gSaveBlock1.enigmaBerry, sizeof(gSaveBlock1.enigmaBerry));
@@ -988,17 +1008,21 @@ void ClearEnigmaBerries(void)
void SetEnigmaBerry(u8 *src)
{
+ // initialize the enigma berry by copying the data from the script.
u32 i;
u8 *dest = (u8*)&gSaveBlock1.enigmaBerry;
for (i = 0; i < sizeof(gSaveBlock1.enigmaBerry); i++)
dest[i] = src[i];
+ // at this point, the description pointer is not yet initialized. we need to initialize it since
+ // we dont know where in memory this is going to be. set the berry desc pointers to the
+ // EnigmaBerry struct's description arrays since these are where the descriptions are stored.
gSaveBlock1.enigmaBerry.berry.description1 = gSaveBlock1.enigmaBerry.description1;
gSaveBlock1.enigmaBerry.berry.description2 = gSaveBlock1.enigmaBerry.description2;
}
-u32 GetEnigmaBerryChecksum(struct EnigmaBerry *enigmaBerry)
+static u32 GetEnigmaBerryChecksum(struct EnigmaBerry *enigmaBerry)
{
const u8 *description1;
const u8 *description2;
@@ -1006,10 +1030,13 @@ u32 GetEnigmaBerryChecksum(struct EnigmaBerry *enigmaBerry)
u32 checksum;
u8 *dest;
+ // the description pointers could be pointing to anywhere in memory. we do not want these
+ // pointers to factor into the checksum as it will produce a different result every time: so
+ // back the pointers up and set them to null so the checksum is safe to calculate.
description1 = gSaveBlock1.enigmaBerry.berry.description1;
description2 = gSaveBlock1.enigmaBerry.berry.description2;
- gSaveBlock1.enigmaBerry.berry.description1 = 0;
- gSaveBlock1.enigmaBerry.berry.description2 = 0;
+ gSaveBlock1.enigmaBerry.berry.description1 = NULL;
+ gSaveBlock1.enigmaBerry.berry.description2 = NULL;
dest = (u8*)enigmaBerry;
checksum = 0;
@@ -1018,17 +1045,20 @@ u32 GetEnigmaBerryChecksum(struct EnigmaBerry *enigmaBerry)
checksum += dest[i];
}
+ // the checksum is calculated: the descriptions are safe to restore now.
gSaveBlock1.enigmaBerry.berry.description1 = description1;
gSaveBlock1.enigmaBerry.berry.description2 = description2;
return checksum;
}
+// due to e-reader scans being particularly volatile to failure, it is a requirement to check for
+// their integrity here due to scans possibly failing to produce the correct result.
bool32 IsEnigmaBerryValid(void)
{
- if (!gSaveBlock1.enigmaBerry.berry.stageDuration)
+ if (gSaveBlock1.enigmaBerry.berry.stageDuration == 0)
return FALSE;
- if (!gSaveBlock1.enigmaBerry.berry.maxYield)
+ if (gSaveBlock1.enigmaBerry.berry.maxYield == 0)
return FALSE;
if (GetEnigmaBerryChecksum(&gSaveBlock1.enigmaBerry) != gSaveBlock1.enigmaBerry.checksum)
return FALSE;
@@ -1037,37 +1067,51 @@ bool32 IsEnigmaBerryValid(void)
const struct Berry *GetBerryInfo(u8 berry)
{
- if (berry == 0x2B && IsEnigmaBerryValid())
+ // when getting the pointer to the berry info, enigma berries are handled differently. if your
+ // berry is an Enigma Berry and its checksum is valid, fetch the pointer to its information in
+ // the save block.
+ if (berry == GETBERRYID(ITEM_ENIGMA_BERRY) && IsEnigmaBerryValid())
return &gSaveBlock1.enigmaBerry.berry;
else
{
- if (berry == 0 || berry > 0x2B)
- berry = 1;
+ // invalid berries will be flattened into a cheri berry. Interestingly, if your berry was
+ // an enigma berry whos checksum failed, the game will use the Enigma Berry information
+ // for this: meaning if you see the Enigma Berry information, its actually because the
+ // checksum failed.
+ if (berry == BERRY_NONE || berry > GETBERRYID(LAST_BERRY))
+ berry = GETBERRYID(FIRST_BERRY);
return &gBerries[berry - 1];
}
}
-struct BerryTree *GetBerryTreeInfo(u8 id)
+// the save file can handle up to a number of 128 berry trees as indicated by its definition
+// in global.h. Interestingly, this function does not check that limit of 128.
+static struct BerryTree *GetBerryTreeInfo(u8 id)
{
return &gSaveBlock1.berryTrees[id];
}
+// this was called because the berry script was successful: meaning the player chose to
+// water the tree. We need to check for the current tree stage and set the appropriate
+// water flag to true.
bool32 FieldObjectInteractionWaterBerryTree(void)
{
+ // GetBerryTreeInfo does not sanitize the tree retrieved, but there are no known
+ // instances where this can cause problems.
struct BerryTree *tree = GetBerryTreeInfo(FieldObjectGetBerryTreeId(gSelectedMapObject));
switch (tree->stage)
{
- case 1:
+ case BERRY_STAGE_PLANTED:
tree->watered1 = TRUE;
break;
- case 2:
+ case BERRY_STAGE_SPROUTED:
tree->watered2 = TRUE;
break;
- case 3:
+ case BERRY_STAGE_TALLER:
tree->watered3 = TRUE;
break;
- case 4:
+ case BERRY_STAGE_FLOWERING:
tree->watered4 = TRUE;
break;
default:
@@ -1076,10 +1120,10 @@ bool32 FieldObjectInteractionWaterBerryTree(void)
return TRUE;
}
-bool8 IsPlayerFacingPlantedBerryTree(void)
+bool8 IsPlayerFacingUnplantedSoil(void)
{
- if (GetFieldObjectScriptPointerForComparison() == S_BerryTree
- && GetStageByBerryTreeId(FieldObjectGetBerryTreeId(gSelectedMapObject)) == 0)
+ if (GetFieldObjectScriptPointerPlayerFacing() == S_BerryTree
+ && GetStageByBerryTreeId(FieldObjectGetBerryTreeId(gSelectedMapObject)) == BERRY_STAGE_NO_BERRY)
return TRUE;
else
return FALSE;
@@ -1087,7 +1131,7 @@ bool8 IsPlayerFacingPlantedBerryTree(void)
bool8 TryToWaterBerryTree(void)
{
- if (GetFieldObjectScriptPointerForComparison() != S_BerryTree)
+ if (GetFieldObjectScriptPointerPlayerFacing() != S_BerryTree)
return FALSE;
else
return FieldObjectInteractionWaterBerryTree();
@@ -1099,70 +1143,84 @@ void ClearBerryTrees(void)
struct SaveBlock1 *saveBlock1 = &gSaveBlock1;
struct BerryTree berryTree = gBlankBerryTree;
- for (i = 0; i < (u8)ARRAY_COUNT(saveBlock1->berryTrees); i++) // casting to u8 fixes a mismatched signed compare. what
+ for (i = 0; i < MAX_BERRY_TREES; i++)
saveBlock1->berryTrees[i] = berryTree;
}
-bool32 BerryTreeGrow(struct BerryTree *tree)
+// when the player does not interact with the tree for a period of time, this is called
+// to advance the grow state.
+static bool32 BerryTreeGrow(struct BerryTree *tree)
{
if (tree->growthSparkle)
return FALSE;
switch (tree->stage)
{
- case 0:
+ case BERRY_STAGE_NO_BERRY:
return FALSE;
- case 4:
+ case BERRY_STAGE_FLOWERING:
tree->berryYield = CalcBerryYield(tree);
- case 1:
- case 2:
- case 3:
+ case BERRY_STAGE_PLANTED:
+ case BERRY_STAGE_SPROUTED:
+ case BERRY_STAGE_TALLER:
tree->stage++;
break;
- case 5:
+ case BERRY_STAGE_BERRIES:
tree->watered1 = 0;
tree->watered2 = 0;
tree->watered3 = 0;
tree->watered4 = 0;
tree->berryYield = 0;
- tree->stage = 2;
- if (++tree->regrowthCount == 10)
+ tree->stage = BERRY_STAGE_SPROUTED;
+ if (++tree->regrowthCount == BERRY_REGROW_LIMIT)
*tree = gBlankBerryTree;
break;
}
return TRUE;
}
-void BerryTreeTimeUpdate(s32 minutes)
+void BerryTreeTimeUpdate(s32 minutesPassed)
{
int i;
struct BerryTree *tree;
- for (i = 0; i < (u8)ARRAY_COUNT(gSaveBlock1.berryTrees); i++)
+ for (i = 0; i < MAX_BERRY_TREES; i++)
{
tree = &gSaveBlock1.berryTrees[i];
- if (tree->berry && tree->stage && !tree->growthSparkle)
+ if (tree->berry != BERRY_NONE && tree->stage != BERRY_STAGE_NO_BERRY && tree->growthSparkle == FALSE)
{
- if (minutes >= GetStageDurationByBerryType(tree->berry) * 71)
+ // the player has waited too long to water the berry. Reset the tree. This is because
+ // if the berry state is not in the unwatered state, the tree will grow anyway despite this
+ // check, which means BerryTreeGrow will handle the regrow process for this, removing the
+ // need for this check. This only handles the unwatered soil state.
+ if (minutesPassed >= GetStageDurationByBerryType(tree->berry) * 71)
{
*tree = gBlankBerryTree;
}
else
{
- s32 time = minutes;
+ // because time is altered below, perhaps they thought it was unsafe to change it, even
+ // though that is not how passed arguments behave.
+ s32 time = minutesPassed;
while (time != 0)
{
if (tree->minutesUntilNextStage > time)
{
- tree->minutesUntilNextStage -= time;
+ // its been X minutes since the last berry update, so update
+ // minutesUntilNextStage appropriately to match the time offset
+ // that has passed since the update.
+ tree->minutesUntilNextStage -= time;
break;
}
+ // perform the subtraction the other way around to get the number of minutes since
+ // the inferred stage update that occured, since minutesUntilNextStage is <= time.
+ // we may need this variable to simulate multiple berry cycles in the while loop.
time -= tree->minutesUntilNextStage;
- tree->minutesUntilNextStage = GetStageDurationByBerryType(tree->berry);
- if (!BerryTreeGrow(tree))
+ tree->minutesUntilNextStage = GetStageDurationByBerryType(tree->berry); // since the tree was inferred to update, set the new minutesUntilNextStage.
+ if (BerryTreeGrow(tree) == FALSE)
break;
- if (tree->stage == 5)
+ if (tree->stage == BERRY_STAGE_BERRIES)
tree->minutesUntilNextStage *= 4;
}
}
@@ -1170,7 +1228,7 @@ void BerryTreeTimeUpdate(s32 minutes)
}
}
-void PlantBerryTree(u8 id, u8 berry, u8 stage, bool8 sparkle)
+void PlantBerryTree(u8 id, u8 berry, u8 stage, bool8 noSparkle)
{
struct BerryTree *tree = GetBerryTreeInfo(id);
@@ -1178,12 +1236,12 @@ void PlantBerryTree(u8 id, u8 berry, u8 stage, bool8 sparkle)
tree->berry = berry;
tree->minutesUntilNextStage = GetStageDurationByBerryType(berry);
tree->stage = stage;
- if (stage == 5)
+ if (stage == BERRY_STAGE_BERRIES)
{
tree->berryYield = CalcBerryYield(tree);
tree->minutesUntilNextStage *= 4;
}
- if (!sparkle)
+ if (noSparkle == FALSE)
{
tree->growthSparkle = TRUE;
}
@@ -1209,19 +1267,19 @@ u8 ItemIdToBerryType(u16 item)
u16 berry = item - FIRST_BERRY;
if (berry > LAST_BERRY - FIRST_BERRY)
- return 1;
+ return GETBERRYID(FIRST_BERRY);
else
- return item - FIRST_BERRY + 1;
+ return GETBERRYID(item);
}
-u16 BerryTypeToItemId(u16 berry)
+static u16 BerryTypeToItemId(u16 berry)
{
u16 item = berry - 1;
if (item > LAST_BERRY - FIRST_BERRY)
return FIRST_BERRY;
else
- return berry + FIRST_BERRY - 1;
+ return GETITEMID(berry);
}
void GetBerryNameByBerryType(u8 berry, u8 *string)
@@ -1232,10 +1290,10 @@ void GetBerryNameByBerryType(u8 berry, u8 *string)
void ResetBerryTreeSparkleFlag(u8 id)
{
- GetBerryTreeInfo(id)->growthSparkle = 0;
+ GetBerryTreeInfo(id)->growthSparkle = FALSE;
}
-u8 BerryTreeGetNumStagesWatered(struct BerryTree *tree)
+static u8 BerryTreeGetNumStagesWatered(struct BerryTree *tree)
{
u8 count = 0;
@@ -1250,18 +1308,20 @@ u8 BerryTreeGetNumStagesWatered(struct BerryTree *tree)
return count;
}
-u8 GetNumStagesWateredByBerryTreeId(u8 id)
+static u8 GetNumStagesWateredByBerryTreeId(u8 id)
{
return BerryTreeGetNumStagesWatered(GetBerryTreeInfo(id));
}
-u8 CalcBerryYieldInternal(u16 max, u16 min, u8 water)
+static u8 CalcBerryYieldInternal(u16 max, u16 min, u8 water)
{
u32 randMin;
u32 randMax;
u32 rand;
u32 extraYield;
+ // depending on if the player gave the tree plenty of water, berry yield will be affected proportionally.
+
if (water == 0)
return min;
else
@@ -1270,7 +1330,7 @@ u8 CalcBerryYieldInternal(u16 max, u16 min, u8 water)
randMax = (max - min) * (water);
rand = randMin + Random() % (randMax - randMin + 1);
- if ((rand & 3) > 1)
+ if ((rand % 4) > 1)
extraYield = rand / 4 + 1;
else
extraYield = rand / 4;
@@ -1278,7 +1338,7 @@ u8 CalcBerryYieldInternal(u16 max, u16 min, u8 water)
}
}
-u8 CalcBerryYield(struct BerryTree *tree)
+static u8 CalcBerryYield(struct BerryTree *tree)
{
const struct Berry *berry = GetBerryInfo(tree->berry);
u8 min = berry->minYield;
@@ -1287,12 +1347,12 @@ u8 CalcBerryYield(struct BerryTree *tree)
return CalcBerryYieldInternal(max, min, BerryTreeGetNumStagesWatered(tree));
}
-u8 GetBerryCountByBerryTreeId(u8 id)
+static u8 GetBerryCountByBerryTreeId(u8 id)
{
return gSaveBlock1.berryTrees[id].berryYield;
}
-u16 GetStageDurationByBerryType(u8 berry)
+static u16 GetStageDurationByBerryType(u8 berry)
{
return GetBerryInfo(berry)->stageDuration * 60;
}
@@ -1301,18 +1361,23 @@ void FieldObjectInteractionGetBerryTreeData(void)
{
u8 id;
u8 berry;
- u8 unk;
+ u8 localId;
u8 group;
u8 num;
id = FieldObjectGetBerryTreeId(gSelectedMapObject);
berry = GetBerryTypeByBerryTreeId(id);
ResetBerryTreeSparkleFlag(id);
- unk = gScriptLastTalked;
+ localId = gScriptLastTalked;
num = gSaveBlock1.location.mapNum;
group = gSaveBlock1.location.mapGroup;
- if (sub_8060234(unk, num, group))
- gSpecialVar_0x8004 = 0xFF;
+ if (IsBerryTreeSparkling(localId, num, group))
+ {
+ // we cannot allow the player to grow/interact with the tree while the tree
+ // is undergoing the sparkling effect, so set the special var to the sparkling
+ // state and let the event script process the flag.
+ gSpecialVar_0x8004 = BERRY_STAGE_SPARKLING;
+ }
else
gSpecialVar_0x8004 = GetStageByBerryTreeId(id);
gSpecialVar_0x8005 = GetNumStagesWateredByBerryTreeId(id);
@@ -1320,7 +1385,7 @@ void FieldObjectInteractionGetBerryTreeData(void)
GetBerryNameByBerryType(berry, gStringVar1);
}
-void sub_80B4EE4(void)
+void Berry_FadeAndGoToBerryBagMenu(void)
{
SetMainCallback2(sub_80A68CC);
}
@@ -1347,11 +1412,13 @@ void FieldObjectInteractionRemoveBerryTree(void)
sub_8060288(gScriptLastTalked, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup);
}
-u8 PlayerHasBerries(void)
+bool8 PlayerHasBerries(void)
{
return IsBagPocketNonEmpty(BAG_BERRIES);
}
+// whenever the player is not within view of the berry tree during its sparkle state, the
+// sparkle state will be reset.
void ResetBerryTreeSparkleFlags(void)
{
s16 cam_left;
@@ -1369,7 +1436,7 @@ void ResetBerryTreeSparkleFlags(void)
bottom = top + 8;
for (i = 0; i < (u8)ARRAY_COUNT(gSaveBlock1.mapObjects); i++)
{
- if (gMapObjects[i].active && gMapObjects[i].animPattern == 12)
+ if (gMapObjects[i].active && gMapObjects[i].animPattern == 12) // is the object an active berry tree?
{
cam_left = gMapObjects[i].coords2.x;
cam_top = gMapObjects[i].coords2.y;
diff --git a/src/field/bike.c b/src/field/bike.c
index 8df901b40..e36ae1798 100644
--- a/src/field/bike.c
+++ b/src/field/bike.c
@@ -10,16 +10,16 @@
#include "songs.h"
#include "sound.h"
-extern u8 gUnknown_02039250;
-extern u8 gUnknown_02039251;
-extern u8 gUnknown_0202E854;
+extern bool8 gBikeCyclingChallenge;
+extern u8 gBikeCollisions;
+extern u8 gUnusedBikeCameraAheadPanback;
static void MovePlayerOnMachBike(u8, u16, u16);
static u8 GetMachBikeTransition(u8 *);
static void MachBikeTransition_FaceDirection(u8);
-static void MachBikeTransition_80E517C(u8);
-static void MachBikeTransition_80E51C4(u8);
-static void MachBikeTransition_80E5270(u8);
+static void MachBikeTransition_TurnDirection(u8);
+static void MachBikeTransition_TrySpeedUp(u8);
+static void MachBikeTransition_TrySlowDown(u8);
static void MovePlayerOnAcroBike(u8, u16, u16);
static u8 CheckMovementInputAcroBike(u8 *, u16, u16);
static u8 AcroBikeHandleInputNormal(u8 *, u16, u16);
@@ -27,64 +27,74 @@ static u8 AcroBikeHandleInputTurning(u8 *, u16, u16);
static u8 AcroBikeHandleInputWheelieStanding(u8 *, u16, u16);
static u8 AcroBikeHandleInputBunnyHop(u8 *, u16, u16);
static u8 AcroBikeHandleInputWheelieMoving(u8 *, u16, u16);
-static u8 AcroBikeHandleInputState5(u8 *, u16, u16);
-static u8 AcroBikeHandleInputState6(u8 *, u16, u16);
+static u8 AcroBikeHandleInputSidewaysJump(u8 *, u16, u16);
+static u8 AcroBikeHandleInputTurnJump(u8 *, u16, u16);
static void AcroBikeTransition_FaceDirection(u8);
-static void AcroBikeTransition_80E5708(u8);
-static void AcroBikeTransition_80E5744(u8);
+static void AcroBikeTransition_TurnDirection(u8);
+static void AcroBikeTransition_Moving(u8);
static void AcroBikeTransition_NormalToWheelie(u8);
-static void AcroBikeTransition_80E57F8(u8);
-static void AcroBikeTransition_80E5834(u8);
-static void AcroBikeTransition_80E5870(u8);
-static void AcroBikeTransition_80E58AC(u8);
-static void AcroBikeTransition_80E5920(u8);
-static void AcroBikeTransition_80E5990(u8);
-static void AcroBikeTransition_80E59A0(u8);
-static void AcroBikeTransition_80E5A30(u8);
-static void AcroBikeTransition_80E5AC0(u8);
-static void sub_80E5B60(u16, u16);
-static u8 sub_80E5C2C(void);
-static void sub_80E5C7C(u8);
-static void sub_80E5CB8(u8);
-static u8 sub_80E5CF4(u16);
+static void AcroBikeTransition_WheelieToNormal(u8);
+static void AcroBikeTransition_WheelieIdle(u8);
+static void AcroBikeTransition_WheelieHoppingStanding(u8);
+static void AcroBikeTransition_WheelieHoppingMoving(u8);
+static void AcroBikeTransition_SideJump(u8);
+static void AcroBikeTransition_TurnJump(u8);
+static void AcroBikeTransition_WheelieMoving(u8);
+static void AcroBikeTransition_WheelieRisingMoving(u8);
+static void AcroBikeTransition_WheelieLoweringMoving(u8);
+static void AcroBike_TryHistoryUpdate(u16, u16);
+static u8 AcroBike_GetJumpDirection(void);
+static void Bike_UpdateDirTimerHistory(u8);
+static void Bike_UpdateABStartSelectHistory(u8);
+static u8 Bike_DPadToDirection(u16);
static u8 get_some_collision(u8);
-static u8 sub_80E5DA0(struct MapObject *, s16, s16, u8, u8);
+static u8 Bike_CheckCollisionTryAdvanceCollisionCount(struct MapObject *, s16, s16, u8, u8);
static bool8 IsRunningDisallowedByMetatile(u8);
-static void sub_80E5E4C();
+static void Bike_TryAdvanceCyclingRoadCollisions();
static u8 CanBikeFaceDirOnMetatile(u8, u8);
-static bool8 sub_80E5EC0(u8, u8);
-static void sub_80E6024(void);
+static bool8 WillPlayerCollideWithCollision(u8, u8);
+static void Bike_SetBikeStill(void);
+
+/*
+ A bike transition is a type of callback for the bike that actually
+ modifies the bicycle's direction or momentum or otherwise movement.
+ Alternatively, a bike may also have input handlers which process the
+ bike transition to call: the acro bike has input handlers while the mach
+ bike does not. This is because the Acro needs to know the button inputs
+ for its complex tricks and actions.
+*/
static void (*const sMachBikeTransitions[])(u8) =
{
- MachBikeTransition_FaceDirection,
- MachBikeTransition_80E517C,
- MachBikeTransition_80E51C4,
- MachBikeTransition_80E5270,
+ MachBikeTransition_FaceDirection, // Face vs Turn: Face has no anim while Turn does. Turn checks for collision because if you turn right as opposed to face right, if there is a wall there, turn will make a bonk sound effect while face will not.
+ MachBikeTransition_TurnDirection,
+ MachBikeTransition_TrySpeedUp,
+ MachBikeTransition_TrySlowDown,
};
-static void (*const gUnknown_083DB5A4[])(u8) =
+// bikeFrameCounter is input which is represented by gMachBikeSpeeds in order: 0 is normal speed (1 speed), 1 is fast speed (2 speed), 2 is fastest speed (4 speed)
+static void (*const sMachBikeSpeedCallbacks[])(u8) =
{
- PlayerGoSpeed0,
- sub_80593C4,
- sub_80593F4,
+ PlayerGoSpeed1, // normal speed (1 speed)
+ PlayerGoSpeed2, // fast speed (2 speed)
+ PlayerGoSpeed4, // fastest speed (4 speed)
};
static void (*const sAcroBikeTransitions[])(u8) =
{
AcroBikeTransition_FaceDirection,
- AcroBikeTransition_80E5708,
- AcroBikeTransition_80E5744,
+ AcroBikeTransition_TurnDirection,
+ AcroBikeTransition_Moving,
AcroBikeTransition_NormalToWheelie,
- AcroBikeTransition_80E57F8,
- AcroBikeTransition_80E5834,
- AcroBikeTransition_80E5870,
- AcroBikeTransition_80E58AC,
- AcroBikeTransition_80E5920,
- AcroBikeTransition_80E5990,
- AcroBikeTransition_80E59A0,
- AcroBikeTransition_80E5A30,
- AcroBikeTransition_80E5AC0,
+ AcroBikeTransition_WheelieToNormal,
+ AcroBikeTransition_WheelieIdle,
+ AcroBikeTransition_WheelieHoppingStanding,
+ AcroBikeTransition_WheelieHoppingMoving,
+ AcroBikeTransition_SideJump,
+ AcroBikeTransition_TurnJump,
+ AcroBikeTransition_WheelieMoving,
+ AcroBikeTransition_WheelieRisingMoving,
+ AcroBikeTransition_WheelieLoweringMoving,
};
static u8 (*const sAcroBikeInputHandlers[])(u8 *, u16, u16) =
@@ -94,19 +104,24 @@ static u8 (*const sAcroBikeInputHandlers[])(u8 *, u16, u16) =
AcroBikeHandleInputWheelieStanding,
AcroBikeHandleInputBunnyHop,
AcroBikeHandleInputWheelieMoving,
- AcroBikeHandleInputState5,
- AcroBikeHandleInputState6,
+ AcroBikeHandleInputSidewaysJump,
+ AcroBikeHandleInputTurnJump,
};
+// used with bikeFrameCounter from mach bike
const u16 gMachBikeSpeeds[] = {SPEED_NORMAL, SPEED_FAST, SPEED_FASTEST};
-static const u8 Unknown_3DB606[] = {4, 0};
-static const struct UnknownStruct1 gUnknown_083DB608[] =
+// this is a list of timers to compare against later, terminated with 0. the only timer being compared against is 4 frames in this list.
+static const u8 AcroBikeJumpTimerList[] = {4, 0};
+
+// this is a list of history inputs to do in order to do the check to retrieve a jump direction for acro bike. it seems to be an extensible list, so its possible that Game Freak may have intended for the Acro Bike to have more complex tricks at some point. The final list only has the acro jump.
+static const struct BikeHistoryInputInfo gAcroBikeTricksList[] =
{
- {1, 2, 15, 15, Unknown_3DB606, Unknown_3DB606, 1},
- {2, 2, 15, 15, Unknown_3DB606, Unknown_3DB606, 2},
- {3, 2, 15, 15, Unknown_3DB606, Unknown_3DB606, 3},
- {4, 2, 15, 15, Unknown_3DB606, Unknown_3DB606, 4},
+ // the 0xF is a mask performed with each byte of the array in order to perform the check on only the last entry of the history list, otherwise the check wouldnt work as there can be 0xF0 as opposed to 0x0F.
+ {DIR_SOUTH, B_BUTTON, 0xF, 0xF, AcroBikeJumpTimerList, AcroBikeJumpTimerList, DIR_SOUTH},
+ {DIR_NORTH, B_BUTTON, 0xF, 0xF, AcroBikeJumpTimerList, AcroBikeJumpTimerList, DIR_NORTH},
+ {DIR_WEST, B_BUTTON, 0xF, 0xF, AcroBikeJumpTimerList, AcroBikeJumpTimerList, DIR_WEST},
+ {DIR_EAST, B_BUTTON, 0xF, 0xF, AcroBikeJumpTimerList, AcroBikeJumpTimerList, DIR_EAST},
};
void MovePlayerOnBike(u8 direction, u16 newKeys, u16 heldKeys)
@@ -122,54 +137,60 @@ static void MovePlayerOnMachBike(u8 direction, u16 newKeys, u16 heldKeys)
sMachBikeTransitions[GetMachBikeTransition(&direction)](direction);
}
-static u8 GetMachBikeTransition(u8 *ptr)
+// dirTraveling is a variable that is 0 when the player is standing still.
+static u8 GetMachBikeTransition(u8 *dirTraveling)
{
+ // if the dir updated before this function, get the relevent new direction to check later.
u8 direction = player_get_direction_upper_nybble();
- if (*ptr == 0)
+ // is the player standing still?
+ if (*dirTraveling == 0)
{
- *ptr = direction;
- if (gPlayerAvatar.unkB == 0)
+ *dirTraveling = direction; // update the direction, since below we either faced a direction or we started moving.
+ if (gPlayerAvatar.bikeSpeed == SPEED_STANDING)
{
- gPlayerAvatar.running2 = 0;
- return 0;
+ gPlayerAvatar.runningState = NOT_MOVING;
+ return MACH_TRANS_FACE_DIRECTION;
}
- gPlayerAvatar.running2 = 2;
- return 3;
+ gPlayerAvatar.runningState = MOVING;
+ return MACH_TRANS_START_MOVING;
}
- if (*ptr != direction && gPlayerAvatar.running2 != 2)
+ // we need to check if the last traveled direction changed from the new direction as well as ensuring that we dont update the state while the player is moving: see the else check.
+ if (*dirTraveling != direction && gPlayerAvatar.runningState != MOVING)
{
- if (gPlayerAvatar.unkB != 0)
+ if (gPlayerAvatar.bikeSpeed != SPEED_STANDING)
{
- *ptr = direction;
- gPlayerAvatar.running2 = 2;
- return 3;
+ *dirTraveling = direction; // implement the new direction
+ gPlayerAvatar.runningState = MOVING;
+ return MACH_TRANS_START_MOVING;
}
- gPlayerAvatar.running2 = 1;
- return 1;
+ // if you didnt start moving but your dir was different, do a turn direction instead.
+ gPlayerAvatar.runningState = TURN_DIRECTION;
+ return MACH_TRANS_TURN_DIRECTION;
}
- else
+ else // the player is either going in the current direction and hasnt changed or their state is currently moving.
{
- gPlayerAvatar.running2 = 2;
- return 2;
+ gPlayerAvatar.runningState = MOVING;
+ return MACH_TRANS_KEEP_MOVING;
}
}
+// the difference between face direction and turn direction is that one changes direction while the other does the animation of turning as well as changing direction.
static void MachBikeTransition_FaceDirection(u8 direction)
{
PlayerFaceDirection(direction);
- sub_80E6024();
+ Bike_SetBikeStill();
}
-static void MachBikeTransition_80E517C(u8 direction)
+static void MachBikeTransition_TurnDirection(u8 direction)
{
struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E))
{
PlayerTurnInPlace(direction);
- sub_80E6024();
+ Bike_SetBikeStill();
}
else
{
@@ -177,15 +198,16 @@ static void MachBikeTransition_80E517C(u8 direction)
}
}
-static void MachBikeTransition_80E51C4(u8 direction)
+static void MachBikeTransition_TrySpeedUp(u8 direction)
{
struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
u8 collision;
- if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0)
+ if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == FALSE)
{
- if (gPlayerAvatar.unkB)
- MachBikeTransition_80E5270(playerMapObj->placeholder18);
+ // we cannot go forward, so either slow down or, if we are stopped, idle face direction.
+ if (gPlayerAvatar.bikeSpeed)
+ MachBikeTransition_TrySlowDown(playerMapObj->placeholder18);
else
MachBikeTransition_FaceDirection(playerMapObj->placeholder18);
}
@@ -194,33 +216,36 @@ static void MachBikeTransition_80E51C4(u8 direction)
collision = get_some_collision(direction);
if (collision > 0 && collision < 12)
{
+ // we hit a solid object, but check to see if its a ledge and then jump.
if (collision == COLLISION_LEDGE_JUMP)
{
PlayerJumpLedge(direction);
}
else
{
- sub_80E6024();
+ // we hit a solid object that is not a ledge, so perform the collision.
+ Bike_SetBikeStill();
if (collision < 5 || collision > 8)
PlayerOnBikeCollide(direction);
}
}
else
{
- gUnknown_083DB5A4[gPlayerAvatar.bikeFrameCounter](direction);
- gPlayerAvatar.unkB = gPlayerAvatar.bikeFrameCounter + (gPlayerAvatar.bikeFrameCounter >> 1); // same as dividing by 2, but compiler is insistent on >> 1
+ // we did not hit anything that can slow us down, so perform the advancement callback depending on the bikeFrameCounter and try to increase the mach bike's speed.
+ sMachBikeSpeedCallbacks[gPlayerAvatar.bikeFrameCounter](direction);
+ gPlayerAvatar.bikeSpeed = gPlayerAvatar.bikeFrameCounter + (gPlayerAvatar.bikeFrameCounter >> 1); // same as dividing by 2, but compiler is insistent on >> 1
if (gPlayerAvatar.bikeFrameCounter < 2) // do not go faster than the last element in the mach bike array
gPlayerAvatar.bikeFrameCounter++;
}
}
}
-static void MachBikeTransition_80E5270(u8 var)
+static void MachBikeTransition_TrySlowDown(u8 var)
{
u8 collision;
- if (gPlayerAvatar.unkB != 0)
- gPlayerAvatar.bikeFrameCounter = --gPlayerAvatar.unkB;
+ if (gPlayerAvatar.bikeSpeed != SPEED_STANDING)
+ gPlayerAvatar.bikeFrameCounter = --gPlayerAvatar.bikeSpeed;
collision = get_some_collision(var);
@@ -232,17 +257,18 @@ static void MachBikeTransition_80E5270(u8 var)
}
else
{
- sub_80E6024();
+ Bike_SetBikeStill();
if (collision < 5 || collision > 8)
PlayerOnBikeCollide(var);
}
}
else
{
- gUnknown_083DB5A4[gPlayerAvatar.bikeFrameCounter](var);
+ sMachBikeSpeedCallbacks[gPlayerAvatar.bikeFrameCounter](var);
}
}
+// the acro bike requires the input handler to be executed before the transition can.
static void MovePlayerOnAcroBike(u8 newDirection, u16 newKeys, u16 heldKeys)
{
sAcroBikeTransitions[CheckMovementInputAcroBike(&newDirection, newKeys, heldKeys)](newDirection);
@@ -265,118 +291,121 @@ static u8 AcroBikeHandleInputNormal(u8 *newDirection, u16 newKeys, u16 heldKeys)
//We're standing still with the B button held.
//Do a wheelie.
*newDirection = direction;
- gPlayerAvatar.running2 = 0;
+ gPlayerAvatar.runningState = NOT_MOVING;
gPlayerAvatar.acroBikeState = ACRO_STATE_WHEELIE_STANDING;
return ACRO_TRANS_NORMAL_TO_WHEELIE;
}
else
{
*newDirection = direction;
- gPlayerAvatar.running2 = 0;
+ gPlayerAvatar.runningState = NOT_MOVING;
return ACRO_TRANS_FACE_DIRECTION;
}
}
- if (*newDirection == direction && (heldKeys & B_BUTTON) && gPlayerAvatar.unkB == 0)
+ if (*newDirection == direction && (heldKeys & B_BUTTON) && gPlayerAvatar.bikeSpeed == SPEED_STANDING)
{
- gPlayerAvatar.unkB++;
+ gPlayerAvatar.bikeSpeed++;
gPlayerAvatar.acroBikeState = ACRO_STATE_WHEELIE_MOVING;
- return 11;
+ return ACRO_TRANS_WHEELIE_RISING_MOVING;
}
- if (*newDirection != direction && gPlayerAvatar.running2 != 2)
+ if (*newDirection != direction && gPlayerAvatar.runningState != MOVING)
{
gPlayerAvatar.acroBikeState = ACRO_STATE_TURNING;
- gPlayerAvatar.unk9 = *newDirection;
- gPlayerAvatar.running2 = 0;
+ gPlayerAvatar.newDirBackup = *newDirection;
+ gPlayerAvatar.runningState = NOT_MOVING;
return CheckMovementInputAcroBike(newDirection, newKeys, heldKeys);
}
- gPlayerAvatar.running2 = 2;
- return 2;
+ gPlayerAvatar.runningState = MOVING;
+ return ACRO_TRANS_MOVING;
}
static u8 AcroBikeHandleInputTurning(u8 *newDirection, u16 newKeys, u16 heldKeys)
{
u8 direction;
- *newDirection = gPlayerAvatar.unk9;
+ *newDirection = gPlayerAvatar.newDirBackup;
gPlayerAvatar.bikeFrameCounter++;
- //Wait 6 frames before actually changing direction
- if (gPlayerAvatar.bikeFrameCounter > 6)
+ // Wait 6 frames before actually changing direction
+ if (gPlayerAvatar.bikeFrameCounter > 6) // ... because it takes 6 frames to advance 1 tile.
{
- gPlayerAvatar.running2 = 1;
+ gPlayerAvatar.runningState = TURN_DIRECTION;
gPlayerAvatar.acroBikeState = ACRO_STATE_NORMAL;
- sub_80E6024();
- return 1;
+ Bike_SetBikeStill();
+ return ACRO_TRANS_TURN_DIRECTION;
}
direction = player_get_direction_upper_nybble();
- if (*newDirection == sub_80E5C2C())
+ if (*newDirection == AcroBike_GetJumpDirection())
{
- sub_80E6024();
- gPlayerAvatar.unkB = 1;
+ Bike_SetBikeStill(); // Bike_SetBikeStill sets speed to standing, but the next line immediately overrides it. could have just reset acroBikeState to 0 here instead of wasting a jump.
+ gPlayerAvatar.bikeSpeed = SPEED_NORMAL;
if (*newDirection == GetOppositeDirection(direction))
{
- gPlayerAvatar.acroBikeState = ACRO_STATE_6;
- return 9;
+ // do a turn jump.
+ // no need to update runningState, didnt move.
+ gPlayerAvatar.acroBikeState = ACRO_STATE_TURN_JUMP;
+ return ACRO_TRANS_TURN_JUMP;
}
else
{
- gPlayerAvatar.running2 = 2;
- gPlayerAvatar.acroBikeState = ACRO_STATE_5;
- return 8;
+ // do a sideways jump.
+ gPlayerAvatar.runningState = MOVING; // we need to move, set state to moving.
+ gPlayerAvatar.acroBikeState = ACRO_STATE_SIDE_JUMP;
+ return ACRO_TRANS_SIDE_JUMP;
}
}
*newDirection = direction;
- return 0;
+ return ACRO_TRANS_FACE_DIRECTION;
}
-static u8 AcroBikeHandleInputWheelieStanding(u8 *ptr, u16 newKeys, u16 heldKeys)
+static u8 AcroBikeHandleInputWheelieStanding(u8 *newDirection, u16 newKeys, u16 heldKeys)
{
u8 direction;
struct MapObject *playerMapObj;
direction = player_get_direction_upper_nybble();
playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
- gPlayerAvatar.running2 = 0;
+ gPlayerAvatar.runningState = NOT_MOVING;
if (heldKeys & B_BUTTON)
gPlayerAvatar.bikeFrameCounter++;
else
{
- //B button was released.
+ // B button was released.
gPlayerAvatar.bikeFrameCounter = 0;
if (!MetatileBehavior_IsBumpySlope(playerMapObj->mapobj_unk_1E))
{
- //Go back to normal on flat ground
- *ptr = direction;
+ // Go back to normal on flat ground
+ *newDirection = direction;
gPlayerAvatar.acroBikeState = ACRO_STATE_NORMAL;
- sub_80E6024();
- return 4;
+ Bike_SetBikeStill();
+ return ACRO_TRANS_WHEELIE_TO_NORMAL;
}
}
if (gPlayerAvatar.bikeFrameCounter >= 40)
{
- *ptr = direction;
+ *newDirection = direction;
gPlayerAvatar.acroBikeState = ACRO_STATE_BUNNY_HOP;
- sub_80E6024();
- return 6;
+ Bike_SetBikeStill();
+ return ACRO_TRANS_WHEELIE_HOPPING_STANDING;
}
- if (*ptr == direction)
+ if (*newDirection == direction)
{
- gPlayerAvatar.running2 = 2;
+ gPlayerAvatar.runningState = MOVING;
gPlayerAvatar.acroBikeState = ACRO_STATE_WHEELIE_MOVING;
- sub_80E6024();
- return 10;
+ Bike_SetBikeStill();
+ return ACRO_TRANS_WHEELIE_MOVING;
}
- if (*ptr == 0)
+ if (*newDirection == 0)
{
- *ptr = direction;
- return 5;
+ *newDirection = direction;
+ return ACRO_TRANS_WHEELIE_IDLE;
}
- gPlayerAvatar.running2 = 1;
- return 5;
+ gPlayerAvatar.runningState = TURN_DIRECTION;
+ return ACRO_TRANS_WHEELIE_IDLE;
}
-static u8 AcroBikeHandleInputBunnyHop(u8 *ptr, u16 newKeys, u16 heldKeys)
+static u8 AcroBikeHandleInputBunnyHop(u8 *newDirection, u16 newKeys, u16 heldKeys)
{
u8 direction;
struct MapObject *playerMapObj;
@@ -385,42 +414,45 @@ static u8 AcroBikeHandleInputBunnyHop(u8 *ptr, u16 newKeys, u16 heldKeys)
playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
if (!(heldKeys & B_BUTTON))
{
- //B button was released
- sub_80E6024();
+ // B button was released
+ Bike_SetBikeStill();
if (MetatileBehavior_IsBumpySlope(playerMapObj->mapobj_unk_1E))
{
- //Do a standing wheelie on a bumpy slope
+ // even though B was released, dont undo the wheelie on the bumpy slope.
gPlayerAvatar.acroBikeState = ACRO_STATE_WHEELIE_STANDING;
- return CheckMovementInputAcroBike(ptr, newKeys, heldKeys);
+ return CheckMovementInputAcroBike(newDirection, newKeys, heldKeys);
}
else
{
- //Go back to normal on flat ground
- *ptr = direction;
- gPlayerAvatar.running2 = 0;
+ // .. otherwise, go back to normal on flat ground
+ *newDirection = direction;
+ gPlayerAvatar.runningState = NOT_MOVING;
gPlayerAvatar.acroBikeState = ACRO_STATE_NORMAL;
- return 4;
+ return ACRO_TRANS_WHEELIE_TO_NORMAL;
}
}
- //B Button is still held
+ // B Button is still held
- if (*ptr == DIR_NONE)
+ if (*newDirection == DIR_NONE)
{
- *ptr = direction;
- gPlayerAvatar.running2 = 0;
- return 6;
+ // we did not move, so keep hopping in place without moving.
+ *newDirection = direction;
+ gPlayerAvatar.runningState = NOT_MOVING;
+ return ACRO_TRANS_WHEELIE_HOPPING_STANDING;
}
- if (*ptr != direction && gPlayerAvatar.running2 != 2)
+ if (*newDirection != direction && gPlayerAvatar.runningState != MOVING)
{
- gPlayerAvatar.running2 = 1;
- return 6;
+ // we changed direction, so turn but do not move hop.
+ gPlayerAvatar.runningState = TURN_DIRECTION;
+ return ACRO_TRANS_WHEELIE_HOPPING_STANDING;
}
- gPlayerAvatar.running2 = 2;
- return 7;
+ // otherwise, we started moving while hopping
+ gPlayerAvatar.runningState = MOVING;
+ return ACRO_TRANS_WHEELIE_HOPPING_MOVING;
}
-static u8 AcroBikeHandleInputWheelieMoving(u8 *ptr, u16 newKeys, u16 heldKeys)
+static u8 AcroBikeHandleInputWheelieMoving(u8 *newDirection, u16 newKeys, u16 heldKeys)
{
u8 direction;
struct MapObject *playerMapObj;
@@ -429,45 +461,53 @@ static u8 AcroBikeHandleInputWheelieMoving(u8 *ptr, u16 newKeys, u16 heldKeys)
playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
if (!(heldKeys & B_BUTTON))
{
- sub_80E6024();
+ // we were moving on a wheelie, but we let go while moving. reset bike still status
+ Bike_SetBikeStill();
if (!MetatileBehavior_IsBumpySlope(playerMapObj->mapobj_unk_1E))
{
+ // we let go of B and arent on a bumpy slope, set state to normal because now we need to handle this
gPlayerAvatar.acroBikeState = ACRO_STATE_NORMAL;
- if (*ptr == 0)
+ if (*newDirection == DIR_NONE)
{
- *ptr = direction;
- gPlayerAvatar.running2 = 0;
- return 4;
+ // we stopped moving but are turning, still try to lower the wheelie in place.
+ *newDirection = direction;
+ gPlayerAvatar.runningState = NOT_MOVING;
+ return ACRO_TRANS_WHEELIE_TO_NORMAL;
}
- if (*ptr != direction && gPlayerAvatar.running2 != 2)
+ if (*newDirection != direction && gPlayerAvatar.runningState != MOVING)
{
- gPlayerAvatar.running2 = 0;
- return 4;
+ // we did not turn while lowering wheelie, so do so without turning.
+ gPlayerAvatar.runningState = NOT_MOVING;
+ return ACRO_TRANS_WHEELIE_TO_NORMAL;
}
- gPlayerAvatar.running2 = 2;
- return 12;
+ // if we are moving while lowering wheelie, put the acro into a lowering state while moving.
+ gPlayerAvatar.runningState = MOVING;
+ return ACRO_TRANS_WHEELIE_LOWERING_MOVING;
}
+ // please do not undo the wheelie on a bumpy slope
gPlayerAvatar.acroBikeState = ACRO_STATE_WHEELIE_STANDING;
- return CheckMovementInputAcroBike(ptr, newKeys, heldKeys);
+ return CheckMovementInputAcroBike(newDirection, newKeys, heldKeys);
}
- if (*ptr == 0)
+ // we are still holding B.
+ if (*newDirection == DIR_NONE)
{
- *ptr = direction;
+ // idle the wheelie in place because we're holding B without moving.
+ *newDirection = direction;
gPlayerAvatar.acroBikeState = ACRO_STATE_WHEELIE_STANDING;
- gPlayerAvatar.running2 = 0;
- sub_80E6024();
- return 5;
+ gPlayerAvatar.runningState = NOT_MOVING;
+ Bike_SetBikeStill();
+ return ACRO_TRANS_WHEELIE_IDLE;
}
- if (direction != *ptr && gPlayerAvatar.running2 != 2)
+ if (direction != *newDirection && gPlayerAvatar.runningState != MOVING)
{
- gPlayerAvatar.running2 = 0;
- return 5;
+ gPlayerAvatar.runningState = NOT_MOVING;
+ return ACRO_TRANS_WHEELIE_IDLE;
}
- gPlayerAvatar.running2 = 2;
- return 10;
+ gPlayerAvatar.runningState = MOVING;
+ return ACRO_TRANS_WHEELIE_MOVING;
}
-static u8 AcroBikeHandleInputState5(u8 *ptr, u16 newKeys, u16 heldKeys)
+static u8 AcroBikeHandleInputSidewaysJump(u8 *ptr, u16 newKeys, u16 heldKeys)
{
struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
@@ -477,7 +517,7 @@ static u8 AcroBikeHandleInputState5(u8 *ptr, u16 newKeys, u16 heldKeys)
return CheckMovementInputAcroBike(ptr, newKeys, heldKeys);
}
-static u8 AcroBikeHandleInputState6(u8 *ptr, u16 newKeys, u16 heldKeys)
+static u8 AcroBikeHandleInputTurnJump(u8 *ptr, u16 newKeys, u16 heldKeys)
{
gPlayerAvatar.acroBikeState = ACRO_STATE_NORMAL;
return CheckMovementInputAcroBike(ptr, newKeys, heldKeys);
@@ -488,7 +528,7 @@ static void AcroBikeTransition_FaceDirection(u8 direction)
PlayerFaceDirection(direction);
}
-static void AcroBikeTransition_80E5708(u8 direction)
+static void AcroBikeTransition_TurnDirection(u8 direction)
{
struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
@@ -497,7 +537,7 @@ static void AcroBikeTransition_80E5708(u8 direction)
PlayerFaceDirection(direction);
}
-static void AcroBikeTransition_80E5744(u8 direction)
+static void AcroBikeTransition_Moving(u8 direction)
{
u8 collision;
struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
@@ -530,41 +570,41 @@ static void AcroBikeTransition_NormalToWheelie(u8 direction)
PlayerStartWheelie(direction);
}
-static void AcroBikeTransition_80E57F8(u8 direction)
+static void AcroBikeTransition_WheelieToNormal(u8 direction)
{
struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0)
direction = playerMapObj->placeholder18;
- sub_8059534(direction);
+ PlayerEndWheelie(direction);
}
-static void AcroBikeTransition_80E5834(u8 direction)
+static void AcroBikeTransition_WheelieIdle(u8 direction)
{
struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0)
direction = playerMapObj->placeholder18;
- sub_8059504(direction);
+ PlayerIdleWheelie(direction);
}
-static void AcroBikeTransition_80E5870(u8 direction)
+static void AcroBikeTransition_WheelieHoppingStanding(u8 direction)
{
struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0)
direction = playerMapObj->placeholder18;
- sub_805954C(direction);
+ PlayerStandingHoppingWheelie(direction);
}
-static void AcroBikeTransition_80E58AC(u8 direction)
+static void AcroBikeTransition_WheelieHoppingMoving(u8 direction)
{
u8 var;
struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0)
{
- AcroBikeTransition_80E5870(playerMapObj->placeholder18);
+ AcroBikeTransition_WheelieHoppingStanding(playerMapObj->placeholder18);
return;
}
var = get_some_collision(direction);
@@ -575,23 +615,23 @@ static void AcroBikeTransition_80E58AC(u8 direction)
}
else if (var == 6)
{
- sub_8059594(direction);
+ PlayerLedgeHoppingWheelie(direction);
}
else if (var < 5 || var > 8)
{
if (var <= 11)
{
- AcroBikeTransition_80E5870(direction);
+ AcroBikeTransition_WheelieHoppingStanding(direction);
}
else
{
derp:
- sub_8059570(direction);
+ PlayerMovingHoppingWheelie(direction);
}
}
}
-static void AcroBikeTransition_80E5920(u8 direction)
+static void AcroBikeTransition_SideJump(u8 direction)
{
u8 var;
struct MapObject *playerMapObj;
@@ -603,12 +643,12 @@ static void AcroBikeTransition_80E5920(u8 direction)
return;
if (var < 10)
{
- AcroBikeTransition_80E5708(direction);
+ AcroBikeTransition_TurnDirection(direction);
return;
}
- if (sub_80E5EC0(var, direction) == 0)
+ if (WillPlayerCollideWithCollision(var, direction) == FALSE)
{
- AcroBikeTransition_80E5708(direction);
+ AcroBikeTransition_TurnDirection(direction);
return;
}
}
@@ -618,19 +658,19 @@ static void AcroBikeTransition_80E5920(u8 direction)
PlayerSetAnimId(sub_80608A4(direction), 2);
}
-static void AcroBikeTransition_80E5990(u8 direction)
+static void AcroBikeTransition_TurnJump(u8 direction)
{
- sub_80595B8(direction);
+ PlayerAcroTurnJump(direction);
}
-static void AcroBikeTransition_80E59A0(u8 direction)
+static void AcroBikeTransition_WheelieMoving(u8 direction)
{
u8 var;
struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0)
{
- sub_8059504(playerMapObj->placeholder18);
+ PlayerIdleWheelie(playerMapObj->placeholder18);
return;
}
var = get_some_collision(direction);
@@ -638,26 +678,26 @@ static void AcroBikeTransition_80E59A0(u8 direction)
{
if (var == 6)
{
- sub_8059594(direction);
+ PlayerLedgeHoppingWheelie(direction);
}
else if (var == 9)
{
- sub_8059504(direction);
+ PlayerIdleWheelie(direction);
}
else if (var <= 4)
{
if (MetatileBehavior_IsBumpySlope(playerMapObj->mapobj_unk_1E))
- sub_8059504(direction);
+ PlayerIdleWheelie(direction);
else
sub_80595DC(direction); //hit wall?
}
return;
}
sub_8059618(direction);
- gPlayerAvatar.running2 = 2;
+ gPlayerAvatar.runningState = MOVING;
}
-static void AcroBikeTransition_80E5A30(u8 direction)
+static void AcroBikeTransition_WheelieRisingMoving(u8 direction)
{
u8 var;
struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
@@ -672,33 +712,33 @@ static void AcroBikeTransition_80E5A30(u8 direction)
{
if (var == 6)
{
- sub_8059594(direction);
+ PlayerLedgeHoppingWheelie(direction);
}
else if (var == 9)
{
- sub_8059504(direction);
+ PlayerIdleWheelie(direction);
}
else if (var <= 4)
{
if (MetatileBehavior_IsBumpySlope(playerMapObj->mapobj_unk_1E))
- sub_8059504(direction);
+ PlayerIdleWheelie(direction);
else
sub_80595DC(direction); //hit wall?
}
return;
}
sub_8059600(direction);
- gPlayerAvatar.running2 = 2;
+ gPlayerAvatar.runningState = MOVING;
}
-static void AcroBikeTransition_80E5AC0(u8 direction)
+static void AcroBikeTransition_WheelieLoweringMoving(u8 direction)
{
u8 var;
struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0)
{
- sub_8059534(playerMapObj->placeholder18);
+ PlayerEndWheelie(playerMapObj->placeholder18);
return;
}
var = get_some_collision(direction);
@@ -707,115 +747,115 @@ static void AcroBikeTransition_80E5AC0(u8 direction)
if (var == 6)
PlayerJumpLedge(direction);
else if (var < 5 || var > 8)
- sub_8059534(direction);
+ PlayerEndWheelie(direction);
return;
}
sub_8059630(direction);
}
-void sub_80E5B38(u16 a, u16 b)
+void Bike_TryAcroBikeHistoryUpdate(u16 newKeys, u16 heldKeys)
{
if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_ACRO_BIKE)
- sub_80E5B60(a, b);
+ AcroBike_TryHistoryUpdate(newKeys, heldKeys);
}
-static void sub_80E5B60(u16 unused, u16 b)
+static void AcroBike_TryHistoryUpdate(u16 newKeys, u16 heldKeys) // newKeys is unused
{
- u8 var;
+ u8 direction = Bike_DPadToDirection(heldKeys);
- var = sub_80E5CF4(b);
- if (var == (gPlayerAvatar.unkC & 0xF))
+ if (direction == (gPlayerAvatar.directionHistory & 0xF))
{
- if (gPlayerAvatar.unk14[0] < 0xFF)
- gPlayerAvatar.unk14[0]++;
+ // increment the timer for direction history since last input.
+ if (gPlayerAvatar.dirTimerHistory[0] < 0xFF)
+ gPlayerAvatar.dirTimerHistory[0]++;
}
else
{
- sub_80E5C7C(var);
- gPlayerAvatar.unkB = 0;
+ Bike_UpdateDirTimerHistory(direction);
+ gPlayerAvatar.bikeSpeed = SPEED_STANDING;
}
- var = b & 0xF;
- if (var == (gPlayerAvatar.unk10 & 0xF))
+ direction = heldKeys & (A_BUTTON | B_BUTTON | SELECT_BUTTON | START_BUTTON); // directions is reused for some reason.
+ if (direction == (gPlayerAvatar.abStartSelectHistory & 0xF))
{
- if (gPlayerAvatar.unk1C[0] < 0xFF)
- gPlayerAvatar.unk1C[0]++;
+ if (gPlayerAvatar.abStartSelectTimerHistory[0] < 0xFF)
+ gPlayerAvatar.abStartSelectTimerHistory[0]++;
}
else
{
- sub_80E5CB8(var);
- gPlayerAvatar.unkB = 0;
+ Bike_UpdateABStartSelectHistory(direction);
+ gPlayerAvatar.bikeSpeed = SPEED_STANDING;
}
}
-static bool8 sub_80E5BC8(const u8 *a, const u8 *b)
+static bool8 HasPlayerInputTakenLongerThanList(const u8 *dirTimerList, const u8 *abStartSelectTimerList)
{
u8 i;
- for (i = 0; a[i] != 0; i++)
+ for (i = 0; dirTimerList[i] != 0; i++)
{
- if (gPlayerAvatar.unk14[i] > a[i])
+ if (gPlayerAvatar.dirTimerHistory[i] > dirTimerList[i])
return FALSE;
}
- for (i = 0; b[i] != 0; i++)
+ for (i = 0; abStartSelectTimerList[i] != 0; i++)
{
- if (gPlayerAvatar.unk1C[i] > b[i])
+ if (gPlayerAvatar.abStartSelectTimerHistory[i] > abStartSelectTimerList[i])
return FALSE;
}
return TRUE;
}
-static u8 sub_80E5C2C(void)
+static u8 AcroBike_GetJumpDirection(void)
{
u32 i;
for (i = 0; i < 4; i++)
{
- const struct UnknownStruct1 *s = &gUnknown_083DB608[i];
- u32 r1 = gPlayerAvatar.unkC;
- u32 r2 = gPlayerAvatar.unk10;
-
- r1 &= s->unk8;
- r2 &= s->unkC;
- if (r1 == s->unk0 && r2 == s->unk4 && sub_80E5BC8(s->unk10, s->unk14))
- return s->unk18;
+ const struct BikeHistoryInputInfo *historyInputInfo = &gAcroBikeTricksList[i];
+ u32 dirHistory = gPlayerAvatar.directionHistory;
+ u32 abStartSelectHistory = gPlayerAvatar.abStartSelectHistory;
+
+ dirHistory &= historyInputInfo->dirHistoryMask;
+ abStartSelectHistory &= historyInputInfo->abStartSelectHistoryMask;
+ if (dirHistory == historyInputInfo->dirHistoryMatch && abStartSelectHistory == historyInputInfo->abStartSelectHistoryMatch && HasPlayerInputTakenLongerThanList(historyInputInfo->dirTimerHistoryList, historyInputInfo->abStartSelectHistoryList))
+ return historyInputInfo->direction;
}
return 0;
}
-static void sub_80E5C7C(u8 a)
+static void Bike_UpdateDirTimerHistory(u8 dir)
{
u8 i;
- gPlayerAvatar.unkC = (gPlayerAvatar.unkC << 4) | (a & 0xF);
+ gPlayerAvatar.directionHistory = (gPlayerAvatar.directionHistory << 4) | (dir & 0xF);
for (i = 7; i != 0; i--)
- gPlayerAvatar.unk14[i] = gPlayerAvatar.unk14[i - 1];
- gPlayerAvatar.unk14[0] = 1;
+ gPlayerAvatar.dirTimerHistory[i] = gPlayerAvatar.dirTimerHistory[i - 1];
+ gPlayerAvatar.dirTimerHistory[0] = 1;
}
-static void sub_80E5CB8(u8 a)
+static void Bike_UpdateABStartSelectHistory(u8 input)
{
u8 i;
- gPlayerAvatar.unk10 = (gPlayerAvatar.unk10 << 4) | (a & 0xF);
+ gPlayerAvatar.abStartSelectHistory = (gPlayerAvatar.abStartSelectHistory << 4) | (input & 0xF);
for (i = 7; i != 0; i--)
- gPlayerAvatar.unk1C[i] = gPlayerAvatar.unk1C[i - 1];
- gPlayerAvatar.unk1C[0] = 1;
+ gPlayerAvatar.abStartSelectTimerHistory[i] = gPlayerAvatar.abStartSelectTimerHistory[i - 1];
+ gPlayerAvatar.abStartSelectTimerHistory[0] = 1;
}
-static u8 sub_80E5CF4(u16 a)
+static u8 Bike_DPadToDirection(u16 heldKeys)
{
- if (a & 0x40)
- return 2;
- if (a & 0x80)
- return 1;
- if (a & 0x20)
- return 3;
- if (a & 0x10)
- return 4;
- return 0;
+ if (heldKeys & DPAD_UP)
+ return DIR_NORTH;
+ if (heldKeys & DPAD_DOWN)
+ return DIR_SOUTH;
+ if (heldKeys & DPAD_LEFT)
+ return DIR_WEST;
+ if (heldKeys & DPAD_RIGHT)
+ return DIR_EAST;
+ return DIR_NONE;
}
static u8 get_some_collision(u8 direction)
@@ -829,10 +869,10 @@ static u8 get_some_collision(u8 direction)
y = playerMapObj->coords2.y;
MoveCoords(direction, &x, &y);
metatitleBehavior = MapGridGetMetatileBehaviorAt(x, y);
- return sub_80E5DA0(playerMapObj, x, y, direction, metatitleBehavior);
+ return Bike_CheckCollisionTryAdvanceCollisionCount(playerMapObj, x, y, direction, metatitleBehavior);
}
-static u8 sub_80E5DA0(struct MapObject *mapObject, s16 x, s16 y, u8 direction, u8 metatitleBehavior)
+static u8 Bike_CheckCollisionTryAdvanceCollisionCount(struct MapObject *mapObject, s16 x, s16 y, u8 direction, u8 metatitleBehavior)
{
u8 collision = CheckForFieldObjectCollision(mapObject, x, y, direction, metatitleBehavior);
@@ -843,7 +883,7 @@ static u8 sub_80E5DA0(struct MapObject *mapObject, s16 x, s16 y, u8 direction, u
collision = 2;
if (collision)
- sub_80E5E4C();
+ Bike_TryAdvanceCyclingRoadCollisions();
return collision;
}
@@ -865,10 +905,10 @@ static bool8 IsRunningDisallowedByMetatile(u8 tile)
return FALSE;
}
-static void sub_80E5E4C(void)
+static void Bike_TryAdvanceCyclingRoadCollisions(void)
{
- if (gUnknown_02039250 != 0 && gUnknown_02039251 < 100)
- gUnknown_02039251++;
+ if (gBikeCyclingChallenge != FALSE && gBikeCollisions < 100)
+ gBikeCollisions++;
}
static bool8 CanBikeFaceDirOnMetatile(u8 direction, u8 tile)
@@ -890,14 +930,14 @@ static bool8 CanBikeFaceDirOnMetatile(u8 direction, u8 tile)
return TRUE;
}
-static bool8 sub_80E5EC0(u8 var1, u8 direction)
+static bool8 WillPlayerCollideWithCollision(u8 newTileCollision, u8 direction)
{
if (direction == DIR_NORTH || direction == DIR_SOUTH)
{
- if (var1 == 10 || var1 == 12)
+ if (newTileCollision == 10 || newTileCollision == 12)
return FALSE;
}
- else if (var1 == 11 || var1 == 13)
+ else if (newTileCollision == 11 || newTileCollision == 13)
{
return FALSE;
}
@@ -930,7 +970,7 @@ bool8 player_should_look_direction_be_enforced_upon_movement(void)
void GetOnOffBike(u8 var)
{
- gUnknown_0202E854 = 0;
+ gUnusedBikeCameraAheadPanback = FALSE;
if (gPlayerAvatar.flags & (PLAYER_AVATAR_FLAG_MACH_BIKE | PLAYER_AVATAR_FLAG_ACRO_BIKE))
{
@@ -946,34 +986,34 @@ void GetOnOffBike(u8 var)
}
}
-void BikeClearState(int var1, int var2)
+void BikeClearState(int newDirHistory, int newAbStartHistory)
{
u8 i;
gPlayerAvatar.acroBikeState = ACRO_STATE_NORMAL;
- gPlayerAvatar.unk9 = 0;
+ gPlayerAvatar.newDirBackup = DIR_NONE;
gPlayerAvatar.bikeFrameCounter = 0;
- gPlayerAvatar.unkB = 0;
- gPlayerAvatar.unkC = var1;
- gPlayerAvatar.unk10 = var2;
+ gPlayerAvatar.bikeSpeed = SPEED_STANDING;
+ gPlayerAvatar.directionHistory = newDirHistory;
+ gPlayerAvatar.abStartSelectHistory = newAbStartHistory;
for (i = 0; i < 8; i++)
- gPlayerAvatar.unk14[i] = 0;
+ gPlayerAvatar.dirTimerHistory[i] = 0;
for (i = 0; i < 8; i++)
- gPlayerAvatar.unk1C[i] = 0;
+ gPlayerAvatar.abStartSelectTimerHistory[i] = 0;
}
-void sub_80E6010(u8 var)
+void Bike_UpdateBikeCounterSpeed(u8 counter)
{
- gPlayerAvatar.bikeFrameCounter = var;
- gPlayerAvatar.unkB = gPlayerAvatar.bikeFrameCounter + (gPlayerAvatar.bikeFrameCounter >> 1); // lazy way of multiplying by 1.5.
+ gPlayerAvatar.bikeFrameCounter = counter;
+ gPlayerAvatar.bikeSpeed = gPlayerAvatar.bikeFrameCounter + (gPlayerAvatar.bikeFrameCounter >> 1); // lazy way of multiplying by 1.5.
}
-static void sub_80E6024(void)
+static void Bike_SetBikeStill(void)
{
gPlayerAvatar.bikeFrameCounter = 0;
- gPlayerAvatar.unkB = 0;
+ gPlayerAvatar.bikeSpeed = SPEED_STANDING;
}
s16 GetPlayerSpeed(void)
@@ -993,7 +1033,7 @@ s16 GetPlayerSpeed(void)
return SPEED_NORMAL;
}
-void sub_80E6084(void)
+void Bike_HandleBumpySlopeJump(void)
{
s16 x, y;
u8 tileBehavior;
diff --git a/src/field/daycare.c b/src/field/daycare.c
index 60cc61e40..d182e121b 100644
--- a/src/field/daycare.c
+++ b/src/field/daycare.c
@@ -13,7 +13,6 @@
#include "moves.h"
#include "trade.h"
#include "strings2.h"
-#include "data/pokemon/egg_moves.h"
#include "party_menu.h"
#include "field_effect.h"
#include "main.h"
@@ -33,6 +32,8 @@ static void sub_80417F4(struct DayCareMail *);
static void sub_80420FC(struct Pokemon *, u16, struct DayCareData *);
static u8 daycare_relationship_score(struct DayCareData *);
+#include "../data/pokemon/egg_moves.h"
+
const u8 *const gUnknown_08209AC4[] = {
DaycareText_GetAlongVeryWell,
DaycareText_GetAlong,
@@ -388,8 +389,8 @@ static void InheritIVs(struct Pokemon *egg, struct DayCareData *dayCareData)
SetMonData(egg, MON_DATA_DEF_IV, &iv);
break;
case 3:
- iv = GetBoxMonData(&dayCareData->mons[whichParent[i]], MON_DATA_SPD_IV);
- SetMonData(egg, MON_DATA_SPD_IV, &iv);
+ iv = GetBoxMonData(&dayCareData->mons[whichParent[i]], MON_DATA_SPEED_IV);
+ SetMonData(egg, MON_DATA_SPEED_IV, &iv);
break;
case 4:
iv = GetBoxMonData(&dayCareData->mons[whichParent[i]], MON_DATA_SPATK_IV);
diff --git a/src/field/field_camera.c b/src/field/field_camera.c
index db51cf054..a29f4c49f 100644
--- a/src/field/field_camera.c
+++ b/src/field/field_camera.c
@@ -7,7 +7,7 @@
#include "sprite.h"
#include "text.h"
-EWRAM_DATA u8 gUnknown_0202E854 = 0;
+EWRAM_DATA bool8 gUnusedBikeCameraAheadPanback = FALSE;
struct UnknownStruct
{
@@ -455,13 +455,14 @@ static void CameraPanningCB_PanAhead(void)
{
u8 var;
- if (gUnknown_0202E854 == 0)
+ if (gUnusedBikeCameraAheadPanback == FALSE)
{
InstallCameraPanAheadCallback();
}
else
{
- if (gPlayerAvatar.running1 == 1)
+ // this code is never reached.
+ if (gPlayerAvatar.tileTransitionState == T_TILE_TRANSITION)
{
gUnknown_0300059C ^= 1;
if (gUnknown_0300059C == 0)
diff --git a/src/field/field_control_avatar.c b/src/field/field_control_avatar.c
index ff8e8504c..e9dd0e9a6 100644
--- a/src/field/field_control_avatar.c
+++ b/src/field/field_control_avatar.c
@@ -124,8 +124,8 @@ void FieldClearPlayerInput(struct FieldInput *input)
void FieldGetPlayerInput(struct FieldInput *input, u16 newKeys, u16 heldKeys)
{
- u8 r6 = gPlayerAvatar.running1;
- u8 r9 = gPlayerAvatar.running2;
+ u8 r6 = gPlayerAvatar.tileTransitionState;
+ u8 r9 = gPlayerAvatar.runningState;
bool8 forcedMove = MetatileBehavior_IsMoveTile(cur_mapdata_block_role_at_player_pos(r9));
if ((r6 == 2 && forcedMove == FALSE) || r6 == 0)
@@ -856,7 +856,7 @@ u8 sub_8068F18(void)
return 0;
}
-u8 *GetFieldObjectScriptPointerForComparison(void)
+u8 *GetFieldObjectScriptPointerPlayerFacing(void)
{
u8 r4;
struct MapPosition position;
diff --git a/src/field/field_effect.c b/src/field/field_effect.c
index afe020ac7..d86d6e5cd 100644
--- a/src/field/field_effect.c
+++ b/src/field/field_effect.c
@@ -1287,7 +1287,7 @@ bool8 sub_80867AC(struct Task *task) // gUnknown_0839F2CC[0]
playerSprite = &gSprites[gPlayerAvatar.spriteId];
CameraObjectReset2();
gMapObjects[gPlayerAvatar.mapObjectId].mapobj_bit_13 = 1;
- gPlayerAvatar.unk6 = 1;
+ gPlayerAvatar.preventStep = TRUE;
FieldObjectSetSpecialAnim(playerObject, GetFaceDirectionAnimId(player_get_direction_lower_nybble()));
task->data[4] = playerSprite->subspriteMode;
playerObject->mapobj_bit_26 = 1;
@@ -1382,7 +1382,7 @@ bool8 sub_80869B8(struct Task *task)
bool8 sub_80869F8(struct Task *task)
{
- gPlayerAvatar.unk6 = 0;
+ gPlayerAvatar.preventStep = FALSE;
ScriptContext2_Disable();
CameraObjectReset1();
UnfreezeMapObjects();
@@ -1678,7 +1678,7 @@ void sub_8086F64(u8 taskId)
bool8 sub_8086FB0(struct Task *task, struct MapObject *mapObject)
{
ScriptContext2_Enable();
- gPlayerAvatar.unk6 = 1;
+ gPlayerAvatar.preventStep = TRUE;
task->data[0]++;
return FALSE;
}
@@ -1725,7 +1725,7 @@ bool8 sub_8087058(struct Task *task, struct MapObject *mapObject)
return TRUE;
}
ScriptContext2_Disable();
- gPlayerAvatar.unk6 = 0;
+ gPlayerAvatar.preventStep = FALSE;
DestroyTask(FindTaskIdByFunc(sub_8086F64));
FieldEffectActiveListRemove(FLDEFF_USE_WATERFALL);
return FALSE;
@@ -1751,7 +1751,7 @@ void Task_Dive(u8 taskId)
bool8 sub_8087124(struct Task *task)
{
- gPlayerAvatar.unk6 = 1;
+ gPlayerAvatar.preventStep = TRUE;
task->data[0]++;
return FALSE;
}
@@ -1796,7 +1796,7 @@ bool8 sub_808722C(struct Task *task, struct MapObject *mapObject, struct Sprite
FreezeMapObjects();
CameraObjectReset2();
SetCameraPanningCallback(NULL);
- gPlayerAvatar.unk6 = 1;
+ gPlayerAvatar.preventStep = TRUE;
mapObject->mapobj_bit_26 = 1;
task->data[1] = 1;
task->data[0]++;
@@ -1913,7 +1913,7 @@ bool8 sub_80874CC(struct Task *task, struct MapObject *mapObject, struct Sprite
{
CameraObjectReset2();
FreezeMapObjects();
- gPlayerAvatar.unk6 = 1;
+ gPlayerAvatar.preventStep = TRUE;
mapObject->mapobj_bit_13 = 1;
task->data[0]++;
return FALSE;
@@ -1951,7 +1951,7 @@ bool8 sub_808759C(struct Task *task, struct MapObject *mapObject, struct Sprite
{
if (FieldObjectClearAnimIfSpecialAnimFinished(mapObject))
{
- gPlayerAvatar.unk6 = 0;
+ gPlayerAvatar.preventStep = FALSE;
ScriptContext2_Disable();
UnfreezeMapObjects();
DestroyTask(FindTaskIdByFunc(sub_8087470));
@@ -1996,7 +1996,7 @@ bool8 sub_80876C8(struct Task *task, struct MapObject *mapObject, struct Sprite
{
FreezeMapObjects();
CameraObjectReset2();
- gPlayerAvatar.unk6 = 1;
+ gPlayerAvatar.preventStep = TRUE;
mapObject->mapobj_bit_26 = 1;
task->data[0]++;
return FALSE;
@@ -2893,7 +2893,7 @@ void sub_8088984(struct Task *task)
{
ScriptContext2_Enable();
FreezeMapObjects();
- gPlayerAvatar.unk6 = 1;
+ gPlayerAvatar.preventStep = TRUE;
SetPlayerAvatarStateMask(8);
PlayerGetDestCoords(&task->data[1], &task->data[2]);
MoveCoords(gMapObjects[gPlayerAvatar.mapObjectId].placeholder18, &task->data[1], &task->data[2]);
@@ -2947,7 +2947,7 @@ void sub_8088AF4(struct Task *task)
mapObject = &gMapObjects[gPlayerAvatar.mapObjectId];
if (FieldObjectClearAnimIfSpecialAnimFinished(mapObject))
{
- gPlayerAvatar.unk6 = 0;
+ gPlayerAvatar.preventStep = FALSE;
gPlayerAvatar.flags &= 0xdf;
FieldObjectSetSpecialAnim(mapObject, GetFaceDirectionAnimId(mapObject->placeholder18));
sub_8127ED0(mapObject->mapobj_unk_1A, 1);
@@ -3024,7 +3024,7 @@ void sub_8088CA0(struct Task *task)
if (!FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive(mapObject) || FieldObjectClearAnimIfSpecialAnimFinished(mapObject))
{
task->data[15] = gPlayerAvatar.flags;
- gPlayerAvatar.unk6 = 0x01;
+ gPlayerAvatar.preventStep = TRUE;
SetPlayerAvatarStateMask(1);
sub_8059BF4();
FieldObjectSetSpecialAnim(mapObject, 0x39);
@@ -3296,7 +3296,7 @@ void sub_80892A0(struct Task *task)
task->data[0]++;
task->data[2] = 17;
task->data[15] = gPlayerAvatar.flags;
- gPlayerAvatar.unk6 = 1;
+ gPlayerAvatar.preventStep = TRUE;
SetPlayerAvatarStateMask(0x01);
if (task->data[15] & 0x08)
{
@@ -3398,7 +3398,7 @@ void fishE(struct Task *task)
sub_805B980(mapObject, GetPlayerAvatarGraphicsIdByStateId(state));
FieldObjectTurn(mapObject, DIR_SOUTH);
gPlayerAvatar.flags = task->data[15];
- gPlayerAvatar.unk6 = 0;
+ gPlayerAvatar.preventStep = FALSE;
FieldEffectActiveListRemove(FLDEFF_FLY_IN);
DestroyTask(FindTaskIdByFunc(sub_8089270));
}
diff --git a/src/field/field_map_obj.c b/src/field/field_map_obj.c
index 0cba448a9..094e70107 100644
--- a/src/field/field_map_obj.c
+++ b/src/field/field_map_obj.c
@@ -1578,13 +1578,13 @@ void (*const gUnknown_0836DA88[])(struct Sprite *) =
const u8 gUnknown_0836DBBC[] = {0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
const u8 gUnknown_0836DC09[] = {DIR_SOUTH, DIR_SOUTH, DIR_SOUTH, DIR_NORTH, DIR_SOUTH, DIR_WEST, DIR_EAST, DIR_NORTH, DIR_SOUTH, DIR_WEST, DIR_EAST, DIR_SOUTH, DIR_SOUTH, DIR_SOUTH, DIR_WEST, DIR_NORTH, DIR_NORTH, DIR_SOUTH, DIR_SOUTH, DIR_SOUTH, DIR_SOUTH, DIR_NORTH, DIR_SOUTH, DIR_SOUTH, DIR_SOUTH, DIR_NORTH, DIR_SOUTH, DIR_WEST, DIR_EAST, DIR_NORTH, DIR_EAST, DIR_SOUTH, DIR_WEST, DIR_NORTH, DIR_WEST, DIR_SOUTH, DIR_EAST, DIR_WEST, DIR_NORTH, DIR_EAST, DIR_SOUTH, DIR_EAST, DIR_NORTH, DIR_WEST, DIR_SOUTH, DIR_NORTH, DIR_SOUTH, DIR_WEST, DIR_EAST, DIR_NORTH, DIR_SOUTH, DIR_WEST, DIR_EAST, DIR_NORTH, DIR_SOUTH, DIR_WEST, DIR_EAST, DIR_SOUTH, DIR_SOUTH, DIR_NORTH, DIR_SOUTH, DIR_WEST, DIR_EAST, DIR_SOUTH, DIR_SOUTH, DIR_NORTH, DIR_WEST, DIR_EAST, DIR_SOUTH, DIR_NORTH, DIR_WEST, DIR_EAST, DIR_SOUTH, DIR_NORTH, DIR_WEST, DIR_EAST, DIR_SOUTH};
-#include "data/field_map_obj/map_object_graphics_info_pointers.h"
-#include "data/field_map_obj/field_effect_object_template_pointers.h"
-#include "data/field_map_obj/map_object_pic_tables.h"
-#include "data/field_map_obj/map_object_anims.h"
-#include "data/field_map_obj/base_oam.h"
-#include "data/field_map_obj/map_object_subsprites.h"
-#include "data/field_map_obj/map_object_graphics_info.h"
+#include "../data/field_map_obj/map_object_graphics_info_pointers.h"
+#include "../data/field_map_obj/field_effect_object_template_pointers.h"
+#include "../data/field_map_obj/map_object_pic_tables.h"
+#include "../data/field_map_obj/map_object_anims.h"
+#include "../data/field_map_obj/base_oam.h"
+#include "../data/field_map_obj/map_object_subsprites.h"
+#include "../data/field_map_obj/map_object_graphics_info.h"
const struct SpritePalette gUnknown_0837377C[] = {
{gMapObjectPalette0, 0x1103},
@@ -1790,14 +1790,14 @@ const u16 *const gUnknown_0837399C[] = {
Unknown_8373988
};
-#include "data/field_map_obj/berry_tree_graphics_tables.h"
-#include "data/field_map_obj/field_effect_objects.h"
+#include "../data/field_map_obj/berry_tree_graphics_tables.h"
+#include "../data/field_map_obj/field_effect_objects.h"
const s16 gUnknown_0837520C[] = {0x20, 0x40, 0x60, 0x80};
const s16 gUnknown_08375204[] = {0x20, 0x40, 0x80, 0xc0};
const s16 gUnknown_0837521C[] = {0x20, 0x30, 0x40, 0x50};
-#include "data/field_map_obj/callback_subroutine_pointers.h"
+#include "../data/field_map_obj/callback_subroutine_pointers.h"
const u8 gUnknown_083755F4[] = {0x00, 0x00, 0x01, 0x02, 0x03, 0x00, 0x00, 0x01, 0x01};
const u8 gUnknown_083755FD[] = {0x04, 0x04, 0x05, 0x06, 0x07, 0x04, 0x04, 0x05, 0x05};
@@ -1886,7 +1886,7 @@ const u8 gUnknown_08375767[][4] = {
{3, 4, 2, 1}
};
-#include "data/field_map_obj/anim_func_ptrs.h"
+#include "../data/field_map_obj/anim_func_ptrs.h"
// text
@@ -5010,7 +5010,7 @@ u8 mss_npc_reset_oampriv3_1_unk2_unk3(struct MapObject *mapObject, struct Sprite
u8 sub_805F364(struct MapObject *mapObject, struct Sprite *sprite)
{
- if (gMapObjects[gPlayerAvatar.mapObjectId].mapobj_unk_1C == 0xFF || gPlayerAvatar.running1 == 2)
+ if (gMapObjects[gPlayerAvatar.mapObjectId].mapobj_unk_1C == 0xFF || gPlayerAvatar.tileTransitionState == T_TILE_CENTER)
{
return 0;
}
@@ -5172,7 +5172,7 @@ fieldmap_object_cb(sub_805F8E0, sub_805F904, gUnknown_083755C0);
u8 mss_08062EA4(struct MapObject *mapObject, struct Sprite *sprite)
{
- if (gMapObjects[gPlayerAvatar.mapObjectId].mapobj_unk_1C == 0xFF || gPlayerAvatar.running1 == 2)
+ if (gMapObjects[gPlayerAvatar.mapObjectId].mapobj_unk_1C == 0xFF || gPlayerAvatar.tileTransitionState == T_TILE_CENTER)
{
return 0;
}
@@ -5549,17 +5549,16 @@ static bool8 DoesObjectCollideWithObjectAt(struct MapObject *mapObject, s16 x, s
return 0;
}
-bool8 sub_8060234(u8 localId, u8 mapNum, u8 mapGroup)
+// this function is only used in berry.c, but its unknown whether its intended context is the berry tree check or if its checking for the flickering.
+bool8 IsBerryTreeSparkling(u8 localId, u8 mapNum, u8 mapGroup)
{
u8 mapObjectId;
+
if (!TryGetFieldObjectIdByLocalIdAndMap(localId, mapNum, mapGroup, &mapObjectId))
- {
if (gSprites[gMapObjects[mapObjectId].spriteId].data7 & 2)
- {
- return 1;
- }
- }
- return 0;
+ return TRUE;
+
+ return FALSE;
}
void sub_8060288(u8 localId, u8 mapNum, u8 mapGroup)
diff --git a/src/field/field_player_avatar.c b/src/field/field_player_avatar.c
index 6c1c9123a..e7da9b1b7 100644
--- a/src/field/field_player_avatar.c
+++ b/src/field/field_player_avatar.c
@@ -31,7 +31,7 @@ static bool8 sub_8058854(struct MapObject *, u8);
static void npc_clear_strange_bits(struct MapObject *a);
static void MovePlayerAvatarUsingKeypadInput(u8 a, u16 b, u16 c);
static void PlayerAllowForcedMovementIfMovingSameDirection(void);
-static u8 TryDoMetatileBehaviorForcedMovement(void);
+static bool8 TryDoMetatileBehaviorForcedMovement(void);
static u8 GetForcedMovementByMetatileBehavior(void);
static void MovePlayerNotOnBike(u8 a, u16 b);
static u8 CheckMovementInputNotOnBike(u8 a);
@@ -49,7 +49,7 @@ static void PlayerNotOnBikeCollide(u8 a);
static void PlayCollisionSoundIfNotFacingWarp(u8 a);
static void sub_8059D60(struct MapObject *a);
static void StartStrengthAnim(u8 a, u8 b);
-static void sub_8059F94(void);
+static void DoPlayerMatJump(void);
static void sub_805A06C(void);
static bool8 (*const gUnknown_0830FB58[])(u8) =
@@ -73,7 +73,7 @@ static bool8 (*const gUnknown_0830FB58[])(u8) =
MetatileBehavior_0xBC,
MetatileBehavior_IsMuddySlope,
};
-static u8 (*const gUnknown_0830FBA0[])(void) =
+static bool8 (*const gUnknown_0830FBA0[])(void) =
{
ForcedMovement_None,
ForcedMovement_Slip,
@@ -91,7 +91,7 @@ static u8 (*const gUnknown_0830FBA0[])(void) =
ForcedMovement_SlideWest,
ForcedMovement_SlideEast,
sub_8058B0C,
- sub_8058C04,
+ ForcedMovement_MatJump,
sub_8058C10,
ForcedMovement_MuddySlope,
};
@@ -182,9 +182,9 @@ static u8 (*const gUnknown_0830FC88[])(struct Task *, struct MapObject *, struct
sub_8059EA4,
sub_8059F40,
};
-static u8 (*const gUnknown_0830FC94[])(struct Task *, struct MapObject *) =
+static u8 (*const sPlayerAvatarSecretBaseMatJump[])(struct Task *, struct MapObject *) =
{
- sub_805A000,
+ PlayerAvatar_DoSecretBaseMatJump,
};
static u8 (*const gUnknown_0830FC98[])(struct Task *, struct MapObject *) =
{
@@ -201,9 +201,9 @@ void player_step(u8 direction, u16 newKeys, u16 heldKeys)
struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
sub_8059D60(playerMapObj);
- if (gPlayerAvatar.unk6 == 0)
+ if (gPlayerAvatar.preventStep == FALSE)
{
- sub_80E5B38(newKeys, heldKeys);
+ Bike_TryAcroBikeHistoryUpdate(newKeys, heldKeys);
if (!sub_8058854(playerMapObj, direction))
{
npc_clear_strange_bits(playerMapObj);
@@ -256,11 +256,11 @@ static void MovePlayerAvatarUsingKeypadInput(u8 direction, u16 newKeys, u16 held
static void PlayerAllowForcedMovementIfMovingSameDirection(void)
{
- if (gPlayerAvatar.running2 == 2)
+ if (gPlayerAvatar.runningState == MOVING)
gPlayerAvatar.flags &= ~PLAYER_AVATAR_FLAG_5;
}
-static u8 TryDoMetatileBehaviorForcedMovement(void)
+static bool8 TryDoMetatileBehaviorForcedMovement(void)
{
return gUnknown_0830FBA0[GetForcedMovementByMetatileBehavior()]();
}
@@ -282,7 +282,7 @@ static u8 GetForcedMovementByMetatileBehavior(void)
return 0;
}
-u8 ForcedMovement_None(void)
+bool8 ForcedMovement_None(void)
{
if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_6)
{
@@ -293,7 +293,7 @@ u8 ForcedMovement_None(void)
FieldObjectSetDirection(playerMapObj, playerMapObj->mapobj_unk_18);
gPlayerAvatar.flags &= ~PLAYER_AVATAR_FLAG_6;
}
- return 0;
+ return FALSE;
}
static u8 DoForcedMovement(u8 direction, void (*b)(u8))
@@ -314,13 +314,13 @@ static u8 DoForcedMovement(u8 direction, void (*b)(u8))
if (collisionType == COLLISION_LEDGE_JUMP)
PlayerJumpLedge(direction);
playerAvatar->flags |= PLAYER_AVATAR_FLAG_6;
- playerAvatar->running2 = 2;
+ playerAvatar->runningState = MOVING;
return 1;
}
}
else
{
- playerAvatar->running2 = 2;
+ playerAvatar->runningState = MOVING;
b(direction);
return 1;
}
@@ -334,47 +334,47 @@ static u8 DoForcedMovementInCurrentDirection(void (*a)(u8))
return DoForcedMovement(playerMapObj->placeholder18, a);
}
-u8 ForcedMovement_Slip(void)
+bool8 ForcedMovement_Slip(void)
{
- return DoForcedMovementInCurrentDirection(sub_80593C4);
+ return DoForcedMovementInCurrentDirection(PlayerGoSpeed2);
}
-u8 sub_8058AAC(void)
+bool8 sub_8058AAC(void)
{
- return DoForcedMovement(1, PlayerGoSpeed0);
+ return DoForcedMovement(1, PlayerGoSpeed1);
}
-u8 sub_8058AC4(void)
+bool8 sub_8058AC4(void)
{
- return DoForcedMovement(2, PlayerGoSpeed0);
+ return DoForcedMovement(2, PlayerGoSpeed1);
}
-u8 sub_8058ADC(void)
+bool8 sub_8058ADC(void)
{
- return DoForcedMovement(3, PlayerGoSpeed0);
+ return DoForcedMovement(3, PlayerGoSpeed1);
}
-u8 sub_8058AF4(void)
+bool8 sub_8058AF4(void)
{
- return DoForcedMovement(4, PlayerGoSpeed0);
+ return DoForcedMovement(4, PlayerGoSpeed1);
}
-u8 sub_8058B0C(void)
+bool8 sub_8058B0C(void)
{
return DoForcedMovement(1, npc_use_some_d2s);
}
-u8 sub_8058B24(void)
+bool8 sub_8058B24(void)
{
return DoForcedMovement(2, npc_use_some_d2s);
}
-u8 sub_8058B3C(void)
+bool8 sub_8058B3C(void)
{
return DoForcedMovement(3, npc_use_some_d2s);
}
-u8 sub_8058B54(void)
+bool8 sub_8058B54(void)
{
return DoForcedMovement(4, npc_use_some_d2s);
}
@@ -388,51 +388,51 @@ static u8 ForcedMovement_Slide(u8 direction, void (*b)(u8))
return DoForcedMovement(direction, b);
}
-u8 ForcedMovement_SlideSouth(void)
+bool8 ForcedMovement_SlideSouth(void)
{
- return ForcedMovement_Slide(1, sub_80593C4);
+ return ForcedMovement_Slide(1, PlayerGoSpeed2);
}
-u8 ForcedMovement_SlideNorth(void)
+bool8 ForcedMovement_SlideNorth(void)
{
- return ForcedMovement_Slide(2, sub_80593C4);
+ return ForcedMovement_Slide(2, PlayerGoSpeed2);
}
-u8 ForcedMovement_SlideWest(void)
+bool8 ForcedMovement_SlideWest(void)
{
- return ForcedMovement_Slide(3, sub_80593C4);
+ return ForcedMovement_Slide(3, PlayerGoSpeed2);
}
-u8 ForcedMovement_SlideEast(void)
+bool8 ForcedMovement_SlideEast(void)
{
- return ForcedMovement_Slide(4, sub_80593C4);
+ return ForcedMovement_Slide(4, PlayerGoSpeed2);
}
-u8 sub_8058C04(void)
+bool8 ForcedMovement_MatJump(void)
{
- sub_8059F94();
- return 1;
+ DoPlayerMatJump();
+ return TRUE;
}
-u8 sub_8058C10(void)
+bool8 sub_8058C10(void)
{
sub_805A06C();
- return 1;
+ return TRUE;
}
-u8 ForcedMovement_MuddySlope(void)
+bool8 ForcedMovement_MuddySlope(void)
{
struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
if (playerMapObj->placeholder18 != 2 || GetPlayerSpeed() <= 3)
{
- sub_80E6010(0);
+ Bike_UpdateBikeCounterSpeed(0);
playerMapObj->mapobj_bit_9 = 1;
- return DoForcedMovement(1, sub_80593C4);
+ return DoForcedMovement(1, PlayerGoSpeed2);
}
else
{
- return 0;
+ return FALSE;
}
}
@@ -445,17 +445,17 @@ static u8 CheckMovementInputNotOnBike(u8 direction)
{
if (direction == DIR_NONE)
{
- gPlayerAvatar.running2 = 0;
+ gPlayerAvatar.runningState = NOT_MOVING;
return 0;
}
- else if (direction != player_get_direction_upper_nybble() && gPlayerAvatar.running2 != 2)
+ else if (direction != player_get_direction_upper_nybble() && gPlayerAvatar.runningState != MOVING)
{
- gPlayerAvatar.running2 = 1;
+ gPlayerAvatar.runningState = TURN_DIRECTION;
return 1;
}
else
{
- gPlayerAvatar.running2 = 2;
+ gPlayerAvatar.runningState = MOVING;
return 2;
}
}
@@ -486,7 +486,8 @@ void sub_8058D0C(u8 direction, u16 heldKeys)
case 0:
if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_SURFING)
{
- sub_80593C4(direction);
+ // speed 2 is fast, same speed as running
+ PlayerGoSpeed2(direction);
return;
}
if (!(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_4) && (heldKeys & B_BUTTON) && FlagGet(SYS_B_DASH)
@@ -497,7 +498,7 @@ void sub_8058D0C(u8 direction, u16 heldKeys)
}
else
{
- PlayerGoSpeed0(direction);
+ PlayerGoSpeed1(direction);
}
}
}
@@ -601,14 +602,14 @@ static void check_acro_bike_metatile(int unused1, int unused2, u8 c, u8 *d)
void SetPlayerAvatarTransitionFlags(u16 a)
{
- gPlayerAvatar.bike |= a;
+ gPlayerAvatar.unk1 |= a;
DoPlayerAvatarTransition();
}
static void DoPlayerAvatarTransition(void)
{
u8 i;
- u32 flags = gPlayerAvatar.bike;
+ u32 flags = gPlayerAvatar.unk1;
if (flags != 0)
{
@@ -627,7 +628,7 @@ static void DoPlayerAvatarTransition(void)
}
#endif
}
- gPlayerAvatar.bike = 0;
+ gPlayerAvatar.unk1 = 0;
}
}
@@ -656,7 +657,7 @@ void PlayerAvatarTransition_AcroBike(struct MapObject *a)
FieldObjectTurn(a, a->placeholder18);
SetPlayerAvatarStateMask(4);
BikeClearState(0, 0);
- sub_80E6084();
+ Bike_HandleBumpySlopeJump();
}
void PlayerAvatarTransition_Surfing(struct MapObject *a)
@@ -689,18 +690,18 @@ void sub_80591F4(struct MapObject *a)
void sub_8059204(void)
{
- gPlayerAvatar.running1 = 0;
+ gPlayerAvatar.tileTransitionState = T_NOT_MOVING;
if (PlayerIsAnimActive())
{
if (!PlayerCheckIfAnimFinishedOrInactive())
{
if (!player_is_anim_in_certain_ranges())
- gPlayerAvatar.running1 = 1;
+ gPlayerAvatar.tileTransitionState = T_TILE_TRANSITION;
}
else
{
if (!sub_80592A4())
- gPlayerAvatar.running1 = 2;
+ gPlayerAvatar.tileTransitionState = T_TILE_CENTER;
}
}
}
@@ -721,7 +722,7 @@ static bool8 player_is_anim_in_certain_ranges(void)
static bool8 sub_80592A4(void)
{
- if (player_is_anim_in_certain_ranges() && gPlayerAvatar.running2 != 1)
+ if (player_is_anim_in_certain_ranges() && gPlayerAvatar.runningState != TURN_DIRECTION)
return TRUE;
else
return FALSE;
@@ -761,12 +762,14 @@ void PlayerSetAnimId(u8 animId, u8 b)
}
}
-void PlayerGoSpeed0(u8 a)
+// normal speed (1 speed)
+void PlayerGoSpeed1(u8 a)
{
PlayerSetAnimId(GetGoSpeed0AnimId(a), 2);
}
-void sub_80593C4(u8 a)
+// fast speed (2 speed)
+void PlayerGoSpeed2(u8 a)
{
PlayerSetAnimId(sub_8060744(a), 2);
}
@@ -776,7 +779,8 @@ void npc_use_some_d2s(u8 a)
PlayerSetAnimId(d2s_08064034(a), 2);
}
-void sub_80593F4(u8 a)
+// fastest speed (4 speed)
+void PlayerGoSpeed4(u8 a)
{
PlayerSetAnimId(sub_806079C(a), 2);
}
@@ -816,48 +820,54 @@ void PlayerJumpLedge(u8 direction)
void sub_80594C0(void)
{
- if (gPlayerAvatar.running1 == 2 || gPlayerAvatar.running1 == 0)
+ if (gPlayerAvatar.tileTransitionState == T_TILE_CENTER || gPlayerAvatar.tileTransitionState == T_NOT_MOVING)
{
if (player_should_look_direction_be_enforced_upon_movement())
sub_8059348(GetFaceDirectionAnimId(gMapObjects[gPlayerAvatar.mapObjectId].mapobj_unk_18));
}
}
-void sub_8059504(u8 a)
+// wheelie idle
+void PlayerIdleWheelie(u8 a)
{
PlayerSetAnimId(sub_80609D8(a), 1);
}
-//normal to wheelie
+// normal to wheelie
void PlayerStartWheelie(u8 a)
{
PlayerSetAnimId(sub_8060A04(a), 1);
}
-void sub_8059534(u8 a)
+// wheelie to normal
+void PlayerEndWheelie(u8 a)
{
PlayerSetAnimId(sub_8060A30(a), 1);
}
-void sub_805954C(u8 a)
+// wheelie hopping standing
+void PlayerStandingHoppingWheelie(u8 a)
{
PlaySE(SE_JITE_PYOKO);
PlayerSetAnimId(sub_8060A5C(a), 1);
}
-void sub_8059570(u8 a)
+// wheelie hopping moving
+void PlayerMovingHoppingWheelie(u8 a)
{
PlaySE(SE_JITE_PYOKO);
PlayerSetAnimId(sub_8060A88(a), 2);
}
-void sub_8059594(u8 a)
+// wheelie hopping ledge
+void PlayerLedgeHoppingWheelie(u8 a)
{
PlaySE(SE_JITE_PYOKO);
PlayerSetAnimId(sub_8060AB4(a), 8);
}
-void sub_80595B8(u8 direction)
+// acro turn jump
+void PlayerAcroTurnJump(u8 direction)
{
PlaySE(SE_JITE_PYOKO);
PlayerSetAnimId(sub_8060878(direction), 1);
@@ -963,8 +973,8 @@ void sub_80597F4(void)
FieldObjectSetDirection(playerMapObj, playerMapObj->mapobj_unk_18);
if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_MACH_BIKE | PLAYER_AVATAR_FLAG_ACRO_BIKE))
{
- sub_80E6084();
- sub_80E6010(0);
+ Bike_HandleBumpySlopeJump();
+ Bike_UpdateBikeCounterSpeed(0);
}
}
@@ -1060,7 +1070,6 @@ bool8 IsPlayerFacingSurfableFishableWater(void)
void ClearPlayerAvatarInfo(void)
{
- //TODO: 0x24 should be the size of gPlayerAvatar
memset(&gPlayerAvatar, 0, sizeof(struct PlayerAvatar));
}
@@ -1099,7 +1108,7 @@ void SetPlayerAvatarExtraStateTransition(u8 a, u8 b)
{
u8 unk = GetPlayerAvatarStateTransitionByGraphicsId(a, gPlayerAvatar.gender);
- gPlayerAvatar.bike |= unk | b;
+ gPlayerAvatar.unk1 |= unk | b;
DoPlayerAvatarTransition();
}
@@ -1127,8 +1136,8 @@ void InitPlayerAvatar(s16 x, s16 y, u8 direction, u8 gender)
mapObject->mapobj_unk_1B = sub_8126B54();
FieldObjectTurn(mapObject, direction);
ClearPlayerAvatarInfo();
- gPlayerAvatar.running2 = 0;
- gPlayerAvatar.running1 = 0;
+ gPlayerAvatar.runningState = NOT_MOVING;
+ gPlayerAvatar.tileTransitionState = T_NOT_MOVING;
gPlayerAvatar.mapObjectId = mapObjectId;
gPlayerAvatar.spriteId = mapObject->spriteId;
gPlayerAvatar.gender = gender;
@@ -1212,7 +1221,7 @@ static void sub_8059E2C(u8 taskId)
u8 sub_8059E84(struct Task *task, struct MapObject *b, struct MapObject *c)
{
ScriptContext2_Enable();
- gPlayerAvatar.unk6 = 1;
+ gPlayerAvatar.preventStep = TRUE;
task->data[0]++;
return 0;
}
@@ -1244,7 +1253,7 @@ u8 sub_8059F40(struct Task *task, struct MapObject *b, struct MapObject *c)
{
FieldObjectClearAnimIfSpecialAnimFinished(b);
FieldObjectClearAnimIfSpecialAnimFinished(c);
- gPlayerAvatar.unk6 = 0;
+ gPlayerAvatar.preventStep = FALSE;
ScriptContext2_Disable();
DestroyTask(FindTaskIdByFunc(sub_8059E2C));
}
@@ -1253,24 +1262,23 @@ u8 sub_8059F40(struct Task *task, struct MapObject *b, struct MapObject *c)
/* Some field effect */
-static void sub_8059FB4(u8 taskId);
+static void DoPlayerAvatarSecretBaseMatJump(u8 taskId);
-static void sub_8059F94(void)
+static void DoPlayerMatJump(void)
{
- u8 taskId = CreateTask(sub_8059FB4, 0xFF);
-
- sub_8059FB4(taskId);
+ DoPlayerAvatarSecretBaseMatJump(CreateTask(DoPlayerAvatarSecretBaseMatJump, 0xFF));
}
-static void sub_8059FB4(u8 taskId)
+static void DoPlayerAvatarSecretBaseMatJump(u8 taskId)
{
- while (gUnknown_0830FC94[gTasks[taskId].data[0]](&gTasks[taskId], &gMapObjects[gPlayerAvatar.mapObjectId]))
+ while (sPlayerAvatarSecretBaseMatJump[gTasks[taskId].data[0]](&gTasks[taskId], &gMapObjects[gPlayerAvatar.mapObjectId]))
;
}
-u8 sub_805A000(struct Task *task, struct MapObject *mapObject)
+// because data[0] is used to call this, it can be inferred that there may have been multiple mat jump functions at one point, so the name for these groups of functions is appropriate in assuming the sole use of mat jump.
+u8 PlayerAvatar_DoSecretBaseMatJump(struct Task *task, struct MapObject *mapObject)
{
- gPlayerAvatar.unk6 = 1;
+ gPlayerAvatar.preventStep = TRUE;
if (FieldObjectClearAnimIfSpecialAnimFinished(mapObject))
{
PlaySE(SE_DANSA);
@@ -1278,9 +1286,9 @@ u8 sub_805A000(struct Task *task, struct MapObject *mapObject)
task->data[1]++;
if (task->data[1] > 1)
{
- gPlayerAvatar.unk6 = 0;
- gPlayerAvatar.bike |= 0x20;
- DestroyTask(FindTaskIdByFunc(sub_8059FB4));
+ gPlayerAvatar.preventStep = FALSE;
+ gPlayerAvatar.unk1 |= 0x20;
+ DestroyTask(FindTaskIdByFunc(DoPlayerAvatarSecretBaseMatJump));
}
}
return 0;
@@ -1307,7 +1315,7 @@ u8 sub_805A0D8(struct Task *task, struct MapObject *mapObject)
{
task->data[0]++;
task->data[1] = mapObject->placeholder18;
- gPlayerAvatar.unk6 = 1;
+ gPlayerAvatar.preventStep = TRUE;
ScriptContext2_Enable();
PlaySE(SE_TK_WARPIN);
return 1;
@@ -1349,7 +1357,7 @@ u8 sub_805A1B8(struct Task *task, struct MapObject *mapObject)
{
FieldObjectSetSpecialAnim(mapObject, GetSimpleGoAnimId(GetOppositeDirection(task->data[1])));
ScriptContext2_Disable();
- gPlayerAvatar.unk6 = 0;
+ gPlayerAvatar.preventStep = FALSE;
DestroyTask(FindTaskIdByFunc(sub_805A08C));
}
return 0;
@@ -1369,7 +1377,7 @@ void sub_805A20C(u8 a)
Overworld_ChangeMusicToDefault();
gPlayerAvatar.flags &= ~PLAYER_AVATAR_FLAG_SURFING;
gPlayerAvatar.flags |= PLAYER_AVATAR_FLAG_ON_FOOT;
- gPlayerAvatar.unk6 = 1;
+ gPlayerAvatar.preventStep = TRUE;
taskId = CreateTask(taskFF_0805D1D4, 0xFF);
gTasks[taskId].data[0] = a;
taskFF_0805D1D4(taskId);
@@ -1397,7 +1405,7 @@ static void sub_805A2D0(u8 taskId)
{
sub_805B980(playerMapObj, GetPlayerAvatarGraphicsIdByStateId(0));
FieldObjectSetSpecialAnim(playerMapObj, GetFaceDirectionAnimId(playerMapObj->mapobj_unk_18));
- gPlayerAvatar.unk6 = 0;
+ gPlayerAvatar.preventStep = FALSE;
ScriptContext2_Disable();
DestroySprite(&gSprites[playerMapObj->mapobj_unk_1A]);
DestroyTask(taskId);
@@ -1462,7 +1470,7 @@ static void Task_Fishing(u8 taskId)
u8 Fishing1(struct Task *task)
{
ScriptContext2_Enable();
- gPlayerAvatar.unk6 = 1;
+ gPlayerAvatar.preventStep = TRUE;
task->tStep++;
return 0;
}
@@ -1647,7 +1655,7 @@ u8 Fishing11(struct Task *task)
if (task->tFrameCounter != 0)
{
- gPlayerAvatar.unk6 = 0;
+ gPlayerAvatar.preventStep = FALSE;
ScriptContext2_Disable();
FishingWildEncounter(task->tFishingRod);
sub_80BE97C(1);
@@ -1707,7 +1715,7 @@ u8 Fishing16(struct Task *task)
{
if (MenuUpdateWindowText())
{
- gPlayerAvatar.unk6 = 0;
+ gPlayerAvatar.preventStep = FALSE;
ScriptContext2_Disable();
UnfreezeMapObjects();
MenuZeroFillScreen();
diff --git a/src/field/field_special_scene.c b/src/field/field_special_scene.c
index d4b59c8a2..5758929b6 100644
--- a/src/field/field_special_scene.c
+++ b/src/field/field_special_scene.c
@@ -18,6 +18,52 @@
#define SECONDS(value) ((signed) (60.0 * value + 0.5))
+// TODO: Move somewhere else
+enum
+{
+ STEP_17 = 0x17,
+ STEP_18,
+ STEP_END = 0xFE,
+};
+
+const u32 gMapObjectPic_MovingBox[] = INCBIN_U32("graphics/map_objects/pics/misc/moving_box.4bpp");
+const u16 gMapObjectPalette19[] = INCBIN_U16("graphics/map_objects/palettes/19.gbapal");
+
+static const s8 gTruckCamera_HorizontalTable[] =
+{
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 1,
+ 2,
+ 2,
+ 2,
+ 2,
+ 2,
+ 2,
+ -1,
+ -1,
+ -1,
+ 0,
+};
+
+const u8 gUnknown_083D295F[] =
+{
+ STEP_18,
+ STEP_END,
+};
+
+const u8 gUnknown_083D2961[] =
+{
+ STEP_17,
+ STEP_END,
+};
+
// porthole states
enum
{
@@ -27,12 +73,7 @@ enum
EXIT_PORTHOLE,
};
-extern s8 gTruckCamera_HorizontalTable[];
-
-extern u8 gUnknown_083D295F[];
-extern u8 gUnknown_083D2961[];
-
-s32 GetTruckCameraBobbingY(int a1)
+s16 GetTruckCameraBobbingY(int a1)
{
if (!(a1 % 120))
return -1;
@@ -42,7 +83,7 @@ s32 GetTruckCameraBobbingY(int a1)
return 0;
}
-s32 GetTruckBoxMovement(int a1) // for the box movement?
+s16 GetTruckBoxMovement(int a1) // for the box movement?
{
if (!((a1 + 120) % 180))
return -1;
@@ -53,28 +94,22 @@ s32 GetTruckBoxMovement(int a1) // for the box movement?
void Task_Truck1(u8 taskId)
{
s16 *data = gTasks[taskId].data;
- s16 cameraYpan;
- s16 box1 = 0;
- s16 box2 = 0;
- s16 box3 = 0;
- u8 mapNum, mapGroup;
- register s16 zero asm("r4");
+ s16 cameraYpan, cameraXpan = 0;
+ s16 box1, box2, box3;
box1 = GetTruckBoxMovement(data[0] + 30) * 4; // top box.
- sub_805BD90(1, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup, 3, box1 + 3);
+ sub_805BD90(1, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup, 3 - cameraXpan, box1 + 3);
box2 = GetTruckBoxMovement(data[0]) * 2; // bottom left box.
- sub_805BD90(2, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup, 0, box2 - 3);
+ sub_805BD90(2, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup, -cameraXpan, box2 - 3);
box3 = GetTruckBoxMovement(data[0]) * 4; // bottom right box.
- mapNum = gSaveBlock1.location.mapNum;
- mapGroup = gSaveBlock1.location.mapGroup;
- zero = 0;
- sub_805BD90(3, mapNum, mapGroup, -3, box3);
+ sub_805BD90(3, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup, -3 - cameraXpan, box3);
if (++data[0] == SECONDS(500)) // this will never run
- data[0] = zero; // reset the timer if it gets stuck.
+ data[0] = 0; // reset the timer if it gets stuck.
+ // this also matches with directly calling GetTruckCameraBobbingY within SetCameraPanning, but this is consistent with a later function that requires a temp variable.
cameraYpan = GetTruckCameraBobbingY(data[0]);
- SetCameraPanning(0, cameraYpan);
+ SetCameraPanning(cameraXpan, cameraYpan);
}
void Task_Truck2(u8 taskId)
@@ -82,9 +117,7 @@ void Task_Truck2(u8 taskId)
s16 *data = gTasks[taskId].data;
s16 cameraYpan;
s16 cameraXpan;
- s16 box1;
- s16 box2;
- s16 box3;
+ s16 box1, box2, box3;
data[0]++;
data[2]++;
@@ -137,7 +170,7 @@ void Task_Truck3(u8 taskId)
{
cameraXpan = gTruckCamera_HorizontalTable[data[1]];
cameraYpan = 0;
- SetCameraPanning(cameraXpan, 0);
+ SetCameraPanning(cameraXpan, cameraYpan);
sub_805BD90(1, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup, 3 - cameraXpan, cameraYpan + 3);
sub_805BD90(2, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup, -cameraXpan, cameraYpan - 3);
sub_805BD90(3, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup, -3 - cameraXpan, cameraYpan);
diff --git a/src/field/field_specials.c b/src/field/field_specials.c
index ea0c2bd6a..d67cbe54f 100644
--- a/src/field/field_specials.c
+++ b/src/field/field_specials.c
@@ -48,9 +48,9 @@ extern u16 gSpecialVar_0x8004;
extern u16 gSpecialVar_0x8005;
extern u16 gScriptResult;
-EWRAM_DATA u8 gUnknown_02039250 = 0;
-EWRAM_DATA u8 gUnknown_02039251 = 0;
-EWRAM_DATA u32 gUnknown_02039254 = 0;
+EWRAM_DATA bool8 gBikeCyclingChallenge = FALSE;
+EWRAM_DATA u8 gBikeCollisions = 0;
+EWRAM_DATA u32 gBikeCyclingTimer = 0;
EWRAM_DATA u8 gUnknown_02039258 = 0;
EWRAM_DATA u8 gUnknown_02039259 = 0;
EWRAM_DATA u8 gUnknown_0203925A = 0;
@@ -76,16 +76,16 @@ void ScrSpecial_ViewWallClock(void)
void ResetCyclingRoadChallengeData(void)
{
- gUnknown_02039250 = 0;
- gUnknown_02039251 = 0;
- gUnknown_02039254 = 0;
+ gBikeCyclingChallenge = FALSE;
+ gBikeCollisions = 0;
+ gBikeCyclingTimer = 0;
}
void ScrSpecial_BeginCyclingRoadChallenge(void)
{
- gUnknown_02039250 = 1;
- gUnknown_02039251 = 0;
- gUnknown_02039254 = gMain.vblankCounter1;
+ gBikeCyclingChallenge = TRUE;
+ gBikeCollisions = 0;
+ gBikeCyclingTimer = gMain.vblankCounter1;
}
u16 GetPlayerAvatarBike(void)
@@ -171,10 +171,10 @@ static void DetermineCyclingRoadResults(u32 arg0, u8 arg1)
}
void FinishCyclingRoadChallenge(void) {
- const u32 time = gMain.vblankCounter1 - gUnknown_02039254;
+ const u32 time = gMain.vblankCounter1 - gBikeCyclingTimer;
- DetermineCyclingRoadResults(time, gUnknown_02039251);
- RecordCyclingRoadResults(time, gUnknown_02039251);
+ DetermineCyclingRoadResults(time, gBikeCollisions);
+ RecordCyclingRoadResults(time, gBikeCollisions);
}
static void RecordCyclingRoadResults(u32 arg0, u8 arg1) {
diff --git a/src/field/item_use.c b/src/field/item_use.c
index 68da27fdb..14b13ca3b 100644
--- a/src/field/item_use.c
+++ b/src/field/item_use.c
@@ -780,7 +780,7 @@ void ItemUseOutOfBattle_SSTicket(u8 taskId)
void sub_80C9C7C(u8 taskId)
{
- if (IsPlayerFacingPlantedBerryTree() == TRUE)
+ if (IsPlayerFacingUnplantedSoil() == TRUE)
{
gFieldItemUseCallback = sub_80C9D00;
gFieldCallback = ExecuteItemUseFromBlackPalette;
diff --git a/src/field/map_obj_lock.c b/src/field/map_obj_lock.c
index 2856320b8..91feaf177 100644
--- a/src/field/map_obj_lock.c
+++ b/src/field/map_obj_lock.c
@@ -10,7 +10,7 @@ extern u16 gScriptFacing;
bool8 walkrun_is_standing_still(void)
{
- if (gPlayerAvatar.running1 == 1)
+ if (gPlayerAvatar.tileTransitionState == T_TILE_TRANSITION)
return FALSE;
else
return TRUE;
diff --git a/src/field/party_menu.c b/src/field/party_menu.c
index 86ad9ecc9..a4c66d891 100644
--- a/src/field/party_menu.c
+++ b/src/field/party_menu.c
@@ -460,7 +460,7 @@ static const u8 StatDataTypes[] = {
MON_DATA_DEF,
MON_DATA_SPATK,
MON_DATA_SPDEF,
- MON_DATA_SPD,
+ MON_DATA_SPEED,
};
struct Unk201C000
diff --git a/src/field/script_movement.c b/src/field/script_movement.c
index 30e10b451..c7ce55171 100644
--- a/src/field/script_movement.c
+++ b/src/field/script_movement.c
@@ -5,19 +5,19 @@
#include "task.h"
#include "util.h"
-static EWRAM_DATA u8 *gUnknown_020384F8[16] = {0};
+static EWRAM_DATA const u8 *gUnknown_020384F8[16] = {0};
static void sub_80A2198(u8);
static u8 sub_80A21E0(void);
-static bool8 sub_80A21F4(u8, u8, u8 *);
+static bool8 sub_80A21F4(u8, u8, const u8 *);
static u8 sub_80A2260(u8, u8);
static bool8 sub_80A2370(u8, u8);
-static void sub_80A23C8(u8, u8, u8, u8 *);
+static void sub_80A23C8(u8, u8, u8, const u8 *);
static void UnfreezeObjects(u8);
static void Task_80A244C(u8);
-static void sub_80A2490(u8, u8, u8, u8 *);
+static void sub_80A2490(u8, u8, u8, const u8 *);
-bool8 ScriptMovement_StartObjectMovementScript(u8 localId, u8 mapNum, u8 mapGroup, u8 *movementScript)
+bool8 ScriptMovement_StartObjectMovementScript(u8 localId, u8 mapNum, u8 mapGroup, const u8 *movementScript)
{
u8 mapObjId;
@@ -70,7 +70,7 @@ static u8 sub_80A21E0(void)
return FindTaskIdByFunc(Task_80A244C);
}
-static bool8 sub_80A21F4(u8 taskId, u8 mapObjId, u8 *movementScript)
+static bool8 sub_80A21F4(u8 taskId, u8 mapObjId, const u8 *movementScript)
{
u8 r4;
@@ -160,17 +160,17 @@ static bool8 sub_80A2370(u8 taskId, u8 b)
return FALSE;
}
-static void npc_obj_offscreen_culling_and_flag_update(u8 a, u8 *movementScript)
+static void npc_obj_offscreen_culling_and_flag_update(u8 a, const u8 *movementScript)
{
gUnknown_020384F8[a] = movementScript;
}
-static u8 *sub_80A23B8(u8 a)
+static const u8 *sub_80A23B8(u8 a)
{
return gUnknown_020384F8[a];
}
-static void sub_80A23C8(u8 taskId, u8 b, u8 mapObjId, u8 *movementScript)
+static void sub_80A23C8(u8 taskId, u8 b, u8 mapObjId, const u8 *movementScript)
{
sub_80A2318(taskId, b);
npc_obj_offscreen_culling_and_flag_update(b, movementScript);
@@ -203,7 +203,7 @@ static void Task_80A244C(u8 taskId)
}
}
-static void sub_80A2490(u8 taskId, u8 b, u8 mapObjId, u8 *d)
+static void sub_80A2490(u8 taskId, u8 b, u8 mapObjId, const u8 *d)
{
u8 var;
diff --git a/src/field/secret_base.c b/src/field/secret_base.c
index f2ed6adb6..2bc94f118 100644
--- a/src/field/secret_base.c
+++ b/src/field/secret_base.c
@@ -72,54 +72,30 @@ const struct
const u8 gUnknown_083D1374[] = {
- MAP_ID_SECRET_BASE_RED_CAVE1, 0,
- MAP_ID_SECRET_BASE_BROWN_CAVE1, 3,
- MAP_ID_SECRET_BASE_RED_CAVE2, 0,
- MAP_ID_SECRET_BASE_SHRUB1, 9,
- MAP_ID_SECRET_BASE_RED_CAVE3, 0,
- MAP_ID_SECRET_BASE_BROWN_CAVE1, 3,
- MAP_ID_SECRET_BASE_RED_CAVE4, 0,
- MAP_ID_SECRET_BASE_BROWN_CAVE2, 13,
- MAP_ID_SECRET_BASE_BROWN_CAVE1, 0,
- MAP_ID_SECRET_BASE_BLUE_CAVE1, 3,
- MAP_ID_SECRET_BASE_BROWN_CAVE2, 0,
- MAP_ID_SECRET_BASE_YELLOW_CAVE2, 2,
- MAP_ID_SECRET_BASE_BROWN_CAVE3, 0,
- MAP_ID_SECRET_BASE_BROWN_CAVE3, 4,
- MAP_ID_SECRET_BASE_BROWN_CAVE4, 0,
- MAP_ID_SECRET_BASE_BROWN_CAVE1, 2,
- MAP_ID_SECRET_BASE_BLUE_CAVE1, 0,
- MAP_ID_SECRET_BASE_BROWN_CAVE1, 3,
- MAP_ID_SECRET_BASE_BLUE_CAVE2, 0,
- MAP_ID_SECRET_BASE_BROWN_CAVE1, 2,
- MAP_ID_SECRET_BASE_BLUE_CAVE3, 0,
- MAP_ID_SECRET_BASE_YELLOW_CAVE1, 15,
- MAP_ID_SECRET_BASE_BLUE_CAVE4, 0,
- MAP_ID_SECRET_BASE_YELLOW_CAVE1, 14,
- MAP_ID_SECRET_BASE_YELLOW_CAVE1, 0,
- MAP_ID_SECRET_BASE_YELLOW_CAVE2, 3,
- MAP_ID_SECRET_BASE_YELLOW_CAVE2, 0,
- MAP_ID_SECRET_BASE_BLUE_CAVE2, 7,
- MAP_ID_SECRET_BASE_YELLOW_CAVE3, 0,
- MAP_ID_SECRET_BASE_YELLOW_CAVE1, 6,
- MAP_ID_SECRET_BASE_YELLOW_CAVE4, 0,
- MAP_ID_SECRET_BASE_SHRUB1, 9,
- MAP_ID_SECRET_BASE_TREE1, 0,
- MAP_ID_SECRET_BASE_BLUE_CAVE1, 3,
- MAP_ID_SECRET_BASE_TREE2, 0,
- MAP_ID_SECRET_BASE_SHRUB1, 6,
- MAP_ID_SECRET_BASE_TREE3, 0,
- MAP_ID_SECRET_BASE_YELLOW_CAVE3, 3,
- MAP_ID_SECRET_BASE_TREE4, 0,
- MAP_ID_SECRET_BASE_TREE1, 10,
- MAP_ID_SECRET_BASE_SHRUB1, 0,
- MAP_ID_SECRET_BASE_YELLOW_CAVE1, 3,
- MAP_ID_SECRET_BASE_SHRUB2, 0,
- MAP_ID_SECRET_BASE_BROWN_CAVE1, 2,
- MAP_ID_SECRET_BASE_SHRUB3, 0,
- MAP_ID_SECRET_BASE_BROWN_CAVE2, 8,
- MAP_ID_SECRET_BASE_SHRUB4, 0,
- MAP_ID_SECRET_BASE_YELLOW_CAVE2, 6
+ MAP_ID_SECRET_BASE_RED_CAVE1, 0, 1, 3,
+ MAP_ID_SECRET_BASE_RED_CAVE2, 0, 5, 9,
+ MAP_ID_SECRET_BASE_RED_CAVE3, 0, 1, 3,
+ MAP_ID_SECRET_BASE_RED_CAVE4, 0, 7, 13,
+ MAP_ID_SECRET_BASE_BROWN_CAVE1, 0, 2, 3,
+ MAP_ID_SECRET_BASE_BROWN_CAVE2, 0, 9, 2,
+ MAP_ID_SECRET_BASE_BROWN_CAVE3, 0, 13, 4,
+ MAP_ID_SECRET_BASE_BROWN_CAVE4, 0, 1, 2,
+ MAP_ID_SECRET_BASE_BLUE_CAVE1, 0, 1, 3,
+ MAP_ID_SECRET_BASE_BLUE_CAVE2, 0, 1, 2,
+ MAP_ID_SECRET_BASE_BLUE_CAVE3, 0, 3, 15,
+ MAP_ID_SECRET_BASE_BLUE_CAVE4, 0, 3, 14,
+ MAP_ID_SECRET_BASE_YELLOW_CAVE1, 0, 9, 3,
+ MAP_ID_SECRET_BASE_YELLOW_CAVE2, 0, 8, 7,
+ MAP_ID_SECRET_BASE_YELLOW_CAVE3, 0, 3, 6,
+ MAP_ID_SECRET_BASE_YELLOW_CAVE4, 0, 5, 9,
+ MAP_ID_SECRET_BASE_TREE1, 0, 2, 3,
+ MAP_ID_SECRET_BASE_TREE2, 0, 5, 6,
+ MAP_ID_SECRET_BASE_TREE3, 0, 15, 3,
+ MAP_ID_SECRET_BASE_TREE4, 0, 4, 10,
+ MAP_ID_SECRET_BASE_SHRUB1, 0, 3, 3,
+ MAP_ID_SECRET_BASE_SHRUB2, 0, 1, 2,
+ MAP_ID_SECRET_BASE_SHRUB3, 0, 7, 8,
+ MAP_ID_SECRET_BASE_SHRUB4, 0, 9, 6
};
const struct MenuAction2 gUnknown_083D13D4[] = {
@@ -455,17 +431,15 @@ void sub_80BBCCC(u8 flagIn)
}
}
-#ifdef NONMATCHING
-// The only nonmatching property of this function is that the implicit variables &gSaveBlock1 and &roomdecor[decidx]
-// are stored in the wrong registers.
void sub_80BBDD0(void)
{
u8 *roomdecor;
u8 *roomdecorpos;
- u8 ndecor;
u8 decidx;
u8 objid = 0;
u8 metatile;
+ u8 permission;
+ u8 ndecor;
u16 curBase = VarGet(VAR_0x4054);
if (!CurrentMapIsSecretBase()) {
roomdecor = gSaveBlock1.playerRoomDecor;
@@ -477,262 +451,33 @@ void sub_80BBDD0(void)
ndecor = 16;
}
for (decidx=0; decidx<ndecor; decidx++) {
- if (roomdecor[decidx] != 0 && gDecorations[roomdecor[decidx]].permission == DECORPERM_SOLID_MAT)
- {
- for (objid=0; objid<gMapHeader.events->mapObjectCount; objid++) {
- if (gMapHeader.events->mapObjects[objid].flagId == gSpecialVar_0x8004 + 0xAE)
- break;
- }
- if (objid == gMapHeader.events->mapObjectCount)
- continue;
- gSpecialVar_0x8006 = roomdecorpos[decidx] >> 4;
- gSpecialVar_0x8007 = roomdecorpos[decidx] & 0xF;
- metatile = MapGridGetMetatileBehaviorAt(gSpecialVar_0x8006 + 7, gSpecialVar_0x8007 + 7);
- if (sub_80572D8(metatile) == TRUE || sub_80572EC(metatile) == TRUE) {
- gScriptResult = gMapHeader.events->mapObjects[objid].graphicsId + VAR_0x3F20;
- VarSet(gScriptResult, gDecorations[roomdecor[decidx]].tiles[0]);
- gScriptResult = gMapHeader.events->mapObjects[objid].localId;
- FlagClear(gSpecialVar_0x8004 + 0xAE);
- show_sprite(gScriptResult, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup);
- sub_805C0F8(gScriptResult, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup, gSpecialVar_0x8006, gSpecialVar_0x8007);
- sub_805C78C(gScriptResult, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup);
- gSpecialVar_0x8004 ++;
+ if (roomdecor[decidx] != DECOR_NONE) {
+ permission = gDecorations[roomdecor[decidx]].permission;
+ if (permission == DECORPERM_SOLID_MAT)
+ {
+ for (objid=0; objid<gMapHeader.events->mapObjectCount; objid++) {
+ if (gMapHeader.events->mapObjects[objid].flagId == gSpecialVar_0x8004 + 0xAE)
+ break;
+ }
+ if (objid == gMapHeader.events->mapObjectCount)
+ continue;
+ gSpecialVar_0x8006 = roomdecorpos[decidx] >> 4;
+ gSpecialVar_0x8007 = roomdecorpos[decidx] & 0xF;
+ metatile = MapGridGetMetatileBehaviorAt(gSpecialVar_0x8006 + 7, gSpecialVar_0x8007 + 7);
+ if (sub_80572D8(metatile) == TRUE || sub_80572EC(metatile) == TRUE) {
+ gScriptResult = gMapHeader.events->mapObjects[objid].graphicsId + VAR_0x3F20;
+ VarSet(gScriptResult, gDecorations[roomdecor[decidx]].tiles[0]);
+ gScriptResult = gMapHeader.events->mapObjects[objid].localId;
+ FlagClear(gSpecialVar_0x8004 + 0xAE);
+ show_sprite(gScriptResult, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup);
+ sub_805C0F8(gScriptResult, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup, gSpecialVar_0x8006, gSpecialVar_0x8007);
+ sub_805C78C(gScriptResult, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup);
+ gSpecialVar_0x8004 ++;
+ }
}
}
}
}
-#else
-__attribute__((naked))
-void sub_80BBDD0(void)
-{
- asm(".syntax unified\n\
- push {r4-r7,lr}\n\
- mov r7, r10\n\
- mov r6, r9\n\
- mov r5, r8\n\
- push {r5-r7}\n\
- sub sp, 0x14\n\
- ldr r0, _080BBE00 @ =0x00004054\n\
- bl VarGet\n\
- lsls r0, 16\n\
- lsrs r4, r0, 16\n\
- bl CurrentMapIsSecretBase\n\
- lsls r0, 24\n\
- cmp r0, 0\n\
- bne _080BBE08\n\
- ldr r0, _080BBE04 @ =gSaveBlock1 + 0x2688\n\
- str r0, [sp, 0x4]\n\
- adds r0, 0xC\n\
- str r0, [sp, 0x8]\n\
- movs r1, 0xC\n\
- str r1, [sp, 0xC]\n\
- b _080BBE1E\n\
- .align 2, 0\n\
-_080BBE00: .4byte 0x00004054\n\
-_080BBE04: .4byte gSaveBlock1 + 0x2688\n\
-_080BBE08:\n\
- lsls r1, r4, 2\n\
- adds r1, r4\n\
- lsls r1, 5\n\
- ldr r0, _080BBF7C @ =gSaveBlock1 + 0x1A1A\n\
- adds r2, r1, r0\n\
- str r2, [sp, 0x4]\n\
- adds r0, 0x10\n\
- adds r1, r0\n\
- str r1, [sp, 0x8]\n\
- movs r3, 0x10\n\
- str r3, [sp, 0xC]\n\
-_080BBE1E:\n\
- movs r6, 0\n\
- ldr r4, [sp, 0xC]\n\
- cmp r6, r4\n\
- bcc _080BBE28\n\
- b _080BBF6C\n\
-_080BBE28:\n\
- ldr r5, _080BBF80 @ =gSaveBlock1\n\
- mov r10, r5\n\
-_080BBE2C:\n\
- ldr r1, [sp, 0x4]\n\
- adds r0, r1, r6\n\
- ldrb r1, [r0]\n\
- mov r9, r0\n\
- adds r2, r6, 0x1\n\
- str r2, [sp, 0x10]\n\
- cmp r1, 0\n\
- bne _080BBE3E\n\
- b _080BBF5E\n\
-_080BBE3E:\n\
- ldrb r0, [r0]\n\
- lsls r0, 5\n\
- ldr r3, _080BBF84 @ =gDecorations\n\
- adds r0, r3\n\
- ldrb r0, [r0, 0x11]\n\
- cmp r0, 0x4\n\
- beq _080BBE4E\n\
- b _080BBF5E\n\
-_080BBE4E:\n\
- movs r5, 0\n\
- ldr r0, _080BBF88 @ =gMapHeader\n\
- ldr r2, [r0, 0x4]\n\
- ldrb r3, [r2]\n\
- mov r8, r0\n\
- cmp r5, r3\n\
- bcs _080BBE8E\n\
- ldr r0, [r2, 0x4]\n\
- ldrh r1, [r0, 0x14]\n\
- ldr r4, _080BBF8C @ =gSpecialVar_0x8004\n\
- ldrh r0, [r4]\n\
- adds r0, 0xAE\n\
- adds r7, r4, 0\n\
- cmp r1, r0\n\
- beq _080BBE8E\n\
- adds r4, r2, 0\n\
- adds r2, r3, 0\n\
-_080BBE70:\n\
- adds r0, r5, 0x1\n\
- lsls r0, 24\n\
- lsrs r5, r0, 24\n\
- cmp r5, r2\n\
- bcs _080BBE8E\n\
- ldr r1, [r4, 0x4]\n\
- lsls r0, r5, 1\n\
- adds r0, r5\n\
- lsls r0, 3\n\
- adds r0, r1\n\
- ldrh r1, [r0, 0x14]\n\
- ldrh r0, [r7]\n\
- adds r0, 0xAE\n\
- cmp r1, r0\n\
- bne _080BBE70\n\
-_080BBE8E:\n\
- mov r1, r8\n\
- ldr r0, [r1, 0x4]\n\
- ldrb r0, [r0]\n\
- cmp r5, r0\n\
- beq _080BBF5E\n\
- ldr r7, _080BBF90 @ =gSpecialVar_0x8006\n\
- ldr r2, [sp, 0x8]\n\
- adds r1, r2, r6\n\
- ldrb r0, [r1]\n\
- lsrs r0, 4\n\
- strh r0, [r7]\n\
- ldr r6, _080BBF94 @ =gSpecialVar_0x8007\n\
- ldrb r1, [r1]\n\
- movs r0, 0xF\n\
- ands r0, r1\n\
- strh r0, [r6]\n\
- ldrh r0, [r7]\n\
- adds r0, 0x7\n\
- ldrh r1, [r6]\n\
- adds r1, 0x7\n\
- bl MapGridGetMetatileBehaviorAt\n\
- lsls r0, 24\n\
- lsrs r4, r0, 24\n\
- adds r0, r4, 0\n\
- bl sub_80572D8\n\
- lsls r0, 24\n\
- lsrs r0, 24\n\
- cmp r0, 0x1\n\
- beq _080BBEDA\n\
- adds r0, r4, 0\n\
- bl sub_80572EC\n\
- lsls r0, 24\n\
- lsrs r0, 24\n\
- cmp r0, 0x1\n\
- bne _080BBF5E\n\
-_080BBEDA:\n\
- mov r3, r8\n\
- ldr r0, [r3, 0x4]\n\
- ldr r1, [r0, 0x4]\n\
- lsls r4, r5, 1\n\
- adds r4, r5\n\
- lsls r4, 3\n\
- adds r1, r4, r1\n\
- ldr r5, _080BBF98 @ =0x00003f20\n\
- adds r0, r5, 0\n\
- ldrb r1, [r1, 0x1]\n\
- adds r0, r1\n\
- ldr r1, _080BBF9C @ =gScriptResult\n\
- strh r0, [r1]\n\
- ldrh r0, [r1]\n\
- mov r2, r9\n\
- ldrb r1, [r2]\n\
- lsls r1, 5\n\
- ldr r3, _080BBFA0 @ =gDecorations + 0x1C\n\
- adds r1, r3\n\
- ldr r1, [r1]\n\
- ldrh r1, [r1]\n\
- bl VarSet\n\
- mov r5, r8\n\
- ldr r0, [r5, 0x4]\n\
- ldr r0, [r0, 0x4]\n\
- adds r4, r0\n\
- ldrb r0, [r4]\n\
- ldr r1, _080BBF9C @ =gScriptResult\n\
- strh r0, [r1]\n\
- ldr r2, _080BBF8C @ =gSpecialVar_0x8004\n\
- ldrh r0, [r2]\n\
- adds r0, 0xAE\n\
- lsls r0, 16\n\
- lsrs r0, 16\n\
- bl FlagClear\n\
- ldr r3, _080BBF9C @ =gScriptResult\n\
- ldrb r0, [r3]\n\
- mov r4, r10\n\
- ldrb r1, [r4, 0x5]\n\
- ldrb r2, [r4, 0x4]\n\
- bl show_sprite\n\
- ldr r5, _080BBF9C @ =gScriptResult\n\
- ldrb r0, [r5]\n\
- ldrb r1, [r4, 0x5]\n\
- ldrb r2, [r4, 0x4]\n\
- movs r4, 0\n\
- ldrsh r3, [r7, r4]\n\
- movs r5, 0\n\
- ldrsh r4, [r6, r5]\n\
- str r4, [sp]\n\
- bl sub_805C0F8\n\
- ldr r1, _080BBF9C @ =gScriptResult\n\
- ldrb r0, [r1]\n\
- mov r2, r10\n\
- ldrb r1, [r2, 0x5]\n\
- ldrb r2, [r2, 0x4]\n\
- bl sub_805C78C\n\
- ldr r3, _080BBF8C @ =gSpecialVar_0x8004\n\
- ldrh r0, [r3]\n\
- adds r0, 0x1\n\
- strh r0, [r3]\n\
-_080BBF5E:\n\
- ldr r4, [sp, 0x10]\n\
- lsls r0, r4, 24\n\
- lsrs r6, r0, 24\n\
- ldr r5, [sp, 0xC]\n\
- cmp r6, r5\n\
- bcs _080BBF6C\n\
- b _080BBE2C\n\
-_080BBF6C:\n\
- add sp, 0x14\n\
- pop {r3-r5}\n\
- mov r8, r3\n\
- mov r9, r4\n\
- mov r10, r5\n\
- pop {r4-r7}\n\
- pop {r0}\n\
- bx r0\n\
- .align 2, 0\n\
-_080BBF7C: .4byte gSaveBlock1 + 0x1A1A\n\
-_080BBF80: .4byte gSaveBlock1\n\
-_080BBF84: .4byte gDecorations\n\
-_080BBF88: .4byte gMapHeader\n\
-_080BBF8C: .4byte gSpecialVar_0x8004\n\
-_080BBF90: .4byte gSpecialVar_0x8006\n\
-_080BBF94: .4byte gSpecialVar_0x8007\n\
-_080BBF98: .4byte 0x00003f20\n\
-_080BBF9C: .4byte gScriptResult\n\
-_080BBFA0: .4byte gDecorations + 0x1C\n\
-.syntax divided\n");
-}
-#endif
void sub_80BBFA4(void)
{
@@ -851,7 +596,7 @@ u8 sub_80BC298(struct Pokemon *mon) { // 80bc298
u16 evsum = GetMonData(mon, MON_DATA_HP_EV);
evsum += GetMonData(mon, MON_DATA_ATK_EV);
evsum += GetMonData(mon, MON_DATA_DEF_EV);
- evsum += GetMonData(mon, MON_DATA_SPD_EV);
+ evsum += GetMonData(mon, MON_DATA_SPEED_EV);
evsum += GetMonData(mon, MON_DATA_SPATK_EV);
evsum += GetMonData(mon, MON_DATA_SPDEF_EV);
return (u8)(evsum / 6);