diff options
author | Seth Barberee <seth.barberee@gmail.com> | 2021-03-30 13:11:51 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-30 13:11:51 -0500 |
commit | a2d206665c6fffbd962375f262b7fbb05c7b7478 (patch) | |
tree | 6710109c4d9098b74da68ca8f18024d6c184ebc2 /src/play_time.c | |
parent | 2fd4f339b42c010191c199772b09ac34c580de94 (diff) |
Move some data and Splitting (#32)
* move friend area settings to src
* split out playtime into different C file and decomp a few more funcs
* time -> play_time
* fix include
* split out more wonder mail stuff
* unify 203B2C0 and unkDungeon structs. snuck in a decomp func too
* split out more menu screens
* work some more on trade items
* doc a few more things
* add a close nonmatch and decomp nullsub and small func
* rollback struct attempt since it causes nonmatchings
* only one func left in asm
* death to trade_item asm and unify into one C file
* more docing and cleanup
* label main menu and trade items menu global menu struct
* doc itemMode
Diffstat (limited to 'src/play_time.c')
-rw-r--r-- | src/play_time.c | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/src/play_time.c b/src/play_time.c new file mode 100644 index 0000000..37af5fe --- /dev/null +++ b/src/play_time.c @@ -0,0 +1,93 @@ +#include "global.h" +#include "play_time.h" + +extern struct PlayTimeStruct *gPlayTimeRef; +extern struct PlayTimeStruct gPlayTime; + +extern void sub_809488C(u8 *r0, u8 *r1, u32); +extern void sub_8094924(u8 *r0, u8 *r1, u32); + +void InitializePlayTime(void) +{ + gPlayTimeRef = &gPlayTime; + ResetPlayTime(&gPlayTime); +} + +struct PlayTimeStruct *GetPlayTime(void) +{ + return &gPlayTime; +} + +void ResetPlayTime(struct PlayTimeStruct *Time) +{ + Time->frames = 0; + Time->seconds = 0; + Time->minutes = 0; + Time->hours = 0; +} + +void IncrementPlayTime(struct PlayTimeStruct *Time) +{ + u16 temp_store16; + + Time->frames++; + if(Time->frames <= 59) + return; + Time->frames = 0; + + Time->seconds++; + if(Time->seconds <= 59) + return; + Time->seconds = 0; + + Time->minutes++; + if(Time->minutes <= 59) + return; + Time->minutes = 0; + + // Casting here for unsigned comparison + temp_store16 = Time->hours; + if(Time->hours <= 9998) + { + temp_store16++; + Time->hours = temp_store16; + } + else + { + Time->seconds = 59; + Time->minutes = 59; + Time->hours= 9999; + } +} + +void DeconstructPlayTime(struct PlayTimeStruct *r0, u32 *outHours, u32 *outMinutes, u32 *outSeconds) +{ + if(r0->hours <= 9999) + { + *outHours = r0->hours; + *outMinutes = r0->minutes; + *outSeconds = r0->seconds; + } + else + { + *outHours = 9999; + *outMinutes = 59; + *outSeconds = 59; + } +} + +void sub_8095044(u8 *r0) +{ + sub_809488C(r0, (&(gPlayTimeRef->frames)), 6); + sub_809488C(r0, (&(gPlayTimeRef->seconds)), 6); + sub_809488C(r0, (&(gPlayTimeRef->minutes)), 6); + sub_809488C(r0, (u8 *)(&(gPlayTimeRef->hours)), 14); +} + +void sub_8095080(u8 *r0) +{ + sub_8094924(r0, (&(gPlayTimeRef->frames)), 6); + sub_8094924(r0, (&(gPlayTimeRef->seconds)), 6); + sub_8094924(r0, (&(gPlayTimeRef->minutes)), 6); + sub_8094924(r0, (u8 *)(&(gPlayTimeRef->hours)), 14); +} |