2018-08-15 15:49:50 +02:00
# include "global.h"
# include "battle.h"
# include "battle_setup.h"
# include "battle_frontier_1.h"
2018-08-15 23:04:46 +02:00
# include "battle_message.h"
2018-08-15 15:49:50 +02:00
# include "event_data.h"
# include "overworld.h"
# include "util.h"
# include "malloc.h"
2018-08-15 23:04:46 +02:00
# include "string_util.h"
# include "random.h"
2018-08-18 00:54:18 +02:00
# include "task.h"
# include "main.h"
# include "gpu_regs.h"
# include "text.h"
# include "bg.h"
# include "window.h"
# include "palette.h"
# include "decompress.h"
# include "menu.h"
2018-08-18 19:52:25 +02:00
# include "sound.h"
2018-08-18 00:54:18 +02:00
# include "pokemon_icon.h"
2018-08-19 17:13:05 +02:00
# include "data2.h"
# include "international_string_util.h"
2018-08-19 01:06:10 +02:00
# include "trainer_pokemon_sprites.h"
2018-08-21 23:36:59 +02:00
# include "scanline_effect.h"
2018-08-15 15:49:50 +02:00
# include "constants/species.h"
2018-08-15 23:04:46 +02:00
# include "constants/moves.h"
# include "constants/trainers.h"
# include "constants/abilities.h"
2018-08-18 19:52:25 +02:00
# include "constants/songs.h"
# define DOME_ROUND1 0
# define DOME_ROUND2 1
# define DOME_QUARTERFINAL 1 // Different name for the same round.
# define DOME_SEMIFINAL 2
# define DOME_FINAL 3
2018-08-25 11:55:16 +02:00
# define DOME_ROUNDS_COUNT 4
2018-08-15 15:49:50 +02:00
struct Unknown_0203BC8C_Struct
{
2018-08-15 23:04:46 +02:00
u16 species ;
u16 moves [ 4 ] ;
u8 itemTableId ;
u8 evSpread ;
u8 nature ;
2018-08-15 15:49:50 +02:00
} ;
2018-08-18 00:54:18 +02:00
struct Unknown_0203CD78_Struct
{
u8 arr [ 16 ] ;
2018-08-18 18:23:40 +02:00
u8 unk_10 ;
u8 unk_11 [ 3 ] ;
2018-08-18 00:54:18 +02:00
} ;
2018-08-15 15:49:50 +02:00
extern void sub_81B8558 ( void ) ;
extern u32 sub_81A39C4 ( void ) ;
extern u16 sub_8162548 ( u8 , u8 ) ;
2018-08-18 18:23:40 +02:00
extern u16 RandomizeFacilityTrainerMonId ( u16 ) ;
2018-08-15 23:04:46 +02:00
extern u8 GetFrontierEnemyMonLevel ( void ) ;
2018-08-25 11:55:16 +02:00
extern void CopyDomeTrainerName ( u8 * dst , u16 trainerId ) ;
extern u16 sub_81A5060 ( u8 monId , u8 moveSlotId ) ;
2018-08-19 17:13:05 +02:00
extern u8 sub_81A50F0 ( u8 , u8 ) ;
extern u8 sub_81A50B0 ( u8 ) ;
2018-08-18 00:54:18 +02:00
extern void sub_8162614 ( u16 , u8 ) ;
extern void sub_81A4C30 ( void ) ;
2018-08-18 18:23:40 +02:00
extern bool8 sub_81A3610 ( void ) ;
extern u16 sub_81A4FF0 ( u8 ) ;
2018-08-19 17:13:05 +02:00
extern u8 GetFrontierTrainerFrontSpriteId ( u16 ) ;
extern u8 GetFrontierOpponentClass ( u16 ) ;
2018-08-15 15:49:50 +02:00
extern u8 gUnknown_0203CEF8 [ ] ;
2018-08-15 23:04:46 +02:00
extern u32 gUnknown_0203CD70 ;
extern u32 gUnknown_0203CD74 ;
2018-08-18 00:54:18 +02:00
extern u16 gBattle_BG0_X ;
extern u16 gBattle_BG0_Y ;
extern u16 gBattle_BG1_X ;
extern u16 gBattle_BG1_Y ;
extern u16 gBattle_BG2_X ;
extern u16 gBattle_BG2_Y ;
extern u16 gBattle_BG3_X ;
extern u16 gBattle_BG3_Y ;
2018-08-18 18:23:40 +02:00
extern struct Unknown_0203BC8C_Struct * gFacilityTrainerMons ;
2018-08-18 00:54:18 +02:00
extern struct Unknown_0203CD78_Struct * gUnknown_0203CD78 ;
2018-08-25 11:55:16 +02:00
extern u8 * gUnknown_0203CD7C ;
2018-08-15 15:49:50 +02:00
extern void ( * const gUnknown_0860D090 [ ] ) ( void ) ;
extern const u32 gUnknown_0860D0EC [ ] [ 2 ] ;
extern const u32 gUnknown_0860D0FC [ ] [ 2 ] ;
2018-08-15 23:04:46 +02:00
extern const u16 gBattleFrontierHeldItems [ ] ;
2018-08-18 18:23:40 +02:00
extern const u8 gUnknown_0860D10C [ ] [ 4 ] ;
extern const u8 gUnknown_0860D14C [ ] ;
extern const struct BgTemplate gUnknown_0860CE84 [ 4 ] ;
extern const struct WindowTemplate gUnknown_0860CEB4 [ ] ;
2018-08-25 11:55:16 +02:00
extern const struct CompressedSpriteSheet gUnknown_0860CF50 [ ] ;
2018-08-18 18:23:40 +02:00
extern const struct SpriteTemplate gUnknown_0860D068 ;
extern const struct SpriteTemplate gUnknown_0860D050 ;
extern const u8 gUnknown_0860D080 [ ] ;
extern const u8 gUnknown_0860D15C [ ] ;
2018-08-18 19:52:25 +02:00
extern const u8 gUnknown_0860D1A0 [ ] ;
extern const u8 gUnknown_0860D19C [ ] ;
2018-08-19 17:13:05 +02:00
extern const u8 gUnknown_0860D349 [ ] ;
2018-08-18 19:52:25 +02:00
extern const u8 gUnknown_0860D1C0 [ ] ;
2018-08-19 17:13:05 +02:00
extern const u8 gUnknown_0860D343 [ ] ;
extern const u8 gUnknown_0860D340 [ ] ;
extern const u8 gUnknown_0860D346 [ ] ;
extern const u8 gUnknown_0860C988 [ 31 ] [ 16 ] ;
2018-08-18 18:23:40 +02:00
extern const u8 gUnknown_0860D3F1 [ ] [ 2 ] ;
2018-08-19 22:26:07 +02:00
extern const u8 gUnknown_0860D3C4 [ ] [ 3 ] ;
extern const u8 gUnknown_0860D3B4 [ ] ;
2018-08-20 22:56:05 +02:00
extern const u8 gUnknown_0860D3A8 [ ] ;
extern const u8 gUnknown_0860D3AB [ ] ;
extern const u8 gUnknown_0860D3AE [ ] ;
extern const u8 gUnknown_0860D3B1 [ ] ;
2018-08-21 23:36:59 +02:00
extern const u8 gUnknown_0860D080 [ ] ;
2018-08-25 11:55:16 +02:00
extern const u8 gUnknown_08D83900 [ ] ;
2018-08-21 23:36:59 +02:00
extern const u8 gUnknown_0860CBF1 [ ] [ 5 ] [ 4 ] ;
2018-08-19 17:13:05 +02:00
extern const u8 * const gBattleDomePotentialPointers [ ] ;
extern const u8 * const gBattleDomeOpponentStylePointers [ ] ;
extern const u8 * const gBattleDomeOpponentStatsPointers [ ] ;
2018-08-20 22:56:05 +02:00
extern const u8 * const gBattleDomeWinStringsPointers [ ] ;
extern const u8 * const gBattleDomeMatchNumberPointers [ ] ;
2018-08-18 18:23:40 +02:00
// gfx
extern const u8 gUnknown_08D83D50 [ ] ;
extern const u8 gUnknown_08D84970 [ ] ;
extern const u8 gUnknown_08D84F00 [ ] ;
extern const u8 gUnknown_08D85444 [ ] ;
extern const u8 gUnknown_08D85358 [ ] ;
extern const u8 gUnknown_08D85600 [ ] ;
extern const u8 gUnknown_08D854C8 [ ] ;
2018-08-25 11:55:16 +02:00
extern const u8 gUnknown_08D82F10 [ ] ;
extern const u8 gUnknown_08D834FC [ ] ;
extern const u8 gUnknown_08D83B2C [ ] ;
extern const u8 gUnknown_08D83C3C [ ] ;
2018-08-15 15:49:50 +02:00
2018-08-19 17:13:05 +02:00
// text
extern const u8 gTrainerClassNames [ ] [ 0xD ] ;
2018-08-15 15:49:50 +02:00
// This file's functions.
2018-08-15 23:04:46 +02:00
u8 GetDomeTrainerMonIvs ( u16 trainerId ) ;
2018-08-18 18:23:40 +02:00
void SwapDomeTrainers ( s32 id1 , s32 id2 , u16 * statsArray ) ;
void CalcDomeMonStats ( u16 species , s32 level , s32 ivs , u8 evBits , u8 nature , s32 * stats ) ;
2018-08-15 23:04:46 +02:00
void CreateDomeTrainerMons ( u16 tournamentTrainerId ) ;
2018-08-25 11:55:16 +02:00
s32 TrainerIdToTournamentId ( u16 trainerId ) ;
2018-08-20 22:56:05 +02:00
s32 GetTrainerMonCountInBits ( u16 tournamentTrainerId ) ;
2018-08-15 23:04:46 +02:00
s32 sub_818FCBC ( u16 tournamentTrainerId , bool8 arg1 ) ;
s32 sub_818FDB8 ( u16 tournamentTrainerId , bool8 arg1 ) ;
s32 sub_818FFC0 ( s32 move , s32 species , s32 arg2 ) ;
s32 sub_818FEB4 ( s32 * arr , bool8 arg1 ) ;
2018-08-18 19:52:25 +02:00
u16 TrainerIdOfPlayerOpponent ( void ) ;
2018-08-18 00:54:18 +02:00
void sub_8190400 ( u8 taskId ) ;
void sub_8190CD4 ( u8 taskId ) ;
2018-08-18 18:23:40 +02:00
void sub_8194220 ( u8 taskId ) ;
2018-08-25 11:55:16 +02:00
void sub_8194950 ( u8 taskId ) ;
static void CB2_BattleDome ( void ) ;
2018-08-18 00:54:18 +02:00
void sub_8194B70 ( void ) ;
2018-08-21 23:36:59 +02:00
static void DisplayMatchInfoOnCard ( u8 flags , u8 matchNo ) ;
2018-08-19 20:21:37 +02:00
static void DisplayTrainerInfoOnCard ( u8 flags , u8 trainerTournamentId ) ;
2018-08-18 18:23:40 +02:00
u8 sub_819221C ( u8 taskId ) ;
s32 sub_8192F08 ( u8 , u8 * ) ;
2018-08-19 17:13:05 +02:00
u8 GetDomeBrainTrainerPicId ( void ) ;
u8 GetDomeBrainTrainerClass ( void ) ;
void CopyDomeBrainTrainerName ( u8 * dst ) ;
2018-08-25 11:55:16 +02:00
void CopyDomeTrainerName ( u8 * dst , u16 trainerId ) ;
2018-08-21 23:36:59 +02:00
void sub_8194D48 ( void ) ;
2018-08-25 11:55:16 +02:00
void sub_8194BEC ( void ) ;
void sub_8194CE4 ( void ) ;
2018-08-21 23:36:59 +02:00
u8 sub_8193BDC ( u8 taskId ) ;
2018-08-25 11:55:16 +02:00
void sub_8195438 ( u8 roundId ) ;
u8 sub_81953E8 ( u8 tournamentId , u8 ) ;
void sub_81948EC ( u8 , u8 ) ;
2018-08-15 15:49:50 +02:00
2018-08-19 22:26:07 +02:00
// const rom data
ALIGNED ( 4 )
static const u8 sMovePoints [ MOVES_COUNT ] [ DOME_TOURNAMENT_TRAINERS_COUNT ] =
{
[ MOVE_NONE ] = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } ,
[ MOVE_POUND ] = { 0 , 0 , 0 , 0 , 0 , 0 , 0 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[ MOVE_DRAGON_DANCE ] = { 1 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } ,
[ MOVE_ROCK_BLAST ] = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } ,
[ MOVE_SHOCK_WAVE ] = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } ,
[ MOVE_WATER_PULSE ] = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 1 } ,
[ MOVE_DOOM_DESIRE ] = { 0 , 0 , 0 , 1 , 0 , 0 , 0 , 1 , 0 , 0 , 1 , 0 , 0 , 1 , 1 , 0 } ,
[ MOVE_PSYCHO_BOOST ] = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 1 , 0 , 0 , 1 , 1 , 1 } ,
} ;
2018-08-15 15:49:50 +02:00
// code
void sub_818E9AC ( void )
{
gUnknown_0860D090 [ gSpecialVar_0x8004 ] ( ) ;
}
void sub_818E9CC ( void )
{
u32 lvlMode = gSaveBlock2Ptr - > frontier . chosenLvl ;
2018-08-18 00:54:18 +02:00
u32 battleMode = VarGet ( VAR_0x40CE ) ;
2018-08-15 15:49:50 +02:00
gSaveBlock2Ptr - > frontier . field_CA8 = 0 ;
gSaveBlock2Ptr - > frontier . field_CB2 = 0 ;
gSaveBlock2Ptr - > frontier . field_CA9_a = 0 ;
gSaveBlock2Ptr - > frontier . field_CA9_b = 0 ;
2018-08-18 00:54:18 +02:00
if ( ! ( gSaveBlock2Ptr - > frontier . field_CDC & gUnknown_0860D0EC [ battleMode ] [ lvlMode ] ) )
gSaveBlock2Ptr - > frontier . field_D0C [ battleMode ] [ lvlMode ] = 0 ;
2018-08-15 15:49:50 +02:00
saved_warp2_set ( 0 , gSaveBlock1Ptr - > location . mapGroup , gSaveBlock1Ptr - > location . mapNum , - 1 ) ;
gTrainerBattleOpponent_A = 0 ;
}
void sub_818EA84 ( void )
{
u32 lvlMode = gSaveBlock2Ptr - > frontier . chosenLvl ;
2018-08-18 00:54:18 +02:00
u32 battleMode = VarGet ( VAR_0x40CE ) ;
2018-08-15 15:49:50 +02:00
switch ( gSpecialVar_0x8005 )
{
case 0 :
2018-08-18 00:54:18 +02:00
gSpecialVar_Result = gSaveBlock2Ptr - > frontier . field_D0C [ battleMode ] [ lvlMode ] ;
2018-08-15 15:49:50 +02:00
break ;
case 1 :
2018-08-18 00:54:18 +02:00
gSpecialVar_Result = ( ( gSaveBlock2Ptr - > frontier . field_CDC & gUnknown_0860D0EC [ battleMode ] [ lvlMode ] ) ! = 0 ) ;
2018-08-15 15:49:50 +02:00
break ;
case 2 :
gSpecialVar_Result = gSaveBlock2Ptr - > frontier . field_D08_0 ;
break ;
case 3 :
gSpecialVar_Result = gSaveBlock2Ptr - > frontier . field_D08_1 ;
break ;
case 4 :
gSpecialVar_Result = gSaveBlock2Ptr - > frontier . field_D08_2 ;
break ;
case 5 :
gSpecialVar_Result = gSaveBlock2Ptr - > frontier . field_D08_3 ;
break ;
case 6 :
if ( VarGet ( VAR_0x40CE ) = = 1 )
{
if ( lvlMode )
gSpecialVar_Result = gSaveBlock2Ptr - > frontier . field_D08_5 ;
else
gSpecialVar_Result = gSaveBlock2Ptr - > frontier . field_D08_4 ;
}
else
{
if ( lvlMode )
gSpecialVar_Result = gSaveBlock2Ptr - > frontier . field_D08_1 ;
else
gSpecialVar_Result = gSaveBlock2Ptr - > frontier . field_D08_0 ;
}
break ;
case 7 :
if ( VarGet ( VAR_0x40CE ) = = 1 )
{
if ( lvlMode )
gSpecialVar_Result = gSaveBlock2Ptr - > frontier . field_D08_7 ;
else
gSpecialVar_Result = gSaveBlock2Ptr - > frontier . field_D08_6 ;
}
else
{
if ( lvlMode )
gSpecialVar_Result = gSaveBlock2Ptr - > frontier . field_D08_3 ;
else
gSpecialVar_Result = gSaveBlock2Ptr - > frontier . field_D08_2 ;
}
break ;
case 8 :
sub_81B8558 ( ) ;
gUnknown_0203CEF8 [ 0 ] = gSaveBlock2Ptr - > frontier . field_CB0 ;
gUnknown_0203CEF8 [ 1 ] = gSaveBlock2Ptr - > frontier . field_CB0 > > 8 ;
break ;
case 9 :
gSpecialVar_Result = ( gSaveBlock2Ptr - > frontier . field_D0A * 2 ) - 3 + gSaveBlock2Ptr - > frontier . field_D0B ;
break ;
}
}
void sub_818ED28 ( void )
{
u32 lvlMode = gSaveBlock2Ptr - > frontier . chosenLvl ;
2018-08-18 00:54:18 +02:00
u32 battleMode = VarGet ( VAR_0x40CE ) ;
2018-08-15 15:49:50 +02:00
switch ( gSpecialVar_0x8005 )
{
case 0 :
2018-08-18 00:54:18 +02:00
gSaveBlock2Ptr - > frontier . field_D0C [ battleMode ] [ lvlMode ] = gSpecialVar_0x8006 ;
2018-08-15 15:49:50 +02:00
break ;
case 1 :
if ( gSpecialVar_0x8006 )
2018-08-18 00:54:18 +02:00
gSaveBlock2Ptr - > frontier . field_CDC | = gUnknown_0860D0EC [ battleMode ] [ lvlMode ] ;
2018-08-15 15:49:50 +02:00
else
2018-08-18 00:54:18 +02:00
gSaveBlock2Ptr - > frontier . field_CDC & = gUnknown_0860D0FC [ battleMode ] [ lvlMode ] ;
2018-08-15 15:49:50 +02:00
break ;
case 2 :
gSaveBlock2Ptr - > frontier . field_D08_0 = gSpecialVar_0x8006 ;
break ;
case 3 :
gSaveBlock2Ptr - > frontier . field_D08_1 = gSpecialVar_0x8006 ;
break ;
case 4 :
gSaveBlock2Ptr - > frontier . field_D08_2 = gSpecialVar_0x8006 ;
break ;
case 5 :
gSaveBlock2Ptr - > frontier . field_D08_3 = gSpecialVar_0x8006 ;
break ;
case 6 :
if ( VarGet ( VAR_0x40CE ) = = 1 )
{
if ( lvlMode )
gSaveBlock2Ptr - > frontier . field_D08_5 = gSpecialVar_0x8006 ;
else
gSaveBlock2Ptr - > frontier . field_D08_4 = gSpecialVar_0x8006 ;
}
else
{
if ( lvlMode )
gSaveBlock2Ptr - > frontier . field_D08_1 = gSpecialVar_0x8006 ;
else
gSaveBlock2Ptr - > frontier . field_D08_0 = gSpecialVar_0x8006 ;
}
break ;
case 7 :
if ( VarGet ( VAR_0x40CE ) = = 1 )
{
if ( lvlMode )
gSaveBlock2Ptr - > frontier . field_D08_7 = gSpecialVar_0x8006 ;
else
gSaveBlock2Ptr - > frontier . field_D08_6 = gSpecialVar_0x8006 ;
}
else
{
if ( lvlMode )
gSaveBlock2Ptr - > frontier . field_D08_3 = gSpecialVar_0x8006 ;
else
gSaveBlock2Ptr - > frontier . field_D08_2 = gSpecialVar_0x8006 ;
}
break ;
case 8 :
gSaveBlock2Ptr - > frontier . field_CB0 = T1_READ_16 ( gUnknown_0203CEF8 ) ;
break ;
}
}
2018-08-18 19:52:25 +02:00
void InitDomeTrainers ( void )
2018-08-15 15:49:50 +02:00
{
2018-08-18 18:23:40 +02:00
s32 i , j , k ;
s32 monLevel ;
s32 species [ 3 ] ;
2018-08-15 15:49:50 +02:00
s32 monTypesBits , monTypesCount ;
2018-08-18 18:23:40 +02:00
s32 trainerId ;
s32 monTournamentId ;
u16 * statSums ;
s32 * statValues ;
u8 ivs = 0 ;
species [ 0 ] = 0 ;
species [ 1 ] = 0 ;
species [ 2 ] = 0 ;
statSums = AllocZeroed ( sizeof ( u16 ) * DOME_TOURNAMENT_TRAINERS_COUNT ) ;
statValues = AllocZeroed ( sizeof ( s32 ) * 6 ) ;
2018-08-15 15:49:50 +02:00
gSaveBlock2Ptr - > frontier . field_D0A = gSaveBlock2Ptr - > frontier . chosenLvl + 1 ;
gSaveBlock2Ptr - > frontier . field_D0B = VarGet ( VAR_0x40CE ) + 1 ;
2018-08-18 18:23:40 +02:00
gSaveBlock2Ptr - > frontier . domeTrainers [ 0 ] . trainerId = TRAINER_PLAYER ;
2018-08-15 23:04:46 +02:00
gSaveBlock2Ptr - > frontier . domeTrainers [ 0 ] . unk1 = 0 ;
gSaveBlock2Ptr - > frontier . domeTrainers [ 0 ] . unk2 = 0 ;
gSaveBlock2Ptr - > frontier . domeTrainers [ 0 ] . unk3 = 0 ;
2018-08-15 15:49:50 +02:00
for ( i = 0 ; i < 3 ; i + + )
{
2018-08-18 18:23:40 +02:00
gSaveBlock2Ptr - > frontier . domeMonId [ 0 ] [ i ] = GetMonData ( & gPlayerParty [ gSaveBlock2Ptr - > frontier . field_CAA [ i ] - 1 ] , MON_DATA_SPECIES , NULL ) ;
2018-08-15 15:49:50 +02:00
for ( j = 0 ; j < 4 ; j + + )
gSaveBlock2Ptr - > frontier . field_EFC [ i ] . moves [ j ] = GetMonData ( & gPlayerParty [ gSaveBlock2Ptr - > frontier . field_CAA [ i ] - 1 ] , MON_DATA_MOVE1 + j , NULL ) ;
for ( j = 0 ; j < 6 ; j + + )
gSaveBlock2Ptr - > frontier . field_EFC [ i ] . evs [ j ] = GetMonData ( & gPlayerParty [ gSaveBlock2Ptr - > frontier . field_CAA [ i ] - 1 ] , MON_DATA_HP_EV + j , NULL ) ;
gSaveBlock2Ptr - > frontier . field_EFC [ i ] . nature = GetNature ( & gPlayerParty [ gSaveBlock2Ptr - > frontier . field_CAA [ i ] - 1 ] ) ;
}
2018-08-18 18:23:40 +02:00
for ( i = 1 ; i < DOME_TOURNAMENT_TRAINERS_COUNT ; i + + )
2018-08-15 15:49:50 +02:00
{
2018-08-18 18:23:40 +02:00
if ( i > 5 )
2018-08-15 15:49:50 +02:00
{
2018-08-18 18:23:40 +02:00
do
2018-08-15 15:49:50 +02:00
{
2018-08-18 18:23:40 +02:00
trainerId = sub_8162548 ( sub_81A39C4 ( ) , 0 ) ;
for ( j = 1 ; j < i ; j + + )
2018-08-15 15:49:50 +02:00
{
2018-08-18 18:23:40 +02:00
if ( gSaveBlock2Ptr - > frontier . domeTrainers [ j ] . trainerId = = trainerId )
2018-08-15 15:49:50 +02:00
break ;
}
2018-08-18 18:23:40 +02:00
} while ( j ! = i ) ;
gSaveBlock2Ptr - > frontier . domeTrainers [ i ] . trainerId = trainerId ;
2018-08-15 15:49:50 +02:00
}
else
{
2018-08-18 18:23:40 +02:00
do
2018-08-15 15:49:50 +02:00
{
2018-08-18 18:23:40 +02:00
trainerId = sub_8162548 ( sub_81A39C4 ( ) + 1 , 0 ) ;
for ( j = 1 ; j < i ; j + + )
2018-08-15 15:49:50 +02:00
{
2018-08-18 18:23:40 +02:00
if ( gSaveBlock2Ptr - > frontier . domeTrainers [ j ] . trainerId = = trainerId )
2018-08-15 15:49:50 +02:00
break ;
}
2018-08-18 18:23:40 +02:00
} while ( j ! = i ) ;
gSaveBlock2Ptr - > frontier . domeTrainers [ i ] . trainerId = trainerId ;
2018-08-15 15:49:50 +02:00
}
2018-08-18 18:23:40 +02:00
for ( j = 0 ; j < 3 ; j + + )
2018-08-15 15:49:50 +02:00
{
2018-08-18 18:23:40 +02:00
// Make sure the mon is valid.
2018-08-15 15:49:50 +02:00
do
{
2018-08-18 18:23:40 +02:00
monTournamentId = RandomizeFacilityTrainerMonId ( trainerId ) ;
for ( k = 0 ; k < j ; k + + )
2018-08-15 15:49:50 +02:00
{
2018-08-18 18:23:40 +02:00
s32 checkingMonId = gSaveBlock2Ptr - > frontier . domeMonId [ i ] [ k ] ;
if ( checkingMonId = = monTournamentId
| | species [ 0 ] = = gFacilityTrainerMons [ monTournamentId ] . species
| | species [ 1 ] = = gFacilityTrainerMons [ monTournamentId ] . species
| | gFacilityTrainerMons [ checkingMonId ] . itemTableId = = gFacilityTrainerMons [ monTournamentId ] . itemTableId )
2018-08-15 15:49:50 +02:00
break ;
}
2018-08-18 18:23:40 +02:00
} while ( k ! = j ) ;
2018-08-15 15:49:50 +02:00
2018-08-18 18:23:40 +02:00
gSaveBlock2Ptr - > frontier . domeMonId [ i ] [ j ] = monTournamentId ;
species [ j ] = gFacilityTrainerMons [ monTournamentId ] . species ;
2018-08-15 15:49:50 +02:00
}
2018-08-18 18:23:40 +02:00
gSaveBlock2Ptr - > frontier . domeTrainers [ i ] . unk1 = 0 ;
gSaveBlock2Ptr - > frontier . domeTrainers [ i ] . unk2 = 0 ;
gSaveBlock2Ptr - > frontier . domeTrainers [ i ] . unk3 = 0 ;
2018-08-15 15:49:50 +02:00
}
2018-08-18 18:23:40 +02:00
monTypesBits = 0 ;
statSums [ 0 ] = 0 ;
2018-08-15 15:49:50 +02:00
for ( i = 0 ; i < 3 ; i + + )
{
2018-08-18 18:23:40 +02:00
trainerId = gSaveBlock2Ptr - > frontier . field_CAA [ i ] - 1 ; // Great variable choice, gamefreak.
statSums [ 0 ] + = GetMonData ( & gPlayerParty [ trainerId ] , MON_DATA_ATK , NULL ) ;
statSums [ 0 ] + = GetMonData ( & gPlayerParty [ trainerId ] , MON_DATA_DEF , NULL ) ;
statSums [ 0 ] + = GetMonData ( & gPlayerParty [ trainerId ] , MON_DATA_SPATK , NULL ) ;
statSums [ 0 ] + = GetMonData ( & gPlayerParty [ trainerId ] , MON_DATA_SPDEF , NULL ) ;
statSums [ 0 ] + = GetMonData ( & gPlayerParty [ trainerId ] , MON_DATA_SPEED , NULL ) ;
statSums [ 0 ] + = GetMonData ( & gPlayerParty [ trainerId ] , MON_DATA_MAX_HP , NULL ) ;
monTypesBits | = gBitTable [ gBaseStats [ GetMonData ( & gPlayerParty [ trainerId ] , MON_DATA_SPECIES , NULL ) ] . type1 ] ;
monTypesBits | = gBitTable [ gBaseStats [ GetMonData ( & gPlayerParty [ trainerId ] , MON_DATA_SPECIES , NULL ) ] . type2 ] ;
2018-08-15 15:49:50 +02:00
}
2018-08-18 18:23:40 +02:00
for ( monTypesCount = 0 , j = 0 ; j < 32 ; j + + )
2018-08-15 15:49:50 +02:00
{
if ( monTypesBits & 1 )
monTypesCount + + ;
monTypesBits > > = 1 ;
}
2018-08-18 18:23:40 +02:00
monLevel = GetFrontierEnemyMonLevel ( ) ;
statSums [ 0 ] + = ( monTypesCount * monLevel ) / 20 ;
2018-08-15 15:49:50 +02:00
2018-08-18 18:23:40 +02:00
for ( i = 1 ; i < DOME_TOURNAMENT_TRAINERS_COUNT ; i + + )
2018-08-15 15:49:50 +02:00
{
2018-08-18 18:23:40 +02:00
monTypesBits = 0 ;
statSums [ i ] = 0 ;
ivs = GetDomeTrainerMonIvs ( gSaveBlock2Ptr - > frontier . domeTrainers [ i ] . trainerId ) ;
2018-08-15 15:49:50 +02:00
for ( j = 0 ; j < 3 ; j + + )
{
2018-08-18 18:23:40 +02:00
CalcDomeMonStats ( gFacilityTrainerMons [ gSaveBlock2Ptr - > frontier . domeMonId [ i ] [ j ] ] . species ,
monLevel , ivs ,
gFacilityTrainerMons [ gSaveBlock2Ptr - > frontier . domeMonId [ i ] [ j ] ] . evSpread ,
gFacilityTrainerMons [ gSaveBlock2Ptr - > frontier . domeMonId [ i ] [ j ] ] . nature ,
statValues ) ;
statSums [ i ] + = statValues [ STAT_ATK ] ;
statSums [ i ] + = statValues [ STAT_DEF ] ;
statSums [ i ] + = statValues [ STAT_SPATK ] ;
statSums [ i ] + = statValues [ STAT_SPDEF ] ;
statSums [ i ] + = statValues [ STAT_SPEED ] ;
statSums [ i ] + = statValues [ STAT_HP ] ;
monTypesBits | = gBitTable [ gBaseStats [ gFacilityTrainerMons [ gSaveBlock2Ptr - > frontier . domeMonId [ i ] [ j ] ] . species ] . type1 ] ;
monTypesBits | = gBitTable [ gBaseStats [ gFacilityTrainerMons [ gSaveBlock2Ptr - > frontier . domeMonId [ i ] [ j ] ] . species ] . type2 ] ;
}
for ( monTypesCount = 0 , j = 0 ; j < 32 ; j + + )
{
if ( monTypesBits & 1 )
monTypesCount + + ;
monTypesBits > > = 1 ;
2018-08-15 15:49:50 +02:00
}
2018-08-18 18:23:40 +02:00
statSums [ i ] + = ( monTypesCount * monLevel ) / 20 ;
2018-08-15 15:49:50 +02:00
}
2018-08-18 18:23:40 +02:00
for ( i = 0 ; i < DOME_TOURNAMENT_TRAINERS_COUNT - 1 ; i + + )
{
for ( j = i + 1 ; j < DOME_TOURNAMENT_TRAINERS_COUNT ; j + + )
{
if ( statSums [ i ] < statSums [ j ] )
{
SwapDomeTrainers ( i , j , statSums ) ;
}
else
{
if ( statSums [ i ] = = statSums [ j ] )
{
if ( gSaveBlock2Ptr - > frontier . domeTrainers [ j ] . trainerId = = TRAINER_PLAYER )
SwapDomeTrainers ( i , j , statSums ) ;
else if ( gSaveBlock2Ptr - > frontier . domeTrainers [ i ] . trainerId > gSaveBlock2Ptr - > frontier . domeTrainers [ j ] . trainerId )
SwapDomeTrainers ( i , j , statSums ) ;
}
}
}
}
if ( sub_81A3610 ( ) )
{
for ( i = 0 ; i < DOME_TOURNAMENT_TRAINERS_COUNT ; i + + )
{
if ( gSaveBlock2Ptr - > frontier . domeTrainers [ i ] . trainerId = = TRAINER_PLAYER )
break ;
}
if ( gUnknown_0860D3F1 [ i ] [ 0 ] ! = 0 )
{
j = 0 ;
gSaveBlock2Ptr - > frontier . domeTrainers [ j ] . trainerId = TRAINER_FRONTIER_BRAIN ;
}
else
{
j = 1 ;
gSaveBlock2Ptr - > frontier . domeTrainers [ j ] . trainerId = TRAINER_FRONTIER_BRAIN ;
}
for ( i = 0 ; i < 3 ; i + + )
gSaveBlock2Ptr - > frontier . domeMonId [ j ] [ i ] = sub_81A4FF0 ( i ) ;
}
Free ( statSums ) ;
Free ( statValues ) ;
2018-08-15 15:49:50 +02:00
}
# define CALC_STAT(base, statIndex) \
{ \
u8 baseStat = gBaseStats [ species ] . base ; \
stats [ statIndex ] = ( ( ( 2 * baseStat + ivs + evs [ statIndex ] / 4 ) * level ) / 100 ) + 5 ; \
stats [ statIndex ] = ( u8 ) ModifyStatByNature ( nature , stats [ statIndex ] , statIndex ) ; \
}
2018-08-18 18:23:40 +02:00
void CalcDomeMonStats ( u16 species , s32 level , s32 ivs , u8 evBits , u8 nature , s32 * stats )
2018-08-15 15:49:50 +02:00
{
s32 i , count ;
u8 bits ;
u16 resultingEvs ;
s32 evs [ 6 ] ;
count = 0 , bits = evBits ;
for ( i = 0 ; i < 6 ; bits > > = 1 , i + + )
{
if ( bits & 1 )
count + + ;
}
resultingEvs = 510 / count ;
for ( i = 0 ; i < 6 ; bits < < = 1 , i + + )
{
evs [ i ] = 0 ;
if ( evBits & bits )
evs [ i ] = resultingEvs ;
}
if ( species = = SPECIES_SHEDINJA )
{
stats [ STAT_HP ] = 1 ;
}
else
{
s32 n = 2 * gBaseStats [ species ] . baseHP ;
stats [ STAT_HP ] = ( ( ( n + ivs + evs [ STAT_HP ] / 4 ) * level ) / 100 ) + level + 10 ;
}
CALC_STAT ( baseAttack , STAT_ATK ) ;
CALC_STAT ( baseDefense , STAT_DEF ) ;
CALC_STAT ( baseSpeed , STAT_SPEED ) ;
CALC_STAT ( baseSpAttack , STAT_SPATK ) ;
CALC_STAT ( baseSpDefense , STAT_SPDEF ) ;
}
# define SWAP_16(x, y) \
{ \
temp = x ; \
x = y ; \
y = temp ; \
}
2018-08-18 18:23:40 +02:00
void SwapDomeTrainers ( s32 id1 , s32 id2 , u16 * statsArray )
2018-08-15 15:49:50 +02:00
{
s32 i ;
u16 temp ;
2018-08-18 18:23:40 +02:00
SWAP_16 ( statsArray [ id1 ] , statsArray [ id2 ] ) ;
2018-08-15 23:04:46 +02:00
SWAP_16 ( gSaveBlock2Ptr - > frontier . domeTrainers [ id1 ] . trainerId , gSaveBlock2Ptr - > frontier . domeTrainers [ id2 ] . trainerId ) ;
2018-08-15 15:49:50 +02:00
for ( i = 0 ; i < 3 ; i + + )
2018-08-15 23:04:46 +02:00
SWAP_16 ( gSaveBlock2Ptr - > frontier . domeMonId [ id1 ] [ i ] , gSaveBlock2Ptr - > frontier . domeMonId [ id2 ] [ i ] ) ;
2018-08-15 15:49:50 +02:00
}
2018-08-15 23:04:46 +02:00
void sub_818F9B0 ( void )
{
StringCopy ( gStringVar1 , gRoundsStringTable [ gSaveBlock2Ptr - > frontier . field_CB2 ] ) ;
}
void sub_818F9E0 ( void )
{
StringCopy ( gStringVar1 , gRoundsStringTable [ gSaveBlock2Ptr - > frontier . field_CB2 ] ) ;
2018-08-25 11:55:16 +02:00
CopyDomeTrainerName ( gStringVar2 , gTrainerBattleOpponent_A ) ;
2018-08-15 23:04:46 +02:00
}
void sub_818FA20 ( void )
{
gUnknown_0203CD70 = 0 ;
gUnknown_0203CD74 = GetMonData ( & gPlayerParty [ 0 ] , MON_DATA_MAX_HP , NULL ) ;
gUnknown_0203CD74 + = GetMonData ( & gPlayerParty [ 1 ] , MON_DATA_MAX_HP , NULL ) ;
CalculatePlayerPartyCount ( ) ;
CreateDomeTrainerMons ( TrainerIdToTournamentId ( gTrainerBattleOpponent_A ) ) ;
}
void CreateDomeMon ( u8 monPartyId , u16 tournamentTrainerId , u8 tournamentMonId , u32 otId )
{
s32 i ;
u8 happiness = 0xFF ;
2018-08-18 00:54:18 +02:00
u8 fixedIv = GetDomeTrainerMonIvs ( tournamentTrainerId ) ; // BUG: Should be using trainerId instead of tournamentTrainerId. As a result, all Pokemon have ivs of 3.
2018-08-15 23:04:46 +02:00
u8 level = GetFrontierEnemyMonLevel ( ) ;
CreateMonWithEVSpreadPersonalityOTID ( & gEnemyParty [ monPartyId ] ,
gFacilityTrainerMons [ gSaveBlock2Ptr - > frontier . domeMonId [ tournamentTrainerId ] [ tournamentMonId ] ] . species ,
level ,
gFacilityTrainerMons [ gSaveBlock2Ptr - > frontier . domeMonId [ tournamentTrainerId ] [ tournamentMonId ] ] . nature ,
fixedIv ,
gFacilityTrainerMons [ gSaveBlock2Ptr - > frontier . domeMonId [ tournamentTrainerId ] [ tournamentMonId ] ] . evSpread , otId ) ;
happiness = 0xFF ;
for ( i = 0 ; i < 4 ; i + + )
{
SetMonMoveSlot ( & gEnemyParty [ monPartyId ] ,
gFacilityTrainerMons [ gSaveBlock2Ptr - > frontier . domeMonId [ tournamentTrainerId ] [ tournamentMonId ] ] . moves [ i ] , i ) ;
if ( gFacilityTrainerMons [ gSaveBlock2Ptr - > frontier . domeMonId [ tournamentTrainerId ] [ tournamentMonId ] ] . moves [ i ] = = MOVE_FRUSTRATION )
happiness = 0 ;
}
SetMonData ( & gEnemyParty [ monPartyId ] , MON_DATA_FRIENDSHIP , & happiness ) ;
SetMonData ( & gEnemyParty [ monPartyId ] , MON_DATA_HELD_ITEM ,
& gBattleFrontierHeldItems [ gFacilityTrainerMons [ gSaveBlock2Ptr - > frontier . domeMonId [ tournamentTrainerId ] [ tournamentMonId ] ] . itemTableId ] ) ;
}
void CreateDomeTrainerMons ( u16 tournamentTrainerId )
{
u8 monsCount = 0 ;
u32 otId = 0 ;
s32 i , bits ;
ZeroEnemyPartyMons ( ) ;
2018-08-20 22:56:05 +02:00
bits = GetTrainerMonCountInBits ( tournamentTrainerId ) ;
2018-08-15 23:04:46 +02:00
otId = Random32 ( ) ;
if ( Random ( ) % 10 > 5 )
{
for ( i = 0 ; i < 3 ; i + + )
{
if ( bits & 1 )
{
CreateDomeMon ( monsCount , tournamentTrainerId , i , otId ) ;
monsCount + + ;
}
bits > > = 1 ;
}
}
else
{
for ( i = 2 ; i > = 0 ; i - - )
{
if ( bits & 4 )
{
CreateDomeMon ( monsCount , tournamentTrainerId , i , otId ) ;
monsCount + + ;
}
bits < < = 1 ;
}
}
}
2018-08-20 22:56:05 +02:00
s32 GetTrainerMonCountInBits ( u16 tournamentTrainerId )
2018-08-15 23:04:46 +02:00
{
s32 bits ;
if ( Random ( ) & 1 )
{
bits = sub_818FCBC ( tournamentTrainerId , FALSE ) ;
if ( bits = = 0 )
bits = sub_818FDB8 ( tournamentTrainerId , TRUE ) ;
}
else
{
bits = sub_818FDB8 ( tournamentTrainerId , FALSE ) ;
if ( bits = = 0 )
bits = sub_818FCBC ( tournamentTrainerId , TRUE ) ;
}
return bits ;
}
s32 sub_818FCBC ( u16 tournamentTrainerId , bool8 arg1 )
{
s32 i , moveId , playerMonId ;
s32 array [ 3 ] ;
for ( i = 0 ; i < 3 ; i + + )
{
array [ i ] = 0 ;
for ( moveId = 0 ; moveId < 4 ; moveId + + )
{
for ( playerMonId = 0 ; playerMonId < 3 ; playerMonId + + )
{
if ( gSaveBlock2Ptr - > frontier . domeTrainers [ tournamentTrainerId ] . trainerId = = TRAINER_FRONTIER_BRAIN )
{
array [ i ] + = sub_818FFC0 ( sub_81A5060 ( i , moveId ) ,
GetMonData ( & gPlayerParty [ playerMonId ] , MON_DATA_SPECIES , NULL ) , 0 ) ;
}
else
{
array [ i ] + = sub_818FFC0 ( gFacilityTrainerMons [ gSaveBlock2Ptr - > frontier . domeMonId [ tournamentTrainerId ] [ i ] ] . moves [ moveId ] ,
GetMonData ( & gPlayerParty [ playerMonId ] , MON_DATA_SPECIES , NULL ) , 0 ) ;
}
}
}
}
return sub_818FEB4 ( array , arg1 ) ;
}
s32 sub_818FDB8 ( u16 tournamentTrainerId , bool8 arg1 )
{
s32 i , moveId , playerMonId ;
s32 array [ 3 ] ;
for ( i = 0 ; i < 3 ; i + + )
{
array [ i ] = 0 ;
for ( moveId = 0 ; moveId < 4 ; moveId + + )
{
for ( playerMonId = 0 ; playerMonId < 3 ; playerMonId + + )
{
if ( gSaveBlock2Ptr - > frontier . domeTrainers [ tournamentTrainerId ] . trainerId = = TRAINER_FRONTIER_BRAIN )
{
array [ i ] + = sub_818FFC0 ( sub_81A5060 ( i , moveId ) ,
GetMonData ( & gPlayerParty [ playerMonId ] , MON_DATA_SPECIES , NULL ) , 1 ) ;
}
else
{
array [ i ] + = sub_818FFC0 ( gFacilityTrainerMons [ gSaveBlock2Ptr - > frontier . domeMonId [ tournamentTrainerId ] [ i ] ] . moves [ moveId ] ,
GetMonData ( & gPlayerParty [ playerMonId ] , MON_DATA_SPECIES , NULL ) , 1 ) ;
}
}
}
}
return sub_818FEB4 ( array , arg1 ) ;
}
s32 sub_818FEB4 ( s32 * arr , bool8 arg1 )
{
s32 i , j ;
s32 bits = 0 ;
s32 array [ 3 ] ;
for ( i = 0 ; i < 3 ; i + + )
array [ i ] = i ;
if ( arr [ 0 ] = = arr [ 1 ] & & arr [ 0 ] = = arr [ 2 ] )
{
if ( arg1 )
{
i = 0 ;
while ( i ! = 2 )
{
u32 rand = Random ( ) & 3 ;
if ( rand ! = 3 & & ! ( bits & gBitTable [ rand ] ) )
{
bits | = gBitTable [ rand ] ;
i + + ;
}
}
}
}
else
{
for ( i = 0 ; i < 2 ; i + + )
{
for ( j = i + 1 ; j < 3 ; j + + )
{
s32 temp ;
if ( arr [ i ] < arr [ j ] )
{
temp = arr [ i ] ;
arr [ i ] = arr [ j ] ;
arr [ j ] = temp ;
temp = array [ i ] ;
array [ i ] = array [ j ] ;
array [ j ] = temp ;
}
if ( arr [ i ] = = arr [ j ] & & ( Random ( ) & 1 ) )
{
temp = arr [ i ] ;
arr [ i ] = arr [ j ] ;
arr [ j ] = temp ;
temp = array [ i ] ;
array [ i ] = array [ j ] ;
array [ j ] = temp ;
}
}
}
for ( i = 0 ; i < 2 ; i + + )
{
bits | = gBitTable [ array [ i ] ] ;
}
}
return bits ;
}
2018-08-18 00:54:18 +02:00
// Functionally equivalent, while loop is impossible to match.
# ifdef NONMATCHING
2018-08-15 23:04:46 +02:00
s32 sub_818FFC0 ( s32 move , s32 species , s32 arg2 )
{
2018-08-16 22:46:02 +02:00
s32 type1 , type2 , ability , moveType ;
2018-08-15 23:04:46 +02:00
s32 i = 0 ;
s32 typePower = 20 ;
if ( move = = MOVE_NONE | | move = = 0xFFFF | | gBattleMoves [ move ] . power = = 0 )
return 0 ;
type1 = gBaseStats [ species ] . type1 ;
type2 = gBaseStats [ species ] . type2 ;
ability = gBaseStats [ species ] . ability1 ;
moveType = gBattleMoves [ move ] . type ;
if ( ability = = ABILITY_LEVITATE & & moveType = = TYPE_GROUND )
{
if ( arg2 = = 1 )
typePower = 8 ;
}
else
{
2018-08-16 22:46:02 +02:00
while ( gTypeEffectiveness [ i + 0 ] ! = TYPE_ENDTABLE )
2018-08-15 23:04:46 +02:00
{
2018-08-16 22:46:02 +02:00
if ( gTypeEffectiveness [ i + 0 ] = = TYPE_FORESIGHT )
2018-08-15 23:04:46 +02:00
{
i + = 3 ;
}
2018-08-16 22:46:02 +02:00
else
2018-08-15 23:04:46 +02:00
{
2018-08-16 22:46:02 +02:00
u8 val = gTypeEffectiveness [ i + 0 ] ;
if ( val = = moveType )
{
// BUG: * 2 is not necessary and makes the condition always false if the ability is wonder guard.
if ( gTypeEffectiveness [ i + 1 ] = = type1 & & ( ability ! = ABILITY_WONDER_GUARD | | gTypeEffectiveness [ i + 2 ] = = TYPE_MUL_SUPER_EFFECTIVE * 2 ) )
typePower = ( gTypeEffectiveness [ i + 2 ] * typePower ) / 10 ;
if ( gTypeEffectiveness [ i + 1 ] = = type2 & & type1 ! = type2 & & ( ability ! = ABILITY_WONDER_GUARD | | gTypeEffectiveness [ i + 2 ] = = TYPE_MUL_SUPER_EFFECTIVE * 2 ) )
typePower = ( gTypeEffectiveness [ i + 2 ] * typePower ) / 10 ;
}
i + = 3 ;
2018-08-15 23:04:46 +02:00
}
}
}
switch ( arg2 )
{
case 0 :
switch ( typePower )
{
case 10 :
case 5 :
case 0 :
default :
typePower = 0 ;
break ;
case 20 :
typePower = 2 ;
break ;
case 40 :
typePower = 4 ;
break ;
case 80 :
typePower = 8 ;
break ;
}
break ;
case 1 :
switch ( typePower )
{
default :
case 20 :
typePower = 0 ;
break ;
case 5 :
typePower = 4 ;
break ;
case 0 :
typePower = 8 ;
break ;
case 10 :
typePower = 2 ;
break ;
case 40 :
typePower = - 2 ;
break ;
case 80 :
typePower = - 4 ;
break ;
}
break ;
case 2 :
switch ( typePower )
{
case 0 :
typePower = - 16 ;
break ;
case 5 :
typePower = - 8 ;
break ;
case 10 :
default :
typePower = 0 ;
break ;
case 20 :
typePower = 4 ;
break ;
case 40 :
typePower = 12 ;
break ;
case 80 :
typePower = 20 ;
break ;
}
break ;
}
return typePower ;
2018-08-16 22:46:02 +02:00
}
2018-08-18 00:54:18 +02:00
# else
NAKED
s32 sub_818FFC0 ( s32 move , s32 species , s32 arg2 )
{
asm_unified ( " \n \
push { r4 - r7 , lr } \ n \
mov r7 , r10 \ n \
mov r6 , r9 \ n \
mov r5 , r8 \ n \
push { r5 - r7 } \ n \
sub sp , 0x8 \ n \
adds r3 , r0 , 0 \ n \
adds r4 , r1 , 0 \ n \
str r2 , [ sp ] \ n \
movs r6 , 0 \ n \
movs r2 , 0x14 \ n \
cmp r3 , 0 \ n \
beq _0818FFF0 \ n \
ldr r0 , = 0x0000ffff \ n \
cmp r3 , r0 \ n \
beq _0818FFF0 \ n \
ldr r0 , = gBattleMoves \ n \
lsls r1 , r3 , 1 \ n \
adds r1 , r3 \ n \
lsls r1 , 2 \ n \
adds r3 , r1 , r0 \ n \
ldrb r0 , [ r3 , 0x1 ] \ n \
cmp r0 , 0 \ n \
bne _0818FFFC \ n \
_0818FFF0 : \ n \
movs r0 , 0 \ n \
b _08190156 \ n \
. pool \ n \
_0818FFFC : \ n \
ldr r1 , = gBaseStats \ n \
lsls r0 , r4 , 3 \ n \
subs r0 , r4 \ n \
lsls r0 , 2 \ n \
adds r0 , r1 \ n \
ldrb r1 , [ r0 , 0x6 ] \ n \
mov r10 , r1 \ n \
ldrb r1 , [ r0 , 0x7 ] \ n \
mov r9 , r1 \ n \
ldrb r0 , [ r0 , 0x16 ] \ n \
mov r8 , r0 \ n \
ldrb r3 , [ r3 , 0x2 ] \ n \
str r3 , [ sp , 0x4 ] \ n \
cmp r0 , 0x1A \ n \
bne _0819002C \ n \
cmp r3 , 0x4 \ n \
bne _0819002C \ n \
ldr r0 , [ sp ] \ n \
cmp r0 , 0x1 \ n \
bne _081900AA \ n \
movs r2 , 0x8 \ n \
b _081900A4 \ n \
. pool \ n \
_0819002C : \ n \
ldr r0 , = gTypeEffectiveness \ n \
adds r1 , r6 , r0 \ n \
ldrb r0 , [ r1 ] \ n \
ldr r7 , = gTypeEffectiveness \ n \
cmp r0 , 0xFF \ n \
beq _081900A4 \ n \
adds r4 , r1 , 0 \ n \
_0819003A : \ n \
ldrb r0 , [ r4 ] \ n \
cmp r0 , 0xFE \ n \
beq _08190096 \ n \
ldrb r0 , [ r4 ] \ n \
ldr r1 , [ sp , 0x4 ] \ n \
cmp r0 , r1 \ n \
bne _08190096 \ n \
ldrb r0 , [ r4 , 0x1 ] \ n \
adds r5 , r6 , 0x1 \ n \
cmp r0 , r10 \ n \
bne _0819006C \ n \
adds r1 , r6 , 0x2 \ n \
mov r0 , r8 \ n \
cmp r0 , 0x19 \ n \
bne _0819005E \ n \
ldrb r0 , [ r4 , 0x2 ] \ n \
cmp r0 , 0x28 \ n \
bne _0819006C \ n \
_0819005E : \ n \
adds r0 , r1 , r7 \ n \
ldrb r0 , [ r0 ] \ n \
muls r0 , r2 \ n \
movs r1 , 0xA \ n \
bl __divsi3 \ n \
adds r2 , r0 , 0 \ n \
_0819006C : \ n \
adds r0 , r5 , r7 \ n \
ldrb r0 , [ r0 ] \ n \
cmp r0 , r9 \ n \
bne _08190096 \ n \
cmp r10 , r9 \ n \
beq _08190096 \ n \
adds r1 , r6 , 0x2 \ n \
mov r0 , r8 \ n \
cmp r0 , 0x19 \ n \
bne _08190088 \ n \
adds r0 , r1 , r7 \ n \
ldrb r0 , [ r0 ] \ n \
cmp r0 , 0x28 \ n \
bne _08190096 \ n \
_08190088 : \ n \
adds r0 , r1 , r7 \ n \
ldrb r0 , [ r0 ] \ n \
muls r0 , r2 \ n \
movs r1 , 0xA \ n \
bl __divsi3 \ n \
adds r2 , r0 , 0 \ n \
_08190096 : \ n \
adds r4 , 0x3 \ n \
adds r6 , 0x3 \ n \
ldr r1 , = gTypeEffectiveness \ n \
adds r0 , r6 , r1 \ n \
ldrb r0 , [ r0 ] \ n \
cmp r0 , 0xFF \ n \
bne _0819003A \ n \
_081900A4 : \ n \
ldr r0 , [ sp ] \ n \
cmp r0 , 0x1 \ n \
beq _081900E0 \ n \
_081900AA : \ n \
ldr r1 , [ sp ] \ n \
cmp r1 , 0x1 \ n \
bgt _081900BC \ n \
cmp r1 , 0 \ n \
beq _081900C4 \ n \
b _08190154 \ n \
. pool \ n \
_081900BC : \ n \
ldr r0 , [ sp ] \ n \
cmp r0 , 0x2 \ n \
beq _08190114 \ n \
b _08190154 \ n \
_081900C4 : \ n \
cmp r2 , 0xA \ n \
beq _08190146 \ n \
cmp r2 , 0xA \ n \
ble _08190146 \ n \
cmp r2 , 0x28 \ n \
beq _0819014A \ n \
cmp r2 , 0x28 \ n \
bgt _081900DA \ n \
cmp r2 , 0x14 \ n \
beq _08190104 \ n \
b _08190146 \ n \
_081900DA : \ n \
cmp r2 , 0x50 \ n \
bne _08190146 \ n \
b _08190100 \ n \
_081900E0 : \ n \
cmp r2 , 0xA \ n \
beq _08190104 \ n \
cmp r2 , 0xA \ n \
bgt _081900F2 \ n \
cmp r2 , 0 \ n \
beq _08190100 \ n \
cmp r2 , 0x5 \ n \
beq _0819014A \ n \
b _08190146 \ n \
_081900F2 : \ n \
cmp r2 , 0x28 \ n \
beq _08190108 \ n \
cmp r2 , 0x28 \ n \
ble _08190146 \ n \
cmp r2 , 0x50 \ n \
beq _0819010E \ n \
b _08190146 \ n \
_08190100 : \ n \
movs r2 , 0x8 \ n \
b _08190154 \ n \
_08190104 : \ n \
movs r2 , 0x2 \ n \
b _08190154 \ n \
_08190108 : \ n \
movs r2 , 0x2 \ n \
negs r2 , r2 \ n \
b _08190154 \ n \
_0819010E : \ n \
movs r2 , 0x4 \ n \
negs r2 , r2 \ n \
b _08190154 \ n \
_08190114 : \ n \
cmp r2 , 0xA \ n \
beq _08190146 \ n \
cmp r2 , 0xA \ n \
bgt _08190126 \ n \
cmp r2 , 0 \ n \
beq _0819013A \ n \
cmp r2 , 0x5 \ n \
beq _08190140 \ n \
b _08190146 \ n \
_08190126 : \ n \
cmp r2 , 0x28 \ n \
beq _0819014E \ n \
cmp r2 , 0x28 \ n \
bgt _08190134 \ n \
cmp r2 , 0x14 \ n \
beq _0819014A \ n \
b _08190146 \ n \
_08190134 : \ n \
cmp r2 , 0x50 \ n \
beq _08190152 \ n \
b _08190146 \ n \
_0819013A : \ n \
movs r2 , 0x10 \ n \
negs r2 , r2 \ n \
b _08190154 \ n \
_08190140 : \ n \
movs r2 , 0x8 \ n \
negs r2 , r2 \ n \
b _08190154 \ n \
_08190146 : \ n \
movs r2 , 0 \ n \
b _08190154 \ n \
_0819014A : \ n \
movs r2 , 0x4 \ n \
b _08190154 \ n \
_0819014E : \ n \
movs r2 , 0xC \ n \
b _08190154 \ n \
_08190152 : \ n \
movs r2 , 0x14 \ n \
_08190154 : \ n \
adds r0 , r2 , 0 \ n \
_08190156 : \ n \
add sp , 0x8 \ n \
pop { r3 - r5 } \ n \
mov r8 , r3 \ n \
mov r9 , r4 \ n \
mov r10 , r5 \ n \
pop { r4 - r7 } \ n \
pop { r1 } \ n \
bx r1 \ n \
" );
}
# endif // NONMATCHING
u8 GetDomeTrainerMonIvs ( u16 trainerId )
{
u8 fixedIv ;
if ( trainerId < = 99 )
fixedIv = 3 ;
else if ( trainerId < = 119 )
fixedIv = 6 ;
else if ( trainerId < = 139 )
fixedIv = 9 ;
else if ( trainerId < = 159 )
fixedIv = 12 ;
else if ( trainerId < = 179 )
fixedIv = 15 ;
else if ( trainerId < = 199 )
fixedIv = 18 ;
else if ( trainerId < = 219 )
fixedIv = 21 ;
else
fixedIv = 31 ;
return fixedIv ;
}
2018-08-18 19:52:25 +02:00
s32 TournamentIdOfOpponent ( s32 roundId , s32 trainerId )
2018-08-18 00:54:18 +02:00
{
s32 i , j , val ;
for ( i = 0 ; i < DOME_TOURNAMENT_TRAINERS_COUNT ; i + + )
{
if ( gSaveBlock2Ptr - > frontier . domeTrainers [ i ] . trainerId = = trainerId )
break ;
}
2018-08-18 19:52:25 +02:00
if ( roundId ! = DOME_ROUND1 )
2018-08-18 00:54:18 +02:00
{
2018-08-18 19:52:25 +02:00
if ( roundId = = DOME_FINAL )
val = gUnknown_0860D10C [ i ] [ roundId ] + 8 ;
2018-08-18 00:54:18 +02:00
else
2018-08-18 19:52:25 +02:00
val = gUnknown_0860D10C [ i ] [ roundId ] + 4 ;
2018-08-18 00:54:18 +02:00
2018-08-18 19:52:25 +02:00
for ( j = gUnknown_0860D10C [ i ] [ roundId ] ; j < val ; j + + )
2018-08-18 00:54:18 +02:00
{
if ( gUnknown_0860D14C [ j ] ! = i & & ! gSaveBlock2Ptr - > frontier . domeTrainers [ gUnknown_0860D14C [ j ] ] . unk1 )
break ;
}
if ( j ! = val )
return gUnknown_0860D14C [ j ] ;
else
return 0xFF ;
}
else
{
if ( ! gSaveBlock2Ptr - > frontier . domeTrainers [ gUnknown_0860D10C [ i ] [ 0 ] ] . unk1 )
return gUnknown_0860D10C [ i ] [ 0 ] ;
else
return 0xFF ;
}
}
void sub_8190298 ( void )
{
2018-08-18 19:52:25 +02:00
gTrainerBattleOpponent_A = TrainerIdOfPlayerOpponent ( ) ;
2018-08-18 00:54:18 +02:00
}
2018-08-18 19:52:25 +02:00
u16 TrainerIdOfPlayerOpponent ( void )
2018-08-18 00:54:18 +02:00
{
2018-08-18 19:52:25 +02:00
return gSaveBlock2Ptr - > frontier . domeTrainers [ TournamentIdOfOpponent ( gSaveBlock2Ptr - > frontier . field_CB2 , TRAINER_PLAYER ) ] . trainerId ;
2018-08-18 00:54:18 +02:00
}
void sub_81902E4 ( void )
{
sub_8162614 ( gTrainerBattleOpponent_A , 0 ) ;
}
void sub_81902F8 ( void )
{
gSaveBlock2Ptr - > frontier . field_CA8 = gSpecialVar_0x8005 ;
VarSet ( VAR_TEMP_0 , 0 ) ;
gSaveBlock2Ptr - > frontier . field_CA9_a = 1 ;
sub_81A4C30 ( ) ;
}
void sub_819033C ( void )
{
u8 lvlMode = gSaveBlock2Ptr - > frontier . chosenLvl ;
u8 battleMode = VarGet ( VAR_0x40CE ) ;
if ( gSaveBlock2Ptr - > frontier . field_D0C [ battleMode ] [ lvlMode ] < 999 )
gSaveBlock2Ptr - > frontier . field_D0C [ battleMode ] [ lvlMode ] + + ;
if ( gSaveBlock2Ptr - > frontier . field_D1C [ battleMode ] [ lvlMode ] < 999 )
gSaveBlock2Ptr - > frontier . field_D1C [ battleMode ] [ lvlMode ] + + ;
if ( gSaveBlock2Ptr - > frontier . field_D0C [ battleMode ] [ lvlMode ] > gSaveBlock2Ptr - > frontier . field_D14 [ battleMode ] [ lvlMode ] )
gSaveBlock2Ptr - > frontier . field_D14 [ battleMode ] [ lvlMode ] = gSaveBlock2Ptr - > frontier . field_D0C [ battleMode ] [ lvlMode ] ;
}
2018-08-18 19:52:25 +02:00
void ShowDomeOpponentInfo ( void )
2018-08-18 00:54:18 +02:00
{
u8 taskId = CreateTask ( sub_8190400 , 0 ) ;
gTasks [ taskId ] . data [ 0 ] = 0 ;
2018-08-18 19:52:25 +02:00
gTasks [ taskId ] . data [ 1 ] = TrainerIdToTournamentId ( TrainerIdOfPlayerOpponent ( ) ) ;
2018-08-18 00:54:18 +02:00
gTasks [ taskId ] . data [ 2 ] = 0 ;
gTasks [ taskId ] . data [ 3 ] = 0 ;
2018-08-25 11:55:16 +02:00
SetMainCallback2 ( CB2_BattleDome ) ;
2018-08-18 00:54:18 +02:00
}
void sub_8190400 ( u8 taskId )
{
s32 i ;
s32 r5 = gTasks [ taskId ] . data [ 1 ] ;
s32 r9 = gTasks [ taskId ] . data [ 2 ] ;
s32 r7 = gTasks [ taskId ] . data [ 3 ] ;
switch ( gTasks [ taskId ] . data [ 0 ] )
{
case 0 :
SetHBlankCallback ( NULL ) ;
SetVBlankCallback ( NULL ) ;
EnableInterrupts ( INTR_FLAG_VBLANK ) ;
CpuFill32 ( 0 , ( void * ) VRAM , VRAM_SIZE ) ;
ResetBgsAndClearDma3BusyFlags ( 0 ) ;
InitBgsFromTemplates ( 0 , gUnknown_0860CE84 , ARRAY_COUNT ( gUnknown_0860CE84 ) ) ;
InitWindows ( gUnknown_0860CEB4 ) ;
DeactivateAllTextPrinters ( ) ;
gBattle_BG0_X = 0 ;
gBattle_BG0_Y = 0 ;
gBattle_BG1_X = 0 ;
gBattle_BG1_Y = 0 ;
gBattle_BG3_X = 0 ;
gBattle_BG3_Y = 0 ;
if ( r9 = = 2 )
gBattle_BG2_X = 0 , gBattle_BG2_Y = 0 ;
else
gBattle_BG2_X = 0 , gBattle_BG2_Y = 160 ;
gTasks [ taskId ] . data [ 0 ] + + ;
break ;
case 1 :
SetGpuReg ( REG_OFFSET_BLDCNT , 0 ) ;
SetGpuReg ( REG_OFFSET_BLDALPHA , 0 ) ;
SetGpuReg ( REG_OFFSET_BLDY , 0 ) ;
SetGpuReg ( REG_OFFSET_MOSAIC , 0 ) ;
SetGpuReg ( REG_OFFSET_WIN0H , 0 ) ;
SetGpuReg ( REG_OFFSET_WIN0V , 0 ) ;
SetGpuReg ( REG_OFFSET_WIN1H , 0 ) ;
SetGpuReg ( REG_OFFSET_WIN1V , 0 ) ;
SetGpuReg ( REG_OFFSET_WININ , 0 ) ;
SetGpuReg ( REG_OFFSET_WINOUT , WINOUT_WIN01_BG0 | WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_BG3 | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR ) ;
ResetPaletteFade ( ) ;
ResetSpriteData ( ) ;
FreeAllSpritePalettes ( ) ;
gReservedSpritePaletteCount = 4 ;
gTasks [ taskId ] . data [ 0 ] + + ;
break ;
case 2 :
DecompressAndLoadBgGfxUsingHeap ( 2 , gUnknown_08D83D50 , 0x2000 , 0 , 0 ) ;
DecompressAndLoadBgGfxUsingHeap ( 2 , gUnknown_08D84970 , 0x2000 , 0 , 1 ) ;
DecompressAndLoadBgGfxUsingHeap ( 3 , gUnknown_08D84F00 , 0x800 , 0 , 1 ) ;
2018-08-25 11:55:16 +02:00
LoadCompressedObjectPic ( gUnknown_0860CF50 ) ;
2018-08-18 00:54:18 +02:00
LoadCompressedPalette ( gUnknown_08D85358 , 0 , 0x200 ) ;
LoadCompressedPalette ( gUnknown_08D85444 , 0x100 , 0x200 ) ;
LoadCompressedPalette ( gUnknown_08D85600 , 0xF0 , 0x20 ) ;
if ( r9 = = 2 )
LoadCompressedPalette ( gUnknown_08D854C8 , 0x50 , 0x20 ) ;
CpuFill32 ( 0 , gPlttBufferFaded , 0x400 ) ;
ShowBg ( 0 ) ;
ShowBg ( 1 ) ;
ShowBg ( 2 ) ;
ShowBg ( 3 ) ;
gTasks [ taskId ] . data [ 0 ] + + ;
break ;
case 3 :
SetVBlankCallback ( sub_8194B70 ) ;
gUnknown_0203CD78 = AllocZeroed ( sizeof ( * gUnknown_0203CD78 ) ) ;
for ( i = 0 ; i < DOME_TOURNAMENT_TRAINERS_COUNT ; i + + )
gUnknown_0203CD78 - > arr [ i ] | = 0xFF ;
LoadMonIconPalettes ( ) ;
i = CreateTask ( sub_8190CD4 , 0 ) ;
gTasks [ i ] . data [ 0 ] = 0 ;
gTasks [ i ] . data [ 2 ] = 0 ;
gTasks [ i ] . data [ 3 ] = r9 ;
gTasks [ i ] . data [ 4 ] = r7 ;
if ( r9 = = 2 )
{
2018-08-21 23:36:59 +02:00
DisplayMatchInfoOnCard ( 0 , r5 ) ;
2018-08-18 18:23:40 +02:00
gUnknown_0203CD78 - > unk_10 = 1 ;
2018-08-18 00:54:18 +02:00
}
else
{
2018-08-19 20:21:37 +02:00
DisplayTrainerInfoOnCard ( 0 , r5 ) ;
2018-08-18 00:54:18 +02:00
}
SetGpuReg ( REG_OFFSET_DISPCNT , DISPCNT_OBJ_ON | DISPCNT_BG_ALL_ON | DISPCNT_OBJ_1D_MAP ) ;
if ( r9 ! = 0 )
{
r7 = CreateSprite ( & gUnknown_0860D068 , 120 , 4 , 0 ) ;
StartSpriteAnim ( & gSprites [ r7 ] , 0 ) ;
gSprites [ r7 ] . data [ 0 ] = i ;
r7 = CreateSprite ( & gUnknown_0860D068 , 120 , 156 , 0 ) ;
StartSpriteAnim ( & gSprites [ r7 ] , 1 ) ;
gSprites [ r7 ] . data [ 0 ] = i ;
r7 = CreateSprite ( & gUnknown_0860D050 , 6 , 80 , 0 ) ;
StartSpriteAnim ( & gSprites [ r7 ] , 0 ) ;
gSprites [ r7 ] . data [ 0 ] = i ;
gSprites [ r7 ] . data [ 1 ] = 0 ;
if ( r9 = = 1 )
gSprites [ r7 ] . invisible = 1 ;
r7 = CreateSprite ( & gUnknown_0860D050 , 234 , 80 , 0 ) ;
StartSpriteAnim ( & gSprites [ r7 ] , 1 ) ;
gSprites [ r7 ] . data [ 0 ] = i ;
gSprites [ r7 ] . data [ 1 ] = 1 ;
}
DestroyTask ( taskId ) ;
break ;
}
}
2018-08-20 22:56:05 +02:00
// Note: Card scrolling up means the current card goes down and another one appears from top.
// The same is true for scrolling left.
// That means that the sprite needs to move with the moving card in the opposite scrolling direction.
static void SpriteCb_TrainerIconCardScrollUp ( struct Sprite * sprite )
2018-08-18 00:54:18 +02:00
{
sprite - > pos1 . y + = 4 ;
if ( sprite - > data [ 0 ] ! = 0 )
{
if ( sprite - > pos1 . y > = - 32 )
sprite - > invisible = 0 ;
if ( + + sprite - > data [ 1 ] = = 40 )
sprite - > callback = SpriteCallbackDummy ;
}
else
{
if ( sprite - > pos1 . y > = 192 )
{
gUnknown_0203CD78 - > arr [ sprite - > data [ 2 ] ] = 0xFF ;
2018-08-19 01:06:10 +02:00
FreeAndDestroyTrainerPicSprite ( sprite - > data [ 3 ] ) ;
2018-08-18 00:54:18 +02:00
}
}
}
2018-08-20 22:56:05 +02:00
static void SpriteCb_TrainerIconCardScrollDown ( struct Sprite * sprite )
2018-08-18 00:54:18 +02:00
{
sprite - > pos1 . y - = 4 ;
if ( sprite - > data [ 0 ] ! = 0 )
{
if ( sprite - > pos1 . y < = 192 )
sprite - > invisible = 0 ;
if ( + + sprite - > data [ 1 ] = = 40 )
sprite - > callback = SpriteCallbackDummy ;
}
else
{
if ( sprite - > pos1 . y < = - 32 )
{
gUnknown_0203CD78 - > arr [ sprite - > data [ 2 ] ] = 0xFF ;
2018-08-19 01:06:10 +02:00
FreeAndDestroyTrainerPicSprite ( sprite - > data [ 3 ] ) ;
2018-08-18 00:54:18 +02:00
}
}
}
2018-08-20 22:56:05 +02:00
static void SpriteCb_TrainerIconCardScrollLeft ( struct Sprite * sprite )
2018-08-18 00:54:18 +02:00
{
sprite - > pos1 . x + = 4 ;
if ( sprite - > data [ 0 ] ! = 0 )
{
if ( sprite - > pos1 . x > = - 32 )
sprite - > invisible = 0 ;
if ( + + sprite - > data [ 1 ] = = 64 )
sprite - > callback = SpriteCallbackDummy ;
}
else
{
if ( sprite - > pos1 . x > = 272 )
{
gUnknown_0203CD78 - > arr [ sprite - > data [ 2 ] ] = 0xFF ;
2018-08-19 01:06:10 +02:00
FreeAndDestroyTrainerPicSprite ( sprite - > data [ 3 ] ) ;
2018-08-18 00:54:18 +02:00
}
}
}
2018-08-20 22:56:05 +02:00
static void SpriteCb_TrainerIconCardScrollRight ( struct Sprite * sprite )
2018-08-18 00:54:18 +02:00
{
sprite - > pos1 . x - = 4 ;
if ( sprite - > data [ 0 ] ! = 0 )
{
if ( sprite - > pos1 . x < = 272 )
sprite - > invisible = 0 ;
if ( + + sprite - > data [ 1 ] = = 64 )
sprite - > callback = SpriteCallbackDummy ;
}
else
{
if ( sprite - > pos1 . x < = - 32 )
{
gUnknown_0203CD78 - > arr [ sprite - > data [ 2 ] ] = 0xFF ;
2018-08-19 01:06:10 +02:00
FreeAndDestroyTrainerPicSprite ( sprite - > data [ 3 ] ) ;
2018-08-18 00:54:18 +02:00
}
}
}
2018-08-20 22:56:05 +02:00
# define sMonIconStill data[3]
static void SpriteCb_MonIcon ( struct Sprite * sprite )
2018-08-18 00:54:18 +02:00
{
2018-08-20 22:56:05 +02:00
if ( ! sprite - > sMonIconStill )
2018-08-18 00:54:18 +02:00
UpdateMonIconFrame ( sprite ) ;
}
2018-08-20 22:56:05 +02:00
static void SpriteCb_MonIconCardScrollUp ( struct Sprite * sprite )
2018-08-18 00:54:18 +02:00
{
2018-08-20 22:56:05 +02:00
if ( ! sprite - > sMonIconStill )
2018-08-18 00:54:18 +02:00
UpdateMonIconFrame ( sprite ) ;
sprite - > pos1 . y + = 4 ;
if ( sprite - > data [ 0 ] ! = 0 )
{
if ( sprite - > pos1 . y > = - 16 )
sprite - > invisible = 0 ;
if ( + + sprite - > data [ 1 ] = = 40 )
2018-08-20 22:56:05 +02:00
sprite - > callback = SpriteCb_MonIcon ;
2018-08-18 00:54:18 +02:00
}
else
{
if ( sprite - > pos1 . y > = 176 )
{
gUnknown_0203CD78 - > arr [ sprite - > data [ 2 ] ] = 0xFF ;
sub_80D2EF8 ( sprite ) ;
}
}
}
2018-08-20 22:56:05 +02:00
static void SpriteCb_MonIconCardScrollDown ( struct Sprite * sprite )
2018-08-18 00:54:18 +02:00
{
2018-08-20 22:56:05 +02:00
if ( ! sprite - > sMonIconStill )
2018-08-18 00:54:18 +02:00
UpdateMonIconFrame ( sprite ) ;
sprite - > pos1 . y - = 4 ;
if ( sprite - > data [ 0 ] ! = 0 )
{
if ( sprite - > pos1 . y < = 176 )
sprite - > invisible = 0 ;
if ( + + sprite - > data [ 1 ] = = 40 )
2018-08-20 22:56:05 +02:00
sprite - > callback = SpriteCb_MonIcon ;
2018-08-18 00:54:18 +02:00
}
else
{
if ( sprite - > pos1 . y < = - 16 )
{
gUnknown_0203CD78 - > arr [ sprite - > data [ 2 ] ] = 0xFF ;
sub_80D2EF8 ( sprite ) ;
}
}
}
2018-08-20 22:56:05 +02:00
static void SpriteCb_MonIconCardScrollLeft ( struct Sprite * sprite )
2018-08-18 00:54:18 +02:00
{
2018-08-20 22:56:05 +02:00
if ( ! sprite - > sMonIconStill )
2018-08-18 00:54:18 +02:00
UpdateMonIconFrame ( sprite ) ;
sprite - > pos1 . x + = 4 ;
if ( sprite - > data [ 0 ] ! = 0 )
{
if ( sprite - > pos1 . x > = - 16 )
sprite - > invisible = 0 ;
if ( + + sprite - > data [ 1 ] = = 64 )
2018-08-20 22:56:05 +02:00
sprite - > callback = SpriteCb_MonIcon ;
2018-08-18 00:54:18 +02:00
}
else
{
if ( sprite - > pos1 . x > = 256 )
{
gUnknown_0203CD78 - > arr [ sprite - > data [ 2 ] ] = 0xFF ;
sub_80D2EF8 ( sprite ) ;
}
}
}
2018-08-20 22:56:05 +02:00
static void SpriteCb_MonIconCardScrollRight ( struct Sprite * sprite )
2018-08-18 00:54:18 +02:00
{
2018-08-20 22:56:05 +02:00
if ( ! sprite - > sMonIconStill )
2018-08-18 00:54:18 +02:00
UpdateMonIconFrame ( sprite ) ;
sprite - > pos1 . x - = 4 ;
if ( sprite - > data [ 0 ] ! = 0 )
{
if ( sprite - > pos1 . x < = 256 )
sprite - > invisible = 0 ;
if ( + + sprite - > data [ 1 ] = = 64 )
2018-08-20 22:56:05 +02:00
sprite - > callback = SpriteCb_MonIcon ;
2018-08-18 00:54:18 +02:00
}
else
{
if ( sprite - > pos1 . x < = - 16 )
{
gUnknown_0203CD78 - > arr [ sprite - > data [ 2 ] ] = 0xFF ;
sub_80D2EF8 ( sprite ) ;
}
}
}
void sub_8190B40 ( struct Sprite * sprite )
{
s32 taskId1 = sprite - > data [ 0 ] ;
s32 arrId = gTasks [ gTasks [ taskId1 ] . data [ 4 ] ] . data [ 1 ] ;
s32 tournmanetTrainerId = gUnknown_0860D080 [ arrId ] ;
s32 r12 = gSaveBlock2Ptr - > frontier . field_CB2 ;
if ( gTasks [ taskId1 ] . data [ 3 ] = = 1 )
{
if ( sprite - > data [ 1 ] )
{
if ( ( gSaveBlock2Ptr - > frontier . domeTrainers [ tournmanetTrainerId ] . unk1
2018-08-18 18:23:40 +02:00
& & gUnknown_0203CD78 - > unk_10 - 1 < gSaveBlock2Ptr - > frontier . domeTrainers [ tournmanetTrainerId ] . unk2 ) )
2018-08-18 00:54:18 +02:00
{
sprite - > invisible = 0 ;
}
else if ( ! gSaveBlock2Ptr - > frontier . domeTrainers [ tournmanetTrainerId ] . unk1
2018-08-18 18:23:40 +02:00
& & gUnknown_0203CD78 - > unk_10 - 1 < r12 )
2018-08-18 00:54:18 +02:00
{
sprite - > invisible = 0 ;
}
else
{
if ( gTasks [ taskId1 ] . data [ 0 ] = = 2 )
sprite - > invisible = 1 ;
}
}
else
{
2018-08-18 18:23:40 +02:00
if ( gUnknown_0203CD78 - > unk_10 ! = 0 )
2018-08-18 00:54:18 +02:00
{
sprite - > invisible = 0 ;
}
else
{
if ( gTasks [ taskId1 ] . data [ 0 ] = = 2 )
sprite - > invisible = 1 ;
}
}
}
else
{
if ( sprite - > data [ 1 ] )
{
2018-08-18 18:23:40 +02:00
if ( gUnknown_0203CD78 - > unk_10 > 1 )
2018-08-18 00:54:18 +02:00
{
if ( gTasks [ taskId1 ] . data [ 0 ] = = 2 )
sprite - > invisible = 1 ;
}
else
{
sprite - > invisible = 0 ;
}
}
else
{
2018-08-18 18:23:40 +02:00
if ( gUnknown_0203CD78 - > unk_10 ! = 0 )
2018-08-18 00:54:18 +02:00
{
sprite - > invisible = 0 ;
}
else
{
if ( gTasks [ taskId1 ] . data [ 0 ] = = 2 )
sprite - > invisible = 1 ;
}
}
}
}
void sub_8190C6C ( struct Sprite * sprite )
{
s32 taskId1 = sprite - > data [ 0 ] ;
if ( gTasks [ taskId1 ] . data [ 3 ] = = 1 )
{
2018-08-18 18:23:40 +02:00
if ( gUnknown_0203CD78 - > unk_10 ! = 0 )
2018-08-18 00:54:18 +02:00
{
if ( gTasks [ taskId1 ] . data [ 0 ] = = 2 )
sprite - > invisible = 1 ;
}
else
{
sprite - > invisible = 0 ;
}
}
else
{
2018-08-18 18:23:40 +02:00
if ( gUnknown_0203CD78 - > unk_10 ! = 1 )
2018-08-18 00:54:18 +02:00
{
if ( gTasks [ taskId1 ] . data [ 0 ] = = 2 )
sprite - > invisible = 1 ;
}
else
{
sprite - > invisible = 0 ;
}
}
}
2018-08-18 18:23:40 +02:00
void sub_8190CD4 ( u8 taskId )
{
s32 i ;
2018-08-20 22:56:05 +02:00
s32 windowId = 0 ;
2018-08-18 18:23:40 +02:00
s32 r9 = gTasks [ taskId ] . data [ 3 ] ;
s32 taskId2 = gTasks [ taskId ] . data [ 4 ] ;
2018-08-20 22:56:05 +02:00
s32 trainerTournamentId = 0 ;
s32 matchNo = 0 ;
2018-08-18 18:23:40 +02:00
switch ( gTasks [ taskId ] . data [ 0 ] )
{
case 0 :
if ( ! gPaletteFade . active )
{
BeginNormalPaletteFade ( 0xFFFFFFFF , 0 , 0x10 , 0 , 0 ) ;
gTasks [ taskId ] . data [ 0 ] = 1 ;
}
break ;
case 1 :
if ( ! gPaletteFade . active )
gTasks [ taskId ] . data [ 0 ] = 2 ;
break ;
case 2 :
i = sub_819221C ( taskId ) ;
switch ( i )
{
case 9 :
BeginNormalPaletteFade ( 0xFFFFFFFF , 0 , 0 , 0x10 , 0 ) ;
gTasks [ taskId ] . data [ 0 ] = 8 ;
break ;
case 1 . . . 8 :
gTasks [ taskId ] . data [ 5 ] = i ;
if ( gTasks [ taskId ] . data [ 2 ] ! = 0 )
2018-08-20 22:56:05 +02:00
windowId = 9 ;
2018-08-18 18:23:40 +02:00
else
2018-08-20 22:56:05 +02:00
windowId = 0 ;
2018-08-18 18:23:40 +02:00
2018-08-20 22:56:05 +02:00
for ( i = windowId ; i < windowId + 9 ; i + + )
2018-08-18 18:23:40 +02:00
{
CopyWindowToVram ( i , 2 ) ;
FillWindowPixelBuffer ( i , 0 ) ;
}
gTasks [ taskId ] . data [ 0 ] = 3 ;
break ;
case 0 :
break ;
}
break ;
case 3 :
i = gTasks [ taskId ] . data [ 5 ] ;
switch ( i )
{
case 1 :
case 5 :
if ( gTasks [ taskId ] . data [ 2 ] )
{
gBattle_BG0_X = 0 ;
gBattle_BG0_Y = 0 ;
gBattle_BG1_X = 0 ;
gBattle_BG1_Y = 160 ;
}
else
{
gBattle_BG0_X = 0 ;
gBattle_BG0_Y = 160 ;
gBattle_BG1_X = 0 ;
gBattle_BG1_Y = 0 ;
}
if ( i = = 1 )
{
if ( gUnknown_0203CD78 - > unk_10 = = 0 )
{
gBattle_BG2_X = 0 ;
gBattle_BG2_Y = 320 ;
2018-08-19 20:21:37 +02:00
trainerTournamentId = gUnknown_0860D080 [ gTasks [ taskId2 ] . data [ 1 ] ] ;
DisplayTrainerInfoOnCard ( gTasks [ taskId ] . data [ 2 ] | 0x10 , trainerTournamentId ) ;
2018-08-18 18:23:40 +02:00
}
else
{
gBattle_BG2_X = 256 ;
gBattle_BG2_Y = 0 ;
2018-08-19 20:21:37 +02:00
trainerTournamentId = gUnknown_0860D080 [ gTasks [ taskId2 ] . data [ 1 ] ] ;
DisplayTrainerInfoOnCard ( gTasks [ taskId ] . data [ 2 ] | 0x10 , trainerTournamentId ) ;
2018-08-18 18:23:40 +02:00
gUnknown_0203CD78 - > unk_10 = 0 ;
}
}
else
{
if ( gUnknown_0203CD78 - > unk_10 = = 0 )
{
2018-08-20 22:56:05 +02:00
matchNo = gTasks [ taskId2 ] . data [ 1 ] - 16 ;
sub_8192F08 ( matchNo , gUnknown_0203CD78 - > unk_11 ) ;
2018-08-18 18:23:40 +02:00
gBattle_BG2_X = 0 ;
gBattle_BG2_Y = 320 ;
2018-08-19 20:21:37 +02:00
trainerTournamentId = gUnknown_0203CD78 - > unk_11 [ 0 ] ;
DisplayTrainerInfoOnCard ( gTasks [ taskId ] . data [ 2 ] | 0x10 , trainerTournamentId ) ;
2018-08-18 18:23:40 +02:00
}
else if ( gUnknown_0203CD78 - > unk_10 = = 2 )
{
2018-08-20 22:56:05 +02:00
matchNo = gTasks [ taskId2 ] . data [ 1 ] - 16 ;
sub_8192F08 ( matchNo , gUnknown_0203CD78 - > unk_11 ) ;
2018-08-18 18:23:40 +02:00
gBattle_BG2_X = 0 ;
gBattle_BG2_Y = 320 ;
2018-08-19 20:21:37 +02:00
trainerTournamentId = gUnknown_0203CD78 - > unk_11 [ 1 ] ;
DisplayTrainerInfoOnCard ( gTasks [ taskId ] . data [ 2 ] | 0x10 , trainerTournamentId ) ;
2018-08-18 18:23:40 +02:00
}
else
{
gBattle_BG2_X = 256 ;
gBattle_BG2_Y = 160 ;
2018-08-20 22:56:05 +02:00
matchNo = gTasks [ taskId2 ] . data [ 1 ] - 16 ;
2018-08-21 23:36:59 +02:00
DisplayMatchInfoOnCard ( gTasks [ taskId ] . data [ 2 ] | 0x10 , matchNo ) ;
2018-08-18 18:23:40 +02:00
}
}
for ( i = 0 ; i < DOME_TOURNAMENT_TRAINERS_COUNT / 2 ; i + + )
{
if ( i < 2 )
{
if ( gUnknown_0203CD78 - > arr [ i ] ! = 0xFF )
{
2018-08-20 22:56:05 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . callback = SpriteCb_TrainerIconCardScrollUp ;
2018-08-18 18:23:40 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 0 ] = gTasks [ taskId ] . data [ 2 ] ^ 1 ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 1 ] = 0 ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 2 ] = i ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 3 ] = gUnknown_0203CD78 - > arr [ i ] ;
}
}
else
{
if ( gUnknown_0203CD78 - > arr [ i ] ! = 0xFF )
{
2018-08-20 22:56:05 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . callback = SpriteCb_MonIconCardScrollUp ;
2018-08-18 18:23:40 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 0 ] = gTasks [ taskId ] . data [ 2 ] ^ 1 ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 1 ] = 0 ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 2 ] = i ;
}
}
}
for ( i = DOME_TOURNAMENT_TRAINERS_COUNT / 2 ; i < DOME_TOURNAMENT_TRAINERS_COUNT ; i + + )
{
if ( i < 10 )
{
if ( gUnknown_0203CD78 - > arr [ i ] ! = 0xFF )
{
2018-08-20 22:56:05 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . callback = SpriteCb_TrainerIconCardScrollUp ;
2018-08-18 18:23:40 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 0 ] = gTasks [ taskId ] . data [ 2 ] ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 1 ] = 0 ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 2 ] = i ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 3 ] = gUnknown_0203CD78 - > arr [ i ] ;
}
}
else
{
if ( gUnknown_0203CD78 - > arr [ i ] ! = 0xFF )
{
2018-08-20 22:56:05 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . callback = SpriteCb_MonIconCardScrollUp ;
2018-08-18 18:23:40 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 0 ] = gTasks [ taskId ] . data [ 2 ] ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 1 ] = 0 ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 2 ] = i ;
}
}
}
gTasks [ taskId ] . data [ 0 ] = 4 ;
gTasks [ taskId ] . data [ 5 ] = 0 ;
break ;
case 2 :
case 6 :
if ( gTasks [ taskId ] . data [ 2 ] )
{
gBattle_BG0_X = 0 ;
gBattle_BG0_Y = 0 ;
gBattle_BG1_X = 0 ;
gBattle_BG1_Y = - 160 ;
}
else
{
gBattle_BG0_X = 0 ;
gBattle_BG0_Y = - 160 ;
gBattle_BG1_X = 0 ;
gBattle_BG1_Y = 0 ;
}
if ( i = = 2 )
{
if ( gUnknown_0203CD78 - > unk_10 = = 0 )
{
gBattle_BG2_X = 0 ;
gBattle_BG2_Y = 160 ;
2018-08-19 20:21:37 +02:00
trainerTournamentId = gUnknown_0860D080 [ gTasks [ taskId2 ] . data [ 1 ] ] ;
DisplayTrainerInfoOnCard ( gTasks [ taskId ] . data [ 2 ] | 4 , trainerTournamentId ) ;
2018-08-18 18:23:40 +02:00
}
else
{
gBattle_BG2_X = 0 ;
gBattle_BG2_Y = 0 ;
2018-08-19 20:21:37 +02:00
trainerTournamentId = gUnknown_0860D080 [ gTasks [ taskId2 ] . data [ 1 ] ] ;
DisplayTrainerInfoOnCard ( gTasks [ taskId ] . data [ 2 ] | 4 , trainerTournamentId ) ;
2018-08-18 18:23:40 +02:00
gUnknown_0203CD78 - > unk_10 = 0 ;
}
}
else
{
if ( gUnknown_0203CD78 - > unk_10 = = 0 )
{
2018-08-20 22:56:05 +02:00
matchNo = gTasks [ taskId2 ] . data [ 1 ] - 16 ;
sub_8192F08 ( matchNo , gUnknown_0203CD78 - > unk_11 ) ;
2018-08-18 18:23:40 +02:00
gBattle_BG2_X = 0 ;
gBattle_BG2_Y = 160 ;
2018-08-19 20:21:37 +02:00
trainerTournamentId = gUnknown_0203CD78 - > unk_11 [ 0 ] ;
DisplayTrainerInfoOnCard ( gTasks [ taskId ] . data [ 2 ] | 4 , trainerTournamentId ) ;
2018-08-18 18:23:40 +02:00
}
else if ( gUnknown_0203CD78 - > unk_10 = = 2 )
{
2018-08-20 22:56:05 +02:00
matchNo = gTasks [ taskId2 ] . data [ 1 ] - 16 ;
sub_8192F08 ( matchNo , gUnknown_0203CD78 - > unk_11 ) ;
2018-08-18 18:23:40 +02:00
gBattle_BG2_X = 0 ;
gBattle_BG2_Y = 160 ;
2018-08-19 20:21:37 +02:00
trainerTournamentId = gUnknown_0203CD78 - > unk_11 [ 1 ] ;
DisplayTrainerInfoOnCard ( gTasks [ taskId ] . data [ 2 ] | 4 , trainerTournamentId ) ;
2018-08-18 18:23:40 +02:00
}
else
{
gBattle_BG2_X = 256 ;
gBattle_BG2_Y = 0 ;
2018-08-20 22:56:05 +02:00
matchNo = gTasks [ taskId2 ] . data [ 1 ] - 16 ;
2018-08-21 23:36:59 +02:00
DisplayMatchInfoOnCard ( gTasks [ taskId ] . data [ 2 ] | 4 , matchNo ) ;
2018-08-18 18:23:40 +02:00
}
}
for ( i = 0 ; i < DOME_TOURNAMENT_TRAINERS_COUNT / 2 ; i + + )
{
if ( i < 2 )
{
if ( gUnknown_0203CD78 - > arr [ i ] ! = 0xFF )
{
2018-08-20 22:56:05 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . callback = SpriteCb_TrainerIconCardScrollDown ;
2018-08-18 18:23:40 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 0 ] = gTasks [ taskId ] . data [ 2 ] ^ 1 ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 1 ] = 0 ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 2 ] = i ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 3 ] = gUnknown_0203CD78 - > arr [ i ] ;
}
}
else
{
if ( gUnknown_0203CD78 - > arr [ i ] ! = 0xFF )
{
2018-08-20 22:56:05 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . callback = SpriteCb_MonIconCardScrollDown ;
2018-08-18 18:23:40 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 0 ] = gTasks [ taskId ] . data [ 2 ] ^ 1 ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 1 ] = 0 ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 2 ] = i ;
}
}
}
for ( i = DOME_TOURNAMENT_TRAINERS_COUNT / 2 ; i < DOME_TOURNAMENT_TRAINERS_COUNT ; i + + )
{
if ( i < 10 )
{
if ( gUnknown_0203CD78 - > arr [ i ] ! = 0xFF )
{
2018-08-20 22:56:05 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . callback = SpriteCb_TrainerIconCardScrollDown ;
2018-08-18 18:23:40 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 0 ] = gTasks [ taskId ] . data [ 2 ] ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 1 ] = 0 ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 2 ] = i ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 3 ] = gUnknown_0203CD78 - > arr [ i ] ;
}
}
else
{
if ( gUnknown_0203CD78 - > arr [ i ] ! = 0xFF )
{
2018-08-20 22:56:05 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . callback = SpriteCb_MonIconCardScrollDown ;
2018-08-18 18:23:40 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 0 ] = gTasks [ taskId ] . data [ 2 ] ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 1 ] = 0 ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 2 ] = i ;
}
}
}
gTasks [ taskId ] . data [ 0 ] = 5 ;
gTasks [ taskId ] . data [ 5 ] = 0 ;
break ;
case 3 :
if ( gTasks [ taskId ] . data [ 2 ] )
{
gBattle_BG0_X = 0 ;
gBattle_BG0_Y = 0 ;
gBattle_BG1_X = 256 ;
gBattle_BG1_Y = 0 ;
}
else
{
gBattle_BG0_X = 256 ;
gBattle_BG0_Y = 0 ;
gBattle_BG1_X = 0 ;
gBattle_BG1_Y = 0 ;
}
if ( gUnknown_0203CD78 - > unk_10 = = 0 )
{
gBattle_BG2_X = 256 ;
gBattle_BG2_Y = 160 ;
2018-08-19 20:21:37 +02:00
trainerTournamentId = gUnknown_0860D080 [ gTasks [ taskId2 ] . data [ 1 ] ] ;
DisplayTrainerInfoOnCard ( gTasks [ taskId ] . data [ 2 ] | 8 , trainerTournamentId ) ;
2018-08-18 18:23:40 +02:00
}
else
{
gBattle_BG2_X = 256 ;
gBattle_BG2_Y = 0 ;
2018-08-20 22:56:05 +02:00
matchNo = gUnknown_0860D15C [ ( gTasks [ taskId2 ] . data [ 1 ] * 4 ) + ( gUnknown_0203CD78 - > unk_10 - 1 ) ] ;
2018-08-21 23:36:59 +02:00
DisplayMatchInfoOnCard ( gTasks [ taskId ] . data [ 2 ] | 8 , matchNo ) ;
2018-08-18 18:23:40 +02:00
}
for ( i = 0 ; i < DOME_TOURNAMENT_TRAINERS_COUNT / 2 ; i + + )
{
if ( i < 2 )
{
if ( gUnknown_0203CD78 - > arr [ i ] ! = 0xFF )
{
2018-08-20 22:56:05 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . callback = SpriteCb_TrainerIconCardScrollLeft ;
2018-08-18 18:23:40 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 0 ] = gTasks [ taskId ] . data [ 2 ] ^ 1 ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 1 ] = 0 ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 2 ] = i ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 3 ] = gUnknown_0203CD78 - > arr [ i ] ;
}
}
else
{
if ( gUnknown_0203CD78 - > arr [ i ] ! = 0xFF )
{
2018-08-20 22:56:05 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . callback = SpriteCb_MonIconCardScrollLeft ;
2018-08-18 18:23:40 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 0 ] = gTasks [ taskId ] . data [ 2 ] ^ 1 ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 1 ] = 0 ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 2 ] = i ;
}
}
}
for ( i = DOME_TOURNAMENT_TRAINERS_COUNT / 2 ; i < DOME_TOURNAMENT_TRAINERS_COUNT ; i + + )
{
if ( i < 10 )
{
if ( gUnknown_0203CD78 - > arr [ i ] ! = 0xFF )
{
2018-08-20 22:56:05 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . callback = SpriteCb_TrainerIconCardScrollLeft ;
2018-08-18 18:23:40 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 0 ] = gTasks [ taskId ] . data [ 2 ] ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 1 ] = 0 ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 2 ] = i ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 3 ] = gUnknown_0203CD78 - > arr [ i ] ;
}
}
else
{
if ( gUnknown_0203CD78 - > arr [ i ] ! = 0xFF )
{
2018-08-20 22:56:05 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . callback = SpriteCb_MonIconCardScrollLeft ;
2018-08-18 18:23:40 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 0 ] = gTasks [ taskId ] . data [ 2 ] ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 1 ] = 0 ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 2 ] = i ;
}
}
}
gTasks [ taskId ] . data [ 0 ] = 6 ;
gTasks [ taskId ] . data [ 5 ] = 0 ;
break ;
case 7 :
if ( gTasks [ taskId ] . data [ 2 ] )
{
gBattle_BG0_X = 0 ;
gBattle_BG0_Y = 0 ;
gBattle_BG1_X = 256 ;
gBattle_BG1_Y = 0 ;
}
else
{
gBattle_BG0_X = 256 ;
gBattle_BG0_Y = 0 ;
gBattle_BG1_X = 0 ;
gBattle_BG1_Y = 0 ;
}
if ( gUnknown_0203CD78 - > unk_10 = = 0 )
{
gBattle_BG2_X = 256 ;
gBattle_BG2_Y = 160 ;
2018-08-19 20:21:37 +02:00
trainerTournamentId = gUnknown_0203CD78 - > unk_11 [ 0 ] ;
DisplayTrainerInfoOnCard ( gTasks [ taskId ] . data [ 2 ] | 8 , trainerTournamentId ) ;
2018-08-18 18:23:40 +02:00
}
else
{
gBattle_BG2_X = 0 ;
gBattle_BG2_Y = 160 ;
2018-08-20 22:56:05 +02:00
matchNo = gTasks [ taskId2 ] . data [ 1 ] - 16 ;
2018-08-21 23:36:59 +02:00
DisplayMatchInfoOnCard ( gTasks [ taskId ] . data [ 2 ] | 8 , matchNo ) ;
2018-08-18 18:23:40 +02:00
}
for ( i = 0 ; i < DOME_TOURNAMENT_TRAINERS_COUNT / 2 ; i + + )
{
if ( i < 2 )
{
if ( gUnknown_0203CD78 - > arr [ i ] ! = 0xFF )
{
2018-08-20 22:56:05 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . callback = SpriteCb_TrainerIconCardScrollLeft ;
2018-08-18 18:23:40 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 0 ] = gTasks [ taskId ] . data [ 2 ] ^ 1 ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 1 ] = 0 ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 2 ] = i ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 3 ] = gUnknown_0203CD78 - > arr [ i ] ;
}
}
else
{
if ( gUnknown_0203CD78 - > arr [ i ] ! = 0xFF )
{
2018-08-20 22:56:05 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . callback = SpriteCb_MonIconCardScrollLeft ;
2018-08-18 18:23:40 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 0 ] = gTasks [ taskId ] . data [ 2 ] ^ 1 ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 1 ] = 0 ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 2 ] = i ;
}
}
}
for ( i = DOME_TOURNAMENT_TRAINERS_COUNT / 2 ; i < DOME_TOURNAMENT_TRAINERS_COUNT ; i + + )
{
if ( i < 10 )
{
if ( gUnknown_0203CD78 - > arr [ i ] ! = 0xFF )
{
2018-08-20 22:56:05 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . callback = SpriteCb_TrainerIconCardScrollLeft ;
2018-08-18 18:23:40 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 0 ] = gTasks [ taskId ] . data [ 2 ] ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 1 ] = 0 ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 2 ] = i ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 3 ] = gUnknown_0203CD78 - > arr [ i ] ;
}
}
else
{
if ( gUnknown_0203CD78 - > arr [ i ] ! = 0xFF )
{
2018-08-20 22:56:05 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . callback = SpriteCb_MonIconCardScrollLeft ;
2018-08-18 18:23:40 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 0 ] = gTasks [ taskId ] . data [ 2 ] ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 1 ] = 0 ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 2 ] = i ;
}
}
}
gTasks [ taskId ] . data [ 0 ] = 6 ;
gTasks [ taskId ] . data [ 5 ] = 0 ;
break ;
case 4 :
if ( gTasks [ taskId ] . data [ 2 ] )
{
gBattle_BG0_X = 0 ;
gBattle_BG0_Y = 0 ;
gBattle_BG1_X = - 256 ;
gBattle_BG1_Y = 0 ;
}
else
{
gBattle_BG0_X = - 256 ;
gBattle_BG0_Y = 0 ;
gBattle_BG1_X = 0 ;
gBattle_BG1_Y = 0 ;
}
if ( gUnknown_0203CD78 - > unk_10 = = 1 )
{
gBattle_BG2_X = 0 ;
gBattle_BG2_Y = 160 ;
}
else
{
gBattle_BG2_X = 0 ;
gBattle_BG2_Y = 0 ;
}
2018-08-20 22:56:05 +02:00
matchNo = gUnknown_0860D15C [ ( gUnknown_0203CD78 - > unk_10 - 1 ) + ( gTasks [ taskId2 ] . data [ 1 ] * 4 ) ] ;
2018-08-21 23:36:59 +02:00
DisplayMatchInfoOnCard ( gTasks [ taskId ] . data [ 2 ] | 2 , matchNo ) ;
2018-08-18 18:23:40 +02:00
for ( i = 0 ; i < DOME_TOURNAMENT_TRAINERS_COUNT / 2 ; i + + )
{
if ( i < 2 )
{
if ( gUnknown_0203CD78 - > arr [ i ] ! = 0xFF )
{
2018-08-20 22:56:05 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . callback = SpriteCb_TrainerIconCardScrollRight ;
2018-08-18 18:23:40 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 0 ] = gTasks [ taskId ] . data [ 2 ] ^ 1 ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 1 ] = 0 ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 2 ] = i ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 3 ] = gUnknown_0203CD78 - > arr [ i ] ;
}
}
else
{
if ( gUnknown_0203CD78 - > arr [ i ] ! = 0xFF )
{
2018-08-20 22:56:05 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . callback = SpriteCb_MonIconCardScrollRight ;
2018-08-18 18:23:40 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 0 ] = gTasks [ taskId ] . data [ 2 ] ^ 1 ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 1 ] = 0 ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 2 ] = i ;
}
}
}
for ( i = DOME_TOURNAMENT_TRAINERS_COUNT / 2 ; i < DOME_TOURNAMENT_TRAINERS_COUNT ; i + + )
{
if ( i < 10 )
{
if ( gUnknown_0203CD78 - > arr [ i ] ! = 0xFF )
{
2018-08-20 22:56:05 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . callback = SpriteCb_TrainerIconCardScrollRight ;
2018-08-18 18:23:40 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 0 ] = gTasks [ taskId ] . data [ 2 ] ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 1 ] = 0 ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 2 ] = i ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 3 ] = gUnknown_0203CD78 - > arr [ i ] ;
}
}
else
{
if ( gUnknown_0203CD78 - > arr [ i ] ! = 0xFF )
{
2018-08-20 22:56:05 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . callback = SpriteCb_MonIconCardScrollRight ;
2018-08-18 18:23:40 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 0 ] = gTasks [ taskId ] . data [ 2 ] ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 1 ] = 0 ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 2 ] = i ;
}
}
}
gTasks [ taskId ] . data [ 0 ] = 7 ;
gTasks [ taskId ] . data [ 5 ] = 0 ;
break ;
case 8 :
if ( gTasks [ taskId ] . data [ 2 ] )
{
gBattle_BG0_X = 0 ;
gBattle_BG0_Y = 0 ;
gBattle_BG1_X = - 256 ;
gBattle_BG1_Y = 0 ;
}
else
{
gBattle_BG0_X = - 256 ;
gBattle_BG0_Y = 0 ;
gBattle_BG1_X = 0 ;
gBattle_BG1_Y = 0 ;
}
if ( gUnknown_0203CD78 - > unk_10 = = 2 )
{
gBattle_BG2_X = 256 ;
gBattle_BG2_Y = 160 ;
2018-08-19 20:21:37 +02:00
trainerTournamentId = gUnknown_0203CD78 - > unk_11 [ 1 ] ;
DisplayTrainerInfoOnCard ( gTasks [ taskId ] . data [ 2 ] | 2 , trainerTournamentId ) ;
2018-08-18 18:23:40 +02:00
}
else
{
gBattle_BG2_X = 0 ;
gBattle_BG2_Y = 160 ;
2018-08-20 22:56:05 +02:00
matchNo = gTasks [ taskId2 ] . data [ 1 ] - 16 ;
2018-08-21 23:36:59 +02:00
DisplayMatchInfoOnCard ( gTasks [ taskId ] . data [ 2 ] | 2 , matchNo ) ;
2018-08-18 18:23:40 +02:00
}
for ( i = 0 ; i < DOME_TOURNAMENT_TRAINERS_COUNT / 2 ; i + + )
{
if ( i < 2 )
{
if ( gUnknown_0203CD78 - > arr [ i ] ! = 0xFF )
{
2018-08-20 22:56:05 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . callback = SpriteCb_TrainerIconCardScrollRight ;
2018-08-18 18:23:40 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 0 ] = gTasks [ taskId ] . data [ 2 ] ^ 1 ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 1 ] = 0 ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 2 ] = i ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 3 ] = gUnknown_0203CD78 - > arr [ i ] ;
}
}
else
{
if ( gUnknown_0203CD78 - > arr [ i ] ! = 0xFF )
{
2018-08-20 22:56:05 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . callback = SpriteCb_MonIconCardScrollRight ;
2018-08-18 18:23:40 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 0 ] = gTasks [ taskId ] . data [ 2 ] ^ 1 ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 1 ] = 0 ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 2 ] = i ;
}
}
}
for ( i = DOME_TOURNAMENT_TRAINERS_COUNT / 2 ; i < DOME_TOURNAMENT_TRAINERS_COUNT ; i + + )
{
if ( i < 10 )
{
if ( gUnknown_0203CD78 - > arr [ i ] ! = 0xFF )
{
2018-08-20 22:56:05 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . callback = SpriteCb_TrainerIconCardScrollRight ;
2018-08-18 18:23:40 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 0 ] = gTasks [ taskId ] . data [ 2 ] ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 1 ] = 0 ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 2 ] = i ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 3 ] = gUnknown_0203CD78 - > arr [ i ] ;
}
}
else
{
if ( gUnknown_0203CD78 - > arr [ i ] ! = 0xFF )
{
2018-08-20 22:56:05 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . callback = SpriteCb_MonIconCardScrollRight ;
2018-08-18 18:23:40 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 0 ] = gTasks [ taskId ] . data [ 2 ] ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 1 ] = 0 ;
gSprites [ gUnknown_0203CD78 - > arr [ i ] ] . data [ 2 ] = i ;
}
}
}
gTasks [ taskId ] . data [ 0 ] = 7 ;
gTasks [ taskId ] . data [ 5 ] = 0 ;
break ;
}
break ;
case 4 :
if ( + + gTasks [ taskId ] . data [ 5 ] ! = 41 )
{
gBattle_BG0_Y - = 4 ;
gBattle_BG1_Y - = 4 ;
gBattle_BG2_Y - = 4 ;
}
else
{
gTasks [ taskId ] . data [ 0 ] = 2 ;
}
break ;
case 5 :
if ( + + gTasks [ taskId ] . data [ 5 ] ! = 41 )
{
gBattle_BG0_Y + = 4 ;
gBattle_BG1_Y + = 4 ;
gBattle_BG2_Y + = 4 ;
}
else
{
gTasks [ taskId ] . data [ 0 ] = 2 ;
}
break ;
case 6 :
if ( + + gTasks [ taskId ] . data [ 5 ] ! = 65 )
{
gBattle_BG0_X - = 4 ;
gBattle_BG1_X - = 4 ;
gBattle_BG2_X - = 4 ;
}
else
{
gTasks [ taskId ] . data [ 0 ] = 2 ;
}
break ;
case 7 :
if ( + + gTasks [ taskId ] . data [ 5 ] ! = 65 )
{
gBattle_BG0_X + = 4 ;
gBattle_BG1_X + = 4 ;
gBattle_BG2_X + = 4 ;
}
else
{
gTasks [ taskId ] . data [ 0 ] = 2 ;
}
break ;
case 8 :
if ( ! gPaletteFade . active )
{
for ( i = 0 ; i < DOME_TOURNAMENT_TRAINERS_COUNT / 2 ; i + + )
{
if ( i < 2 )
{
if ( gUnknown_0203CD78 - > arr [ i ] ! = 0xFF )
2018-08-19 01:06:10 +02:00
FreeAndDestroyTrainerPicSprite ( gUnknown_0203CD78 - > arr [ i ] ) ;
2018-08-18 18:23:40 +02:00
}
else
{
if ( gUnknown_0203CD78 - > arr [ i ] ! = 0xFF )
sub_80D2EF8 ( & gSprites [ gUnknown_0203CD78 - > arr [ i ] ] ) ;
}
}
for ( i = DOME_TOURNAMENT_TRAINERS_COUNT / 2 ; i < DOME_TOURNAMENT_TRAINERS_COUNT ; i + + )
{
if ( i < 10 )
{
if ( gUnknown_0203CD78 - > arr [ i ] ! = 0xFF )
2018-08-19 01:06:10 +02:00
FreeAndDestroyTrainerPicSprite ( gUnknown_0203CD78 - > arr [ i ] ) ;
2018-08-18 18:23:40 +02:00
}
else
{
if ( gUnknown_0203CD78 - > arr [ i ] ! = 0xFF )
sub_80D2EF8 ( & gSprites [ gUnknown_0203CD78 - > arr [ i ] ] ) ;
}
}
FreeMonIconPalettes ( ) ;
FREE_AND_SET_NULL ( gUnknown_0203CD78 ) ;
FreeAllWindowBuffers ( ) ;
if ( r9 = = 0 )
{
SetMainCallback2 ( CB2_ReturnToFieldContinueScriptPlayMapMusic ) ;
}
else
{
i = CreateTask ( sub_8194220 , 0 ) ;
gTasks [ i ] . data [ 0 ] = 0 ;
gTasks [ i ] . data [ 1 ] = 0 ;
gTasks [ i ] . data [ 2 ] = 3 ;
gTasks [ i ] . data [ 3 ] = gTasks [ taskId ] . data [ 4 ] ;
gTasks [ i ] . data [ 4 ] = gTasks [ taskId2 ] . data [ 6 ] ;
}
DestroyTask ( taskId ) ;
}
break ;
}
}
2018-08-18 19:52:25 +02:00
u8 sub_819221C ( u8 taskId )
{
u8 retVal = 0 ;
s32 taskId2 = gTasks [ taskId ] . data [ 4 ] ;
s32 r5 = gTasks [ taskId2 ] . data [ 1 ] ;
u8 r10 = gUnknown_0860D080 [ r5 ] ;
u16 roundId = gSaveBlock2Ptr - > frontier . field_CB2 ;
if ( gMain . newKeys & ( A_BUTTON | B_BUTTON ) )
retVal = 9 ;
2018-08-19 01:06:10 +02:00
if ( gTasks [ taskId ] . data [ 3 ] = = 0 )
return retVal ;
if ( gTasks [ taskId ] . data [ 3 ] = = 1 )
2018-08-18 19:52:25 +02:00
{
2018-08-19 01:06:10 +02:00
if ( gMain . newKeys & DPAD_UP & & gUnknown_0203CD78 - > unk_10 = = 0 )
2018-08-18 19:52:25 +02:00
{
2018-08-19 01:06:10 +02:00
if ( r5 = = 0 )
r5 = 15 ;
else
r5 - - ;
retVal = 1 ;
2018-08-18 19:52:25 +02:00
}
2018-08-19 01:06:10 +02:00
else if ( gMain . newKeys & DPAD_DOWN & & gUnknown_0203CD78 - > unk_10 = = 0 )
2018-08-18 19:52:25 +02:00
{
2018-08-19 01:06:10 +02:00
if ( r5 = = 15 )
r5 = 0 ;
else
r5 + + ;
retVal = 2 ;
}
else if ( gMain . newKeys & DPAD_LEFT & & gUnknown_0203CD78 - > unk_10 ! = 0 )
{
gUnknown_0203CD78 - > unk_10 - - ;
retVal = 3 ;
}
else if ( gMain . newKeys & DPAD_RIGHT )
{
if ( gSaveBlock2Ptr - > frontier . domeTrainers [ r10 ] . unk1 & & gUnknown_0203CD78 - > unk_10 - 1 < gSaveBlock2Ptr - > frontier . domeTrainers [ r10 ] . unk2 )
2018-08-18 19:52:25 +02:00
{
2018-08-19 01:06:10 +02:00
gUnknown_0203CD78 - > unk_10 + + ;
retVal = 4 ;
2018-08-18 19:52:25 +02:00
}
2018-08-19 01:06:10 +02:00
if ( ! gSaveBlock2Ptr - > frontier . domeTrainers [ r10 ] . unk1 & & gUnknown_0203CD78 - > unk_10 - 1 < roundId )
2018-08-18 19:52:25 +02:00
{
gUnknown_0203CD78 - > unk_10 + + ;
2018-08-19 01:06:10 +02:00
retVal = 4 ;
2018-08-18 19:52:25 +02:00
}
2018-08-19 01:06:10 +02:00
}
2018-08-18 19:52:25 +02:00
2018-08-19 01:06:10 +02:00
if ( retVal = = 9 )
{
if ( gUnknown_0203CD78 - > unk_10 ! = 0 )
gTasks [ taskId2 ] . data [ 1 ] = gUnknown_0860D1A0 [ ( r5 / 2 ) * 4 + ( gUnknown_0203CD78 - > unk_10 - 1 ) ] ;
else
gTasks [ taskId2 ] . data [ 1 ] = r5 ;
}
}
else
{
if ( gMain . newKeys & DPAD_UP & & gUnknown_0203CD78 - > unk_10 = = 1 )
{
if ( r5 = = 16 )
r5 = gUnknown_0860D19C [ roundId ] ;
else
r5 - - ;
retVal = 5 ;
}
else if ( gMain . newKeys & DPAD_DOWN & & gUnknown_0203CD78 - > unk_10 = = 1 )
{
if ( r5 = = gUnknown_0860D19C [ roundId ] )
r5 = 16 ;
else
r5 + + ;
retVal = 6 ;
}
else if ( gMain . newKeys & DPAD_LEFT & & gUnknown_0203CD78 - > unk_10 ! = 0 )
{
retVal = 7 ;
gUnknown_0203CD78 - > unk_10 - - ;
}
else if ( gMain . newKeys & DPAD_RIGHT & & ( gUnknown_0203CD78 - > unk_10 = = 0 | | gUnknown_0203CD78 - > unk_10 = = 1 ) )
{
retVal = 8 ;
gUnknown_0203CD78 - > unk_10 + + ;
2018-08-18 19:52:25 +02:00
}
2018-08-19 01:06:10 +02:00
if ( retVal = = 9 )
2018-08-18 19:52:25 +02:00
{
2018-08-19 01:06:10 +02:00
if ( gUnknown_0203CD78 - > unk_10 = = 0 )
gTasks [ taskId2 ] . data [ 1 ] = gUnknown_0860D1C0 [ gUnknown_0203CD78 - > unk_11 [ 0 ] ] ;
else if ( gUnknown_0203CD78 - > unk_10 = = 2 )
gTasks [ taskId2 ] . data [ 1 ] = gUnknown_0860D1C0 [ gUnknown_0203CD78 - > unk_11 [ 1 ] ] ;
else
gTasks [ taskId2 ] . data [ 1 ] = r5 ;
2018-08-18 19:52:25 +02:00
}
}
2018-08-19 01:06:10 +02:00
if ( retVal ! = 0 & & retVal ! = 9 )
{
PlaySE ( SE_SELECT ) ;
gTasks [ taskId2 ] . data [ 1 ] = r5 ;
gTasks [ taskId ] . data [ 2 ] ^ = 1 ;
}
2018-08-18 19:52:25 +02:00
return retVal ;
}
2018-08-19 01:06:10 +02:00
2018-08-19 20:21:37 +02:00
static void DisplayTrainerInfoOnCard ( u8 flags , u8 trainerTournamentId )
2018-08-19 01:06:10 +02:00
{
2018-08-19 17:13:05 +02:00
struct TextSubPrinter textPrinter ;
2018-08-19 20:21:37 +02:00
s32 i , j , k ;
s32 trainerId = 0 ;
u8 nature = 0 ;
s32 arrId = 0 ;
s32 windowId = 0 ;
s32 x = 0 , y = 0 ;
u8 palSlot = 0 ;
s16 * allocatedArray = AllocZeroed ( sizeof ( s16 ) * 18 ) ;
2018-08-19 17:13:05 +02:00
trainerId = gSaveBlock2Ptr - > frontier . domeTrainers [ trainerTournamentId ] . trainerId ;
2018-08-19 20:21:37 +02:00
if ( flags & 1 )
arrId = 8 , windowId = 9 , palSlot = 2 ;
if ( flags & 2 )
2018-08-19 17:13:05 +02:00
x = 256 ;
2018-08-19 20:21:37 +02:00
if ( flags & 4 )
2018-08-19 17:13:05 +02:00
y = 160 ;
2018-08-19 20:21:37 +02:00
if ( flags & 8 )
2018-08-19 17:13:05 +02:00
x = - 256 ;
2018-08-19 20:21:37 +02:00
if ( flags & 0x10 )
2018-08-19 17:13:05 +02:00
y = - 160 ;
if ( trainerId = = TRAINER_PLAYER )
2018-08-19 20:21:37 +02:00
gUnknown_0203CD78 - > arr [ arrId ] = CreateTrainerPicSprite ( PlayerGenderToFrontTrainerPicId ( gSaveBlock2Ptr - > playerGender ) , TRUE , x + 48 , y + 64 , palSlot + 12 , 0xFFFF ) ;
2018-08-19 17:13:05 +02:00
else if ( trainerId = = TRAINER_FRONTIER_BRAIN )
2018-08-19 20:21:37 +02:00
gUnknown_0203CD78 - > arr [ arrId ] = CreateTrainerPicSprite ( GetDomeBrainTrainerPicId ( ) , TRUE , x + 48 , y + 64 , palSlot + 12 , 0xFFFF ) ;
2018-08-19 17:13:05 +02:00
else
2018-08-19 20:21:37 +02:00
gUnknown_0203CD78 - > arr [ arrId ] = CreateTrainerPicSprite ( GetFrontierTrainerFrontSpriteId ( trainerId ) , TRUE , x + 48 , y + 64 , palSlot + 12 , 0xFFFF ) ;
2018-08-19 17:13:05 +02:00
2018-08-19 20:21:37 +02:00
if ( flags & 0x1E )
gSprites [ gUnknown_0203CD78 - > arr [ arrId ] ] . invisible = 1 ;
2018-08-19 17:13:05 +02:00
for ( i = 0 ; i < 3 ; i + + )
{
if ( trainerId = = TRAINER_PLAYER )
2018-08-19 20:21:37 +02:00
{
gUnknown_0203CD78 - > arr [ 2 + i + arrId ] = CreateMonIcon ( gSaveBlock2Ptr - > frontier . domeMonId [ trainerTournamentId ] [ i ] ,
2018-08-20 22:56:05 +02:00
SpriteCb_MonIcon ,
2018-08-19 17:13:05 +02:00
x | gUnknown_0860D340 [ i ] ,
y + gUnknown_0860D343 [ i ] ,
0 , 0 , TRUE ) ;
2018-08-19 20:21:37 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ 2 + i + arrId ] ] . oam . priority = 0 ;
}
2018-08-19 17:13:05 +02:00
else if ( trainerId = = TRAINER_FRONTIER_BRAIN )
2018-08-19 20:21:37 +02:00
{
gUnknown_0203CD78 - > arr [ 2 + i + arrId ] = CreateMonIcon ( gSaveBlock2Ptr - > frontier . domeMonId [ trainerTournamentId ] [ i ] ,
2018-08-20 22:56:05 +02:00
SpriteCb_MonIcon ,
2018-08-19 17:13:05 +02:00
x | gUnknown_0860D340 [ i ] ,
y + gUnknown_0860D343 [ i ] ,
0 , 0 , TRUE ) ;
2018-08-19 20:21:37 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ 2 + i + arrId ] ] . oam . priority = 0 ;
}
2018-08-19 17:13:05 +02:00
else
2018-08-19 20:21:37 +02:00
{
gUnknown_0203CD78 - > arr [ 2 + i + arrId ] = CreateMonIcon ( gFacilityTrainerMons [ gSaveBlock2Ptr - > frontier . domeMonId [ trainerTournamentId ] [ i ] ] . species ,
2018-08-20 22:56:05 +02:00
SpriteCb_MonIcon ,
2018-08-19 17:13:05 +02:00
x | gUnknown_0860D340 [ i ] ,
y + gUnknown_0860D343 [ i ] ,
0 , 0 , TRUE ) ;
2018-08-19 20:21:37 +02:00
gSprites [ gUnknown_0203CD78 - > arr [ 2 + i + arrId ] ] . oam . priority = 0 ;
}
if ( flags & 0x1E )
gSprites [ gUnknown_0203CD78 - > arr [ 2 + i + arrId ] ] . invisible = 1 ;
2018-08-19 17:13:05 +02:00
}
textPrinter . fontId = 2 ;
textPrinter . x = 0 ;
textPrinter . y = 0 ;
2018-08-19 20:21:37 +02:00
textPrinter . currentX = textPrinter . x ;
textPrinter . currentY = textPrinter . y ;
2018-08-19 17:13:05 +02:00
textPrinter . letterSpacing = 2 ;
textPrinter . lineSpacing = 0 ;
textPrinter . fontColor_l = 0 ;
textPrinter . fgColor = 14 ;
textPrinter . bgColor = 0 ;
textPrinter . shadowColor = 13 ;
i = 0 ;
if ( trainerId = = TRAINER_PLAYER )
j = gFacilityClassToTrainerClass [ FACILITY_CLASS_PKMN_TRAINER_BRENDAN ] ;
else if ( trainerId = = TRAINER_FRONTIER_BRAIN )
j = GetDomeBrainTrainerClass ( ) ;
else
j = GetFrontierOpponentClass ( trainerId ) ;
for ( ; gTrainerClassNames [ j ] [ i ] ! = EOS ; i + + )
gStringVar1 [ i ] = gTrainerClassNames [ j ] [ i ] ;
gStringVar1 [ i ] = CHAR_SPACE ;
gStringVar1 [ i + 1 ] = EOS ;
if ( trainerId = = TRAINER_PLAYER )
{
StringAppend ( gStringVar1 , gSaveBlock2Ptr - > playerName ) ;
}
else if ( trainerId = = TRAINER_FRONTIER_BRAIN )
{
CopyDomeBrainTrainerName ( gStringVar2 ) ;
StringAppend ( gStringVar1 , gStringVar2 ) ;
}
else
{
2018-08-25 11:55:16 +02:00
CopyDomeTrainerName ( gStringVar2 , trainerId ) ;
2018-08-19 17:13:05 +02:00
StringAppend ( gStringVar1 , gStringVar2 ) ;
}
textPrinter . currentX = GetStringCenterAlignXOffsetWithLetterSpacing ( textPrinter . fontId , gStringVar1 , 0xD0 , textPrinter . letterSpacing ) ;
textPrinter . current_text_offset = gStringVar1 ;
textPrinter . windowId = windowId ;
PutWindowTilemap ( windowId ) ;
CopyWindowToVram ( windowId , 3 ) ;
AddTextPrinter ( & textPrinter , 0 , NULL ) ;
textPrinter . letterSpacing = 0 ;
for ( i = 0 ; i < 3 ; i + + )
{
textPrinter . currentY = gUnknown_0860D346 [ i ] ;
if ( trainerId = = TRAINER_PLAYER )
textPrinter . current_text_offset = gSpeciesNames [ gSaveBlock2Ptr - > frontier . domeMonId [ trainerTournamentId ] [ i ] ] ;
else if ( trainerId = = TRAINER_FRONTIER_BRAIN )
textPrinter . current_text_offset = gSpeciesNames [ gSaveBlock2Ptr - > frontier . domeMonId [ trainerTournamentId ] [ i ] ] ;
else
textPrinter . current_text_offset = gSpeciesNames [ gFacilityTrainerMons [ gSaveBlock2Ptr - > frontier . domeMonId [ trainerTournamentId ] [ i ] ] . species ] ;
2018-08-19 20:21:37 +02:00
textPrinter . windowId = 1 + i + windowId ;
2018-08-19 17:13:05 +02:00
if ( i = = 1 )
textPrinter . currentX = 7 ;
else
textPrinter . currentX = 0 ;
2018-08-19 20:21:37 +02:00
PutWindowTilemap ( 1 + i + windowId ) ;
CopyWindowToVram ( 1 + i + windowId , 3 ) ;
2018-08-19 17:13:05 +02:00
AddTextPrinter ( & textPrinter , 0 , NULL ) ;
}
PutWindowTilemap ( windowId + 4 ) ;
CopyWindowToVram ( windowId + 4 , 3 ) ;
if ( trainerId = = TRAINER_FRONTIER_BRAIN )
textPrinter . current_text_offset = gBattleDomePotentialPointers [ 16 ] ;
else
textPrinter . current_text_offset = gBattleDomePotentialPointers [ trainerTournamentId ] ;
textPrinter . fontId = 1 ;
textPrinter . windowId = windowId + 4 ;
textPrinter . currentX = 0 ;
textPrinter . y = 4 ;
textPrinter . currentY = 4 ;
AddTextPrinter ( & textPrinter , 0 , NULL ) ;
for ( i = 0 ; i < 3 ; i + + )
{
for ( j = 0 ; j < 4 ; j + + )
{
for ( k = 0 ; k < DOME_TOURNAMENT_TRAINERS_COUNT ; k + + )
{
if ( trainerId = = TRAINER_FRONTIER_BRAIN )
2018-08-19 22:26:07 +02:00
allocatedArray [ k ] + = sMovePoints [ sub_81A5060 ( i , j ) ] [ k ] ;
2018-08-19 17:13:05 +02:00
else if ( trainerId = = TRAINER_PLAYER )
2018-08-19 22:26:07 +02:00
allocatedArray [ k ] + = sMovePoints [ gSaveBlock2Ptr - > frontier . field_EFC [ i ] . moves [ j ] ] [ k ] ;
2018-08-19 17:13:05 +02:00
else
2018-08-19 22:26:07 +02:00
allocatedArray [ k ] + = sMovePoints [ gFacilityTrainerMons [ gSaveBlock2Ptr - > frontier . domeMonId [ trainerTournamentId ] [ i ] ] . moves [ j ] ] [ k ] ;
2018-08-19 17:13:05 +02:00
}
}
}
for ( i = 0 ; i < ARRAY_COUNT ( gUnknown_0860C988 ) ; i + + )
{
s32 r4 = 0 ;
for ( k = 0 , j = 0 ; j < DOME_TOURNAMENT_TRAINERS_COUNT ; j + + )
{
if ( gUnknown_0860C988 [ i ] [ j ] ! = 0 )
{
r4 + + ;
if ( allocatedArray [ j ] ! = 0 & & allocatedArray [ j ] > = gUnknown_0860C988 [ i ] [ j ] )
k + + ;
}
}
if ( r4 = = k )
break ;
}
textPrinter . current_text_offset = gBattleDomeOpponentStylePointers [ i ] ;
textPrinter . y = 20 ;
textPrinter . currentY = 20 ;
AddTextPrinter ( & textPrinter , 0 , NULL ) ;
for ( i = 0 ; i < 18 ; i + + )
allocatedArray [ i ] = 0 ;
if ( trainerId = = TRAINER_FRONTIER_BRAIN | | trainerId = = TRAINER_PLAYER )
{
for ( i = 0 ; i < 3 ; i + + )
{
for ( j = 0 ; j < 6 ; j + + )
{
if ( trainerId = = TRAINER_FRONTIER_BRAIN )
allocatedArray [ j ] = sub_81A50F0 ( i , j ) ;
else
allocatedArray [ j ] = gSaveBlock2Ptr - > frontier . field_EFC [ i ] . evs [ j ] ;
}
allocatedArray [ 6 ] + = allocatedArray [ 0 ] ;
for ( j = 0 ; j < 5 ; j + + )
{
if ( trainerId = = TRAINER_FRONTIER_BRAIN )
nature = sub_81A50B0 ( i ) ;
else
nature = gSaveBlock2Ptr - > frontier . field_EFC [ i ] . nature ;
if ( gNatureStatTable [ nature ] [ j ] > 0 )
{
allocatedArray [ j + 7 ] + = ( allocatedArray [ j + 1 ] * 110 ) / 100 ;
}
else if ( gNatureStatTable [ nature ] [ j ] < 0 )
{
allocatedArray [ j + 7 ] + = ( allocatedArray [ j + 1 ] * 90 ) / 100 ;
allocatedArray [ j + 13 ] + + ;
}
else
{
allocatedArray [ j + 7 ] + = allocatedArray [ j + 1 ] ;
}
}
}
for ( j = 0 , i = 0 ; i < 6 ; i + + )
j + = allocatedArray [ 6 + i ] ;
for ( i = 0 ; i < 6 ; i + + )
allocatedArray [ i ] = ( allocatedArray [ 6 + i ] * 100 ) / j ;
}
else
{
for ( i = 0 ; i < 3 ; i + + )
{
s32 evBits = gFacilityTrainerMons [ gSaveBlock2Ptr - > frontier . domeMonId [ trainerTournamentId ] [ i ] ] . evSpread ;
for ( k = 0 , j = 0 ; j < 6 ; j + + )
{
allocatedArray [ j ] = 0 ;
if ( evBits & 1 )
k + + ;
evBits > > = 1 ;
}
k = 510 / k ;
evBits = gFacilityTrainerMons [ gSaveBlock2Ptr - > frontier . domeMonId [ trainerTournamentId ] [ i ] ] . evSpread ;
for ( j = 0 ; j < 6 ; j + + )
{
if ( evBits & 1 )
allocatedArray [ j ] = k ;
evBits > > = 1 ;
}
allocatedArray [ 6 ] + = allocatedArray [ 0 ] ;
for ( j = 0 ; j < 5 ; j + + )
{
nature = gFacilityTrainerMons [ gSaveBlock2Ptr - > frontier . domeMonId [ trainerTournamentId ] [ i ] ] . nature ;
if ( gNatureStatTable [ nature ] [ j ] > 0 )
{
allocatedArray [ j + 7 ] + = ( allocatedArray [ j + 1 ] * 110 ) / 100 ;
}
else if ( gNatureStatTable [ nature ] [ j ] < 0 )
{
allocatedArray [ j + 7 ] + = ( allocatedArray [ j + 1 ] * 90 ) / 100 ;
allocatedArray [ j + 13 ] + + ;
}
else
{
allocatedArray [ j + 7 ] + = allocatedArray [ j + 1 ] ;
}
}
}
for ( j = 0 , i = 0 ; i < 6 ; i + + )
j + = allocatedArray [ i + 6 ] ;
for ( i = 0 ; i < 6 ; i + + )
allocatedArray [ i ] = ( allocatedArray [ 6 + i ] * 100 ) / j ;
}
for ( i = 0 , j = 0 , k = 0 ; k < 6 ; k + + )
{
if ( allocatedArray [ k ] > 29 )
{
if ( i = = 2 )
{
if ( allocatedArray [ 6 ] < allocatedArray [ k ] )
{
if ( allocatedArray [ 7 ] < allocatedArray [ k ] )
{
if ( allocatedArray [ 6 ] < allocatedArray [ 7 ] )
{
2018-08-19 20:21:37 +02:00
allocatedArray [ 6 ] = allocatedArray [ 7 ] ;
2018-08-19 17:13:05 +02:00
allocatedArray [ 7 ] = k ;
}
else
{
allocatedArray [ 7 ] = k ;
}
}
else
{
2018-08-19 20:21:37 +02:00
allocatedArray [ 6 ] = allocatedArray [ 7 ] ;
2018-08-19 17:13:05 +02:00
allocatedArray [ 7 ] = k ;
}
}
else
{
if ( allocatedArray [ 7 ] < allocatedArray [ k ] )
allocatedArray [ 7 ] = k ;
}
}
else
{
2018-08-19 20:21:37 +02:00
allocatedArray [ i + 6 ] = k ;
2018-08-19 17:13:05 +02:00
i + + ;
}
}
if ( allocatedArray [ k ] = = 0 )
{
if ( j = = 2 )
{
if ( allocatedArray [ k + 12 ] > = 2
2018-08-19 20:21:37 +02:00
| | ( ( allocatedArray [ k + 12 ] = = 1 & & allocatedArray [ 12 + allocatedArray [ 8 ] ] = = 0 & & allocatedArray [ 12 + allocatedArray [ 9 ] ] = = 0 )
2018-08-19 17:13:05 +02:00
)
)
{
allocatedArray [ 8 ] = allocatedArray [ 9 ] ;
allocatedArray [ 9 ] = k ;
}
else if ( allocatedArray [ k + 12 ] = = 1 & & allocatedArray [ 12 + allocatedArray [ 8 ] ] = = 0 )
{
allocatedArray [ 8 ] = allocatedArray [ 9 ] ;
allocatedArray [ 9 ] = k ;
}
else if ( allocatedArray [ k + 12 ] = = 1 & & allocatedArray [ 12 + allocatedArray [ 9 ] ] = = 0 )
{
allocatedArray [ 9 ] = k ;
}
}
else
{
allocatedArray [ j + 8 ] = k ;
j + + ;
}
}
}
if ( i = = 2 )
i = gUnknown_0860D349 [ allocatedArray [ 6 ] ] + ( allocatedArray [ 7 ] - ( allocatedArray [ 6 ] + 1 ) ) ;
else if ( i = = 1 )
i = allocatedArray [ 6 ] + 15 ;
else if ( j = = 2 )
i = gUnknown_0860D349 [ allocatedArray [ 8 ] ] + ( allocatedArray [ 9 ] - ( allocatedArray [ 8 ] + 1 ) ) + 21 ;
else if ( j = = 1 )
i = allocatedArray [ 8 ] + 36 ;
else
i = 42 ;
2018-08-19 01:06:10 +02:00
2018-08-19 17:13:05 +02:00
textPrinter . current_text_offset = gBattleDomeOpponentStatsPointers [ i ] ;
textPrinter . y = 36 ;
textPrinter . currentY = 36 ;
AddTextPrinter ( & textPrinter , 0 , NULL ) ;
Free ( allocatedArray ) ;
2018-08-19 01:06:10 +02:00
}
2018-08-19 22:26:07 +02:00
s32 sub_8192F08 ( u8 arg0 , u8 * arg1 )
{
s32 i ;
u8 tournamentId ;
s32 retVal = 0 ;
s32 count = 0 ;
for ( i = gUnknown_0860D3C4 [ arg0 ] [ 0 ] ; i < gUnknown_0860D3C4 [ arg0 ] [ 0 ] + gUnknown_0860D3C4 [ arg0 ] [ 1 ] ; i + + )
{
tournamentId = gUnknown_0860D3B4 [ i ] ;
if ( ! gSaveBlock2Ptr - > frontier . domeTrainers [ tournamentId ] . unk1 )
{
arg1 [ count ] = tournamentId ;
if ( gSaveBlock2Ptr - > frontier . domeTrainers [ tournamentId ] . trainerId = = TRAINER_PLAYER )
StringCopy ( gStringVar1 , gSaveBlock2Ptr - > playerName ) ;
else if ( gSaveBlock2Ptr - > frontier . domeTrainers [ tournamentId ] . trainerId = = TRAINER_FRONTIER_BRAIN )
CopyDomeBrainTrainerName ( gStringVar1 ) ;
else
2018-08-25 11:55:16 +02:00
CopyDomeTrainerName ( gStringVar1 , gSaveBlock2Ptr - > frontier . domeTrainers [ tournamentId ] . trainerId ) ;
2018-08-19 22:26:07 +02:00
count + + ;
}
}
if ( count = = 2 )
return 0 ;
for ( i = gUnknown_0860D3C4 [ arg0 ] [ 0 ] ; i < gUnknown_0860D3C4 [ arg0 ] [ 0 ] + gUnknown_0860D3C4 [ arg0 ] [ 1 ] ; i + + )
{
tournamentId = gUnknown_0860D3B4 [ i ] ;
if ( gSaveBlock2Ptr - > frontier . domeTrainers [ tournamentId ] . unk1
& & gSaveBlock2Ptr - > frontier . domeTrainers [ tournamentId ] . unk2 > = gUnknown_0860D3C4 [ arg0 ] [ 2 ] )
{
arg1 [ count ] = tournamentId ;
count + + ;
if ( gSaveBlock2Ptr - > frontier . domeTrainers [ tournamentId ] . unk2 = = gUnknown_0860D3C4 [ arg0 ] [ 2 ] )
{
StringCopy ( gStringVar2 , gMoveNames [ gSaveBlock2Ptr - > frontier . field_EC0 [ tournamentId ] ] ) ;
retVal = gSaveBlock2Ptr - > frontier . domeTrainers [ tournamentId ] . unk3 * 2 ;
if ( gSaveBlock2Ptr - > frontier . field_EC0 [ tournamentId ] = = 0 & & gSaveBlock2Ptr - > frontier . domeTrainers [ tournamentId ] . unk3 = = 0 )
retVal = 4 ;
}
else
{
if ( gSaveBlock2Ptr - > frontier . domeTrainers [ tournamentId ] . trainerId = = TRAINER_PLAYER )
StringCopy ( gStringVar1 , gSaveBlock2Ptr - > playerName ) ;
else if ( gSaveBlock2Ptr - > frontier . domeTrainers [ tournamentId ] . trainerId = = TRAINER_FRONTIER_BRAIN )
CopyDomeBrainTrainerName ( gStringVar1 ) ;
else
2018-08-25 11:55:16 +02:00
CopyDomeTrainerName ( gStringVar1 , gSaveBlock2Ptr - > frontier . domeTrainers [ tournamentId ] . trainerId ) ;
2018-08-19 22:26:07 +02:00
}
}
if ( count = = 2 )
break ;
}
if ( arg0 = = 14 )
return retVal + 2 ;
else
return retVal + 1 ;
}
2018-08-20 22:56:05 +02:00
2018-08-21 23:36:59 +02:00
static void DisplayMatchInfoOnCard ( u8 flags , u8 matchNo )
2018-08-20 22:56:05 +02:00
{
struct TextSubPrinter textPrinter ;
s32 tournamentIds [ 2 ] ;
s32 trainerIds [ 2 ] ;
bool32 lost [ 2 ] ;
s32 i ;
s32 winStringId = 0 ;
s32 arrId = 0 ;
s32 windowId = 0 ;
s32 x = 0 , y = 0 ;
u8 palSlot = 0 ;
if ( flags & 1 )
arrId = 8 , windowId = 9 , palSlot = 2 ;
if ( flags & 2 )
x = 256 ;
if ( flags & 4 )
y = 160 ;
if ( flags & 8 )
x = - 256 ;
if ( flags & 0x10 )
y = - 160 ;
// Copy trainers information to handy arrays.
winStringId = sub_8192F08 ( matchNo , gUnknown_0203CD78 - > unk_11 ) ;
for ( i = 0 ; i < 2 ; i + + )
{
tournamentIds [ i ] = gUnknown_0203CD78 - > unk_11 [ i ] ;
trainerIds [ i ] = gSaveBlock2Ptr - > frontier . domeTrainers [ tournamentIds [ i ] ] . trainerId ;
if ( gSaveBlock2Ptr - > frontier . domeTrainers [ tournamentIds [ i ] ] . unk2 < = gUnknown_0860D3C4 [ matchNo ] [ 2 ]
& & gSaveBlock2Ptr - > frontier . domeTrainers [ tournamentIds [ i ] ] . unk1 )
lost [ i ] = TRUE ;
else
lost [ i ] = FALSE ;
}
// Draw first trainer sprite.
if ( trainerIds [ 0 ] = = TRAINER_PLAYER )
gUnknown_0203CD78 - > arr [ arrId ] = CreateTrainerPicSprite ( PlayerGenderToFrontTrainerPicId ( gSaveBlock2Ptr - > playerGender ) , TRUE , x + 48 , y + 88 , palSlot + 12 , 0xFFFF ) ;
else if ( trainerIds [ 0 ] = = TRAINER_FRONTIER_BRAIN )
gUnknown_0203CD78 - > arr [ arrId ] = CreateTrainerPicSprite ( GetDomeBrainTrainerPicId ( ) , TRUE , x + 48 , y + 88 , palSlot + 12 , 0xFFFF ) ;
else
gUnknown_0203CD78 - > arr [ arrId ] = CreateTrainerPicSprite ( GetFrontierTrainerFrontSpriteId ( trainerIds [ 0 ] ) , TRUE , x + 48 , y + 88 , palSlot + 12 , 0xFFFF ) ;
if ( flags & 0x1E )
gSprites [ gUnknown_0203CD78 - > arr [ arrId ] ] . invisible = 1 ;
if ( lost [ 0 ] )
gSprites [ gUnknown_0203CD78 - > arr [ arrId ] ] . oam . paletteNum = 3 ;
// Draw second trainer sprite.
if ( trainerIds [ 1 ] = = TRAINER_PLAYER )
gUnknown_0203CD78 - > arr [ 1 + arrId ] = CreateTrainerPicSprite ( PlayerGenderToFrontTrainerPicId ( gSaveBlock2Ptr - > playerGender ) , TRUE , x + 192 , y + 88 , palSlot + 13 , 0xFFFF ) ;
else if ( trainerIds [ 1 ] = = TRAINER_FRONTIER_BRAIN )
gUnknown_0203CD78 - > arr [ 1 + arrId ] = CreateTrainerPicSprite ( GetDomeBrainTrainerPicId ( ) , TRUE , x + 192 , y + 88 , palSlot + 13 , 0xFFFF ) ;
else
gUnknown_0203CD78 - > arr [ 1 + arrId ] = CreateTrainerPicSprite ( GetFrontierTrainerFrontSpriteId ( trainerIds [ 1 ] ) , TRUE , x + 192 , y + 88 , palSlot + 13 , 0xFFFF ) ;
if ( flags & 0x1E )
gSprites [ gUnknown_0203CD78 - > arr [ 1 + arrId ] ] . invisible = 1 ;
if ( lost [ 1 ] )
gSprites [ gUnknown_0203CD78 - > arr [ 1 + arrId ] ] . oam . paletteNum = 3 ;
// Draw first trainer's pokemon icons.
for ( i = 0 ; i < 3 ; i + + )
{
if ( trainerIds [ 0 ] = = TRAINER_PLAYER )
{
gUnknown_0203CD78 - > arr [ 2 + i + arrId ] = CreateMonIcon ( gSaveBlock2Ptr - > frontier . domeMonId [ tournamentIds [ 0 ] ] [ i ] ,
SpriteCb_MonIcon ,
x | gUnknown_0860D3A8 [ i ] ,
y + gUnknown_0860D3AB [ i ] ,
0 , 0 , TRUE ) ;
gSprites [ gUnknown_0203CD78 - > arr [ 2 + i + arrId ] ] . oam . priority = 0 ;
}
else if ( trainerIds [ 0 ] = = TRAINER_FRONTIER_BRAIN )
{
gUnknown_0203CD78 - > arr [ 2 + i + arrId ] = CreateMonIcon ( gSaveBlock2Ptr - > frontier . domeMonId [ tournamentIds [ 0 ] ] [ i ] ,
SpriteCb_MonIcon ,
x | gUnknown_0860D3A8 [ i ] ,
y + gUnknown_0860D3AB [ i ] ,
0 , 0 , TRUE ) ;
gSprites [ gUnknown_0203CD78 - > arr [ 2 + i + arrId ] ] . oam . priority = 0 ;
}
else
{
gUnknown_0203CD78 - > arr [ 2 + i + arrId ] = CreateMonIcon ( gFacilityTrainerMons [ gSaveBlock2Ptr - > frontier . domeMonId [ tournamentIds [ 0 ] ] [ i ] ] . species ,
SpriteCb_MonIcon ,
x | gUnknown_0860D3A8 [ i ] ,
y + gUnknown_0860D3AB [ i ] ,
0 , 0 , TRUE ) ;
gSprites [ gUnknown_0203CD78 - > arr [ 2 + i + arrId ] ] . oam . priority = 0 ;
}
if ( flags & 0x1E )
gSprites [ gUnknown_0203CD78 - > arr [ 2 + i + arrId ] ] . invisible = 1 ;
if ( lost [ 0 ] )
{
gSprites [ gUnknown_0203CD78 - > arr [ 2 + i + arrId ] ] . oam . paletteNum = 3 ;
gSprites [ gUnknown_0203CD78 - > arr [ 2 + i + arrId ] ] . sMonIconStill = TRUE ;
}
}
// Draw second trainer's pokemon icons.
for ( i = 0 ; i < 3 ; i + + )
{
if ( trainerIds [ 1 ] = = TRAINER_PLAYER )
{
gUnknown_0203CD78 - > arr [ 5 + i + arrId ] = CreateMonIcon ( gSaveBlock2Ptr - > frontier . domeMonId [ tournamentIds [ 1 ] ] [ i ] ,
SpriteCb_MonIcon ,
x | gUnknown_0860D3AE [ i ] ,
y + gUnknown_0860D3B1 [ i ] ,
0 , 0 , TRUE ) ;
gSprites [ gUnknown_0203CD78 - > arr [ 5 + i + arrId ] ] . oam . priority = 0 ;
}
else if ( trainerIds [ 1 ] = = TRAINER_FRONTIER_BRAIN )
{
gUnknown_0203CD78 - > arr [ 5 + i + arrId ] = CreateMonIcon ( gSaveBlock2Ptr - > frontier . domeMonId [ tournamentIds [ 1 ] ] [ i ] ,
SpriteCb_MonIcon ,
x | gUnknown_0860D3AE [ i ] ,
y + gUnknown_0860D3B1 [ i ] ,
0 , 0 , TRUE ) ;
gSprites [ gUnknown_0203CD78 - > arr [ 5 + i + arrId ] ] . oam . priority = 0 ;
}
else
{
gUnknown_0203CD78 - > arr [ 5 + i + arrId ] = CreateMonIcon ( gFacilityTrainerMons [ gSaveBlock2Ptr - > frontier . domeMonId [ tournamentIds [ 1 ] ] [ i ] ] . species ,
SpriteCb_MonIcon ,
x | gUnknown_0860D3AE [ i ] ,
y + gUnknown_0860D3B1 [ i ] ,
0 , 0 , TRUE ) ;
gSprites [ gUnknown_0203CD78 - > arr [ 5 + i + arrId ] ] . oam . priority = 0 ;
}
if ( flags & 0x1E )
gSprites [ gUnknown_0203CD78 - > arr [ 5 + i + arrId ] ] . invisible = 1 ;
if ( lost [ 1 ] )
{
gSprites [ gUnknown_0203CD78 - > arr [ 5 + i + arrId ] ] . oam . paletteNum = 3 ;
gSprites [ gUnknown_0203CD78 - > arr [ 5 + i + arrId ] ] . sMonIconStill = TRUE ;
}
}
// Print the win string (or 'Let the battle begin!' one).
textPrinter . x = 0 ;
textPrinter . y = 2 ;
textPrinter . currentX = textPrinter . x ;
textPrinter . currentY = textPrinter . y ;
textPrinter . letterSpacing = 0 ;
textPrinter . lineSpacing = 0 ;
textPrinter . fontColor_l = 0 ;
textPrinter . fgColor = 14 ;
textPrinter . bgColor = 0 ;
textPrinter . shadowColor = 13 ;
StringExpandPlaceholders ( gStringVar4 , gBattleDomeWinStringsPointers [ winStringId ] ) ;
textPrinter . current_text_offset = gStringVar4 ;
textPrinter . windowId = windowId + 8 ;
textPrinter . fontId = 1 ;
PutWindowTilemap ( windowId + 8 ) ;
CopyWindowToVram ( windowId + 8 , 3 ) ;
textPrinter . currentX = 0 ;
textPrinter . currentY = textPrinter . y = 0 ;
AddTextPrinter ( & textPrinter , 0 , NULL ) ;
// Print first trainer's name.
if ( trainerIds [ 0 ] = = TRAINER_PLAYER )
StringCopy ( gStringVar1 , gSaveBlock2Ptr - > playerName ) ;
else if ( trainerIds [ 0 ] = = TRAINER_FRONTIER_BRAIN )
CopyDomeBrainTrainerName ( gStringVar1 ) ;
else
2018-08-25 11:55:16 +02:00
CopyDomeTrainerName ( gStringVar1 , trainerIds [ 0 ] ) ;
2018-08-20 22:56:05 +02:00
textPrinter . fontId = 2 ;
textPrinter . letterSpacing = 2 ;
textPrinter . current_text_offset = gStringVar1 ;
textPrinter . windowId = windowId + 6 ;
textPrinter . currentX = GetStringCenterAlignXOffsetWithLetterSpacing ( textPrinter . fontId , textPrinter . current_text_offset , 0x40 , textPrinter . letterSpacing ) ;
textPrinter . currentY = textPrinter . y = 2 ;
PutWindowTilemap ( windowId + 6 ) ;
CopyWindowToVram ( windowId + 6 , 3 ) ;
AddTextPrinter ( & textPrinter , 0 , NULL ) ;
// Print second trainer's name.
if ( trainerIds [ 1 ] = = TRAINER_PLAYER )
StringCopy ( gStringVar1 , gSaveBlock2Ptr - > playerName ) ;
else if ( trainerIds [ 1 ] = = TRAINER_FRONTIER_BRAIN )
CopyDomeBrainTrainerName ( gStringVar1 ) ;
else
2018-08-25 11:55:16 +02:00
CopyDomeTrainerName ( gStringVar1 , trainerIds [ 1 ] ) ;
2018-08-20 22:56:05 +02:00
textPrinter . current_text_offset = gStringVar1 ;
textPrinter . windowId = windowId + 7 ;
textPrinter . currentX = GetStringCenterAlignXOffsetWithLetterSpacing ( textPrinter . fontId , textPrinter . current_text_offset , 0x40 , textPrinter . letterSpacing ) ;
textPrinter . currentY = textPrinter . y = 2 ;
PutWindowTilemap ( windowId + 7 ) ;
CopyWindowToVram ( windowId + 7 , 3 ) ;
AddTextPrinter ( & textPrinter , 0 , NULL ) ;
// Print match number.
textPrinter . letterSpacing = 0 ;
textPrinter . current_text_offset = gBattleDomeMatchNumberPointers [ matchNo ] ;
textPrinter . windowId = windowId + 5 ;
textPrinter . currentX = GetStringCenterAlignXOffsetWithLetterSpacing ( textPrinter . fontId , textPrinter . current_text_offset , 0xA0 , textPrinter . letterSpacing ) ;
textPrinter . currentY = textPrinter . y = 2 ;
PutWindowTilemap ( windowId + 5 ) ;
CopyWindowToVram ( windowId + 5 , 3 ) ;
AddTextPrinter ( & textPrinter , 0 , NULL ) ;
}
2018-08-21 23:36:59 +02:00
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 ;
2018-08-25 11:55:16 +02:00
SetMainCallback2 ( CB2_BattleDome ) ;
2018-08-21 23:36:59 +02:00
}
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 ;
2018-08-25 11:55:16 +02:00
SetMainCallback2 ( CB2_BattleDome ) ;
2018-08-21 23:36:59 +02:00
}
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 ;
}
2018-08-25 11:55:16 +02:00
void sub_8193D40 ( void )
{
u8 taskId = CreateTask ( sub_8194220 , 0 ) ;
gTasks [ taskId ] . data [ 0 ] = 0 ;
gTasks [ taskId ] . data [ 1 ] = 1 ;
gTasks [ taskId ] . data [ 2 ] = 2 ;
gTasks [ taskId ] . data [ 4 ] = 0 ;
SetMainCallback2 ( CB2_BattleDome ) ;
}
void sub_8193D7C ( void )
{
s32 i ;
if ( gSpecialVar_0x8005 = = 1 )
{
gSaveBlock2Ptr - > frontier . domeTrainers [ TrainerIdToTournamentId ( gTrainerBattleOpponent_A ) ] . unk1 = 1 ;
gSaveBlock2Ptr - > frontier . domeTrainers [ TrainerIdToTournamentId ( gTrainerBattleOpponent_A ) ] . unk2 = gSaveBlock2Ptr - > frontier . field_CB2 ;
gSaveBlock2Ptr - > frontier . field_EC0 [ TrainerIdToTournamentId ( gTrainerBattleOpponent_A ) ] = gBattleResults . lastUsedMovePlayer ;
if ( gSaveBlock2Ptr - > frontier . field_CB2 < DOME_FINAL )
sub_8195438 ( gSaveBlock2Ptr - > frontier . field_CB2 ) ;
}
else
{
gSaveBlock2Ptr - > frontier . domeTrainers [ TrainerIdToTournamentId ( TRAINER_PLAYER ) ] . unk1 = 1 ;
gSaveBlock2Ptr - > frontier . domeTrainers [ TrainerIdToTournamentId ( TRAINER_PLAYER ) ] . unk2 = gSaveBlock2Ptr - > frontier . field_CB2 ;
gSaveBlock2Ptr - > frontier . field_EC0 [ TrainerIdToTournamentId ( TRAINER_PLAYER ) ] = gBattleResults . lastUsedMoveOpponent ;
if ( gBattleOutcome = = B_OUTCOME_FORFEITED | | gSpecialVar_0x8005 = = 9 )
gSaveBlock2Ptr - > frontier . domeTrainers [ TrainerIdToTournamentId ( TRAINER_PLAYER ) ] . unk3 = 1 ;
for ( i = gSaveBlock2Ptr - > frontier . field_CB2 ; i < DOME_ROUNDS_COUNT ; i + + )
sub_8195438 ( i ) ;
}
}
u16 GetWinningMove ( s32 winnerTournamentId , s32 loserTournamentId , u8 roundId )
{
s32 i , j , k ;
s32 moveScores [ 4 * 3 ] ;
u16 moveIds [ 4 * 3 ] ;
u16 bestScore = 0 ;
u16 bestId = 0 ;
s32 movePower = 0 ;
GetFrontierEnemyMonLevel ( ) ; // Unused return variable.
// Calc move points of all 4 moves for all 3 pokemon hitting all 3 target mons.
for ( i = 0 ; i < 3 ; i + + )
{
for ( j = 0 ; j < 4 ; j + + )
{
moveScores [ i * 4 + j ] = 0 ;
if ( gSaveBlock2Ptr - > frontier . domeTrainers [ winnerTournamentId ] . trainerId = = TRAINER_FRONTIER_BRAIN )
moveIds [ i * 4 + j ] = sub_81A5060 ( i , j ) ;
else
moveIds [ i * 4 + j ] = gFacilityTrainerMons [ gSaveBlock2Ptr - > frontier . domeMonId [ winnerTournamentId ] [ i ] ] . moves [ j ] ;
movePower = gBattleMoves [ moveIds [ i * 4 + j ] ] . power ;
if ( movePower = = 0 )
movePower = 40 ;
else if ( movePower = = 1 )
movePower = 60 ;
else if ( moveIds [ i * 4 + j ] = = MOVE_SELF_DESTRUCT | | moveIds [ i * 4 + j ] = = MOVE_EXPLOSION )
movePower / = 2 ;
for ( k = 0 ; k < 3 ; k + + )
{
u32 var = 0 ;
u32 targetSpecies = 0 ;
u32 targetAbility = 0 ;
do
{
var = Random32 ( ) ;
} while ( gFacilityTrainerMons [ gSaveBlock2Ptr - > frontier . domeMonId [ loserTournamentId ] [ k ] ] . nature ! = GetNatureFromPersonality ( var ) ) ;
targetSpecies = gFacilityTrainerMons [ gSaveBlock2Ptr - > frontier . domeMonId [ loserTournamentId ] [ k ] ] . species ;
if ( var & 1 )
targetAbility = gBaseStats [ targetSpecies ] . ability2 ;
else
targetAbility = gBaseStats [ targetSpecies ] . ability1 ;
var = AI_TypeCalc ( moveIds [ i * 4 + j ] , targetSpecies , targetAbility ) ;
if ( var & MOVE_RESULT_NOT_VERY_EFFECTIVE & & var & MOVE_RESULT_SUPER_EFFECTIVE )
moveScores [ i * 4 + j ] + = movePower ;
else if ( var & MOVE_RESULT_NO_EFFECT )
moveScores [ i * 4 + j ] + = 0 ;
else if ( var & MOVE_RESULT_SUPER_EFFECTIVE )
moveScores [ i * 4 + j ] + = movePower * 2 ;
else if ( var & MOVE_RESULT_NOT_VERY_EFFECTIVE )
moveScores [ i * 4 + j ] + = movePower / 2 ;
else
moveScores [ i * 4 + j ] + = movePower ;
}
if ( bestScore < moveScores [ i * 4 + j ] )
{
bestId = i * 4 + j ;
bestScore = moveScores [ i * 4 + j ] ;
}
else if ( bestScore = = moveScores [ i * 4 + j ] )
{
if ( moveIds [ bestId ] < moveIds [ i * 4 + j ] ) // Why not use (Random() & 1) instead of promoting moves with a higher id?
bestId = i * 4 + j ;
}
}
}
j = bestId ;
goto LABEL ;
while ( j ! = 0 )
{
for ( j = 0 , k = 0 ; k < 4 * 3 ; k + + )
{
if ( bestScore < moveScores [ k ] )
{
j = k ;
bestScore = moveScores [ k ] ;
}
else if ( bestScore = = moveScores [ k ] & & moveIds [ j ] < moveIds [ k ] )
{
j = k ;
}
}
if ( i = = roundId - 1 )
break ;
LABEL :
{
for ( i = 0 ; i < roundId - 1 ; i + + )
{
if ( gSaveBlock2Ptr - > frontier . field_EC0 [ sub_81953E8 ( winnerTournamentId , i ) ] = = moveIds [ j ] )
break ;
}
if ( i = = roundId - 1 )
break ;
moveScores [ j ] = 0 ;
bestScore = 0 ;
j = 0 ;
for ( k = 0 ; k < 4 * 3 ; k + + )
j + = moveScores [ k ] ;
}
}
if ( moveScores [ j ] = = 0 )
j = bestId ;
return moveIds [ j ] ;
}
extern const struct BgTemplate gUnknown_0860CE74 [ 4 ] ;
extern const struct WindowTemplate gUnknown_0860CE94 [ ] ;
extern const u8 gUnknown_0860D411 [ ] [ 2 ] ;
extern const struct SpriteTemplate gUnknown_0860CFA8 ;
extern const struct SpriteTemplate gUnknown_0860D008 ;
extern const struct SpriteTemplate gUnknown_0860CFD8 ;
extern const struct ScanlineEffectParams gUnknown_0860CF44 ;
void sub_8194220 ( u8 taskId )
{
s32 i ;
struct TextSubPrinter textPrinter ;
s32 r10 = gTasks [ taskId ] . data [ 1 ] ;
s32 r4 = gTasks [ taskId ] . data [ 2 ] ;
switch ( gTasks [ taskId ] . data [ 0 ] )
{
case 0 :
SetHBlankCallback ( NULL ) ;
SetVBlankCallback ( NULL ) ;
EnableInterrupts ( INTR_FLAG_HBLANK | INTR_FLAG_VBLANK ) ;
CpuFill32 ( 0 , ( void * ) VRAM , VRAM_SIZE ) ;
ResetBgsAndClearDma3BusyFlags ( 0 ) ;
InitBgsFromTemplates ( 0 , gUnknown_0860CE74 , ARRAY_COUNT ( gUnknown_0860CE74 ) ) ;
InitWindows ( gUnknown_0860CE94 ) ;
DeactivateAllTextPrinters ( ) ;
gBattle_BG0_X = 0 ;
gBattle_BG0_Y = 0 ;
gBattle_BG1_X = 0 ;
gBattle_BG1_Y = 0 ;
ChangeBgX ( 2 , 0 , 0 ) ;
ChangeBgY ( 2 , 0 , 0 ) ;
ChangeBgX ( 3 , 0 , 0 ) ;
ChangeBgY ( 3 , 0xB00 , 0 ) ;
gTasks [ taskId ] . data [ 0 ] + + ;
break ;
case 1 :
SetGpuReg ( REG_OFFSET_BLDCNT , 0 ) ;
SetGpuReg ( REG_OFFSET_BLDALPHA , 0 ) ;
SetGpuReg ( REG_OFFSET_BLDY , 0 ) ;
SetGpuReg ( REG_OFFSET_MOSAIC , 0 ) ;
SetGpuReg ( REG_OFFSET_WIN0H , 0x5860 ) ;
SetGpuReg ( REG_OFFSET_WIN0V , 0x9F ) ;
SetGpuReg ( REG_OFFSET_WIN1H , 0x9098 ) ;
SetGpuReg ( REG_OFFSET_WIN1V , 0x9F ) ;
SetGpuReg ( REG_OFFSET_WININ , 0 ) ;
SetGpuReg ( REG_OFFSET_WINOUT , 0x3F ) ;
ResetPaletteFade ( ) ;
ResetSpriteData ( ) ;
FreeAllSpritePalettes ( ) ;
gTasks [ taskId ] . data [ 0 ] + + ;
break ;
case 2 :
gUnknown_0203CD7C = AllocZeroed ( 0x800 ) ;
LZDecompressWram ( gUnknown_08D83900 , gUnknown_0203CD7C ) ;
SetBgTilemapBuffer ( 1 , gUnknown_0203CD7C ) ;
CopyBgTilemapBufferToVram ( 1 ) ;
DecompressAndLoadBgGfxUsingHeap ( 1 , gUnknown_08D82F10 , 0x2000 , 0 , 0 ) ;
DecompressAndLoadBgGfxUsingHeap ( 2 , gUnknown_08D834FC , 0x2000 , 0 , 0 ) ;
DecompressAndLoadBgGfxUsingHeap ( 2 , gUnknown_08D83B2C , 0x2000 , 0 , 1 ) ;
DecompressAndLoadBgGfxUsingHeap ( 3 , gUnknown_08D83C3C , 0x2000 , 0 , 1 ) ;
LoadCompressedPalette ( gUnknown_08D85358 , 0 , 0x200 ) ;
LoadCompressedPalette ( gUnknown_08D85444 , 0x100 , 0x200 ) ;
LoadCompressedPalette ( gUnknown_08D85600 , 0xF0 , 0x20 ) ;
CpuFill32 ( 0 , gPlttBufferFaded , 0x400 ) ;
ShowBg ( 0 ) ;
ShowBg ( 1 ) ;
ShowBg ( 2 ) ;
ShowBg ( 3 ) ;
gTasks [ taskId ] . data [ 0 ] + + ;
break ;
case 3 :
LoadCompressedObjectPic ( gUnknown_0860CF50 ) ;
if ( r10 = = 0 )
{
for ( i = 0 ; i < ( unsigned ) 31 ; i + + )
CreateSprite ( & gUnknown_0860CFA8 , gUnknown_0860D411 [ i ] [ 0 ] , gUnknown_0860D411 [ i ] [ 1 ] , 0 ) ;
if ( gTasks [ taskId ] . data [ 4 ] )
CreateSprite ( & gUnknown_0860D008 , 218 , 12 , 0 ) ;
else
CreateSprite ( & gUnknown_0860CFD8 , 218 , 12 , 0 ) ;
}
SetGpuReg ( REG_OFFSET_DISPCNT , DISPCNT_BG_ALL_ON | DISPCNT_OBJ_ON | DISPCNT_WIN0_ON | DISPCNT_WIN1_ON | DISPCNT_OBJ_1D_MAP ) ;
gTasks [ taskId ] . data [ 0 ] + + ;
break ;
case 4 :
textPrinter . fontId = 2 ;
textPrinter . current_text_offset = gText_BattleTourney ;
textPrinter . windowId = 2 ;
textPrinter . x = 0 ;
textPrinter . y = 0 ;
textPrinter . letterSpacing = 2 ;
textPrinter . lineSpacing = 0 ;
textPrinter . currentX = GetStringCenterAlignXOffsetWithLetterSpacing ( textPrinter . fontId , textPrinter . current_text_offset , 0x70 , textPrinter . letterSpacing ) ;
textPrinter . currentY = 1 ;
textPrinter . fontColor_l = 0 ;
textPrinter . fgColor = 14 ;
textPrinter . bgColor = 0 ;
textPrinter . shadowColor = 13 ;
AddTextPrinter ( & textPrinter , 0 , NULL ) ;
for ( i = 0 ; i < DOME_TOURNAMENT_TRAINERS_COUNT ; i + + )
{
s32 var , var2 ;
CopyDomeTrainerName ( gDisplayedStringBattle , gSaveBlock2Ptr - > frontier . domeTrainers [ i ] . trainerId ) ;
if ( r10 = = 1 )
{
if ( gSaveBlock2Ptr - > frontier . domeTrainers [ i ] . unk1 )
{
if ( gSaveBlock2Ptr - > frontier . domeTrainers [ i ] . unk2 ! = 0 )
{
var2 = gSaveBlock2Ptr - > frontier . domeTrainers [ i ] . unk2 - 1 ;
sub_81948EC ( i , var2 ) ;
}
}
else if ( gSaveBlock2Ptr - > frontier . field_CB2 ! = DOME_ROUND2 )
{
sub_81948EC ( i , gSaveBlock2Ptr - > frontier . field_CB2 - 2 ) ;
}
}
else if ( r10 = = 0 )
{
if ( gSaveBlock2Ptr - > frontier . domeTrainers [ i ] . unk1 )
{
if ( gSaveBlock2Ptr - > frontier . domeTrainers [ i ] . unk2 ! = 0 )
{
var2 = gSaveBlock2Ptr - > frontier . domeTrainers [ i ] . unk2 - 1 ;
sub_81948EC ( i , var2 ) ;
}
}
else if ( gSaveBlock2Ptr - > frontier . field_CB2 ! = DOME_ROUND1 )
{
if ( gTasks [ taskId ] . data [ 4 ] )
var2 = gSaveBlock2Ptr - > frontier . field_CB2 ;
else
var2 = gSaveBlock2Ptr - > frontier . field_CB2 - 1 ;
sub_81948EC ( i , var2 ) ;
}
}
if ( gTasks [ taskId ] . data [ 4 ] )
var = gSaveBlock2Ptr - > frontier . field_CB2 ;
else
var = gSaveBlock2Ptr - > frontier . field_CB2 - 1 ;
if ( ( ( r10 = = 1 & & gSaveBlock2Ptr - > frontier . domeTrainers [ i ] . unk2 < gSaveBlock2Ptr - > frontier . field_CB2 - 1 )
| | ( r10 = = 0 & & gSaveBlock2Ptr - > frontier . domeTrainers [ i ] . unk2 < = var ) )
& & gSaveBlock2Ptr - > frontier . domeTrainers [ i ] . unk1 )
{
if ( gSaveBlock2Ptr - > frontier . domeTrainers [ i ] . trainerId = = TRAINER_PLAYER )
{
textPrinter . fgColor = 3 ;
textPrinter . shadowColor = 4 ;
}
else
{
textPrinter . fgColor = 11 ;
textPrinter . shadowColor = 13 ;
}
}
else
{
if ( gSaveBlock2Ptr - > frontier . domeTrainers [ i ] . trainerId = = TRAINER_PLAYER )
{
textPrinter . fgColor = 3 ;
textPrinter . shadowColor = 4 ;
}
else
{
textPrinter . fgColor = 14 ;
textPrinter . shadowColor = 13 ;
}
}
if ( gUnknown_0860D3F1 [ i ] [ 0 ] = = 0 )
textPrinter . currentX = GetStringWidthDifference ( textPrinter . fontId , gDisplayedStringBattle , 0x3D , textPrinter . letterSpacing ) ;
else
textPrinter . currentX = 3 ;
textPrinter . current_text_offset = gDisplayedStringBattle ;
textPrinter . windowId = gUnknown_0860D3F1 [ i ] [ 0 ] ;
textPrinter . currentY = gUnknown_0860D3F1 [ i ] [ 1 ] ;
AddTextPrinter ( & textPrinter , 0 , NULL ) ;
}
gTasks [ taskId ] . data [ 0 ] + + ;
break ;
case 5 :
PutWindowTilemap ( 0 ) ;
PutWindowTilemap ( 1 ) ;
PutWindowTilemap ( 2 ) ;
CopyWindowToVram ( 0 , 3 ) ;
CopyWindowToVram ( 1 , 3 ) ;
CopyWindowToVram ( 2 , 3 ) ;
SetHBlankCallback ( sub_8194BEC ) ;
SetVBlankCallback ( sub_8194CE4 ) ;
if ( r4 = = 2 )
{
if ( r10 = = 0 )
{
i = CreateTask ( sub_819395C , 0 ) ;
gTasks [ i ] . data [ 0 ] = r10 ;
gTasks [ i ] . data [ 1 ] = r10 ;
gTasks [ i ] . data [ 6 ] = gTasks [ taskId ] . data [ 4 ] ;
}
else
{
i = CreateTask ( sub_8194950 , 0 ) ;
gTasks [ i ] . data [ 0 ] = 0 ;
}
}
else
{
i = gTasks [ taskId ] . data [ 3 ] ;
gTasks [ i ] . data [ 0 ] = 0 ;
}
ScanlineEffect_Clear ( ) ;
for ( i = 0 ; i < 91 ; i + + )
{
gScanlineEffectRegBuffers [ 0 ] [ i ] = 0x1F0A ;
gScanlineEffectRegBuffers [ 1 ] [ i ] = 0x1F0A ;
}
for ( i = 91 ; i < 160 ; i + + )
{
asm ( " " : : " r " ( i ) ) ;
gScanlineEffectRegBuffers [ 0 ] [ i ] = 0x1F09 ;
gScanlineEffectRegBuffers [ 1 ] [ i ] = 0x1F09 ;
}
ScanlineEffect_SetParams ( gUnknown_0860CF44 ) ;
DestroyTask ( taskId ) ;
break ;
}
}
struct UnkStruct_860DD10
{
u8 x ;
u8 y ;
u16 src ;
} ;
extern struct UnkStruct_860DD10 * gUnknown_0860DD10 [ ] [ 4 ] ;
extern const u8 gUnknown_0860DE10 [ ] [ 4 ] ;
void sub_81948EC ( u8 tournamentId , u8 arg1 )
{
s32 i ;
struct UnkStruct_860DD10 * structPtr = gUnknown_0860DD10 [ tournamentId ] [ arg1 ] ;
for ( i = 0 ; i < gUnknown_0860DE10 [ tournamentId ] [ arg1 ] ; i + + )
CopyToBgTilemapBufferRect_ChangePalette ( 1 , & structPtr [ i ] . src , structPtr [ i ] . x , structPtr [ i ] . y , 1 , 1 , 0x11 ) ;
CopyBgTilemapBufferToVram ( 1 ) ;
}
void sub_8194950 ( u8 taskId )
{
s32 i ;
struct TextSubPrinter textPrinter ;
switch ( gTasks [ taskId ] . data [ 0 ] )
{
case 0 :
BeginNormalPaletteFade ( 0xFFFFFFFF , 0 , 0x10 , 0 , 0 ) ;
gTasks [ taskId ] . data [ 0 ] = 1 ;
break ;
case 1 :
if ( ! gPaletteFade . active )
{
gTasks [ taskId ] . data [ 0 ] = 2 ;
gTasks [ taskId ] . data [ 3 ] = 64 ;
textPrinter . fontId = 2 ;
textPrinter . x = 0 ;
textPrinter . y = 0 ;
textPrinter . letterSpacing = 2 ;
textPrinter . lineSpacing = 0 ;
textPrinter . fontColor_l = 0 ;
textPrinter . fgColor = 11 ;
textPrinter . bgColor = 0 ;
textPrinter . shadowColor = 13 ;
for ( i = 0 ; i < DOME_TOURNAMENT_TRAINERS_COUNT ; i + + )
{
CopyDomeTrainerName ( gDisplayedStringBattle , gSaveBlock2Ptr - > frontier . domeTrainers [ i ] . trainerId ) ;
if ( gSaveBlock2Ptr - > frontier . domeTrainers [ i ] . unk2 = = gSaveBlock2Ptr - > frontier . field_CB2 - 1
& & gSaveBlock2Ptr - > frontier . domeTrainers [ i ] . unk1 )
{
if ( gUnknown_0860D3F1 [ i ] [ 0 ] = = 0 )
textPrinter . currentX = GetStringWidthDifference ( textPrinter . fontId , gDisplayedStringBattle , 0x3D , textPrinter . letterSpacing ) ;
else
textPrinter . currentX = 3 ;
textPrinter . current_text_offset = gDisplayedStringBattle ;
textPrinter . windowId = gUnknown_0860D3F1 [ i ] [ 0 ] ;
textPrinter . currentY = gUnknown_0860D3F1 [ i ] [ 1 ] ;
AddTextPrinter ( & textPrinter , 0 , NULL ) ;
}
if ( ! gSaveBlock2Ptr - > frontier . domeTrainers [ i ] . unk1 )
{
s32 var = gSaveBlock2Ptr - > frontier . field_CB2 - 1 ;
sub_81948EC ( i , var ) ;
}
}
}
break ;
case 2 :
if ( - - gTasks [ taskId ] . data [ 3 ] = = 0 )
gTasks [ taskId ] . data [ 0 ] = 3 ;
break ;
case 3 :
if ( gMain . newKeys & ( A_BUTTON | B_BUTTON ) )
{
BeginNormalPaletteFade ( 0xFFFFFFFF , 0 , 0 , 0x10 , 0 ) ;
gTasks [ taskId ] . data [ 0 ] = 4 ;
}
break ;
case 4 :
if ( ! gPaletteFade . active )
{
SetMainCallback2 ( CB2_ReturnToFieldContinueScriptPlayMapMusic ) ;
DestroyTask ( taskId ) ;
}
break ;
}
}
static void CB2_BattleDome ( void )
{
AnimateSprites ( ) ;
BuildOamBuffer ( ) ;
RunTextPrinters ( ) ;
UpdatePaletteFade ( ) ;
RunTasks ( ) ;
}