More battle dome

This commit is contained in:
DizzyEggg 2018-08-21 23:36:59 +02:00
parent a12b69eae1
commit dea1de3fed
2 changed files with 177 additions and 527 deletions

View File

@ -5,525 +5,7 @@
.text
thumb_func_start sub_81938A4
sub_81938A4: @ 81938A4
push {lr}
ldr r0, =sub_8194220
movs r1, 0
bl CreateTask
lsls r0, 24
lsrs r0, 24
ldr r2, =gTasks
lsls r1, r0, 2
adds r1, r0
lsls r1, 3
adds r1, r2
movs r2, 0
strh r2, [r1, 0x8]
strh r2, [r1, 0xA]
movs r0, 0x2
strh r0, [r1, 0xC]
strh r2, [r1, 0x10]
ldr r0, =sub_8194B54
bl SetMainCallback2
pop {r0}
bx r0
.pool
thumb_func_end sub_81938A4
thumb_func_start sub_81938E0
sub_81938E0: @ 81938E0
push {r4,lr}
bl sub_8194D48
ldr r4, =gSaveBlock2Ptr
ldr r2, [r4]
ldr r1, =0x00000d0a
adds r0, r2, r1
ldrb r1, [r0]
subs r1, 0x1
ldr r0, =0x00000ca9
adds r2, r0
movs r0, 0x3
ands r1, r0
ldrb r3, [r2]
movs r0, 0x4
negs r0, r0
ands r0, r3
orrs r0, r1
strb r0, [r2]
ldr r0, [r4]
ldr r1, =0x00000cb2
adds r0, r1
movs r4, 0
movs r1, 0x3
strh r1, [r0]
ldr r0, =sub_8194220
movs r1, 0
bl CreateTask
lsls r0, 24
lsrs r0, 24
ldr r2, =gTasks
lsls r1, r0, 2
adds r1, r0
lsls r1, 3
adds r1, r2
strh r4, [r1, 0x8]
strh r4, [r1, 0xA]
movs r0, 0x2
strh r0, [r1, 0xC]
movs r0, 0x1
strh r0, [r1, 0x10]
ldr r0, =sub_8194B54
bl SetMainCallback2
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end sub_81938E0
thumb_func_start sub_819395C
sub_819395C: @ 819395C
push {r4-r7,lr}
sub sp, 0x4
lsls r0, 24
lsrs r5, r0, 24
ldr r1, =gTasks
lsls r0, r5, 2
adds r0, r5
lsls r0, 3
adds r0, r1
movs r2, 0xA
ldrsh r7, [r0, r2]
movs r2, 0x8
ldrsh r0, [r0, r2]
adds r2, r1, 0
cmp r0, 0x7
bls _0819397E
b _08193BC2
_0819397E:
lsls r0, 2
ldr r1, =_08193990
adds r0, r1
ldr r0, [r0]
mov pc, r0
.pool
.align 2, 0
_08193990:
.4byte _081939B0
.4byte _08193A00
.4byte _08193A20
.4byte _08193AA8
.4byte _08193BC2
.4byte _08193B20
.4byte _08193BC2
.4byte _08193B84
_081939B0:
ldr r0, =gPaletteFade
ldrb r1, [r0, 0x7]
movs r0, 0x80
ands r0, r1
lsls r0, 24
lsrs r1, r0, 24
cmp r1, 0
beq _081939C2
b _08193BC2
_081939C2:
movs r0, 0x1
negs r0, r0
str r1, [sp]
movs r1, 0
movs r2, 0x10
movs r3, 0
bl BeginNormalPaletteFade
ldr r1, =gTasks
lsls r0, r5, 2
adds r0, r5
lsls r0, 3
adds r0, r1
movs r1, 0x1
strh r1, [r0, 0x8]
lsls r0, r7, 4
adds r0, r7
lsls r0, 2
ldr r1, =gSprites
adds r0, r1
movs r1, 0x1
bl StartSpriteAnim
b _08193BC2
.pool
_08193A00:
ldr r0, =gPaletteFade
ldrb r1, [r0, 0x7]
movs r0, 0x80
ands r0, r1
cmp r0, 0
beq _08193A0E
b _08193BC2
_08193A0E:
lsls r0, r5, 2
adds r0, r5
lsls r0, 3
adds r0, r2
movs r1, 0x2
strh r1, [r0, 0x8]
b _08193BC2
.pool
_08193A20:
adds r0, r5, 0
bl sub_8193BDC
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
bne _08193A30
b _08193BC2
_08193A30:
cmp r0, 0x1
ble _08193A3C
cmp r0, 0x2
beq _08193A60
cmp r0, 0x3
beq _08193A84
_08193A3C:
movs r0, 0x1
negs r0, r0
movs r1, 0
str r1, [sp]
movs r2, 0
movs r3, 0x10
bl BeginNormalPaletteFade
ldr r1, =gTasks
lsls r0, r5, 2
adds r0, r5
lsls r0, 3
adds r0, r1
movs r1, 0x7
strh r1, [r0, 0x8]
b _08193BC2
.pool
_08193A60:
movs r0, 0x1
negs r0, r0
movs r1, 0
str r1, [sp]
movs r2, 0
movs r3, 0x10
bl BeginNormalPaletteFade
ldr r1, =gTasks
lsls r0, r5, 2
adds r0, r5
lsls r0, 3
adds r0, r1
movs r1, 0x3
strh r1, [r0, 0x8]
b _08193BC2
.pool
_08193A84:
movs r0, 0x1
negs r0, r0
movs r1, 0
str r1, [sp]
movs r2, 0
movs r3, 0x10
bl BeginNormalPaletteFade
ldr r1, =gTasks
lsls r0, r5, 2
adds r0, r5
lsls r0, 3
adds r0, r1
movs r1, 0x5
strh r1, [r0, 0x8]
b _08193BC2
.pool
_08193AA8:
ldr r0, =gPaletteFade
ldrb r1, [r0, 0x7]
movs r0, 0x80
ands r0, r1
lsls r0, 24
lsrs r6, r0, 24
cmp r6, 0
beq _08193ABA
b _08193BC2
_08193ABA:
bl FreeAllWindowBuffers
bl ScanlineEffect_Stop
ldr r4, =gUnknown_0203CD7C
ldr r0, [r4]
bl Free
str r6, [r4]
ldr r0, =sub_8190400
movs r1, 0
bl CreateTask
lsls r0, 24
lsrs r3, r0, 24
ldr r2, =gTasks
lsls r1, r3, 2
adds r1, r3
lsls r1, 3
adds r1, r2
movs r3, 0
strh r6, [r1, 0x8]
ldr r0, =gUnknown_0860D080
adds r0, r7, r0
ldrb r0, [r0]
strh r0, [r1, 0xA]
movs r0, 0x1
strh r0, [r1, 0xC]
strh r5, [r1, 0xE]
lsls r0, r5, 2
adds r0, r5
lsls r0, 3
adds r0, r2
movs r1, 0x4
strh r1, [r0, 0x8]
ldr r0, =gUnknown_0203CD78
ldr r0, [r0]
strb r3, [r0, 0x10]
b _08193BC2
.pool
_08193B20:
ldr r0, =gPaletteFade
ldrb r1, [r0, 0x7]
movs r0, 0x80
ands r0, r1
lsls r0, 24
lsrs r6, r0, 24
cmp r6, 0
bne _08193BC2
bl FreeAllWindowBuffers
bl ScanlineEffect_Stop
ldr r4, =gUnknown_0203CD7C
ldr r0, [r4]
bl Free
str r6, [r4]
ldr r0, =sub_8190400
movs r1, 0
bl CreateTask
lsls r0, 24
lsrs r3, r0, 24
ldr r2, =gTasks
lsls r0, r3, 2
adds r0, r3
lsls r0, 3
adds r0, r2
strh r6, [r0, 0x8]
adds r1, r7, 0
subs r1, 0x10
strh r1, [r0, 0xA]
movs r1, 0x2
strh r1, [r0, 0xC]
strh r5, [r0, 0xE]
lsls r0, r5, 2
adds r0, r5
lsls r0, 3
adds r0, r2
movs r1, 0x6
strh r1, [r0, 0x8]
b _08193BC2
.pool
_08193B84:
ldr r0, =gPaletteFade
ldrb r1, [r0, 0x7]
movs r0, 0x80
ands r0, r1
lsls r0, 24
lsrs r6, r0, 24
cmp r6, 0
bne _08193BC2
bl FreeAllWindowBuffers
bl ScanlineEffect_Stop
ldr r4, =gUnknown_0203CD7C
ldr r0, [r4]
bl Free
str r6, [r4]
ldr r0, =CB2_ReturnToFieldContinueScriptPlayMapMusic
bl SetMainCallback2
ldr r1, =gTasks
lsls r0, r5, 2
adds r0, r5
lsls r0, 3
adds r0, r1
ldrb r0, [r0, 0x16]
bl DestroyTask
adds r0, r5, 0
bl DestroyTask
_08193BC2:
add sp, 0x4
pop {r4-r7}
pop {r0}
bx r0
.pool
thumb_func_end sub_819395C
thumb_func_start sub_8193BDC
sub_8193BDC: @ 8193BDC
push {r4-r7,lr}
mov r7, r9
mov r6, r8
push {r6,r7}
lsls r0, 24
lsrs r7, r0, 24
movs r0, 0x1
mov r9, r0
movs r1, 0x4
mov r8, r1
ldr r1, =gTasks
lsls r0, r7, 2
adds r0, r7
lsls r0, 3
adds r0, r1
movs r1, 0xA
ldrsh r5, [r0, r1]
ldr r0, =gSaveBlock2Ptr
ldr r0, [r0]
ldr r1, =0x00000cb2
adds r0, r1
ldrh r6, [r0]
ldr r0, =gMain
ldrh r1, [r0, 0x2E]
adds r2, r1, 0
adds r3, r0, 0
cmp r2, 0x2
beq _08193C20
mov r0, r9
ands r0, r1
cmp r0, 0
beq _08193C58
cmp r5, 0x1F
bne _08193C3C
_08193C20:
movs r0, 0x5
bl PlaySE
movs r0, 0
mov r9, r0
b _08193CDE
.pool
_08193C3C:
cmp r5, 0xF
bgt _08193C4C
movs r0, 0x5
bl PlaySE
movs r1, 0x2
mov r9, r1
b _08193CDE
_08193C4C:
movs r0, 0x5
bl PlaySE
movs r0, 0x3
mov r9, r0
b _08193CDE
_08193C58:
cmp r2, 0x40
bne _08193C78
ldr r0, =gUnknown_0860CBF1
lsls r1, r5, 2
adds r1, r5
adds r1, r6
lsls r1, 2
adds r1, r0
ldrb r0, [r1]
cmp r0, 0xFF
beq _08193C78
movs r1, 0
mov r8, r1
b _08193CDE
.pool
_08193C78:
ldrh r0, [r3, 0x2E]
cmp r0, 0x80
bne _08193C9C
ldr r0, =gUnknown_0860CBF1
lsls r1, r5, 2
adds r1, r5
adds r1, r6
lsls r1, 2
adds r0, 0x1
adds r1, r0
ldrb r0, [r1]
cmp r0, 0xFF
beq _08193C9C
movs r0, 0x1
b _08193CDC
.pool
_08193C9C:
ldrh r0, [r3, 0x2E]
cmp r0, 0x20
bne _08193CC0
ldr r0, =gUnknown_0860CBF1
lsls r1, r5, 2
adds r1, r5
adds r1, r6
lsls r1, 2
adds r0, 0x2
adds r1, r0
ldrb r0, [r1]
cmp r0, 0xFF
beq _08193CC0
movs r1, 0x2
mov r8, r1
b _08193CDE
.pool
_08193CC0:
ldrh r0, [r3, 0x2E]
cmp r0, 0x10
bne _08193CDE
ldr r0, =gUnknown_0860CBF1
lsls r1, r5, 2
adds r1, r5
adds r1, r6
lsls r1, 2
adds r0, 0x3
adds r1, r0
ldrb r0, [r1]
cmp r0, 0xFF
beq _08193CDE
movs r0, 0x3
_08193CDC:
mov r8, r0
_08193CDE:
mov r1, r8
cmp r1, 0x4
beq _08193D26
movs r0, 0x5
bl PlaySE
lsls r0, r5, 4
adds r0, r5
lsls r0, 2
ldr r4, =gSprites
adds r0, r4
movs r1, 0
bl StartSpriteAnim
ldr r2, =gUnknown_0860CBF1
lsls r1, r6, 2
add r1, r8
lsls r0, r5, 2
adds r0, r5
lsls r0, 2
adds r1, r0
adds r1, r2
ldrb r5, [r1]
lsls r0, r5, 4
adds r0, r5
lsls r0, 2
adds r0, r4
movs r1, 0x1
bl StartSpriteAnim
ldr r1, =gTasks
lsls r0, r7, 2
adds r0, r7
lsls r0, 3
adds r0, r1
strh r5, [r0, 0xA]
_08193D26:
mov r0, r9
pop {r3,r4}
mov r8, r3
mov r9, r4
pop {r4-r7}
pop {r1}
bx r1
.pool
thumb_func_end sub_8193BDC
thumb_func_start sub_8193D40
sub_8193D40: @ 8193D40

View File

@ -23,6 +23,7 @@
#include "data2.h"
#include "international_string_util.h"
#include "trainer_pokemon_sprites.h"
#include "scanline_effect.h"
#include "constants/species.h"
#include "constants/moves.h"
#include "constants/trainers.h"
@ -80,6 +81,7 @@ extern u16 gBattle_BG3_X;
extern u16 gBattle_BG3_Y;
extern struct Unknown_0203BC8C_Struct *gFacilityTrainerMons;
extern struct Unknown_0203CD78_Struct *gUnknown_0203CD78;
extern void *gUnknown_0203CD7C;
extern void (* const gUnknown_0860D090[])(void);
extern const u32 gUnknown_0860D0EC[][2];
@ -109,6 +111,8 @@ extern const u8 gUnknown_0860D3A8[];
extern const u8 gUnknown_0860D3AB[];
extern const u8 gUnknown_0860D3AE[];
extern const u8 gUnknown_0860D3B1[];
extern const u8 gUnknown_0860D080[];
extern const u8 gUnknown_0860CBF1[][5][4];
extern const u8 *const gBattleDomePotentialPointers[];
extern const u8 *const gBattleDomeOpponentStylePointers[];
extern const u8 *const gBattleDomeOpponentStatsPointers[];
@ -144,7 +148,7 @@ void sub_8190CD4(u8 taskId);
void sub_8194220(u8 taskId);
void sub_8194B54(void);
void sub_8194B70(void);
static void DrawMatchInfoOnCard(u8 flags, u8 matchNo);
static void DisplayMatchInfoOnCard(u8 flags, u8 matchNo);
static void DisplayTrainerInfoOnCard(u8 flags, u8 trainerTournamentId);
u8 sub_819221C(u8 taskId);
s32 sub_8192F08(u8, u8*);
@ -152,6 +156,8 @@ u8 GetDomeBrainTrainerPicId(void);
u8 GetDomeBrainTrainerClass(void);
void CopyDomeBrainTrainerName(u8 *dst);
void CopyDomeOpponentName(u8 *dst, u16 trainerId);
void sub_8194D48(void);
u8 sub_8193BDC(u8 taskId);
// const rom data
ALIGNED(4)
@ -1701,7 +1707,7 @@ void sub_8190400(u8 taskId)
gTasks[i].data[4] = r7;
if (r9 == 2)
{
DrawMatchInfoOnCard(0, r5);
DisplayMatchInfoOnCard(0, r5);
gUnknown_0203CD78->unk_10 = 1;
}
else
@ -2127,7 +2133,7 @@ void sub_8190CD4(u8 taskId)
gBattle_BG2_X = 256;
gBattle_BG2_Y = 160;
matchNo = gTasks[taskId2].data[1] - 16;
DrawMatchInfoOnCard(gTasks[taskId].data[2] | 0x10, matchNo);
DisplayMatchInfoOnCard(gTasks[taskId].data[2] | 0x10, matchNo);
}
}
@ -2243,7 +2249,7 @@ void sub_8190CD4(u8 taskId)
gBattle_BG2_X = 256;
gBattle_BG2_Y = 0;
matchNo = gTasks[taskId2].data[1] - 16;
DrawMatchInfoOnCard(gTasks[taskId].data[2] | 4, matchNo);
DisplayMatchInfoOnCard(gTasks[taskId].data[2] | 4, matchNo);
}
}
@ -2327,7 +2333,7 @@ void sub_8190CD4(u8 taskId)
gBattle_BG2_X = 256;
gBattle_BG2_Y = 0;
matchNo = gUnknown_0860D15C[(gTasks[taskId2].data[1] * 4) + (gUnknown_0203CD78->unk_10 - 1)];
DrawMatchInfoOnCard(gTasks[taskId].data[2] | 8, matchNo);
DisplayMatchInfoOnCard(gTasks[taskId].data[2] | 8, matchNo);
}
for (i = 0; i < DOME_TOURNAMENT_TRAINERS_COUNT / 2; i++)
@ -2410,7 +2416,7 @@ void sub_8190CD4(u8 taskId)
gBattle_BG2_X = 0;
gBattle_BG2_Y = 160;
matchNo = gTasks[taskId2].data[1] - 16;
DrawMatchInfoOnCard(gTasks[taskId].data[2] | 8, matchNo);
DisplayMatchInfoOnCard(gTasks[taskId].data[2] | 8, matchNo);
}
for (i = 0; i < DOME_TOURNAMENT_TRAINERS_COUNT / 2; i++)
@ -2492,7 +2498,7 @@ void sub_8190CD4(u8 taskId)
gBattle_BG2_Y = 0;
}
matchNo = gUnknown_0860D15C[(gUnknown_0203CD78->unk_10 - 1) + (gTasks[taskId2].data[1] * 4)];
DrawMatchInfoOnCard(gTasks[taskId].data[2] | 2, matchNo);
DisplayMatchInfoOnCard(gTasks[taskId].data[2] | 2, matchNo);
for (i = 0; i < DOME_TOURNAMENT_TRAINERS_COUNT / 2; i++)
{
@ -2574,7 +2580,7 @@ void sub_8190CD4(u8 taskId)
gBattle_BG2_X = 0;
gBattle_BG2_Y = 160;
matchNo = gTasks[taskId2].data[1] - 16;
DrawMatchInfoOnCard(gTasks[taskId].data[2] | 2, matchNo);
DisplayMatchInfoOnCard(gTasks[taskId].data[2] | 2, matchNo);
}
for (i = 0; i < DOME_TOURNAMENT_TRAINERS_COUNT / 2; i++)
@ -3264,7 +3270,7 @@ s32 sub_8192F08(u8 arg0, u8 *arg1)
return retVal + 1;
}
static void DrawMatchInfoOnCard(u8 flags, u8 matchNo)
static void DisplayMatchInfoOnCard(u8 flags, u8 matchNo)
{
struct TextSubPrinter textPrinter;
s32 tournamentIds[2];
@ -3472,3 +3478,165 @@ static void DrawMatchInfoOnCard(u8 flags, u8 matchNo)
CopyWindowToVram(windowId + 5, 3);
AddTextPrinter(&textPrinter, 0, NULL);
}
void sub_81938A4(void)
{
u8 taskId = CreateTask(sub_8194220, 0);
gTasks[taskId].data[0] = 0;
gTasks[taskId].data[1] = 0;
gTasks[taskId].data[2] = 2;
gTasks[taskId].data[4] = 0;
SetMainCallback2(sub_8194B54);
}
void sub_81938E0(void)
{
u8 taskId;
sub_8194D48();
gSaveBlock2Ptr->frontier.chosenLvl = gSaveBlock2Ptr->frontier.field_D0A - 1;
gSaveBlock2Ptr->frontier.field_CB2 = 3;
taskId = CreateTask(sub_8194220, 0);
gTasks[taskId].data[0] = 0;
gTasks[taskId].data[1] = 0;
gTasks[taskId].data[2] = 2;
gTasks[taskId].data[4] = 1;
SetMainCallback2(sub_8194B54);
}
void sub_819395C(u8 taskId)
{
u8 newTaskId = 0;
s32 spriteId = gTasks[taskId].data[1];
switch (gTasks[taskId].data[0])
{
case 0:
if (!gPaletteFade.active)
{
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, 0);
gTasks[taskId].data[0] = 1;
StartSpriteAnim(&gSprites[spriteId], 1);
}
break;
case 1:
if (!gPaletteFade.active)
gTasks[taskId].data[0] = 2;
break;
case 2:
switch (sub_8193BDC(taskId))
{
case 0:
default:
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0);
gTasks[taskId].data[0] = 7;
break;
case 1:
break;
case 2:
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0);
gTasks[taskId].data[0] = 3;
break;
case 3:
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0);
gTasks[taskId].data[0] = 5;
break;
}
break;
case 3:
if (!gPaletteFade.active)
{
FreeAllWindowBuffers();
ScanlineEffect_Stop();
FREE_AND_SET_NULL(gUnknown_0203CD7C);
newTaskId = CreateTask(sub_8190400, 0);
gTasks[newTaskId].data[0] = 0;
gTasks[newTaskId].data[1] = gUnknown_0860D080[spriteId];
gTasks[newTaskId].data[2] = 1;
gTasks[newTaskId].data[3] = taskId;
gTasks[taskId].data[0] = 4;
gUnknown_0203CD78->unk_10 = 0;
}
break;
case 4:
break;
case 5:
if (!gPaletteFade.active)
{
FreeAllWindowBuffers();
ScanlineEffect_Stop();
FREE_AND_SET_NULL(gUnknown_0203CD7C);
newTaskId = CreateTask(sub_8190400, 0);
gTasks[newTaskId].data[0] = 0;
gTasks[newTaskId].data[1] = spriteId - 16;
gTasks[newTaskId].data[2] = 2;
gTasks[newTaskId].data[3] = taskId;
gTasks[taskId].data[0] = 6;
}
break;
case 6:
break;
case 7:
if (!gPaletteFade.active)
{
FreeAllWindowBuffers();
ScanlineEffect_Stop();
FREE_AND_SET_NULL(gUnknown_0203CD7C);
SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic);
DestroyTask(gTasks[taskId].data[7]);
DestroyTask(taskId);
}
break;
}
}
u8 sub_8193BDC(u8 taskId)
{
u8 retVal = 1;
s32 arrId = 4;
s32 spriteId = gTasks[taskId].data[1];
s32 roundId = gSaveBlock2Ptr->frontier.field_CB2;
if (gMain.newKeys == B_BUTTON || (gMain.newKeys & A_BUTTON && spriteId == 31))
{
PlaySE(SE_SELECT);
retVal = 0;
}
else if (gMain.newKeys & A_BUTTON)
{
if (spriteId < 16)
{
PlaySE(SE_SELECT);
retVal = 2;
}
else
{
PlaySE(SE_SELECT);
retVal = 3;
}
}
else
{
if (gMain.newKeys == DPAD_UP && gUnknown_0860CBF1[spriteId][roundId][0] != 0xFF)
arrId = 0;
else if (gMain.newKeys == DPAD_DOWN && gUnknown_0860CBF1[spriteId][roundId][1] != 0xFF)
arrId = 1;
else if (gMain.newKeys == DPAD_LEFT && gUnknown_0860CBF1[spriteId][roundId][2] != 0xFF)
arrId = 2;
else if (gMain.newKeys == DPAD_RIGHT && gUnknown_0860CBF1[spriteId][roundId][3] != 0xFF)
arrId = 3;
}
if (arrId != 4)
{
PlaySE(SE_SELECT);
StartSpriteAnim(&gSprites[spriteId], 0);
spriteId = gUnknown_0860CBF1[spriteId][roundId][arrId];
StartSpriteAnim(&gSprites[spriteId], 1);
gTasks[taskId].data[1] = spriteId;
}
return retVal;
}