Merge pull request #299 from DizzyEggg/contest_ai

Decompile Contest ai
This commit is contained in:
Diegoisawesome 2018-08-15 16:19:18 -07:00 committed by GitHub
commit f65da613cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 1808 additions and 5449 deletions

View File

@ -43,7 +43,7 @@ sub_80DB8B8: @ 80DB8B8
lsrs r4, r0, 24 lsrs r4, r0, 24
adds r5, r4, 0 adds r5, r4, 0
adds r0, r4, 0 adds r0, r4, 0
bl sub_80DBCA8 bl Contest_IsMonsTurnDisabled
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
beq _080DB8D0 beq _080DB8D0
@ -55,8 +55,8 @@ _080DB8D0:
cmp r4, r0 cmp r4, r0
beq _080DB8F4 beq _080DB8F4
adds r0, r4, 0 adds r0, r4, 0
bl sub_81562C4 bl ContestAI_ResetAI
bl sub_8156324 bl ContestAI_GetActionToUse
lsls r0, 24 lsls r0, 24
ldr r2, =gContestMons ldr r2, =gContestMons
lsrs r0, 23 lsrs r0, 23
@ -533,7 +533,7 @@ _080DBC3C:
ldr r0, [r3, 0x4] ldr r0, [r3, 0x4]
adds r0, r4, r0 adds r0, r4, r0
ldrh r0, [r0, 0x6] ldrh r0, [r0, 0x6]
bl sub_80DD9F0 bl Contest_GetMoveExcitement
ldr r1, [r5] ldr r1, [r5]
ldr r2, [r1] ldr r2, [r1]
ldrb r1, [r2, 0x1] ldrb r1, [r2, 0x1]
@ -568,8 +568,8 @@ _080DBC3C:
.pool .pool
thumb_func_end sub_80DBAA0 thumb_func_end sub_80DBAA0
thumb_func_start sub_80DBCA8 thumb_func_start Contest_IsMonsTurnDisabled
sub_80DBCA8: @ 80DBCA8 Contest_IsMonsTurnDisabled: @ 80DBCA8
push {lr} push {lr}
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
@ -599,7 +599,7 @@ _080DBCD8:
_080DBCDA: _080DBCDA:
pop {r1} pop {r1}
bx r1 bx r1
thumb_func_end sub_80DBCA8 thumb_func_end Contest_IsMonsTurnDisabled
thumb_func_start sub_80DBCE0 thumb_func_start sub_80DBCE0
sub_80DBCE0: @ 80DBCE0 sub_80DBCE0: @ 80DBCE0
@ -3425,7 +3425,7 @@ _080DD334:
ldr r0, [r0, 0x4] ldr r0, [r0, 0x4]
adds r0, r4, r0 adds r0, r4, r0
ldrh r0, [r0, 0x6] ldrh r0, [r0, 0x6]
bl sub_80DD9F0 bl Contest_GetMoveExcitement
ldr r1, [r5] ldr r1, [r5]
ldr r1, [r1, 0x10] ldr r1, [r1, 0x10]
strb r0, [r1] strb r0, [r1]
@ -4213,8 +4213,8 @@ _080DD9C8:
.pool .pool
thumb_func_end sub_80DD940 thumb_func_end sub_80DD940
thumb_func_start sub_80DD9F0 thumb_func_start Contest_GetMoveExcitement
sub_80DD9F0: @ 80DD9F0 Contest_GetMoveExcitement: @ 80DD9F0
lsls r0, 16 lsls r0, 16
ldr r3, =gUnknown_085899EC ldr r3, =gUnknown_085899EC
ldr r1, =gContestMoves ldr r1, =gContestMoves
@ -4233,7 +4233,7 @@ sub_80DD9F0: @ 80DD9F0
ldrsb r0, [r1, r0] ldrsb r0, [r1, r0]
bx lr bx lr
.pool .pool
thumb_func_end sub_80DD9F0 thumb_func_end Contest_GetMoveExcitement
thumb_func_start sub_80DDA20 thumb_func_start sub_80DDA20
sub_80DDA20: @ 80DDA20 sub_80DDA20: @ 80DDA20
@ -5136,7 +5136,7 @@ _080DE146:
beq _080DE1CA beq _080DE1CA
lsls r0, r7, 24 lsls r0, r7, 24
lsrs r0, 24 lsrs r0, 24
bl sub_80DBCA8 bl Contest_IsMonsTurnDisabled
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
bne _080DE1CA bne _080DE1CA

File diff suppressed because it is too large Load Diff

View File

@ -951,7 +951,7 @@ _080E5B00:
bne _080E5B38 bne _080E5B38
lsls r0, r5, 24 lsls r0, r5, 24
lsrs r0, 24 lsrs r0, 24
bl sub_80DBCA8 bl Contest_IsMonsTurnDisabled
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
bne _080E5B38 bne _080E5B38

View File

@ -1,144 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.section .rodata
.align 2
gUnknown_085CDD00:: @ 85CDD00
.4byte sub_81564DC
.4byte sub_8156530
.4byte sub_8156550
.4byte sub_8156594
.4byte sub_81565D8
.4byte sub_815661C
.4byte sub_8156660
.4byte sub_8156684
.4byte sub_81566C8
.4byte sub_815670C
.4byte sub_8156750
.4byte sub_8156794
.4byte sub_81567BC
.4byte sub_8156800
.4byte sub_8156844
.4byte sub_8156888
.4byte sub_81568CC
.4byte sub_815690C
.4byte sub_8156950
.4byte sub_8156994
.4byte sub_81569D8
.4byte sub_8156A1C
.4byte sub_8156A48
.4byte sub_8156A98
.4byte sub_8156AE8
.4byte sub_8156B38
.4byte sub_8156B88
.4byte sub_8156BB4
.4byte sub_8156C04
.4byte sub_8156C54
.4byte sub_8156CA4
.4byte sub_8156CF4
.4byte sub_8156D18
.4byte sub_8156D5C
.4byte sub_8156DA0
.4byte sub_8156DE4
.4byte sub_8156E2C
.4byte sub_8156E74
.4byte sub_8156EBC
.4byte sub_8156F04
.4byte sub_8156F44
.4byte sub_8156F88
.4byte sub_8156FCC
.4byte sub_8157018
.4byte sub_815705C
.4byte sub_81570A0
.4byte sub_815712C
.4byte sub_8157174
.4byte sub_8157200
.4byte sub_8157248
.4byte sub_81572A4
.4byte sub_81572E8
.4byte sub_815732C
.4byte sub_8157370
.4byte sub_81573B4
.4byte sub_8157410
.4byte sub_8157454
.4byte sub_8157498
.4byte sub_81574DC
.4byte sub_8157520
.4byte sub_8157578
.4byte sub_81575BC
.4byte sub_8157600
.4byte sub_8157644
.4byte sub_8157688
.4byte sub_8157700
.4byte sub_8157748
.4byte sub_8157790
.4byte sub_8157808
.4byte sub_8157850
.4byte sub_8157898
.4byte sub_81578F8
.4byte sub_8157940
.4byte sub_8157988
.4byte sub_81579CC
.4byte sub_8157A10
.4byte sub_8157A54
.4byte sub_8157A98
.4byte sub_8157ADC
.4byte sub_8157B38
.4byte sub_8157B7C
.4byte sub_8157BC0
.4byte sub_8157C04
.4byte sub_8157C48
.4byte sub_8157C94
.4byte sub_8157CDC
.4byte sub_8157D24
.4byte sub_8157D60
.4byte sub_8157DA8
.4byte sub_8157DF0
.4byte sub_8157E3C
.4byte sub_8157E84
.4byte sub_8157ECC
.4byte sub_8157F14
.4byte sub_8157F5C
.4byte sub_8157FA0
.4byte sub_8157FE8
.4byte sub_8158030
.4byte sub_8158078
.4byte sub_81580C0
.4byte sub_8158108
.4byte sub_815814C
.4byte sub_8158190
.4byte sub_81581D4
.4byte sub_8158218
.4byte sub_8158254
.4byte sub_8158298
.4byte sub_81582DC
.4byte sub_8158320
.4byte sub_8158364
.4byte sub_81583B8
.4byte sub_81583FC
.4byte sub_8158440
.4byte sub_815846C
.4byte sub_815849C
.4byte sub_81584D4
.4byte sub_8158508
.4byte sub_815853C
.4byte sub_815858C
.4byte sub_81585DC
.4byte sub_815862C
.4byte sub_815867C
.4byte sub_81586D0
.4byte sub_8158724
.4byte sub_8158778
.4byte sub_81587CC
.4byte sub_815881C
.4byte sub_815886C
.4byte dp15_call
.4byte sub_81588BC
.4byte sub_8158948
.4byte sub_81589A4
.4byte sub_81589EC
.4byte sub_8158A34
.4byte sub_8158AA0
.4byte sub_8158AE8

View File

@ -341,7 +341,8 @@ struct UnknownContestStruct7
u8 contestant; u8 contestant;
}; };
struct ContestAIInfo { struct ContestAIInfo
{
/*0x00*/ u8 aiState; /*0x00*/ u8 aiState;
/*0x02*/ u16 unk2; /*0x02*/ u16 unk2;
/*0x04*/ u8 unk4; /*0x04*/ u8 unk4;
@ -352,9 +353,9 @@ struct ContestAIInfo {
/*0x14*/ u32 flags; /*0x14*/ u32 flags;
/*0x18*/ s16 scriptResult; /*0x18*/ s16 scriptResult;
/*0x1A*/ s16 scriptArr[3]; /*0x1A*/ s16 scriptArr[3];
/*0x20*/ u32 stack[8]; /*0x20*/ const u8 *stack[8];
/*0x40*/ u8 unk40; /*0x40*/ u8 stackSize;
/*0x41*/ u8 unk41; /*0x41*/ u8 contestantId;
}; };
struct UnknownContestStruct5 struct UnknownContestStruct5
@ -406,7 +407,7 @@ extern struct ContestResources *gContestResources;
#define sContest (*gContestResources->field_0) #define sContest (*gContestResources->field_0)
#define sContestantStatus (gContestResources->field_4) #define sContestantStatus (gContestResources->field_4)
#define shared192D0 (*gContestResources->field_8) #define shared192D0 (*gContestResources->field_8)
#define eContestAI (*gContestResources->field_C) #define eContestAI (gContestResources->field_C)
#define shared19328 (*gContestResources->field_10) #define shared19328 (*gContestResources->field_10)
#define shared19338 (*gContestResources->field_14) #define shared19338 (*gContestResources->field_14)
@ -417,5 +418,12 @@ extern u32 gContestRngValue;
bool8 IsSpeciesNotUnown(u16 species); bool8 IsSpeciesNotUnown(u16 species);
void LoadContestBgAfterMoveAnim(void); void LoadContestBgAfterMoveAnim(void);
void SetContestantEffectStringID(u8 a, u8 b);
void SetContestantEffectStringID2(u8 a, u8 b);
void MakeContestantNervous(u8 p);
bool8 Contest_IsMonsTurnDisabled(u8 a);
bool8 sub_80DE1E8(u8 a);
void SetStartledString(u8 a, u8 b);
s8 Contest_GetMoveExcitement(u16);
#endif //GUARD_CONTEST_H #endif //GUARD_CONTEST_H

16
include/contest_ai.h Normal file
View File

@ -0,0 +1,16 @@
#ifndef GUARD_CONTESTAI_H
#define GUARD_CONTESTAI_H
// AI states
enum
{
CONTESTAI_SETTING_UP,
CONTESTAI_PROCESSING,
CONTESTAI_FINISHED,
CONTESTAI_DO_NOT_PROCESS
};
void ContestAI_ResetAI(u8);
u8 ContestAI_GetActionToUse(void);
#endif // GUARD_CONTESTAI_H

View File

@ -17,6 +17,8 @@ struct ContestEffect
}; };
extern const struct ContestMove gContestMoves[]; extern const struct ContestMove gContestMoves[];
extern struct ContestEffect gContestEffects[]; extern const struct ContestEffect gContestEffects[];
bool8 AreMovesContestCombo(u16 lastMove, u16 nextMove);
#endif //GUARD_CONTEST_EFFECT_H #endif //GUARD_CONTEST_EFFECT_H

View File

@ -203,7 +203,7 @@ SECTIONS {
src/save.o(.text); src/save.o(.text);
src/mystery_event_script.o(.text); src/mystery_event_script.o(.text);
asm/field_effect_helpers.o(.text); asm/field_effect_helpers.o(.text);
asm/contest_ai.o(.text); src/contest_ai.o(.text);
src/battle_anim_sound_tasks.o(.text); src/battle_anim_sound_tasks.o(.text);
src/battle_controller_safari.o(.text); src/battle_controller_safari.o(.text);
src/fldeff_sweetscent.o(.text); src/fldeff_sweetscent.o(.text);
@ -488,7 +488,7 @@ SECTIONS {
data/cable_car.o(.rodata); data/cable_car.o(.rodata);
src/save.o(.rodata); src/save.o(.rodata);
data/field_effect_helpers.o(.rodata); data/field_effect_helpers.o(.rodata);
data/contest_ai.o(.rodata); src/contest_ai.o(.rodata);
src/battle_controller_safari.o(.rodata); src/battle_controller_safari.o(.rodata);
data/battle_anim_815A0D4.o(.rodata); data/battle_anim_815A0D4.o(.rodata);
src/learn_move.o(.rodata); src/learn_move.o(.rodata);

View File

@ -107,7 +107,7 @@ u16 sub_80DE84C(u16);
void sub_80DB89C(void); void sub_80DB89C(void);
u16 sub_80DB8B8(u8); u16 sub_80DB8B8(u8);
void sub_80DB918(void); void sub_80DB918(void);
bool8 sub_80DBCA8(u8); bool8 Contest_IsMonsTurnDisabled(u8);
void sub_80DBF68(void); void sub_80DBF68(void);
void sub_80DBF90(void); void sub_80DBF90(void);
void sub_80DC2BC(void); void sub_80DC2BC(void);
@ -721,7 +721,7 @@ void sub_80D833C(u8 taskId)
sub_80DCD48(); sub_80DCD48();
DmaCopy32Defvars(3, gPlttBufferUnfaded, shared18000.unk18204, 0x400); DmaCopy32Defvars(3, gPlttBufferUnfaded, shared18000.unk18204, 0x400);
ConvertIntToDecimalStringN(gStringVar1, gContestResources->field_0->turnNumber + 1, STR_CONV_MODE_LEFT_ALIGN, 1); ConvertIntToDecimalStringN(gStringVar1, gContestResources->field_0->turnNumber + 1, STR_CONV_MODE_LEFT_ALIGN, 1);
if (!sub_80DBCA8(gContestPlayerMonIndex)) if (!Contest_IsMonsTurnDisabled(gContestPlayerMonIndex))
StringCopy(gDisplayedStringBattle, gText_0827D507); StringCopy(gDisplayedStringBattle, gText_0827D507);
else else
StringCopy(gDisplayedStringBattle, gText_0827D531); StringCopy(gDisplayedStringBattle, gText_0827D531);
@ -745,7 +745,7 @@ void sub_80D8424(u8 taskId)
if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys == B_BUTTON)) if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys == B_BUTTON))
{ {
PlaySE(SE_SELECT); PlaySE(SE_SELECT);
if (!sub_80DBCA8(gContestPlayerMonIndex)) if (!Contest_IsMonsTurnDisabled(gContestPlayerMonIndex))
{ {
sub_80DC490(TRUE); sub_80DC490(TRUE);
gTasks[taskId].func = sub_80D8490; gTasks[taskId].func = sub_80D8490;
@ -819,7 +819,7 @@ void sub_80D8610(u8 taskId)
PlaySE(SE_SELECT); PlaySE(SE_SELECT);
sub_80DC490(FALSE); sub_80DC490(FALSE);
ConvertIntToDecimalStringN(gStringVar1, gContestResources->field_0->turnNumber + 1, STR_CONV_MODE_LEFT_ALIGN, 1); ConvertIntToDecimalStringN(gStringVar1, gContestResources->field_0->turnNumber + 1, STR_CONV_MODE_LEFT_ALIGN, 1);
if (!sub_80DBCA8(gContestPlayerMonIndex)) if (!Contest_IsMonsTurnDisabled(gContestPlayerMonIndex))
StringCopy(gDisplayedStringBattle, gText_0827D507); StringCopy(gDisplayedStringBattle, gText_0827D507);
else else
StringCopy(gDisplayedStringBattle, gText_0827D531); StringCopy(gDisplayedStringBattle, gText_0827D531);
@ -2636,7 +2636,7 @@ void sub_80DB4E0(u16 move, u8 b)
{ {
u8 r7 = gUnknown_02039F26[b] * 5 + 2; u8 r7 = gUnknown_02039F26[b] * 5 + 2;
if (!sub_80DBCA8(b) && move != MOVE_NONE) if (!Contest_IsMonsTurnDisabled(b) && move != MOVE_NONE)
{ {
u16 tile = sub_80DB2EC(move, b); u16 tile = sub_80DB2EC(move, b);

1756
src/contest_ai.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -42,7 +42,6 @@ extern struct UnkStruct_61CC04 gUnknown_0861CC10;
extern struct UnkStruct_61CC04 gUnknown_0861CBEC; extern struct UnkStruct_61CC04 gUnknown_0861CBEC;
extern struct UnkStruct_61CC04 gUnknown_0861CBF8; extern struct UnkStruct_61CC04 gUnknown_0861CBF8;
extern u16 gSummaryScreenWindow_Tilemap[]; extern u16 gSummaryScreenWindow_Tilemap[];
extern struct ContestEffect gContestEffects[];
extern struct WindowTemplate gUnknown_0861CC24; extern struct WindowTemplate gUnknown_0861CC24;
extern u8 gUnknown_0861CD2C[][3]; extern u8 gUnknown_0861CD2C[][3];
extern const u8 gSpeciesNames[][POKEMON_NAME_LENGTH + 1]; extern const u8 gSpeciesNames[][POKEMON_NAME_LENGTH + 1];