diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/gba/gba.h | 34 | ||||
-rw-r--r-- | include/global.h | 40 | ||||
-rw-r--r-- | include/rtc.h | 54 | ||||
-rw-r--r-- | include/rtc_util.h | 20 | ||||
-rw-r--r-- | include/string_util.h | 10 |
5 files changed, 129 insertions, 29 deletions
diff --git a/include/gba/gba.h b/include/gba/gba.h new file mode 100644 index 000000000..5a9dc9b2d --- /dev/null +++ b/include/gba/gba.h @@ -0,0 +1,34 @@ +#ifndef GUARD_GBA_GBA_H +#define GUARD_GBA_GBA_H + +#include <stddef.h> + +typedef unsigned char u8; +typedef unsigned short u16; +typedef unsigned int u32; +typedef signed char s8; +typedef signed short s16; +typedef signed int s32; + +typedef volatile u8 vu8; +typedef volatile u16 vu16; +typedef volatile u32 vu32; +typedef volatile s8 vs8; +typedef volatile s16 vs16; +typedef volatile s32 vs32; + +typedef float f32; +typedef double f64; + +typedef u8 bool8; +typedef u16 bool16; +typedef u32 bool32; + +#define TRUE 1 +#define FALSE 0 + +#include "gba/io_reg.h" +#include "gba/syscall.h" +#include "gba/macro.h" + +#endif // GUARD_GBA_GBA_H diff --git a/include/global.h b/include/global.h index 0c7fef66e..1747446f3 100644 --- a/include/global.h +++ b/include/global.h @@ -1,35 +1,7 @@ #ifndef GUARD_GLOBAL_H #define GUARD_GLOBAL_H -#include <stddef.h> - -typedef unsigned char u8; -typedef unsigned short u16; -typedef unsigned int u32; -typedef signed char s8; -typedef signed short s16; -typedef signed int s32; - -typedef volatile u8 vu8; -typedef volatile u16 vu16; -typedef volatile u32 vu32; -typedef volatile s8 vs8; -typedef volatile s16 vs16; -typedef volatile s32 vs32; - -typedef float f32; -typedef double f64; - -typedef u8 bool8; -typedef u16 bool16; -typedef u32 bool32; - -#define TRUE 1 -#define FALSE 0 - -#include "gba/io_reg.h" -#include "gba/syscall.h" -#include "gba/macro.h" +#include "gba/gba.h" extern u8 gStringVar1[]; extern u8 gStringVar2[]; @@ -41,6 +13,14 @@ enum FEMALE }; +struct Time +{ + s16 days; + s8 hours; + s8 minutes; + s8 seconds; +}; + struct SaveBlock2 { u8 playerName[8]; @@ -51,6 +31,8 @@ struct SaveBlock2 u8 playTimeMinutes; u8 playTimeSeconds; u8 playTimeVBlanks; + u8 filler[0x85]; + struct Time localTimeOffset; }; extern struct SaveBlock2 gSaveBlock2; diff --git a/include/rtc.h b/include/rtc.h new file mode 100644 index 000000000..5ecff238f --- /dev/null +++ b/include/rtc.h @@ -0,0 +1,54 @@ +#ifndef GUARD_RTC_H +#define GUARD_RTC_H + +#include "gba/gba.h" + +#define RTC_INFO_CTRL_UNK1 0x01 // unknown +#define RTC_INFO_CTRL_IRQ_ENABLE 0x02 // per-minute IRQ enable +#define RTC_INFO_CTRL_UNK2 0x04 // unknown +#define RTC_INFO_CTRL_24HOUR 0x40 // 0: 12-hour mode, 1: 24-hour mode +#define RTC_INFO_CTRL_POWER_FAILURE 0x80 // power failure occurred + +enum +{ + MONTH_JAN = 1, + MONTH_FEB, + MONTH_MAR, + MONTH_APR, + MONTH_MAY, + MONTH_JUN, + MONTH_JUL, + MONTH_AUG, + MONTH_SEP, + MONTH_OCT, + MONTH_NOV, + MONTH_DEC +}; + +struct RtcInfo +{ + u8 year; + u8 month; + u8 day; + u8 dayOfWeek; + u8 hour; + u8 minute; + u8 second; + u8 control; + u8 unknown1; + u8 unknown2; +}; + +void RTC_Unprotect(); +void RTC_Protect(); +u8 RTC_Probe(); +bool8 RTC_Reset(); +bool8 RTC_GetControl(struct RtcInfo *rtc); +bool8 RTC_SetControl(struct RtcInfo *rtc); +bool8 RTC_GetDateTime(struct RtcInfo *rtc); +bool8 RTC_SetDateTime(struct RtcInfo *rtc); +bool8 RTC_GetTime(struct RtcInfo *rtc); +bool8 RTC_SetTime(struct RtcInfo *rtc); +bool8 RTC_SetUnknownData(struct RtcInfo *rtc); + +#endif // GUARD_RTC_H diff --git a/include/rtc_util.h b/include/rtc_util.h new file mode 100644 index 000000000..584b675d6 --- /dev/null +++ b/include/rtc_util.h @@ -0,0 +1,20 @@ +#ifndef GUARD_RTC_UTIL_H +#define GUARD_RTC_UTIL_H + +#include "global.h" + +void RtcInit(); +u16 RtcGetErrorFlags(); +void RtcReset(); +void FormatDecimalTime(u8 *dest, s32 hour, s32 minute, s32 second); +void FormatHexTime(u8 *dest, s32 hour, s32 minute, s32 second); +void FormatHexRtcTime(u8 *dest); +void FormatDecimalDate(u8 *dest, s32 year, s32 month, s32 day); +void FormatHexDate(u8 *dest, s32 year, s32 month, s32 day); +void RtcCalcLocalTime(); +void RtcInitLocalTimeOffset(s32 hours, s32 minutes); +void RtcCalcLocalTimeOffset(s32 days, s32 hours, s32 minutes, s32 seconds); +void CalcTimeDifference(struct Time *result, struct Time *t1, struct Time *t2); +u32 RtcGetMinuteCount(); + +#endif // GUARD_RTC_UTIL_H diff --git a/include/string_util.h b/include/string_util.h index d1b90aa34..0dee55828 100644 --- a/include/string_util.h +++ b/include/string_util.h @@ -1,6 +1,16 @@ #ifndef GUARD_STRING_UTIL_H #define GUARD_STRING_UTIL_H +#include "global.h" + +#define CHAR_SPACE 0x00 +#define CHAR_QUESTION_MARK 0xAC +#define CHAR_HYPHEN 0xAE +#define CHAR_COLON 0xF0 +#define EXT_CTRL_CODE_BEGIN 0xFC // extended control code +#define PLACEHOLDER_BEGIN 0xFD // string placeholder +#define EOS 0xFF // end of string + enum StringConvertMode { STR_CONV_MODE_LEFT_ALIGN, |