Skip to content

Commit

Permalink
Label some code referenced by main (#133)
Browse files Browse the repository at this point in the history
* main callback, hblank

* HandleConsoleFold

* WaitFrame, SoftReset, UpdateSound

* HeapCanary

* Label the RTC code

* Address review comments
  • Loading branch information
meithecatte authored Jan 29, 2024
1 parent b7fffbf commit f360401
Show file tree
Hide file tree
Showing 155 changed files with 944 additions and 974 deletions.
19 changes: 10 additions & 9 deletions include/core_sys.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#ifndef POKEPLATINUM_CORE_SYS_H
#define POKEPLATINUM_CORE_SYS_H

#include "functypes/funcptr_02017798.h"
#include "struct_decls/struct_0201CD88_decl.h"
#include "overlay023/funcptr_ov23_022537D4.h"

typedef void (* Callback)(void *);

enum ButtonMode {
BUTTON_MODE_NORMAL = 0,
BUTTON_MODE_START_IS_X = 1,
Expand All @@ -13,18 +14,18 @@ enum ButtonMode {
};

typedef struct CoreSys {
UnkFuncPtr_02017798 unk_00;
void * unk_04;
UnkFuncPtr_02017798 unk_08;
void * unk_0C;
Callback mainCallback;
void *mainCallbackData;
Callback hblankCallback;
void *hblankCallbackData;
UnkFuncPtr_ov23_022537D4 unk_10;
UnkFuncPtr_ov23_022537D4 unk_14;
UnkStruct_0201CD88 * unk_18;
UnkStruct_0201CD88 * unk_1C;
UnkStruct_0201CD88 * unk_20;
UnkStruct_0201CD88 * unk_24;
u32 * unk_28;
u32 unk_2C;
u32 frameCounter;
u32 unk_30;
enum ButtonMode buttonMode;
u32 heldKeysRaw;
Expand All @@ -43,11 +44,11 @@ typedef struct CoreSys {
u8 unk_64;
u8 unk_65;
u8 unk_66;
u8 unk_67;
u8 unk_68;
u8 inhibitSleep;
u8 inhibitReset;
u8 padding_69[3];
BOOL unk_6C;
u32 * unk_70;
u32 *heapCanary;
} CoreSys;

extern CoreSys gCoreSys;
Expand Down
6 changes: 0 additions & 6 deletions include/functypes/funcptr_02017798.h

This file was deleted.

28 changes: 28 additions & 0 deletions include/rtc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#ifndef POKEPLATINUM_RTC_H
#define POKEPLATINUM_RTC_H


#include <nitro/rtc.h>

enum TimeOfDay {
TOD_MORNING = 0,
TOD_DAY = 1,
TOD_TWILIGHT = 2,
TOD_NIGHT = 3,
TOD_LATE_NIGHT = 4,
};

void InitRTC(void);
void UpdateRTC(void);
void GetCurrentDateTime(RTCDate * date, RTCTime * time);
void GetCurrentTime(RTCTime * time);
void GetCurrentDate(RTCDate * date);
int GetSecondsSinceMidnight(void);
s64 GetTimestamp(void);
int DayNumberForDate(const RTCDate * date);
BOOL IsNight(void);
enum TimeOfDay GetTimeOfDay(void);
enum TimeOfDay TimeOfDayForHour(int hour);
s64 TimeElapsed(s64 since, s64 until);

#endif // POKEPLATINUM_RTC_H
4 changes: 2 additions & 2 deletions include/unk_02000C88.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <nitro/fs.h>

void sub_02000EC4(FSOverlayID param0, const UnkStruct_0208BE5C * param1);
void sub_02001028(void);
void sub_0200106C(void);
void InitRNG(void);
void HandleConsoleFold(void);

#endif // POKEPLATINUM_UNK_02000C88_H
2 changes: 1 addition & 1 deletion include/unk_02003B60.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <nnsys.h>

void sub_02003B60(ChatotCry * param0, AnimationControlFlags * param1);
void sub_02003BD8(void);
void UpdateSound(void);
void sub_02003D0C(int param0);
UnkStruct_02003D54 * sub_02003D54(void);
void * sub_02003D5C(int param0);
Expand Down
20 changes: 0 additions & 20 deletions include/unk_0201378C.h

This file was deleted.

28 changes: 14 additions & 14 deletions include/unk_02017728.h
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
#ifndef POKEPLATINUM_UNK_02017728_H
#define POKEPLATINUM_UNK_02017728_H

#include "functypes/funcptr_02017798.h"
#include "core_sys.h"

void sub_02017728(void);
void sub_02017798(UnkFuncPtr_02017798 param0, void * param1);
void sub_020177A4(void);
BOOL sub_020177BC(UnkFuncPtr_02017798 param0, void * param1);
void SetMainCallback(Callback cb, void *data);
void DisableHBlank(void);
BOOL SetHBlankCallback(Callback cb, void *data);
void sub_0201789C(void);
void sub_020179E4(void);
void * ReadFileToHeap(int heapID, const char * filename);
void ReadFileToBuffer(const char * filename, void ** buf);
void InitGraphics(void);
void * ReadFileToHeap(int heapID, const char *filename);
void ReadFileToBuffer(const char *filename, void **buf);
void sub_02017ACC(void);
void InitKeypadAndTouchpad(void);
void sub_02017B70(int param0);
void sub_02017B7C(u8 param0);
void sub_02017B8C(u8 param0);
void SleepLock(u8 param0);
void SleepUnlock(u8 param0);
void ReadKeypadAndTouchpad(void);
void SetAutorepeat(int rate, int delay);
void sub_02017DE0(u8 param0);
void sub_02017DF0(u8 param0);
void sub_02017E00(int param0);
void sub_02017E2C(void);
BOOL sub_02017E54(void);
void ResetLock(u8 param0);
void ResetUnlock(u8 param0);
void InitHeapCanary(int param0);
void FreeHeapCanary(void);
BOOL HeapCanaryOK(void);

#endif // POKEPLATINUM_UNK_02017728_H
4 changes: 2 additions & 2 deletions include/unk_0201E3D8.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ u32 sub_0201E450(u32 param0);
u32 sub_0201E530(void);
u32 sub_0201E564(UnkStruct_ov72_0223E2A8 * param0, u32 param1, u32 param2);
void sub_0201E5C0(TPData * param0, u32 param1);
void sub_0201E5FC(void);
void sub_0201E630(void);
void AfterSleep(void);
void BeforeSleep(void);

#endif // POKEPLATINUM_UNK_0201E3D8_H
2 changes: 1 addition & 1 deletion platinum.us/main.lsf
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Static main
Object main.nef.p/src_unk_02012480.c.o
Object main.nef.p/src_unk_02012744.c.o
Object main.nef.p/src_unk_020131EC.c.o
Object main.nef.p/src_unk_0201378C.c.o
Object main.nef.p/src_rtc.c.o
Object main.nef.p/src_unk_02013A04.c.o
Object main.nef.p/src_unk_02013B10.c.o
Object main.nef.p/src_unk_02014000.c.o
Expand Down
8 changes: 4 additions & 4 deletions src/error_message_reset.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ void ErrorMessageReset_PrintErrorAndReset (void)
OS_SetIrqFunction(OS_IE_V_BLANK, VBlankIntr);
OS_EnableIrqMask(OS_IE_V_BLANK);

sub_02017798(NULL, NULL);
sub_020177BC(NULL, NULL);
SetMainCallback(NULL, NULL);
SetHBlankCallback(NULL, NULL);

GXLayers_DisableEngineALayers();
GXLayers_DisableEngineBLayers();
Expand Down Expand Up @@ -167,7 +167,7 @@ void ErrorMessageReset_PrintErrorAndReset (void)
sub_02037DB0();

while (TRUE) {
sub_0200106C();
HandleConsoleFold();
sub_020349EC();

if (sub_02038AB8()) {
Expand All @@ -178,7 +178,7 @@ void ErrorMessageReset_PrintErrorAndReset (void)
}

while (TRUE) {
sub_0200106C();
HandleConsoleFold();

if (PAD_Read() & PAD_BUTTON_A) {
break;
Expand Down
Loading

0 comments on commit f360401

Please sign in to comment.