through sub_80D7DE8

This commit is contained in:
PikalaxALT 2018-05-02 08:43:27 -04:00
parent ef29d17c41
commit 4bf0950421
11 changed files with 105 additions and 231 deletions

View File

@ -5,216 +5,6 @@
.text .text
thumb_func_start sub_80D7C7C
sub_80D7C7C: @ 80D7C7C
push {lr}
lsls r0, 24
lsrs r3, r0, 24
ldr r0, =gPaletteFade
ldrb r1, [r0, 0x7]
movs r0, 0x80
ands r0, r1
lsls r0, 24
lsrs r2, r0, 24
cmp r2, 0
bne _080D7CA2
ldr r0, =gTasks
lsls r1, r3, 2
adds r1, r3
lsls r1, 3
adds r1, r0
strh r2, [r1, 0x8]
ldr r0, =sub_80D7CB4
str r0, [r1]
_080D7CA2:
pop {r0}
bx r0
.pool
thumb_func_end sub_80D7C7C
thumb_func_start sub_80D7CB4
sub_80D7CB4: @ 80D7CB4
push {r4-r6,lr}
lsls r0, 24
lsrs r5, r0, 24
ldr r0, =gIsLinkContest
ldrb r1, [r0]
movs r0, 0x1
ands r0, r1
cmp r0, 0
beq _080D7D90
movs r0, 0x2
ands r0, r1
cmp r0, 0
beq _080D7D3A
ldr r2, =gTasks
lsls r1, r5, 2
adds r0, r1, r5
lsls r0, 3
adds r4, r0, r2
movs r2, 0x8
ldrsh r0, [r4, r2]
adds r6, r1, 0
cmp r0, 0x1
beq _080D7D04
cmp r0, 0x1
bgt _080D7CF4
cmp r0, 0
beq _080D7CFA
b _080D7D3A
.pool
_080D7CF4:
cmp r0, 0x2
beq _080D7D28
b _080D7D3A
_080D7CFA:
bl sub_80DBF68
ldrh r0, [r4, 0x8]
adds r0, 0x1
strh r0, [r4, 0x8]
_080D7D04:
bl sub_800A520
lsls r0, 24
cmp r0, 0
beq _080D7D9E
bl sub_800ADF8
ldr r0, =gTasks
adds r1, r6, r5
lsls r1, 3
adds r1, r0
ldrh r0, [r1, 0x8]
adds r0, 0x1
strh r0, [r1, 0x8]
b _080D7D9E
.pool
_080D7D28:
bl sub_800A520
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
bne _080D7D9E
ldrh r0, [r4, 0x8]
adds r0, 0x1
strh r0, [r4, 0x8]
_080D7D3A:
ldr r2, =gPaletteFade
ldrb r1, [r2, 0x7]
movs r0, 0x80
ands r0, r1
lsls r0, 24
lsrs r4, r0, 24
cmp r4, 0
bne _080D7D9E
ldrb r1, [r2, 0x8]
movs r0, 0x7F
ands r0, r1
strb r0, [r2, 0x8]
ldr r0, =gIsLinkContest
ldrb r1, [r0]
movs r0, 0x2
ands r0, r1
cmp r0, 0
bne _080D7D62
bl sub_80DBF68
_080D7D62:
ldr r0, =sub_80D7DAC
movs r1, 0
bl CreateTask
ldr r1, =gTasks
lsls r0, r5, 2
adds r0, r5
lsls r0, 3
adds r0, r1
strh r4, [r0, 0x8]
ldr r1, =TaskDummy1
str r1, [r0]
b _080D7D9E
.pool
_080D7D90:
ldr r0, =gTasks
lsls r1, r5, 2
adds r1, r5
lsls r1, 3
adds r1, r0
ldr r0, =sub_80D80C8
str r0, [r1]
_080D7D9E:
pop {r4-r6}
pop {r0}
bx r0
.pool
thumb_func_end sub_80D7CB4
thumb_func_start sub_80D7DAC
sub_80D7DAC: @ 80D7DAC
push {lr}
lsls r0, 24
lsrs r0, 24
ldr r1, =sub_80FC998
ldr r2, =sub_80D7DC8
bl SetTaskFuncWithFollowupFunc
pop {r0}
bx r0
.pool
thumb_func_end sub_80D7DAC
thumb_func_start sub_80D7DC8
sub_80D7DC8: @ 80D7DC8
lsls r0, 24
lsrs r0, 24
ldr r2, =gTasks
lsls r1, r0, 2
adds r1, r0
lsls r1, 3
adds r1, r2
movs r0, 0x1
strh r0, [r1, 0x8]
ldr r0, =sub_80D7DE8
str r0, [r1]
bx lr
.pool
thumb_func_end sub_80D7DC8
thumb_func_start sub_80D7DE8
sub_80D7DE8: @ 80D7DE8
push {r4,r5,lr}
lsls r0, 24
lsrs r4, r0, 24
ldr r5, =gTasks
lsls r0, r4, 2
adds r0, r4
lsls r0, 3
adds r0, r5
ldrh r1, [r0, 0x8]
subs r1, 0x1
strh r1, [r0, 0x8]
lsls r1, 16
cmp r1, 0
bgt _080D7E2A
bl GetMultiplayerId
adds r0, r4, 0
bl DestroyTask
ldr r0, =gContestResources
ldr r0, [r0]
ldr r0, [r0]
ldrb r1, [r0, 0x8]
lsls r0, r1, 2
adds r0, r1
lsls r0, 3
adds r0, r5
ldr r1, =sub_80D80C8
str r1, [r0]
ldr r1, =gRngValue
ldr r0, =gUnknown_030060B8
ldr r0, [r0]
str r0, [r1]
_080D7E2A:
pop {r4,r5}
pop {r0}
bx r0
.pool
thumb_func_end sub_80D7DE8
thumb_func_start sub_80D7E44 thumb_func_start sub_80D7E44
sub_80D7E44: @ 80D7E44 sub_80D7E44: @ 80D7E44
push {r4-r7,lr} push {r4-r7,lr}
@ -4722,7 +4512,7 @@ _080DA65C:
bl sub_80DF4F8 bl sub_80DF4F8
bl sub_80DF750 bl sub_80DF750
_080DA668: _080DA668:
ldr r1, =gUnknown_030060B8 ldr r1, =gContestRngValue
ldr r0, =gRngValue ldr r0, =gRngValue
ldr r0, [r0] ldr r0, [r0]
str r0, [r1] str r0, [r1]

View File

@ -434,7 +434,7 @@ _080FC858:
adds r1, r4, 0 adds r1, r4, 0
movs r2, 0x4 movs r2, 0x4
bl memcpy bl memcpy
ldr r0, =gUnknown_030060B8 ldr r0, =gContestRngValue
adds r1, r4, 0 adds r1, r4, 0
movs r2, 0x4 movs r2, 0x4
bl memcpy bl memcpy

View File

@ -558,7 +558,7 @@ _081DA2AC:
adds r1, r4, 0 adds r1, r4, 0
movs r2, 0x4 movs r2, 0x4
bl memcpy bl memcpy
ldr r0, =gUnknown_030060B8 ldr r0, =gContestRngValue
adds r1, r4, 0 adds r1, r4, 0
movs r2, 0x4 movs r2, 0x4
bl memcpy bl memcpy

View File

@ -979,7 +979,7 @@ sub_80F8FE8: @ 80F8FE8
ands r0, r1 ands r0, r1
cmp r0, 0 cmp r0, 0
beq _080F9020 beq _080F9020
ldr r2, =gUnknown_030060B8 ldr r2, =gContestRngValue
ldr r1, [r2] ldr r1, [r2]
ldr r0, =0x41c64e6d ldr r0, =0x41c64e6d
muls r0, r1 muls r0, r1
@ -1007,7 +1007,7 @@ _080F902A:
thumb_func_start sub_80F903C thumb_func_start sub_80F903C
sub_80F903C: @ 80F903C sub_80F903C: @ 80F903C
ldr r2, =gUnknown_030060B8 ldr r2, =gContestRngValue
ldr r1, [r2] ldr r1, [r2]
ldr r0, =0x41c64e6d ldr r0, =0x41c64e6d
muls r0, r1 muls r0, r1

1
common_syms/contest.txt Normal file
View File

@ -0,0 +1 @@
gContestRngValue

View File

@ -405,6 +405,8 @@ struct ContestResources
extern struct ContestResources *gContestResources; extern struct ContestResources *gContestResources;
extern u32 gContestRngValue;
bool8 IsSpeciesNotUnown(u16 species); bool8 IsSpeciesNotUnown(u16 species);
void LoadContestBgAfterMoveAnim(void); void LoadContestBgAfterMoveAnim(void);

View File

@ -4,5 +4,6 @@
void sub_80F840C(void); void sub_80F840C(void);
void sub_80F8484(void); void sub_80F8484(void);
void sub_80F84C4(u8); void sub_80F84C4(u8);
void sub_80FC998(u8 taskId);
#endif // GUARD_CONTEST_LINK_80F57C4_H #endif // GUARD_CONTEST_LINK_80F57C4_H

View File

@ -30,18 +30,25 @@
#include "tv.h" #include "tv.h"
#include "scanline_effect.h" #include "scanline_effect.h"
#include "util.h" #include "util.h"
#include "contest_link_80F57C4.h"
#define DESTROY_POINTER(ptr) \ #define DESTROY_POINTER(ptr) \
free(ptr); \ free(ptr); \
ptr = NULL; ptr = NULL;
void sub_80DD590(void);
void sub_80D782C(void); void sub_80D782C(void);
void sub_80D7C7C(u8 taskId);
void sub_80D7CB4(u8 taskId);
void sub_80D7DAC(u8 taskId);
void sub_80D7DC8(u8 taskId);
void sub_80D7DE8(u8 taskId);
void sub_80D80C8(u8 taskId);
void sub_80D823C(void);
void sub_80DBF68(void);
void sub_80DCE58(u8); void sub_80DCE58(u8);
void sub_80DD590(void);
bool8 sub_80D7E44(u8 *); bool8 sub_80D7E44(u8 *);
void sub_80DE224(void); void sub_80DE224(void);
void sub_80D7C7C(u8 taskId);
void sub_80D823C(void);
void vblank_cb_battle(void); void vblank_cb_battle(void);
EWRAM_DATA struct ContestPokemon gContestMons[4] = {0}; EWRAM_DATA struct ContestPokemon gContestMons[4] = {0};
@ -53,7 +60,9 @@ EWRAM_DATA u8 gContestFinalStandings[4] = {0};
EWRAM_DATA u8 gUnknown_02039F24 = 0; EWRAM_DATA u8 gUnknown_02039F24 = 0;
EWRAM_DATA u8 gContestPlayerMonIndex = 0; EWRAM_DATA u8 gContestPlayerMonIndex = 0;
EWRAM_DATA u8 gUnknown_02039F26[4] = {0}; EWRAM_DATA u8 gUnknown_02039F26[4] = {0};
EWRAM_DATA bool8 gIsLinkContest = FALSE; EWRAM_DATA u8 gIsLinkContest = 0;
// Bit 0: Is a link contest
// Bit 1: Link contest uses wireless adapter
EWRAM_DATA u8 gUnknown_02039F2B = 0; EWRAM_DATA u8 gUnknown_02039F2B = 0;
EWRAM_DATA u16 gSpecialVar_ContestCategory = 0; EWRAM_DATA u16 gSpecialVar_ContestCategory = 0;
EWRAM_DATA u16 gSpecialVar_ContestRank = 0; EWRAM_DATA u16 gSpecialVar_ContestRank = 0;
@ -61,6 +70,9 @@ EWRAM_DATA u8 gUnknown_02039F30 = 0;
EWRAM_DATA u8 gUnknown_02039F31 = 0; EWRAM_DATA u8 gUnknown_02039F31 = 0;
EWRAM_DATA struct ContestResources * gContestResources = NULL; EWRAM_DATA struct ContestResources * gContestResources = NULL;
EWRAM_DATA u8 gUnknown_02039F38 = 0; EWRAM_DATA u8 gUnknown_02039F38 = 0;
EWRAM_DATA struct ContestWinner gUnknown_02039F3C = {0};
u32 gContestRngValue;
extern u16 gBattle_BG0_X; extern u16 gBattle_BG0_X;
extern u16 gBattle_BG0_Y; extern u16 gBattle_BG0_Y;
@ -89,7 +101,7 @@ void TaskDummy1(u8 taskId)
void ResetLinkContestBoolean(void) void ResetLinkContestBoolean(void)
{ {
gIsLinkContest = FALSE; gIsLinkContest = 0;
} }
void sub_80D7678(void) void sub_80D7678(void)
@ -309,3 +321,78 @@ void sub_80D7B24(void)
} }
} }
void sub_80D7C7C(u8 taskId)
{
if (!gPaletteFade.active)
{
gTasks[taskId].data[0] = 0;
gTasks[taskId].func = sub_80D7CB4;
}
}
void sub_80D7CB4(u8 taskId)
{
if (gIsLinkContest & 1)
{
if (gIsLinkContest & 2)
{
switch (gTasks[taskId].data[0])
{
case 0:
sub_80DBF68();
gTasks[taskId].data[0]++;
// fallthrough
case 1:
if (sub_800A520())
{
sub_800ADF8();
gTasks[taskId].data[0]++;
}
return;
case 2:
if (sub_800A520() != TRUE)
return;
gTasks[taskId].data[0]++;
break;
}
}
if (!gPaletteFade.active)
{
gPaletteFade.bufferTransferDisabled = FALSE;
if (!(gIsLinkContest & 2))
sub_80DBF68();
CreateTask(sub_80D7DAC, 0);
gTasks[taskId].data[0] = 0;
gTasks[taskId].func = TaskDummy1;
}
}
else
{
gTasks[taskId].func = sub_80D80C8;
}
}
void sub_80D7DAC(u8 taskId)
{
SetTaskFuncWithFollowupFunc(taskId, sub_80FC998, sub_80D7DC8);
}
void sub_80D7DC8(u8 taskId)
{
gTasks[taskId].data[0] = 1;
gTasks[taskId].func = sub_80D7DE8;
}
void sub_80D7DE8(u8 taskId)
{
gTasks[taskId].data[0]--;
if (gTasks[taskId].data[0] <= 0)
{
GetMultiplayerId(); // unused return value
DestroyTask(taskId);
gTasks[gContestResources->field_0->mainTaskId].func = sub_80D80C8;
gRngValue = gContestRngValue;
}
}

View File

@ -25,6 +25,8 @@ enum
KEYITEMS_POCKET KEYITEMS_POCKET
}; };
EWRAM_DATA struct BagPocket gBagPockets[5] = {};
u16 GetBagItemQuantity(u16* quantity) u16 GetBagItemQuantity(u16* quantity)
{ {
return gSaveBlock2Ptr->encryptionKey ^ *quantity; return gSaveBlock2Ptr->encryptionKey ^ *quantity;

View File

@ -83,9 +83,7 @@ gUnknown_030060B0: @ 30060B0
gUnknown_030060B4: @ 30060B4 gUnknown_030060B4: @ 30060B4
.space 0x4 .space 0x4
gUnknown_030060B8: @ 30060B8 .include "contest.o"
.space 0x4
.include "tv.o" .include "tv.o"
gUnknown_03006130: @ 3006130 gUnknown_03006130: @ 3006130

View File

@ -414,17 +414,10 @@ gUnknown_02039DD0: @ 2039DD0
.space 0x4 .space 0x4
.include "src/map_name_popup.o" .include "src/map_name_popup.o"
.space 0x3 .include "src/item.o"
gBagPockets: @ 2039DD8
.space 0x28
.include "src/contest.o" .include "src/contest.o"
.align 2 .align 2
gUnknown_02039F3C: @ 2039F3C
.space 0x20
gUnknown_02039F5C: @ 2039F5C gUnknown_02039F5C: @ 2039F5C
.space 0x1 .space 0x1