diff options
author | YamaArashi <shadow962@live.com> | 2016-10-17 23:11:09 -0700 |
---|---|---|
committer | YamaArashi <shadow962@live.com> | 2016-10-17 23:11:09 -0700 |
commit | b52494be04c2fd233db5b81bc53ef2f653ac7ff3 (patch) | |
tree | b3153c2c5e2c8bbf183e17ccb1c4b8e205cb92d0 | |
parent | ea34a432b76188dac75f86a888a93af5cbf22161 (diff) |
var.c
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | data/event_scripts.s | 2 | ||||
-rw-r--r-- | ld_script.txt | 2 | ||||
-rw-r--r-- | shared_syms.txt | 2 | ||||
-rw-r--r-- | src/var.c | 38 |
5 files changed, 43 insertions, 3 deletions
@@ -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); +} |