Merge pull request #168 from TrainerRiley/PoketchData_Calendar

PoketchData Calendar Documentation
This commit is contained in:
Rachel
2024-03-27 14:14:08 -07:00
committed by GitHub
3 changed files with 58 additions and 30 deletions

View File

@@ -6,7 +6,7 @@
/** Poketch app IDs, used to register and switch between apps in the Poketch */
enum PoketchAppID {
POKETCH_APPID_DIGITALWATCH,
POKETCH_APPID_DIGITALWATCH = 0,
POKETCH_APPID_CALCULATOR,
POKETCH_APPID_MEMOPAD,
POKETCH_APPID_PEDOMETER,
@@ -29,15 +29,15 @@ enum PoketchAppID {
POKETCH_APPID_KITCHENTIMER,
POKETCH_APPID_COLORCHANGER,
POKETCH_APPID_MATCHUPCHECKER,
POKETCH_APPID_STOPWATCH,
POKETCH_APPID_ALARMCLOCK,
POKETCH_APPID_STOPWATCH, // unused
POKETCH_APPID_ALARMCLOCK, // unused
POKETCH_APPID_MAX
};
/** Poketch Screen colors, used in PoketchData_SetScreenColor */
enum PoketchScreenColor {
POKETCH_SCREEN_COLOR_GREEN,
POKETCH_SCREEN_COLOR_GREEN = 0,
POKETCH_SCREEN_COLOR_YELLOW,
POKETCH_SCREEN_COLOR_ORANGE,
POKETCH_SCREEN_COLOR_RED,
@@ -76,8 +76,9 @@ typedef struct PoketchData {
u16 unk_28_12 : 4; //!< unused; bitfield padding
u8 unk_2A[120];
u32 unk_A4;
u8 unk_A8;
u32 calendarMarkBitmap; //!< Bitmap for every day in the calendar month and whether it's been marked
u8 calendarMonth; //!< Current calendar month
/**
* @brief XY coordinates of a single Map Marker in the Marking Map app
@@ -221,9 +222,36 @@ void PoketchData_AlarmTime(const PoketchData *poketchData, u32 *hour, u32 *minut
*/
void PoketchData_SetAlarm(PoketchData *poketchData, BOOL enabled, u32 hour, u32 minute);
void sub_02056934(PoketchData *poketchData, u32 param1, u32 param2);
void sub_02056970(PoketchData *poketchData, u32 param1, u32 param2);
BOOL sub_020569A8(const PoketchData *poketchData, u32 param1, u32 param2);
/**
* Marks the given date on the Calendar app as highlighted.
*
* @param poketchData: The Poketch data to update.
* @param month: The month of the date to mark. If this month does not match the currently stored month,
* the month will update to this value and clear all marks on the calendar (except the one on the passed in day).
* @param day: The day of the date to mark.
*/
void PoketchData_SetCalendarMark(PoketchData *poketchData, u32 month, u32 day);
/**
* Clears the mark on the given date on the Calendar app.
*
* @param poketchData: The Poketch data to update.
* @param month: The month of the date to clear. If this month does not match the currently stored month,
* the month will update to this value and clear all marks on the calendar.
* @param day: The day of the date to clear.
*/
void PoketchData_ClearCalendarMark(PoketchData *poketchData, u32 month, u32 day);
/**
* Checks whether the given date is currently marked on the calendar.
*
* @param poketchData: The Poketch data to check.
* @param month: The month of the date to check.
* @param day: The day of the date to check.
*
* @param return TRUE if the date is marked, FALSE if not. If the given month is not the currently stored month, returns FALSE.
*/
BOOL PoketchData_CalendarMarked(const PoketchData *poketchData, u32 month, u32 day);
/**
* Sets the location of a map marker.

View File

@@ -160,7 +160,7 @@ static void ov50_022562AC (UnkStruct_ov50_02256510_1 * param0, UnkStruct_ov50_02
for (v1 = 0; v1 < (param0->unk_04); v1++) {
param0->unk_0C[v1].unk_00 = v1 + 1;
param0->unk_0C[v1].unk_03 = sub_020569A8(param1->unk_98, param0->unk_00, v1 + 1);
param0->unk_0C[v1].unk_03 = PoketchData_CalendarMarked(param1->unk_98, param0->unk_00, v1 + 1);
param0->unk_0C[v1].unk_02 = v2 + v1;
}
}
@@ -252,10 +252,10 @@ static BOOL ov50_02256418 (UnkStruct_ov50_022561D4 * param0)
if ((param0->unk_A4 >= param0->unk_A8) && (param0->unk_A4 <= param0->unk_AC)) {
int v0 = (param0->unk_A4 - param0->unk_A8);
if (sub_020569A8(param0->unk_98, param0->unk_04.unk_00, v0 + 1)) {
sub_02056970(param0->unk_98, param0->unk_04.unk_00, v0 + 1);
if (PoketchData_CalendarMarked(param0->unk_98, param0->unk_04.unk_00, v0 + 1)) {
PoketchData_ClearCalendarMark(param0->unk_98, param0->unk_04.unk_00, v0 + 1);
} else {
sub_02056934(param0->unk_98, param0->unk_04.unk_00, v0 + 1);
PoketchData_SetCalendarMark(param0->unk_98, param0->unk_04.unk_00, v0 + 1);
}
param0->unk_04.unk_0C[v0].unk_03 ^= 1;

View File

@@ -43,8 +43,8 @@ void Poketch_Init(PoketchData *poketchData)
poketchData->alarmSet = 0;
poketchData->alarmHour = 0;
poketchData->alarmMinute = 0;
poketchData->unk_A8 = 1;
poketchData->unk_A4 = 0;
poketchData->calendarMonth = 1;
poketchData->calendarMarkBitmap = 0;
for (i = 0; i < POKETCH_MAPMARKER_COUNT; i++) {
poketchData->markMapPositions[i].x = sDefaultMapMarkers[i].x;
@@ -191,33 +191,33 @@ void PoketchData_SetAlarm(PoketchData *poketchData, BOOL enable, u32 hour, u32 m
poketchData->alarmMinute = minute;
}
void sub_02056934 (PoketchData *poketchData, u32 param1, u32 param2)
void PoketchData_SetCalendarMark(PoketchData *poketchData, u32 month, u32 day)
{
if (poketchData->unk_A8 == param1) {
poketchData->unk_A4 |= (1 << (param2 - 1));
if (poketchData->calendarMonth == month) {
poketchData->calendarMarkBitmap |= (1 << (day - 1));
} else {
poketchData->unk_A8 = param1;
poketchData->unk_A4 = (1 << (param2 - 1));
poketchData->calendarMonth = month;
poketchData->calendarMarkBitmap = (1 << (day - 1));
}
}
void sub_02056970 (PoketchData *poketchData, u32 param1, u32 param2)
void PoketchData_ClearCalendarMark(PoketchData *poketchData, u32 month, u32 day)
{
if (poketchData->unk_A8 == param1) {
poketchData->unk_A4 &= ~(1 << (param2 - 1));
if (poketchData->calendarMonth == month) {
poketchData->calendarMarkBitmap &= ~(1 << (day - 1));
} else {
poketchData->unk_A8 = param1;
poketchData->unk_A4 = 0;
poketchData->calendarMonth = month;
poketchData->calendarMarkBitmap = 0;
}
}
BOOL sub_020569A8 (const PoketchData *poketchData, u32 param1, u32 param2)
BOOL PoketchData_CalendarMarked(const PoketchData *poketchData, u32 month, u32 day)
{
if (poketchData->unk_A8 == param1) {
return (poketchData->unk_A4 >> (param2 - 1)) & 1;
} else {
return 0;
if (poketchData->calendarMonth == month) {
return (poketchData->calendarMarkBitmap >> (day - 1)) & 1;
}
return FALSE;
}
void PoketchData_SetMapMarker(PoketchData *poketchData, int index, u8 x, u8 y)