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 /src/var.c | |
parent | ea34a432b76188dac75f86a888a93af5cbf22161 (diff) |
var.c
Diffstat (limited to 'src/var.c')
-rw-r--r-- | src/var.c | 38 |
1 files changed, 38 insertions, 0 deletions
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); +} |