Skip to content

Commit

Permalink
Small assortment of arm9 stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Adex-8x committed Dec 21, 2024
1 parent d5d2460 commit d233b79
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 2 deletions.
10 changes: 9 additions & 1 deletion headers/functions/arm9.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,17 @@ void HaltProcessDisp(int status);
bool OverlayIsLoaded(enum overlay_group_id group_id);
void LoadOverlay(enum overlay_group_id group_id);
void UnloadOverlay(enum overlay_group_id group_id);
void GetDsFirmwareUserSettingsVeneer(struct user_settings* settings);
void Rgb8ToRgb5(struct rgb5* target, struct rgba* source);
float EuclideanNorm(int* vec2);
void ClampComponentAbs(int* vec2, int max);
bool GetHeldButtons(int controller, undefined* btn_ptr);
bool GetPressedButtons(int controller, undefined* btn_ptr);
bool GetReleasedStylus(undefined* stylus_ptr);
void KeyWaitInit(void);
void DebugPrintSystemClock(void);
void GetSystemClock(struct system_clock* clock);
void SprintfSystemClock(struct system_clock* clock, char* str);
void DataTransferInit(void);
void DataTransferStop(void);
void FileInitVeneer(struct file_stream* file);
Expand Down Expand Up @@ -522,7 +526,9 @@ void LoadTblTalk(void);
int GetTalkLine(int personality_idx, int group_id, int restrictions);
bool IsAOrBPressed(void);
void DrawTextInWindow(int window_id, int x, int y, char* string);
uint8_t GetCharWidth(char symbol);
int GetColorCodePaletteOffset(char symbol);
uint8_t DrawChar(int window_id, int x, int y, char symbol, int color_offset);
struct window* GetWindow(int window_id);
int NewWindowScreenCheck(struct window_params* params, uint8_t param_2);
int NewWindow(struct window_params* params, uint8_t param_2);
Expand Down Expand Up @@ -602,10 +608,12 @@ void SetCollectionMenuField0x1B2(int window_id, undefined4 value);
bool IsCollectionMenuState3(int window_id);
int CreateOptionsMenu(struct window_params* params, struct window_flags flags,
struct window_extra_info* window_extra_info,
struct options_menu_id_item* menu_items, int n_items, undefined4* param_6);
struct options_menu_id_item* menu_items, int n_items, int* option_states);
void CloseOptionsMenu(int window_id);
bool IsOptionsMenuActive(int window_id);
bool CheckOptionsMenuField0x1A4(int window_id);
void GetOptionsMenuStates(int window_id, int* option_states);
bool GetOptionsMenuResult(int window_id);
void UpdateOptionsMenu(struct window* window);
int CreateDebugMenu(struct window_params* params, struct window_flags flags,
struct window_extra_info* window_extra_info, uint16_t* menu_item_string_ids,
Expand Down
1 change: 1 addition & 0 deletions headers/functions/arm9/libs.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ int EnableIrqFiqFlags(void);
int SetIrqFiqFlags(int new_value);
int GetIrqFlag(void);
int GetProcessorMode(void);
void GetDsFirmwareUserSettings(struct user_settings* settings);
uint32_t CountLeadingZeros(uint32_t x);
void WaitForever2(void);
void WaitForInterrupt(void);
Expand Down
39 changes: 39 additions & 0 deletions headers/types/common/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,4 +257,43 @@ struct thread_info {
};
ASSERT_SIZE(struct thread_info, 52); // Could be shorter

// Language and flags of the DS firmware user settings.
// Although in total, the language and flags consist of two bytes, calling GetDsFirmwareUserSettings only results in the lower byte being saved.
struct language_and_flags {
uint8_t language : 3;
bool gba_mode_screen : 1;
uint8_t backlight_level : 2;
bool bootmenu_disable : 1;
undefined field_0x7 : 1;
};
ASSERT_SIZE(struct language_and_flags, 1);

// Various pieces of user settings originating from the DS firmware.
// See https://problemkaputt.de/gbatek.htm#dsfirmwareusersettings
struct user_settings {
struct language_and_flags language_and_flags;
uint8_t favorite_color;
uint8_t birthday_month;
uint8_t birthday_day;
uint16_t nickname[10]; // UTF-16 string
undefined2 field_0x18; // always 0; null terminator for nickname?
uint16_t nickname_length;
uint16_t message[26]; // UTF-16 string
undefined2 field_0x50; // always 0; null terminator for message?
uint16_t message_length;
};
ASSERT_SIZE(struct user_settings, 84);

// Fields of the DS system clock.
struct system_clock {
undefined4 field_0x0; // always 0
int second;
int minute;
int hour;
int day;
int month;
int year;
};
ASSERT_SIZE(struct system_clock, 28);

#endif
85 changes: 84 additions & 1 deletion symbols/arm9.yml
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,17 @@ arm9:
r0: group ID of the overlay to unload
others: ?
- name: GetDsFirmwareUserSettingsVeneer
address:
EU: 0x2004F74
NA: 0x2004F74
JP: 0x2004F74
description: |-
Likely a linker-generated veneer for GetDsFirmwareUserSettings.
See https://developer.arm.com/documentation/dui0474/k/image-structure-and-generation/linker-generated-veneers/what-is-a-veneer-
r0: user_settings pointer
- name: Rgb8ToRgb5
address:
EU: 0x2004FCC
Expand Down Expand Up @@ -912,6 +923,34 @@ arm9:
Implements (most of?) SPECIAL_PROC_KEY_WAIT_INIT (see ScriptSpecialProcessCall).
No params.
- name: DebugPrintSystemClock
address:
EU: 0x2006EF8
NA: 0x2006EF8
JP: 0x2006EF8
description: |-
This function prints the debug message "Now date & time" followed by the current date and time of the DS system clock. Called on boot.
No params.
- name: GetSystemClock
address:
EU: 0x2006F68
NA: 0x2006F68
JP: 0x2006F68
description: |-
Gets information surrounding the DS system clock, such as the current month, day, etc.
r0: system_clock pointer
- name: SprintfSystemClock
address:
EU: 0x2006FB8
NA: 0x2006FB8
JP: 0x2006FB8
description: |-
Calls sprintf to format a string using the fields of the DS system clock as "year/month/day hour:minute:second". Used in DebugPrintSystemClock.
r0: system_clock pointer
r1: str
- name: DataTransferInit
aliases:
- FileRom_InitDataTransfer
Expand Down Expand Up @@ -5070,6 +5109,16 @@ arm9:
r1: x offset within window
r2: y offset within window
r3: text to draw
- name: GetCharWidth
address:
EU: 0x2026830
NA: 0x202654C
JP: 0x2026624
description: |-
Gets the width of a text char.
r0: char
return: char width
- name: GetColorCodePaletteOffset
address:
EU: 0x20268A8
Expand All @@ -5082,6 +5131,20 @@ arm9:
r0: char
return: offset
- name: DrawChar
address:
EU: 0x2026A50
NA: 0x202676C
JP: 0x2026844
description: |-
Draws a single char within a window. This function is also responsible for drawing the shadows of a char.
r0: window_id
r1: x offset within window
r2: y offset within window
r3: char
stack[0]: color offset
return: char width
- name: GetWindow
address:
EU: 0x20278EC
Expand Down Expand Up @@ -5779,7 +5842,7 @@ arm9:
r2: window_extra_info pointer
r3: options_menu_id_item struct array, terminated with an item with msg_id 0
stack[0]: number of items
stack[1]: ?
stack[1]: option_states pointer
return: window_id
- name: CloseOptionsMenu
address:
Expand Down Expand Up @@ -5810,6 +5873,26 @@ arm9:
description: |-
Checks if options_menu::field_0x1a4 is 0.
r0: window_id
return: bool
- name: GetOptionsMenuStates
address:
EU: 0x202D8A4
NA: 0x202D5B0
JP: 0x202D908
description: |-
Gets all the option menu states; used to determine what options the user has selected in a menu. Each option state corresponds a options_menu_id_item.
r0: window_id
r1: option_states pointer
- name: GetOptionsMenuResult
address:
EU: 0x202D8D8
NA: 0x202D5E4
JP: 0x202D93C
description: |-
Returns whether or not the options menu was confirmed or canceled (e.g., by pressing the B button).
r0: window_id
return: bool
- name: UpdateOptionsMenu
Expand Down
11 changes: 11 additions & 0 deletions symbols/arm9/libs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1979,6 +1979,17 @@ libs:
See https://problemkaputt.de/gbatek.htm#armcpuflagsconditionfieldcond
return: cpsr & 0x1f (the cpsr mode bits M4-M0)
- name: GetDsFirmwareUserSettings
address:
EU: 0x207BDA0
NA: 0x207BA08
JP: 0x207BCF0
description: |-
Gets the user settings of the DS firmware.
See https://problemkaputt.de/gbatek.htm#dsfirmwareusersettings
r0: user_settings pointer
- name: CountLeadingZeros
address:
EU: 0x207BE24
Expand Down

0 comments on commit d233b79

Please sign in to comment.