Skip to content

Commit

Permalink
Merge branch 'master' into daynight2
Browse files Browse the repository at this point in the history
  • Loading branch information
citrusbolt committed Apr 20, 2021
2 parents f74f948 + 9959a80 commit 5c6f846
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 14 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ The highest design priorities are 100% compatibility in terms of:
* The IV Judge at the Battle Frontier gives specific numbers for all stats.
* Next door, there is an EV Judge as well as an EV Reseter.
* An IV Judge is also at the Day Care on Route 117.
* A clock has been added to the start menu.
* The real-time clock effects the world visually.
* Trading restrictions with all Generation 3 games besides Pokémon XD: Gale of Darkness have been removed.
* A Premier Ball can be obtained as a gift for every 10 Poké Balls (of any kind) purchased at the Poké Mart.
Expand Down
2 changes: 2 additions & 0 deletions include/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,8 @@ struct SaveBlock2
u16 optionsBattleStyle:1; // OPTIONS_BATTLE_STYLE_[SHIFT/SET]
u16 optionsBattleSceneOff:1; // whether battle animations are disabled
u16 regionMapZoom:1; // whether the map is zoomed in
u16 options24HourClock:1;
u16 extraOptionsFiller:3;
/*0x18*/ struct Pokedex pokedex;
/*0x90*/ u8 filler_90[0x8];
/*0x98*/ struct Time localTimeOffset;
Expand Down
5 changes: 5 additions & 0 deletions include/strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -3159,5 +3159,10 @@ extern const u8 gText_EggFromJohto[];
extern const u8 gText_BadEggDesc[];
extern const u8 gText_CurrentTime[];
extern const u8 gText_CurrentTimeOff[];
extern const u8 gText_CurrentTimeAM[];
extern const u8 gText_CurrentTimeAMOff[];
extern const u8 gText_CurrentTimePM[];
extern const u8 gText_CurrentTimePMOff[];
extern const u8 gText_ClockOption[];

#endif // GUARD_STRINGS_H
51 changes: 46 additions & 5 deletions src/option_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ enum
TD_SOUND,
TD_BUTTONMODE,
TD_FRAMETYPE,
TD_CLOCK
};

// Menu items
Expand All @@ -37,7 +38,8 @@ enum
MENUITEM_SOUND,
MENUITEM_BUTTONMODE,
MENUITEM_FRAMETYPE,
MENUITEM_CANCEL,
MENUITEM_CLOCK,
//MENUITEM_CANCEL,
MENUITEM_COUNT,
};

Expand All @@ -54,6 +56,7 @@ enum
#define YPOS_SOUND (MENUITEM_SOUND * 16)
#define YPOS_BUTTONMODE (MENUITEM_BUTTONMODE * 16)
#define YPOS_FRAMETYPE (MENUITEM_FRAMETYPE * 16)
#define YPOS_CLOCK (MENUITEM_CLOCK * 16)

// this file's functions
static void Task_OptionMenuFadeIn(u8 taskId);
Expand All @@ -73,6 +76,8 @@ static u8 FrameType_ProcessInput(u8 selection);
static void FrameType_DrawChoices(u8 selection);
static u8 ButtonMode_ProcessInput(u8 selection);
static void ButtonMode_DrawChoices(u8 selection);
static u8 Clock_ProcessInput(u8 selection);
static void Clock_DrawChoices(u8 selection);
static void DrawTextOption(void);
static void DrawOptionMenuTexts(void);
static void DrawBgWindowFrames(void);
Expand All @@ -91,7 +96,8 @@ static const u8 *const sOptionMenuItemsNames[MENUITEM_COUNT] =
[MENUITEM_SOUND] = gText_Sound,
[MENUITEM_BUTTONMODE] = gText_ButtonMode,
[MENUITEM_FRAMETYPE] = gText_Frame,
[MENUITEM_CANCEL] = gText_OptionMenuCancel,
[MENUITEM_CLOCK] = gText_ClockOption,
//[MENUITEM_CANCEL] = gText_OptionMenuCancel,
};

static const struct WindowTemplate sOptionMenuWinTemplates[] =
Expand Down Expand Up @@ -242,13 +248,15 @@ void CB2_InitOptionMenu(void)
gTasks[taskId].data[TD_SOUND] = gSaveBlock2Ptr->optionsSound;
gTasks[taskId].data[TD_BUTTONMODE] = gSaveBlock2Ptr->optionsButtonMode;
gTasks[taskId].data[TD_FRAMETYPE] = gSaveBlock2Ptr->optionsWindowFrameType;
gTasks[taskId].data[TD_CLOCK] = gSaveBlock2Ptr->options24HourClock;

TextSpeed_DrawChoices(gTasks[taskId].data[TD_TEXTSPEED]);
BattleScene_DrawChoices(gTasks[taskId].data[TD_BATTLESCENE]);
BattleStyle_DrawChoices(gTasks[taskId].data[TD_BATTLESTYLE]);
Sound_DrawChoices(gTasks[taskId].data[TD_SOUND]);
ButtonMode_DrawChoices(gTasks[taskId].data[TD_BUTTONMODE]);
FrameType_DrawChoices(gTasks[taskId].data[TD_FRAMETYPE]);
Clock_DrawChoices(gTasks[taskId].data[TD_CLOCK]);
HighlightOptionMenuItem(gTasks[taskId].data[TD_MENUSELECTION]);

CopyWindowToVram(WIN_OPTIONS, 3);
Expand All @@ -273,7 +281,7 @@ static void Task_OptionMenuProcessInput(u8 taskId)
{
if (JOY_NEW(A_BUTTON))
{
if (gTasks[taskId].data[TD_MENUSELECTION] == MENUITEM_CANCEL)
//if (gTasks[taskId].data[TD_MENUSELECTION] == MENUITEM_CANCEL)
gTasks[taskId].func = Task_OptionMenuSave;
}
else if (JOY_NEW(B_BUTTON))
Expand All @@ -285,12 +293,14 @@ static void Task_OptionMenuProcessInput(u8 taskId)
if (gTasks[taskId].data[TD_MENUSELECTION] > 0)
gTasks[taskId].data[TD_MENUSELECTION]--;
else
gTasks[taskId].data[TD_MENUSELECTION] = MENUITEM_CANCEL;
gTasks[taskId].data[TD_MENUSELECTION] = MENUITEM_CLOCK;
// gTasks[taskId].data[TD_MENUSELECTION] = MENUITEM_CANCEL;
HighlightOptionMenuItem(gTasks[taskId].data[TD_MENUSELECTION]);
}
else if (JOY_NEW(DPAD_DOWN))
{
if (gTasks[taskId].data[TD_MENUSELECTION] < MENUITEM_CANCEL)
//if (gTasks[taskId].data[TD_MENUSELECTION] < MENUITEM_CANCEL)
if (gTasks[taskId].data[TD_MENUSELECTION] < MENUITEM_CLOCK)
gTasks[taskId].data[TD_MENUSELECTION]++;
else
gTasks[taskId].data[TD_MENUSELECTION] = 0;
Expand Down Expand Up @@ -344,6 +354,13 @@ static void Task_OptionMenuProcessInput(u8 taskId)
if (previousOption != gTasks[taskId].data[TD_FRAMETYPE])
FrameType_DrawChoices(gTasks[taskId].data[TD_FRAMETYPE]);
break;
case MENUITEM_CLOCK:
previousOption = gTasks[taskId].data[TD_CLOCK];
gTasks[taskId].data[TD_CLOCK] = Clock_ProcessInput(gTasks[taskId].data[TD_CLOCK]);

if (previousOption != gTasks[taskId].data[TD_CLOCK])
Clock_DrawChoices(gTasks[taskId].data[TD_CLOCK]);
break;
default:
return;
}
Expand All @@ -364,6 +381,7 @@ static void Task_OptionMenuSave(u8 taskId)
gSaveBlock2Ptr->optionsSound = gTasks[taskId].data[TD_SOUND];
gSaveBlock2Ptr->optionsButtonMode = gTasks[taskId].data[TD_BUTTONMODE];
gSaveBlock2Ptr->optionsWindowFrameType = gTasks[taskId].data[TD_FRAMETYPE];
gSaveBlock2Ptr->options24HourClock = gTasks[taskId].data[TD_CLOCK];

BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 0x10, RGB_BLACK);
gTasks[taskId].func = Task_OptionMenuFadeOut;
Expand Down Expand Up @@ -623,6 +641,29 @@ static void ButtonMode_DrawChoices(u8 selection)
DrawOptionMenuChoice(gText_ButtonTypeLEqualsA, GetStringRightAlignXOffset(1, gText_ButtonTypeLEqualsA, 198), YPOS_BUTTONMODE, styles[2]);
}

static u8 Clock_ProcessInput(u8 selection)
{
if (JOY_NEW(DPAD_LEFT | DPAD_RIGHT))
{
selection ^= 1;
sArrowPressed = TRUE;
}

return selection;
}

static void Clock_DrawChoices(u8 selection)
{
u8 styles[2];

styles[0] = 0;
styles[1] = 0;
styles[selection] = 1;

DrawOptionMenuChoice(gText_BattleSceneOn, 104, YPOS_CLOCK, styles[0]);
DrawOptionMenuChoice(gText_BattleSceneOff, GetStringRightAlignXOffset(1, gText_BattleSceneOff, 198), YPOS_CLOCK, styles[1]);
}

static void DrawTextOption(void)
{
FillWindowPixelBuffer(WIN_TEXT_OPTION, PIXEL_FILL(1));
Expand Down
70 changes: 61 additions & 9 deletions src/start_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ static const struct WindowTemplate sSaveInfoWindowTemplate = {
.baseBlock = 8
};

static const struct WindowTemplate sCurrentTimeWindowTemplate = {0, 1, 17, 4, 2, 0xF, 48};
static const struct WindowTemplate sCurrentTime24WindowTemplate = {0, 1, 17, 4, 2, 0xF, 48};
static const struct WindowTemplate sCurrentTimeWindowTemplate = {0, 1, 17, 7, 2, 0xF, 48};

// Local functions
static void BuildStartMenuActions(void);
Expand Down Expand Up @@ -1432,13 +1433,37 @@ void AppendToList(u8 *list, u8 *pos, u8 newEntry)
static void ShowCurrentTimeWindow(void)
{
RtcCalcLocalTime();
sCurrentTimeWindowId = AddWindow(&sCurrentTimeWindowTemplate);
if (gSaveBlock2Ptr->options24HourClock)
sCurrentTimeWindowId = AddWindow(&sCurrentTime24WindowTemplate);
else
sCurrentTimeWindowId = AddWindow(&sCurrentTimeWindowTemplate);
PutWindowTilemap(sCurrentTimeWindowId);
DrawStdWindowFrame(sCurrentTimeWindowId, FALSE);
FlagSet(FLAG_TEMP_5);
ConvertIntToDecimalStringN(gStringVar1, gLocalTime.hours, STR_CONV_MODE_LEADING_ZEROS, 2);
ConvertIntToDecimalStringN(gStringVar2, gLocalTime.minutes, STR_CONV_MODE_LEADING_ZEROS, 2);
StringExpandPlaceholders(gStringVar4, gText_CurrentTime);
if (gSaveBlock2Ptr->options24HourClock)
{
ConvertIntToDecimalStringN(gStringVar1, gLocalTime.hours, STR_CONV_MODE_LEADING_ZEROS, 2);
ConvertIntToDecimalStringN(gStringVar2, gLocalTime.minutes, STR_CONV_MODE_LEADING_ZEROS, 2);
StringExpandPlaceholders(gStringVar4, gText_CurrentTime);
}
else
{
if (gLocalTime.hours >= 12)
{
ConvertIntToDecimalStringN(gStringVar1, gLocalTime.hours - 12, STR_CONV_MODE_RIGHT_ALIGN, 2);
ConvertIntToDecimalStringN(gStringVar2, gLocalTime.minutes, STR_CONV_MODE_LEADING_ZEROS, 2);
StringExpandPlaceholders(gStringVar4, gText_CurrentTimePM);
}
else
{
if (gLocalTime.hours == 0)
ConvertIntToDecimalStringN(gStringVar1, 12, STR_CONV_MODE_LEADING_ZEROS, 2);
else
ConvertIntToDecimalStringN(gStringVar1, gLocalTime.hours, STR_CONV_MODE_RIGHT_ALIGN, 2);
ConvertIntToDecimalStringN(gStringVar2, gLocalTime.minutes, STR_CONV_MODE_LEADING_ZEROS, 2);
StringExpandPlaceholders(gStringVar4, gText_CurrentTimeAM);
}
}
AddTextPrinterParameterized(sCurrentTimeWindowId, 1, gStringVar4, 0, 1, 0xFF, NULL);
CopyWindowToVram(sCurrentTimeWindowId, 2);
}
Expand All @@ -1448,12 +1473,39 @@ void UpdateClockDisplay(void)
if (!FlagGet(FLAG_TEMP_5))
return;
RtcCalcLocalTime();
ConvertIntToDecimalStringN(gStringVar1, gLocalTime.hours, STR_CONV_MODE_LEADING_ZEROS, 2);
ConvertIntToDecimalStringN(gStringVar2, gLocalTime.minutes, STR_CONV_MODE_LEADING_ZEROS, 2);
if (gLocalTime.seconds % 2)
if (gSaveBlock2Ptr->options24HourClock)
{
ConvertIntToDecimalStringN(gStringVar1, gLocalTime.hours, STR_CONV_MODE_LEADING_ZEROS, 2);
ConvertIntToDecimalStringN(gStringVar2, gLocalTime.minutes, STR_CONV_MODE_LEADING_ZEROS, 2);
StringExpandPlaceholders(gStringVar4, gText_CurrentTime);
}
else
StringExpandPlaceholders(gStringVar4, gText_CurrentTimeOff);
{
if (gLocalTime.hours >= 12)
{
if (gLocalTime.hours == 12)
ConvertIntToDecimalStringN(gStringVar1, 12, STR_CONV_MODE_LEADING_ZEROS, 2);
else
ConvertIntToDecimalStringN(gStringVar1, gLocalTime.hours - 12, STR_CONV_MODE_RIGHT_ALIGN, 2);
ConvertIntToDecimalStringN(gStringVar2, gLocalTime.minutes, STR_CONV_MODE_LEADING_ZEROS, 2);
if (gLocalTime.seconds % 2)
StringExpandPlaceholders(gStringVar4, gText_CurrentTimePM);
else
StringExpandPlaceholders(gStringVar4, gText_CurrentTimePMOff);
}
else
{
if (gLocalTime.hours == 0)
ConvertIntToDecimalStringN(gStringVar1, 12, STR_CONV_MODE_LEADING_ZEROS, 2);
else
ConvertIntToDecimalStringN(gStringVar1, gLocalTime.hours, STR_CONV_MODE_RIGHT_ALIGN, 2);
ConvertIntToDecimalStringN(gStringVar2, gLocalTime.minutes, STR_CONV_MODE_LEADING_ZEROS, 2);
if (gLocalTime.seconds % 2)
StringExpandPlaceholders(gStringVar4, gText_CurrentTimeAM);
else
StringExpandPlaceholders(gStringVar4, gText_CurrentTimeAMOff);
}
}
AddTextPrinterParameterized(sCurrentTimeWindowId, 1, gStringVar4, 0, 1, 0xFF, NULL);
CopyWindowToVram(sCurrentTimeWindowId, 2);
}
5 changes: 5 additions & 0 deletions src/strings.c
Original file line number Diff line number Diff line change
Expand Up @@ -1913,3 +1913,8 @@ const u8 gText_EggFromJohto[] = _("An odd POKéMON EGG found\nby the DAY CARE co
const u8 gText_BadEggDesc[] = _("A peculiar POKéMON EGG.");
const u8 gText_CurrentTime[] = _(" {STR_VAR_1}:{STR_VAR_2}");
const u8 gText_CurrentTimeOff[] = _(" {STR_VAR_1} {STR_VAR_2}");
const u8 gText_CurrentTimeAM[] = _(" {STR_VAR_1}:{STR_VAR_2} a.m.");
const u8 gText_CurrentTimeAMOff[] = _(" {STR_VAR_1} {STR_VAR_2} a.m.");
const u8 gText_CurrentTimePM[] = _(" {STR_VAR_1}:{STR_VAR_2} p.m.");
const u8 gText_CurrentTimePMOff[] = _(" {STR_VAR_1} {STR_VAR_2} p.m.");
const u8 gText_ClockOption[] = _("12 HOUR CLOCK");

0 comments on commit 5c6f846

Please sign in to comment.