through sub_8121064

This commit is contained in:
PikalaxALT 2018-05-03 17:51:14 -04:00
parent 1943118a1e
commit 876e1eb7cc
2 changed files with 137 additions and 361 deletions

View File

@ -5,366 +5,6 @@
.text
thumb_func_start sub_8120E08
sub_8120E08: @ 8120E08
push {r4,r5,lr}
ldr r2, =gUnknown_0203A12C
ldr r0, =gSaveBlock1Ptr
ldr r0, [r0]
ldr r1, =0x00002e28
adds r0, r1
str r0, [r2]
movs r3, 0
movs r1, 0x3
strb r1, [r0]
ldr r0, [r2]
strb r3, [r0, 0x1]
movs r5, 0
movs r4, 0xFF
_08120E24:
ldr r0, [r2]
adds r0, 0x4
adds r0, r3
strb r5, [r0]
ldr r1, [r2]
adds r1, 0x8
adds r1, r3
ldrb r0, [r1]
orrs r0, r4
strb r0, [r1]
adds r3, 0x1
cmp r3, 0x3
ble _08120E24
pop {r4,r5}
pop {r0}
bx r0
.pool
thumb_func_end sub_8120E08
thumb_func_start sub_8120E50
sub_8120E50: @ 8120E50
ldr r3, =gUnknown_0203A12C
ldr r0, =gSaveBlock1Ptr
ldr r0, [r0]
ldr r1, =0x00002e28
adds r0, r1
str r0, [r3]
movs r2, 0
movs r1, 0x3
strb r1, [r0]
ldr r0, [r3]
strb r2, [r0, 0x1]
bx lr
.pool
thumb_func_end sub_8120E50
thumb_func_start sub_8120E74
sub_8120E74: @ 8120E74
push {lr}
lsls r0, 24
lsrs r0, 24
cmp r0, 0x32
bne _08120E80
movs r0, 0
_08120E80:
bl GetGameStat
pop {r1}
bx r1
thumb_func_end sub_8120E74
thumb_func_start sub_8120E88
sub_8120E88: @ 8120E88
push {lr}
adds r3, r0, 0
movs r2, 0
ldr r1, =gUnknown_0859F048
_08120E90:
ldrb r0, [r1]
cmp r0, r3
bne _08120EA0
adds r0, r1, 0
b _08120EAA
.pool
_08120EA0:
adds r1, 0x10
adds r2, 0x1
cmp r2, 0x23
ble _08120E90
ldr r0, =gUnknown_0859F048+0x230
_08120EAA:
pop {r1}
bx r1
.pool
thumb_func_end sub_8120E88
thumb_func_start sub_8120EB4
sub_8120EB4: @ 8120EB4
push {lr}
bl sub_8120E88
ldr r0, [r0, 0x4]
pop {r1}
bx r1
thumb_func_end sub_8120EB4
thumb_func_start sub_8120EC0
sub_8120EC0: @ 8120EC0
push {lr}
bl sub_8120E88
ldr r0, [r0, 0xC]
pop {r1}
bx r1
thumb_func_end sub_8120EC0
thumb_func_start sub_8120ECC
sub_8120ECC: @ 8120ECC
push {lr}
bl sub_8120E88
ldr r0, [r0, 0x8]
pop {r1}
bx r1
thumb_func_end sub_8120ECC
thumb_func_start sub_8120ED8
sub_8120ED8: @ 8120ED8
push {lr}
movs r1, 0
ldr r2, =gUnknown_0203A12C
ldr r0, [r2]
ldrb r0, [r0, 0x4]
cmp r0, 0
beq _08120EFC
_08120EE6:
adds r0, r1, 0x1
lsls r0, 24
lsrs r1, r0, 24
cmp r1, 0x3
bhi _08120EFC
ldr r0, [r2]
adds r0, 0x4
adds r0, r1
ldrb r0, [r0]
cmp r0, 0
bne _08120EE6
_08120EFC:
adds r0, r1, 0
pop {r1}
bx r1
.pool
thumb_func_end sub_8120ED8
thumb_func_start sub_8120F08
sub_8120F08: @ 8120F08
ldr r1, =gUnknown_0203A12C
lsls r0, 2
adds r0, 0x24
ldr r2, [r1]
adds r2, r0
ldrb r0, [r2]
ldrb r1, [r2, 0x1]
lsls r1, 8
orrs r0, r1
ldrb r1, [r2, 0x2]
lsls r1, 16
orrs r0, r1
ldrb r1, [r2, 0x3]
lsls r1, 24
orrs r0, r1
bx lr
.pool
thumb_func_end sub_8120F08
thumb_func_start sub_8120F2C
sub_8120F2C: @ 8120F2C
ldr r2, =gUnknown_0203A12C
lsls r0, 2
adds r0, 0x24
ldr r2, [r2]
adds r2, r0
strb r1, [r2]
lsrs r0, r1, 8
strb r0, [r2, 0x1]
lsrs r0, r1, 16
strb r0, [r2, 0x2]
lsrs r1, 24
strb r1, [r2, 0x3]
bx lr
.pool
thumb_func_end sub_8120F2C
thumb_func_start sub_8120F4C
sub_8120F4C: @ 8120F4C
push {r4,r5,lr}
adds r5, r0, 0
ldr r0, =gUnknown_0203A12C
ldr r0, [r0]
adds r0, 0x4
adds r0, r5
ldrb r0, [r0]
bl sub_8120E74
adds r4, r0, 0
adds r0, r5, 0
bl sub_8120F08
cmp r4, r0
bhi _08120F74
movs r0, 0
b _08120F76
.pool
_08120F74:
movs r0, 0x1
_08120F76:
pop {r4,r5}
pop {r1}
bx r1
thumb_func_end sub_8120F4C
thumb_func_start sub_8120F7C
sub_8120F7C: @ 8120F7C
push {r4,r5,lr}
adds r5, r1, 0
ldr r2, =gUnknown_0203A12C
lsls r1, r0, 3
subs r1, r0
adds r1, 0x8
ldr r4, [r2]
adds r4, r1
adds r0, r5, 0
movs r1, 0xFF
movs r2, 0x8
bl memset
adds r0, r5, 0
adds r1, r4, 0
movs r2, 0x7
bl memcpy
pop {r4,r5}
pop {r0}
bx r0
.pool
thumb_func_end sub_8120F7C
thumb_func_start sub_8120FAC
sub_8120FAC: @ 8120FAC
push {r4,r5,lr}
adds r5, r1, 0
ldr r2, =gUnknown_0203A12C
lsls r1, r0, 3
subs r1, r0
adds r1, 0x8
ldr r4, [r2]
adds r4, r1
adds r0, r4, 0
movs r1, 0xFF
movs r2, 0x7
bl memset
adds r0, r4, 0
adds r1, r5, 0
movs r2, 0x7
bl memcpy
pop {r4,r5}
pop {r0}
bx r0
.pool
thumb_func_end sub_8120FAC
thumb_func_start sub_8120FDC
sub_8120FDC: @ 8120FDC
push {r4-r6,lr}
mov r6, r9
mov r5, r8
push {r5,r6}
mov r8, r0
adds r6, r1, 0
ldr r0, =gUnknown_0203A12C
mov r9, r0
ldr r0, [r0]
adds r0, 0x4
add r0, r8
strb r6, [r0]
ldr r0, =gSaveBlock2Ptr
ldr r1, [r0]
mov r0, r8
bl sub_8120FAC
lsls r4, r6, 24
lsrs r4, 24
adds r0, r4, 0
bl sub_8120E74
adds r1, r0, 0
mov r0, r8
bl sub_8120F2C
ldr r5, =gStringVar1
adds r0, r4, 0
bl sub_8120E74
adds r1, r0, 0
adds r0, r5, 0
movs r2, 0
movs r3, 0xA
bl ConvertIntToDecimalStringN
ldr r4, =gStringVar2
adds r0, r6, 0
bl sub_8120ECC
adds r1, r0, 0
adds r0, r4, 0
bl StringCopy
mov r1, r9
ldr r0, [r1]
adds r0, 0x34
add r0, r8
ldr r1, =gGameLanguage
ldrb r1, [r1]
strb r1, [r0]
pop {r3,r4}
mov r8, r3
mov r9, r4
pop {r4-r6}
pop {r0}
bx r0
.pool
thumb_func_end sub_8120FDC
thumb_func_start sub_8121064
sub_8121064: @ 8121064
push {r4-r7,lr}
adds r7, r0, 0
adds r6, r1, 0
movs r5, 0
cmp r5, r6
bge _0812107A
_08121070:
adds r0, r7, r5
strb r5, [r0]
adds r5, 0x1
cmp r5, r6
blt _08121070
_0812107A:
cmp r6, 0
ble _081210B0
adds r5, r6, 0
_08121080:
bl Random
lsls r0, 16
lsrs r0, 16
adds r1, r6, 0
bl __modsi3
adds r4, r0, 0
bl Random
lsls r0, 16
lsrs r0, 16
adds r1, r6, 0
bl __modsi3
adds r4, r7, r4
ldrb r2, [r4]
adds r0, r7, r0
ldrb r1, [r0]
strb r1, [r4]
strb r2, [r0]
subs r5, 0x1
cmp r5, 0
bne _08121080
_081210B0:
pop {r4-r7}
pop {r0}
bx r0
thumb_func_end sub_8121064
thumb_func_start sub_81210B8
sub_81210B8: @ 81210B8
push {r4-r7,lr}

View File

@ -18,6 +18,7 @@
#include "bard_music.h"
#include "sound.h"
#include "strings.h"
#include "overworld.h"
#define CHAR_SONG_WORD_SEPARATOR 0x37
@ -35,7 +36,7 @@ void sub_8133A60(void);
struct BardSong gUnknown_03006130;
EWRAM_DATA u16 gUnknown_0203A128 = 0;
EWRAM_DATA struct MauvilleOldMan * gUnknown_0203A12C = NULL;
EWRAM_DATA struct MauvilleManStoryteller * gUnknown_0203A12C = NULL;
EWRAM_DATA u8 gUnknown_0203A130 = 0;
static const u16 sDefaultBardSongLyrics[6] = {
@ -949,3 +950,138 @@ const struct Story gUnknown_0859F048[] = {
{GAME_STAT_RODE_CABLE_CAR, 1, MauvilleCity_PokemonCenter_1F_Text_28FFDD, MauvilleCity_PokemonCenter_1F_Text_28FFFA, MauvilleCity_PokemonCenter_1F_Text_29000D},
{GAME_STAT_ENTERED_HOT_SPRINGS, 1, MauvilleCity_PokemonCenter_1F_Text_290097, MauvilleCity_PokemonCenter_1F_Text_2900B5, MauvilleCity_PokemonCenter_1F_Text_2900CB}
};
void sub_8120E08(void) // StorytellerSetup
{
s32 i;
gUnknown_0203A12C = &gSaveBlock1Ptr->oldMan.storyteller;
gUnknown_0203A12C->id = MAUVILLE_MAN_STORYTELLER;
gUnknown_0203A12C->alreadyRecorded = FALSE;
for (i = 0; i < 4; i++)
{
gUnknown_0203A12C->gameStatIDs[i] = 0;
gUnknown_0203A12C->trainerNames[0][i] = EOS; // Maybe they meant storyteller->trainerNames[i][0] instead?
}
}
void sub_8120E50(void)
{
gUnknown_0203A12C = &gSaveBlock1Ptr->oldMan.storyteller;
gUnknown_0203A12C->id = MAUVILLE_MAN_STORYTELLER;
gUnknown_0203A12C->alreadyRecorded = FALSE;
}
u32 sub_8120E74(u8 stat) // StorytellerGetGameStat
{
if (stat == 50)
stat = 0;
return GetGameStat(stat);
}
const struct Story *sub_8120E88(u32 stat) // GetStoryByStat
{
s32 i;
for (i = 0; i < 36; i++)
{
if (gUnknown_0859F048[i].stat == stat)
return &gUnknown_0859F048[i];
}
return &gUnknown_0859F048[35];
}
const u8 *sub_8120EB4(u32 stat) // GetStoryTitleByStat
{
return sub_8120E88(stat)->title;
}
const u8 *sub_8120EC0(u32 stat) // GetStoryTextByStat
{
return sub_8120E88(stat)->fullText;
}
const u8 *sub_8120ECC(u32 stat) // GetStoryActionByStat
{
return sub_8120E88(stat)->action;
}
u8 sub_8120ED8(void) // GetFreeStorySlot
{
u8 i;
for (i = 0; i < 4; i++)
{
if (gUnknown_0203A12C->gameStatIDs[i] == 0)
break;
}
return i;
}
u32 sub_8120F08(u32 trainer) // StorytellerGetRecordedTrainerStat
{
u8 *ptr = gUnknown_0203A12C->statValues[trainer];
return ptr[0] | (ptr[1] << 8) | (ptr[2] << 16) | (ptr[3] << 24);
}
void sub_8120F2C(u32 trainer, u32 val) // StorytellerSetRecordedTrainerStat
{
u8 *ptr = gUnknown_0203A12C->statValues[trainer];
ptr[0] = val;
ptr[1] = val >> 8;
ptr[2] = val >> 16;
ptr[3] = val >> 24;
}
bool32 sub_8120F4C(u32 trainer) // HasTrainerStatIncreased
{
if (sub_8120E74(gUnknown_0203A12C->gameStatIDs[trainer]) > sub_8120F08(trainer))
return TRUE;
else
return FALSE;
}
void sub_8120F7C(u32 player, void *dst) // GetStoryByStattellerPlayerName
{
u8 *name = gUnknown_0203A12C->trainerNames[player];
memset(dst, EOS, 8);
memcpy(dst, name, 7);
}
void sub_8120FAC(u32 player, const u8 * src) // StorytellerSetPlayerName
{
u8 * name = gUnknown_0203A12C->trainerNames[player];
memset(name, EOS, 7);
memcpy(name, src, 7);
}
void sub_8120FDC(u32 player, u32 stat) // StorytellerRecordNewStat
{
gUnknown_0203A12C->gameStatIDs[player] = stat;
sub_8120FAC(player, gSaveBlock2Ptr->playerName);
sub_8120F2C(player, sub_8120E74(stat));
ConvertIntToDecimalStringN(gStringVar1, sub_8120E74(stat), STR_CONV_MODE_LEFT_ALIGN, 10);
StringCopy(gStringVar2, sub_8120ECC(stat));
gUnknown_0203A12C->unk34[player] = gGameLanguage;
}
void sub_8121064(u8 * arr, s32 count) // ScrambleStatList
{
s32 i;
for (i = 0; i < count; i++)
arr[i] = i;
for (i = 0; i < count; i++)
{
u32 a = Random() % count;
u32 b = Random() % count;
u8 temp = arr[a];
arr[a] = arr[b];
arr[b] = temp;
}
}