summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYamaArashi <shadow962@live.com>2016-10-17 23:11:09 -0700
committerYamaArashi <shadow962@live.com>2016-10-17 23:11:09 -0700
commitb52494be04c2fd233db5b81bc53ef2f653ac7ff3 (patch)
treeb3153c2c5e2c8bbf183e17ccb1c4b8e205cb92d0
parentea34a432b76188dac75f86a888a93af5cbf22161 (diff)
var.c
-rw-r--r--Makefile2
-rw-r--r--data/event_scripts.s2
-rw-r--r--ld_script.txt2
-rw-r--r--shared_syms.txt2
-rw-r--r--src/var.c38
5 files changed, 43 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 73b2fecfc..439f2fb82 100644
--- a/Makefile
+++ b/Makefile
@@ -52,7 +52,7 @@ asm/tileset.o asm/rom_8065394.o asm/rom_803D1FC.o asm/calculate_base_damage.o \
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/var.o \
+asm/field_effect.o asm/title_screen.o asm/rom_807C828.o \
asm/flag.o asm/rom_806936C.o
DATA_ASM_OBJS := data/data2.o data/graphics.o data/sound_data.o \
diff --git a/data/event_scripts.s b/data/event_scripts.s
index 3b524572b..bc5c4728d 100644
--- a/data/event_scripts.s
+++ b/data/event_scripts.s
@@ -8,7 +8,7 @@
.include "data/script_cmd_table.s"
.align 2
-gUnknown_0814B14C::
+gSpecialVars::
.4byte 0x202e8c4
.4byte 0x202e8c6
.4byte 0x202e8c8
diff --git a/ld_script.txt b/ld_script.txt
index 4d9e14d5c..705c9b55f 100644
--- a/ld_script.txt
+++ b/ld_script.txt
@@ -65,7 +65,7 @@ SECTIONS {
src/script.o(.text);
src/scrcmd.o(.text);
asm/rom_8065394.o(.text);
- asm/var.o(.text);
+ src/var.o(.text);
asm/flag.o(.text);
asm/rom_806936C.o(.text);
asm/party_menu.o(.text);
diff --git a/shared_syms.txt b/shared_syms.txt
index 38b13e8fd..73d91724a 100644
--- a/shared_syms.txt
+++ b/shared_syms.txt
@@ -8,3 +8,5 @@ gSecretBaseRecord = 0x2017000;
dword_2017100 = 0x2017100;
gHallOfFame = 0x201E000;
+
+gVars = 0x201EA74;
diff --git a/src/var.c b/src/var.c
new file mode 100644
index 000000000..ee9604385
--- /dev/null
+++ b/src/var.c
@@ -0,0 +1,38 @@
+#include "global.h"
+
+extern u16 gVars[];
+
+extern u16 *gSpecialVars[];
+
+u16 *GetVarPointer(u16 id)
+{
+ if (id < 0x4000)
+ return NULL;
+
+ if ((s16)id >= 0)
+ return &gVars[id];
+
+ return gSpecialVars[id - 0x8000];
+}
+
+u16 VarGet(u16 id)
+{
+ u16 *ptr = GetVarPointer(id);
+ if (!ptr)
+ return id;
+ return *ptr;
+}
+
+bool8 VarSet(u16 id, u16 value)
+{
+ u16 *ptr = GetVarPointer(id);
+ if (!ptr)
+ return FALSE;
+ *ptr = value;
+ return TRUE;
+}
+
+u8 VarGetFieldObjectGraphicsId(u8 id)
+{
+ return VarGet(0x4010 + id);
+}