diff --git a/headers/functions/arm9.h b/headers/functions/arm9.h index a523ba3e..0445875c 100644 --- a/headers/functions/arm9.h +++ b/headers/functions/arm9.h @@ -485,6 +485,9 @@ uint32_t DecodeFragmentByteAssemblyTable(struct wan_fragment_bytes_assembly_entr void* dst); int LoadObjPalette(struct obj_graphics_control* obj_graphics_control, struct palette_init_info* palette_init_info, uint8_t palette_num); +int AddWanFragmentToOam(struct obj_graphics_control* obj_graphics_control, + struct wan_fragment* fragment, uint16_t* param_3, + uint16_t* oam_adjustment_info); int AddSimpleObjToOam(struct obj_graphics_control* obj_graphics_control, uint16_t* obj, int group); void GroupOamAttributesWrapper(struct obj_graphics_control* obj_graphics_control); void CopyAttributesToOamWrapper(struct obj_graphics_control* obj_graphics_control); @@ -495,6 +498,7 @@ void InitObjGraphicsControls(void); void CopyAttributesToOamBothScreens(void); void GroupOamAttributesBothScreens(void); void CopyAndInterleaveWrapper(uint16_t* dst, uint16_t* src, uint32_t len, uint8_t val); +void InitOamAdjustmentInfo(uint16_t* oam_adjustment_info); void InitAnimationControl(struct animation_control* animation_control); void InitAnimationControlWithSet(struct animation_control* animation_control); void SetSpriteIdForAnimationControl(struct animation_control* anim_ctrl, uint16_t sprite_id); @@ -512,7 +516,7 @@ void SetAndPlayAnimationForAnimationControl(struct animation_control* anim_ctrl, void SwitchAnimationControlToNextFrame(struct animation_control* anim_ctrl); void LoadAnimationFrameAndIncrementInAnimationControl(struct animation_control* anim_ctrl, struct wan_animation_frame* anim_frame); -void FillOamAttributeInfo(struct animation_control* dst, uint16_t* src); +void FillOamAdjustmentInfo(struct animation_control* dst, uint16_t* src); uint32_t AnimationControlGetAllocForMaxFrame(struct animation_control* anim_ctrl); void DeleteWanTableEntry(struct wan_table* wan_table, int wan_id); int AllocateWanTableEntry(struct wan_table* wan_table); @@ -553,6 +557,7 @@ void GeomSetVertexCoord16(int x, int y, int z); void InitRender3dData(void); void GeomSwapBuffers(void); void InitRender3dElement64(struct render_3d_element_64* element64); +int GetPaletteBaseAddress(undefined4 pal_vram_offset_upper, undefined4 pal_vram_offset_lower); void Render3d64Texture0x7(struct render_3d_element_64* element64); void Render3d64WindowFrame(struct render_3d_element_64* element64); void EnqueueRender3d64Tiling(struct render_3d_element_64* element64); @@ -568,7 +573,7 @@ void ConvertPointersSir0(undefined* sir0_ptr); int HandleSir0TranslationVeneer(uint8_t** dst, uint8_t* src); void FillPaletteInitInfo(struct palette_init_info* palette_init_info, struct rgba* palette_bytes, uint16_t palette_mode, uint16_t nb_colors_or_palettes, - uint16_t ext_palette_upper, int8_t palette_num_custom); + uint16_t ext_palette_start, int8_t palette_num_custom); int DecompressAtNormalVeneer(undefined* addr_decomp, int expected_size, undefined* at_ptr); int DecompressAtNormal(undefined* addr_decomp, int expected_size, undefined* at_ptr); int DecompressAtHalf(undefined* addr_decomp, int expected_size, undefined* at_ptr, int high_nibble); @@ -589,6 +594,11 @@ int PreprocessStringFromId(char* output, int output_size, int string_id, bool StrcmpTagVeneer(const char* s1, const char* s2); int AtoiTagVeneer(const char* s); void InitPreprocessorArgs(struct preprocessor_args* args); +void CopyOrInitPreprocessorArgs(struct preprocessor_args* out, struct preprocessor_args* in); +void QuantityToString(char* s, int quantity, uint8_t adj_size, undefined4 param_4); +void MoneyQuantityToString(char* s, int quantity); +void BankQuantityToString(char* s, int quantity); +void ExpQuantityToString(char* s, int quantity); char* SetStringAccuracy(char* s, int param_2); char* SetStringPower(char* s, int param_2); char* GetRankString(char* s, int rank_and_flags); @@ -625,7 +635,6 @@ 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); -int GetPaletteBaseAddress(undefined4 pal_vram_offset_upper, undefined4 pal_vram_offset_lower); void SetScreenWindowsColor(int palette_idx, bool upper_screen); void SetBothScreensWindowsColor(int palette_idx); void UpdateWindow(int window_id); diff --git a/headers/functions/overlay29.h b/headers/functions/overlay29.h index df7bba4a..5bbdfc88 100644 --- a/headers/functions/overlay29.h +++ b/headers/functions/overlay29.h @@ -57,7 +57,7 @@ int GetVisibilityRange(void); void RevealWholeFloor(struct entity* entity); int PlayEffectAnimationEntity(struct entity* entity, int effect_id, bool play_now, int param_4, int param_5, undefined param_6, enum direction_id effect_dir, - undefined2* param_8); + uint16_t* custom_oam_adjustment_info); int PlayEffectAnimationPos(struct position* pos, int effect_id, bool play_now); int PlayEffectAnimationPixelPos(struct pixel_position* pixel_pos, int effect_id, bool play_now); void AnimationDelayOrSomething(undefined param_1); @@ -88,6 +88,7 @@ bool ShouldDisplayEntityAdvanced(struct entity* entity); void PlayEffectAnimation0x1A9(struct entity* entity); void PlayEffectAnimation0x29(struct entity* entity); void PlayEffectAnimation0x18E(struct entity* entity); +void PlayStairSensorArrowEffect(struct entity* entity, enum direction_id arrow_dir); void LoadMappaFileAttributes(int quick_saved, bool disable_monsters, undefined* special_process); enum trap_id GetRandomSpawnTrapId(void); enum trap_id GetRandomTrapId(void); @@ -147,6 +148,8 @@ int CalcStatusDuration(struct entity* entity, int16_t* turn_range, bool iq_skill void DungeonRngUnsetSecondary(void); void DungeonRngSetSecondary(int i); void DungeonRngSetPrimary(void); +void PlayLevelUpSound(void); +void PlayDungeonTipSound(void); void PlaySeByIdIfNotSilence(int se_id); void PlayMeByIdIfNot998(int me_id); enum music_id MusicTableIdxToMusicId(int music_table_idx); @@ -293,7 +296,12 @@ bool ShouldMonsterHeadToStairs(struct entity* entity); void DisplayLinkedMovesWarnings(struct entity* entity, int move_slot); bool MewSpawnCheck(enum monster_id monster_id, bool fail_if_mew); void TryEndStatusWithAbility(struct entity* attacker, struct entity* defender); +void TryActivateNewFloorPpRestoration(bool suppress_logs); bool ExclusiveItemEffectIsActive(struct entity* entity, enum exclusive_item_effect_id effect_id); +void TryActivateNewFloorHpRestoration(bool log_failure); +void TryActivateStairSensor(bool suppress_logs); +void TryActivateAcuteSniffer(bool suppress_logs); +bool ShouldTreatMonsterAsAlly(struct entity* entity1, struct entity* entity2); struct entity* GetTeamMemberWithIqSkill(enum iq_skill_id iq_skill); bool TeamMemberHasEnabledIqSkill(enum iq_skill_id iq_skill); bool TeamLeaderIqSkillIsEnabled(enum iq_skill_id iq_skill); @@ -406,6 +414,7 @@ bool IsTacticSet(struct entity* entity, enum tactic_id tactic_id); bool HasDropeyeStatus(struct entity* entity); bool IqSkillIsEnabled(struct entity* entity, enum iq_skill_id iq_id); void UpdateIqSkills(struct monster* monster); +void UpdateIqSkillsWrapper(struct entity* entity); bool CanSeeTeammate(struct monster* monster); enum type_id GetMoveTypeForMonster(struct entity* entity, struct move* move); int GetMovePower(struct entity* entity, struct move* move); @@ -507,6 +516,12 @@ void UpdateShopkeeperModeAfterTrap(struct entity* shopkeeper, bool non_team_memb void ResetDamageCalcDiagnostics(void); void PointCameraToMonsterWrapper(struct entity* entity); bool IsEitherMonsterInvalid(struct entity* entity1, struct entity* entity2); +void SwapDefensiveStages(struct entity* attacker, struct entity* defender, bool log_message); +void SwapDefensiveMultipliers(struct entity* attacker, struct entity* defender, bool log_message); +void SwapOffensiveStages(struct entity* attacker, struct entity* defender, bool log_message); +void SwapOffensiveMultipliers(struct entity* attacker, struct entity* defender, bool log_message); +void SwapHitChanceStages(struct entity* attacker, struct entity* defender, bool log_message); +void SwapUserAtkAndDefModifiers(struct entity* attacker, struct entity* defender, bool log_message); bool SpecificRecruitCheck(enum monster_id monster_id); bool RecruitCheck(struct entity* user, struct entity* target); bool TryRecruit(struct entity* user, struct entity* recruit); @@ -795,10 +810,11 @@ void ActivateSportCondition(bool water_sport); bool TryActivateWeather(bool param_1, bool param_2); int DigitCount(int n); void LoadTextureUi(void); +void InitUi3dElement(struct render_3d_element_64* element64, undefined4 pal_vram_offset_upper); int GetPaletteBaseAddressOv29(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); + undefined4 pal_vram_offset_lower); void DisplayUi(void); struct tile* GetTile(int x, int y); struct tile* GetTileSafe(int x, int y); diff --git a/headers/types/common/graphics.h b/headers/types/common/graphics.h index 2de0cf30..63cd0273 100644 --- a/headers/types/common/graphics.h +++ b/headers/types/common/graphics.h @@ -18,12 +18,12 @@ struct animation_control { uint16_t field6_0xc; // (from struct entity) animation frame counter for the idle animation? undefined field7_0xe; undefined field8_0xf; - // 0x10: Information used to create an object's OAM attributes. + // 0x10: Information used to adjust an object's OAM attributes. // See https://problemkaputt.de/gbatek.htm#lcdobjoamattributes - // To do so, the first three elements of the array are ANDed with some value, then ORed - // with the element three indexes above. - // Notably, setting bit 0x400 of oam_attribute_info[3] will make the object semi-transparent. - uint16_t oam_attribute_info[6]; + // To do so, each attribute is ANDed with the corresponding element in the first half + // of the array, then ORed with the corresponding element in the second half. + // Notably, setting bit 0x400 of oam_adjustment_info[3] will make the object semi-transparent. + uint16_t oam_adjustment_info[6]; struct vec2_16 position; struct vec2_16 anim_frame_offset; struct vec2_16 anim_frame_shadow_offset; diff --git a/headers/types/files/wan.h b/headers/types/files/wan.h index 8ac42c79..7d56cb84 100644 --- a/headers/types/files/wan.h +++ b/headers/types/files/wan.h @@ -39,7 +39,7 @@ struct palette_init_info { // https://problemkaputt.de/gbatek.htm#dsvideoextendedpalettes uint16_t palette_mode; uint16_t nb_colors_or_palettes; // 0x6 - uint16_t ext_palette_upper; // 0x8: Upper 4 bits in 256-color extended palette + uint16_t ext_palette_start; // 0x8: Starting position in 256-color extended palette int8_t palette_num_custom; // 0xA: If not -1, overwrites palette_num in LoadObjPalette // 0xB: If 1, splits the palette in chunks of 0x10 across multiple // extended palettes starting from palette_num @@ -103,16 +103,19 @@ ASSERT_SIZE(struct wan_header, 10); struct wan_fragment { // negative mean using the previous defined fragment bytes (or to not update it?) int16_t fragment_bytes_index; - int8_t unk1; - int8_t unk2; + int16_t unk1; // 2 bytes int8_t offset_y : 8; bool unk3 : 1; bool unk4 : 1; - uint8_t likely_padding_1 : 3; + // 0=Normal, 1=Semi-Transparent, 2=OBJ Window, 3=Prohibited + // Seemingly always 0 in the base game, but still works properly for creating + // semi-transparent objects assuming it is not zeroed by oam_adjustment_info. + uint8_t obj_mode : 2; + uint8_t likely_padding_1 : 1; bool is_mosaic : 1; - uint8_t shape_indice : 2; // as used in OBJ attribute 1 + uint8_t shape_indice : 2; // as used in OBJ attribute 0 // 2 bytes uint16_t offset_x : 9; // The value to be used is this - 256, which can end up negative. @@ -121,7 +124,7 @@ struct wan_fragment { bool is_last : 1; bool h_flip : 1; bool v_flip : 1; - uint8_t size_indice : 2; // as used in OBJ attribute 0 + uint8_t size_indice : 2; // as used in OBJ attribute 1 // 2 bytes uint16_t fragment_alloc_counter : 10; diff --git a/symbols/arm9.yml b/symbols/arm9.yml index 693ff6ff..c29900c0 100644 --- a/symbols/arm9.yml +++ b/symbols/arm9.yml @@ -1161,7 +1161,7 @@ arm9: r0: oam_info r1: oam_attributes - r2: group + r2: priority group - name: UpdateFadeStatus address: EU: 0x200BA18 @@ -4701,6 +4701,17 @@ arm9: r1: palette_init_info r2: palette_num (bits 12-15 of OAM attribute 2) return: always 1 + - name: AddWanFragmentToOam + address: + EU: 0x201B770 + description: |- + Adds a WAN fragment to OAM. + + r0: obj_graphics_control + r1: wan_fragment + r2: ? + r3: oam_adjustment_info (length 6 array, or null to not adjust) + return: -2 if group out of bounds, -1 if too many objects, 0 if successful - name: AddSimpleObjToOam address: EU: 0x201BA94 @@ -4714,7 +4725,7 @@ arm9: r0: obj_graphics_control r1: obj - r2: group + r2: priority group return: -2 if group out of bounds, -1 if too many objects, 0 if successful - name: GroupOamAttributesWrapper address: @@ -4775,6 +4786,13 @@ arm9: r1: src r2: len (in bytes, will be divided by 2 in the call to CopyAndInterleave) r3: val + - name: InitOamAdjustmentInfo + address: + EU: 0x201C09C + description: |- + Initializes an oam_adjustment_info array that will be used in an animation_control structure with default values (0xFFFF for the ANDs, 0 for the ORs). + + r0: [output] oam_adjustment_info array (length 6) - name: InitAnimationControl address: EU: 0x201C0EC @@ -4895,13 +4913,15 @@ arm9: r0: animation_control r1: animation_frame - - name: FillOamAttributeInfo + - name: FillOamAdjustmentInfo + aliases: + - FillOamAttributeInfo address: EU: 0x201D1AC NA: 0x201D110 JP: 0x201D168 description: |- - Copies an array of values into an animation_control struct's oam_attribute_info. + Copies an array of values into an animation_control struct's oam_adjustment_info. r0: animation_control r1: source array (length 6) @@ -5227,6 +5247,20 @@ arm9: Initialize the render_3d_element_64 structure (without performing any drawing or external data access) r0: render_3d_element_64 + - name: GetPaletteBaseAddress + address: + EU: + - 0x201E858 + - 0x2027B9C + NA: 0x20278A8 + JP: 0x2027C08 + description: |- + Gets the palette base address for a 3D element loaded from a WTE file. + Normally 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: Render3d64Texture0x7 address: EU: 0x201E8E0 @@ -5600,9 +5634,55 @@ arm9: NA: 0x2023690 JP: 0x20236E0 description: |- - Initializes a struct preprocess_args. + Initializes a preprocessor_args struct. r0: preprocessor args pointer + - name: CopyOrInitPreprocessorArgs + address: + EU: 0x2023920 + description: |- + Copies the input preprocessor_args struct to the output struct, or initializes it if the input is a null pointer. + + r0: [output] preprocessor args pointer + r1: input preprocessor args pointer, or null if should initialize one + - name: QuantityToString + address: + EU: 0x20239D8 + description: |- + Converts a quantity to a string, adding commas in between numbers when appropriate. + + r0: [output] string + r1: quantity + r2: adjusted size (if there are less characters in the string than this number, leading spaces will be added to make it this size) + r3: ? + - name: MoneyQuantityToString + address: + EU: + - 0x2023B30 + - 0x2023B58 + description: |- + Converts a money quantity to a string, adding commas in between numbers when appropriate. + + Note that this function does not add the P symbol at the end. + + r0: [output] string + r1: quantity + - name: BankQuantityToString + address: + EU: 0x2023B44 + description: |- + Converts a money quantity shown in the bank menu to a string, adding commas in between numbers when appropriate and also adding leading spaces. + + r0: [output] string + r1: quantity + - name: ExpQuantityToString + address: + EU: 0x2023B6C + description: |- + Converts an experience quantity to a string, adding commas in between numbers when appropriate. + + r0: [output] string + r1: quantity - name: SetStringAccuracy address: EU: 0x20245C0 @@ -5991,18 +6071,6 @@ arm9: r0: window_params pointer to be copied by value into window::hdr in the new window r1: ? return: window_id - - name: GetPaletteBaseAddress - address: - EU: 0x2027B9C - NA: 0x20278A8 - JP: 0x2027C08 - 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: SetScreenWindowsColor address: EU: 0x2027D5C diff --git a/symbols/overlay29.yml b/symbols/overlay29.yml index 9e2c55ce..239df016 100644 --- a/symbols/overlay29.yml +++ b/symbols/overlay29.yml @@ -763,6 +763,7 @@ overlay29: r1: Effect ID r2: appears to be a flag for actually running the animation now? If this is 0, the AdvanceFrame loop is skipped entirely. stack[2]: direction of effect + stack[3]: custom oam_adjustment_info array for the animation_control struct (length 6, or null if should use default values) others: ? return: status code, or maybe the number of frames or something? Either way, -1 seems to indicate the animation being finished or something? - name: PlayEffectAnimationPos @@ -1087,6 +1088,14 @@ overlay29: Just a guess. Calls PlayEffectAnimation with data from animation ID 0x18E. r0: entity pointer + - name: PlayStairSensorArrowEffect + address: + EU: 0x22E72D8 + description: |- + Plays the Stair Sensor arrow effect. + + r0: entity pointer + r1: arrow direction - name: LoadMappaFileAttributes address: EU: 0x22E796C @@ -1673,6 +1682,22 @@ overlay29: description: |- Sets the dungeon PRNG to use the primary LCG for subsequent random number generation. + No params. + - name: PlayLevelUpSound + address: + EU: 0x22EB62C + description: |- + Plays the sound for leveling up. + + No params. + - name: PlayDungeonTipSound + address: + EU: + - 0x22EB63C + - 0x22EB66C + description: |- + Plays the sound effect for displaying a dungeon tip. + No params. - name: PlaySeByIdIfNotSilence address: @@ -3096,6 +3121,13 @@ overlay29: r0: attacker entity pointer r1: defender entity pointer + - name: TryActivateNewFloorPpRestoration + address: + EU: 0x22FB464 + description: |- + Activates the Deep Breather IQ skill and/or the exclusive item effect for restoring PP on new floors for team members that have them. + + r0: flag to suppress message logging - name: ExclusiveItemEffectIsActive address: EU: @@ -3143,6 +3175,36 @@ overlay29: r0: entity pointer r1: exclusive item effect ID return: bool + - name: TryActivateNewFloorHpRestoration + address: + EU: 0x22FB6C8 + description: |- + Activates the exclusive item effect for fully restoring HP on new floors for team members that have it. + + r0: flag to log a message on failure + - name: TryActivateStairSensor + address: + EU: 0x22FB758 + description: |- + Activates the Stair Sensor IQ skill if a member on the team has it and they are not a special story ally. + + r0: flag to suppress message logging + - name: TryActivateAcuteSniffer + address: + EU: 0x22FB914 + description: |- + Activates the Acute Sniffer IQ skill if a member on the team has it and no boss fight is active. + + r0: flag to suppress message logging + - name: ShouldTreatMonsterAsAlly + address: + EU: 0x22FB9E0 + description: |- + Returns true if entity 1 should treat entity 2 as an ally, assuming entity 1 can see invisible monsters and will not ignore petrified ones. + + r0: Pointer to entity 1 + r1: Pointer to entity 2 + return: bool - name: GetTeamMemberWithIqSkill address: EU: 0x22FBA04 @@ -4274,6 +4336,13 @@ overlay29: Called after exiting the IQ skills menu or after an enemy spawns. r0: monster pointer + - name: UpdateIqSkillsWrapper + address: + EU: 0x2302C1C + description: |- + Wrapper function for UpdateIqSkills. + + r0: monster entity pointer - name: CanSeeTeammate address: EU: 0x2302C2C @@ -5123,6 +5192,60 @@ overlay29: r0: entity pointer r1: entity pointer return: bool + - name: SwapDefensiveStages + address: + EU: 0x230E2E8 + description: |- + Swaps the defensive stages of two monsters. + + r0: attacker pointer + r1: defender pointer + r2: whether to log a message + - name: SwapDefensiveMultipliers + address: + EU: 0x230E35C + description: |- + Swaps the defensive multipliers of two monsters. + + r0: attacker pointer + r1: defender pointer + r2: whether to log a message + - name: SwapOffensiveStages + address: + EU: 0x230E3D0 + description: |- + Swaps the offensive stages of two monsters. + + r0: attacker pointer + r1: defender pointer + r2: whether to log a message + - name: SwapOffensiveMultipliers + address: + EU: 0x230E444 + description: |- + Swaps the offensive multipliers of two monsters. + + r0: attacker pointer + r1: defender pointer + r2: whether to log a message + - name: SwapHitChanceStages + address: + EU: 0x230E4B8 + description: |- + Swaps the hit chance stages of two monsters. + + r0: attacker pointer + r1: defender pointer + r2: whether to log a message + - name: SwapUserAtkAndDefModifiers + address: + EU: 0x230E52C + description: |- + Swaps the attack and defense modifiers of the user entity. + + r0: attacker pointer + r1: defender pointer + r2: whether to log a message - name: SpecificRecruitCheck address: EU: 0x230E588 @@ -7753,6 +7876,14 @@ overlay29: Note: unverified, ported from Irdkwia's notes No params. + - name: InitUi3dElement + address: + EU: 0x2336254 + description: |- + Initializes a 3D element for displaying a part of the dungeon UI. + + r0: [output] render_3d_element_64 + r1: upper part of the palette VRAM - name: GetPaletteBaseAddressOv29 aliases: - GetPaletteBaseAddress @@ -7762,7 +7893,7 @@ overlay29: JP: 0x2336C34 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. + Normally takes the same parameters as were used in the specified file's ProcessWte call. Is an exact copy of GetPaletteBaseAddress in arm9. @@ -7794,7 +7925,7 @@ overlay29: r1: x position r2: y position r3: char_id - stack[0]: ? + stack[0]: lower part of the palette VRAM return: ? - name: DisplayUi address: