summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--include/global.h2
-rw-r--r--ld_script.txt2
-rw-r--r--src/flag.c43
4 files changed, 46 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 439f2fb82..ac0c9e6e7 100644
--- a/Makefile
+++ b/Makefile
@@ -53,7 +53,7 @@ asm/rom_813BA94.o asm/rom_81258BC.o asm/mystery_event_script.o \
asm/field_effect_helpers.o asm/contest_ai.o asm/berry.o asm/rom_80B5054.o \
asm/party_menu.o asm/rom_806D7F8.o asm/wild_encounter.o asm/rom_80859BC.o \
asm/field_effect.o asm/title_screen.o asm/rom_807C828.o \
-asm/flag.o asm/rom_806936C.o
+asm/rom_806936C.o
DATA_ASM_OBJS := data/data2.o data/graphics.o data/sound_data.o \
data/event_scripts.o data/battle_anim_scripts.o \
diff --git a/include/global.h b/include/global.h
index d0f160506..5b1705261 100644
--- a/include/global.h
+++ b/include/global.h
@@ -143,7 +143,7 @@ struct SaveBlock1
u8 unk938[52]; // pokedex related
u8 filler_96C[0x2B4];
struct MapObjectTemplate mapObjectTemplates[64];
- u8 filler_1220[0x120];
+ u8 flags[0x120];
u16 vars[0x100];
u32 gameStats[NUM_GAME_STATS];
u8 filler_1608[0x18F4];
diff --git a/ld_script.txt b/ld_script.txt
index 705c9b55f..5b5c2651a 100644
--- a/ld_script.txt
+++ b/ld_script.txt
@@ -66,7 +66,7 @@ SECTIONS {
src/scrcmd.o(.text);
asm/rom_8065394.o(.text);
src/var.o(.text);
- asm/flag.o(.text);
+ src/flag.o(.text);
asm/rom_806936C.o(.text);
asm/party_menu.o(.text);
asm/rom_806D7F8.o(.text);
diff --git a/src/flag.c b/src/flag.c
new file mode 100644
index 000000000..a4798fb49
--- /dev/null
+++ b/src/flag.c
@@ -0,0 +1,43 @@
+#include "global.h"
+
+extern u8 gUnknown_0202E8E2[];
+
+u8 *GetFlagPointer(u16 id)
+{
+ if (id == 0)
+ return 0;
+
+ if (id < 0x4000)
+ return &gSaveBlock1.flags[id / 8];
+
+ return &gUnknown_0202E8E2[(id - 0x4000) / 8];
+}
+
+u8 FlagSet(u16 id)
+{
+ u8 *ptr = GetFlagPointer(id);
+ if (ptr)
+ *ptr |= 1 << (id & 7);
+ return 0;
+}
+
+u8 FlagReset(u16 id)
+{
+ u8 *ptr = GetFlagPointer(id);
+ if (ptr)
+ *ptr &= ~(1 << (id & 7));
+ return 0;
+}
+
+bool8 FlagGet(u16 id)
+{
+ u8 *ptr = GetFlagPointer(id);
+
+ if (!ptr)
+ return FALSE;
+
+ if (!(((*ptr) >> (id & 7)) & 1))
+ return FALSE;
+
+ return TRUE;
+}