More lo hanging fruit

This commit is contained in:
Adrienn Tindall 2023-07-29 01:21:45 -04:00
parent 1f3256dfae
commit 442d04ae15
15 changed files with 148 additions and 282 deletions

View File

@ -171,7 +171,7 @@
.public BattleSystem_GetPartyMon
.public ov12_0223A8E4
.public ov12_0223A938
.public ov12_0223A9F4
.public BattleSystem_GetTrainer
.public BattleSystem_GetBag
.public BattleSystem_GetBagCursor
.public ov12_0223AB0C

View File

@ -128,9 +128,9 @@
.public ov12_0223A8F4
.public ov12_0223A930
.public ov12_0223A938
.public ov12_0223A93C
.public BattleSystem_GetPokedex
.public ov12_0223A9A4
.public ov12_0223A9A8
.public BattleSystem_GetMessageBuffer
.public ov12_0223AAB8
.public ov12_0223AAD8
.public BattleSystem_GetFieldSide

View File

@ -168,7 +168,7 @@
.public ov12_0223A938
.public ov12_0223A99C
.public BattleSystem_GetTrainerIndex
.public ov12_0223A9F4
.public BattleSystem_GetTrainer
.public BattleSystem_GetPlayerProfile
.public BattleSystem_GetBag
.public ov12_0223AAC8

View File

@ -30,7 +30,7 @@
.public BattleSystem_GetOpponentData
.public BattleSystem_GetMaxBattlers
.public BattleSystem_GetParty
.public ov12_0223A9F4
.public BattleSystem_GetTrainer
.public BattleSystem_GetPlayerProfile
.public BattleSystem_GetBag
.public BattleSystem_GetBagCursor

View File

@ -87,7 +87,7 @@
.public ov12_0223A930
.public ov12_0223A934
.public ov12_0223A938
.public ov12_0223A93C
.public BattleSystem_GetPokedex
.public BattleSystem_GetSendBufferPtr
.public BattleSystem_GetRecvBufferPtr
.public ov12_0223A954
@ -98,9 +98,9 @@
.public ov12_0223A990
.public ov12_0223A99C
.public ov12_0223A9A4
.public ov12_0223A9A8
.public BattleSystem_GetMessageBuffer
.public BattleSystem_GetTrainerIndex
.public ov12_0223A9F4
.public BattleSystem_GetTrainer
.public BattleSystem_GetPlayerProfile
.public BattleSystem_GetBag
.public BattleSystem_GetBagCursor

View File

@ -3461,7 +3461,7 @@ ov08_0221D91C: ; 0x0221D91C
add r1, r0, #0
ldr r0, [r5]
ldr r0, [r0, #8]
bl ov12_0223A9F4
bl BattleSystem_GetTrainer
add r2, r0, #0
ldr r0, _0221DABC ; =0x00001FAC
mov r1, #0

View File

@ -2225,7 +2225,7 @@ _02246A72:
bl BattleSystem_GetPartyMon
str r0, [sp, #0xdc]
ldr r0, [r4]
bl ov12_0223A93C
bl BattleSystem_GetPokedex
bl Pokedex_IsNatDexEnabled
str r0, [sp, #0xe0]
bl sub_02021BD0
@ -5167,7 +5167,7 @@ ov12_02248228: ; 0x02248228
bl ov12_0223A930
str r0, [sp, #0x28]
add r0, r7, #0
bl ov12_0223A9A8
bl BattleSystem_GetMessageBuffer
str r0, [sp, #0x20]
add r0, r7, #0
bl ov12_0223A9A4

View File

@ -3504,7 +3504,7 @@ ov12_0225A2A0: ; 0x0225A2A0
_0225A2DA:
ldrb r1, [r5, r1]
add r0, r6, #0
bl ov12_0223A9F4
bl BattleSystem_GetTrainer
add r2, r0, #0
mov r0, #0
strb r0, [r4, #0xb]

View File

@ -5842,7 +5842,7 @@ _0224DA80:
_0224DA96:
ldr r0, [sp]
mov r1, #1
bl ov12_0223A9F4
bl BattleSystem_GetTrainer
ldrb r0, [r0, #1]
sub r0, #0x42
cmp r0, #0x2e

View File

@ -6,257 +6,6 @@
.text
thumb_func_start ov12_0223A930
ov12_0223A930: ; 0x0223A930
ldr r0, [r0, #0xc]
bx lr
thumb_func_end ov12_0223A930
thumb_func_start ov12_0223A934
ov12_0223A934: ; 0x0223A934
ldr r0, [r0, #0x10]
bx lr
thumb_func_end ov12_0223A934
thumb_func_start ov12_0223A938
ov12_0223A938: ; 0x0223A938
ldr r0, [r0, #0x28]
bx lr
thumb_func_end ov12_0223A938
thumb_func_start ov12_0223A93C
ov12_0223A93C: ; 0x0223A93C
ldr r0, [r0, #0x60]
bx lr
thumb_func_end ov12_0223A93C
thumb_func_start BattleSystem_GetSendBufferPtr
BattleSystem_GetSendBufferPtr: ; 0x0223A940
mov r1, #0x8a
lsl r1, r1, #2
add r0, r0, r1
bx lr
thumb_func_end BattleSystem_GetSendBufferPtr
thumb_func_start BattleSystem_GetRecvBufferPtr
BattleSystem_GetRecvBufferPtr: ; 0x0223A948
ldr r1, _0223A950 ; =0x00001228
add r0, r0, r1
bx lr
nop
_0223A950: .word 0x00001228
thumb_func_end BattleSystem_GetRecvBufferPtr
thumb_func_start ov12_0223A954
ov12_0223A954: ; 0x0223A954
ldr r1, _0223A95C ; =0x000023E8
add r0, r0, r1
bx lr
nop
_0223A95C: .word 0x000023E8
thumb_func_end ov12_0223A954
thumb_func_start ov12_0223A960
ov12_0223A960: ; 0x0223A960
ldr r1, _0223A968 ; =0x000023EA
add r0, r0, r1
bx lr
nop
_0223A968: .word 0x000023EA
thumb_func_end ov12_0223A960
thumb_func_start ov12_0223A96C
ov12_0223A96C: ; 0x0223A96C
ldr r1, _0223A974 ; =0x000023EC
add r0, r0, r1
bx lr
nop
_0223A974: .word 0x000023EC
thumb_func_end ov12_0223A96C
thumb_func_start ov12_0223A978
ov12_0223A978: ; 0x0223A978
ldr r1, _0223A980 ; =0x000023EE
add r0, r0, r1
bx lr
nop
_0223A980: .word 0x000023EE
thumb_func_end ov12_0223A978
thumb_func_start ov12_0223A984
ov12_0223A984: ; 0x0223A984
ldr r1, _0223A98C ; =0x000023F0
add r0, r0, r1
bx lr
nop
_0223A98C: .word 0x000023F0
thumb_func_end ov12_0223A984
thumb_func_start ov12_0223A990
ov12_0223A990: ; 0x0223A990
ldr r1, _0223A998 ; =0x000023F2
add r0, r0, r1
bx lr
nop
_0223A998: .word 0x000023F2
thumb_func_end ov12_0223A990
thumb_func_start ov12_0223A99C
ov12_0223A99C: ; 0x0223A99C
mov r1, #0x1d
lsl r1, r1, #4
add r0, r0, r1
bx lr
thumb_func_end ov12_0223A99C
thumb_func_start ov12_0223A9A4
ov12_0223A9A4: ; 0x0223A9A4
ldr r0, [r0, #0x14]
bx lr
thumb_func_end ov12_0223A9A4
thumb_func_start ov12_0223A9A8
ov12_0223A9A8: ; 0x0223A9A8
ldr r0, [r0, #0x18]
bx lr
thumb_func_end ov12_0223A9A8
thumb_func_start BattleSystem_GetTrainerIndex
BattleSystem_GetTrainerIndex: ; 0x0223A9AC
push {r3, r4, r5, lr}
add r5, r0, #0
ldr r2, [r5, #0x2c]
mov r3, #8
add r4, r1, #0
tst r3, r2
bne _0223A9CA
mov r3, #0x10
tst r2, r3
beq _0223A9D4
bl ov12_0223AB0C
mov r1, #1
tst r0, r1
beq _0223A9D4
_0223A9CA:
lsl r0, r4, #1
add r0, r5, r0
add r0, #0xa0
ldrh r0, [r0]
pop {r3, r4, r5, pc}
_0223A9D4:
ldr r1, [r5, #0x2c]
mov r0, #2
tst r0, r1
beq _0223A9E8
lsl r0, r4, #0x1f
lsr r0, r0, #0x1e
add r0, r5, r0
add r0, #0xa0
ldrh r0, [r0]
pop {r3, r4, r5, pc}
_0223A9E8:
lsl r0, r4, #1
add r0, r5, r0
add r0, #0xa0
ldrh r0, [r0]
pop {r3, r4, r5, pc}
.balign 4, 0
thumb_func_end BattleSystem_GetTrainerIndex
thumb_func_start ov12_0223A9F4
ov12_0223A9F4: ; 0x0223A9F4
push {r3, r4, r5, lr}
add r5, r0, #0
ldr r2, [r5, #0x2c]
mov r3, #8
add r4, r1, #0
tst r3, r2
bne _0223AA12
mov r3, #0x10
tst r2, r3
beq _0223AA1C
bl ov12_0223AB0C
mov r1, #1
tst r0, r1
beq _0223AA1C
_0223AA12:
mov r0, #0x34
add r5, #0xac
mul r0, r4
add r0, r5, r0
pop {r3, r4, r5, pc}
_0223AA1C:
ldr r1, [r5, #0x2c]
mov r0, #2
tst r0, r1
beq _0223AA34
mov r0, #1
add r1, r4, #0
and r1, r0
mov r0, #0x34
add r5, #0xac
mul r0, r1
add r0, r5, r0
pop {r3, r4, r5, pc}
_0223AA34:
mov r0, #0x34
add r5, #0xac
mul r0, r4
add r0, r5, r0
pop {r3, r4, r5, pc}
.balign 4, 0
thumb_func_end ov12_0223A9F4
thumb_func_start BattleSystem_GetPlayerProfile
BattleSystem_GetPlayerProfile: ; 0x0223AA40
push {r3, r4, r5, lr}
add r5, r0, #0
ldr r2, [r5, #0x2c]
mov r3, #8
add r4, r1, #0
tst r3, r2
bne _0223AA5E
mov r3, #0x10
tst r2, r3
beq _0223AA66
bl ov12_0223AB0C
mov r1, #1
tst r0, r1
beq _0223AA66
_0223AA5E:
lsl r0, r4, #2
add r0, r5, r0
ldr r0, [r0, #0x48]
pop {r3, r4, r5, pc}
_0223AA66:
ldr r1, [r5, #0x2c]
mov r0, #2
tst r0, r1
beq _0223AA78
lsl r0, r4, #0x1f
lsr r0, r0, #0x1d
add r0, r5, r0
ldr r0, [r0, #0x48]
pop {r3, r4, r5, pc}
_0223AA78:
lsl r0, r4, #2
add r0, r5, r0
ldr r0, [r0, #0x48]
pop {r3, r4, r5, pc}
thumb_func_end BattleSystem_GetPlayerProfile
thumb_func_start BattleSystem_GetBag
BattleSystem_GetBag: ; 0x0223AA80
ldr r0, [r0, #0x58]
bx lr
thumb_func_end BattleSystem_GetBag
thumb_func_start BattleSystem_GetBagCursor
BattleSystem_GetBagCursor: ; 0x0223AA84
ldr r0, [r0, #0x5c]
bx lr
thumb_func_end BattleSystem_GetBagCursor
thumb_func_start BattleSystem_GetMonBall
BattleSystem_GetMonBall: ; 0x0223AA88
push {r3, lr}
@ -5145,7 +4894,7 @@ ov12_0223CEB4: ; 0x0223CEB4
add r4, r1, #0
add r5, r0, #0
add r1, r2, #0
bl ov12_0223A9F4
bl BattleSystem_GetTrainer
add r2, r0, #0
ldr r0, [r5, #0x14]
add r1, r4, #0
@ -5159,7 +4908,7 @@ ov12_0223CECC: ; 0x0223CECC
add r4, r1, #0
add r5, r0, #0
add r1, r2, #0
bl ov12_0223A9F4
bl BattleSystem_GetTrainer
add r2, r0, #0
ldr r0, [r5, #0x14]
add r1, r4, #0

View File

@ -1,10 +1,14 @@
#ifndef POKEHEARTGOLD_BATTLE_H
#define POKEHEARTGOLD_BATTLE_H
#include "bag.h"
#include "bag_cursor.h"
#include "bg_window.h"
#include "item.h"
#include "font.h"
#include "move.h"
#include "player_data.h"
#include "pokedex.h"
#include "pokemon_storage_system.h"
#include "trainer_data.h"
#include "filesystem.h"
@ -509,19 +513,19 @@ struct BattleSystem {
u32 *unkC;
u32 *unk10;
u32 *unk14;
u32 *unk18;
String *msgBuffer;
u32 unk1C;
u32 unk20;
u32 unk24;
u32 unk28;
void *unk28;
u32 battleType;
BATTLECONTEXT *ctx;
OpponentData *opponentData[4];
int maxBattlers;
u32 *unk48[4];
u32 *unk58;
u32 *unk5C;
u32 *unk60;
PlayerProfile *playerProfile[4];
Bag *bag;
BagCursor *bagCursor;
Pokedex *pokedex;
PC_STORAGE *storage;
PARTY *trainerParty[4];
u32 *unk78[4];
@ -552,8 +556,8 @@ struct BattleSystem {
u32 *unk22C;
u8 *unk230;
u16 *unk234;
u8 unk238[0x1000];
u8 unk1238[0x1000];
u8 sendBuffer[0x1000];
u8 recvBuffer[0x1000];
u16 unk2238[0x70];
u16 unk2318[0x70];
u16 unk23E8; //labeling may be wrong before here

View File

@ -3,7 +3,6 @@
#include "bag.h"
#include "battle.h"
#include "player_data.h"
#include "pokemon.h"
#include "sav_chatot.h"
@ -26,11 +25,31 @@ u32 *ov12_0223A908(BattleSystem *bsys, int index);
void ov12_0223A914(BattleSystem *bsys, int index, u32 *a2);
FontID *BattleSystem_GetHpFont(BattleSystem *bsys);
FontID *BattleSystem_GetLevelFont(BattleSystem *bsys);
u32 *ov12_0223A930(BattleSystem *bsys);
u32 *ov12_0223A934(BattleSystem *bsys);
void *ov12_0223A938(BattleSystem *bsys);
Pokedex *BattleSystem_GetPokedex(BattleSystem *bsys);
u8 *BattleSystem_GetSendBufferPtr(BattleSystem *bsys);
u8 *BattleSystem_GetRecvBufferPtr(BattleSystem *bsys);
u16 *ov12_0223A954(BattleSystem *bsys);
u16 *ov12_0223A960(BattleSystem *bsys);
u16 *ov12_0223A96C(BattleSystem *bsys);
u16 *ov12_0223A978(BattleSystem *bsys);
u16 *ov12_0223A984(BattleSystem *bsys);
u16 *ov12_0223A990(BattleSystem *bsys);
UnkBattleSystemSub1D0 *ov12_0223A99C(BattleSystem *bsys);
u32 *ov12_0223A9A4(BattleSystem *bsys);
String *BattleSystem_GetMessageBuffer(BattleSystem *bsys);
u16 BattleSystem_GetTrainerIndex(BattleSystem *bsys, int battlerId);
TRAINER *BattleSystem_GetTrainer(BattleSystem *bsys, int battlerId);
PlayerProfile *BattleSystem_GetPlayerProfile(BattleSystem *bsys, int a1);
Bag *BattleSystem_GetBag(BattleSystem *bsys);
BagCursor *BattleSystem_GetBagCursor(BattleSystem *bsys);
u8 BattleSystem_GetMonBall(BattleSystem *bsys, Pokemon *mon);
//These functions haven't been decompiled
u32 BattleSystem_GetFieldSide(BattleSystem *bsys, int battlerId);
int BattleSystem_Random(BattleSystem *bsys);
PlayerProfile *BattleSystem_GetPlayerProfile(BattleSystem *bsys, int a1);
int BattleSystem_GetTerrainId(BattleSystem *bsys);
int ov12_0223ABB8(BattleSystem *bsys, int battlerId, int a2);
void BattleSystem_RecoverStatus(BattleSystem *bsys, int battlerIdA, int battlerIdB, int a2, int itemWork);
@ -39,14 +58,12 @@ void PokedexSetBattlerSeen(BattleSystem *bsys, int battlerId);
SOUND_CHATOT *BattleSystem_GetChatotVoice(BattleSystem *bsys, int battlerId);
int BattleSystem_GetChatotVoiceParam(BattleSystem *bsys, int battlerId);
int BattleSystem_GetBattlerIdPartner(BattleSystem *bsys, int battlerId);
int BattleSystem_GetTrainerIndex(BattleSystem *bsys, int battlerId);
BOOL Link_QueueNotEmpty(BATTLECONTEXT *ctx);
BOOL BattleSystem_AreBattleAnimationsOn(BattleSystem *bsys);
BOOL ov12_0223C080(BattleSystem *bsys);
void ov12_0223BFFC(BattleSystem *bsys, u32 a1);
void *ov12_0223A938(BattleSystem *bsys);
int ov12_0223AB54(BattleSystem *bsys);
u8 BattleSystem_GetMonBall(BattleSystem *bsys, Pokemon *mon);
u32 BattleSystem_GetWinLoseFlags(BattleSystem *bsys);
void ov12_0223C0C4(BattleSystem *bsys);
int BattleSystem_GetWeather(BattleSystem *bsys);
@ -56,8 +73,6 @@ void ov12_0223BB64(BattleSystem *bsys, int a1);
void ov12_02237ED0(BattleSystem *bsys, int a1);
void ov12_022642F0(BattleSystem *bsys);
BOOL ov12_022581BC(BattleSystem *bsys, BATTLECONTEXT *ctx);
Bag *BattleSystem_GetBag(BattleSystem *bsys);
BagCursor *BattleSystem_GetBagCursor(BattleSystem *bsys);
int ov12_0223B6B4(BattleSystem *bsys);
void ov12_0223B6C0(BattleSystem *bsys, int item);
void ov12_02263A1C(BattleSystem *bsys, BATTLECONTEXT *ctx, int battlerId);

View File

@ -129,7 +129,7 @@ void Link_CheckTimeout(BATTLECONTEXT *ctx);
BOOL CheckLegalMeFirstMove(BATTLECONTEXT *ctx, u16 move);
int ov12_02253DA0(BattleSystem *bsys, BATTLECONTEXT *ctx, int battlerId);
u32 BattleSystem_GetBattleSpecial(BattleSystem *bsys);
u32 ov12_0223C24C(PARTY *party, u32 *a1);
u32 ov12_0223C24C(PARTY *party, PlayerProfile *profile);
int ov12_02251D28(BattleSystem *bsys, BATTLECONTEXT *ctx, int moveNo, int moveType, int battlerIdAttacker, int battlerIdTarget, int dmg, u32 *statusFlag);
void ov12_02252D14(BattleSystem *bsys, BATTLECONTEXT *ctx);
void ov12_0225859C(BATTLECONTEXT *ctx, u8 battlerId);

View File

@ -2175,7 +2175,7 @@ BOOL BtlCmd_CalcPrizeMoney(BattleSystem *bsys, BATTLECONTEXT *ctx) {
}
PlayerProfile_AddMoney(BattleSystem_GetPlayerProfile(bsys, 0), prizeMoney);
} else {
prizeMoney = ov12_0223C24C(bsys->trainerParty[0], bsys->unk48[0]);
prizeMoney = ov12_0223C24C(bsys->trainerParty[0], bsys->playerProfile[0]);
PlayerProfile_SubMoney(BattleSystem_GetPlayerProfile(bsys, 0), prizeMoney);
}

View File

@ -95,3 +95,101 @@ FontID *BattleSystem_GetHpFont(BattleSystem *bsys) {
FontID *BattleSystem_GetLevelFont(BattleSystem *bsys) {
return bsys->levelFont;
}
u32 *ov12_0223A930(BattleSystem *bsys) {
return bsys->unkC;
}
u32 *ov12_0223A934(BattleSystem *bsys) {
return bsys->unk10;
}
void *ov12_0223A938(BattleSystem *bsys) {
return bsys->unk28;
}
Pokedex *BattleSystem_GetPokedex(BattleSystem *bsys) {
return bsys->pokedex;
}
u8 *BattleSystem_GetSendBufferPtr(BattleSystem *bsys) {
return &bsys->sendBuffer[0];
}
u8 *BattleSystem_GetRecvBufferPtr(BattleSystem *bsys) {
return &bsys->recvBuffer[0];
}
u16 *ov12_0223A954(BattleSystem *bsys) {
return &bsys->unk23E8;
}
u16 *ov12_0223A960(BattleSystem *bsys) {
return &bsys->unk23EA;
}
u16 *ov12_0223A96C(BattleSystem *bsys) {
return &bsys->unk23EC;
}
u16 *ov12_0223A978(BattleSystem *bsys) {
return &bsys->unk23EE;
}
u16 *ov12_0223A984(BattleSystem *bsys) {
return &bsys->unk23F0;
}
u16 *ov12_0223A990(BattleSystem *bsys) {
return &bsys->unk23F2;
}
UnkBattleSystemSub1D0 *ov12_0223A99C(BattleSystem *bsys) {
return &bsys->unk1D0[0];
}
u32 *ov12_0223A9A4(BattleSystem *bsys) {
return bsys->unk14;
}
String *BattleSystem_GetMessageBuffer(BattleSystem *bsys) {
return bsys->msgBuffer;
}
u16 BattleSystem_GetTrainerIndex(BattleSystem *bsys, int battlerId) {
if ((bsys->battleType & BATTLE_TYPE_MULTI) || ((bsys->battleType & BATTLE_TYPE_INGAME_PARTNER) && (ov12_0223AB0C(bsys, battlerId) & 1))) {
return bsys->trainerId[battlerId];
} else if (bsys->battleType & BATTLE_TYPE_DOUBLES) {
return bsys->trainerId[battlerId & 1];
} else {
return bsys->trainerId[battlerId];
}
}
TRAINER *BattleSystem_GetTrainer(BattleSystem *bsys, int battlerId) {
if ((bsys->battleType & BATTLE_TYPE_MULTI) || ((bsys->battleType & BATTLE_TYPE_INGAME_PARTNER) && (ov12_0223AB0C(bsys, battlerId) & 1))) {
return &bsys->trainers[battlerId];
} else if (bsys->battleType & BATTLE_TYPE_DOUBLES) {
return &bsys->trainers[battlerId & 1];
} else {
return &bsys->trainers[battlerId];
}
}
PlayerProfile *BattleSystem_GetPlayerProfile(BattleSystem *bsys, int battlerId) {
if ((bsys->battleType & BATTLE_TYPE_MULTI) || ((bsys->battleType & BATTLE_TYPE_INGAME_PARTNER) && (ov12_0223AB0C(bsys, battlerId) & 1))) {
return bsys->playerProfile[battlerId];
} else if (bsys->battleType & BATTLE_TYPE_DOUBLES) {
return bsys->playerProfile[battlerId & 1];
} else {
return bsys->playerProfile[battlerId];
}
}
Bag *BattleSystem_GetBag(BattleSystem *bsys) {
return bsys->bag;
}
BagCursor *BattleSystem_GetBagCursor(BattleSystem *bsys) {
return bsys->bagCursor;
}