2017-08-31 16:48:24 +02:00
|
|
|
#include "global.h"
|
|
|
|
#include "play_time.h"
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
STOPPED,
|
|
|
|
RUNNING,
|
|
|
|
MAXED_OUT
|
|
|
|
};
|
|
|
|
|
|
|
|
static u8 sPlayTimeCounterState;
|
|
|
|
|
2017-09-08 18:28:00 +02:00
|
|
|
void PlayTimeCounter_Reset(void)
|
2017-08-31 16:48:24 +02:00
|
|
|
{
|
|
|
|
sPlayTimeCounterState = STOPPED;
|
|
|
|
|
|
|
|
gSaveBlock2Ptr->playTimeHours = 0;
|
|
|
|
gSaveBlock2Ptr->playTimeMinutes = 0;
|
|
|
|
gSaveBlock2Ptr->playTimeSeconds = 0;
|
|
|
|
gSaveBlock2Ptr->playTimeVBlanks = 0;
|
|
|
|
}
|
|
|
|
|
2017-09-08 18:28:00 +02:00
|
|
|
void PlayTimeCounter_Start(void)
|
2017-08-31 16:48:24 +02:00
|
|
|
{
|
|
|
|
sPlayTimeCounterState = RUNNING;
|
|
|
|
|
|
|
|
if (gSaveBlock2Ptr->playTimeHours > 999)
|
|
|
|
PlayTimeCounter_SetToMax();
|
|
|
|
}
|
|
|
|
|
2017-09-08 18:28:00 +02:00
|
|
|
void PlayTimeCounter_Stop(void)
|
2017-08-31 16:48:24 +02:00
|
|
|
{
|
|
|
|
sPlayTimeCounterState = STOPPED;
|
|
|
|
}
|
|
|
|
|
2017-09-08 18:28:00 +02:00
|
|
|
void PlayTimeCounter_Update(void)
|
2017-08-31 16:48:24 +02:00
|
|
|
{
|
|
|
|
if (sPlayTimeCounterState == RUNNING)
|
|
|
|
{
|
|
|
|
gSaveBlock2Ptr->playTimeVBlanks++;
|
|
|
|
|
|
|
|
if (gSaveBlock2Ptr->playTimeVBlanks > 59)
|
|
|
|
{
|
|
|
|
gSaveBlock2Ptr->playTimeVBlanks = 0;
|
|
|
|
gSaveBlock2Ptr->playTimeSeconds++;
|
|
|
|
|
|
|
|
if (gSaveBlock2Ptr->playTimeSeconds > 59)
|
|
|
|
{
|
|
|
|
gSaveBlock2Ptr->playTimeSeconds = 0;
|
|
|
|
gSaveBlock2Ptr->playTimeMinutes++;
|
|
|
|
|
|
|
|
if (gSaveBlock2Ptr->playTimeMinutes > 59)
|
|
|
|
{
|
|
|
|
gSaveBlock2Ptr->playTimeMinutes = 0;
|
|
|
|
gSaveBlock2Ptr->playTimeHours++;
|
|
|
|
|
|
|
|
if (gSaveBlock2Ptr->playTimeHours > 999)
|
|
|
|
PlayTimeCounter_SetToMax();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-08 18:28:00 +02:00
|
|
|
void PlayTimeCounter_SetToMax(void)
|
2017-08-31 16:48:24 +02:00
|
|
|
{
|
|
|
|
sPlayTimeCounterState = MAXED_OUT;
|
|
|
|
|
|
|
|
gSaveBlock2Ptr->playTimeHours = 999;
|
|
|
|
gSaveBlock2Ptr->playTimeMinutes = 59;
|
|
|
|
gSaveBlock2Ptr->playTimeSeconds = 59;
|
|
|
|
gSaveBlock2Ptr->playTimeVBlanks = 59;
|
|
|
|
}
|