through sub_80D7B24

This commit is contained in:
PikalaxALT 2018-05-01 21:27:24 -04:00
parent 4b1e30434d
commit ef29d17c41
4 changed files with 126 additions and 314 deletions

View File

@ -5,306 +5,6 @@
.text
thumb_func_start sub_80D7988
sub_80D7988: @ 80D7988
push {r4,r5,lr}
ldr r4, =gContestResources
movs r0, 0x40
bl AllocZeroed
str r0, [r4]
movs r0, 0x5C
bl AllocZeroed
ldr r1, [r4]
str r0, [r1]
movs r0, 0x70
bl AllocZeroed
ldr r1, [r4]
str r0, [r1, 0x4]
movs r0, 0x14
bl AllocZeroed
ldr r1, [r4]
str r0, [r1, 0x8]
movs r0, 0x44
bl AllocZeroed
ldr r1, [r4]
str r0, [r1, 0xC]
movs r0, 0x10
bl AllocZeroed
ldr r1, [r4]
str r0, [r1, 0x10]
movs r0, 0x10
bl AllocZeroed
ldr r1, [r4]
str r0, [r1, 0x14]
movs r0, 0x14
bl AllocZeroed
ldr r1, [r4]
str r0, [r1, 0x18]
movs r0, 0x40
bl AllocZeroed
ldr r1, [r4]
str r0, [r1, 0x1C]
movs r0, 0xC
bl AllocZeroed
ldr r1, [r4]
str r0, [r1, 0x20]
movs r5, 0x80
lsls r5, 5
adds r0, r5, 0
bl AllocZeroed
ldr r1, [r4]
str r0, [r1, 0x24]
adds r0, r5, 0
bl AllocZeroed
ldr r1, [r4]
str r0, [r1, 0x28]
adds r0, r5, 0
bl AllocZeroed
ldr r1, [r4]
str r0, [r1, 0x2C]
adds r0, r5, 0
bl AllocZeroed
ldr r1, [r4]
str r0, [r1, 0x30]
movs r5, 0x80
lsls r5, 4
adds r0, r5, 0
bl AllocZeroed
ldr r1, [r4]
str r0, [r1, 0x34]
adds r0, r5, 0
bl AllocZeroed
ldr r1, [r4]
str r0, [r1, 0x38]
movs r0, 0x80
lsls r0, 6
bl AllocZeroed
ldr r2, [r4]
str r0, [r2, 0x3C]
ldr r1, =gUnknown_0202305C
str r0, [r1]
ldr r1, =gUnknown_02023060
ldr r0, [r2, 0x28]
str r0, [r1]
pop {r4,r5}
pop {r0}
bx r0
.pool
thumb_func_end sub_80D7988
thumb_func_start sub_80D7A5C
sub_80D7A5C: @ 80D7A5C
push {r4,r5,lr}
ldr r5, =gContestResources
ldr r0, [r5]
ldr r0, [r0]
bl Free
ldr r0, [r5]
movs r4, 0
str r4, [r0]
ldr r0, [r0, 0x4]
bl Free
ldr r0, [r5]
str r4, [r0, 0x4]
ldr r0, [r0, 0x8]
bl Free
ldr r0, [r5]
str r4, [r0, 0x8]
ldr r0, [r0, 0xC]
bl Free
ldr r0, [r5]
str r4, [r0, 0xC]
ldr r0, [r0, 0x10]
bl Free
ldr r0, [r5]
str r4, [r0, 0x10]
ldr r0, [r0, 0x14]
bl Free
ldr r0, [r5]
str r4, [r0, 0x14]
ldr r0, [r0, 0x18]
bl Free
ldr r0, [r5]
str r4, [r0, 0x18]
ldr r0, [r0, 0x1C]
bl Free
ldr r0, [r5]
str r4, [r0, 0x1C]
ldr r0, [r0, 0x20]
bl Free
ldr r0, [r5]
str r4, [r0, 0x20]
ldr r0, [r0, 0x24]
bl Free
ldr r0, [r5]
str r4, [r0, 0x24]
ldr r0, [r0, 0x28]
bl Free
ldr r0, [r5]
str r4, [r0, 0x28]
ldr r0, [r0, 0x2C]
bl Free
ldr r0, [r5]
str r4, [r0, 0x2C]
ldr r0, [r0, 0x30]
bl Free
ldr r0, [r5]
str r4, [r0, 0x30]
ldr r0, [r0, 0x34]
bl Free
ldr r0, [r5]
str r4, [r0, 0x34]
ldr r0, [r0, 0x38]
bl Free
ldr r0, [r5]
str r4, [r0, 0x38]
ldr r0, [r0, 0x3C]
bl Free
ldr r0, [r5]
str r4, [r0, 0x3C]
bl Free
str r4, [r5]
ldr r0, =gUnknown_0202305C
str r4, [r0]
ldr r0, =gUnknown_02023060
str r4, [r0]
pop {r4,r5}
pop {r0}
bx r0
.pool
thumb_func_end sub_80D7A5C
thumb_func_start sub_80D7B24
sub_80D7B24: @ 80D7B24
push {r4-r6,lr}
ldr r0, =gMain
movs r1, 0x87
lsls r1, 3
adds r6, r0, r1
ldrb r5, [r6]
cmp r5, 0x1
beq _080D7BD4
cmp r5, 0x1
bgt _080D7B44
cmp r5, 0
beq _080D7B4E
b _080D7C56
.pool
_080D7B44:
cmp r5, 0x2
beq _080D7BDA
cmp r5, 0x3
beq _080D7C04
b _080D7C56
_080D7B4E:
ldr r0, =gUnknown_02039F38
strb r5, [r0]
bl sub_80D7988
bl AllocateMonSpritesGfx
ldr r4, =gMonSpritesGfxPtr
ldr r0, [r4]
ldr r0, [r0]
bl Free
ldr r0, [r4]
str r5, [r0]
movs r0, 0x80
lsls r0, 7
bl AllocZeroed
ldr r1, [r4]
str r0, [r1]
movs r0, 0
bl SetVBlankCallback
bl sub_80D779C
bl sub_80D77E4
bl sub_80D7678
bl ScanlineEffect_Clear
bl ResetPaletteFade
ldr r2, =gPaletteFade
ldrb r0, [r2, 0x8]
movs r1, 0x80
orrs r0, r1
strb r0, [r2, 0x8]
bl ResetSpriteData
bl ResetTasks
bl FreeAllSpritePalettes
ldr r1, =gReservedSpritePaletteCount
movs r0, 0x4
strb r0, [r1]
ldr r0, =0x02000000
movs r1, 0xD0
lsls r1, 9
adds r0, r1
strb r5, [r0]
bl ClearBattleMonForms
bl sub_80D787C
b _080D7BF6
.pool
_080D7BD4:
movs r0, 0x2
strb r0, [r6]
b _080D7C56
_080D7BDA:
ldr r4, =gContestResources
ldr r0, [r4]
ldr r0, [r0]
adds r0, 0x59
bl sub_80D7E44
lsls r0, 24
cmp r0, 0
beq _080D7C56
ldr r0, [r4]
ldr r0, [r0]
adds r0, 0x59
movs r1, 0
strb r1, [r0]
_080D7BF6:
ldrb r0, [r6]
adds r0, 0x1
strb r0, [r6]
b _080D7C56
.pool
_080D7C04:
bl sub_80DE224
ldr r0, =gBattle_BG1_X
movs r1, 0
strh r1, [r0]
ldr r0, =gBattle_BG1_Y
strh r1, [r0]
movs r0, 0x2
bl BeginFastPaletteFade
ldr r2, =gPaletteFade
ldrb r1, [r2, 0x8]
movs r0, 0x7F
ands r0, r1
strb r0, [r2, 0x8]
ldr r0, =vblank_cb_battle
bl SetVBlankCallback
ldr r0, =sub_80D7C7C
movs r1, 0xA
bl CreateTask
ldr r1, =gContestResources
ldr r1, [r1]
ldr r1, [r1]
strb r0, [r1, 0x8]
ldr r0, =sub_80D823C
bl SetMainCallback2
ldr r0, =gIsLinkContest
ldrb r1, [r0]
movs r0, 0x2
ands r0, r1
cmp r0, 0
beq _080D7C56
bl sub_800E0E8
movs r0, 0x8
movs r1, 0x8
bl CreateWirelessStatusIndicatorSprite
_080D7C56:
pop {r4-r6}
pop {r0}
bx r0
.pool
thumb_func_end sub_80D7B24
thumb_func_start sub_80D7C7C
sub_80D7C7C: @ 80D7C7C
push {lr}

View File

@ -379,6 +379,11 @@ struct ContestResourcesField1C
u8 filler_00[0x40];
};
struct ContestResourcesField20
{
u8 filler_00[0x0C];
};
struct ContestResources
{
struct Contest *field_0;
@ -386,11 +391,14 @@ struct ContestResources
struct UnknownContestStruct7 *field_8;
struct ContestAIInfo *field_C;
struct UnknownContestStruct5 *field_10;
struct UnknownContestStruct4 (*field_14)[4];
struct UnknownContestStruct4 *field_14;
struct ContestStruct_field_18 *field_18;
struct ContestResourcesField1C * field_1c;
u8 filler_20[4];
struct ContestResourcesField20 * field_20;
u8 * field_24[4];
void * field_34;
void * field_38;
void * field_3c;
};
#define shared18000 (*(struct Shared18000 *)(gHeap + 0x1a000))

View File

@ -31,9 +31,18 @@
#include "scanline_effect.h"
#include "util.h"
#define DESTROY_POINTER(ptr) \
free(ptr); \
ptr = NULL;
void sub_80DD590(void);
void sub_80D782C(void);
void sub_80DCE58(u8);
bool8 sub_80D7E44(u8 *);
void sub_80DE224(void);
void sub_80D7C7C(u8 taskId);
void sub_80D823C(void);
void vblank_cb_battle(void);
EWRAM_DATA struct ContestPokemon gContestMons[4] = {0};
EWRAM_DATA s16 gUnknown_02039F00[4] = {0};
@ -48,6 +57,10 @@ EWRAM_DATA bool8 gIsLinkContest = FALSE;
EWRAM_DATA u8 gUnknown_02039F2B = 0;
EWRAM_DATA u16 gSpecialVar_ContestCategory = 0;
EWRAM_DATA u16 gSpecialVar_ContestRank = 0;
EWRAM_DATA u8 gUnknown_02039F30 = 0;
EWRAM_DATA u8 gUnknown_02039F31 = 0;
EWRAM_DATA struct ContestResources * gContestResources = NULL;
EWRAM_DATA u8 gUnknown_02039F38 = 0;
extern u16 gBattle_BG0_X;
extern u16 gBattle_BG0_Y;
@ -194,3 +207,105 @@ void sub_80D787C(void)
sub_80DD590();
*gContestResources->field_1c = (struct ContestResourcesField1C){};
}
void sub_80D7988(void)
{
gContestResources = AllocZeroed(sizeof(struct ContestResources));
gContestResources->field_0 = AllocZeroed(sizeof(struct Contest));
gContestResources->field_4 = AllocZeroed(sizeof(struct ContestantStatus) * 4);
gContestResources->field_8 = AllocZeroed(sizeof(struct UnknownContestStruct7));
gContestResources->field_C = AllocZeroed(sizeof(struct ContestAIInfo));
gContestResources->field_10 = AllocZeroed(sizeof(struct UnknownContestStruct5) * 4);
gContestResources->field_14 = AllocZeroed(sizeof(struct UnknownContestStruct4) * 4);
gContestResources->field_18 = AllocZeroed(sizeof(struct ContestStruct_field_18));
gContestResources->field_1c = AllocZeroed(sizeof(struct ContestResourcesField1C));
gContestResources->field_20 = AllocZeroed(sizeof(struct ContestResourcesField20));
gContestResources->field_24[0] = AllocZeroed(0x1000);
gContestResources->field_24[1] = AllocZeroed(0x1000);
gContestResources->field_24[2] = AllocZeroed(0x1000);
gContestResources->field_24[3] = AllocZeroed(0x1000);
gContestResources->field_34 = AllocZeroed(0x800);
gContestResources->field_38 = AllocZeroed(0x800);
gContestResources->field_3c = AllocZeroed(0x2000);
gUnknown_0202305C = gContestResources->field_3c;
gUnknown_02023060 = gContestResources->field_24[1];
}
void sub_80D7A5C(void)
{
DESTROY_POINTER(gContestResources->field_0);
DESTROY_POINTER(gContestResources->field_4);
DESTROY_POINTER(gContestResources->field_8);
DESTROY_POINTER(gContestResources->field_C);
DESTROY_POINTER(gContestResources->field_10);
DESTROY_POINTER(gContestResources->field_14);
DESTROY_POINTER(gContestResources->field_18);
DESTROY_POINTER(gContestResources->field_1c);
DESTROY_POINTER(gContestResources->field_20);
DESTROY_POINTER(gContestResources->field_24[0]);
DESTROY_POINTER(gContestResources->field_24[1]);
DESTROY_POINTER(gContestResources->field_24[2]);
DESTROY_POINTER(gContestResources->field_24[3]);
DESTROY_POINTER(gContestResources->field_34);
DESTROY_POINTER(gContestResources->field_38);
DESTROY_POINTER(gContestResources->field_3c);
DESTROY_POINTER(gContestResources);
gUnknown_0202305C = NULL;
gUnknown_02023060 = NULL;
}
void sub_80D7B24(void)
{
switch (gMain.state)
{
case 0:
gUnknown_02039F38 = 0;
sub_80D7988();
AllocateMonSpritesGfx();
DESTROY_POINTER(gMonSpritesGfxPtr->firstDecompressed);
gMonSpritesGfxPtr->firstDecompressed = AllocZeroed(0x4000);
SetVBlankCallback(NULL);
sub_80D779C();
sub_80D77E4();
sub_80D7678();
ScanlineEffect_Clear();
ResetPaletteFade();
gPaletteFade.bufferTransferDisabled = TRUE;
ResetSpriteData();
ResetTasks();
FreeAllSpritePalettes();
gReservedSpritePaletteCount = 4;
//shared18000.unk18000 = 0;
gHeap[0x1a000] = 0;
ClearBattleMonForms();
sub_80D787C();
gMain.state++;
break;
case 1:
gMain.state++;
break;
case 2:
if (sub_80D7E44(&gContestResources->field_0->unk1925D))
{
gContestResources->field_0->unk1925D = 0;
gMain.state++;
}
break;
case 3:
sub_80DE224();
gBattle_BG1_X = 0;
gBattle_BG1_Y = 0;
BeginFastPaletteFade(2);
gPaletteFade.bufferTransferDisabled = FALSE;
SetVBlankCallback(vblank_cb_battle);
gContestResources->field_0->mainTaskId = CreateTask(sub_80D7C7C, 10);
SetMainCallback2(sub_80D823C);
if (gIsLinkContest & 2)
{
sub_800E0E8();
CreateWirelessStatusIndicatorSprite(8, 8);
}
break;
}
}

View File

@ -421,18 +421,7 @@ gBagPockets: @ 2039DD8
.include "src/contest.o"
gUnknown_02039F30: @ 2039F30
.space 0x1
gUnknown_02039F31: @ 2039F31
.space 0x3
gContestResources: @ 2039F34
.space 0x4
gUnknown_02039F38: @ 2039F38
.space 0x4
.align 2
gUnknown_02039F3C: @ 2039F3C
.space 0x20