diff --git a/asm/menu_specialized.s b/asm/menu_specialized.s index b09ab4c44..36db0f865 100644 --- a/asm/menu_specialized.s +++ b/asm/menu_specialized.s @@ -9,478 +9,6 @@ - - - - thumb_func_start sub_81D32D4 -sub_81D32D4: @ 81D32D4 - push {lr} - adds r1, r0, 0 - ldrh r0, [r1, 0x30] - adds r0, 0x1 - strh r0, [r1, 0x30] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x3C - ble _081D32F0 - movs r0, 0 - strh r0, [r1, 0x30] - adds r0, r1, 0 - bl sub_81D3408 -_081D32F0: - pop {r0} - bx r0 - thumb_func_end sub_81D32D4 - - thumb_func_start sub_81D32F4 -sub_81D32F4: @ 81D32F4 - push {lr} - adds r2, r0, 0 - adds r0, 0x3F - ldrb r1, [r0] - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - beq _081D330C - movs r0, 0 - strh r0, [r2, 0x30] - ldr r0, =sub_81D32D4 - str r0, [r2, 0x1C] -_081D330C: - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D32F4 - - thumb_func_start sub_81D3314 -sub_81D3314: @ 81D3314 - push {r4,r5,lr} - adds r4, r0, 0 - movs r1, 0x36 - ldrsh r0, [r4, r1] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - ldr r0, =gSprites - adds r3, r1, r0 - cmp r3, 0 - beq _081D3360 - ldrh r1, [r3, 0x24] - ldrh r2, [r3, 0x20] - adds r1, r2 - ldr r2, =gUnknown_08625B2C - movs r5, 0x2E - ldrsh r0, [r4, r5] - lsls r0, 2 - adds r0, r2 - ldrh r0, [r0] - adds r0, r1 - strh r0, [r4, 0x20] - ldrh r1, [r3, 0x26] - ldrh r3, [r3, 0x22] - adds r1, r3 - movs r3, 0x2E - ldrsh r0, [r4, r3] - lsls r0, 2 - adds r2, 0x2 - adds r0, r2 - ldrh r0, [r0] - adds r0, r1 - b _081D337E - .pool -_081D3360: - ldr r1, =gUnknown_08625B2C - movs r5, 0x2E - ldrsh r0, [r4, r5] - lsls r0, 2 - adds r0, r1 - ldrh r0, [r0] - adds r0, 0x28 - strh r0, [r4, 0x20] - movs r2, 0x2E - ldrsh r0, [r4, r2] - lsls r0, 2 - adds r1, 0x2 - adds r0, r1 - ldrh r0, [r0] - adds r0, 0x68 -_081D337E: - strh r0, [r4, 0x22] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D3314 - - thumb_func_start sub_81D338C -sub_81D338C: @ 81D338C - push {r4-r7,lr} - mov r7, r8 - push {r7} - mov r8, r2 - lsls r0, 24 - lsrs r6, r0, 24 - lsls r1, 24 - lsrs r7, r1, 24 - movs r5, 0 -_081D339E: - lsls r0, r5, 2 - mov r1, r8 - adds r4, r0, r1 - ldr r0, [r4] - cmp r0, 0 - beq _081D33F0 - strh r5, [r0, 0x2E] - ldr r1, [r4] - lsls r0, r5, 4 - adds r0, 0x1 - strh r0, [r1, 0x30] - ldr r0, [r4] - strh r6, [r0, 0x32] - ldr r0, [r4] - strh r5, [r0, 0x34] - cmp r7, 0 - beq _081D33C4 - cmp r6, 0x9 - beq _081D33D0 -_081D33C4: - ldr r1, [r4] - ldr r0, =sub_81D3564 - str r0, [r1, 0x1C] - b _081D33F0 - .pool -_081D33D0: - ldr r0, [r4] - bl sub_81D3314 - ldr r0, [r4] - bl sub_81D35E8 - ldr r2, [r4] - ldr r0, =sub_81D32F4 - str r0, [r2, 0x1C] - adds r2, 0x3E - ldrb r0, [r2] - movs r3, 0x5 - negs r3, r3 - adds r1, r3, 0 - ands r0, r1 - strb r0, [r2] -_081D33F0: - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - cmp r5, 0x9 - bls _081D339E - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D338C - - thumb_func_start sub_81D3408 -sub_81D3408: @ 81D3408 - push {r4-r7,lr} - adds r4, r0, 0 - ldrh r0, [r4, 0x38] - lsls r0, 24 - lsrs r2, r0, 24 - movs r3, 0 - movs r1, 0x32 - ldrsh r0, [r4, r1] - adds r0, 0x1 - cmp r3, r0 - bge _081D3454 - ldr r5, =gSprites - movs r7, 0x1C - adds r7, r5 - mov r12, r7 - ldr r6, =sub_81D3564 -_081D3428: - lsls r1, r2, 4 - adds r1, r2 - lsls r1, 2 - adds r2, r1, r5 - movs r7, 0x2E - ldrsh r0, [r2, r7] - lsls r0, 4 - adds r0, 0x1 - strh r0, [r2, 0x30] - add r1, r12 - str r6, [r1] - ldrh r0, [r2, 0x38] - lsls r0, 24 - lsrs r2, r0, 24 - adds r0, r3, 0x1 - lsls r0, 16 - lsrs r3, r0, 16 - movs r1, 0x32 - ldrsh r0, [r4, r1] - adds r0, 0x1 - cmp r3, r0 - blt _081D3428 -_081D3454: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D3408 - - thumb_func_start sub_81D3464 -sub_81D3464: @ 81D3464 - push {lr} - adds r2, r0, 0 - movs r1, 0 - movs r3, 0 -_081D346C: - lsls r0, r1, 2 - adds r0, r2 - str r3, [r0] - adds r0, r1, 0x1 - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x9 - bls _081D346C - pop {r0} - bx r0 - thumb_func_end sub_81D3464 - - thumb_func_start sub_81D3480 -sub_81D3480: @ 81D3480 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - mov r8, r0 - lsls r1, 24 - lsrs r1, 24 - mov r10, r1 - lsls r2, 24 - movs r0, 0 - mov r9, r0 - lsrs r7, r2, 24 - movs r5, 0 - adds r0, r7, 0x1 - cmp r9, r0 - bge _081D34FE -_081D34A2: - ldr r0, =gUnknown_08625B14 - movs r1, 0 - movs r2, 0 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r3, r0, 24 - adds r6, r3, 0 - cmp r3, 0x40 - beq _081D34FE - lsls r0, r5, 2 - mov r1, r8 - adds r4, r0, r1 - lsls r0, r3, 4 - adds r0, r3 - lsls r0, 2 - ldr r1, =gSprites - adds r0, r1 - str r0, [r4] - adds r0, 0x3E - ldrb r1, [r0] - movs r2, 0x4 - orrs r1, r2 - strb r1, [r0] - ldr r0, [r4] - mov r1, r10 - strh r1, [r0, 0x36] - cmp r5, 0 - beq _081D34F0 - subs r0, r4, 0x4 - ldr r0, [r0] - strh r3, [r0, 0x38] - b _081D34F2 - .pool -_081D34F0: - mov r9, r6 -_081D34F2: - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - adds r0, r7, 0x1 - cmp r5, r0 - blt _081D34A2 -_081D34FE: - lsls r0, r7, 2 - add r0, r8 - ldr r0, [r0] - mov r1, r9 - strh r1, [r0, 0x38] - adds r0, r7, 0 - movs r1, 0x1 - mov r2, r8 - bl sub_81D338C - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_81D3480 - - thumb_func_start sub_81D3520 -sub_81D3520: @ 81D3520 - push {r4-r6,lr} - adds r6, r0, 0 - movs r5, 0 -_081D3526: - cmp r5, 0x9 - bhi _081D3544 - lsls r0, r5, 2 - adds r4, r0, r6 - ldr r0, [r4] - cmp r0, 0 - beq _081D3544 - bl DestroySprite - movs r0, 0 - str r0, [r4] - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - b _081D3526 -_081D3544: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_81D3520 - - thumb_func_start sub_81D354C -sub_81D354C: @ 81D354C - push {lr} - bl sub_81D3520 - movs r0, 0x68 - bl FreeSpriteTilesByTag - movs r0, 0x68 - bl FreeSpritePaletteByTag - pop {r0} - bx r0 - thumb_func_end sub_81D354C - - thumb_func_start sub_81D3564 -sub_81D3564: @ 81D3564 - push {r4,lr} - adds r4, r0, 0 - ldrh r1, [r4, 0x30] - movs r2, 0x30 - ldrsh r0, [r4, r2] - cmp r0, 0 - beq _081D3592 - subs r0, r1, 0x1 - strh r0, [r4, 0x30] - lsls r0, 16 - cmp r0, 0 - bne _081D35DC - adds r0, r4, 0 - movs r1, 0 - bl SeekSpriteAnim - adds r2, r4, 0 - adds r2, 0x3E - ldrb r1, [r2] - movs r0, 0x5 - negs r0, r0 - ands r0, r1 - strb r0, [r2] -_081D3592: - adds r0, r4, 0 - bl sub_81D3314 - adds r0, r4, 0 - adds r0, 0x3F - ldrb r1, [r0] - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - beq _081D35DC - adds r2, r4, 0 - adds r2, 0x3E - ldrb r0, [r2] - movs r1, 0x4 - orrs r0, r1 - strb r0, [r2] - movs r0, 0x34 - ldrsh r1, [r4, r0] - movs r2, 0x32 - ldrsh r0, [r4, r2] - cmp r1, r0 - bne _081D35D8 - cmp r1, 0x9 - bne _081D35D0 - adds r0, r4, 0 - bl sub_81D35E8 - ldr r0, =sub_81D32F4 - b _081D35DA - .pool -_081D35D0: - ldr r0, =sub_81D32D4 - b _081D35DA - .pool -_081D35D8: - ldr r0, =SpriteCallbackDummy -_081D35DA: - str r0, [r4, 0x1C] -_081D35DC: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D3564 - - thumb_func_start sub_81D35E8 -sub_81D35E8: @ 81D35E8 - push {r4-r7,lr} - adds r6, r0, 0 - ldrh r0, [r6, 0x38] - lsls r0, 24 - lsrs r1, r0, 24 - movs r5, 0 - movs r2, 0x32 - ldrsh r0, [r6, r2] - adds r0, 0x1 - cmp r5, r0 - bge _081D3636 - movs r0, 0x5 - negs r0, r0 - adds r7, r0, 0 -_081D3604: - lsls r4, r1, 4 - adds r4, r1 - lsls r4, 2 - ldr r0, =gSprites - adds r4, r0 - adds r0, r4, 0 - movs r1, 0 - bl SeekSpriteAnim - adds r1, r4, 0 - adds r1, 0x3E - ldrb r0, [r1] - ands r0, r7 - strb r0, [r1] - ldrh r0, [r4, 0x38] - lsls r0, 24 - lsrs r1, r0, 24 - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - movs r2, 0x32 - ldrsh r0, [r6, r2] - adds r0, 0x1 - cmp r5, r0 - blt _081D3604 -_081D3636: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D35E8 - thumb_func_start DrawLevelUpWindowPg1 DrawLevelUpWindowPg1: @ 81D3640 push {r4-r7,lr} diff --git a/include/menu_specialized.h b/include/menu_specialized.h index 90623a888..d29ac5751 100644 --- a/include/menu_specialized.h +++ b/include/menu_specialized.h @@ -26,12 +26,6 @@ struct UnknownStruct_81D1ED4 /*0x355*/ u8 unk355; }; -struct Unk81D2F78_Struct -{ - u8 contestStats[4][5]; - struct UnknownSubStruct_81D1ED4 field_20[4][5]; -}; - bool8 sub_81D1C44(u8 count); u8 sub_81D1C84(u8 a0); u8 sub_81D1DC0(struct PlayerPCItemPageStruct *page); @@ -44,11 +38,7 @@ void sub_81D1ED4(struct UnknownStruct_81D1ED4 *a0); void sub_81D2108(struct UnknownStruct_81D1ED4 *arg0); void sub_81D20AC(struct UnknownStruct_81D1ED4 *arg0); void sub_81D2230(struct UnknownStruct_81D1ED4 *arg0); -void sub_81D3520(struct Sprite **); bool8 sub_81D20BC(struct UnknownStruct_81D1ED4 *arg0); -void sub_81D354C(struct Sprite **); -void sub_81D3464(struct Sprite **arg0); -void sub_81D3480(struct Sprite **arg0, u8 arg1, u8 arg2); bool32 sub_81D2074(struct UnknownStruct_81D1ED4 *a0); void sub_81D2754(u8 *arg0, struct UnknownSubStruct_81D1ED4 *arg1); void sub_81D1F84(struct UnknownStruct_81D1ED4 *arg0, struct UnknownSubStruct_81D1ED4 *arg1, struct UnknownSubStruct_81D1ED4 *arg2); @@ -60,8 +50,8 @@ void InitMoveRelearnerWindows(bool8 useContextWindow); void GetMonLevelUpWindowStats(struct Pokemon* mon, void* statStoreLocation); s32 GetBoxOrPartyMonData(u16 boxId, u16 monId, s32 request, u8 *dst); void sub_81D2ED4(u8 *dst, u8 *nameDst, u16 boxId, u16 monId, u16 arg5, u16 arg6, bool8 arg7); -void sub_81D2F78(struct Unk81D2F78_Struct *arg0, u8 *sheen, u16 boxId, u16 monId, u16 arg5, u16 id, u16 arg7, bool8 arg8); -void sub_81D3094(u8 *tilesDst, u8 *palDst, u16 boxId, u16 monId, u16 arg5, u16 arg6, bool8 arg7); +void sub_81D2F78(struct UnknownStruct_81D1ED4 *arg0, u8 *sheen, u16 boxId, u16 monId, u16 arg5, u16 id, u16 arg7, bool8 arg8); +void sub_81D3094(void *tilesDst, void *palDst, u16 boxId, u16 monId, u16 arg5, u16 arg6, bool8 arg7); bool8 sub_81D312C(s16 *var); bool8 sub_81D3150(s16 *var); bool8 sub_81D3178(struct UnknownStruct_81D1ED4 *arg0, s16 *arg1); @@ -69,5 +59,9 @@ bool8 sub_81D31A4(struct UnknownStruct_81D1ED4 *arg0, s16 *arg1); void sub_81D31D0(struct SpriteSheet *sheet, struct SpriteTemplate *template, struct SpritePalette *pal); void sub_81D321C(struct SpriteSheet *sheets, struct SpriteTemplate * template, struct SpritePalette *pals); void sub_81D32B0(struct SpriteSheet *sheet, struct SpritePalette *pal); +void sub_81D3464(struct Sprite **sprites); +void sub_81D3480(struct Sprite **sprites, u8 arg1, u8 arg2); +void sub_81D3520(struct Sprite **sprites); +void sub_81D354C(struct Sprite **sprites); #endif // GUARD_MENU_SPECIALIZED_H diff --git a/src/menu_specialized.c b/src/menu_specialized.c index ae150dcb4..f21f4e51a 100644 --- a/src/menu_specialized.c +++ b/src/menu_specialized.c @@ -37,6 +37,9 @@ static void sub_81D24A4(struct UnknownStruct_81D1ED4 *a0); static void sub_81D2634(struct UnknownStruct_81D1ED4 *a0); static void MoveRelearnerCursorCallback(s32 itemIndex, bool8 onInit, struct ListMenu *list); static void nullsub_79(void); +static void sub_81D3408(struct Sprite *sprite); +/*static*/ void sub_81D3564(struct Sprite *sprite); +static void sub_81D35E8(struct Sprite *sprite); static const struct WindowTemplate sUnknown_086253E8[] = { @@ -1243,7 +1246,7 @@ void sub_81D2ED4(u8 *dst, u8 *nameDst, u16 boxId, u16 monId, u16 arg5, u16 arg6, } } -void sub_81D2F78(struct Unk81D2F78_Struct *arg0, u8 *sheen, u16 boxId, u16 monId, u16 arg5, u16 id, u16 arg7, bool8 arg8) +void sub_81D2F78(struct UnknownStruct_81D1ED4 *arg0, u8 *sheen, u16 boxId, u16 monId, u16 arg5, u16 id, u16 arg7, bool8 arg8) { u16 i; @@ -1252,30 +1255,30 @@ void sub_81D2F78(struct Unk81D2F78_Struct *arg0, u8 *sheen, u16 boxId, u16 monId if (arg5 != arg7) { - arg0->contestStats[id][0] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_COOL, NULL); - arg0->contestStats[id][1] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_TOUGH, NULL); - arg0->contestStats[id][2] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SMART, NULL); - arg0->contestStats[id][3] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_CUTE, NULL); - arg0->contestStats[id][4] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_BEAUTY, NULL); + arg0->unk0[id][0] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_COOL, NULL); + arg0->unk0[id][1] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_TOUGH, NULL); + arg0->unk0[id][2] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SMART, NULL); + arg0->unk0[id][3] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_CUTE, NULL); + arg0->unk0[id][4] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_BEAUTY, NULL); sheen[id] = (GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL) != 0xFF) ? GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL) / 29u : 9; - sub_81D2754(arg0->contestStats[id], arg0->field_20[id]); + sub_81D2754(arg0->unk0[id], arg0->unk14[id]); } else { for (i = 0; i < 5; i++) { - arg0->contestStats[id][i] = 0; - arg0->field_20[id][i].unk0 = 155; - arg0->field_20[id][i].unk2 = 91; + arg0->unk0[id][i] = 0; + arg0->unk14[id][i].unk0 = 155; + arg0->unk14[id][i].unk2 = 91; } } } -void sub_81D3094(u8 *tilesDst, u8 *palDst, u16 boxId, u16 monId, u16 arg5, u16 arg6, bool8 arg7) +void sub_81D3094(void *tilesDst, void *palDst, u16 boxId, u16 monId, u16 arg5, u16 arg6, bool8 arg7) { if (!arg7) arg6--; @@ -1325,10 +1328,10 @@ bool8 sub_81D31A4(struct UnknownStruct_81D1ED4 *arg0, s16 *arg1) return ((var1 != 0) || (var2 != 0)); } -const u32 gUnknown_08625560[] = INCBIN_U32("graphics/pokenav/pokeball.4bpp"); -const u32 gUnknown_08625660[] = INCBIN_U32("graphics/pokenav/pokeball_placeholder.4bpp"); -const u16 gUnknown_08625680[] = INCBIN_U16("graphics/pokenav/sparkle.gbapal"); -const u32 gUnknown_086256A0[] = INCBIN_U32("graphics/pokenav/sparkle.4bpp"); +static const u32 gUnknown_08625560[] = INCBIN_U32("graphics/pokenav/pokeball.4bpp"); +static const u32 gUnknown_08625660[] = INCBIN_U32("graphics/pokenav/pokeball_placeholder.4bpp"); +static const u16 gUnknown_08625680[] = INCBIN_U16("graphics/pokenav/sparkle.gbapal"); +static const u32 gUnknown_086256A0[] = INCBIN_U32("graphics/pokenav/sparkle.4bpp"); static const struct OamData sOamData_8625A20 = { @@ -1347,7 +1350,7 @@ static const struct OamData sOamData_8625A20 = .affineParam = 0 }; -const struct OamData sOamData_8625A28 = +static const struct OamData sOamData_8625A28 = { .y = 0, .affineMode = 0, @@ -1376,7 +1379,7 @@ static const union AnimCmd sSpriteAnim_8625A38[] = ANIMCMD_END }; -const union AnimCmd *const sSpriteAnimTable_8625A40[] = +static const union AnimCmd *const sSpriteAnimTable_8625A40[] = { sSpriteAnim_8625A30, sSpriteAnim_8625A38 @@ -1451,3 +1454,188 @@ void sub_81D32B0(struct SpriteSheet *sheet, struct SpritePalette *pal) *sheet = dataSheet; *pal = dataPal; } + +static void sub_81D32D4(struct Sprite *sprite) +{ + if (++sprite->data[1] > 60) + { + sprite->data[1] = 0; + sub_81D3408(sprite); + } +} + +static void sub_81D32F4(struct Sprite *sprite) +{ + if (sprite->animEnded) + { + sprite->data[1] = 0; + sprite->callback = sub_81D32D4; + } +} + +// Todo: Move these variables to C. +extern const s16 gUnknown_08625B2C[][2]; +extern const struct SpriteTemplate gUnknown_08625B14; + +void sub_81D3314(struct Sprite *sprite) +{ + struct Sprite *sprite2 = &gSprites[sprite->data[4]]; + + if (sprite2 != NULL) + { + sprite->pos1.x = sprite2->pos1.x + sprite2->pos2.x + gUnknown_08625B2C[sprite->data[0]][0]; + sprite->pos1.y = sprite2->pos1.y + sprite2->pos2.y + gUnknown_08625B2C[sprite->data[0]][1]; + } + else + { + sprite->pos1.x = gUnknown_08625B2C[sprite->data[0]][0] + 40; + sprite->pos1.y = gUnknown_08625B2C[sprite->data[0]][1] + 104; + } +} + +void sub_81D338C(u8 arg0, u8 arg1, struct Sprite **sprites) +{ + u16 i; + + for (i = 0; i < 10; i++) + { + if (sprites[i] != NULL) + { + sprites[i]->data[0] = i; + sprites[i]->data[1] = (i * 16) + 1; + sprites[i]->data[2] = arg0; + sprites[i]->data[3] = i; + if (arg1 == 0 || arg0 != 9) + { + sprites[i]->callback = sub_81D3564; + } + else + { + sub_81D3314(sprites[i]); + sub_81D35E8(sprites[i]); + sprites[i]->callback = sub_81D32F4; + sprites[i]->invisible = FALSE; + } + } + } +} + +static void sub_81D3408(struct Sprite *sprite) +{ + u16 i; + u8 id = sprite->data[5]; + + for (i = 0; i < sprite->data[2] + 1; i++) + { + gSprites[id].data[1] = (gSprites[id].data[0] * 16) + 1; + gSprites[id].callback = sub_81D3564; + id = gSprites[id].data[5]; + } +} + +void sub_81D3464(struct Sprite **sprites) +{ + u8 i; + + for (i = 0; i < 10; i++) + sprites[i] = NULL; +} + +void sub_81D3480(struct Sprite **sprites, u8 arg1, u8 arg2) +{ + u16 i, spriteId, firstSpriteId = 0; + u8 count = arg2; + + for (i = 0; i < count + 1; i++) + { + spriteId = CreateSprite(&gUnknown_08625B14, 0, 0, 0); + if (spriteId != MAX_SPRITES) + { + sprites[i] = &gSprites[spriteId]; + sprites[i]->invisible = TRUE; + sprites[i]->data[4] = arg1; + if (i != 0) + sprites[i - 1]->data[5] = spriteId; + else + firstSpriteId = spriteId; + } + else + { + break; + } + } + + sprites[count]->data[5] = firstSpriteId; + sub_81D338C(count, 1, sprites); +} + +void sub_81D3520(struct Sprite **sprites) +{ + u16 i; + + for (i = 0; i < 10; i++) + { + if (sprites[i] != NULL) + { + DestroySprite(sprites[i]); + sprites[i] = NULL; + } + else + { + break; + } + } +} + +void sub_81D354C(struct Sprite **sprites) +{ + sub_81D3520(sprites); + FreeSpriteTilesByTag(104); + FreeSpritePaletteByTag(104); +} + +/*static*/ void sub_81D3564(struct Sprite *sprite) +{ + if (sprite->data[1] != 0) + { + if (--sprite->data[1] != 0) + return; + + SeekSpriteAnim(sprite, 0); + sprite->invisible = FALSE; + } + + sub_81D3314(sprite); + if (sprite->animEnded) + { + sprite->invisible = TRUE; + if (sprite->data[3] == sprite->data[2]) + { + if (sprite->data[3] == 9) + { + sub_81D35E8(sprite); + sprite->callback = sub_81D32F4; + } + else + { + sprite->callback = sub_81D32D4; + } + } + else + { + sprite->callback = SpriteCallbackDummy; + } + } +} + +static void sub_81D35E8(struct Sprite *sprite) +{ + u8 i, id = sprite->data[5]; + + for (i = 0; i < sprite->data[2] + 1; i++) + { + SeekSpriteAnim(&gSprites[id], 0); + gSprites[id].invisible = FALSE; + id = gSprites[id].data[5]; + } +} diff --git a/src/use_pokeblock.c b/src/use_pokeblock.c index d78132585..6df826214 100644 --- a/src/use_pokeblock.c +++ b/src/use_pokeblock.c @@ -57,11 +57,11 @@ struct Unk7FB8 struct UsePokeblockStruct { - /*0x0000*/ u8 field_0[4]; - /*0x0000*/ u16 field_4[3][0x40]; - /*0x0184*/ u8 field_184[0x304 - 0x184]; + /*0x0000*/ u8 filler0[4]; + /*0x0000*/ u16 field_4[6][0x40]; /*0x0304*/ u8 field_304[3][0x2000]; - /*0x6304*/ u8 field_6304[0x7b06 - 0x6304]; + /*0x6304*/ u8 filler_6304[0x1000]; + /*0x7304*/ u8 tilemapBuffer[BG_SCREEN_SIZE + 2]; /*0x7B06*/ u8 field_7B06[7]; /*0x7B0E*/ s16 field_7B0E; /*0x7B10*/ u8 field_7B10; @@ -71,8 +71,7 @@ struct UsePokeblockStruct /*0x7B1C*/ struct Sprite *field_7B1C[10]; /*0x7B44*/ struct Sprite *field_7B44[2]; /*0x7B4C*/ u8 field_7B4C; - /*0x7B4D*/ u8 filler7B4D[0x47]; - /*0x7B94*/ u8 filler7B94; + /*0x7B4D*/ u8 field_7B4D[3][24]; /*0x7B95*/ u8 field_7B95[3][64]; /*0x7C58*/ struct UnknownStruct_81D1ED4 field_7C58; /*0x7FB0*/ u8 unk7FB0[3]; @@ -119,7 +118,7 @@ void sub_8167338(void); void sub_81681F4(u8); void sub_8166E24(void); bool8 sub_8166EDC(void); -void Pokeblock_BufferEnhancedStatText(u8 *dest, u8 statID, s16 a2); +void Pokeblock_BufferEnhancedStatText(u8 *dest, u8 statId, s16 a2); void Pokeblock_MenuWindowTextPrint(const u8 *message); void sub_8167184(struct Pokeblock *, struct Pokemon *); void sub_81673DC(struct Sprite *sprite); @@ -712,15 +711,13 @@ void Pokeblock_MenuWindowTextPrint(const u8 *message) AddTextPrinterParameterized(2, 1, gStringVar4, 0, 1, 0, NULL); } +// This function is a joke. #ifdef NONMATCHING -void Pokeblock_BufferEnhancedStatText(u8 *dest, u8 statID, s16 a2) +void Pokeblock_BufferEnhancedStatText(u8 *dest, u8 statId, s16 a2) { if (a2 != 0) { - if (a2 > 0) - a2 = 0; - - StringCopy(dest, sContestStatNames[statID]); + StringCopy(dest, sContestStatNames[statId]); StringAppend(dest, gText_WasEnhanced); } else @@ -730,7 +727,7 @@ void Pokeblock_BufferEnhancedStatText(u8 *dest, u8 statID, s16 a2) } #else NAKED -void Pokeblock_BufferEnhancedStatText(u8 *dest, u8 statID, s16 a2) +void Pokeblock_BufferEnhancedStatText(u8 *dest, u8 statId, s16 a2) { asm(".syntax unified\n\ push {r4,lr}\n\ @@ -979,116 +976,17 @@ void sub_81674BC(void) sub_816753C(var2, 2); } -#ifdef NONMATCHING -void sub_816753C(s16 a1, u8 a2) +void sub_816753C(s16 id1, u8 id2) { - u8 *v3; - int v5; - int v6; + u8 boxId = gUnknown_0203BCAC->field_7FB8[id1].unk0; + u8 monId = gUnknown_0203BCAC->field_7FB8[id1].unk1; + u8 r6 = gUnknown_0203BCAC->info.field_70; + bool8 r8 = FALSE; - v3 = &gUnknown_0203BCAC->field_0[a1 << 16 >> 14]; - v5 = *(0x7FB8 + v3); - v6 = *(0x7FB9 + v3); - - sub_81D2ED4(gUnknown_0203BCAC->field_0[0x7B4D + 24 * a2], gUnknown_0203BCAC->field_0[0x7B95 + 64 * a2], v5, v6, a1, gUnknown_0203BCAC->info.field_70, 0); - sub_81D2F78(gUnknown_0203BCAC->field_7C58[0], gUnknown_0203BCAC->field_0[0x7FB0], v5, v6, a1, a2, gUnknown_0203BCAC->info.field_70, 0); - sub_81D3094(gUnknown_0203BCAC->field_0[(a2 << 13) + 0x304], gUnknown_0203BCAC->field_0[(a2 << 7) + 4], v5, v6, a1, gUnknown_0203BCAC->info.field_70, 0); - //gUnknown_0203BCAC->field_0[0x7B4D + a1 * 40], gUnknown_0203BCAC->field_7FB8, gUnknown_0203BCAC->field_7FB9, gUnknown_203BCAC->field_0[0], gUnknown_203BCAC->info.field_70, 0) + sub_81D2ED4(gUnknown_0203BCAC->field_7B4D[id2], gUnknown_0203BCAC->field_7B95[id2], boxId, monId, id1, r6, r8); + sub_81D2F78(&gUnknown_0203BCAC->field_7C58, gUnknown_0203BCAC->unk7FB0, boxId, monId, id1, id2, r6, r8); + sub_81D3094(gUnknown_0203BCAC->field_304[id2], gUnknown_0203BCAC->field_4[id2], boxId, monId, id1, r6, r8); } -#else -NAKED -void sub_816753C(s16 a1, u8 a2) -{ - asm(".syntax unified\n\ - push {r4-r7,lr}\n\ - mov r7, r10\n\ - mov r6, r9\n\ - mov r5, r8\n\ - push {r5-r7}\n\ - sub sp, 0x10\n\ - adds r5, r0, 0\n\ - adds r4, r1, 0\n\ - lsls r4, 24\n\ - lsrs r4, 24\n\ - ldr r0, =gUnknown_0203BCAC\n\ - mov r9, r0\n\ - ldr r1, [r0]\n\ - lsls r5, 16\n\ - asrs r0, r5, 14\n\ - adds r0, r1, r0\n\ - ldr r3, =0x00007fb8\n\ - adds r2, r0, r3\n\ - ldrb r7, [r2]\n\ - ldr r2, =0x00007fb9\n\ - adds r0, r2\n\ - ldrb r0, [r0]\n\ - mov r10, r0\n\ - adds r3, 0x88\n\ - adds r0, r1, r3\n\ - ldrb r6, [r0]\n\ - movs r0, 0\n\ - mov r8, r0\n\ - lsls r0, r4, 1\n\ - adds r0, r4\n\ - lsls r0, 3\n\ - ldr r2, =0x00007b4d\n\ - adds r0, r2\n\ - adds r0, r1, r0\n\ - lsls r2, r4, 6\n\ - ldr r3, =0x00007b95\n\ - adds r2, r3\n\ - adds r1, r2\n\ - lsrs r5, 16\n\ - str r5, [sp]\n\ - str r6, [sp, 0x4]\n\ - mov r2, r8\n\ - str r2, [sp, 0x8]\n\ - adds r2, r7, 0\n\ - mov r3, r10\n\ - bl sub_81D2ED4\n\ - mov r3, r9\n\ - ldr r1, [r3]\n\ - ldr r2, =0x00007c58\n\ - adds r0, r1, r2\n\ - ldr r3, =0x00007fb0\n\ - adds r1, r3\n\ - str r5, [sp]\n\ - str r4, [sp, 0x4]\n\ - str r6, [sp, 0x8]\n\ - mov r2, r8\n\ - str r2, [sp, 0xC]\n\ - adds r2, r7, 0\n\ - mov r3, r10\n\ - bl sub_81D2F78\n\ - lsls r0, r4, 13\n\ - movs r1, 0xC1\n\ - lsls r1, 2\n\ - adds r0, r1\n\ - mov r3, r9\n\ - ldr r1, [r3]\n\ - adds r0, r1, r0\n\ - lsls r4, 7\n\ - adds r4, 0x4\n\ - adds r1, r4\n\ - str r5, [sp]\n\ - str r6, [sp, 0x4]\n\ - mov r2, r8\n\ - str r2, [sp, 0x8]\n\ - adds r2, r7, 0\n\ - mov r3, r10\n\ - bl sub_81D3094\n\ - add sp, 0x10\n\ - pop {r3-r5}\n\ - mov r8, r3\n\ - mov r9, r4\n\ - mov r10, r5\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .pool\n\ - .syntax divided\n"); -} -#endif void sub_8167608(u8 arg0) { @@ -1242,10 +1140,10 @@ bool8 sub_8167930(void) CopyBgTilemapBufferToVram(1); break; case 10: - LZ77UnCompVram(gUnknown_085DFC0C, &gUnknown_0203BCAC->field_0[0x7304]); + LZ77UnCompVram(gUnknown_085DFC0C, gUnknown_0203BCAC->tilemapBuffer); break; case 11: - LoadBgTilemap(2, &gUnknown_0203BCAC->field_0[0x7304], 1280, 0); + LoadBgTilemap(2, gUnknown_0203BCAC->tilemapBuffer, 1280, 0); LoadPalette(gUnknown_086231E8, 48, 32); LoadPalette(gUnknown_08623208, 240, 32); sub_81D21DC(2);