summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPikalaxALT <pikalaxalt@gmail.com>2018-10-08 12:10:33 -0400
committerPikalaxALT <pikalaxalt@gmail.com>2018-10-08 12:10:33 -0400
commit7040e8e9568a21ef8417c7de6e47fd636dcd7865 (patch)
tree798c013a06652158fdb64e5da9d1b8a8df5040c4
parentf285a81e859bb045725acac3d33f2d7d665ee8c5 (diff)
sub_8146C30
-rw-r--r--asm/menews_jisan.s47
-rw-r--r--include/global.h21
-rw-r--r--include/mevent.h6
-rw-r--r--ld_script.txt1
-rw-r--r--src/menews_jisan.c74
5 files changed, 101 insertions, 48 deletions
diff --git a/asm/menews_jisan.s b/asm/menews_jisan.s
index abd5e44f4..160d0e4c8 100644
--- a/asm/menews_jisan.s
+++ b/asm/menews_jisan.s
@@ -5,53 +5,6 @@
.text
- thumb_func_start sub_8146C30
-sub_8146C30: @ 8146C30
- push {r4,r5,lr}
- adds r4, r0, 0
- bl sub_8143D94
- adds r5, r0, 0
- movs r0, 0x3
- adds r1, r4, 0
- ands r1, r0
- ldrb r2, [r5]
- movs r0, 0x4
- negs r0, r0
- ands r0, r2
- orrs r0, r1
- strb r0, [r5]
- cmp r4, 0x2
- bhi _08146C56
- cmp r4, 0x1
- bcs _08146C5C
- b _08146C80
-_08146C56:
- cmp r4, 0x3
- beq _08146C6E
- b _08146C80
-_08146C5C:
- bl Random
- lsls r0, 16
- lsrs r0, 16
- movs r1, 0xF
- bl __umodsi3
- adds r0, 0x10
- b _08146C7E
-_08146C6E:
- bl Random
- lsls r0, 16
- lsrs r0, 16
- movs r1, 0xF
- bl __umodsi3
- adds r0, 0x1
-_08146C7E:
- strb r0, [r5, 0x1]
-_08146C80:
- pop {r4,r5}
- pop {r0}
- bx r0
- thumb_func_end sub_8146C30
-
thumb_func_start sub_8146C88
sub_8146C88: @ 8146C88
push {lr}
diff --git a/include/global.h b/include/global.h
index 75911b9f2..2b35e303d 100644
--- a/include/global.h
+++ b/include/global.h
@@ -466,6 +466,14 @@ struct RecordMixingDayCareMail
bool16 holdsItem[DAYCARE_MON_COUNT];
};
+struct MysteryEventStruct
+{
+ u8 unk_0_0:2;
+ u8 unk_0_2:6;
+ u8 unk_1;
+ u8 filler_2[0x1ba];
+};
+
#define MAP_OBJECTS_COUNT 16
#define BERRY_TREES_COUNT 128
#define FLAGS_COUNT 300
@@ -476,7 +484,18 @@ struct SaveBlock1
{
/*0x0000*/ u8 filler[0x4];
/*0x0004*/ struct WarpData location;
- /*0x000C*/ u8 fillerC[0x3610];
+ /*0x0C*/ struct WarpData warp1;
+ /*0x14*/ struct WarpData warp2;
+ /*0x1C*/ struct WarpData lastHealLocation;
+ /*0x24*/ struct WarpData warp4;
+ /*0x002C*/ u8 filler2C[0x60C];
+ /*0x638*/ u8 trainerRematchStepCounter;
+ u8 filler_639;
+ /*0x63a*/ u8 trainerRematches[100];
+ /*0x06A0*/ struct MapObject mapObjects[MAP_OBJECTS_COUNT];
+ /*0x08E0*/ struct MapObjectTemplate mapObjectTemplates[64];
+ /*0x0EE0*/ u8 fillerEE0[0x2580];
+ /*0x3460*/ struct MysteryEventStruct unk_3460;
/*0x361C*/ struct RamScript ramScript;
/*0x3A08*/ u8 filler3A08[0x44];
/*0x3A4C*/ u8 rivalName[PLAYER_NAME_LENGTH];
diff --git a/include/mevent.h b/include/mevent.h
new file mode 100644
index 000000000..b196d655b
--- /dev/null
+++ b/include/mevent.h
@@ -0,0 +1,6 @@
+#ifndef GUARD_MEVENT_H
+#define GUARD_MEVENT_H
+
+struct MysteryEventStruct * sub_8143D94(void);
+
+#endif //GUARD_MEVENT_H
diff --git a/ld_script.txt b/ld_script.txt
index bc27ac048..777735b7c 100644
--- a/ld_script.txt
+++ b/ld_script.txt
@@ -249,6 +249,7 @@ SECTIONS {
asm/mevent.o(.text);
asm/mevent_server.o(.text);
asm/mevent_8145654.o(.text);
+ src/menews_jisan.o(.text);
asm/menews_jisan.o(.text);
asm/seagallop.o(.text);
asm/unk_8147500.o(.text);
diff --git a/src/menews_jisan.c b/src/menews_jisan.c
new file mode 100644
index 000000000..afaef7cf9
--- /dev/null
+++ b/src/menews_jisan.c
@@ -0,0 +1,74 @@
+#include "global.h"
+#include "mevent.h"
+#include "random.h"
+
+#ifdef NONMATCHING
+void sub_8146C30(u32 a0)
+{
+ struct MysteryEventStruct *r5 = sub_8143D94();
+
+ r5->unk_0_0 = a0;
+ asm_comment("The switch logic does not match. Specifically, the \"bhi\" is replaced with a \"bls\" and the comparisons with 1 and 3 are swapped chronologically.");
+ switch (a0)
+ {
+ case 0:
+ r5->unk_1 = (Random() % 15) + 16;
+ break;
+ case 1:
+ break;
+ case 2:
+ break;
+ case 3:
+ r5->unk_1 = (Random() % 15) + 1;
+ break;
+ }
+}
+#else
+NAKED
+void sub_8146C30(u32 a0)
+{
+ asm_unified("\tpush {r4,r5,lr}\n"
+ "\tadds r4, r0, 0\n"
+ "\tbl sub_8143D94\n"
+ "\tadds r5, r0, 0\n"
+ "\tmovs r0, 0x3\n"
+ "\tadds r1, r4, 0\n"
+ "\tands r1, r0\n"
+ "\tldrb r2, [r5]\n"
+ "\tmovs r0, 0x4\n"
+ "\tnegs r0, r0\n"
+ "\tands r0, r2\n"
+ "\torrs r0, r1\n"
+ "\tstrb r0, [r5]\n"
+ "\tcmp r4, 0x2\n"
+ "\tbhi _08146C56\n"
+ "\tcmp r4, 0x1\n"
+ "\tbcs _08146C5C\n"
+ "\tb _08146C80\n"
+ "_08146C56:\n"
+ "\tcmp r4, 0x3\n"
+ "\tbeq _08146C6E\n"
+ "\tb _08146C80\n"
+ "_08146C5C:\n"
+ "\tbl Random\n"
+ "\tlsls r0, 16\n"
+ "\tlsrs r0, 16\n"
+ "\tmovs r1, 0xF\n"
+ "\tbl __umodsi3\n"
+ "\tadds r0, 0x10\n"
+ "\tb _08146C7E\n"
+ "_08146C6E:\n"
+ "\tbl Random\n"
+ "\tlsls r0, 16\n"
+ "\tlsrs r0, 16\n"
+ "\tmovs r1, 0xF\n"
+ "\tbl __umodsi3\n"
+ "\tadds r0, 0x1\n"
+ "_08146C7E:\n"
+ "\tstrb r0, [r5, 0x1]\n"
+ "_08146C80:\n"
+ "\tpop {r4,r5}\n"
+ "\tpop {r0}\n"
+ "\tbx r0");
+}
+#endif