battle tent start and create frontier struct in saveblock

This commit is contained in:
DizzyEggg 2018-06-17 12:30:09 +02:00
parent f807eb1f2d
commit 0fe3e612eb
23 changed files with 464 additions and 805 deletions

View File

@ -5,586 +5,6 @@
.text
thumb_func_start sub_81B99B4
sub_81B99B4: @ 81B99B4
push {lr}
ldr r1, =gUnknown_086160B4
ldr r0, =gSpecialVar_0x8004
ldrh r0, [r0]
lsls r0, 2
adds r0, r1
ldr r0, [r0]
bl _call_via_r0
pop {r0}
bx r0
.pool
thumb_func_end sub_81B99B4
thumb_func_start sub_81B99D4
sub_81B99D4: @ 81B99D4
push {lr}
ldr r1, =gSaveBlock2Ptr
ldr r0, [r1]
ldr r2, =0x00000ca8
adds r0, r2
movs r2, 0
strb r2, [r0]
ldr r1, [r1]
ldr r3, =0x00000cb2
adds r0, r1, r3
strh r2, [r0]
ldr r0, =0x00000ca9
adds r1, r0
ldrb r2, [r1]
movs r0, 0x5
negs r0, r0
ands r0, r2
strb r0, [r1]
ldr r0, =gSaveBlock1Ptr
ldr r0, [r0]
movs r1, 0x4
ldrsb r1, [r0, r1]
movs r2, 0x5
ldrsb r2, [r0, r2]
movs r3, 0x1
negs r3, r3
movs r0, 0
bl saved_warp2_set
pop {r0}
bx r0
.pool
thumb_func_end sub_81B99D4
thumb_func_start sub_81B9A28
sub_81B9A28: @ 81B9A28
ldr r1, =gSpecialVar_Result
ldr r0, =gSaveBlock2Ptr
ldr r0, [r0]
ldr r2, =0x00000e6a
adds r0, r2
ldrh r0, [r0]
strh r0, [r1]
bx lr
.pool
thumb_func_end sub_81B9A28
thumb_func_start sub_81B9A44
sub_81B9A44: @ 81B9A44
ldr r0, =gSaveBlock2Ptr
ldr r0, [r0]
ldr r1, =gSpecialVar_0x8006
ldrh r1, [r1]
ldr r2, =0x00000e6a
adds r0, r2
strh r1, [r0]
bx lr
.pool
thumb_func_end sub_81B9A44
thumb_func_start sub_81B9A60
sub_81B9A60: @ 81B9A60
push {r4,lr}
ldr r4, =gTrainerBattleOpponent_A
bl Random
lsls r0, 16
lsrs r0, 16
movs r1, 0xFF
bl __umodsi3
lsls r0, 16
lsrs r0, 16
lsls r1, r0, 2
adds r1, r0
lsrs r1, 6
strh r1, [r4]
ldrh r0, [r4]
movs r1, 0
bl sub_8162614
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end sub_81B9A60
thumb_func_start sub_81B9A90
sub_81B9A90: @ 81B9A90
push {lr}
ldr r3, =gTrainerBattleOpponent_A
ldrh r1, [r3]
ldr r0, =0x0000012b
cmp r1, r0
bhi _081B9AAC
ldr r2, =gUnknown_0203BC88
movs r0, 0x34
muls r1, r0
ldr r0, [r2]
adds r0, r1
adds r0, 0xC
bl ConvertBattleFrontierTrainerSpeechToString
_081B9AAC:
pop {r0}
bx r0
.pool
thumb_func_end sub_81B9A90
thumb_func_start sub_81B9ABC
sub_81B9ABC: @ 81B9ABC
push {r4,lr}
ldr r4, =gSaveBlock2Ptr
ldr r0, [r4]
ldr r1, =gSpecialVar_0x8005
ldrh r1, [r1]
ldr r2, =0x00000ca8
adds r0, r2
strb r1, [r0]
movs r0, 0x80
lsls r0, 7
movs r1, 0
bl VarSet
ldr r1, [r4]
ldr r0, =0x00000ca9
adds r1, r0
ldrb r0, [r1]
movs r2, 0x4
orrs r0, r2
strb r0, [r1]
bl sub_81A4C30
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end sub_81B9ABC
thumb_func_start sub_81B9B00
sub_81B9B00: @ 81B9B00
push {r4,r5,lr}
ldr r0, =gSaveBlock2Ptr
ldr r4, [r0]
ldr r5, =gUnknown_086160D4
bl Random
ldrh r0, [r5]
ldr r1, =0x00000e6a
adds r4, r1
strh r0, [r4]
pop {r4,r5}
pop {r0}
bx r0
.pool
thumb_func_end sub_81B9B00
thumb_func_start sub_81B9B28
sub_81B9B28: @ 81B9B28
push {r4,r5,lr}
ldr r4, =gSaveBlock2Ptr
ldr r0, [r4]
ldr r1, =0x00000e6a
adds r0, r1
ldrh r0, [r0]
movs r1, 0x1
bl AddBagItem
lsls r0, 24
lsrs r5, r0, 24
cmp r5, 0x1
bne _081B9B70
ldr r0, [r4]
ldr r1, =0x00000e6a
adds r0, r1
ldrh r0, [r0]
ldr r1, =gStringVar1
bl CopyItemName
ldr r0, [r4]
ldr r1, =0x00000e6a
adds r0, r1
movs r1, 0
strh r1, [r0]
ldr r0, =gSpecialVar_Result
strh r5, [r0]
b _081B9B76
.pool
_081B9B70:
ldr r1, =gSpecialVar_Result
movs r0, 0
strh r0, [r1]
_081B9B76:
pop {r4,r5}
pop {r0}
bx r0
.pool
thumb_func_end sub_81B9B28
thumb_func_start sub_81B9B80
sub_81B9B80: @ 81B9B80
push {lr}
ldr r1, =gUnknown_086160D8
ldr r0, =gSpecialVar_0x8004
ldrh r0, [r0]
lsls r0, 2
adds r0, r1
ldr r0, [r0]
bl _call_via_r0
pop {r0}
bx r0
.pool
thumb_func_end sub_81B9B80
thumb_func_start sub_81B9BA0
sub_81B9BA0: @ 81B9BA0
push {lr}
ldr r1, =gSaveBlock2Ptr
ldr r0, [r1]
ldr r2, =0x00000ca8
adds r0, r2
movs r2, 0
strb r2, [r0]
ldr r1, [r1]
ldr r3, =0x00000cb2
adds r0, r1, r3
strh r2, [r0]
ldr r0, =0x00000ca9
adds r1, r0
ldrb r2, [r1]
movs r0, 0x5
negs r0, r0
ands r0, r2
strb r0, [r1]
ldr r0, =gSaveBlock1Ptr
ldr r0, [r0]
movs r1, 0x4
ldrsb r1, [r0, r1]
movs r2, 0x5
ldrsb r2, [r0, r2]
movs r3, 0x1
negs r3, r3
movs r0, 0
bl saved_warp2_set
pop {r0}
bx r0
.pool
thumb_func_end sub_81B9BA0
thumb_func_start sub_81B9BF4
sub_81B9BF4: @ 81B9BF4
ldr r1, =gSpecialVar_Result
ldr r0, =gSaveBlock2Ptr
ldr r0, [r0]
ldr r2, =0x00000e6c
adds r0, r2
ldrh r0, [r0]
strh r0, [r1]
bx lr
.pool
thumb_func_end sub_81B9BF4
thumb_func_start sub_81B9C10
sub_81B9C10: @ 81B9C10
ldr r0, =gSaveBlock2Ptr
ldr r0, [r0]
ldr r1, =gSpecialVar_0x8006
ldrh r1, [r1]
ldr r2, =0x00000e6c
adds r0, r2
strh r1, [r0]
bx lr
.pool
thumb_func_end sub_81B9C10
thumb_func_start sub_81B9C2C
sub_81B9C2C: @ 81B9C2C
push {r4,lr}
ldr r4, =gSaveBlock2Ptr
ldr r0, [r4]
ldr r1, =gSpecialVar_0x8005
ldrh r1, [r1]
ldr r2, =0x00000ca8
adds r0, r2
strb r1, [r0]
movs r0, 0x80
lsls r0, 7
movs r1, 0
bl VarSet
ldr r1, [r4]
ldr r0, =0x00000ca9
adds r1, r0
ldrb r0, [r1]
movs r2, 0x4
orrs r0, r2
strb r0, [r1]
bl sub_81A4C30
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end sub_81B9C2C
thumb_func_start sub_81B9C70
sub_81B9C70: @ 81B9C70
push {r4,r5,lr}
ldr r0, =gSaveBlock2Ptr
ldr r4, [r0]
ldr r5, =gUnknown_086160F4
bl Random
ldrh r0, [r5]
ldr r1, =0x00000e6c
adds r4, r1
strh r0, [r4]
pop {r4,r5}
pop {r0}
bx r0
.pool
thumb_func_end sub_81B9C70
thumb_func_start sub_81B9C98
sub_81B9C98: @ 81B9C98
push {r4,r5,lr}
ldr r4, =gSaveBlock2Ptr
ldr r0, [r4]
ldr r1, =0x00000e6c
adds r0, r1
ldrh r0, [r0]
movs r1, 0x1
bl AddBagItem
lsls r0, 24
lsrs r5, r0, 24
cmp r5, 0x1
bne _081B9CE0
ldr r0, [r4]
ldr r1, =0x00000e6c
adds r0, r1
ldrh r0, [r0]
ldr r1, =gStringVar1
bl CopyItemName
ldr r0, [r4]
ldr r1, =0x00000e6c
adds r0, r1
movs r1, 0
strh r1, [r0]
ldr r0, =gSpecialVar_Result
strh r5, [r0]
b _081B9CE6
.pool
_081B9CE0:
ldr r1, =gSpecialVar_Result
movs r0, 0
strh r0, [r1]
_081B9CE6:
pop {r4,r5}
pop {r0}
bx r0
.pool
thumb_func_end sub_81B9C98
thumb_func_start sub_81B9CF0
sub_81B9CF0: @ 81B9CF0
push {lr}
ldr r0, =gStringVar1
ldr r1, =gTrainerBattleOpponent_A
ldrh r1, [r1]
bl GetFrontierTrainerName
pop {r0}
bx r0
.pool
thumb_func_end sub_81B9CF0
thumb_func_start sub_81B9D08
sub_81B9D08: @ 81B9D08
push {lr}
ldr r1, =gUnknown_086160F8
ldr r0, =gSpecialVar_0x8004
ldrh r0, [r0]
lsls r0, 2
adds r0, r1
ldr r0, [r0]
bl _call_via_r0
pop {r0}
bx r0
.pool
thumb_func_end sub_81B9D08
thumb_func_start sub_81B9D28
sub_81B9D28: @ 81B9D28
push {lr}
ldr r1, =gSaveBlock2Ptr
ldr r0, [r1]
ldr r2, =0x00000ca8
adds r0, r2
movs r2, 0
strb r2, [r0]
ldr r1, [r1]
ldr r3, =0x00000cb2
adds r0, r1, r3
strh r2, [r0]
ldr r0, =0x00000ca9
adds r1, r0
ldrb r2, [r1]
movs r0, 0x5
negs r0, r0
ands r0, r2
strb r0, [r1]
ldr r0, =gSaveBlock1Ptr
ldr r0, [r0]
movs r1, 0x4
ldrsb r1, [r0, r1]
movs r2, 0x5
ldrsb r2, [r0, r2]
movs r3, 0x1
negs r3, r3
movs r0, 0
bl saved_warp2_set
pop {r0}
bx r0
.pool
thumb_func_end sub_81B9D28
thumb_func_start sub_81B9D7C
sub_81B9D7C: @ 81B9D7C
ldr r1, =gSpecialVar_Result
ldr r0, =gSaveBlock2Ptr
ldr r0, [r0]
ldr r2, =0x00000e6e
adds r0, r2
ldrh r0, [r0]
strh r0, [r1]
bx lr
.pool
thumb_func_end sub_81B9D7C
thumb_func_start sub_81B9D98
sub_81B9D98: @ 81B9D98
ldr r0, =gSaveBlock2Ptr
ldr r0, [r0]
ldr r1, =gSpecialVar_0x8006
ldrh r1, [r1]
ldr r2, =0x00000e6e
adds r0, r2
strh r1, [r0]
bx lr
.pool
thumb_func_end sub_81B9D98
thumb_func_start sub_81B9DB4
sub_81B9DB4: @ 81B9DB4
push {r4,lr}
ldr r4, =gSaveBlock2Ptr
ldr r0, [r4]
ldr r1, =gSpecialVar_0x8005
ldrh r1, [r1]
ldr r2, =0x00000ca8
adds r0, r2
strb r1, [r0]
movs r0, 0x80
lsls r0, 7
movs r1, 0
bl VarSet
ldr r1, [r4]
ldr r0, =0x00000ca9
adds r1, r0
ldrb r0, [r1]
movs r2, 0x4
orrs r0, r2
strb r0, [r1]
bl sub_81A4C30
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end sub_81B9DB4
thumb_func_start sub_81B9DF8
sub_81B9DF8: @ 81B9DF8
push {r4,r5,lr}
ldr r0, =gSaveBlock2Ptr
ldr r4, [r0]
ldr r5, =gUnknown_08616120
bl Random
ldrh r0, [r5]
ldr r1, =0x00000e6e
adds r4, r1
strh r0, [r4]
pop {r4,r5}
pop {r0}
bx r0
.pool
thumb_func_end sub_81B9DF8
thumb_func_start sub_81B9E20
sub_81B9E20: @ 81B9E20
push {r4,r5,lr}
ldr r4, =gSaveBlock2Ptr
ldr r0, [r4]
ldr r1, =0x00000e6e
adds r0, r1
ldrh r0, [r0]
movs r1, 0x1
bl AddBagItem
lsls r0, 24
lsrs r5, r0, 24
cmp r5, 0x1
bne _081B9E68
ldr r0, [r4]
ldr r1, =0x00000e6e
adds r0, r1
ldrh r0, [r0]
ldr r1, =gStringVar1
bl CopyItemName
ldr r0, [r4]
ldr r1, =0x00000e6e
adds r0, r1
movs r1, 0
strh r1, [r0]
ldr r0, =gSpecialVar_Result
strh r5, [r0]
b _081B9E6E
.pool
_081B9E68:
ldr r1, =gSpecialVar_Result
movs r0, 0
strh r0, [r1]
_081B9E6E:
pop {r4,r5}
pop {r0}
bx r0
.pool
thumb_func_end sub_81B9E20
thumb_func_start sub_81B9E78
sub_81B9E78: @ 81B9E78
push {lr}
bl ZeroPlayerPartyMons
bl sub_819A4F8
pop {r0}
bx r0
thumb_func_end sub_81B9E78
thumb_func_start sub_81B9E88
sub_81B9E88: @ 81B9E88
push {lr}
bl sub_819DC00
pop {r0}
bx r0
thumb_func_end sub_81B9E88
thumb_func_start sub_81B9E94
sub_81B9E94: @ 81B9E94
push {lr}
movs r2, 0
ldr r1, =gMapHeader
ldrb r0, [r1, 0x14]
cmp r0, 0x8
bne _081B9EB2
ldr r3, =0xfffffe7f
adds r0, r3, 0
ldrh r1, [r1, 0x12]
adds r0, r1
lsls r0, 16
lsrs r0, 16
cmp r0, 0x1
bhi _081B9EB2
movs r2, 0x1
_081B9EB2:
adds r0, r2, 0
pop {r1}
bx r1
.pool
thumb_func_end sub_81B9E94
thumb_func_start sub_81B9EC0
sub_81B9EC0: @ 81B9EC0

View File

@ -1,51 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.section .rodata
.align 2
gUnknown_086160B4:: @ 86160B4
.4byte sub_81B99D4
.4byte sub_81B9A28
.4byte sub_81B9A44
.4byte sub_81B9A60
.4byte sub_81B9A90
.4byte sub_81B9ABC
.4byte sub_81B9B00
.4byte sub_81B9B28
.align 2
gUnknown_086160D4:: @ 86160D4
.4byte 0x00000008
.align 2
gUnknown_086160D8:: @ 86160D8
.4byte sub_81B9BA0
.4byte sub_81B9BF4
.4byte sub_81B9C10
.4byte sub_81B9C2C
.4byte sub_81B9C70
.4byte sub_81B9C98
.4byte sub_81B9CF0
.align 2
gUnknown_086160F4:: @ 86160F4
.4byte 0x00000015
.align 2
gUnknown_086160F8:: @ 86160F8
.4byte sub_81B9D28
.4byte sub_81B9D7C
.4byte sub_81B9D98
.4byte sub_81B9DB4
.4byte sub_81B9DF8
.4byte sub_81B9E20
.4byte sub_81B9E78
.4byte sub_81B9E88
.4byte sub_81BA040
.4byte sub_81B9EC0
.align 2
gUnknown_08616120:: @ 8616120
.4byte 0x00000017

View File

@ -8,5 +8,8 @@ void sub_81A8AF8(void);
bool8 InBattlePike(void);
void sub_819FA50(void);
void sub_81AA078(u16*, u8);
void sub_81A4C30(void);
void sub_819A4F8(void);
void sub_819DC00(void);
#endif // GUARD_BATTLE_FRONTIER_2_H

View File

@ -22,10 +22,25 @@ union BattleTowerRecord
struct EmeraldBattleTowerRecord emerald;
};
struct BattleFrontierTrainer
{
u32 trainerClass;
u8 trainerName[8];
u16 speechBefore[6];
u16 speechWin[6];
u16 speechLose[6];
u16 *btMonPool;
};
extern struct BattleFrontierTrainer *gUnknown_0203BC88;
u16 sub_8164FCC(u8, u8);
void sub_81659DC(struct RSBattleTowerRecord *a0, struct RSBattleTowerRecord *a1);
bool32 sub_816587C(union BattleTowerRecord *, union BattleTowerRecord *);
void CalcEmeraldBattleTowerChecksum(struct EmeraldBattleTowerRecord *);
void sub_81628A0(union BattleTowerRecord *);
void sub_8162614(u16 trainerId, u8);
void ConvertBattleFrontierTrainerSpeechToString(u16 *words);
void GetFrontierTrainerName(u8 *dest, u16 trainerIdx);
#endif //GUARD_BATTLE_TOWER_H

View File

@ -314,62 +314,30 @@ struct EmeraldBattleTowerRecord
/*0xE8*/ u32 checksum;
};
struct SaveBlock2
struct BattleFrontier
{
/*0x00*/ u8 playerName[PLAYER_NAME_LENGTH];
/*0x08*/ u8 playerGender; // MALE, FEMALE
/*0x09*/ u8 specialSaveWarp;
/*0x0A*/ u8 playerTrainerId[4];
/*0x0E*/ u16 playTimeHours;
/*0x10*/ u8 playTimeMinutes;
/*0x11*/ u8 playTimeSeconds;
/*0x12*/ u8 playTimeVBlanks;
/*0x13*/ u8 optionsButtonMode; // OPTIONS_BUTTON_MODE_[NORMAL/LR/L_EQUALS_A]
/*0x14*/ u16 optionsTextSpeed:3; // OPTIONS_TEXT_SPEED_[SLOW/MID/FAST]
u16 optionsWindowFrameType:5; // Specifies one of the 20 decorative borders for text boxes
u16 optionsSound:1; // OPTIONS_SOUND_[MONO/STEREO]
u16 optionsBattleStyle:1; // OPTIONS_BATTLE_STYLE_[SHIFT/SET]
u16 optionsBattleSceneOff:1; // whether battle animations are disabled
u16 regionMapZoom:1; // whether the map is zoomed in
/*0x18*/ struct Pokedex pokedex;
/*0x90*/ u8 filler_90[0x8];
/*0x98*/ struct Time localTimeOffset;
/*0xA0*/ struct Time lastBerryTreeUpdate;
/*0xA8*/ u32 field_A8;
/*0xAC*/ u32 encryptionKey;
// TODO: fix and verify labels
/*0xB0*/ u8 field_B0;
/*0xB1*/ u8 field_B1;
/*0xB2*/ u8 field_B2_0:3;
/*0xB2*/ u8 field_B2_1:2;
/*0xB3*/ u8 field_B3[0x29];
/*0xDC*/ struct UnkRecordMixingStruct field_DC[4];
/*0x1EC*/ struct BerryCrush berryCrush;
/*0x1FC*/ struct PokemonJumpResults pokeJump;
/*0x20C*/ struct BerryPickingResults berryPick;
/*0x21C*/ u8 field_21C[1032];
/*0x624*/ u16 contestLinkResults[20]; // 4 positions for 5 categories, possibly a struct or a 2d array
// All below could be a one giant struct
/*0x64C*/ struct EmeraldBattleTowerRecord battleTower;
/*0x738*/ struct UnknownSaveBlock2Struct field_738[5]; // No idea here, it's probably wrong, no clue.
/*0xBD4*/ u16 field_BD4;
/*0xBD6*/ u16 field_BD6;
/*0xBD8*/ u8 field_BD8[11];
/*0xBE3*/ u8 filler_BE3[8];
/*0xBE3*/ u8 field_BE3[8];
/*0xBEB*/ u8 field_BEB;
/*0xBE3*/ u8 filler_BEC[189];
/*0xCA9*/ u8 frontierChosenLvl : 2; // 0x1, 0x2 -> 0x3
/*0xCA9*/ u8 field_CA9_a : 1; // 0x4
/*0xCA9*/ u8 field_CA9_b : 1; // 0x8
/*0xCA9*/ u8 field_CA9_c : 1; // 0x10
/*0xCA9*/ u8 field_CA9_d : 1; // 0x20
/*0xCA9*/ u8 field_CA9_e : 1; // 0x40
/*0xCA9*/ u8 field_CA9_f : 1; // 0x80
/*0xBEC*/ u8 filler_BEC[16];
/*0xBFC*/ u16 ecwords_BFC[6];
/*0xC08*/ u16 ecwords_C08[6];
/*0xC14*/ u16 ecwords_C14[6];
/*0xC20*/ u8 filler_C20[0x88];
/*0xCA8*/ u8 field_CA8;
/*0xCA9*/ u8 chosenLvl:2; // 0x1, 0x2 -> 0x3
/*0xCA9*/ u8 field_CA9_a:1; // 0x4
/*0xCA9*/ u8 field_CA9_b:1; // 0x8
/*0xCA9*/ u8 field_CA9_c:1; // 0x10
/*0xCA9*/ u8 field_CA9_d:1; // 0x20
/*0xCA9*/ u8 field_CA9_e:1; // 0x40
/*0xCA9*/ u8 field_CA9_f:1; // 0x80
/*0xCAA*/ u16 field_CAA[4];
/*0xCB2*/ u16 battlePyramidWildHeaderId;
/*0xCB2*/ u16 field_CB2;
/*0xCB4*/ u16 field_CB4[30];
/*0xCF0*/ u16 field_CF0[2];
/*0xCF4*/ u16 field_CF4[2];
@ -416,21 +384,61 @@ struct SaveBlock2
/*0xE04*/ u16 field_E04;
/*0xE06*/ u16 field_E06;
/*0xE08*/ u16 field_E08[9];
/*0xE1A*/ u16 battlePyramidFloor; // possibly?
/*0xE1A*/ u16 field_E1A;
/*0xE1C*/ u16 field_E1C;
/*0xE1E*/ u16 field_E1E[7];
/*0xE2C*/ struct PyramidBag pyramidBag;
/*0x???*/ u8 field_unkown[6];
/*0xE6E*/ u16 battleTentWinStreak;
/*0xE58*/ u16 field_E58;
/*0xE6A*/ u16 field_E6A;
/*0xE6C*/ u16 field_E6C;
/*0xE6E*/ u16 field_E6E;
/*0xE70*/ u8 field_E70[72];
/*0xEB8*/ u16 frontierBattlePoints;
/*0xEBA*/ u8 field_EBA[39];
/*0xEE1*/ u8 field_EE1[2][PLAYER_NAME_LENGTH];
/*0xEF1*/ u8 field_EF1[2][4];
/*0xEF9*/ u8 field_EF9[51];
// sizeof=0xF2C
};
struct SaveBlock2
{
/*0x00*/ u8 playerName[PLAYER_NAME_LENGTH];
/*0x08*/ u8 playerGender; // MALE, FEMALE
/*0x09*/ u8 specialSaveWarp;
/*0x0A*/ u8 playerTrainerId[4];
/*0x0E*/ u16 playTimeHours;
/*0x10*/ u8 playTimeMinutes;
/*0x11*/ u8 playTimeSeconds;
/*0x12*/ u8 playTimeVBlanks;
/*0x13*/ u8 optionsButtonMode; // OPTIONS_BUTTON_MODE_[NORMAL/LR/L_EQUALS_A]
/*0x14*/ u16 optionsTextSpeed:3; // OPTIONS_TEXT_SPEED_[SLOW/MID/FAST]
u16 optionsWindowFrameType:5; // Specifies one of the 20 decorative borders for text boxes
u16 optionsSound:1; // OPTIONS_SOUND_[MONO/STEREO]
u16 optionsBattleStyle:1; // OPTIONS_BATTLE_STYLE_[SHIFT/SET]
u16 optionsBattleSceneOff:1; // whether battle animations are disabled
u16 regionMapZoom:1; // whether the map is zoomed in
/*0x18*/ struct Pokedex pokedex;
/*0x90*/ u8 filler_90[0x8];
/*0x98*/ struct Time localTimeOffset;
/*0xA0*/ struct Time lastBerryTreeUpdate;
/*0xA8*/ u32 field_A8;
/*0xAC*/ u32 encryptionKey;
// TODO: fix and verify labels
/*0xB0*/ u8 field_B0;
/*0xB1*/ u8 field_B1;
/*0xB2*/ u8 field_B2_0:3;
/*0xB2*/ u8 field_B2_1:2;
/*0xB3*/ u8 field_B3[0x29];
/*0xDC*/ struct UnkRecordMixingStruct field_DC[4];
/*0x1EC*/ struct BerryCrush berryCrush;
/*0x1FC*/ struct PokemonJumpResults pokeJump;
/*0x20C*/ struct BerryPickingResults berryPick;
/*0x21C*/ u8 field_21C[1032];
/*0x624*/ u16 contestLinkResults[20]; // 4 positions for 5 categories, possibly a struct or a 2d array
/*0x64C*/ struct BattleFrontier frontier;
}; // sizeof=0xF2C
extern struct SaveBlock2 *gSaveBlock2Ptr;
struct SecretBaseParty

View File

@ -4,12 +4,7 @@
void WriteUnalignedWord(u32 var, u8 *dataPtr);
u32 ReadUnalignedWord(u8* dataPtr);
void CopyUnalignedWord(u8 *copyTo, u8 *copyFrom);
void InitPlayerTrainerId(void);
void SetDefaultOptions(void);
void ClearPokedexFlags(void);
void WarpToTruck(void);
void NewGameInitData(void);
void ResetMiniGamesResults(void);
void sub_808447C(void);
void Sav2_ClearSetDefault(void);

View File

@ -246,6 +246,7 @@ SECTIONS {
src/save_location.o(.text);
src/item_icon.o(.text);
asm/party_menu.o(.text);
src/battle_tent.o(.text);
asm/battle_tent.o(.text);
src/unk_text_util_2.o(.text);
src/multiboot.o(.text);
@ -518,7 +519,7 @@ SECTIONS {
src/save_location.o(.rodata);
src/item_icon.o(.rodata);
data/party_menu.o(.rodata);
data/battle_tent.o(.rodata);
src/battle_tent.o(.rodata);
src/unk_text_util_2.o(.rodata);
src/unk_81BAD84.o(.rodata);
src/battle_controller_player_partner.o(.rodata);

View File

@ -1854,7 +1854,7 @@ static void LinkOpponentHandleCmd55(void)
else
gBattleOutcome = gBattleBufferA[gActiveBattler][1] ^ B_OUTCOME_DREW;
gSaveBlock2Ptr->field_CA9_b = gBattleBufferA[gActiveBattler][2];
gSaveBlock2Ptr->frontier.field_CA9_b = gBattleBufferA[gActiveBattler][2];
FadeOutMapMusic(5);
BeginFastPaletteFade(3);
LinkOpponentBufferExecCompleted();

View File

@ -1684,7 +1684,7 @@ static void LinkPartnerHandleCmd55(void)
{
sub_81851A8(&gBattleBufferA[gActiveBattler][4]);
gBattleOutcome = gBattleBufferA[gActiveBattler][1];
gSaveBlock2Ptr->field_CA9_b = gBattleBufferA[gActiveBattler][2];
gSaveBlock2Ptr->frontier.field_CA9_b = gBattleBufferA[gActiveBattler][2];
FadeOutMapMusic(5);
BeginFastPaletteFade(3);
LinkPartnerBufferExecCompleted();

View File

@ -3104,7 +3104,7 @@ static void PlayerHandleCmd55(void)
{
sub_81851A8(&gBattleBufferA[gActiveBattler][4]);
gBattleOutcome = gBattleBufferA[gActiveBattler][1];
gSaveBlock2Ptr->field_CA9_b = gBattleBufferA[gActiveBattler][2];
gSaveBlock2Ptr->frontier.field_CA9_b = gBattleBufferA[gActiveBattler][2];
FadeOutMapMusic(5);
BeginFastPaletteFade(3);
PlayerBufferExecCompleted();

View File

@ -1515,8 +1515,8 @@ void BtlController_EmitCmd55(u8 bufferId, u8 arg1)
{
sBattleBuffersTransferData[0] = CONTROLLER_55;
sBattleBuffersTransferData[1] = arg1;
sBattleBuffersTransferData[2] = gSaveBlock2Ptr->field_CA9_b;
sBattleBuffersTransferData[3] = gSaveBlock2Ptr->field_CA9_b;
sBattleBuffersTransferData[2] = gSaveBlock2Ptr->frontier.field_CA9_b;
sBattleBuffersTransferData[3] = gSaveBlock2Ptr->frontier.field_CA9_b;
sBattleBuffersTransferData[5] = sBattleBuffersTransferData[4] = sub_81850DC(&sBattleBuffersTransferData[6]);
PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, sBattleBuffersTransferData[4] + 6);
}

View File

@ -676,7 +676,7 @@ static void CB2_InitBattleInternal(void)
}
gMain.inBattle = TRUE;
gSaveBlock2Ptr->field_CA9_b = 0;
gSaveBlock2Ptr->frontier.field_CA9_b = 0;
for (i = 0; i < 6; i++)
AdjustFriendship(&gPlayerParty[i], 3);
@ -2273,7 +2273,7 @@ static void sub_8038F34(void)
for (i = 0; i < monsCount && (gLinkPlayers[i].version & 0xFF) == VERSION_EMERALD; i++);
if (!gSaveBlock2Ptr->field_CA9_b && i == monsCount)
if (!gSaveBlock2Ptr->frontier.field_CA9_b && i == monsCount)
{
if (FlagGet(FLAG_SYS_FRONTIER_PASS))
{
@ -5015,7 +5015,7 @@ static void HandleEndTurn_BattleLost(void)
{
gBattlescriptCurrInstr = BattleScript_PrintPlayerForfeitedLinkBattle;
gBattleOutcome &= ~(B_OUTCOME_LINK_BATTLE_RAN);
gSaveBlock2Ptr->field_CA9_b = 1;
gSaveBlock2Ptr->frontier.field_CA9_b = 1;
}
else
{
@ -5047,7 +5047,7 @@ static void HandleEndTurn_RanFromBattle(void)
{
gBattlescriptCurrInstr = BattleScript_PrintPlayerForfeited;
gBattleOutcome = B_OUTCOME_FORFEITED;
gSaveBlock2Ptr->field_CA9_b = 1;
gSaveBlock2Ptr->frontier.field_CA9_b = 1;
}
else if (gBattleTypeFlags & BATTLE_TYPE_x4000000)
{
@ -5666,7 +5666,7 @@ static void HandleAction_Run(void)
}
gBattleOutcome |= B_OUTCOME_LINK_BATTLE_RAN;
gSaveBlock2Ptr->field_CA9_b = 1;
gSaveBlock2Ptr->frontier.field_CA9_b = 1;
}
else
{

View File

@ -883,8 +883,8 @@ u8 sub_80B100C(s32 arg0)
return sUnknown_0854FE98[Random() % ARRAY_COUNT(sUnknown_0854FE98)];
}
var = gSaveBlock2Ptr->field_CB4[gSaveBlock2Ptr->battlePyramidWildHeaderId * 2 + 0]
+ gSaveBlock2Ptr->field_CB4[gSaveBlock2Ptr->battlePyramidWildHeaderId * 2 + 1];
var = gSaveBlock2Ptr->frontier.field_CB4[gSaveBlock2Ptr->frontier.field_CB2 * 2 + 0]
+ gSaveBlock2Ptr->frontier.field_CB4[gSaveBlock2Ptr->frontier.field_CB2 * 2 + 1];
return sUnknown_0854FE98[var % ARRAY_COUNT(sUnknown_0854FE98)];
}

267
src/battle_tent.c Normal file
View File

@ -0,0 +1,267 @@
#include "global.h"
#include "overworld.h"
#include "event_data.h"
#include "region_map.h"
#include "battle.h"
#include "battle_setup.h"
#include "battle_tower.h"
#include "battle_frontier_2.h"
#include "random.h"
#include "item.h"
#include "constants/items.h"
// this file's functions
void sub_81B99D4(void);
void sub_81B9A28(void);
void sub_81B9A44(void);
void sub_81B9A60(void);
void sub_81B9A90(void);
void sub_81B9ABC(void);
void sub_81B9B00(void);
void sub_81B9B28(void);
void sub_81B9BA0(void);
void sub_81B9BF4(void);
void sub_81B9C10(void);
void sub_81B9C2C(void);
void sub_81B9C70(void);
void sub_81B9C98(void);
void sub_81B9CF0(void);
void sub_81B9D28(void);
void sub_81B9D7C(void);
void sub_81B9D98(void);
void sub_81B9DB4(void);
void sub_81B9DF8(void);
void sub_81B9E20(void);
void sub_81B9E78(void);
void sub_81B9E88(void);
void sub_81BA040(void);
void sub_81B9EC0(void);
// const rom data
void (*const gUnknown_086160B4[])(void) =
{
sub_81B99D4,
sub_81B9A28,
sub_81B9A44,
sub_81B9A60,
sub_81B9A90,
sub_81B9ABC,
sub_81B9B00,
sub_81B9B28
};
const u16 gUnknown_086160D4[] = {ITEM_NEST_BALL, ITEM_NONE};
void (*const gUnknown_086160D8[])(void) =
{
sub_81B9BA0,
sub_81B9BF4,
sub_81B9C10,
sub_81B9C2C,
sub_81B9C70,
sub_81B9C98,
sub_81B9CF0
};
const u16 gUnknown_086160F4[] = {ITEM_HYPER_POTION, ITEM_NONE};
void (*const gUnknown_086160F8[])(void) =
{
sub_81B9D28,
sub_81B9D7C,
sub_81B9D98,
sub_81B9DB4,
sub_81B9DF8,
sub_81B9E20,
sub_81B9E78,
sub_81B9E88,
sub_81BA040,
sub_81B9EC0
};
const u16 gUnknown_08616120[] = {ITEM_FULL_HEAL, ITEM_NONE};
// code
void sub_81B99B4(void)
{
gUnknown_086160B4[gSpecialVar_0x8004]();
}
void sub_81B99D4(void)
{
gSaveBlock2Ptr->frontier.field_CA8 = 0;
gSaveBlock2Ptr->frontier.field_CB2 = 0;
gSaveBlock2Ptr->frontier.field_CA9_a = FALSE;
saved_warp2_set(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1);
}
void sub_81B9A28(void)
{
gSpecialVar_Result = gSaveBlock2Ptr->frontier.field_E6A;
}
void sub_81B9A44(void)
{
gSaveBlock2Ptr->frontier.field_E6A = gSpecialVar_0x8006;
}
void sub_81B9A60(void)
{
gTrainerBattleOpponent_A = (u32)((Random() % 255) * 5) / 64;
sub_8162614(gTrainerBattleOpponent_A, 0);
}
void sub_81B9A90(void)
{
if (gTrainerBattleOpponent_A < 300)
ConvertBattleFrontierTrainerSpeechToString(gUnknown_0203BC88[gTrainerBattleOpponent_A].speechBefore);
}
void sub_81B9ABC(void)
{
gSaveBlock2Ptr->frontier.field_CA8 = gSpecialVar_0x8005;
VarSet(VAR_TEMP_0, 0);
gSaveBlock2Ptr->frontier.field_CA9_a = TRUE;
sub_81A4C30();
}
void sub_81B9B00(void)
{
gSaveBlock2Ptr->frontier.field_E6A = gUnknown_086160D4[Random() % 1];
}
void sub_81B9B28(void)
{
if (AddBagItem(gSaveBlock2Ptr->frontier.field_E6A, 1) == TRUE)
{
CopyItemName(gSaveBlock2Ptr->frontier.field_E6A, gStringVar1);
gSaveBlock2Ptr->frontier.field_E6A = ITEM_NONE;
gSpecialVar_Result = TRUE;
}
else
{
gSpecialVar_Result = FALSE;
}
}
void sub_81B9B80(void)
{
gUnknown_086160D8[gSpecialVar_0x8004]();
}
void sub_81B9BA0(void)
{
gSaveBlock2Ptr->frontier.field_CA8 = 0;
gSaveBlock2Ptr->frontier.field_CB2 = 0;
gSaveBlock2Ptr->frontier.field_CA9_a = FALSE;
saved_warp2_set(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1);
}
void sub_81B9BF4(void)
{
gSpecialVar_Result = gSaveBlock2Ptr->frontier.field_E6C;
}
void sub_81B9C10(void)
{
gSaveBlock2Ptr->frontier.field_E6C = gSpecialVar_0x8006;
}
void sub_81B9C2C(void)
{
gSaveBlock2Ptr->frontier.field_CA8 = gSpecialVar_0x8005;
VarSet(VAR_TEMP_0, 0);
gSaveBlock2Ptr->frontier.field_CA9_a = TRUE;
sub_81A4C30();
}
void sub_81B9C70(void)
{
gSaveBlock2Ptr->frontier.field_E6C = gUnknown_086160F4[Random() % 1];
}
void sub_81B9C98(void)
{
if (AddBagItem(gSaveBlock2Ptr->frontier.field_E6C, 1) == TRUE)
{
CopyItemName(gSaveBlock2Ptr->frontier.field_E6C, gStringVar1);
gSaveBlock2Ptr->frontier.field_E6C = ITEM_NONE;
gSpecialVar_Result = TRUE;
}
else
{
gSpecialVar_Result = FALSE;
}
}
void sub_81B9CF0(void)
{
GetFrontierTrainerName(gStringVar1, gTrainerBattleOpponent_A);
}
void sub_81B9D08(void)
{
gUnknown_086160F8[gSpecialVar_0x8004]();
}
void sub_81B9D28(void)
{
gSaveBlock2Ptr->frontier.field_CA8 = 0;
gSaveBlock2Ptr->frontier.field_CB2 = 0;
gSaveBlock2Ptr->frontier.field_CA9_a = FALSE;
saved_warp2_set(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1);
}
void sub_81B9D7C(void)
{
gSpecialVar_Result = gSaveBlock2Ptr->frontier.field_E6E;
}
void sub_81B9D98(void)
{
gSaveBlock2Ptr->frontier.field_E6E = gSpecialVar_0x8006;
}
void sub_81B9DB4(void)
{
gSaveBlock2Ptr->frontier.field_CA8 = gSpecialVar_0x8005;
VarSet(VAR_TEMP_0, 0);
gSaveBlock2Ptr->frontier.field_CA9_a = TRUE;
sub_81A4C30();
}
void sub_81B9DF8(void)
{
gSaveBlock2Ptr->frontier.field_E6E = gUnknown_08616120[Random() % 1];
}
void sub_81B9E20(void)
{
if (AddBagItem(gSaveBlock2Ptr->frontier.field_E6E, 1) == TRUE)
{
CopyItemName(gSaveBlock2Ptr->frontier.field_E6E, gStringVar1);
gSaveBlock2Ptr->frontier.field_E6E = ITEM_NONE;
gSpecialVar_Result = TRUE;
}
else
{
gSpecialVar_Result = FALSE;
}
}
void sub_81B9E78(void)
{
ZeroPlayerPartyMons();
sub_819A4F8();
}
void sub_81B9E88(void)
{
sub_819DC00();
}
bool8 sub_81B9E94(void)
{
return (gMapHeader.regionMapSectionId == 8
&& ((gMapHeader.mapDataId == 385) | (gMapHeader.mapDataId == 386)));
}

View File

@ -845,8 +845,8 @@ u16 CountTotalItemQuantityInBag(u16 itemId)
static bool8 CheckPyramidBagHasItem(u16 itemId, u16 count)
{
u8 i;
u16 *items = gSaveBlock2Ptr->pyramidBag.itemId[gSaveBlock2Ptr->frontierChosenLvl];
u8 *quantities = gSaveBlock2Ptr->pyramidBag.quantity[gSaveBlock2Ptr->frontierChosenLvl];
u16 *items = gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.chosenLvl];
u8 *quantities = gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.chosenLvl];
for (i = 0; i < PYRAMID_BAG_ITEMS_COUNT; i++)
{
@ -867,8 +867,8 @@ static bool8 CheckPyramidBagHasItem(u16 itemId, u16 count)
static bool8 CheckPyramidBagHasSpace(u16 itemId, u16 count)
{
u8 i;
u16 *items = gSaveBlock2Ptr->pyramidBag.itemId[gSaveBlock2Ptr->frontierChosenLvl];
u8 *quantities = gSaveBlock2Ptr->pyramidBag.quantity[gSaveBlock2Ptr->frontierChosenLvl];
u16 *items = gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.chosenLvl];
u8 *quantities = gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.chosenLvl];
for (i = 0; i < PYRAMID_BAG_ITEMS_COUNT; i++)
{
@ -890,8 +890,8 @@ bool8 AddPyramidBagItem(u16 itemId, u16 count)
{
u16 i;
u16 *items = gSaveBlock2Ptr->pyramidBag.itemId[gSaveBlock2Ptr->frontierChosenLvl];
u8 *quantities = gSaveBlock2Ptr->pyramidBag.quantity[gSaveBlock2Ptr->frontierChosenLvl];
u16 *items = gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.chosenLvl];
u8 *quantities = gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.chosenLvl];
u16 *newItems = Alloc(PYRAMID_BAG_ITEMS_COUNT * sizeof(u16));
u8 *newQuantities = Alloc(PYRAMID_BAG_ITEMS_COUNT * sizeof(u8));
@ -963,8 +963,8 @@ bool8 RemovePyramidBagItem(u16 itemId, u16 count)
{
u16 i;
u16 *items = gSaveBlock2Ptr->pyramidBag.itemId[gSaveBlock2Ptr->frontierChosenLvl];
u8 *quantities = gSaveBlock2Ptr->pyramidBag.quantity[gSaveBlock2Ptr->frontierChosenLvl];
u16 *items = gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.chosenLvl];
u8 *quantities = gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.chosenLvl];
i = gUnknown_0203CF30[3] + gUnknown_0203CF30[4];
if (items[i] == itemId && quantities[i] >= count)

View File

@ -236,7 +236,7 @@ static void ShowMapNamePopUpWindow(void)
else
{
withoutPrefixPtr = &(mapDisplayHeader[3]);
mapDisplayHeaderSource = gBattlePyramid_MapHeaderStrings[gSaveBlock2Ptr->battlePyramidWildHeaderId];
mapDisplayHeaderSource = gBattlePyramid_MapHeaderStrings[gSaveBlock2Ptr->frontier.field_CB2];
}
StringCopy(withoutPrefixPtr, mapDisplayHeaderSource);
}

View File

@ -31,11 +31,9 @@ extern u8 gUnknown_030060B0;
// TODO: replace those declarations with file headers
extern u16 GetGeneratedTrainerIdLower(void);
extern void ClearContestWinnerPicsInContestHall(void);
extern void warp_in(void);
extern void sub_80BB358(void);
extern void ResetBagScrollPositions(void);
extern void ResetPokedex(void);
extern void sub_8084400(void);
extern void ResetGabbyAndTy(void);
extern void ResetSecretBases(void);
extern void ResetLinkContestBoolean(void);
@ -58,6 +56,19 @@ extern void SetBerryPowder(u32* powder, u32 newValue);
extern const u8 EventScript_2715DE[];
// this file's functions
static void ClearFrontierRecord(void);
static void WarpToTruck(void);
static void ResetMiniGamesResults(void);
// const rom data
static const struct ContestWinner sContestWinnerPicDummy =
{
.monName = _(""),
.trainerName = _("")
};
// code
void WriteUnalignedWord(u32 var, u8 *dataPtr)
{
dataPtr[0] = var;
@ -78,14 +89,14 @@ void CopyUnalignedWord(u8 *copyTo, u8 *copyFrom)
copyTo[i] = copyFrom[i];
}
void InitPlayerTrainerId(void)
static void InitPlayerTrainerId(void)
{
u32 trainerId = (Random() << 0x10) | GetGeneratedTrainerIdLower();
WriteUnalignedWord(trainerId, gSaveBlock2Ptr->playerTrainerId);
}
// L=A isnt set here for some reason.
void SetDefaultOptions(void)
static void SetDefaultOptions(void)
{
gSaveBlock2Ptr->optionsTextSpeed = OPTIONS_TEXT_SPEED_MID;
gSaveBlock2Ptr->optionsWindowFrameType = 0;
@ -95,37 +106,31 @@ void SetDefaultOptions(void)
gSaveBlock2Ptr->regionMapZoom = FALSE;
}
void ClearPokedexFlags(void)
static void ClearPokedexFlags(void)
{
gUnknown_030060B0 = 0;
memset(&gSaveBlock2Ptr->pokedex.owned, 0, sizeof(gSaveBlock2Ptr->pokedex.owned));
memset(&gSaveBlock2Ptr->pokedex.seen, 0, sizeof(gSaveBlock2Ptr->pokedex.seen));
}
const struct ContestWinner gContestWinnerPicDummy = {
.monName = _(""),
.trainerName = _("")
};
void ClearAllContestWinnerPics(void)
{
s32 i;
ClearContestWinnerPicsInContestHall();
for (i = 8; i < 13; i++)
gSaveBlock1Ptr->contestWinners[i] = gContestWinnerPicDummy;
gSaveBlock1Ptr->contestWinners[i] = sContestWinnerPicDummy;
}
void sub_8084400(void)
static void ClearFrontierRecord(void)
{
// probably clearing one struct for battle frontier
CpuFill32(0, &gSaveBlock2Ptr->battleTower, 2272);
CpuFill32(0, &gSaveBlock2Ptr->frontier, sizeof(gSaveBlock2Ptr->frontier));
gSaveBlock2Ptr->field_EE1[0][0] = EOS;
gSaveBlock2Ptr->field_EE1[1][0] = EOS;
gSaveBlock2Ptr->frontier.field_EE1[0][0] = EOS;
gSaveBlock2Ptr->frontier.field_EE1[1][0] = EOS;
}
void WarpToTruck(void)
static void WarpToTruck(void)
{
Overworld_SetWarpDestination(25, 40, -1, -1, -1); // inside of truck
warp_in();
@ -157,7 +162,7 @@ void NewGameInitData(void)
ZeroPlayerPartyMons();
ZeroEnemyPartyMons();
ResetPokedex();
sub_8084400();
ClearFrontierRecord();
ClearSav1();
ClearMailData();
gSaveBlock2Ptr->specialSaveWarp = 0;
@ -207,7 +212,7 @@ void NewGameInitData(void)
ResetContestLinkResults();
}
void ResetMiniGamesResults(void)
static void ResetMiniGamesResults(void)
{
CpuFill16(0, &gSaveBlock2Ptr->berryCrush, sizeof(struct BerryCrush));
SetBerryPowder(&gSaveBlock2Ptr->berryCrush.berryPowderAmount, 0);

View File

@ -1575,8 +1575,8 @@ void sub_8068338(struct Pokemon *mon, struct UnknownPokemonStruct *src, bool8 lv
u8 language;
u8 value;
if (gSaveBlock2Ptr->frontierChosenLvl != 0)
level = BattleFrontierGetOpponentLvl(gSaveBlock2Ptr->frontierChosenLvl);
if (gSaveBlock2Ptr->frontier.chosenLvl != 0)
level = BattleFrontierGetOpponentLvl(gSaveBlock2Ptr->frontier.chosenLvl);
else if (lvl50)
level = 50;
else

View File

@ -197,10 +197,10 @@ static void SetSrcLookupPointers(void)
sOldManSave = &gSaveBlock1Ptr->oldMan;
sEasyChatPairsSave = gSaveBlock1Ptr->easyChatPairs;
gUnknown_03001148 = &gUnknown_02039F9C;
sBattleTowerSave = &gSaveBlock2Ptr->battleTower;
sBattleTowerSave = &gSaveBlock2Ptr->frontier.battleTower;
sLilycoveLadySave = &gSaveBlock1Ptr->lilycoveLady;
gUnknown_03001154 = gSaveBlock2Ptr->field_DC;
sBattleTowerSave_Duplicate = &gSaveBlock2Ptr->battleTower;
sBattleTowerSave_Duplicate = &gSaveBlock2Ptr->frontier.battleTower;
}
static void PrepareUnknownExchangePacket(struct PlayerRecordsRS *dest)
@ -1625,24 +1625,24 @@ void sub_80E8260(struct UnkRecordMixingStruct2 *dst)
{
dst->field_120[j].language = GAME_LANGUAGE;
CopyUnalignedWord(dst->field_120[j].playerId1, gSaveBlock2Ptr->playerTrainerId);
CopyUnalignedWord(dst->field_120[j].playerId2, gSaveBlock2Ptr->field_EF1[j]);
CopyUnalignedWord(dst->field_120[j].playerId2, gSaveBlock2Ptr->frontier.field_EF1[j]);
StringCopy(dst->field_120[j].playerName1, gSaveBlock2Ptr->playerName);
StringCopy(dst->field_120[j].playerName2, gSaveBlock2Ptr->field_EE1[j]);
StringCopy(dst->field_120[j].playerName2, gSaveBlock2Ptr->frontier.field_EE1[j]);
}
for (i = 0; i < 2; i++)
{
dst->field_0[0][i].field_4 = gSaveBlock2Ptr->field_CF0[i];
dst->field_0[1][i].field_4 = gSaveBlock2Ptr->field_CF4[i];
dst->field_0[2][i].field_4 = gSaveBlock2Ptr->field_CF8[i];
dst->field_0[3][i].field_4 = gSaveBlock2Ptr->field_D14[i];
dst->field_0[4][i].field_4 = gSaveBlock2Ptr->field_DD0[i];
dst->field_0[5][i].field_4 = gSaveBlock2Ptr->field_DDE[i];
dst->field_0[6][i].field_4 = gSaveBlock2Ptr->field_DEA[i];
dst->field_0[7][i].field_4 = gSaveBlock2Ptr->field_E08[i];
dst->field_0[8][i].field_4 = gSaveBlock2Ptr->field_E1E[i];
dst->field_0[0][i].field_4 = gSaveBlock2Ptr->frontier.field_CF0[i];
dst->field_0[1][i].field_4 = gSaveBlock2Ptr->frontier.field_CF4[i];
dst->field_0[2][i].field_4 = gSaveBlock2Ptr->frontier.field_CF8[i];
dst->field_0[3][i].field_4 = gSaveBlock2Ptr->frontier.field_D14[i];
dst->field_0[4][i].field_4 = gSaveBlock2Ptr->frontier.field_DD0[i];
dst->field_0[5][i].field_4 = gSaveBlock2Ptr->frontier.field_DDE[i];
dst->field_0[6][i].field_4 = gSaveBlock2Ptr->frontier.field_DEA[i];
dst->field_0[7][i].field_4 = gSaveBlock2Ptr->frontier.field_E08[i];
dst->field_0[8][i].field_4 = gSaveBlock2Ptr->frontier.field_E1E[i];
dst->field_120[i].field_8 = gSaveBlock2Ptr->field_CFC[i];
dst->field_120[i].field_8 = gSaveBlock2Ptr->frontier.field_CFC[i];
}
}

View File

@ -390,7 +390,7 @@ u32 MoveRecordedBattleToSaveData(void)
battleSave->opponentB = gTrainerBattleOpponent_B;
battleSave->partnerId = gPartnerTrainerId;
battleSave->field_4FA = gUnknown_0203C7B4;
battleSave->field_4FC = gSaveBlock2Ptr->field_CA9_b;
battleSave->field_4FC = gSaveBlock2Ptr->frontier.field_CA9_b;
battleSave->field_4FD = sUnknown_0203C7AE;
battleSave->field_4FE = sUnknown_0203C7AF;
battleSave->battleStyle = gSaveBlock2Ptr->optionsBattleStyle;
@ -1293,7 +1293,7 @@ static bool32 AllocTryCopyRecordedBattleSaveData(struct RecordedBattleSave *dst)
static void CB2_RecordedBattleEnd(void)
{
gSaveBlock2Ptr->frontierChosenLvl = sUnknown_0203C7AD;
gSaveBlock2Ptr->frontier.chosenLvl = sUnknown_0203C7AD;
gBattleOutcome = 0;
gBattleTypeFlags = 0;
gTrainerBattleOpponent_A = 0;
@ -1353,7 +1353,7 @@ static void SetRecordedBattleVarsFromSave(struct RecordedBattleSave *src)
gTrainerBattleOpponent_B = src->opponentB;
gPartnerTrainerId = src->partnerId;
gUnknown_0203C7B4 = src->field_4FA;
sUnknown_0203C7AD = gSaveBlock2Ptr->frontierChosenLvl;
sUnknown_0203C7AD = gSaveBlock2Ptr->frontier.chosenLvl;
sUnknown_0203C7AE = src->field_4FD;
sUnknown_0203C7AF = src->field_4FE;
sRecordedBattle_BattleStyle = src->battleStyle;
@ -1375,7 +1375,7 @@ static void SetRecordedBattleVarsFromSave(struct RecordedBattleSave *src)
sUnknown_0203CCDC[i] = src->field_50E[i];
}
gSaveBlock2Ptr->frontierChosenLvl = src->field_4FC;
gSaveBlock2Ptr->frontier.chosenLvl = src->field_4FC;
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
{

View File

@ -288,14 +288,14 @@ static void BuildNormalStartMenu(void)
{
AddStartMenuAction(MENU_ACTION_POKEMON);
}
AddStartMenuAction(MENU_ACTION_BAG);
if (FlagGet(FLAG_SYS_POKENAV_GET) == TRUE)
{
AddStartMenuAction(MENU_ACTION_POKENAV);
}
AddStartMenuAction(MENU_ACTION_PLAYER);
AddStartMenuAction(MENU_ACTION_SAVE);
AddStartMenuAction(MENU_ACTION_OPTION);
@ -322,7 +322,7 @@ static void BuildLinkModeStartMenu(void)
{
AddStartMenuAction(MENU_ACTION_POKENAV);
}
AddStartMenuAction(MENU_ACTION_PLAYER_LINK);
AddStartMenuAction(MENU_ACTION_OPTION);
AddStartMenuAction(MENU_ACTION_EXIT);
@ -384,18 +384,14 @@ static void ShowSafariBallsWindow(void)
static void ShowPyramidFloorWindow(void)
{
if (gSaveBlock2Ptr->field_CAA[4] == 7) // TODO: fix location
{
if (gSaveBlock2Ptr->frontier.field_CB2 == 7)
sBattlePyramidFloorWindowId = AddWindow(&sPyramidFloorWindowTemplate_1);
}
else
{
sBattlePyramidFloorWindowId = AddWindow(&sPyramidFloorWindowTemplate_2);
}
PutWindowTilemap(sBattlePyramidFloorWindowId);
NewMenuHelpers_DrawStdWindowFrame(sBattlePyramidFloorWindowId, FALSE);
StringCopy(gStringVar1, sPyramindFloorNames[gSaveBlock2Ptr->field_CAA[4]]);
StringCopy(gStringVar1, sPyramindFloorNames[gSaveBlock2Ptr->frontier.field_CB2]);
StringExpandPlaceholders(gStringVar4, gText_BattlePyramidFloor);
PrintTextOnWindow(sBattlePyramidFloorWindowId, 1, gStringVar4, 0, 1, 0xFF, NULL);
CopyWindowToVram(sBattlePyramidFloorWindowId, 2);
@ -419,7 +415,7 @@ static void RemoveExtraStartMenuWindows(void)
static bool32 PrintStartMenuActions(s8 *pIndex, u32 count)
{
s8 index = *pIndex;
do
{
if (sStartMenuItems[sCurrentStartMenuActions[index]].func.u8_void == StartMenuPlayerNameCallback) {
@ -444,11 +440,11 @@ static bool32 PrintStartMenuActions(s8 *pIndex, u32 count)
return FALSE;
}
static bool32 InitStartMenuStep(void)
static bool32 InitStartMenuStep(void)
{
s8 value = sUnknown_02037619[0];
switch (value)
switch (value)
{
case 0:
sUnknown_02037619[0]++;
@ -468,14 +464,14 @@ static bool32 InitStartMenuStep(void)
{
ShowSafariBallsWindow();
}
if (InBattlePyramid() != FALSE)
if (InBattlePyramid() != FALSE)
{
ShowPyramidFloorWindow();
}
sUnknown_02037619[0]++;
break;
case 4:
if (PrintStartMenuActions(&sUnknown_02037619[1], 2) == FALSE)
if (PrintStartMenuActions(&sUnknown_02037619[1], 2) == FALSE)
{
break;
}
@ -515,7 +511,7 @@ static void CreateStartMenuTask(TaskFunc followupFunc)
SetTaskFuncWithFollowupFunc(taskId, StartMenuTask, followupFunc);
}
static bool8 sub_809FA00(void)
static bool8 sub_809FA00(void)
{
if (InitStartMenuStep() == FALSE)
{
@ -537,7 +533,7 @@ void sub_809FA34(u8 taskId) // Referenced in field_screen.s and rom_8011DC0.s
{
struct Task* task = &gTasks[taskId];
switch(task->data[0])
switch(task->data[0])
{
case 0:
if (InUnionRoom() == TRUE)
@ -576,13 +572,13 @@ static bool8 HandleStartMenuInput(void)
PlaySE(SE_SELECT);
sStartMenuCursorPos = MoveMenuCursor(-1);
}
if (gMain.newKeys & DPAD_DOWN)
{
PlaySE(SE_SELECT);
sStartMenuCursorPos = MoveMenuCursor(1);
}
if (gMain.newKeys & A_BUTTON)
{
PlaySE(SE_SELECT);
@ -592,20 +588,20 @@ static bool8 HandleStartMenuInput(void)
return FALSE;
}
}
gMenuCallback = sStartMenuItems[sCurrentStartMenuActions[sStartMenuCursorPos]].func.u8_void;
if (gMenuCallback != StartMenuSaveCallback
if (gMenuCallback != StartMenuSaveCallback
&& gMenuCallback != StartMenuExitCallback
&& gMenuCallback != StartMenuSafariZoneRetireCallback
&& gMenuCallback != StartMenuBattlePyramidRetireCallback)
{
FadeScreen(1, 0);
}
return FALSE;
}
if (gMain.newKeys & (START_BUTTON | B_BUTTON))
{
RemoveExtraStartMenuWindows();
@ -625,10 +621,10 @@ static bool8 StartMenuPokedexCallback(void)
RemoveExtraStartMenuWindows();
overworld_free_bg_tilemaps();
SetMainCallback2(sub_80BB534); // Display pokedex
return TRUE;
}
return FALSE;
}
@ -640,7 +636,7 @@ static bool8 StartMenuPokemonCallback(void)
RemoveExtraStartMenuWindows();
overworld_free_bg_tilemaps();
SetMainCallback2(CB2_PartyMenuFromStartMenu); // Display party menu
return TRUE;
}
@ -693,7 +689,7 @@ static bool8 StartMenuPlayerNameCallback(void)
{
sub_80C51C4(CB2_ReturnToFieldWithOpenMenu); // Display frontier pass
}
else
else
{
sub_80C4DDC(CB2_ReturnToFieldWithOpenMenu); // Display trainer card
}
@ -736,7 +732,7 @@ static bool8 StartMenuExitCallback(void)
{
RemoveExtraStartMenuWindows();
HideStartMenu(); // Hide start menu
return TRUE;
}
@ -911,7 +907,7 @@ static void SaveGameTask(u8 taskId)
case SAVE_IN_PROGRESS:
return;
}
DestroyTask(taskId);
EnableBothScriptContexts();
}
@ -972,7 +968,7 @@ static u8 SaveConfirmSaveCallback(void)
{
ShowSaveMessage(gText_BattlePyramidConfirmRest, SaveYesNoCallback);
}
else
else
{
ShowSaveMessage(gText_ConfirmSave, SaveYesNoCallback);
}
@ -1025,7 +1021,7 @@ static u8 SaveFileExistsCallback(void)
{
ShowSaveMessage(gText_DifferentSaveFile, SaveConfirmOverwriteNoCallback);
}
else
else
{
ShowSaveMessage(gText_AlreadySavedFile, SaveConfirmOverwriteCallback);
}
@ -1082,7 +1078,7 @@ static u8 SaveDoSaveCallback(void)
saveStatus = TrySavingData(SAVE_OVERWRITE_DIFFERENT_FILE);
gDifferentSaveFile = FALSE;
}
else
else
{
saveStatus = TrySavingData(SAVE_NORMAL);
}
@ -1118,7 +1114,7 @@ static u8 SaveReturnSuccessCallback(void)
HideSaveInfoWindow();
return SAVE_SUCCESS;
}
else
else
{
return SAVE_IN_PROGRESS;
}
@ -1131,13 +1127,13 @@ static u8 SaveErrorCallback(void)
PlaySE(SE_BOO);
sSaveDialogCallback = SaveReturnErrorCallback;
}
return SAVE_IN_PROGRESS;
}
static u8 SaveReturnErrorCallback(void)
{
if (!SaveErrorTimer())
if (!SaveErrorTimer())
{
return SAVE_IN_PROGRESS;
}
@ -1182,7 +1178,7 @@ static u8 BattlePyramidRetireInputCallback(void)
sub_80A0014();
return SAVE_SUCCESS;
}
return SAVE_IN_PROGRESS;
}
@ -1254,8 +1250,8 @@ static void sub_80A0550(u8 taskId)
{
case 0:
FillWindowPixelBuffer(0, 17);
AddTextPrinterParameterized(0,
1,
AddTextPrinterParameterized(0,
1,
gText_SavingDontTurnOffPower,
255,
NULL,
@ -1266,14 +1262,14 @@ static void sub_80A0550(u8 taskId)
PutWindowTilemap(0);
CopyWindowToVram(0, 3);
BeginNormalPaletteFade(-1, 0, 16, 0, 0);
if (gWirelessCommType != 0 && InUnionRoom())
{
if (sub_800A07C())
{
*step = 1;
}
else
else
{
*step = 5;
}
@ -1327,7 +1323,7 @@ static void ShowSaveInfoWindow(void)
u8 color;
u32 xOffset;
u32 yOffset;
if (!FlagGet(FLAG_SYS_POKEDEX_GET))
{
saveInfoWindow.height -= 2;
@ -1340,7 +1336,7 @@ static void ShowSaveInfoWindow(void)
color = TEXT_COLOR_RED; // Red when female, blue when male.
if (gender == MALE)
{
{
color = TEXT_COLOR_BLUE;
}
@ -1423,4 +1419,4 @@ void AppendToList(u8 *list, u8 *pos, u8 newEntry)
{
list[*pos] = newEntry;
(*pos)++;
}
}

View File

@ -1541,12 +1541,12 @@ static void InterviewAfter_BravoTrainerBattleTowerProfile(void)
show->bravoTrainerTower.kind = TVSHOW_BRAVO_TRAINER_BATTLE_TOWER_PROFILE;
show->bravoTrainerTower.active = TRUE;
StringCopy(show->bravoTrainerTower.trainerName, gSaveBlock2Ptr->playerName);
StringCopy(show->bravoTrainerTower.pokemonName, gSaveBlock2Ptr->field_BD8);
show->bravoTrainerTower.species = gSaveBlock2Ptr->field_BD4;
show->bravoTrainerTower.defeatedSpecies = gSaveBlock2Ptr->field_BD6;
show->bravoTrainerTower.numFights = sub_8164FCC(gSaveBlock2Ptr->field_D07, 0);
show->bravoTrainerTower.wonTheChallenge = gSaveBlock2Ptr->field_D06;
if (gSaveBlock2Ptr->field_D07 == 0)
StringCopy(show->bravoTrainerTower.pokemonName, gSaveBlock2Ptr->frontier.field_BD8);
show->bravoTrainerTower.species = gSaveBlock2Ptr->frontier.field_BD4;
show->bravoTrainerTower.defeatedSpecies = gSaveBlock2Ptr->frontier.field_BD6;
show->bravoTrainerTower.numFights = sub_8164FCC(gSaveBlock2Ptr->frontier.field_D07, 0);
show->bravoTrainerTower.wonTheChallenge = gSaveBlock2Ptr->frontier.field_D06;
if (gSaveBlock2Ptr->frontier.field_D07 == 0)
{
show->bravoTrainerTower.btLevel = 50;
}
@ -1557,13 +1557,13 @@ static void InterviewAfter_BravoTrainerBattleTowerProfile(void)
show->bravoTrainerTower.interviewResponse = gSpecialVar_0x8004;
tv_store_id_2x(show);
show->bravoTrainerTower.language = gGameLanguage;
if (show->bravoTrainerTower.language == LANGUAGE_JAPANESE || gSaveBlock2Ptr->field_BEB == LANGUAGE_JAPANESE)
if (show->bravoTrainerTower.language == LANGUAGE_JAPANESE || gSaveBlock2Ptr->frontier.field_BEB == LANGUAGE_JAPANESE)
{
show->bravoTrainerTower.pokemonNameLanguage = LANGUAGE_JAPANESE;
}
else
{
show->bravoTrainerTower.pokemonNameLanguage = gSaveBlock2Ptr->field_BEB;
show->bravoTrainerTower.pokemonNameLanguage = gSaveBlock2Ptr->frontier.field_BEB;
}
}
@ -1972,7 +1972,7 @@ void sub_80EDB44(void)
show->rivalTrainer.nGoldSymbols ++;
}
}
show->rivalTrainer.battlePoints = gSaveBlock2Ptr->frontierBattlePoints;
show->rivalTrainer.battlePoints = gSaveBlock2Ptr->frontier.frontierBattlePoints;
StringCopy(show->rivalTrainer.playerName, gSaveBlock2Ptr->playerName);
tv_store_id_3x(show);
show->rivalTrainer.language = gGameLanguage;
@ -2540,8 +2540,8 @@ void sub_80EE8C8(u16 winStreak, u8 facility)
show->frontier.species2 = GetMonData(&gPlayerParty[1], MON_DATA_SPECIES, NULL);
break;
case 4:
show->frontier.species1 = GetMonData(&gSaveBlock1Ptr->playerParty[gSaveBlock2Ptr->field_CAA[0] - 1], MON_DATA_SPECIES, NULL);
show->frontier.species2 = GetMonData(&gSaveBlock1Ptr->playerParty[gSaveBlock2Ptr->field_CAA[1] - 1], MON_DATA_SPECIES, NULL);
show->frontier.species1 = GetMonData(&gSaveBlock1Ptr->playerParty[gSaveBlock2Ptr->frontier.field_CAA[0] - 1], MON_DATA_SPECIES, NULL);
show->frontier.species2 = GetMonData(&gSaveBlock1Ptr->playerParty[gSaveBlock2Ptr->frontier.field_CAA[1] - 1], MON_DATA_SPECIES, NULL);
break;
}
tv_store_id_3x(show);

View File

@ -5102,7 +5102,7 @@ bool8 StandardWildEncounter(u16 currMetaTileBehavior, u16 previousMetaTileBehavi
}
if (gMapHeader.mapDataId == 0x169)
{
headerId = gSaveBlock2Ptr->battlePyramidWildHeaderId;
headerId = gSaveBlock2Ptr->frontier.field_CB2;
if (previousMetaTileBehavior != currMetaTileBehavior && !DoGlobalWildEncounterDiceRoll())
return FALSE;
else if (DoWildEncounterRateTest(gBattlePyramidWildMonHeaders[headerId].landMonsInfo->encounterRate, FALSE) != TRUE)
@ -5240,7 +5240,7 @@ bool8 SweetScentWildEncounter(void)
}
if (gMapHeader.mapDataId == 0x169)
{
headerId = gSaveBlock2Ptr->battlePyramidWildHeaderId;
headerId = gSaveBlock2Ptr->frontier.field_CB2;
if (TryGenerateWildMon(gBattlePyramidWildMonHeaders[headerId].landMonsInfo, WILD_AREA_LAND, 0) != TRUE)
return FALSE;