Decompile contest_link_81D9DE4.c

This commit is contained in:
Marcus Huderle 2019-01-03 11:54:22 -06:00 committed by huderlem
parent b471bba55e
commit bc43dbab13
10 changed files with 399 additions and 939 deletions

View File

@ -4628,7 +4628,7 @@ sub_80F7ED0: @ 80F7ED0
thumb_func_start sub_80F7F30 thumb_func_start sub_80F7F30
sub_80F7F30: @ 80F7F30 sub_80F7F30: @ 80F7F30
push {r4,r5,lr} push {r4,r5,lr}
ldr r0, =gUnknown_02039F24 ldr r0, =gContestMonPartyIndex
ldrb r1, [r0] ldrb r1, [r0]
movs r0, 0x64 movs r0, 0x64
muls r0, r1 muls r0, r1
@ -4660,7 +4660,7 @@ _080F7F5E:
sub_80F7F7C: @ 80F7F7C sub_80F7F7C: @ 80F7F7C
push {r4,lr} push {r4,lr}
movs r4, 0 movs r4, 0
ldr r0, =gUnknown_02039F24 ldr r0, =gContestMonPartyIndex
ldrb r1, [r0] ldrb r1, [r0]
movs r0, 0x64 movs r0, 0x64
muls r1, r0 muls r1, r0
@ -4750,7 +4750,7 @@ _080F8034:
.4byte _080F8190 .4byte _080F8190
.4byte _080F81F8 .4byte _080F81F8
_080F8048: _080F8048:
ldr r6, =gUnknown_02039F24 ldr r6, =gContestMonPartyIndex
ldrb r0, [r6] ldrb r0, [r6]
movs r5, 0x64 movs r5, 0x64
muls r0, r5 muls r0, r5
@ -4801,7 +4801,7 @@ _080F809C:
.pool .pool
_080F80B8: _080F80B8:
mov r4, sp mov r4, sp
ldr r7, =gUnknown_02039F24 ldr r7, =gContestMonPartyIndex
ldrb r0, [r7] ldrb r0, [r7]
movs r6, 0x64 movs r6, 0x64
muls r0, r6 muls r0, r6
@ -4850,7 +4850,7 @@ _080F810A:
.pool .pool
_080F8124: _080F8124:
mov r4, sp mov r4, sp
ldr r7, =gUnknown_02039F24 ldr r7, =gContestMonPartyIndex
ldrb r0, [r7] ldrb r0, [r7]
movs r6, 0x64 movs r6, 0x64
muls r0, r6 muls r0, r6
@ -4897,7 +4897,7 @@ _080F814E:
.pool .pool
_080F8190: _080F8190:
mov r4, sp mov r4, sp
ldr r7, =gUnknown_02039F24 ldr r7, =gContestMonPartyIndex
ldrb r0, [r7] ldrb r0, [r7]
movs r6, 0x64 movs r6, 0x64
muls r0, r6 muls r0, r6
@ -4940,7 +4940,7 @@ _080F8190:
.pool .pool
_080F81F8: _080F81F8:
mov r4, sp mov r4, sp
ldr r7, =gUnknown_02039F24 ldr r7, =gContestMonPartyIndex
ldrb r0, [r7] ldrb r0, [r7]
movs r6, 0x64 movs r6, 0x64
muls r0, r6 muls r0, r6
@ -5320,7 +5320,7 @@ sub_80F8508: @ 80F8508
ands r0, r1 ands r0, r1
cmp r0, 0 cmp r0, 0
beq _080F8540 beq _080F8540
ldr r0, =gUnknown_02039F24 ldr r0, =gContestMonPartyIndex
ldrb r0, [r0] ldrb r0, [r0]
bl sub_80DA8C8 bl sub_80DA8C8
ldr r1, =sub_80FC6BC ldr r1, =sub_80FC6BC
@ -5330,7 +5330,7 @@ sub_80F8508: @ 80F8508
b _080F8556 b _080F8556
.pool .pool
_080F8540: _080F8540:
ldr r0, =gUnknown_02039F24 ldr r0, =gContestMonPartyIndex
ldrb r0, [r0] ldrb r0, [r0]
bl sub_80DA8C8 bl sub_80DA8C8
ldr r1, =gTasks ldr r1, =gTasks
@ -5399,7 +5399,7 @@ sub_80F85BC: @ 80F85BC
str r0, [sp] str r0, [sp]
str r0, [sp, 0x4] str r0, [sp, 0x4]
movs r3, 0 movs r3, 0
ldr r5, =gUnknown_02039F30 ldr r5, =gNumLinkContestPlayers
mov r12, r5 mov r12, r5
ldr r0, =gSpecialVar_0x8004 ldr r0, =gSpecialVar_0x8004
mov r9, r0 mov r9, r0
@ -5529,7 +5529,7 @@ sub_80F86E0: @ 80F86E0
adds r3, r0, 0 adds r3, r0, 0
movs r4, 0 movs r4, 0
movs r2, 0x1 movs r2, 0x1
ldr r0, =gUnknown_02039F30 ldr r0, =gNumLinkContestPlayers
ldrb r0, [r0] ldrb r0, [r0]
cmp r2, r0 cmp r2, r0
bge _080F8708 bge _080F8708

View File

@ -142,7 +142,7 @@ sub_80FC5DC: @ 80FC5DC
ldr r1, =gContestPlayerMonIndex ldr r1, =gContestPlayerMonIndex
strb r0, [r1] strb r0, [r1]
bl GetLinkPlayerCount bl GetLinkPlayerCount
ldr r4, =gUnknown_02039F30 ldr r4, =gNumLinkContestPlayers
strb r0, [r4] strb r0, [r4]
ldr r1, =gIsLinkContest ldr r1, =gIsLinkContest
movs r0, 0x1 movs r0, 0x1
@ -313,7 +313,7 @@ _080FC758:
cmp r0, 0 cmp r0, 0
beq _080FC7F4 beq _080FC7F4
movs r5, 0 movs r5, 0
ldr r0, =gUnknown_02039F30 ldr r0, =gNumLinkContestPlayers
mov r8, r6 mov r8, r6
ldrb r0, [r0] ldrb r0, [r0]
cmp r5, r0 cmp r5, r0
@ -334,7 +334,7 @@ _080FC770:
bl sub_80DFA08 bl sub_80DFA08
adds r6, 0x1C adds r6, 0x1C
adds r5, 0x1 adds r5, 0x1
ldr r0, =gUnknown_02039F30 ldr r0, =gNumLinkContestPlayers
ldrb r0, [r0] ldrb r0, [r0]
cmp r5, r0 cmp r5, r0
blt _080FC770 blt _080FC770
@ -513,7 +513,7 @@ _080FC90C:
cmp r0, 0 cmp r0, 0
beq _080FC986 beq _080FC986
movs r3, 0 movs r3, 0
ldr r1, =gUnknown_02039F30 ldr r1, =gNumLinkContestPlayers
ldrb r0, [r1] ldrb r0, [r1]
cmp r3, r0 cmp r3, r0
bge _080FC93A bge _080FC93A
@ -682,7 +682,7 @@ _080FCA68:
cmp r0, 0 cmp r0, 0
beq _080FCAB2 beq _080FCAB2
movs r2, 0 movs r2, 0
ldr r6, =gUnknown_02039F30 ldr r6, =gNumLinkContestPlayers
mov r9, r8 mov r9, r8
mov r12, r7 mov r12, r7
ldrb r0, [r6] ldrb r0, [r6]

View File

@ -1,890 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.syntax unified
.text
thumb_func_start sub_81D9DE4
sub_81D9DE4: @ 81D9DE4
push {r4-r6,lr}
lsls r0, 24
lsrs r6, r0, 24
ldr r1, =gTasks
lsls r0, r6, 2
adds r0, r6
lsls r0, 3
adds r0, r1
movs r1, 0x1A
ldrsh r0, [r0, r1]
cmp r0, 0x4
bhi _081D9EA4
lsls r0, 2
ldr r1, =_081D9E10
adds r0, r1
ldr r0, [r0]
mov pc, r0
.pool
.align 2, 0
_081D9E10:
.4byte _081D9E24
.4byte _081D9E44
.4byte _081D9E64
.4byte _081D9E84
.4byte _081D9EA4
_081D9E24:
ldr r4, =gUnknown_02039F31
ldr r0, =gUnknown_02039F24
ldrb r1, [r0]
movs r0, 0x64
muls r0, r1
ldr r1, =gPlayerParty
adds r0, r1
movs r1, 0x32
b _081D9EB4
.pool
_081D9E44:
ldr r4, =gUnknown_02039F31
ldr r0, =gUnknown_02039F24
ldrb r1, [r0]
movs r0, 0x64
muls r0, r1
ldr r1, =gPlayerParty
adds r0, r1
movs r1, 0x33
b _081D9EB4
.pool
_081D9E64:
ldr r4, =gUnknown_02039F31
ldr r0, =gUnknown_02039F24
ldrb r1, [r0]
movs r0, 0x64
muls r0, r1
ldr r1, =gPlayerParty
adds r0, r1
movs r1, 0x34
b _081D9EB4
.pool
_081D9E84:
ldr r4, =gUnknown_02039F31
ldr r0, =gUnknown_02039F24
ldrb r1, [r0]
movs r0, 0x64
muls r0, r1
ldr r1, =gPlayerParty
adds r0, r1
movs r1, 0x35
b _081D9EB4
.pool
_081D9EA4:
ldr r4, =gUnknown_02039F31
ldr r0, =gUnknown_02039F24
ldrb r1, [r0]
movs r0, 0x64
muls r0, r1
ldr r1, =gPlayerParty
adds r0, r1
movs r1, 0x36
_081D9EB4:
bl GetMonData
strb r0, [r4]
ldr r5, =gContestMons
ldr r4, =gContestPlayerMonIndex
ldrb r0, [r4]
lsls r0, 6
adds r0, r5
ldr r1, =gUnknown_02039F31
ldrb r1, [r1]
adds r0, 0x2C
strb r1, [r0]
ldr r0, =0x00000864 @ = FLAG_SYS_GAME_CLEAR
bl FlagGet
lsls r0, 24
lsrs r0, 24
negs r0, r0
lsrs r0, 31
ldrb r1, [r4]
lsls r1, 6
adds r1, r5
adds r1, 0x2D
strb r0, [r1]
ldr r1, =sub_81DA160
ldr r2, =sub_81D9F14
adds r0, r6, 0
bl SetTaskFuncWithFollowupFunc
pop {r4-r6}
pop {r0}
bx r0
.pool
thumb_func_end sub_81D9DE4
thumb_func_start sub_81D9F14
sub_81D9F14: @ 81D9F14
push {lr}
lsls r0, 24
lsrs r0, 24
ldr r1, =sub_81DA244
ldr r2, =sub_81D9F30
bl SetTaskFuncWithFollowupFunc
pop {r0}
bx r0
.pool
thumb_func_end sub_81D9F14
thumb_func_start sub_81D9F30
sub_81D9F30: @ 81D9F30
push {lr}
lsls r0, 24
lsrs r0, 24
ldr r1, =sub_81DA2E8
ldr r2, =sub_81D9F4C
bl SetTaskFuncWithFollowupFunc
pop {r0}
bx r0
.pool
thumb_func_end sub_81D9F30
thumb_func_start sub_81D9F4C
sub_81D9F4C: @ 81D9F4C
push {lr}
lsls r0, 24
lsrs r0, 24
ldr r1, =sub_81DA3B8
ldr r2, =sub_81D9F68
bl SetTaskFuncWithFollowupFunc
pop {r0}
bx r0
.pool
thumb_func_end sub_81D9F4C
thumb_func_start sub_81D9F68
sub_81D9F68: @ 81D9F68
push {r4-r7,lr}
mov r7, r9
mov r6, r8
push {r6,r7}
sub sp, 0x8
lsls r0, 24
lsrs r6, r0, 24
movs r0, 0
str r0, [sp]
str r0, [sp, 0x4]
movs r3, 0
ldr r5, =gUnknown_02039F30
mov r8, r5
ldr r0, =gSpecialVar_0x8004
mov r12, r0
add r1, sp, 0x4
mov r9, r1
ldrb r4, [r5]
cmp r3, r4
bcs _081D9FB2
lsls r0, r6, 2
adds r0, r6
lsls r4, r0, 3
ldr r7, =gTasks + 0x8
_081D9F98:
mov r0, sp
adds r2, r0, r3
adds r1, r3, 0x1
lsls r0, r1, 1
adds r0, r4
adds r0, r7
ldrh r0, [r0]
strb r0, [r2]
lsls r1, 24
lsrs r3, r1, 24
ldrb r1, [r5]
cmp r3, r1
bcc _081D9F98
_081D9FB2:
movs r3, 0
mov r4, r8
ldrb r0, [r4]
cmp r3, r0
bcs _081D9FD6
adds r4, r0, 0
mov r2, sp
_081D9FC0:
adds r0, r3, 0x1
lsls r0, 24
lsrs r3, r0, 24
cmp r3, r4
bcs _081D9FD6
mov r7, sp
adds r1, r7, r3
ldrb r0, [r2]
ldrb r1, [r1]
cmp r0, r1
beq _081D9FC0
_081D9FD6:
mov r0, r8
ldrb r0, [r0]
cmp r3, r0
bne _081D9FF4
movs r0, 0
mov r1, r12
strh r0, [r1]
b _081D9FFA
.pool
_081D9FF4:
movs r0, 0x1
mov r4, r12
strh r0, [r4]
_081D9FFA:
movs r3, 0
mov r7, r8
mov r0, r8
ldrb r0, [r0]
cmp r3, r0
bcs _081DA02A
mov r4, r9
lsls r0, r6, 2
adds r0, r6
lsls r2, r0, 3
ldr r5, =gTasks + 0x8
_081DA010:
adds r1, r4, r3
adds r0, r3, 0x5
lsls r0, 1
adds r0, r2
adds r0, r5
ldrh r0, [r0]
strb r0, [r1]
adds r0, r3, 0x1
lsls r0, 24
lsrs r3, r0, 24
ldrb r1, [r7]
cmp r3, r1
bcc _081DA010
_081DA02A:
mov r4, r8
ldrb r0, [r4]
cmp r0, 0x4
beq _081DA0B8
bl GetMultiplayerId
lsls r0, 24
cmp r0, 0
bne _081DA0B8
ldr r0, =gContestMons
adds r1, r0, 0
adds r1, 0x2C
ldrb r2, [r1]
movs r3, 0x1
ldrb r1, [r4]
adds r5, r0, 0
cmp r3, r1
bcs _081DA06C
adds r4, r5, 0
mov r7, r8
ldrb r1, [r7]
_081DA054:
lsls r0, r3, 6
adds r0, r4
adds r0, 0x2C
ldrb r7, [r0]
cmp r2, r7
bcs _081DA062
ldrb r2, [r0]
_081DA062:
adds r0, r3, 0x1
lsls r0, 24
lsrs r3, r0, 24
cmp r3, r1
bcc _081DA054
_081DA06C:
cmp r2, 0
beq _081DA076
subs r0, r2, 0x1
lsls r0, 24
lsrs r2, r0, 24
_081DA076:
movs r4, 0x1
movs r3, 0
mov r0, r8
ldrb r0, [r0]
cmp r3, r0
bcs _081DA0AC
adds r0, r5, 0
b _081DA0A2
.pool
_081DA090:
adds r0, r3, 0x1
lsls r0, 24
lsrs r3, r0, 24
mov r1, r8
ldrb r1, [r1]
cmp r3, r1
bcs _081DA0AC
lsls r0, r3, 6
adds r0, r5
_081DA0A2:
adds r0, 0x2D
ldrb r0, [r0]
cmp r0, 0
bne _081DA090
movs r4, 0
_081DA0AC:
mov r0, sp
ldrb r0, [r0]
adds r1, r2, 0
adds r2, r4, 0
bl sub_80DACBC
_081DA0B8:
mov r0, r9
bl sub_80F86E0
ldr r1, =gUnknown_02039F2B
strb r0, [r1]
ldr r0, =gUnknown_02039F30
ldrb r0, [r0]
cmp r0, 0x3
bhi _081DA0E8
ldr r1, =sub_81DA488
ldr r2, =sub_81DA10C
adds r0, r6, 0
bl SetTaskFuncWithFollowupFunc
b _081DA0F6
.pool
_081DA0E8:
ldr r0, =gTasks
lsls r1, r6, 2
adds r1, r6
lsls r1, 3
adds r1, r0
ldr r0, =sub_81DA10C
str r0, [r1]
_081DA0F6:
add sp, 0x8
pop {r3,r4}
mov r8, r3
mov r9, r4
pop {r4-r7}
pop {r0}
bx r0
.pool
thumb_func_end sub_81D9F68
thumb_func_start sub_81DA10C
sub_81DA10C: @ 81DA10C
push {r4,lr}
adds r4, r0, 0
lsls r4, 24
lsrs r4, 24
ldr r0, =gSpecialVar_ContestCategory
ldrb r0, [r0]
bl sub_80DB09C
ldr r1, =sub_80FCF40
ldr r2, =sub_81DA138
adds r0, r4, 0
bl SetTaskFuncWithFollowupFunc
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end sub_81DA10C
thumb_func_start sub_81DA138
sub_81DA138: @ 81DA138
push {r4,lr}
adds r4, r0, 0
lsls r4, 24
lsrs r4, 24
movs r0, 0
bl sub_80DCE58
ldr r1, =sub_80FCFD0
ldr r2, =sub_80F8714
adds r0, r4, 0
bl SetTaskFuncWithFollowupFunc
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end sub_81DA138
thumb_func_start sub_81DA160
sub_81DA160: @ 81DA160
push {r4-r7,lr}
mov r7, r8
push {r7}
lsls r0, 24
lsrs r7, r0, 24
lsls r6, r7, 2
adds r0, r6, r7
lsls r4, r0, 3
ldr r5, =gTasks + 0x8
adds r0, r4, r5
adds r0, 0x18
bl sub_80FC670
cmp r0, 0
beq _081DA224
adds r0, r5, 0
subs r0, 0x8
adds r4, r0
movs r1, 0x8
ldrsh r0, [r4, r1]
cmp r0, 0
beq _081DA1A4
cmp r0, 0x1
beq _081DA1D4
movs r0, 0
strh r0, [r4, 0x8]
strh r0, [r4, 0x20]
adds r0, r7, 0
bl SwitchTaskToFollowupFunc
b _081DA224
.pool
_081DA1A4:
bl IsLinkTaskFinished
lsls r0, 24
cmp r0, 0
beq _081DA224
ldr r0, =gContestPlayerMonIndex
ldrb r0, [r0]
lsls r0, 6
ldr r1, =gContestMons
adds r0, r1
movs r1, 0x40
bl sub_80FC4F4
cmp r0, 0x1
bne _081DA224
ldrh r0, [r4, 0x8]
adds r0, 0x1
strh r0, [r4, 0x8]
b _081DA224
.pool
_081DA1D4:
bl sub_80FC55C
lsls r0, 24
cmp r0, 0
beq _081DA224
movs r5, 0
ldr r0, =gUnknown_02039F30
mov r8, r6
ldrb r0, [r0]
cmp r5, r0
bge _081DA214
ldr r6, =gLinkPlayers
_081DA1EC:
lsls r4, r5, 6
ldr r0, =gContestMons
adds r4, r0
lsls r1, r5, 8
ldr r0, =gBlockRecvBuffer
adds r1, r0
adds r0, r4, 0
movs r2, 0x40
bl memcpy
ldrh r1, [r6, 0x1A]
adds r0, r4, 0
bl sub_80DFA08
adds r6, 0x1C
adds r5, 0x1
ldr r0, =gUnknown_02039F30
ldrb r0, [r0]
cmp r5, r0
blt _081DA1EC
_081DA214:
ldr r0, =gTasks
mov r2, r8
adds r1, r2, r7
lsls r1, 3
adds r1, r0
ldrh r0, [r1, 0x8]
adds r0, 0x1
strh r0, [r1, 0x8]
_081DA224:
pop {r3}
mov r8, r3
pop {r4-r7}
pop {r0}
bx r0
.pool
thumb_func_end sub_81DA160
thumb_func_start sub_81DA244
sub_81DA244: @ 81DA244
push {r4-r6,lr}
lsls r0, 24
lsrs r4, r0, 24
lsls r0, r4, 2
adds r0, r4
lsls r5, r0, 3
ldr r6, =gTasks + 0x8
adds r0, r5, r6
adds r0, 0x18
bl sub_80FC670
cmp r0, 0
beq _081DA2D4
adds r0, r6, 0
subs r0, 0x8
adds r5, r0
movs r1, 0x8
ldrsh r0, [r5, r1]
cmp r0, 0
beq _081DA284
cmp r0, 0x1
beq _081DA2AC
movs r0, 0
strh r0, [r5, 0x8]
strh r0, [r5, 0x20]
adds r0, r4, 0
bl SwitchTaskToFollowupFunc
b _081DA2D4
.pool
_081DA284:
bl GetMultiplayerId
lsls r0, 24
cmp r0, 0
bne _081DA2CE
bl IsLinkTaskFinished
lsls r0, 24
cmp r0, 0
beq _081DA2D4
ldr r0, =gRngValue
movs r1, 0x4
bl sub_80FC4F4
cmp r0, 0x1
bne _081DA2D4
b _081DA2CE
.pool
_081DA2AC:
movs r0, 0
bl sub_80FC530
lsls r0, 24
cmp r0, 0
beq _081DA2D4
ldr r0, =gRngValue
ldr r4, =gBlockRecvBuffer
adds r1, r4, 0
movs r2, 0x4
bl memcpy
ldr r0, =gContestRngValue
adds r1, r4, 0
movs r2, 0x4
bl memcpy
_081DA2CE:
ldrh r0, [r5, 0x8]
adds r0, 0x1
strh r0, [r5, 0x8]
_081DA2D4:
pop {r4-r6}
pop {r0}
bx r0
.pool
thumb_func_end sub_81DA244
thumb_func_start sub_81DA2E8
sub_81DA2E8: @ 81DA2E8
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
sub sp, 0xC
lsls r0, 24
lsrs r6, r0, 24
lsls r0, r6, 2
mov r9, r0
adds r0, r6
lsls r5, r0, 3
ldr r1, =gTasks + 0x8
mov r8, r1
adds r0, r5, r1
adds r0, 0x18
bl sub_80FC670
cmp r0, 0
beq _081DA39E
movs r0, 0x8
negs r0, r0
add r0, r8
mov r10, r0
adds r4, r5, r0
movs r1, 0x8
ldrsh r0, [r4, r1]
cmp r0, 0
beq _081DA338
cmp r0, 0x1
beq _081DA35A
movs r0, 0
strh r0, [r4, 0x8]
strh r0, [r4, 0x20]
adds r0, r6, 0
bl SwitchTaskToFollowupFunc
b _081DA39E
.pool
_081DA338:
bl IsLinkTaskFinished
lsls r0, 24
cmp r0, 0
beq _081DA39E
add r0, sp, 0x8
movs r1, 0x6E
strh r1, [r0]
movs r1, 0x2
bl sub_80FC4F4
cmp r0, 0x1
bne _081DA39E
ldrh r0, [r4, 0x8]
adds r0, 0x1
strh r0, [r4, 0x8]
b _081DA39E
_081DA35A:
bl sub_80FC55C
lsls r0, 24
cmp r0, 0
beq _081DA39E
movs r1, 0
ldr r7, =gUnknown_02039F30
ldrb r0, [r7]
cmp r1, r0
bge _081DA390
mov r0, r8
adds r0, 0xA
adds r3, r5, r0
ldr r4, =gBlockRecvBuffer
mov r2, sp
movs r5, 0x80
lsls r5, 1
_081DA37C:
ldrh r0, [r4]
strh r0, [r2]
strh r0, [r3]
adds r3, 0x2
adds r4, r5
adds r2, 0x2
adds r1, 0x1
ldrb r0, [r7]
cmp r1, r0
blt _081DA37C
_081DA390:
mov r0, r9
adds r1, r0, r6
lsls r1, 3
add r1, r10
ldrh r0, [r1, 0x8]
adds r0, 0x1
strh r0, [r1, 0x8]
_081DA39E:
add sp, 0xC
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r0}
bx r0
.pool
thumb_func_end sub_81DA2E8
thumb_func_start sub_81DA3B8
sub_81DA3B8: @ 81DA3B8
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
sub sp, 0xC
lsls r0, 24
lsrs r6, r0, 24
lsls r0, r6, 2
mov r9, r0
adds r0, r6
lsls r5, r0, 3
ldr r1, =gTasks + 0x8
mov r8, r1
adds r0, r5, r1
adds r0, 0x18
bl sub_80FC670
cmp r0, 0
beq _081DA46E
movs r0, 0x8
negs r0, r0
add r0, r8
mov r10, r0
adds r4, r5, r0
movs r1, 0x8
ldrsh r0, [r4, r1]
cmp r0, 0
beq _081DA408
cmp r0, 0x1
beq _081DA42A
movs r0, 0
strh r0, [r4, 0x8]
strh r0, [r4, 0x20]
adds r0, r6, 0
bl SwitchTaskToFollowupFunc
b _081DA46E
.pool
_081DA408:
bl IsLinkTaskFinished
lsls r0, 24
cmp r0, 0
beq _081DA46E
ldrh r1, [r4, 0x1A]
add r0, sp, 0x8
strh r1, [r0]
movs r1, 0x2
bl sub_80FC4F4
cmp r0, 0x1
bne _081DA46E
ldrh r0, [r4, 0x8]
adds r0, 0x1
strh r0, [r4, 0x8]
b _081DA46E
_081DA42A:
bl sub_80FC55C
lsls r0, 24
cmp r0, 0
beq _081DA46E
movs r1, 0
ldr r7, =gUnknown_02039F30
ldrb r0, [r7]
cmp r1, r0
bge _081DA460
mov r0, r8
adds r0, 0x2
adds r3, r5, r0
ldr r4, =gBlockRecvBuffer
mov r2, sp
movs r5, 0x80
lsls r5, 1
_081DA44C:
ldrh r0, [r4]
strh r0, [r2]
strh r0, [r3]
adds r3, 0x2
adds r4, r5
adds r2, 0x2
adds r1, 0x1
ldrb r0, [r7]
cmp r1, r0
blt _081DA44C
_081DA460:
mov r0, r9
adds r1, r0, r6
lsls r1, 3
add r1, r10
ldrh r0, [r1, 0x8]
adds r0, 0x1
strh r0, [r1, 0x8]
_081DA46E:
add sp, 0xC
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r0}
bx r0
.pool
thumb_func_end sub_81DA3B8
thumb_func_start sub_81DA488
sub_81DA488: @ 81DA488
push {r4-r7,lr}
mov r7, r8
push {r7}
lsls r0, 24
lsrs r6, r0, 24
lsls r7, r6, 2
adds r0, r7, r6
lsls r4, r0, 3
ldr r5, =gTasks + 0x8
adds r0, r4, r5
adds r0, 0x18
bl sub_80FC670
cmp r0, 0
beq _081DA55C
adds r0, r5, 0
subs r0, 0x8
adds r4, r0
movs r1, 0x8
ldrsh r0, [r4, r1]
cmp r0, 0
beq _081DA4CC
cmp r0, 0x1
beq _081DA50C
movs r0, 0
strh r0, [r4, 0x8]
strh r0, [r4, 0x20]
adds r0, r6, 0
bl SwitchTaskToFollowupFunc
b _081DA55C
.pool
_081DA4CC:
bl GetMultiplayerId
lsls r0, 24
cmp r0, 0
bne _081DA4FA
bl IsLinkTaskFinished
lsls r0, 24
cmp r0, 0
beq _081DA55C
ldr r0, =gUnknown_02039F30
ldrb r2, [r0]
lsls r0, r2, 6
ldr r1, =gContestMons
adds r0, r1
movs r1, 0x4
subs r1, r2
lsls r1, 22
lsrs r1, 16
bl sub_80FC4F4
cmp r0, 0x1
bne _081DA55C
_081DA4FA:
ldrh r0, [r4, 0x8]
adds r0, 0x1
strh r0, [r4, 0x8]
b _081DA55C
.pool
_081DA50C:
movs r0, 0
bl sub_80FC530
lsls r0, 24
cmp r0, 0
beq _081DA55C
ldr r4, =gUnknown_02039F30
ldrb r3, [r4]
lsls r0, r3, 6
ldr r5, =gContestMons
adds r0, r5
ldr r1, =gBlockRecvBuffer
movs r2, 0x4
subs r2, r3
lsls r2, 6
bl memcpy
ldrb r4, [r4]
mov r8, r7
cmp r4, 0x3
bgt _081DA54C
lsls r0, r4, 6
adds r5, r0, r5
ldr r7, =gLinkPlayers
_081DA53C:
ldrh r1, [r7, 0x1A]
adds r0, r5, 0
bl sub_80DFA08
adds r5, 0x40
adds r4, 0x1
cmp r4, 0x3
ble _081DA53C
_081DA54C:
ldr r0, =gTasks
mov r2, r8
adds r1, r2, r6
lsls r1, 3
adds r1, r0
ldrh r0, [r1, 0x8]
adds r0, 0x1
strh r0, [r1, 0x8]
_081DA55C:
pop {r3}
mov r8, r3
pop {r4-r7}
pop {r0}
bx r0
.pool
thumb_func_end sub_81DA488
.align 2, 0 @ Don't pad with nop.

View File

@ -222,10 +222,12 @@ struct ContestPokemon
}; // wow }; // wow
extern struct ContestPokemon gContestMons[4]; extern struct ContestPokemon gContestMons[4];
extern u8 gUnknown_02039F24; extern u8 gContestMonPartyIndex;
extern u16 gSpecialVar_ContestCategory; extern u16 gSpecialVar_ContestCategory;
extern u16 gSpecialVar_ContestRank; extern u16 gSpecialVar_ContestRank;
extern u8 gUnknown_02039F30; extern u8 gUnknown_02039F2B;
extern u8 gNumLinkContestPlayers;
extern u8 gHighestRibbonRank;
extern u8 gContestFinalStandings[4]; extern u8 gContestFinalStandings[4];
extern u8 gContestPlayerMonIndex; extern u8 gContestPlayerMonIndex;
extern s16 gUnknown_02039F08[4]; extern s16 gUnknown_02039F08[4];
@ -434,5 +436,20 @@ void SetStartledString(u8 a, u8 b);
s8 Contest_GetMoveExcitement(u16); s8 Contest_GetMoveExcitement(u16);
u8 sub_80DAE0C(struct Pokemon *); u8 sub_80DAE0C(struct Pokemon *);
void sub_80DEDA8(u8); void sub_80DEDA8(u8);
void sub_80DACBC(u8 contestType, u8 rank, bool32 isPostgame);
void sub_80DB09C(u8 contestCategory);
void sub_80DCE58(u8);
void sub_80DFA08(struct ContestPokemon *mon, int language);
// contest link
void sub_81D9DE4(u8 taskId);
void sub_80FCF40(u8);
void sub_80FCFD0(u8);
void sub_80F8714(u8);
int sub_80FC670(s16 *);
int sub_80FC4F4(void *, u16);
u8 sub_80FC55C(void);
u8 sub_80FC530(u8);
u8 sub_80F86E0(u8 *);
#endif //GUARD_CONTEST_H #endif //GUARD_CONTEST_H

View File

@ -293,7 +293,7 @@ SECTIONS {
asm/pokenav.o(.text.after.match.call); asm/pokenav.o(.text.after.match.call);
src/rayquaza_scene.o(.text); src/rayquaza_scene.o(.text);
src/walda_phrase.o(.text); src/walda_phrase.o(.text);
asm/contest_link_81D9DE4.o(.text); src/contest_link_81D9DE4.o(.text);
src/gym_leader_rematch.o(.text); src/gym_leader_rematch.o(.text);
src/unk_transition.o(.text); src/unk_transition.o(.text);
src/international_string_util.o(.text); src/international_string_util.o(.text);

View File

@ -176,7 +176,7 @@ EWRAM_DATA s16 gUnknown_02039F08[4] = {0};
EWRAM_DATA s16 gUnknown_02039F10[4] = {0}; EWRAM_DATA s16 gUnknown_02039F10[4] = {0};
EWRAM_DATA s16 gUnknown_02039F18[4] = {0}; EWRAM_DATA s16 gUnknown_02039F18[4] = {0};
EWRAM_DATA u8 gContestFinalStandings[4] = {0}; EWRAM_DATA u8 gContestFinalStandings[4] = {0};
EWRAM_DATA u8 gUnknown_02039F24 = 0; EWRAM_DATA u8 gContestMonPartyIndex = 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 u8 gIsLinkContest = 0; EWRAM_DATA u8 gIsLinkContest = 0;
@ -185,8 +185,8 @@ EWRAM_DATA u8 gIsLinkContest = 0;
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;
EWRAM_DATA u8 gUnknown_02039F30 = 0; EWRAM_DATA u8 gNumLinkContestPlayers = 0;
EWRAM_DATA u8 gUnknown_02039F31 = 0; EWRAM_DATA u8 gHighestRibbonRank = 0;
EWRAM_DATA struct ContestResources * gContestResources = NULL; EWRAM_DATA struct ContestResources * gContestResources = NULL;
EWRAM_DATA u8 sContestBgCopyFlags = 0; EWRAM_DATA u8 sContestBgCopyFlags = 0;
EWRAM_DATA struct ContestWinner gUnknown_02039F3C = {0}; EWRAM_DATA struct ContestWinner gUnknown_02039F3C = {0};
@ -932,9 +932,9 @@ void sub_80D8A88(u8 taskId)
{ {
s32 i; s32 i;
for (i = 0; i + gUnknown_02039F30 < 4; i++) for (i = 0; i + gNumLinkContestPlayers < 4; i++)
{ {
gContestResources->field_4[gUnknown_02039F30 + i].currMove = sub_80DB8B8(gUnknown_02039F30 + i); gContestResources->field_4[gNumLinkContestPlayers + i].currMove = sub_80DB8B8(gNumLinkContestPlayers + i);
} }
} }
gTasks[taskId].data[0] = 0; gTasks[taskId].data[0] = 0;
@ -2110,7 +2110,7 @@ void sub_80DAB8C(u8 contestType, u8 rank)
opponentsCount--; opponentsCount--;
} }
sub_80DA8C8(gUnknown_02039F24); sub_80DA8C8(gContestMonPartyIndex);
} }
#ifdef NONMATCHING #ifdef NONMATCHING
@ -2121,7 +2121,7 @@ void sub_80DACBC(u8 contestType, u8 rank, bool32 isPostgame)
u8 opponents[100]; u8 opponents[100];
const u8 * r6; const u8 * r6;
if (gUnknown_02039F30 == 4) if (gNumLinkContestPlayers == 4)
return; return;
r6 = gUnknown_085898A4; r6 = gUnknown_085898A4;
@ -2151,14 +2151,14 @@ void sub_80DACBC(u8 contestType, u8 rank, bool32 isPostgame)
opponents[opponentsCount++] = i; opponents[opponentsCount++] = i;
} }
opponents[opponentsCount] = 0xFF; opponents[opponentsCount] = 0xFF;
for (i = 0; i < 4 - gUnknown_02039F30; i++) for (i = 0; i < 4 - gNumLinkContestPlayers; i++)
{ {
u16 rnd = sub_80F903C() % opponentsCount; u16 rnd = sub_80F903C() % opponentsCount;
s32 j; s32 j;
gContestMons[gUnknown_02039F30 + i] = gContestOpponents[opponents[rnd]]; gContestMons[gNumLinkContestPlayers + i] = gContestOpponents[opponents[rnd]];
sub_80DF9D4(gContestMons[gUnknown_02039F30 + i].trainerName); sub_80DF9D4(gContestMons[gNumLinkContestPlayers + i].trainerName);
sub_80DF9E0(gContestMons[gUnknown_02039F30 + i].nickname, GAME_LANGUAGE); sub_80DF9E0(gContestMons[gNumLinkContestPlayers + i].nickname, GAME_LANGUAGE);
for (j = rnd; opponents[j] != 0xFF; j++) for (j = rnd; opponents[j] != 0xFF; j++)
opponents[j] = opponents[j + 1]; opponents[j] = opponents[j + 1];
opponentsCount--; opponentsCount--;
@ -2178,7 +2178,7 @@ NAKED void sub_80DACBC(u8 contestType, u8 rank, bool32 isPostgame)
"\tlsls r1, 24\n" "\tlsls r1, 24\n"
"\tlsrs r2, r1, 24\n" "\tlsrs r2, r1, 24\n"
"\tmovs r7, 0\n" "\tmovs r7, 0\n"
"\tldr r0, =gUnknown_02039F30\n" "\tldr r0, =gNumLinkContestPlayers\n"
"\tldrb r1, [r0]\n" "\tldrb r1, [r0]\n"
"\tmov r9, r0\n" "\tmov r9, r0\n"
"\tcmp r1, 0x4\n" "\tcmp r1, 0x4\n"
@ -2471,12 +2471,12 @@ u16 sub_80DAFE0(u8 who, u8 contestCategory)
return statMain + (statSub1 + statSub2 + gContestMons[who].sheen) / 2; return statMain + (statSub1 + statSub2 + gContestMons[who].sheen) / 2;
} }
void sub_80DB09C(u8 a0) void sub_80DB09C(u8 contestCategory)
{ {
s32 i; s32 i;
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
gContestMonConditions[i] = sub_80DAFE0(i, a0); gContestMonConditions[i] = sub_80DAFE0(i, contestCategory);
} }
u8 sub_80DB0C4(void) u8 sub_80DB0C4(void)

333
src/contest_link_81D9DE4.c Executable file
View File

@ -0,0 +1,333 @@
#include "global.h"
#include "contest.h"
#include "event_data.h"
#include "link.h"
#include "pokemon.h"
#include "random.h"
#include "task.h"
#include "constants/flags.h"
static void sub_81D9F14(u8);
static void sub_81D9F30(u8);
static void sub_81D9F4C(u8);
static void sub_81D9F68(u8);
static void sub_81DA10C(u8);
static void sub_81DA138(u8);
static void sub_81DA160(u8);
static void sub_81DA244(u8);
static void sub_81DA2E8(u8);
static void sub_81DA3B8(u8);
static void sub_81DA488(u8);
void sub_81D9DE4(u8 taskId)
{
int gameCleared;
switch (gTasks[taskId].data[9])
{
case 0:
gHighestRibbonRank = GetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_COOL_RIBBON);
break;
case 1:
gHighestRibbonRank = GetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_BEAUTY_RIBBON);
break;
case 2:
gHighestRibbonRank = GetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_CUTE_RIBBON);
break;
case 3:
gHighestRibbonRank = GetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_SMART_RIBBON);
break;
case 4:
default:
gHighestRibbonRank = GetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_TOUGH_RIBBON);
break;
}
gContestMons[gContestPlayerMonIndex].unk2C[0] = gHighestRibbonRank;
gameCleared = FlagGet(FLAG_SYS_GAME_CLEAR) > 0;
gContestMons[gContestPlayerMonIndex].unk2C[1] = gameCleared;
SetTaskFuncWithFollowupFunc(taskId, sub_81DA160, sub_81D9F14);
}
static void sub_81D9F14(u8 taskId)
{
SetTaskFuncWithFollowupFunc(taskId, sub_81DA244, sub_81D9F30);
}
static void sub_81D9F30(u8 taskId)
{
SetTaskFuncWithFollowupFunc(taskId, sub_81DA2E8, sub_81D9F4C);
}
static void sub_81D9F4C(u8 taskId)
{
SetTaskFuncWithFollowupFunc(taskId, sub_81DA3B8, sub_81D9F68);
}
static void sub_81D9F68(u8 taskId)
{
u8 i;
u8 rank;
int gameCleared;
u8 data1[4];
u8 data2[4];
memset(data1, 0, sizeof(data1));
memset(data2, 0, sizeof(data2));
for (i = 0; i < gNumLinkContestPlayers; i++)
data1[i] = gTasks[taskId].data[i + 1];
i = 0;
if (i < gNumLinkContestPlayers)
{
while (++i < gNumLinkContestPlayers)
{
if (data1[0] != data1[i])
break;
}
}
if (i == gNumLinkContestPlayers)
gSpecialVar_0x8004 = 0;
else
gSpecialVar_0x8004 = 1;
for (i = 0; i < gNumLinkContestPlayers; i++)
data2[i] = gTasks[taskId].data[i + 5];
if (gNumLinkContestPlayers != 4 && GetMultiplayerId() == 0)
{
rank = gContestMons[0].unk2C[0];
for (i = 1; i < gNumLinkContestPlayers; i++)
{
if (rank < gContestMons[i].unk2C[0])
rank = gContestMons[i].unk2C[0];
}
if (rank)
rank--;
gameCleared = 1;
for (i = 0; i < gNumLinkContestPlayers; i++)
{
if (!gContestMons[i].unk2C[1])
{
gameCleared = 0;
break;
}
}
sub_80DACBC(data1[0], rank, gameCleared);
}
gUnknown_02039F2B = sub_80F86E0(data2);
if (gNumLinkContestPlayers < 4)
SetTaskFuncWithFollowupFunc(taskId, sub_81DA488, sub_81DA10C);
else
gTasks[taskId].func = sub_81DA10C;
}
static void sub_81DA10C(u8 taskId)
{
sub_80DB09C(gSpecialVar_ContestCategory);
SetTaskFuncWithFollowupFunc(taskId, sub_80FCF40, sub_81DA138);
}
static void sub_81DA138(u8 taskId)
{
sub_80DCE58(0);
SetTaskFuncWithFollowupFunc(taskId, sub_80FCFD0, sub_80F8714);
}
static void sub_81DA160(u8 taskId)
{
int i;
if (!sub_80FC670(&gTasks[taskId].data[12]))
return;
switch (gTasks[taskId].data[0])
{
default:
gTasks[taskId].data[0] = 0;
gTasks[taskId].data[12] = 0;
SwitchTaskToFollowupFunc(taskId);
break;
case 0:
if (IsLinkTaskFinished())
{
if (sub_80FC4F4(&gContestMons[gContestPlayerMonIndex], sizeof(struct ContestPokemon)) == 1)
gTasks[taskId].data[0]++;
}
break;
case 1:
if (sub_80FC55C())
{
for (i = 0; i < gNumLinkContestPlayers; i++)
{
memcpy(&gContestMons[i], gBlockRecvBuffer[i], sizeof(struct ContestPokemon));
sub_80DFA08(&gContestMons[i], gLinkPlayers[i].language);
}
gTasks[taskId].data[0]++;
}
break;
}
}
static void sub_81DA244(u8 taskId)
{
if (!sub_80FC670(&gTasks[taskId].data[12]))
return;
switch (gTasks[taskId].data[0])
{
default:
gTasks[taskId].data[0] = 0;
gTasks[taskId].data[12] = 0;
SwitchTaskToFollowupFunc(taskId);
break;
case 0:
if (GetMultiplayerId() == 0)
{
if (!IsLinkTaskFinished())
return;
if (sub_80FC4F4(&gRngValue, sizeof(gRngValue)) == 1)
gTasks[taskId].data[0]++;
}
else
{
gTasks[taskId].data[0]++;
}
break;
case 1:
if (sub_80FC530(0))
{
memcpy(&gRngValue, gBlockRecvBuffer[0], sizeof(gRngValue));
memcpy(&gContestRngValue, gBlockRecvBuffer[0], sizeof(gContestRngValue));
gTasks[taskId].data[0]++;
}
break;
}
}
static void sub_81DA2E8(u8 taskId)
{
int i;
u16 data[4];
u16 var0;
if (!sub_80FC670(&gTasks[taskId].data[12]))
return;
switch (gTasks[taskId].data[0])
{
default:
gTasks[taskId].data[0] = 0;
gTasks[taskId].data[12] = 0;
SwitchTaskToFollowupFunc(taskId);
break;
case 0:
if (IsLinkTaskFinished())
{
var0 = 0x6E;
if (sub_80FC4F4(&var0, sizeof(var0)) == 1)
gTasks[taskId].data[0]++;
}
break;
case 1:
if (sub_80FC55C())
{
for (i = 0; i < gNumLinkContestPlayers; i++)
{
data[i] = gBlockRecvBuffer[i][0];
gTasks[taskId].data[i + 5] = data[i];
}
gTasks[taskId].data[0]++;
}
break;
}
}
static void sub_81DA3B8(u8 taskId)
{
int i;
u16 data[4];
u16 var0;
if (!sub_80FC670(&gTasks[taskId].data[12]))
return;
switch (gTasks[taskId].data[0])
{
default:
gTasks[taskId].data[0] = 0;
gTasks[taskId].data[12] = 0;
SwitchTaskToFollowupFunc(taskId);
break;
case 0:
if (IsLinkTaskFinished())
{
var0 = gTasks[taskId].data[9];
if (sub_80FC4F4(&var0, sizeof(var0)) == 1)
gTasks[taskId].data[0]++;
}
break;
case 1:
if (sub_80FC55C())
{
for (i = 0; i < gNumLinkContestPlayers; i++)
{
data[i] = gBlockRecvBuffer[i][0];
gTasks[taskId].data[i + 1] = data[i];
}
gTasks[taskId].data[0]++;
}
break;
}
}
static void sub_81DA488(u8 taskId)
{
int i;
if (!sub_80FC670(&gTasks[taskId].data[12]))
return;
switch (gTasks[taskId].data[0])
{
default:
gTasks[taskId].data[0] = 0;
gTasks[taskId].data[12] = 0;
SwitchTaskToFollowupFunc(taskId);
break;
case 0:
if (GetMultiplayerId() == 0)
{
if (!IsLinkTaskFinished())
return;
if (sub_80FC4F4(&gContestMons[gNumLinkContestPlayers], (4 - gNumLinkContestPlayers) * sizeof(struct ContestPokemon)) == 1)
gTasks[taskId].data[0]++;
}
else
{
gTasks[taskId].data[0]++;
}
break;
case 1:
if (sub_80FC530(0))
{
memcpy(&gContestMons[gNumLinkContestPlayers], gBlockRecvBuffer[0], (4 - gNumLinkContestPlayers) * sizeof(struct ContestPokemon));
for (i = gNumLinkContestPlayers; i < 4; i++)
sub_80DFA08(&gContestMons[i], gLinkPlayers[0].language);
gTasks[taskId].data[0]++;
}
break;
}
}

View File

@ -7257,10 +7257,10 @@ static void sub_81B9424(u8 taskId)
static void sub_81B9470(void) static void sub_81B9470(void)
{ {
gUnknown_02039F24 = GetCursorSelectionMonId(); gContestMonPartyIndex = GetCursorSelectionMonId();
if (gUnknown_02039F24 >= PARTY_SIZE) if (gContestMonPartyIndex >= PARTY_SIZE)
gUnknown_02039F24 = 0xFF; gContestMonPartyIndex = 0xFF;
gSpecialVar_0x8004 = gUnknown_02039F24; gSpecialVar_0x8004 = gContestMonPartyIndex;
gFieldCallback2 = hm_add_c3_without_phase_2; gFieldCallback2 = hm_add_c3_without_phase_2;
SetMainCallback2(CB2_ReturnToField); SetMainCallback2(CB2_ReturnToField);
} }

View File

@ -228,7 +228,7 @@ void sub_80F8AFC(void)
if (gIsLinkContest & 1) if (gIsLinkContest & 1)
{ {
for (i = 0; i < gUnknown_02039F30; i++) for (i = 0; i < gNumLinkContestPlayers; i++)
{ {
int version = (u8)gLinkPlayers[i].version; int version = (u8)gLinkPlayers[i].version;
if (version == VERSION_RUBY || version == VERSION_SAPPHIRE) if (version == VERSION_RUBY || version == VERSION_SAPPHIRE)
@ -257,7 +257,7 @@ void sub_80F8B94(void)
gReservedSpritePaletteCount = 12; gReservedSpritePaletteCount = 12;
if (gIsLinkContest & 1) if (gIsLinkContest & 1)
{ {
for (i = 0; i < gUnknown_02039F30; i++) for (i = 0; i < gNumLinkContestPlayers; i++)
{ {
eventObjectId = GetEventObjectIdByLocalIdAndMap(gUnknown_0858D8EC[i], gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup); eventObjectId = GetEventObjectIdByLocalIdAndMap(gUnknown_0858D8EC[i], gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup);
sprite = &gSprites[gEventObjects[eventObjectId].spriteId]; sprite = &gSprites[gEventObjects[eventObjectId].spriteId];
@ -285,14 +285,14 @@ u8 GiveMonArtistRibbon(void)
{ {
u8 hasArtistRibbon; u8 hasArtistRibbon;
hasArtistRibbon = GetMonData(&gPlayerParty[gUnknown_02039F24], MON_DATA_ARTIST_RIBBON); hasArtistRibbon = GetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_ARTIST_RIBBON);
if (!hasArtistRibbon && gContestFinalStandings[gContestPlayerMonIndex] == 0 && gSpecialVar_ContestRank == 3 if (!hasArtistRibbon && gContestFinalStandings[gContestPlayerMonIndex] == 0 && gSpecialVar_ContestRank == 3
&& gUnknown_02039F08[gContestPlayerMonIndex] >= 800) && gUnknown_02039F08[gContestPlayerMonIndex] >= 800)
{ {
hasArtistRibbon = 1; hasArtistRibbon = 1;
SetMonData(&gPlayerParty[gUnknown_02039F24], MON_DATA_ARTIST_RIBBON, &hasArtistRibbon); SetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_ARTIST_RIBBON, &hasArtistRibbon);
if (GetRibbonCount(&gPlayerParty[gUnknown_02039F24]) > 4) if (GetRibbonCount(&gPlayerParty[gContestMonPartyIndex]) > 4)
sub_80EE4DC(&gPlayerParty[gUnknown_02039F24], MON_DATA_ARTIST_RIBBON); sub_80EE4DC(&gPlayerParty[gContestMonPartyIndex], MON_DATA_ARTIST_RIBBON);
return 1; return 1;
} }
@ -402,7 +402,7 @@ static void sub_80F8EE8(u8 taskId)
void ScriptGetMultiplayerId(void) void ScriptGetMultiplayerId(void)
{ {
if ((gIsLinkContest & 1) && gUnknown_02039F30 == 4 && !(gIsLinkContest & 2)) if ((gIsLinkContest & 1) && gNumLinkContestPlayers == 4 && !(gIsLinkContest & 2))
gSpecialVar_Result = GetMultiplayerId(); gSpecialVar_Result = GetMultiplayerId();
else else
gSpecialVar_Result = 4; gSpecialVar_Result = 4;

View File

@ -1262,7 +1262,7 @@ static void InterviewAfter_ContestLiveUpdates(void)
show2->contestLiveUpdates.active = TRUE; show2->contestLiveUpdates.active = TRUE;
StringCopy(show2->contestLiveUpdates.playerName, gSaveBlock2Ptr->playerName); StringCopy(show2->contestLiveUpdates.playerName, gSaveBlock2Ptr->playerName);
show2->contestLiveUpdates.category = gSpecialVar_ContestCategory; show2->contestLiveUpdates.category = gSpecialVar_ContestCategory;
show2->contestLiveUpdates.species = GetMonData(&gPlayerParty[gUnknown_02039F24], MON_DATA_SPECIES, NULL); show2->contestLiveUpdates.species = GetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_SPECIES, NULL);
show2->contestLiveUpdates.winningSpecies = show->contestLiveUpdates.winningSpecies; show2->contestLiveUpdates.winningSpecies = show->contestLiveUpdates.winningSpecies;
show2->contestLiveUpdates.appealFlags2 = show->contestLiveUpdates.appealFlags2; show2->contestLiveUpdates.appealFlags2 = show->contestLiveUpdates.appealFlags2;
show2->contestLiveUpdates.round1Rank = show->contestLiveUpdates.round1Rank; show2->contestLiveUpdates.round1Rank = show->contestLiveUpdates.round1Rank;
@ -1453,7 +1453,7 @@ void ContestLiveUpdates_BeforeInterview_5(u8 a0, u8 a1)
StringCopy(show->contestLiveUpdates.winningTrainerName, gContestMons[a1].trainerName); StringCopy(show->contestLiveUpdates.winningTrainerName, gContestMons[a1].trainerName);
StripExtCtrlCodes(show->contestLiveUpdates.winningTrainerName); StripExtCtrlCodes(show->contestLiveUpdates.winningTrainerName);
show->contestLiveUpdates.appealFlags2 = a0; show->contestLiveUpdates.appealFlags2 = a0;
if (a1 + 1 > gUnknown_02039F30) if (a1 + 1 > gNumLinkContestPlayers)
{ {
show->contestLiveUpdates.winningTrainerLanguage = gLinkPlayers[0].language; show->contestLiveUpdates.winningTrainerLanguage = gLinkPlayers[0].language;
} }
@ -1527,10 +1527,10 @@ void BravoTrainerPokemonProfile_BeforeInterview2(u8 a0)
show->bravoTrainer.contestResult = a0; show->bravoTrainer.contestResult = a0;
show->bravoTrainer.contestCategory = gSpecialVar_ContestCategory; show->bravoTrainer.contestCategory = gSpecialVar_ContestCategory;
show->bravoTrainer.contestRank = gSpecialVar_ContestRank; show->bravoTrainer.contestRank = gSpecialVar_ContestRank;
show->bravoTrainer.species = GetMonData(&gPlayerParty[gUnknown_02039F24], MON_DATA_SPECIES, NULL); show->bravoTrainer.species = GetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_SPECIES, NULL);
GetMonData(&gPlayerParty[gUnknown_02039F24], MON_DATA_NICKNAME, show->bravoTrainer.pokemonNickname); GetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_NICKNAME, show->bravoTrainer.pokemonNickname);
StripExtCtrlCodes(show->bravoTrainer.pokemonNickname); StripExtCtrlCodes(show->bravoTrainer.pokemonNickname);
show->bravoTrainer.pokemonNameLanguage = GetMonData(&gPlayerParty[gUnknown_02039F24], MON_DATA_LANGUAGE); show->bravoTrainer.pokemonNameLanguage = GetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_LANGUAGE);
} }
} }