From 158e9ff7623a8eba3e00c962e1050c6937bf535a Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 4 Nov 2017 12:20:40 -0400 Subject: [PATCH] sub_80E78C4 --- asm/cable_club.s | 2 +- asm/link.s | 6 ++-- asm/record_mixing.s | 70 ++------------------------------------ include/link.h | 2 +- include/mauville_old_man.h | 3 ++ src/record_mixing.c | 29 ++++++++++++++-- 6 files changed, 37 insertions(+), 75 deletions(-) diff --git a/asm/cable_club.s b/asm/cable_club.s index 80c177d20..c9f15ef47 100644 --- a/asm/cable_club.s +++ b/asm/cable_club.s @@ -795,7 +795,7 @@ sub_80B2A08: @ 80B2A08 ldrh r0, [r0] cmp r0, 0x4 bne _080B2A38 - bl Link_AnyPartnersPlayingRubyOrSapphrie + bl Link_AnyPartnersPlayingRubyOrSapphire cmp r0, 0 bne _080B2A4A bl sub_800AC34 diff --git a/asm/link.s b/asm/link.s index 840b153e7..6fc5a6dff 100644 --- a/asm/link.s +++ b/asm/link.s @@ -1464,8 +1464,8 @@ _0800A060: bx r1 thumb_func_end Link_HaveFourPlayersWithAtLeastOneRubyOrSapphire - thumb_func_start Link_AnyPartnersPlayingRubyOrSapphrie -Link_AnyPartnersPlayingRubyOrSapphrie: @ 800A064 + thumb_func_start Link_AnyPartnersPlayingRubyOrSapphire +Link_AnyPartnersPlayingRubyOrSapphire: @ 800A064 push {lr} movs r0, 0x2 movs r1, 0x1 @@ -1479,7 +1479,7 @@ _0800A076: _0800A078: pop {r1} bx r1 - thumb_func_end Link_AnyPartnersPlayingRubyOrSapphrie + thumb_func_end Link_AnyPartnersPlayingRubyOrSapphire thumb_func_start sub_800A07C sub_800A07C: @ 800A07C diff --git a/asm/record_mixing.s b/asm/record_mixing.s index 2c86404ec..424913e6c 100644 --- a/asm/record_mixing.s +++ b/asm/record_mixing.s @@ -5,70 +5,6 @@ .text - thumb_func_start sub_80E78C4 -sub_80E78C4: @ 80E78C4 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x10 - mov r9, r0 - mov r8, r1 - lsls r2, 24 - lsrs r7, r2, 24 - mov r0, sp - bl sub_80E7830 - lsls r0, r7, 2 - add r0, sp - ldr r1, [r0] - mov r0, r8 - muls r0, r1 - mov r2, r9 - adds r6, r2, r0 - ldr r2, =gLinkPlayers - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r4, [r0] - ldrh r5, [r0, 0x1A] - bl Link_AnyPartnersPlayingRubyOrSapphrie - cmp r0, 0 - beq _080E7910 - adds r0, r6, 0 - adds r1, r4, 0 - adds r2, r5, 0 - bl sub_8120D34 - b _080E791A - .pool -_080E7910: - adds r0, r6, 0 - adds r1, r4, 0 - adds r2, r5, 0 - bl sub_8120CD0 -_080E791A: - ldr r0, =gUnknown_03001140 - ldr r0, [r0] - lsls r1, r7, 2 - add r1, sp - ldr r1, [r1] - mov r2, r8 - muls r2, r1 - adds r1, r2, 0 - add r1, r9 - movs r2, 0x40 - bl memcpy - bl sub_8120670 - add sp, 0x10 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80E78C4 - thumb_func_start sub_80E7948 sub_80E7948: @ 80E7948 push {r4-r7,lr} @@ -82,7 +18,7 @@ sub_80E7948: @ 80E7948 lsrs r6, r2, 24 mov r0, sp bl sub_80E7830 - bl Link_AnyPartnersPlayingRubyOrSapphrie + bl Link_AnyPartnersPlayingRubyOrSapphire cmp r0, 0 beq _080E79AC lsls r0, r6, 2 @@ -399,7 +335,7 @@ _080E7BB0: mov r8, r0 cmp r0, 0x3 bls _080E7BB0 - bl Link_AnyPartnersPlayingRubyOrSapphrie + bl Link_AnyPartnersPlayingRubyOrSapphire str r0, [sp, 0x3C] movs r2, 0 mov r8, r2 @@ -956,7 +892,7 @@ _080E8024: .4byte _080E80EE .4byte _080E80FA _080E804C: - bl Link_AnyPartnersPlayingRubyOrSapphrie + bl Link_AnyPartnersPlayingRubyOrSapphire cmp r0, 0 bne _080E80F2 movs r0, 0x6 diff --git a/include/link.h b/include/link.h index 04a7d3864..77e9a9d24 100644 --- a/include/link.h +++ b/include/link.h @@ -194,7 +194,7 @@ void sub_8011BD0(void); u8 sub_800ABAC(void); u8 sub_800ABBC(void); void sub_800AC34(void); -bool32 Link_AnyPartnersPlayingRubyOrSapphrie(void); +bool32 Link_AnyPartnersPlayingRubyOrSapphire(void); bool32 sub_800A03C(void); void sub_8009628(u8); u8 sub_800AA48(void); diff --git a/include/mauville_old_man.h b/include/mauville_old_man.h index 25c5d8cd2..0c0ed624a 100644 --- a/include/mauville_old_man.h +++ b/include/mauville_old_man.h @@ -5,5 +5,8 @@ void SetMauvilleOldMan(void); u8 sub_81201C8(void); void sub_8120B70(OldMan *dest); +void sub_8120D34(OldMan *dest, u8 version, u16 language); +void sub_8120CD0(OldMan *dest, u8 version, u16 language); +void sub_8120670(void); #endif // GUARD_MAUVILLE_OLD_MAN_H diff --git a/src/record_mixing.c b/src/record_mixing.c index 14afd57ce..6670663f4 100644 --- a/src/record_mixing.c +++ b/src/record_mixing.c @@ -160,7 +160,7 @@ void sub_80E6E24(void) sub_80E9914(); sub_80F0BB8(); sub_80E6BF8(); - if (Link_AnyPartnersPlayingRubyOrSapphrie()) + if (Link_AnyPartnersPlayingRubyOrSapphire()) { if (sub_800A03C() == FALSE) { @@ -193,7 +193,7 @@ void sub_80E6E24(void) void sub_80E6F60(u32 a0) { - if (Link_AnyPartnersPlayingRubyOrSapphrie()) + if (Link_AnyPartnersPlayingRubyOrSapphire()) { // Ruby/Sapphire sub_80E7B2C(gUnknown_0203A014[0].tvShows); @@ -380,7 +380,7 @@ static void sub_80E7324(u8 taskId) task->data[0] = 0; task->data[5] = sub_80E7810(); task->func = sub_80E756C; - if (Link_AnyPartnersPlayingRubyOrSapphrie()) + if (Link_AnyPartnersPlayingRubyOrSapphire()) { sub_80E7808(gUnknown_0203A018, (u16 *)&task->data[2]); taskId2 = CreateTask(sub_80E7630, 80); @@ -575,3 +575,26 @@ void sub_80E7830(u32 *data) break; } } + +void sub_80E78C4(OldMan *oldMan, size_t recordSize, u8 which) +{ + u8 version; + u16 language; + OldMan *dest; + u32 data[4]; + + sub_80E7830(data); + dest = (OldMan *)((void *)oldMan + recordSize * data[which]); + version = gLinkPlayers[data[which]].version; + language = gLinkPlayers[data[which]].language; + if (Link_AnyPartnersPlayingRubyOrSapphire()) + { + sub_8120D34(dest, version, language); + } + else + { + sub_8120CD0(dest, version, language); + } + memcpy(gUnknown_03001140, (OldMan *)((void *)oldMan + recordSize * data[which]), sizeof(OldMan)); + sub_8120670(); +}