diff options
author | YamaArashi <shadow962@live.com> | 2016-10-18 00:53:12 -0700 |
---|---|---|
committer | YamaArashi <shadow962@live.com> | 2016-10-18 00:53:12 -0700 |
commit | 63941a405cc3060cef79fb1913119a73579ec917 (patch) | |
tree | 437ba24a82c2830f4bff3b7a39c69aa8f4148442 /src | |
parent | a43fcacd18218cb3d8a232db81b3540745c7b47c (diff) |
flag.c
Diffstat (limited to 'src')
-rw-r--r-- | src/flag.c | 43 |
1 files changed, 43 insertions, 0 deletions
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; +} |