diff options
author | scnorton <scnorton@biociphers.org> | 2017-06-21 11:25:27 -0400 |
---|---|---|
committer | scnorton <scnorton@biociphers.org> | 2017-06-21 11:25:27 -0400 |
commit | fce70e6bd5c00f1557dc05a92086b1727d58bb9e (patch) | |
tree | 563c917854d7707c090cd91db18e6e2400b31348 /src | |
parent | d008cc7d60d4cfd34c27a0abcb3cef991b8096a6 (diff) |
Another batch of functions; last of the field specials data
Diffstat (limited to 'src')
-rwxr-xr-x | src/field_specials.c | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/src/field_specials.c b/src/field_specials.c index 214afebf8..13a726ee3 100755 --- a/src/field_specials.c +++ b/src/field_specials.c @@ -34,6 +34,7 @@ #include "battle_tower.h" #include "field_weather.h" #include "pokemon_summary_screen.h" +#include "rng.h" #if ENGLISH #define CHAR_DECIMAL_SEPARATOR CHAR_PERIOD @@ -2088,10 +2089,16 @@ void sub_810F9AC(void) } } +const u8 gUnknown_083F8404[] = {2, 1, 2, 1}; +const u8 gUnknown_083F8408[] = {8, 9, 10, 11, 12, 13, 14, 15}; +const u8 gUnknown_083F8410[] = {8, 13, 14, 11, 10, 12, 15, 9}; + bool8 sub_810FF30(void); void sub_810FCE8(void); void sub_810FF48(void); void sub_810FD80(void); +u16 sub_810FCB0(void); +int sub_810FB9C(void); void ResetFanClub(void) { @@ -2122,3 +2129,74 @@ void sub_810FAA0(void) VarSet(VAR_0x4095, 1); } } + +u8 sub_810FB10(u8 a0) +{ + if (VarGet(VAR_0x4095) == 2) + { + if ((gSaveBlock1.vars[0x41] & 0x7f) + gUnknown_083F8404[a0] >= 20) + { + if (sub_810FCB0() < 3) + { + sub_810FB9C(); + gSaveBlock1.vars[0x41] &= 0xff80; + } + else + { + gSaveBlock1.vars[0x41] = (gSaveBlock1.vars[0x41] & 0xff80) | 20; + } + } + else + { + gSaveBlock1.vars[0x41] += gUnknown_083F8404[a0]; + } + } + return gSaveBlock1.vars[0x41] & 0x7f; +} + +int sub_810FB9C(void) +{ + u8 i; + int retval = 0; + for (i=0; i<8; i++) + { + if (!((gSaveBlock1.vars[0x41] >> gUnknown_083F8408[i]) & 0x01)) + { + retval = i; + if (Random() & 1) + { + gSaveBlock1.vars[0x41] |= (1 << gUnknown_083F8408[i]); + return retval; + } + } + } + gSaveBlock1.vars[0x41] |= (1 << gUnknown_083F8408[retval]); + return retval; +} + +int sub_810FC18(void) +{ + u8 i; + int retval = 0; + if (sub_810FCB0() == TRUE) + { + return 0; + } + for (i=0; i<8; i++) + { + if ((gSaveBlock1.vars[0x41] >> gUnknown_083F8410[i]) & 1) + { + retval = i; + if (Random() & 1) + { + gSaveBlock1.vars[0x41] ^= (1 << gUnknown_083F8410[i]); + return retval; + } + } + } + if ((gSaveBlock1.vars[0x41] >> gUnknown_083F8410[retval]) & 1) + { + gSaveBlock1.vars[0x41] ^= (1 << gUnknown_083F8410[retval]); + } + return retval; +} |