2017-08-31 15:48:24 +01:00
|
|
|
#include "global.h"
|
|
|
|
#include "play_time.h"
|
2024-07-10 19:58:01 +01:00
|
|
|
#include "fake_rtc.h"
|
2017-08-31 15:48:24 +01:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
STOPPED,
|
|
|
|
RUNNING,
|
|
|
|
MAXED_OUT
|
|
|
|
};
|
|
|
|
|
|
|
|
static u8 sPlayTimeCounterState;
|
|
|
|
|
2017-09-08 17:28:00 +01:00
|
|
|
void PlayTimeCounter_Reset(void)
|
2017-08-31 15:48:24 +01:00
|
|
|
{
|
|
|
|
sPlayTimeCounterState = STOPPED;
|
|
|
|
|
|
|
|
gSaveBlock2Ptr->playTimeHours = 0;
|
|
|
|
gSaveBlock2Ptr->playTimeMinutes = 0;
|
|
|
|
gSaveBlock2Ptr->playTimeSeconds = 0;
|
|
|
|
gSaveBlock2Ptr->playTimeVBlanks = 0;
|
|
|
|
}
|
|
|
|
|
2017-09-08 17:28:00 +01:00
|
|
|
void PlayTimeCounter_Start(void)
|
2017-08-31 15:48:24 +01:00
|
|
|
{
|
|
|
|
sPlayTimeCounterState = RUNNING;
|
|
|
|
|
|
|
|
if (gSaveBlock2Ptr->playTimeHours > 999)
|
|
|
|
PlayTimeCounter_SetToMax();
|
|
|
|
}
|
|
|
|
|
2017-09-08 17:28:00 +01:00
|
|
|
void PlayTimeCounter_Stop(void)
|
2017-08-31 15:48:24 +01:00
|
|
|
{
|
|
|
|
sPlayTimeCounterState = STOPPED;
|
|
|
|
}
|
|
|
|
|
2017-09-08 17:28:00 +01:00
|
|
|
void PlayTimeCounter_Update(void)
|
2017-08-31 15:48:24 +01:00
|
|
|
{
|
2020-06-08 22:09:54 +01:00
|
|
|
if (sPlayTimeCounterState != RUNNING)
|
|
|
|
return;
|
|
|
|
|
|
|
|
gSaveBlock2Ptr->playTimeVBlanks++;
|
|
|
|
|
|
|
|
if (gSaveBlock2Ptr->playTimeVBlanks < 60)
|
|
|
|
return;
|
|
|
|
|
|
|
|
gSaveBlock2Ptr->playTimeVBlanks = 0;
|
|
|
|
gSaveBlock2Ptr->playTimeSeconds++;
|
2024-07-10 19:58:01 +01:00
|
|
|
FakeRtc_TickTimeForward();
|
2020-06-08 22:09:54 +01:00
|
|
|
|
|
|
|
if (gSaveBlock2Ptr->playTimeSeconds < 60)
|
|
|
|
return;
|
|
|
|
|
|
|
|
gSaveBlock2Ptr->playTimeSeconds = 0;
|
|
|
|
gSaveBlock2Ptr->playTimeMinutes++;
|
|
|
|
|
|
|
|
if (gSaveBlock2Ptr->playTimeMinutes < 60)
|
|
|
|
return;
|
|
|
|
|
|
|
|
gSaveBlock2Ptr->playTimeMinutes = 0;
|
|
|
|
gSaveBlock2Ptr->playTimeHours++;
|
|
|
|
|
|
|
|
if (gSaveBlock2Ptr->playTimeHours > 999)
|
|
|
|
PlayTimeCounter_SetToMax();
|
2017-08-31 15:48:24 +01:00
|
|
|
}
|
|
|
|
|
2017-09-08 17:28:00 +01:00
|
|
|
void PlayTimeCounter_SetToMax(void)
|
2017-08-31 15:48:24 +01:00
|
|
|
{
|
|
|
|
sPlayTimeCounterState = MAXED_OUT;
|
|
|
|
|
|
|
|
gSaveBlock2Ptr->playTimeHours = 999;
|
|
|
|
gSaveBlock2Ptr->playTimeMinutes = 59;
|
|
|
|
gSaveBlock2Ptr->playTimeSeconds = 59;
|
|
|
|
gSaveBlock2Ptr->playTimeVBlanks = 59;
|
|
|
|
}
|