more recorded battle done

This commit is contained in:
DizzyEggg 2017-11-13 00:10:34 +01:00
parent c4674735d2
commit 3b43668286
3 changed files with 113 additions and 378 deletions

View File

@ -6,364 +6,7 @@
.text
thumb_func_start RecordedBattle_SetBankAction
RecordedBattle_SetBankAction: @ 8184FBC
push {r4-r6,lr}
lsls r0, 24
lsrs r5, r0, 24
lsls r1, 24
lsrs r6, r1, 24
ldr r1, =sRecordedBytesNo
lsls r0, r5, 1
adds r4, r0, r1
ldrh r2, [r4]
adds r3, r2, 0
ldr r0, =0x00000297
cmp r3, r0
bhi _08184FF0
ldr r0, =gUnknown_0203C7AC
ldrb r0, [r0]
cmp r0, 0x2
beq _08184FF0
ldr r1, =sBattleRecords
adds r0, r2, 0x1
strh r0, [r4]
movs r0, 0xA6
lsls r0, 2
muls r0, r5
adds r0, r3, r0
adds r0, r1
strb r6, [r0]
_08184FF0:
pop {r4-r6}
pop {r0}
bx r0
.pool
thumb_func_end RecordedBattle_SetBankAction
thumb_func_start RecordedBattle_ClearBankAction
RecordedBattle_ClearBankAction: @ 8185008
push {r4-r7,lr}
lsls r0, 24
lsrs r5, r0, 24
lsls r1, 24
lsrs r4, r1, 24
movs r3, 0
cmp r3, r4
bge _08185046
ldr r0, =sRecordedBytesNo
lsls r1, r5, 1
adds r2, r1, r0
ldr r7, =sBattleRecords
movs r0, 0xA6
lsls r0, 2
muls r5, r0
movs r6, 0xFF
_08185028:
ldrh r0, [r2]
subs r0, 0x1
strh r0, [r2]
ldrh r1, [r2]
adds r1, r5
adds r1, r7
ldrb r0, [r1]
orrs r0, r6
strb r0, [r1]
ldrh r0, [r2]
cmp r0, 0
beq _08185046
adds r3, 0x1
cmp r3, r4
blt _08185028
_08185046:
pop {r4-r7}
pop {r0}
bx r0
.pool
thumb_func_end RecordedBattle_ClearBankAction
thumb_func_start RecordedBattle_ReadBankAction
RecordedBattle_ReadBankAction: @ 8185054
push {r4,lr}
sub sp, 0x4
lsls r0, 24
lsrs r3, r0, 24
ldr r1, =sRecordedBytesNo
lsls r0, r3, 1
adds r2, r0, r1
ldrh r1, [r2]
ldr r0, =0x00000297
cmp r1, r0
bhi _0818507A
ldr r4, =sBattleRecords
adds r0, 0x1
muls r3, r0
adds r0, r1, r3
adds r0, r4
ldrb r0, [r0]
cmp r0, 0xFF
bne _081850BC
_0818507A:
ldr r2, =gScriptResult
ldr r1, =gBattleOutcome
movs r0, 0x5
strb r0, [r1]
movs r0, 0x5
strh r0, [r2]
bl ResetPaletteFadeControl
movs r0, 0x1
negs r0, r0
movs r1, 0
str r1, [sp]
movs r2, 0
movs r3, 0x10
bl BeginNormalPaletteFade
ldr r0, =CB2_QuitRecordedBattle
bl SetMainCallback2
movs r0, 0xFF
b _081850C6
.pool
_081850BC:
adds r0, r1, 0x1
strh r0, [r2]
adds r0, r1, r3
adds r0, r4
ldrb r0, [r0]
_081850C6:
add sp, 0x4
pop {r4}
pop {r1}
bx r1
thumb_func_end RecordedBattle_ReadBankAction
thumb_func_start sub_81850D0
sub_81850D0: @ 81850D0
ldr r0, =gUnknown_0203C7AC
ldrb r0, [r0]
bx lr
.pool
thumb_func_end sub_81850D0
thumb_func_start sub_81850DC
sub_81850DC: @ 81850DC
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
sub sp, 0x4
mov r8, r0
movs r7, 0
movs r0, 0
mov r12, r0
_081850F0:
mov r1, r12
lsls r3, r1, 1
ldr r0, =sRecordedBytesNo
adds r5, r3, r0
ldr r1, =gUnknown_0203C79C
adds r6, r3, r1
ldrh r0, [r5]
mov r9, r3
mov r1, r12
adds r1, 0x1
str r1, [sp]
ldrh r1, [r6]
cmp r0, r1
beq _0818517E
adds r1, r7, 0
adds r0, r1, 0x1
lsls r0, 24
lsrs r7, r0, 24
adds r2, r7, 0
add r1, r8
mov r0, r12
strb r0, [r1]
adds r0, r2, 0x1
lsls r0, 24
lsrs r7, r0, 24
add r2, r8
ldrb r0, [r5]
ldrb r1, [r6]
subs r0, r1
strb r0, [r2]
movs r4, 0
ldrh r0, [r5]
ldrh r1, [r6]
subs r0, r1
cmp r4, r0
bge _08185172
ldr r1, =sBattleRecords
mov r10, r1
ldr r6, =gUnknown_0203C79C
movs r0, 0xA6
lsls r0, 2
mov r5, r12
muls r5, r0
_08185146:
adds r1, r7, 0
adds r0, r1, 0x1
lsls r0, 24
lsrs r7, r0, 24
add r1, r8
adds r2, r3, r6
ldrh r0, [r2]
adds r0, r4
adds r0, r5
add r0, r10
ldrb r0, [r0]
strb r0, [r1]
adds r0, r4, 0x1
lsls r0, 24
lsrs r4, r0, 24
ldr r1, =sRecordedBytesNo
adds r0, r3, r1
ldrh r1, [r0]
ldrh r0, [r2]
subs r1, r0
cmp r4, r1
blt _08185146
_08185172:
ldr r0, =gUnknown_0203C79C
add r0, r9
ldr r1, =sRecordedBytesNo
add r1, r9
ldrh r1, [r1]
strh r1, [r0]
_0818517E:
ldr r1, [sp]
lsls r0, r1, 24
lsrs r0, 24
mov r12, r0
cmp r0, 0x3
bls _081850F0
adds r0, r7, 0
add sp, 0x4
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r1}
bx r1
.pool
thumb_func_end sub_81850DC
thumb_func_start sub_81851A8
sub_81851A8: @ 81851A8
push {r4-r7,lr}
mov r7, r8
push {r7}
sub sp, 0x8
adds r7, r0, 0
movs r1, 0x2
mov r0, sp
strb r1, [r0]
ldr r0, =gBattleTypeFlags
ldr r0, [r0]
ands r0, r1
cmp r0, 0
beq _0818525E
movs r5, 0
ldr r4, =gLinkPlayers
b _081851DA
.pool
_081851D0:
ldrb r0, [r4]
cmp r0, 0x3
bne _0818525E
adds r4, 0x1C
adds r5, 0x1
_081851DA:
bl GetLinkPlayerCount
lsls r0, 24
lsrs r0, 24
cmp r5, r0
blt _081851D0
ldr r0, =gBattleTypeFlags
ldr r0, [r0]
movs r1, 0x4
ands r0, r1
cmp r0, 0
bne _0818525E
ldrb r0, [r7]
mov r4, sp
adds r4, 0x1
strb r0, [r4]
ldrb r0, [r4]
mov r8, r4
cmp r0, 0
beq _0818525E
_08185202:
adds r0, r7, 0
mov r1, sp
adds r2, r4, 0
bl sub_8185278
lsls r0, 24
lsrs r6, r0, 24
adds r0, r7, 0
mov r1, sp
adds r2, r4, 0
bl sub_8185278
lsls r0, 24
lsrs r2, r0, 24
cmp r2, 0
beq _08185256
ldr r3, =sBattleRecords
ldr r0, =gUnknown_0203C7A4
lsls r1, r6, 1
adds r4, r1, r0
adds r5, r2, 0
movs r0, 0xA6
lsls r0, 2
muls r6, r0
_08185232:
adds r0, r7, 0
mov r1, sp
mov r2, r8
str r3, [sp, 0x4]
bl sub_8185278
ldrh r1, [r4]
adds r2, r1, 0x1
strh r2, [r4]
lsls r1, 16
lsrs r1, 16
adds r1, r6
ldr r3, [sp, 0x4]
adds r1, r3
strb r0, [r1]
subs r5, 0x1
cmp r5, 0
bne _08185232
_08185256:
mov r4, r8
ldrb r0, [r4]
cmp r0, 0
bne _08185202
_0818525E:
add sp, 0x8
pop {r3}
mov r8, r3
pop {r4-r7}
pop {r0}
bx r0
.pool
thumb_func_end sub_81851A8
thumb_func_start sub_8185278
sub_8185278: @ 8185278
ldrb r3, [r2]
subs r3, 0x1
strb r3, [r2]
ldrb r2, [r1]
adds r3, r2, 0x1
strb r3, [r1]
lsls r2, 24
lsrs r2, 24
adds r0, r2
ldrb r0, [r0]
bx lr
thumb_func_end sub_8185278
thumb_func_start sub_8185290
sub_8185290: @ 8185290

View File

@ -7,6 +7,7 @@
#include "event_data.h"
#include "link.h"
#include "string_util.h"
#include "palette.h"
#define BANK_RECORD_SIZE 664
@ -42,11 +43,18 @@ EWRAM_DATA struct Pokemon sSavedPlayerParty[PARTY_SIZE] = {0};
EWRAM_DATA struct Pokemon sSavedOpponentParty[PARTY_SIZE] = {0};
EWRAM_DATA u16 gUnknown_0203CC70[8] = {0};
EWRAM_DATA struct PlayerInfo sRecordedBattle_Players[BATTLE_BANKS_COUNT] = {0};
extern u8 gUnknown_0203CCD0;
EWRAM_DATA u8 gUnknown_0203CCD0 = 0;
EWRAM_DATA u8 gUnknown_0203CCD1[8] = {0};
EWRAM_DATA u8 gUnknown_0203CCD9 = 0;
EWRAM_DATA u8 gUnknown_0203CCDA = 0;
EWRAM_DATA u16 gUnknown_0203CCDC[6] = {0};
EWRAM_DATA u8 gUnknown_0203CCE8 = 0;
extern u32 sub_81A513C(void);
// this file's functions
static u8 sub_8185278(u8 *arg0, u8 *arg1, u8 *arg2);
void sub_8184DA4(u8 arg0)
{
s32 i, j;
@ -130,3 +138,106 @@ void sub_8184E58(void)
sRecordedBattle_Players[0].name[i] = gSaveBlock2Ptr->playerName[i];
}
}
void RecordedBattle_SetBankAction(u8 bank, u8 action)
{
if (sRecordedBytesNo[bank] < BANK_RECORD_SIZE && gUnknown_0203C7AC != 2)
{
sBattleRecords[bank][sRecordedBytesNo[bank]++] = action;
}
}
void RecordedBattle_ClearBankAction(u8 bank, u8 bytesToClear)
{
s32 i;
for (i = 0; i < bytesToClear; i++)
{
sRecordedBytesNo[bank]--;
sBattleRecords[bank][sRecordedBytesNo[bank]] |= 0xFF;
if (sRecordedBytesNo[bank] == 0)
break;
}
}
u8 RecordedBattle_ReadBankAction(u8 bank)
{
// trying to read past array or invalid action byte, battle is over
if (sRecordedBytesNo[bank] >= BANK_RECORD_SIZE || sBattleRecords[bank][sRecordedBytesNo[bank]] == 0xFF)
{
gScriptResult = gBattleOutcome = BATTLE_PLAYER_TELEPORTED; // hah
ResetPaletteFadeControl();
BeginNormalPaletteFade(-1, 0, 0, 0x10, 0);
SetMainCallback2(CB2_QuitRecordedBattle);
return 0xFF;
}
else
{
return sBattleRecords[bank][sRecordedBytesNo[bank]++];
}
}
u8 sub_81850D0(void)
{
return gUnknown_0203C7AC;
}
u8 sub_81850DC(u8 *arg0)
{
u8 i, j;
u8 ret = 0;
for (i = 0; i < BATTLE_BANKS_COUNT; i++)
{
if (sRecordedBytesNo[i] != gUnknown_0203C79C[i])
{
arg0[ret++] = i;
arg0[ret++] = sRecordedBytesNo[i] - gUnknown_0203C79C[i];
for (j = 0; j < sRecordedBytesNo[i] - gUnknown_0203C79C[i]; j++)
{
arg0[ret++] = sBattleRecords[i][gUnknown_0203C79C[i] + j];
}
gUnknown_0203C79C[i] = sRecordedBytesNo[i];
}
}
return ret;
}
void sub_81851A8(u8 *arg0)
{
s32 i;
u8 var1 = 2;
u8 var2;
if (!(gBattleTypeFlags & BATTLE_TYPE_LINK))
return;
for (i = 0; i < GetLinkPlayerCount(); i++)
{
if ((gLinkPlayers[i].version & 0xFF) != VERSION_EMERALD)
return;
}
if (!(gBattleTypeFlags & BATTLE_TYPE_WILD))
{
for (var2 = *arg0; var2 != 0;)
{
u8 unkVar = sub_8185278(arg0, &var1, &var2);
u8 unkVar2 = sub_8185278(arg0, &var1, &var2);
for (i = 0; i < unkVar2; i++)
{
sBattleRecords[unkVar][gUnknown_0203C7A4[unkVar]++] = sub_8185278(arg0, &var1, &var2);
}
}
}
}
static u8 sub_8185278(u8 *arg0, u8 *arg1, u8 *arg2)
{
(*arg2)--;
return arg0[(*arg1)++];
}

View File

@ -1455,25 +1455,6 @@ gUnknown_0203BD28: @ 203BD28
.space 0x4
.include "src/recorded_battle.o"
gUnknown_0203CCD0: @ 203CCD0
.space 0x1
gUnknown_0203CCD1: @ 203CCD1
.space 0x8
gUnknown_0203CCD9: @ 203CCD9
.space 0x1
gUnknown_0203CCDA: @ 203CCDA
.space 0x2
gUnknown_0203CCDC: @ 203CCDC
.space 0xC
gUnknown_0203CCE8: @ 203CCE8
.space 0x4
.include "src/battle_dome_cards.o"
.include "src/lilycove_lady.o"