diff --git a/asm/contest.s b/asm/contest.s index 6524f7a90..69060422e 100644 --- a/asm/contest.s +++ b/asm/contest.s @@ -5,267 +5,6 @@ .text - thumb_func_start IsSpeciesNotUnown -IsSpeciesNotUnown: @ 80DB2A8 - push {lr} - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0xC9 - beq _080DB2B6 - movs r0, 0x1 - b _080DB2B8 -_080DB2B6: - movs r0, 0 -_080DB2B8: - pop {r1} - bx r1 - thumb_func_end IsSpeciesNotUnown - - thumb_func_start sub_80DB2BC -sub_80DB2BC: @ 80DB2BC - push {r4-r6,lr} - ldr r5, =gContestResources - ldr r0, [r5] - ldr r0, [r0, 0x24] - movs r4, 0xA0 - lsls r4, 3 - adds r1, r0, r4 - movs r6, 0xA0 - lsls r6, 1 - adds r2, r6, 0 - bl CpuSet - ldr r0, [r5] - ldr r0, [r0, 0x2C] - adds r4, r0, r4 - adds r1, r4, 0 - adds r2, r6, 0 - bl CpuSet - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80DB2BC - - thumb_func_start sub_80DB2EC -sub_80DB2EC: @ 80DB2EC - push {lr} - lsls r0, 16 - lsls r1, 24 - lsrs r3, r1, 24 - ldr r2, =gContestEffects - ldr r1, =gContestMoves - lsrs r0, 13 - adds r0, r1 - ldrb r0, [r0] - lsls r0, 2 - adds r0, r2 - ldrb r0, [r0] - cmp r0, 0x8 - bhi _080DB354 - lsls r0, 2 - ldr r1, =_080DB320 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_080DB320: - .4byte _080DB344 - .4byte _080DB344 - .4byte _080DB34C - .4byte _080DB34C - .4byte _080DB354 - .4byte _080DB354 - .4byte _080DB354 - .4byte _080DB354 - .4byte _080DB344 -_080DB344: - ldr r0, =0x00009082 - b _080DB356 - .pool -_080DB34C: - ldr r0, =0x00009088 - b _080DB356 - .pool -_080DB354: - ldr r0, =0x00009086 -_080DB356: - lsls r1, r3, 12 - movs r2, 0x90 - lsls r2, 8 - adds r1, r2 - lsls r0, 16 - asrs r0, 16 - adds r0, r1 - lsls r0, 16 - lsrs r0, 16 - pop {r1} - bx r1 - .pool - thumb_func_end sub_80DB2EC - - thumb_func_start prints_contest_move_description -prints_contest_move_description: @ 80DB370 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x10 - lsls r0, 16 - lsrs r0, 16 - mov r8, r0 - ldr r1, =gContestMoves - lsls r0, 3 - adds r0, r1 - ldrb r0, [r0, 0x1] - lsls r0, 29 - lsrs r0, 29 - ldr r7, =0x00004040 - cmp r0, 0 - beq _080DB3A4 - adds r7, 0x5 - cmp r0, 0x1 - beq _080DB3A4 - adds r7, 0x5 - cmp r0, 0x2 - beq _080DB3A4 - adds r7, 0x40 - cmp r0, 0x3 - bne _080DB3A4 - subs r7, 0x20 -_080DB3A4: - movs r6, 0x5 - str r6, [sp] - movs r4, 0x1 - str r4, [sp, 0x4] - movs r5, 0x11 - str r5, [sp, 0x8] - str r4, [sp, 0xC] - movs r0, 0 - adds r1, r7, 0 - movs r2, 0xB - movs r3, 0x1F - bl sub_80DECB8 - adds r1, r7, 0 - adds r1, 0x10 - str r6, [sp] - str r4, [sp, 0x4] - str r5, [sp, 0x8] - str r4, [sp, 0xC] - movs r0, 0 - movs r2, 0xB - movs r3, 0x20 - bl sub_80DECB8 - ldr r2, =gContestEffects - ldr r0, =gContestMoves - mov r3, r8 - lsls r1, r3, 3 - adds r0, r1, r0 - ldrb r0, [r0] - lsls r0, 2 - adds r2, r0, r2 - ldrb r0, [r2, 0x1] - adds r7, r1, 0 - cmp r0, 0xFF - bne _080DB3FC - movs r6, 0 - b _080DB408 - .pool -_080DB3FC: - ldrb r0, [r2, 0x1] - movs r1, 0xA - bl __udivsi3 - lsls r0, 24 - lsrs r6, r0, 24 -_080DB408: - cmp r6, 0x8 - bls _080DB40E - movs r6, 0x8 -_080DB40E: - ldr r1, =0x00005035 - movs r0, 0x8 - str r0, [sp] - movs r5, 0x1 - str r5, [sp, 0x4] - movs r4, 0x11 - str r4, [sp, 0x8] - movs r0, 0 - movs r2, 0x15 - movs r3, 0x1F - bl sub_80DED10 - ldr r1, =0x00005012 - str r6, [sp] - str r5, [sp, 0x4] - str r4, [sp, 0x8] - movs r0, 0 - movs r2, 0x15 - movs r3, 0x1F - bl sub_80DED10 - ldr r1, =gContestEffects - ldr r0, =gContestMoves - adds r0, r7, r0 - ldrb r0, [r0] - lsls r0, 2 - adds r1, r0, r1 - ldrb r0, [r1, 0x2] - cmp r0, 0xFF - bne _080DB460 - movs r6, 0 - b _080DB46C - .pool -_080DB460: - ldrb r0, [r1, 0x2] - movs r1, 0xA - bl __udivsi3 - lsls r0, 24 - lsrs r6, r0, 24 -_080DB46C: - cmp r6, 0x8 - bls _080DB472 - movs r6, 0x8 -_080DB472: - ldr r1, =0x00005036 - movs r0, 0x8 - str r0, [sp] - movs r5, 0x1 - str r5, [sp, 0x4] - movs r4, 0x11 - str r4, [sp, 0x8] - movs r0, 0 - movs r2, 0x15 - movs r3, 0x20 - bl sub_80DED10 - ldr r1, =0x00005014 - str r6, [sp] - str r5, [sp, 0x4] - str r4, [sp, 0x8] - movs r0, 0 - movs r2, 0x15 - movs r3, 0x20 - bl sub_80DED10 - movs r0, 0xA - movs r1, 0 - bl FillWindowPixelBuffer - ldr r1, =gContestEffectDescriptionPointers - ldr r0, =gContestMoves - adds r0, r7, r0 - ldrb r0, [r0] - lsls r0, 2 - adds r0, r1 - ldr r1, [r0] - movs r0, 0xA - bl sub_80DEB70 - ldr r1, =gText_Slash - movs r0, 0x9 - bl sub_80DEB70 - add sp, 0x10 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end prints_contest_move_description - thumb_func_start sub_80DB4E0 sub_80DB4E0: @ 80DB4E0 push {r4-r7,lr} diff --git a/include/contest_effect.h b/include/contest_effect.h index 4d680be9e..3484ca5df 100644 --- a/include/contest_effect.h +++ b/include/contest_effect.h @@ -9,6 +9,14 @@ struct ContestMove u8 comboMoves[4]; }; +struct ContestEffect +{ + u8 effectType; + u8 appeal; + u8 jam; +}; + extern const struct ContestMove gContestMoves[]; +extern struct ContestEffect gContestEffects[]; #endif //GUARD_CONTEST_EFFECT_H diff --git a/src/contest.c b/src/contest.c index 1ce90fd45..b4e71d82b 100644 --- a/src/contest.c +++ b/src/contest.c @@ -104,8 +104,9 @@ void sub_80DAFA0(u8, u8); u8 sub_80DB0C4(void); u8 sub_80DB120(void); u8 sub_80DB174(u16, u32, u32, u32); -u16 sub_80DE84C(u16); void sub_80DB2BC(void); +void prints_contest_move_description(u16); +u16 sub_80DE84C(u16); void sub_80DB89C(void); u16 sub_80DB8B8(u8); void sub_80DB918(void); @@ -137,7 +138,6 @@ bool32 sub_80DED4C(void); void sub_80DED60(u32); void sub_80FC9F8(u8); bool8 AreMovesContestCombo(u16, u16); -void prints_contest_move_description(u16); void sub_80DBD18(void); void sub_80DF250(void); void sub_80DF4F8(void); @@ -171,6 +171,8 @@ void sub_80DC3AC(void); bool8 sub_80DC3C4(void); void sub_80DF9D4(u8 *); void sub_80DF9E0(u8 *, s32); +void sub_80DED10(u8, u16, u8, u8, u8, u8, u8); +void sub_80DEB70(u8, const u8 *); EWRAM_DATA struct ContestPokemon gContestMons[4] = {0}; EWRAM_DATA s16 gContestMonConditions[4] = {0}; @@ -244,6 +246,7 @@ extern const struct CompressedSpritePalette gUnknown_08587C10; extern const struct SpriteTemplate gSpriteTemplate_8587C18; extern const union AffineAnimCmd *const gUnknown_082FF6C0[]; extern const union AffineAnimCmd *const gUnknown_082FF694[]; +extern const u8 *const gContestEffectDescriptionPointers[]; void TaskDummy1(u8 taskId) { @@ -2550,3 +2553,84 @@ u8 sub_80DB174(u16 species, u32 otId, u32 personality, u32 index) return spriteId; } + +bool8 IsSpeciesNotUnown(u16 species) +{ + if (species == SPECIES_UNOWN) + return FALSE; + else + return TRUE; +} + +void sub_80DB2BC(void) +{ + CpuCopy16(gContestResources->field_24[0], gContestResources->field_24[0] + 0x500, 0x280); + CpuCopy16(gContestResources->field_24[2], gContestResources->field_24[2] + 0x500, 0x280); +} + +u16 sub_80DB2EC(u16 a0, u8 a1) +{ + u16 var; + + switch (gContestEffects[gContestMoves[a0].effect].effectType) + { + case 0: + case 1: + case 8: + var = 0x9082; + break; + case 2: + case 3: + var = 0x9088; + break; + default: + var = 0x9086; + break; + } + var += 0x9000 + (a1 << 12); + return var; +} + +void prints_contest_move_description(u16 a) +{ + u8 category; + u16 categoryTile; + u8 numHearts; + + category = gContestMoves[a].contestCategory; + if (category == CONTEST_CATEGORY_COOL) + categoryTile = 0x4040; + else if (category == CONTEST_CATEGORY_BEAUTY) + categoryTile = 0x4045; + else if (category == CONTEST_CATEGORY_CUTE) + categoryTile = 0x404A; + else if (category == CONTEST_CATEGORY_SMART) + categoryTile = 0x406A; + else + categoryTile = 0x408A; + + sub_80DECB8(0, categoryTile, 0x0b, 0x1f, 0x05, 0x01, 0x11, 0x01); + sub_80DECB8(0, categoryTile + 0x10, 0x0b, 0x20, 0x05, 0x01, 0x11, 0x01); + + if (gContestEffects[gContestMoves[a].effect].appeal == 0xFF) + numHearts = 0; + else + numHearts = gContestEffects[gContestMoves[a].effect].appeal / 10; + if (numHearts > 8) + numHearts = 8; + sub_80DED10(0, 0x5035, 0x15, 0x1f, 0x08, 0x01, 0x11); + sub_80DED10(0, 0x5012, 0x15, 0x1f, numHearts, 0x01, 0x11); + + if (gContestEffects[gContestMoves[a].effect].jam == 0xFF) + numHearts = 0; + else + numHearts = gContestEffects[gContestMoves[a].effect].jam / 10; + if (numHearts > 8) + numHearts = 8; + sub_80DED10(0, 0x5036, 0x15, 0x20, 0x08, 0x01, 0x11); + sub_80DED10(0, 0x5014, 0x15, 0x20, numHearts, 0x01, 0x11); + + FillWindowPixelBuffer(10, 0); + sub_80DEB70(10, gContestEffectDescriptionPointers[gContestMoves[a].effect]); + sub_80DEB70(9, gText_Slash); +} diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c index bf3e9aeee..ee0a7f288 100644 --- a/src/pokemon_summary_screen.c +++ b/src/pokemon_summary_screen.c @@ -27,21 +27,7 @@ #include "scanline_effect.h" #include "menu_helpers.h" #include "daycare.h" - -struct ContestMove -{ - u8 effect; - u8 type; - u8 comboID; - u8 combo[4]; -}; - -struct ContestEffect -{ - u8 type; - u8 appeal; - u8 jam; -}; +#include "contest_effect.h" extern struct UnkSummaryStruct* gUnknown_0203CF1C; extern struct BgTemplate gUnknown_0861CBB4; @@ -54,7 +40,6 @@ extern struct UnkStruct_61CC04 gUnknown_0861CC10; extern struct UnkStruct_61CC04 gUnknown_0861CBEC; extern struct UnkStruct_61CC04 gUnknown_0861CBF8; extern u16 gSummaryScreenWindow_Tilemap[]; -extern struct ContestMove gContestMoves[]; extern struct ContestEffect gContestEffects[]; extern struct WindowTemplate gUnknown_0861CC24; extern u8 gUnknown_0861CD2C[][3];