diff --git a/headers/data/ram.h b/headers/data/ram.h index 5fe76651..371116b2 100644 --- a/headers/data/ram.h +++ b/headers/data/ram.h @@ -64,6 +64,7 @@ extern struct mem_arena* GROUND_MEMORY_ARENA_1_PTR; extern struct mem_arena* GROUND_MEMORY_ARENA_2_PTR; extern bool LOCK_NOTIFY_ARRAY[20]; extern struct mem_arena GROUND_MEMORY_ARENA_1; +extern struct dungeon_button_input DUNGEON_BUTTON_INPUT; extern struct mem_block GROUND_MEMORY_ARENA_1_BLOCKS[52]; extern uint8_t GROUND_MEMORY_ARENA_1_MEMORY[408324]; extern struct sentry_duty SENTRY_DUTY_STRUCT; diff --git a/headers/functions/arm9.h b/headers/functions/arm9.h index 99cefde4..65df6295 100644 --- a/headers/functions/arm9.h +++ b/headers/functions/arm9.h @@ -90,8 +90,8 @@ 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 GetHeldButtons(int controller, struct buttons* btn_ptr); +bool GetPressedButtons(int controller, struct buttons* btn_ptr); bool GetReleasedStylus(undefined* stylus_ptr); void KeyWaitInit(void); void DebugPrintSystemClock(void); @@ -476,8 +476,8 @@ void LoadWteFromFileDirectory(struct wte_handle* handle, enum pack_file_id pack_ uint16_t file_index, uint32_t malloc_flags); void UnloadWte(struct wte_handle* handle); undefined* LoadWtuFromBin(int bin_file_id, int file_id, int load_type); -void ProcessWte(undefined* wte_header_ptr, undefined4 pal_vram_offset, - undefined4 pal_texture_vram_offset_upper, undefined4 pal_texture_vram_offset_lower); +void ProcessWte(undefined* wte_header_ptr, undefined4 texture_vram_offset, + undefined4 pal_vram_offset_upper, undefined4 pal_vram_offset_lower); void DelayWteFree(struct wte_handle* handle); void ResetPlannedVramTransfer(struct delayed_texture_vram_container* container); uint32_t PlanCopyTextureToTextureVram(struct delayed_texture_vram_container* container, diff --git a/headers/functions/overlay29.h b/headers/functions/overlay29.h index ba97e7ce..5343a678 100644 --- a/headers/functions/overlay29.h +++ b/headers/functions/overlay29.h @@ -22,6 +22,7 @@ int GetScenarioBalanceVeneer(void); void FadeToBlack(void); void SetDungeonEscapeFields(uint32_t successful_exit_tracker, bool end_floor_no_death_check_flag); uint32_t GetSuccessfulExitTracker(void); +void GetAndStoreButtonInput(void); bool CheckTouchscreenArea(int x1, int y1, int x2, int y2); struct trap* GetTrapInfo(struct entity* trap_entity); struct item* GetItemInfo(struct entity* item_entity); @@ -748,6 +749,7 @@ void ActivateSportCondition(bool water_sport); bool TryActivateWeather(bool param_1, bool param_2); int DigitCount(int n); void LoadTextureUi(void); +int GetPaletteBaseAddress(undefined4 pal_vram_offset_upper, undefined4 pal_vram_offset_lower); int DisplayNumberTextureUi(int16_t x, int16_t y, int n, int ally_mode); int DisplayCharTextureUi(struct render_3d_element_64* element64, int16_t x, int16_t y, int char_id, int16_t param_5); diff --git a/headers/types/common/common.h b/headers/types/common/common.h index 0b49123d..0535cec8 100644 --- a/headers/types/common/common.h +++ b/headers/types/common/common.h @@ -1412,4 +1412,29 @@ struct options { }; ASSERT_SIZE(struct options, 10); +// This is the layout of all button bitflags in the input/controller structs. +// Derived from https://problemkaputt.de/gbatek.htm#gbakeypadinput +// as well as https://problemkaputt.de/gbatek.htm#dskeypad for the DS-specific buttons. +// Note that the referenced IO registers represent the flags the opposite way +// to this struct, using 0 to mean pressed and 1 to mean released. +struct buttons { + bool a : 1; + bool b : 1; + bool select : 1; + bool start : 1; + bool right : 1; + bool left : 1; + bool up : 1; + bool down : 1; + bool r : 1; + bool l : 1; + bool x : 1; + bool y : 1; + bool unk12 : 1; + bool debug : 1; + bool unk14 : 1; + bool unk15 : 1; +}; +ASSERT_SIZE(struct buttons, 2); + #endif diff --git a/headers/types/dungeon_mode/dungeon_mode.h b/headers/types/dungeon_mode/dungeon_mode.h index 7ae77e33..0e3827be 100644 --- a/headers/types/dungeon_mode/dungeon_mode.h +++ b/headers/types/dungeon_mode/dungeon_mode.h @@ -2564,6 +2564,21 @@ struct message_log_info { }; ASSERT_SIZE(struct message_log_info, 12); +// Contains information about the user's current button input in dungeon mode. +struct dungeon_button_input { + struct buttons cur_held_buttons; // 0x0 + struct buttons cur_pressed_buttons; // 0x2 + struct buttons field_0x4; + // 0x6: This and the next bitfield are duplicates of each other, and store whether + // a certain key has been released this frame after being held for 2-11 frames. + // Only implemented for B and R. + struct buttons cur_released_buttons; + struct buttons cur_released_buttons_2; // 0x8 + uint16_t b_frames_counter; // 0x10: How many frames B has been held for (caps at 100) + uint16_t r_frames_counter; // 0x10: How many frames R has been held for (caps at 100) +}; +ASSERT_SIZE(struct dungeon_button_input, 14); + // Separate this out into its own file because it's massive #include "dungeon.h" diff --git a/symbols/arm9.yml b/symbols/arm9.yml index d905b695..da1ff5c3 100644 --- a/symbols/arm9.yml +++ b/symbols/arm9.yml @@ -908,7 +908,7 @@ arm9: NA: 0x20061EC JP: 0x20061EC description: |- - Note: unverified, ported from Irdkwia's notes + Gets the currently held buttons. r0: controller r1: btn_ptr @@ -919,7 +919,7 @@ arm9: NA: 0x200625C JP: 0x200625C description: |- - Note: unverified, ported from Irdkwia's notes + Gets the currently pressed buttons. r0: controller r1: btn_ptr diff --git a/symbols/overlay29.yml b/symbols/overlay29.yml index 055fcaf8..7ead0416 100644 --- a/symbols/overlay29.yml +++ b/symbols/overlay29.yml @@ -358,6 +358,13 @@ overlay29: Returns the successful_exit_tracker field of the dungeon struct. return: successful_exit_tracker + - name: GetAndStoreButtonInput + address: + EU: 0x22E13A4 + description: |- + Gets and stores the button input for the current frame in DUNGEON_BUTTON_INPUT. + + No params. - name: CheckTouchscreenArea address: EU: 0x22E15F8 @@ -7347,6 +7354,16 @@ overlay29: Note: unverified, ported from Irdkwia's notes No params. + - name: GetPaletteBaseAddress + address: + EU: 0x23362B0 + description: |- + Gets the palette base address for a 3D element loaded from a WTE file. + Takes the same parameters as were used in the specified file's ProcessWte call. + + r0: upper part of the palette VRAM + r1: lower part of the palette VRAM + return: palette base address - name: DisplayNumberTextureUi address: EU: 0x23362CC diff --git a/symbols/ram.yml b/symbols/ram.yml index 12f33007..460703ca 100644 --- a/symbols/ram.yml +++ b/symbols/ram.yml @@ -642,6 +642,15 @@ ram: Including the allocator metadata, this arena occupies 0x64000 bytes of space. type: struct mem_arena + - name: DUNGEON_BUTTON_INPUT + address: + EU: 0x237D294 + length: + EU: 0xE + description: |- + [Runtime] Stores information about the user's current button input in dungeon mode. + + type: struct dungeon_button_input - name: GROUND_MEMORY_ARENA_1_BLOCKS address: NA: 0x2324FDC