start apprentice

This commit is contained in:
DizzyEggg 2018-10-13 00:48:26 +02:00
parent a2a6700966
commit 74b81bf229
3 changed files with 164 additions and 490 deletions

View File

@ -5,494 +5,8 @@
.text .text
thumb_func_start sub_819F99C
sub_819F99C: @ 819F99C
push {r4-r7,lr}
mov r7, r8
push {r7}
lsls r0, 24
lsrs r5, r0, 24
ldr r2, =gSaveBlock2Ptr
ldr r1, [r2]
lsls r0, r5, 4
adds r0, r5
lsls r0, 2
adds r1, r0
adds r1, 0xDE
ldrb r1, [r1]
movs r6, 0
adds r7, r2, 0
ldr r0, =gStringVar1
mov r8, r0
cmp r1, 0
beq _0819F9DC
_0819F9C2:
adds r0, r1, 0
movs r1, 0xA
bl __udivsi3
lsls r0, 24
lsrs r1, r0, 24
adds r0, r6, 0x1
lsls r0, 24
lsrs r6, r0, 24
cmp r1, 0
beq _0819F9DC
cmp r6, 0x3
bls _0819F9C2
_0819F9DC:
lsls r4, r5, 4
adds r4, r5
lsls r4, 2
ldr r1, [r7]
adds r1, r4, r1
movs r0, 0x8A
lsls r0, 1
adds r1, r0
mov r0, r8
bl StringCopy7
ldr r0, [r7]
adds r0, r4
ldr r1, =0x0000011b
adds r0, r1
ldrb r1, [r0]
mov r0, r8
bl ConvertInternationalString
ldr r0, =gStringVar2
ldr r1, [r7]
adds r1, r4
adds r1, 0xDE
ldrb r1, [r1]
movs r2, 0x1
adds r3, r6, 0
bl ConvertIntToDecimalStringN
ldr r1, =gUnknown_08611330
ldr r0, [r7]
adds r0, r4
adds r0, 0xDC
ldrb r0, [r0]
lsls r0, 27
lsrs r0, 25
adds r0, r1
ldr r1, [r0]
ldr r0, =gStringVar4
bl StringExpandPlaceholders
pop {r3}
mov r8, r3
pop {r4-r7}
pop {r0}
bx r0
.pool
thumb_func_end sub_819F99C
thumb_func_start sub_819FA50
sub_819FA50: @ 819FA50
push {lr}
bl EnableBothScriptContexts
pop {r0}
bx r0
thumb_func_end sub_819FA50
thumb_func_start sub_819FA5C
sub_819FA5C: @ 819FA5C
push {r4,r5,lr}
adds r3, r0, 0
movs r2, 0
adds r4, r3, 0
adds r4, 0x28
ldr r0, =0x0000ffff
adds r5, r0, 0
_0819FA6A:
lsls r0, r2, 1
adds r0, r4, r0
ldrh r1, [r0]
orrs r1, r5
strh r1, [r0]
adds r0, r2, 0x1
lsls r0, 24
lsrs r2, r0, 24
cmp r2, 0x5
bls _0819FA6A
adds r1, r3, 0
adds r1, 0x38
movs r0, 0xFF
strb r0, [r1]
ldrb r1, [r3]
movs r0, 0x20
negs r0, r0
ands r0, r1
movs r1, 0x10
orrs r0, r1
strb r0, [r3]
pop {r4,r5}
pop {r0}
bx r0
.pool
thumb_func_end sub_819FA5C
thumb_func_start sub_819FAA0
sub_819FAA0: @ 819FAA0
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
ldr r3, =gSaveBlock2Ptr
ldr r1, [r3]
adds r1, 0xB2
ldrb r2, [r1]
movs r0, 0x19
negs r0, r0
ands r0, r2
strb r0, [r1]
movs r0, 0
mov r12, r0
adds r5, r3, 0
mov r8, r0
ldr r1, =0x0000ffff
mov r10, r1
_0819FAC6:
movs r2, 0
mov r3, r12
lsls r7, r3, 4
movs r4, 0x1
add r4, r12
mov r9, r4
adds r0, r7, r3
lsls r3, r0, 2
_0819FAD6:
ldr r1, [r5]
lsls r0, r2, 1
adds r0, r3
movs r4, 0x82
lsls r4, 1
adds r1, r4
adds r1, r0
ldrh r0, [r1]
mov r4, r10
orrs r0, r4
strh r0, [r1]
adds r0, r2, 0x1
lsls r0, 24
lsrs r2, r0, 24
cmp r2, 0x5
bls _0819FAD6
ldr r2, [r5]
mov r0, r12
adds r3, r7, r0
lsls r3, 2
adds r2, r3
adds r2, 0xDC
ldrb r1, [r2]
movs r0, 0x20
negs r0, r0
ands r0, r1
movs r1, 0x10
orrs r0, r1
strb r0, [r2]
ldr r0, [r5]
adds r0, r3
movs r1, 0x8A
lsls r1, 1
adds r0, r1
movs r1, 0xFF
strb r1, [r0]
ldr r1, [r5]
adds r1, r3
adds r1, 0xDC
ldrb r2, [r1]
movs r0, 0x61
negs r0, r0
ands r0, r2
strb r0, [r1]
ldr r0, [r5]
adds r0, r3
adds r0, 0xDE
mov r4, r8
strb r4, [r0]
ldr r0, [r5]
adds r0, r3
adds r0, 0xDD
strb r4, [r0]
movs r2, 0
ldr r6, =gSaveBlock2Ptr
movs r4, 0x88
lsls r4, 1
_0819FB48:
ldr r0, [r6]
adds r1, r2, r3
adds r0, r4
adds r0, r1
mov r1, r8
strb r1, [r0]
adds r0, r2, 0x1
lsls r0, 24
lsrs r2, r0, 24
cmp r2, 0x3
bls _0819FB48
ldr r0, [r5]
mov r3, r12
adds r2, r7, r3
lsls r2, 2
adds r0, r2
ldr r4, =gGameLanguage
ldrb r1, [r4]
ldr r3, =0x0000011b
adds r0, r3
strb r1, [r0]
ldr r0, [r5]
movs r4, 0x8E
lsls r4, 1
adds r0, r4
adds r0, r2
mov r1, r8
str r1, [r0]
mov r3, r9
lsls r0, r3, 24
lsrs r0, 24
mov r12, r0
cmp r0, 0x3
bls _0819FAC6
bl sub_81A087C
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r0}
bx r0
.pool
thumb_func_end sub_819FAA0
thumb_func_start sub_819FBB0
sub_819FBB0: @ 819FBB0
ldr r0, =gSaveBlock2Ptr
ldr r0, [r0]
adds r0, 0xB1
ldrb r0, [r0]
movs r1, 0x3
ands r1, r0
negs r0, r1
orrs r0, r1
lsrs r0, 31
bx lr
.pool
thumb_func_end sub_819FBB0
thumb_func_start sub_819FBC8
sub_819FBC8: @ 819FBC8
push {r4,r5,lr}
ldr r2, =gSaveBlock2Ptr
ldr r0, [r2]
adds r0, 0xDE
ldrb r0, [r0]
cmp r0, 0
bne _0819FC10
adds r4, r2, 0
ldr r5, =gUnknown_08611548
_0819FBDA:
bl Random
ldr r2, [r4]
lsls r0, 16
movs r1, 0xE0
lsls r1, 11
ands r1, r0
lsrs r1, 16
adds r1, r5
ldrb r0, [r1]
adds r2, 0xB0
strb r0, [r2]
ldr r0, [r4]
adds r1, r0, 0
adds r1, 0xB0
adds r0, 0xDC
ldrb r0, [r0]
lsls r0, 27
ldrb r1, [r1]
lsrs r0, 27
cmp r1, r0
beq _0819FBDA
b _0819FC38
.pool
_0819FC10:
adds r4, r2, 0
_0819FC12:
bl Random
ldr r2, [r4]
lsls r0, 16
lsrs r0, 16
movs r1, 0xF
ands r0, r1
adds r2, 0xB0
strb r0, [r2]
ldr r0, [r4]
adds r1, r0, 0
adds r1, 0xB0
adds r0, 0xDC
ldrb r0, [r0]
lsls r0, 27
ldrb r1, [r1]
lsrs r0, 27
cmp r1, r0
beq _0819FC12
_0819FC38:
pop {r4,r5}
pop {r0}
bx r0
thumb_func_end sub_819FBC8
thumb_func_start sub_819FC40
sub_819FC40: @ 819FC40
lsls r0, 24
lsrs r0, 24
ldr r1, =gSaveBlock2Ptr
ldr r2, [r1]
adds r2, 0xB1
movs r1, 0x3
ands r0, r1
ldrb r3, [r2]
subs r1, 0x7
ands r1, r3
orrs r1, r0
strb r1, [r2]
bx lr
.pool
thumb_func_end sub_819FC40
thumb_func_start sub_819FC60
sub_819FC60: @ 819FC60
push {r4-r7,lr}
sub sp, 0xC
movs r5, 0
_0819FC66:
mov r1, sp
adds r0, r1, r5
strb r5, [r0]
adds r0, r5, 0x1
lsls r0, 24
lsrs r5, r0, 24
cmp r5, 0x9
bls _0819FC66
movs r5, 0
_0819FC78:
bl Random
lsls r0, 16
lsrs r0, 16
movs r1, 0xA
bl __umodsi3
adds r4, r0, 0
lsls r4, 24
lsrs r4, 24
bl Random
lsls r0, 16
lsrs r0, 16
movs r1, 0xA
bl __umodsi3
lsls r0, 24
lsrs r0, 24
mov r7, sp
adds r2, r7, r4
ldrb r3, [r2]
adds r1, r7, r0
ldrb r0, [r1]
strb r0, [r2]
strb r3, [r1]
adds r0, r5, 0x1
lsls r0, 24
lsrs r5, r0, 24
cmp r5, 0x31
bls _0819FC78
movs r5, 0
ldr r6, =gSaveBlock2Ptr
movs r4, 0xF
_0819FCBC:
ldr r3, [r6]
adds r3, 0xB4
adds r3, r5
lsls r2, r5, 1
mov r1, sp
adds r0, r1, r2
ldrb r0, [r0]
adds r1, r4, 0
ands r1, r0
lsls r1, 4
adds r2, 0x1
mov r7, sp
adds r0, r7, r2
ldrb r2, [r0]
adds r0, r4, 0
ands r0, r2
orrs r1, r0
strb r1, [r3]
adds r0, r5, 0x1
lsls r0, 24
lsrs r5, r0, 24
cmp r5, 0x2
bls _0819FCBC
add sp, 0xC
pop {r4-r7}
pop {r0}
bx r0
.pool
thumb_func_end sub_819FC60
thumb_func_start sub_819FCF8
sub_819FCF8: @ 819FCF8
push {r4-r6,lr}
lsls r0, 24
lsrs r0, 24
movs r5, 0
cmp r0, 0x2
bne _0819FD4C
ldr r6, =gUnknown_030062EC
_0819FD06:
bl Random
lsls r0, 16
lsrs r0, 16
movs r1, 0x3
bl __umodsi3
lsls r0, 24
lsrs r5, r0, 24
movs r3, 0
movs r2, 0
ldr r1, [r6]
lsls r0, r5, 2
adds r0, r5
lsls r4, r0, 1
adds r1, 0x2
_0819FD26:
lsls r0, r2, 1
adds r0, r4
adds r0, r1, r0
ldrh r0, [r0]
cmp r0, 0
beq _0819FD38
adds r0, r3, 0x1
lsls r0, 24
lsrs r3, r0, 24
_0819FD38:
adds r0, r2, 0x1
lsls r0, 24
lsrs r2, r0, 24
cmp r2, 0x4
bls _0819FD26
cmp r3, 0x3
bhi _0819FD06
b _0819FD5A
.pool
_0819FD4C:
cmp r0, 0x1
bne _0819FD5A
ldrb r0, [r2]
adds r1, r0
ldrb r5, [r1]
adds r0, 0x1
strb r0, [r2]
_0819FD5A:
adds r0, r5, 0
pop {r4-r6}
pop {r1}
bx r1
thumb_func_end sub_819FCF8
thumb_func_start sub_819FD64 thumb_func_start sub_819FD64
sub_819FD64: @ 819FD64 sub_819FD64: @ 819FD64

View File

@ -297,9 +297,16 @@ struct UnknownSaveBlock2Struct
struct UnkRecordMixingStruct struct UnkRecordMixingStruct
{ {
u8 field_0[0x34]; u8 field_0_0:5;
u8 field_0_1:2;
u8 field_1;
u8 field_2;
u8 field_3[37];
u16 unk28[6];
u8 playerId[4]; u8 playerId[4];
u8 field_38[10]; u8 playerName[PLAYER_NAME_LENGTH];
u8 language;
u32 unk40;
}; };
struct UnknownPokemonStruct struct UnknownPokemonStruct
@ -492,10 +499,12 @@ struct SaveBlock2
// TODO: fix and verify labels // TODO: fix and verify labels
/*0xB0*/ u8 field_B0; /*0xB0*/ u8 field_B0;
/*0xB1*/ u8 field_B1; /*0xB1*/ u8 field_B1_0:2;
/*0xB1*/ u8 field_B1_1:6;
/*0xB2*/ u8 field_B2_0:3; /*0xB2*/ u8 field_B2_0:3;
/*0xB2*/ u8 field_B2_1:2; /*0xB2*/ u8 field_B2_1:2;
/*0xB3*/ u8 field_B3[0x29]; /*0xB3*/ u8 field_B3;
/*0xB4*/ u8 field_B4[0x28];
/*0xDC*/ struct UnkRecordMixingStruct field_DC[4]; /*0xDC*/ struct UnkRecordMixingStruct field_DC[4];
/*0x1EC*/ struct BerryCrush berryCrush; /*0x1EC*/ struct BerryCrush berryCrush;
/*0x1FC*/ struct PokemonJumpResults pokeJump; /*0x1FC*/ struct PokemonJumpResults pokeJump;

151
src/battle_frontier_2.c Normal file
View File

@ -0,0 +1,151 @@
#include "global.h"
#include "string_util.h"
#include "script.h"
#include "text.h"
#include "random.h"
#include "main.h"
struct Unk030062ECStruct
{
u8 unk0;
u16 unk2[3][5];
};
extern struct Unk030062ECStruct *gUnknown_030062EC;
extern const u8 *const gUnknown_08611330[];
extern const u8 gUnknown_08611548[8];
// This file's functions.
void sub_81A087C(void);
void sub_819F99C(u8 id)
{
u8 i, var;
const u8 *str;
var = gSaveBlock2Ptr->field_DC[id].field_2;
for (i = 0; var != 0 && i < 4; i++)
{
var /= 10;
}
StringCopy7(gStringVar1, gSaveBlock2Ptr->field_DC[id].playerName);
ConvertInternationalString(gStringVar1, gSaveBlock2Ptr->field_DC[id].language);
ConvertIntToDecimalStringN(gStringVar2, gSaveBlock2Ptr->field_DC[id].field_2, STR_CONV_MODE_RIGHT_ALIGN, i);
str = gUnknown_08611330[gSaveBlock2Ptr->field_DC[id].field_0_0];
StringExpandPlaceholders(gStringVar4, str);
}
void sub_819FA50(void)
{
EnableBothScriptContexts();
}
void sub_819FA5C(struct UnkRecordMixingStruct *structPtr)
{
u8 i;
for (i = 0; i < 6; i++)
structPtr->unk28[i] |= 0xFFFF;
structPtr->playerName[0] = EOS;
structPtr->field_0_0 = 16;
}
void sub_819FAA0(void)
{
u8 i, j;
gSaveBlock2Ptr->field_B2_1 = 0;
for (i = 0; i < 4; i++)
{
for (j = 0; j < 6; j++)
gSaveBlock2Ptr->field_DC[i].unk28[j] |= 0xFFFF;
gSaveBlock2Ptr->field_DC[i].field_0_0 = 16;
gSaveBlock2Ptr->field_DC[i].playerName[0] = EOS;
gSaveBlock2Ptr->field_DC[i].field_0_1 = 0;
gSaveBlock2Ptr->field_DC[i].field_2 = 0;
gSaveBlock2Ptr->field_DC[i].field_1 = 0;
for (j = 0; j < 4; j++)
gSaveBlock2Ptr->field_DC[i].playerId[j] = 0;
gSaveBlock2Ptr->field_DC[i].language = gGameLanguage;
gSaveBlock2Ptr->field_DC[i].unk40 = 0;
}
sub_81A087C();
}
u8 sub_819FBB0(void)
{
return (gSaveBlock2Ptr->field_B1_0 != 0);
}
void sub_819FBC8(void)
{
if (gSaveBlock2Ptr->field_DC[0].field_2 == 0)
{
do
{
gSaveBlock2Ptr->field_B0 = gUnknown_08611548[Random() % ARRAY_COUNT(gUnknown_08611548)];
} while (gSaveBlock2Ptr->field_B0 == gSaveBlock2Ptr->field_DC[0].field_0_0);
}
else
{
do
{
gSaveBlock2Ptr->field_B0 = Random() % 16;
} while (gSaveBlock2Ptr->field_B0 == gSaveBlock2Ptr->field_DC[0].field_0_0);
}
}
void sub_819FC40(u8 value)
{
gSaveBlock2Ptr->field_B1_0 = value;
}
void sub_819FC60(void)
{
u8 array[10];
u8 i;
for (i = 0; i < ARRAY_COUNT(array); i++)
array[i] = i;
for (i = 0; i < 50; i++)
{
u8 temp;
u8 var1 = Random() % ARRAY_COUNT(array);
u8 var2 = Random() % ARRAY_COUNT(array);
SWAP(array[var1], array[var2], temp);
}
for (i = 0; i < 3; i++)
gSaveBlock2Ptr->field_B4[i] = ((array[i * 2] & 0xF) << 4) | ((array[i * 2 + 1]) & 0xF);
}
u8 sub_819FCF8(u8 val, u8 *arg1, u8 *arg2)
{
u8 i, count;
u8 ret = 0;
if (val == 2)
{
do
{
ret = Random() % 3;
for (count = 0, i = 0; i < 5; i++)
{
if (gUnknown_030062EC->unk2[ret][i] != 0)
count++;
}
} while (count > 3);
}
else if (val == 1)
{
ret = arg1[*arg2];
(*arg2)++;
}
return ret;
}