Battle Factory is decompiled and documented.

This commit is contained in:
DizzyEggg 2018-09-10 01:01:39 +02:00
parent cf8898071d
commit b87856b58e
17 changed files with 569 additions and 1057 deletions

View File

@ -4,410 +4,6 @@
.syntax unified
.text
thumb_func_start sub_819F654
sub_819F654: @ 819F654
push {r4,lr}
adds r4, r0, 0
adds r0, 0x3F
ldrb r1, [r0]
movs r0, 0x20
ands r0, r1
cmp r0, 0
beq _0819F694
ldrb r0, [r4, 0x3]
lsls r0, 26
lsrs r0, 27
bl FreeOamMatrix
movs r1, 0x3C
ldrsh r0, [r4, r1]
cmp r0, 0x1
bne _0819F688
ldr r0, =sFactorySwapScreen
ldr r0, [r0]
adds r0, 0x30
movs r1, 0
strb r1, [r0]
b _0819F68E
.pool
_0819F688:
movs r0, 0
bl sub_819BE20
_0819F68E:
adds r0, r4, 0
bl DestroySprite
_0819F694:
pop {r4}
pop {r0}
bx r0
thumb_func_end sub_819F654
thumb_func_start sub_819F69C
sub_819F69C: @ 819F69C
push {r4,r5,lr}
lsls r0, 24
lsrs r5, r0, 24
lsls r0, r5, 2
adds r0, r5
lsls r0, 3
ldr r1, =gTasks
adds r4, r0, r1
movs r1, 0x8
ldrsh r0, [r4, r1]
cmp r0, 0x1
beq _0819F71A
cmp r0, 0x1
bgt _0819F6C4
cmp r0, 0
beq _0819F6CA
b _0819F77C
.pool
_0819F6C4:
cmp r0, 0x2
beq _0819F73C
b _0819F77C
_0819F6CA:
movs r0, 0x58
strh r0, [r4, 0xE]
movs r0, 0x98
strh r0, [r4, 0x38]
movs r0, 0x40
strh r0, [r4, 0x12]
movs r0, 0x41
strh r0, [r4, 0x18]
movs r1, 0x80
lsls r1, 6
movs r0, 0
bl SetGpuRegBits
ldrh r1, [r4, 0xE]
lsls r1, 8
ldrh r0, [r4, 0x38]
orrs r1, r0
lsls r1, 16
lsrs r1, 16
movs r0, 0x40
bl SetGpuReg
ldrh r1, [r4, 0x12]
lsls r1, 8
ldrh r0, [r4, 0x18]
orrs r1, r0
lsls r1, 16
lsrs r1, 16
movs r0, 0x44
bl SetGpuReg
movs r0, 0x48
movs r1, 0x3F
bl SetGpuReg
movs r0, 0x4A
movs r1, 0x37
bl SetGpuReg
b _0819F7A6
_0819F71A:
movs r0, 0x3
bl ShowBg
ldr r1, =0x00001248
movs r0, 0x50
bl SetGpuReg
ldr r1, =0x0000040b
movs r0, 0x52
bl SetGpuReg
b _0819F7A6
.pool
_0819F73C:
ldrh r0, [r4, 0x12]
subs r0, 0x4
strh r0, [r4, 0x12]
ldrh r1, [r4, 0x18]
adds r1, 0x4
strh r1, [r4, 0x18]
lsls r0, 16
asrs r0, 16
cmp r0, 0x20
ble _0819F758
lsls r0, r1, 16
asrs r0, 16
cmp r0, 0x5F
ble _0819F760
_0819F758:
movs r0, 0x20
strh r0, [r4, 0x12]
movs r0, 0x60
strh r0, [r4, 0x18]
_0819F760:
ldrh r1, [r4, 0x12]
lsls r1, 8
ldrh r0, [r4, 0x18]
orrs r1, r0
lsls r1, 16
lsrs r1, 16
movs r0, 0x44
bl SetGpuReg
movs r2, 0x12
ldrsh r0, [r4, r2]
cmp r0, 0x20
bne _0819F7AC
b _0819F7A6
_0819F77C:
adds r0, r5, 0
bl DestroyTask
ldr r0, =gTasks
lsls r1, r5, 2
adds r1, r5
lsls r1, 3
adds r1, r0
movs r2, 0x16
ldrsh r0, [r1, r2]
cmp r0, 0x1
bne _0819F7A0
bl sub_819F8E0
b _0819F7AC
.pool
_0819F7A0:
bl sub_819BD70
b _0819F7AC
_0819F7A6:
ldrh r0, [r4, 0x8]
adds r0, 0x1
strh r0, [r4, 0x8]
_0819F7AC:
pop {r4,r5}
pop {r0}
bx r0
thumb_func_end sub_819F69C
thumb_func_start sub_819F7B4
sub_819F7B4: @ 819F7B4
push {r4,r5,lr}
lsls r0, 24
lsrs r5, r0, 24
lsls r0, r5, 2
adds r0, r5
lsls r0, 3
ldr r1, =gTasks
adds r4, r0, r1
movs r1, 0x8
ldrsh r0, [r4, r1]
cmp r0, 0
beq _0819F844
cmp r0, 0x1
beq _0819F894
movs r0, 0x3
bl HideBg
ldr r3, =gSprites
movs r0, 0x14
ldrsh r1, [r4, r0]
lsls r0, r1, 4
adds r0, r1
lsls r0, 2
adds r0, r3
ldrh r1, [r4, 0x16]
strh r1, [r0, 0x3C]
movs r0, 0x14
ldrsh r1, [r4, r0]
lsls r0, r1, 4
adds r0, r1
lsls r0, 2
adds r0, r3
adds r0, 0x3E
ldrb r2, [r0]
movs r1, 0x5
negs r1, r1
ands r1, r2
strb r1, [r0]
movs r0, 0x14
ldrsh r1, [r4, r0]
lsls r0, r1, 4
adds r0, r1
lsls r0, 2
adds r1, r3, 0
adds r1, 0x1C
adds r0, r1
ldr r1, =sub_819F654
str r1, [r0]
movs r0, 0x14
ldrsh r1, [r4, r0]
lsls r0, r1, 4
adds r0, r1
lsls r0, 2
adds r0, r3
movs r1, 0x1
bl StartSpriteAffineAnim
movs r1, 0x80
lsls r1, 6
movs r0, 0
bl ClearGpuRegBits
adds r0, r5, 0
bl DestroyTask
b _0819F8D8
.pool
_0819F844:
movs r0, 0x58
strh r0, [r4, 0xE]
movs r0, 0x98
strh r0, [r4, 0x38]
movs r0, 0x20
strh r0, [r4, 0x12]
movs r0, 0x60
strh r0, [r4, 0x18]
movs r1, 0x80
lsls r1, 6
movs r0, 0
bl SetGpuRegBits
ldrh r1, [r4, 0xE]
lsls r1, 8
ldrh r0, [r4, 0x38]
orrs r1, r0
lsls r1, 16
lsrs r1, 16
movs r0, 0x40
bl SetGpuReg
ldrh r1, [r4, 0x12]
lsls r1, 8
ldrh r0, [r4, 0x18]
orrs r1, r0
lsls r1, 16
lsrs r1, 16
movs r0, 0x44
bl SetGpuReg
movs r0, 0x48
movs r1, 0x3F
bl SetGpuReg
movs r0, 0x4A
movs r1, 0x37
bl SetGpuReg
b _0819F8D2
_0819F894:
ldrh r0, [r4, 0x12]
adds r0, 0x4
strh r0, [r4, 0x12]
ldrh r1, [r4, 0x18]
subs r1, 0x4
strh r1, [r4, 0x18]
lsls r0, 16
asrs r0, 16
cmp r0, 0x3F
bgt _0819F8B0
lsls r0, r1, 16
asrs r0, 16
cmp r0, 0x41
bgt _0819F8B8
_0819F8B0:
movs r0, 0x40
strh r0, [r4, 0x12]
movs r0, 0x41
strh r0, [r4, 0x18]
_0819F8B8:
ldrh r1, [r4, 0x12]
lsls r1, 8
ldrh r0, [r4, 0x18]
orrs r1, r0
lsls r1, 16
lsrs r1, 16
movs r0, 0x44
bl SetGpuReg
movs r1, 0x12
ldrsh r0, [r4, r1]
cmp r0, 0x40
bne _0819F8D8
_0819F8D2:
ldrh r0, [r4, 0x8]
adds r0, 0x1
strh r0, [r4, 0x8]
_0819F8D8:
pop {r4,r5}
pop {r0}
bx r0
thumb_func_end sub_819F7B4
thumb_func_start sub_819F8E0
sub_819F8E0: @ 819F8E0
push {r4-r6,lr}
sub sp, 0x10
ldr r0, =sFactorySwapScreen
ldr r1, [r0]
ldrb r0, [r1, 0x14]
cmp r0, 0
bne _0819F900
ldrb r1, [r1, 0x3]
movs r0, 0x64
muls r1, r0
ldr r0, =gPlayerParty
b _0819F908
.pool
_0819F900:
ldrb r1, [r1, 0x3]
movs r0, 0x64
muls r1, r0
ldr r0, =gEnemyParty
_0819F908:
adds r6, r1, r0
adds r0, r6, 0
movs r1, 0xB
movs r2, 0
bl GetMonData
adds r4, r0, 0
lsls r4, 16
lsrs r4, 16
adds r0, r6, 0
movs r1, 0
movs r2, 0
bl GetMonData
adds r5, r0, 0
adds r0, r6, 0
movs r1, 0x1
movs r2, 0
bl GetMonData
adds r1, r0, 0
movs r0, 0x58
str r0, [sp]
movs r0, 0x20
str r0, [sp, 0x4]
movs r0, 0xF
str r0, [sp, 0x8]
ldr r0, =0x0000ffff
str r0, [sp, 0xC]
adds r0, r4, 0
adds r2, r5, 0
movs r3, 0x1
bl CreateMonPicSprite_HandleDeoxys
ldr r2, =sFactorySwapScreen
ldr r1, [r2]
adds r1, 0x2C
movs r3, 0
strb r0, [r1]
ldr r4, =gSprites
ldr r0, [r2]
adds r0, 0x2C
ldrb r1, [r0]
lsls r0, r1, 4
adds r0, r1
lsls r0, 2
adds r0, r4
adds r0, 0x28
strb r3, [r0]
ldr r0, [r2]
adds r0, 0x2C
ldrb r1, [r0]
lsls r0, r1, 4
adds r0, r1
lsls r0, 2
adds r0, r4
adds r0, 0x29
strb r3, [r0]
ldr r0, [r2]
adds r0, 0x30
strb r3, [r0]
add sp, 0x10
pop {r4-r6}
pop {r0}
bx r0
.pool
thumb_func_end sub_819F8E0
@ Battle Factory ends here
thumb_func_start sub_819F99C
sub_819F99C: @ 819F99C
@ -12655,7 +12251,7 @@ nullsub_123: @ 81A6184
sub_81A6188: @ 81A6188
push {lr}
bl ZeroPlayerPartyMons
bl sub_819A4F8
bl DoBattleFactorySelectScreen
pop {r0}
bx r0
thumb_func_end sub_81A6188
@ -12663,7 +12259,7 @@ sub_81A6188: @ 81A6188
thumb_func_start sub_81A6198
sub_81A6198: @ 81A6198
push {lr}
bl sub_819DC00
bl DoBattleFactorySwapScreen
pop {r0}
bx r0
thumb_func_end sub_81A6198

View File

@ -1,260 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.syntax unified
.text
thumb_func_start sub_81BA040
sub_81BA040: @ 81BA040
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
sub sp, 0x10
movs r0, 0
mov r10, r0
ldr r1, =gFacilityTrainers
ldr r0, =gSlateportBattleTentTrainers
str r0, [r1]
ldr r1, =gFacilityTrainerMons
ldr r0, =gSlateportBattleTentMons
str r0, [r1]
ldr r7, =gSaveBlock2Ptr
ldr r1, =0x0000ffff
mov r8, r1
_081BA062:
mov r2, r10
lsls r6, r2, 1
_081BA066:
bl Random
lsls r0, 16
lsrs r0, 16
movs r1, 0x1E
bl __umodsi3
lsls r0, 16
lsrs r3, r0, 16
movs r5, 0
ldr r1, [r7]
ldr r4, =0x00000cb2
adds r0, r1, r4
ldrh r0, [r0]
cmp r5, r0
bge _081BA0AA
ldr r2, =0x00000cb4
adds r0, r1, r2
ldrh r0, [r0]
cmp r0, r3
beq _081BA0AA
ldr r0, =gSaveBlock2Ptr
ldr r1, [r0]
adds r0, r1, r4
ldrh r2, [r0]
adds r4, 0x2
adds r1, r4
_081BA09C:
adds r1, 0x2
adds r5, 0x1
cmp r5, r2
bge _081BA0AA
ldrh r0, [r1]
cmp r0, r3
bne _081BA09C
_081BA0AA:
ldr r0, [r7]
ldr r1, =0x00000cb2
adds r0, r1
ldrh r0, [r0]
cmp r5, r0
bne _081BA066
ldr r2, =gTrainerBattleOpponent_A
strh r3, [r2]
ldrh r3, [r2]
ldr r4, =gFacilityTrainers
ldr r1, [r4]
movs r0, 0x34
muls r0, r3
adds r0, r1
ldr r0, [r0, 0x30]
adds r1, r6, r0
ldrh r0, [r1]
cmp r0, r8
beq _081BA0DE
ldr r3, =0x0000ffff
_081BA0D2:
adds r1, 0x2
movs r6, 0x1
add r10, r6
ldrh r0, [r1]
cmp r0, r3
bne _081BA0D2
_081BA0DE:
mov r0, r10
cmp r0, 0x8
bgt _081BA110
movs r1, 0
mov r10, r1
b _081BA062
.pool
_081BA110:
ldr r0, =gSaveBlock2Ptr
ldr r1, [r0]
ldr r6, =0x00000cb2
adds r3, r1, r6
ldrh r0, [r3]
cmp r0, 0x1
bhi _081BA12A
lsls r0, 1
ldr r3, =0x00000cb4
adds r1, r3
adds r1, r0
ldrh r0, [r2]
strh r0, [r1]
_081BA12A:
ldrh r1, [r2]
ldr r2, [r4]
movs r0, 0x34
muls r0, r1
adds r0, r2
ldr r0, [r0, 0x30]
mov r9, r0
movs r5, 0
ldr r7, =gUnknown_03001298
mov r8, sp
_081BA13E:
bl Random
lsls r0, 16
lsrs r0, 16
mov r1, r10
bl __modsi3
lsls r0, 1
add r0, r9
ldrh r0, [r0]
strh r0, [r7]
movs r2, 0
ldrh r0, [r7]
ldr r4, =gFacilityTrainerMons
ldr r3, [r4]
lsls r0, 4
adds r0, r3
ldr r1, =gSaveBlock2Ptr
ldrh r6, [r0]
ldr r1, [r1]
_081BA166:
movs r4, 0xE7
lsls r4, 4
adds r0, r1, r4
ldrh r0, [r0]
lsls r0, 4
adds r0, r3
ldrh r0, [r0]
cmp r6, r0
beq _081BA180
adds r1, 0xC
adds r2, 0x1
cmp r2, 0x5
ble _081BA166
_081BA180:
cmp r2, 0x6
bne _081BA220
movs r4, 0
cmp r4, r5
bge _081BA1B0
mov r0, sp
ldrh r0, [r0]
cmp r0, r6
beq _081BA1B0
ldr r6, =gUnknown_03001298
ldr r3, =gFacilityTrainerMons
mov r2, sp
_081BA198:
adds r2, 0x2
adds r4, 0x1
cmp r4, r5
bge _081BA1B0
ldrh r0, [r6]
ldr r1, [r3]
lsls r0, 4
adds r0, r1
ldrh r1, [r2]
ldrh r0, [r0]
cmp r1, r0
bne _081BA198
_081BA1B0:
cmp r4, r5
bne _081BA220
movs r4, 0
cmp r4, r5
bge _081BA1E6
ldr r6, =gBattleFrontierHeldItems
mov r12, r6
add r3, sp, 0x8
_081BA1C0:
ldrh r2, [r3]
cmp r2, 0
beq _081BA1DE
ldr r1, =gUnknown_03001298
ldrh r0, [r1]
ldr r6, =gFacilityTrainerMons
ldr r1, [r6]
lsls r0, 4
adds r0, r1
ldrb r0, [r0, 0xA]
lsls r0, 1
add r0, r12
ldrh r0, [r0]
cmp r2, r0
beq _081BA1E6
_081BA1DE:
adds r3, 0x2
adds r4, 0x1
cmp r4, r5
blt _081BA1C0
_081BA1E6:
cmp r4, r5
bne _081BA220
lsls r2, r5, 1
ldrh r0, [r7]
ldr r1, =gFacilityTrainerMons
ldr r4, [r1]
lsls r0, 4
adds r0, r4
ldrh r0, [r0]
mov r3, r8
strh r0, [r3]
add r1, sp, 0x8
adds r1, r2
ldr r3, =gBattleFrontierHeldItems
ldrh r0, [r7]
lsls r0, 4
adds r0, r4
ldrb r0, [r0, 0xA]
lsls r0, 1
adds r0, r3
ldrh r0, [r0]
strh r0, [r1]
ldr r0, =gUnknown_03006298
adds r2, r0
ldrh r0, [r7]
strh r0, [r2]
movs r4, 0x2
add r8, r4
adds r5, 0x1
_081BA220:
cmp r5, 0x3
bne _081BA13E
add sp, 0x10
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r0}
bx r0
.pool
thumb_func_end sub_81BA040
.align 2, 0 @ Don't pad with nop.

View File

@ -8,3 +8,6 @@ gUnknown_03006208
gSaveUnusedVar
gSaveFileStatus
gGameContinueCallback
gRamSaveSectionLocations
gSaveUnusedVar2
gUnknown_03006294

View File

@ -6,29 +6,6 @@
.section .rodata
gUnknown_08610918:: @ 8610918
.byte 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, 0x00, 0x1f, 0x00
gUnknown_08610922:: @ 8610922
.byte 0x00, 0x02, 0x00
gUnknown_08610925:: @ 8610925
.byte 0x00, 0x04, 0x00
.align 2
gUnknown_08610928:: @ 8610928
.4byte 0x00000001, sub_819F20C
.4byte 0x00000001, sub_819F20C
.4byte 0x00000001, sub_819F20C
.4byte 0x00000003, sub_819F1AC
.align 2
gUnknown_08610948:: @ 8610948
.4byte 0x00000001, sub_819F20C
.4byte 0x00000001, sub_819F20C
.4byte 0x00000001, sub_819F20C
.4byte 0x00000002, sub_819F1DC
.4byte 0x00000003, sub_819F1AC
.align 2 @ struct, eight bytes x6 for names in different languages, then 0x28 more bytes of data
gUnknown_08610970:: @ 8610970

7
include/battle_factory.h Normal file
View File

@ -0,0 +1,7 @@
#ifndef GUARD_BATTLE_FACTORY_H
#define GUARD_BATTLE_FACTORY_H
void DoBattleFactorySelectScreen(void);
void DoBattleFactorySwapScreen(void);
#endif // GUARD_BATTLE_FACTORY_H

View File

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

View File

@ -31,7 +31,7 @@ struct BattleFrontierTrainer
u16 speechBefore[6];
u16 speechWin[6];
u16 speechLose[6];
u16 *btMonPool;
const u16 *btMonPool;
};
struct FacilityMon

View File

@ -35,7 +35,6 @@ void SetStandardWindowBorderStyle(u8 a0, u8 a1);
void sub_8197930(void);
u8 GetPlayerTextSpeed(void);
void sub_81978B0(u16 arg0);
void AddTextPrinterWithCallbackForMessage(bool8 a1, void (*callback)(struct TextSubPrinter *, u16));
void AddTextPrinterParameterized3(u8 windowId, u8 fontId, u8 left, u8 top, const u8 *color, s8 speed, const u8 *str);
void sub_8198070(u8 windowId, bool8 copyToVram);
@ -87,5 +86,6 @@ u8 AddMapNamePopUpWindow(void);
void AddTextPrinterParameterized5(u8 windowId, u8 fontId, const u8 *str, u8 left, u8 top, u8 speed, void (*callback)(struct TextSubPrinter *, u16), u8 letterSpacing, u8 lineSpacing);
void sub_8199C30(u8 bgId, u8 left, u8 top, u8 width, u8 height, u8 palette);
void sub_8199D3C(void *ptr, int delta, int width, int height, bool32 is8BPP);
void sub_8198204(const u8 *string, const u8 *string2, u8 a3, u8 a4, bool8 copyToVram);
#endif // GUARD_MENU_H

View File

@ -1,8 +1,6 @@
#ifndef GUARD_SAVE_H
#define GUARD_SAVE_H
extern u16 gSaveFileStatus;
struct SaveSectionLocation
{
void *data;
@ -58,6 +56,20 @@ enum
#define SECTION_ID_RECORDED_BATTLE 31
extern u16 gLastWrittenSector;
extern u32 gLastSaveCounter;
extern u16 gLastKnownGoodSector;
extern u32 gDamagedSaveSectors;
extern u32 gSaveCounter;
extern struct SaveSection *gFastSaveSection;
extern u16 gUnknown_03006208;
extern u16 gSaveFileStatus;
extern void (*gGameContinueCallback)(void);
extern struct SaveSectionLocation gRamSaveSectionLocations[];
extern u16 gUnknown_03006294;
extern struct SaveSection gSaveDataBuffer;
void ClearSaveData(void);
void Save_ResetSaveCounters(void);
bool32 SetDamagedSectorBits(u8 op, u8 bit);

View File

@ -256,7 +256,6 @@ SECTIONS {
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);
src/unk_81BAD84.o(.text);

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +1,15 @@
#include "global.h"
#include "battle_tent.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 "battle_factory.h"
#include "battle_frontier_2.h"
#include "constants/items.h"
#include "constants/region_map_sections.h"
@ -15,35 +17,40 @@ extern const struct BattleFrontierTrainer gSlateportBattleTentTrainers[];
extern const struct FacilityMon gSlateportBattleTentMons[];
extern const u16 gBattleFrontierHeldItems[];
extern u16 gUnknown_03006298[];
// 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);
static void sub_81B99D4(void);
static void sub_81B9A28(void);
static void sub_81B9A44(void);
static void sub_81B9A60(void);
static void sub_81B9A90(void);
static void sub_81B9ABC(void);
static void sub_81B9B00(void);
static void sub_81B9B28(void);
static void sub_81B9BA0(void);
static void sub_81B9BF4(void);
static void sub_81B9C10(void);
static void sub_81B9C2C(void);
static void sub_81B9C70(void);
static void sub_81B9C98(void);
static void sub_81B9CF0(void);
static void sub_81B9D28(void);
static void sub_81B9D7C(void);
static void sub_81B9D98(void);
static void sub_81B9DB4(void);
static void sub_81B9DF8(void);
static void sub_81B9E20(void);
static void sub_81B9E78(void);
static void sub_81B9E88(void);
static void sub_81BA040(void);
static void sub_81B9EC0(void);
// IWRAM bss
static IWRAM_DATA u16 sRandMonSetId;
// const rom data
void (*const gUnknown_086160B4[])(void) =
void static (*const gUnknown_086160B4[])(void) =
{
sub_81B99D4,
sub_81B9A28,
@ -57,7 +64,7 @@ void (*const gUnknown_086160B4[])(void) =
static const u16 sVerdanturfTentRewards[] = {ITEM_NEST_BALL};
void (*const gUnknown_086160D8[])(void) =
void static (*const gUnknown_086160D8[])(void) =
{
sub_81B9BA0,
sub_81B9BF4,
@ -70,7 +77,7 @@ void (*const gUnknown_086160D8[])(void) =
static const u16 sFallarborTentRewards[] = {ITEM_HYPER_POTION};
void (*const gUnknown_086160F8[])(void) =
void static (*const gUnknown_086160F8[])(void) =
{
sub_81B9D28,
sub_81B9D7C,
@ -92,7 +99,7 @@ void sub_81B99B4(void)
gUnknown_086160B4[gSpecialVar_0x8004]();
}
void sub_81B99D4(void)
static void sub_81B99D4(void)
{
gSaveBlock2Ptr->frontier.field_CA8 = 0;
gSaveBlock2Ptr->frontier.field_CB2 = 0;
@ -100,29 +107,29 @@ void sub_81B99D4(void)
saved_warp2_set(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1);
}
void sub_81B9A28(void)
static void sub_81B9A28(void)
{
gSpecialVar_Result = gSaveBlock2Ptr->frontier.field_E6A;
}
void sub_81B9A44(void)
static void sub_81B9A44(void)
{
gSaveBlock2Ptr->frontier.field_E6A = gSpecialVar_0x8006;
}
void sub_81B9A60(void)
static void sub_81B9A60(void)
{
gTrainerBattleOpponent_A = (u32)((Random() % 255) * 5) / 64;
sub_8162614(gTrainerBattleOpponent_A, 0);
}
void sub_81B9A90(void)
static void sub_81B9A90(void)
{
if (gTrainerBattleOpponent_A < 300)
ConvertBattleFrontierTrainerSpeechToString(gFacilityTrainers[gTrainerBattleOpponent_A].speechBefore);
}
void sub_81B9ABC(void)
static void sub_81B9ABC(void)
{
gSaveBlock2Ptr->frontier.field_CA8 = gSpecialVar_0x8005;
VarSet(VAR_TEMP_0, 0);
@ -130,12 +137,12 @@ void sub_81B9ABC(void)
sub_81A4C30();
}
void sub_81B9B00(void)
static void sub_81B9B00(void)
{
gSaveBlock2Ptr->frontier.field_E6A = sVerdanturfTentRewards[Random() % ARRAY_COUNT(sVerdanturfTentRewards)];
}
void sub_81B9B28(void)
static void sub_81B9B28(void)
{
if (AddBagItem(gSaveBlock2Ptr->frontier.field_E6A, 1) == TRUE)
{
@ -154,7 +161,7 @@ void sub_81B9B80(void)
gUnknown_086160D8[gSpecialVar_0x8004]();
}
void sub_81B9BA0(void)
static void sub_81B9BA0(void)
{
gSaveBlock2Ptr->frontier.field_CA8 = 0;
gSaveBlock2Ptr->frontier.field_CB2 = 0;
@ -162,17 +169,17 @@ void sub_81B9BA0(void)
saved_warp2_set(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1);
}
void sub_81B9BF4(void)
static void sub_81B9BF4(void)
{
gSpecialVar_Result = gSaveBlock2Ptr->frontier.field_E6C;
}
void sub_81B9C10(void)
static void sub_81B9C10(void)
{
gSaveBlock2Ptr->frontier.field_E6C = gSpecialVar_0x8006;
}
void sub_81B9C2C(void)
static void sub_81B9C2C(void)
{
gSaveBlock2Ptr->frontier.field_CA8 = gSpecialVar_0x8005;
VarSet(VAR_TEMP_0, 0);
@ -180,12 +187,12 @@ void sub_81B9C2C(void)
sub_81A4C30();
}
void sub_81B9C70(void)
static void sub_81B9C70(void)
{
gSaveBlock2Ptr->frontier.field_E6C = sFallarborTentRewards[Random() % ARRAY_COUNT(sFallarborTentRewards)];
}
void sub_81B9C98(void)
static void sub_81B9C98(void)
{
if (AddBagItem(gSaveBlock2Ptr->frontier.field_E6C, 1) == TRUE)
{
@ -199,7 +206,7 @@ void sub_81B9C98(void)
}
}
void sub_81B9CF0(void)
static void sub_81B9CF0(void)
{
GetFrontierTrainerName(gStringVar1, gTrainerBattleOpponent_A);
}
@ -209,7 +216,7 @@ void sub_81B9D08(void)
gUnknown_086160F8[gSpecialVar_0x8004]();
}
void sub_81B9D28(void)
static void sub_81B9D28(void)
{
gSaveBlock2Ptr->frontier.field_CA8 = 0;
gSaveBlock2Ptr->frontier.field_CB2 = 0;
@ -217,17 +224,17 @@ void sub_81B9D28(void)
saved_warp2_set(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1);
}
void sub_81B9D7C(void)
static void sub_81B9D7C(void)
{
gSpecialVar_Result = gSaveBlock2Ptr->frontier.field_E6E;
}
void sub_81B9D98(void)
static void sub_81B9D98(void)
{
gSaveBlock2Ptr->frontier.field_E6E = gSpecialVar_0x8006;
}
void sub_81B9DB4(void)
static void sub_81B9DB4(void)
{
gSaveBlock2Ptr->frontier.field_CA8 = gSpecialVar_0x8005;
VarSet(VAR_TEMP_0, 0);
@ -235,12 +242,12 @@ void sub_81B9DB4(void)
sub_81A4C30();
}
void sub_81B9DF8(void)
static void sub_81B9DF8(void)
{
gSaveBlock2Ptr->frontier.field_E6E = sSlateportTentRewards[Random() % ARRAY_COUNT(sSlateportTentRewards)];
}
void sub_81B9E20(void)
static void sub_81B9E20(void)
{
if (AddBagItem(gSaveBlock2Ptr->frontier.field_E6E, 1) == TRUE)
{
@ -254,15 +261,15 @@ void sub_81B9E20(void)
}
}
void sub_81B9E78(void)
static void sub_81B9E78(void)
{
ZeroPlayerPartyMons();
sub_819A4F8();
DoBattleFactorySelectScreen();
}
void sub_81B9E88(void)
static void sub_81B9E88(void)
{
sub_819DC00();
DoBattleFactorySwapScreen();
}
bool8 sub_81B9E94(void)
@ -273,7 +280,7 @@ bool8 sub_81B9E94(void)
// This function was written very...oddly.
#ifdef NONMATCHING
void sub_81B9EC0(void)
static void sub_81B9EC0(void)
{
s32 i, j;
u16 currMonId = 0, currSpecies = 0;
@ -335,7 +342,7 @@ void sub_81B9EC0(void)
}
#else
NAKED
void sub_81B9EC0(void)
static void sub_81B9EC0(void)
{
asm_unified("\n\
push {r4-r7,lr}\n\
@ -526,3 +533,74 @@ _081BA024:\n\
");
}
#endif // NONMATCHING
static void sub_81BA040(void)
{
u16 trainerId;
s32 i, j, k;
register const u16 *monSetsPool asm("r9"); // Fix me. Compiler insists on moving that variable into stack.
u16 species[3];
u16 heldItems[3];
s32 monPoolCount = 0;
gFacilityTrainers = gSlateportBattleTentTrainers;
gFacilityTrainerMons = gSlateportBattleTentMons;
while (1)
{
do
{
trainerId = Random() % 30;
for (i = 0; i < gSaveBlock2Ptr->frontier.field_CB2; i++)
{
if (gSaveBlock2Ptr->frontier.field_CB4[i] == trainerId)
break;
}
} while (i != gSaveBlock2Ptr->frontier.field_CB2);
gTrainerBattleOpponent_A = trainerId;
while (gFacilityTrainers[gTrainerBattleOpponent_A].btMonPool[monPoolCount] != 0xFFFF)
monPoolCount++;
if (monPoolCount > 8)
break;
monPoolCount = 0;
}
if (gSaveBlock2Ptr->frontier.field_CB2 < 2)
gSaveBlock2Ptr->frontier.field_CB4[gSaveBlock2Ptr->frontier.field_CB2] = gTrainerBattleOpponent_A;
monSetsPool = gFacilityTrainers[gTrainerBattleOpponent_A].btMonPool;
i = 0;
while (i != 3)
{
sRandMonSetId = monSetsPool[Random() % monPoolCount];
for (j = 0; j < 6; j++)
{
if (gFacilityTrainerMons[sRandMonSetId].species == gFacilityTrainerMons[gSaveBlock2Ptr->frontier.field_E70[j].monId].species)
break;
}
if (j != 6)
continue;
for (k = 0; k < i; k++)
{
if (species[k] == gFacilityTrainerMons[sRandMonSetId].species)
break;
}
if (k != i)
continue;
for (k = 0; k < i; k++)
{
if (heldItems[k] != 0 && heldItems[k] == gBattleFrontierHeldItems[gFacilityTrainerMons[sRandMonSetId].itemTableId])
break;
}
if (k != i)
continue;
species[i] = gFacilityTrainerMons[sRandMonSetId].species;
heldItems[i] = gBattleFrontierHeldItems[gFacilityTrainerMons[sRandMonSetId].itemTableId];
gUnknown_03006298[i] = sRandMonSetId;
i++;
}
}

View File

@ -28,6 +28,7 @@
#include "overworld.h"
#include "menu.h"
#include "trainer_pokemon_sprites.h"
#include "data2.h"
struct HallofFameMon
{
@ -57,10 +58,6 @@ static EWRAM_DATA struct HofGfx *sHofGfxPtr = NULL;
extern bool8 gHasHallOfFameRecords;
extern struct MusicPlayerInfo gMPlayInfo_BGM;
extern MainCallback gGameContinueCallback;
extern u32 gDamagedSaveSectors;
extern u8 gReservedSpritePaletteCount;
extern const u8 gSpeciesNames[][11];
#define HALL_OF_FAME_MAX_TEAMS 50
@ -84,10 +81,6 @@ extern const u8 gContestConfetti_Gfx[];
extern const u8 gContestConfetti_Pal[];
extern void sub_8175620(void);
extern u8 TrySavingData(u8);
extern void sub_8197434(u8, u8);
extern u16 sub_818D97C(u8 playerGender, u8);
extern void sub_8198204(u8 *dst, const u8 *src, u8, u8, u8);
extern bool8 sub_80F9C30(void);
extern void sub_8198314(void);
extern void ReturnFromHallOfFamePC(void);
@ -182,20 +175,18 @@ static const u8 sUnknown_085E5388[] = {0, 1, 2, 0};
static const u8 sUnknown_085E538C[] = {0, 2, 3, 0, 4, 5, 0, 0};
static const struct CompressedSpriteSheet sHallOfFame_ConfettiSpriteSheet =
static const struct CompressedSpriteSheet sHallOfFame_ConfettiSpriteSheet[] =
{
gContestConfetti_Gfx, 0x220, 1001
{gContestConfetti_Gfx, 0x220, 1001},
{},
};
static const u8 sUnused0[8] = {};
static const struct CompressedSpritePalette sHallOfFame_ConfettiSpritePalette =
static const struct CompressedSpritePalette sHallOfFame_ConfettiSpritePalette[] =
{
gContestConfetti_Pal, 1001
{gContestConfetti_Pal, 1001},
{},
};
static const u8 sUnused1[8] = {};
static const s16 sHallOfFame_MonFullTeamPositions[6][4] =
{
{120, 210, 120, 40},
@ -610,7 +601,7 @@ static void Task_Hof_DisplayMon(u8 taskId)
gSprites[spriteId].tSpecies = currMon->species;
gSprites[spriteId].callback = SpriteCB_GetOnScreenAndAnimate;
gTasks[taskId].tMonSpriteId(currMonId) = spriteId;
sub_8197434(0, 1);
sub_8197434(0, TRUE);
gTasks[taskId].func = Task_Hof_PrintMonInfoAfterAnimating;
}
@ -964,9 +955,9 @@ static void Task_HofPC_DrawSpritesPrintText(u8 taskId)
StringExpandPlaceholders(gStringVar4, gText_HOFNumber);
if (gTasks[taskId].tCurrTeamNo <= 0)
sub_8198204(gStringVar4, gText_PickCancel, 0, 0, 1);
sub_8198204(gStringVar4, gText_PickCancel, 0, 0, TRUE);
else
sub_8198204(gStringVar4, gText_PickNextCancel, 0, 0, 1);
sub_8198204(gStringVar4, gText_PickNextCancel, 0, 0, TRUE);
gTasks[taskId].func = Task_HofPC_PrintMonInfo;
}
@ -1300,8 +1291,8 @@ static void sub_8174F70(void)
ResetAllPicSprites();
FreeAllSpritePalettes();
gReservedSpritePaletteCount = 8;
LoadCompressedObjectPic(&sHallOfFame_ConfettiSpriteSheet);
LoadCompressedObjectPalette(&sHallOfFame_ConfettiSpritePalette);
LoadCompressedObjectPic(sHallOfFame_ConfettiSpriteSheet);
LoadCompressedObjectPalette(sHallOfFame_ConfettiSpritePalette);
}
static void sub_8174FAC(void)
@ -1517,8 +1508,8 @@ static void sub_8175364(u8 taskId)
gSpecialVar_0x8004 = var;
gSpecialVar_0x8005 = 0xFFFF;
}
LoadCompressedObjectPic(&sHallOfFame_ConfettiSpriteSheet);
LoadCompressedObjectPalette(&sHallOfFame_ConfettiSpritePalette);
LoadCompressedObjectPic(sHallOfFame_ConfettiSpriteSheet);
LoadCompressedObjectPalette(sHallOfFame_ConfettiSpritePalette);
data[0]++;
break;
case 1:

View File

@ -9,8 +9,6 @@
// for the chunk declarations
extern struct SaveSectionLocation gRamSaveSectionLocations[0xE];
extern u16 gUnknown_03006294;
extern bool8 gSoftResetDisabled;
extern u32 gUnknown_0203CF5C;
@ -83,6 +81,9 @@ u16 gUnknown_03006208;
u16 gSaveUnusedVar;
u16 gSaveFileStatus;
void (*gGameContinueCallback)(void);
struct SaveSectionLocation gRamSaveSectionLocations[0xE];
u16 gSaveUnusedVar2;
u16 gUnknown_03006294;
EWRAM_DATA struct SaveSection gSaveDataBuffer = {0};

View File

@ -4,6 +4,7 @@
#include "palette.h"
#include "gpu_regs.h"
#include "bg.h"
#include "decompress.h"
#include "task.h"
#include "window.h"
#include "menu.h"
@ -14,16 +15,11 @@
#define MSG_WIN_TOP 12
#define CLOCK_WIN_TOP (MSG_WIN_TOP - 4)
extern void (*gGameContinueCallback)(void);
extern u32 gDamagedSaveSectors;
extern const u8 gBirchHelpGfx[];
extern const u8 gBirchBagTilemap[];
extern const u8 gBirchGrassTilemap[];
extern const u16 gBirchBagGrassPal[];
extern const u16 gUnknown_0860F074[];
extern struct SaveSection gSaveDataBuffer;
extern u8 gText_SaveFailedCheckingBackup[];
extern u8 gText_BackupMemoryDamaged[];
@ -32,8 +28,6 @@ extern u8 gText_SaveCompleteGameCannotContinue[];
extern u8 gText_SaveCompletePressA[];
extern u8 gText_GamePlayCannotBeContinued[];
extern u8 gDecompressionBuffer[];
// gSaveFailedClockInfo enum
enum
{

View File

@ -98,9 +98,7 @@ gUnknown_03001290: @ 3001290
gUnknown_03001294: @ 3001294
.space 0x4
gUnknown_03001298: @ 3001298
.space 0x4
.include "src/battle_tent.o"
.include "src/multiboot.o"
.space 0x4 @ XXX: why is this needed?

View File

@ -99,14 +99,6 @@ gUnknown_030061EC: @ 30061EC
.include "save.o"
.space 0x8
gRamSaveSectionLocations: @ 3006220
.space 0x74
gUnknown_03006294: @ 3006294
.space 0x4
gUnknown_03006298: @ 3006298
.space 0x8