diff --git a/asm/ground_sprite.s b/asm/ground_sprite.s index 499032aa..ca67ea03 100644 --- a/asm/ground_sprite.s +++ b/asm/ground_sprite.s @@ -5,54 +5,6 @@ .text - thumb_func_start sub_80A658C -sub_80A658C: - push {r4,lr} - bl sub_800DB7C - movs r0, 0 - bl ResetSprites - movs r0, 0 - bl nullsub_10 - bl sub_8005180 - bl nullsub_12 - bl CopySpritesToOam - bl nullsub_13 - bl sub_8005304 - bl nullsub_14 - ldr r0, _080A65D0 - ldr r0, [r0] - bl CloseFile - ldr r4, _080A65D4 - ldr r0, [r4] - bl MemoryFree - movs r0, 0 - str r0, [r4] - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_080A65D0: .4byte gUnknown_203B4B4 -_080A65D4: .4byte gUnknown_3001B7C - thumb_func_end sub_80A658C - - thumb_func_start sub_80A65D8 -sub_80A65D8: - adds r0, 0x50 - ldrh r0, [r0] - bx lr - thumb_func_end sub_80A65D8 - - thumb_func_start sub_80A65E0 -sub_80A65E0: - lsrs r0, 16 - ldr r2, _080A65EC - adds r1, r2, 0 - ands r0, r1 - bx lr - .align 2, 0 -_080A65EC: .4byte 0x0000337f - thumb_func_end sub_80A65E0 - thumb_func_start sub_80A65F0 sub_80A65F0: push {r4-r6,lr} diff --git a/include/axdata.h b/include/axdata.h new file mode 100644 index 00000000..5391ac5d --- /dev/null +++ b/include/axdata.h @@ -0,0 +1,107 @@ +#ifndef GUARD_AXDATA_H +#define GUARD_AXDATA_H + +#include "file_system.h" + +// size: 0x8 +struct UnkSpriteMem +{ + /* 0x0 */ void *src; + /* 0x4 */ s32 byteCount; +}; + +// size: 0x20 +struct axdata1 +{ + /* 0x0 */ s16 xPos; + /* 0x2 */ s16 yPos; + /* 0x4 */ u16 xOffset; + /* 0x6 */ u16 yOffset; + /* 0x8 */ u16 xShadow; + /* 0xA */ u16 yShadow; + u32 unkC; + u32 unk10; + /* 0x14 */ s16 vramTileOrMaybeAnimTimer; + s16 unk16; + /* 0x18 */ s16 poseId; + /* 0x1A */ s16 lastPoseId; + u8 fill1C[0x1E - 0x1C]; + u8 paletteNum; +}; + +// size: 0xA +struct __attribute__ ((packed, aligned(2))) ax_pose +{ + /* 0x0 */ s16 sprite; + u16 unk2; // Always 0 in red (except for end markers which are 0xFFFF) + /* 0x4 */ u16 flags1; + /* 0x6 */ u16 flags2; + /* 0x8 */ u16 flags3; +}; + +// size: 0xC +struct ax_anim +{ + /* 0x0 */ u8 frames; + /* 0x1 */ u8 unkFlags; + /* 0x2 */ s16 poseId; + /* 0x4 */ s16 xOffset; + /* 0x6 */ s16 yOffset; + /* 0x8 */ s16 xShadow; + /* 0xA */ s16 yShadow; +}; + +// size: 0x3C +struct axdata +{ + /* 0x0 */ u16 flags; + /* 0x2 */ u16 animFrames; + /* 0x4 */ u16 animWaitFrames; + /* 0x6 */ s16 totalFrames; + /* 0x8 */ struct axdata1 sub1; + /* 0x28 */ struct ax_anim *nextAnimData; + /* 0x2C */ struct ax_anim *activeAnimData; + /* 0x30 */ void *paletteData; // ? + /* 0x34 */ struct ax_pose *poseData; + /* 0x38 */ struct UnkSpriteMem **spriteData; +}; + +// size: 0x14 +struct axmain +{ + /* 0x0 */ struct ax_pose **poses; + /* 0x4 */ struct ax_anim ****animations; + /* 0x8 */ u32 animCount; + /* 0xC */ void *spriteData; // ? + /* 0x10 */ void *palettes; // ? +}; + +// size: ? +struct axPokemon +{ + /* 0x0 */ struct axdata axdata; + /* 0x3C */ struct OpenedFile *spriteFile; + u16 unk40_maybeAnimTimer; + u8 unk42_animId1; + u8 unk43_animId2; + u8 unk44; + u8 unk45_orientation; + u8 unk46; + u8 unk47; + u8 unk48; + u8 fill49[0x4C - 0x49]; + /* 0x4C */ struct axmain *axmain; + u8 flags_0x50; + u8 fill51; + s16 unk52; + u8 fill54[0x66 - 0x54]; + s16 unk66; + u8 fill68[0x6C - 0x68]; + u16 unk6C; + u16 unk6E; + u8 unk70; + u8 fill71[0x7C - 0x71]; + s32 unk7C; +}; + +#endif // GUARD_AXDATA_H \ No newline at end of file diff --git a/include/code_800558C_1.h b/include/code_800558C_1.h index 4d931ace..fd9e1890 100644 --- a/include/code_800558C_1.h +++ b/include/code_800558C_1.h @@ -2,5 +2,8 @@ #define GUARD_CODE_800558C_1_H void nullsub_10(bool8); +void nullsub_12(void); +void nullsub_13(void); +void nullsub_14(void); #endif // GUARD_CODE_800558C_1_H \ No newline at end of file diff --git a/include/code_800DAC0.h b/include/code_800DAC0.h index b7e0e87d..66d71d80 100644 --- a/include/code_800DAC0.h +++ b/include/code_800DAC0.h @@ -2,5 +2,6 @@ #define GUARD_CODE_800DAC0_H void sub_800DAC0(u32); +void sub_800DB7C(void); #endif // GUARD_CODE_800DAC0_H \ No newline at end of file diff --git a/include/sprite.h b/include/sprite.h index d0bd6504..2da32219 100644 --- a/include/sprite.h +++ b/include/sprite.h @@ -1,6 +1,7 @@ #ifndef GUARD_SPRITE_H #define GUARD_SPRITE_H +#include "axdata.h" #include "ground_sprite.h" #include "position.h" @@ -39,42 +40,6 @@ struct unkStruct_20266B0 /* 0x8 */ void *dest; }; -// size: 0x8 -struct UnkSpriteMem -{ - /* 0x0 */ void *src; - /* 0x4 */ s32 byteCount; -}; - -// size: 0x20 -struct axdata1 -{ - /* 0x0 */ s16 xPos; - /* 0x2 */ s16 yPos; - /* 0x4 */ u16 xOffset; - /* 0x6 */ u16 yOffset; - /* 0x8 */ u16 xShadow; - /* 0xA */ u16 yShadow; - u32 unkC; - u32 unk10; - /* 0x14 */ s16 vramTileOrMaybeAnimTimer; - s16 unk16; - /* 0x18 */ s16 poseId; - /* 0x1A */ s16 lastPoseId; - u8 fill1C[0x1E - 0x1C]; - u8 paletteNum; -}; - -// size: 0xA -struct __attribute__ ((packed, aligned(2))) ax_pose -{ - s16 sprite; - u16 unk2; // Always 0 in red (except for end markers which are 0xFFFF) - u16 flags1; - u16 flags2; - u16 flags3; -}; - void AddSprite(struct unkSprite *, s32, struct UnkSpriteMem *, struct unkStruct_2039DB0 *); void BlinkSavingIcon(void); void CopySpritesToOam(void); diff --git a/src/code_800DAC0.c b/src/code_800DAC0.c index 8265ce3c..40b6dedd 100644 --- a/src/code_800DAC0.c +++ b/src/code_800DAC0.c @@ -57,7 +57,6 @@ extern u8 gefob001_string[]; extern struct FileArchive gEffectFileArchive; extern void sub_8005610(struct OpenedFile *, u32, u32,u32); -extern void sub_800DB7C(void); extern void sub_800F034(void); extern void sub_800ED38(u32); extern void sub_800DC14(void); diff --git a/src/code_80A7714.c b/src/code_80A7714.c index a6b91265..9d0d8904 100644 --- a/src/code_80A7714.c +++ b/src/code_80A7714.c @@ -1,23 +1,24 @@ #include "global.h" +#include "axdata.h" -extern void sub_80A68A0(void); -extern void sub_80A7094(u32 r0, u32 r1, u32 r2, u32 r3); -extern void sub_80A7310(u32 r0, u32 r1, u32 r2, u32 r3); +extern void sub_80A68A0(u32); +extern void sub_80A7094(struct axPokemon *, u32, u32, u32); +extern void sub_80A7310(struct axPokemon *, u32, u32, u32); extern void sub_80A7784(); extern s16 gUnknown_2039DE0; extern u32 gUnknown_8117EFC; extern u32 *gMapScriptTable[]; -void sub_80A7714(void) +void sub_80A7714(u32 a0) { - sub_80A68A0(); + sub_80A68A0(a0); } -void sub_80A7720(u32 r0, u32 r1, u32 r2) +void sub_80A7720(struct axPokemon *a0, u32 a1, u32 a2) { - sub_80A7094(r0, 0, r1, r2); - sub_80A7310(r0, r1, 0, r2); + sub_80A7094(a0, 0, a1, a2); + sub_80A7310(a0, a1, 0, a2); } void sub_80A7744(void) @@ -30,55 +31,43 @@ void sub_80A7754(void) gUnknown_2039DE0 = -1; } -void sub_80A7764(s16 r0) +void sub_80A7764(s16 a0) { - s32 temp = r0; + s32 temp = a0; + sub_80A7784(); - if(temp != -1) - { + + if (temp != -1) gUnknown_2039DE0 = temp; - } } void sub_80A7784(void) { - if(gUnknown_2039DE0 != -1) - { + if (gUnknown_2039DE0 != -1) gUnknown_2039DE0 = -1; - } } -u8 sub_80A77A0(s16 r0) +bool8 sub_80A77A0(s16 a0) { s32 temp; s32 temp2; - temp = r0; + temp = a0; temp2 = temp; - if(gUnknown_2039DE0 != temp) - { - if(temp < 0) - { + if (gUnknown_2039DE0 != temp) { + if (temp < 0) sub_80A7784(); - - } else - { sub_80A7764(temp2); - } - return 1; + return TRUE; } - return 0; + return FALSE; } // TODO review this later -u32 *sub_80A77D0(s16 r0) +u32 *sub_80A77D0(s16 a0) { - if(r0 != -1) - { - return gMapScriptTable[r0]; - } + if (a0 != -1) + return gMapScriptTable[a0]; else - { return &gUnknown_8117EFC; - } } diff --git a/src/ground_sprite.c b/src/ground_sprite.c index 8792e1e1..fcfc4c28 100644 --- a/src/ground_sprite.c +++ b/src/ground_sprite.c @@ -178,4 +178,31 @@ void sub_80A64A4(void) CloseFile(file); } } +} + +void sub_80A658C(void) +{ + sub_800DB7C(); + ResetSprites(FALSE); + nullsub_10(0); + sub_8005180(); + nullsub_12(); + CopySpritesToOam(); + nullsub_13(); + sub_8005304(); + nullsub_14(); + CloseFile(gUnknown_203B4B4); + MemoryFree(gUnknown_3001B7C); + gUnknown_3001B7C = NULL; +} + +// Unused +u16 sub_80A65D8(u16 *a0) +{ + return a0[40]; +} + +u16 sub_80A65E0(u32 a0) +{ + return (a0 >> 16) & 0x337F; } \ No newline at end of file