diff --git a/asm/record_mixing.s b/asm/record_mixing.s index 9ff2624d8..ceb25dd21 100644 --- a/asm/record_mixing.s +++ b/asm/record_mixing.s @@ -5,417 +5,6 @@ .text - thumb_func_start sub_80E8110 -sub_80E8110: @ 80E8110 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x10 - str r0, [sp] - mov r10, r1 - adds r1, r0, 0 - adds r1, 0x38 - movs r0, 0xFF - strb r0, [r1] - ldr r1, [sp] - adds r1, 0x7C - movs r0, 0x1 - negs r0, r0 - strb r0, [r1] - ldr r0, [sp] - mov r1, r10 - movs r2, 0x44 - bl memcpy - movs r0, 0 - str r0, [sp, 0x8] - movs r1, 0 - str r1, [sp, 0xC] - movs r2, 0 - str r2, [sp, 0x4] - mov r8, r2 - movs r7, 0 - ldr r0, =gSaveBlock2Ptr - mov r9, r0 -_080E8150: - mov r1, r9 - ldr r0, [r1] - adds r0, 0xB2 - ldrb r0, [r0] - lsls r0, 27 - lsrs r0, 30 - adds r0, r7, r0 - movs r1, 0x3 - bl __modsi3 - adds r6, r0, 0x1 - lsls r0, r6, 4 - adds r0, r6 - lsls r0, 2 - mov r2, r10 - adds r1, r0, r2 - adds r0, r1, 0 - adds r0, 0x38 - ldrb r0, [r0] - cmp r0, 0xFF - beq _080E81B8 - adds r5, r1, 0 - adds r5, 0x34 - adds r0, r5, 0 - bl ReadUnalignedWord - adds r4, r0, 0 - mov r1, r9 - ldr r0, [r1] - adds r0, 0xA - bl ReadUnalignedWord - cmp r4, r0 - beq _080E819A - movs r2, 0x1 - add r8, r2 - str r6, [sp, 0x4] -_080E819A: - adds r0, r5, 0 - bl ReadUnalignedWord - adds r4, r0, 0 - mov r1, r9 - ldr r0, [r1] - adds r0, 0xA - bl ReadUnalignedWord - cmp r4, r0 - bne _080E81B8 - ldr r2, [sp, 0xC] - adds r2, 0x1 - str r2, [sp, 0xC] - str r6, [sp, 0x8] -_080E81B8: - adds r7, 0x1 - cmp r7, 0x1 - ble _080E8150 - mov r0, r8 - cmp r0, 0 - bne _080E81D0 - ldr r1, [sp, 0xC] - cmp r1, 0 - beq _080E81D0 - mov r8, r1 - ldr r2, [sp, 0x8] - str r2, [sp, 0x4] -_080E81D0: - mov r0, r8 - cmp r0, 0x1 - beq _080E81E0 - cmp r0, 0x2 - beq _080E81EC - b _080E824C - .pool -_080E81E0: - ldr r2, [sp, 0x4] - lsls r1, r2, 4 - adds r1, r2 - lsls r1, 2 - add r1, r10 - b _080E820E -_080E81EC: - bl Random2 - lsls r0, 16 - ldr r1, =0x33330000 - cmp r0, r1 - bls _080E8224 - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - adds r0, 0xB2 - ldrb r0, [r0] - lsls r0, 27 - lsrs r0, 30 - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - add r1, r10 - adds r1, 0x44 -_080E820E: - ldr r0, [sp] - adds r0, 0x44 - movs r2, 0x44 - bl memcpy - b _080E824C - .pool -_080E8224: - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - adds r0, 0xB2 - ldrb r0, [r0] - lsls r0, 27 - lsrs r0, 30 - adds r0, 0x1 - movs r1, 0x3 - bl __modsi3 - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - add r1, r10 - adds r1, 0x44 - ldr r0, [sp] - adds r0, 0x44 - movs r2, 0x44 - bl memcpy -_080E824C: - add sp, 0x10 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80E8110 - - thumb_func_start sub_80E8260 -sub_80E8260: @ 80E8260 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0xC - mov r8, r0 - movs r6, 0 - ldr r0, =gSaveBlock2Ptr - mov r10, r0 -_080E8274: - movs r7, 0 - lsls r0, r6, 5 - adds r6, 0x1 - mov r9, r6 - mov r1, r8 - adds r4, r0, r1 - adds r0, 0x6 - adds r6, r1, r0 - adds r5, r4, 0 -_080E8286: - mov r2, r10 - ldr r1, [r2] - adds r1, 0xA - adds r0, r5, 0 - bl CopyUnalignedWord - movs r0, 0x2 - strb r0, [r4, 0xE] - mov r0, r10 - ldr r1, [r0] - adds r0, r6, 0 - bl StringCopy - adds r4, 0x10 - adds r6, 0x10 - adds r5, 0x10 - adds r7, 0x1 - cmp r7, 0x1 - ble _080E8286 - mov r6, r9 - cmp r6, 0x8 - ble _080E8274 - ldr r1, =gSaveBlock2Ptr - mov r10, r1 - ldr r2, =0x00000ee1 - str r2, [sp, 0x4] - movs r4, 0x99 - lsls r4, 1 - add r4, r8 - movs r0, 0x95 - lsls r0, 1 - add r0, r8 - mov r9, r0 - ldr r1, =0x00000ef1 - str r1, [sp, 0x8] - movs r6, 0x92 - lsls r6, 1 - add r6, r8 - movs r5, 0x90 - lsls r5, 1 - add r5, r8 - movs r7, 0x1 -_080E82DA: - movs r0, 0x2 - strb r0, [r4, 0x8] - mov r2, r10 - ldr r1, [r2] - adds r1, 0xA - adds r0, r5, 0 - bl CopyUnalignedWord - mov r0, r10 - ldr r1, [r0] - ldr r2, [sp, 0x8] - adds r1, r2 - adds r0, r6, 0 - bl CopyUnalignedWord - mov r0, r10 - ldr r1, [r0] - mov r0, r9 - bl StringCopy - mov r2, r10 - ldr r1, [r2] - ldr r0, [sp, 0x4] - adds r1, r0 - adds r0, r4, 0 - bl StringCopy - ldr r1, [sp, 0x4] - adds r1, 0x8 - str r1, [sp, 0x4] - adds r4, 0x1C - movs r2, 0x1C - add r9, r2 - ldr r0, [sp, 0x8] - adds r0, 0x4 - str r0, [sp, 0x8] - adds r6, 0x1C - adds r5, 0x1C - subs r7, 0x1 - cmp r7, 0 - bge _080E82DA - movs r6, 0 - ldr r0, =gSaveBlock2Ptr - ldr r3, [r0] - mov r4, r8 - movs r1, 0xC4 - adds r1, r4 - mov r9, r1 - movs r2, 0x84 - adds r2, r4 - mov r8, r2 - movs r0, 0x44 - adds r0, r4 - mov r12, r0 - adds r7, r4, 0x4 - movs r1, 0xCF - lsls r1, 4 - adds r1, r3, r1 - str r1, [sp] - mov r10, r4 - ldr r2, =0x00000cf4 - adds r5, r3, r2 -_080E8356: - lsls r2, r6, 1 - ldr r1, [sp] - ldrh r0, [r1] - strh r0, [r7] - ldrh r0, [r5] - strh r0, [r7, 0x20] - ldrh r0, [r5, 0x4] - mov r1, r12 - strh r0, [r1] - ldr r1, =0x00000d14 - adds r0, r3, r1 - adds r0, r2 - ldrh r0, [r0] - mov r1, r12 - strh r0, [r1, 0x20] - movs r1, 0xDD - lsls r1, 4 - adds r0, r3, r1 - adds r0, r2 - ldrh r0, [r0] - mov r1, r8 - strh r0, [r1] - ldr r1, =0x00000dde - adds r0, r3, r1 - adds r0, r2 - ldrh r0, [r0] - mov r1, r8 - strh r0, [r1, 0x20] - ldr r1, =0x00000dea - adds r0, r3, r1 - adds r0, r2 - ldrh r0, [r0] - mov r1, r9 - strh r0, [r1] - ldr r1, =0x00000e08 - adds r0, r3, r1 - adds r0, r2 - ldrh r0, [r0] - mov r1, r9 - strh r0, [r1, 0x20] - ldr r1, =0x00000e1e - adds r0, r3, r1 - adds r0, r2 - ldrh r1, [r0] - movs r0, 0x82 - lsls r0, 1 - add r0, r10 - strh r1, [r0] - ldr r1, =0x00000cfc - adds r0, r3, r1 - adds r0, r2 - ldrh r1, [r0] - movs r2, 0x94 - lsls r2, 1 - adds r0, r4, r2 - strh r1, [r0] - adds r4, 0x1C - movs r0, 0x10 - add r9, r0 - add r8, r0 - add r12, r0 - adds r7, 0x10 - ldr r1, [sp] - adds r1, 0x2 - str r1, [sp] - add r10, r0 - adds r5, 0x2 - adds r6, 0x1 - cmp r6, 0x1 - ble _080E8356 - add sp, 0xC - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80E8260 - - thumb_func_start sub_80E841C -sub_80E841C: @ 80E841C - push {r4-r7,lr} - mov r7, r8 - push {r7} - adds r7, r0, 0 - movs r0, 0 - mov r8, r0 - adds r6, r1, 0 - adds r6, 0x34 - adds r5, r1, 0 -_080E842E: - adds r0, r7, 0 - adds r0, 0x34 - bl ReadUnalignedWord - adds r4, r0, 0 - adds r0, r6, 0 - bl ReadUnalignedWord - cmp r4, r0 - bne _080E844E - ldrb r0, [r7, 0x2] - ldrb r1, [r5, 0x2] - cmp r0, r1 - bne _080E844E - movs r0, 0x1 - b _080E845E -_080E844E: - adds r6, 0x44 - adds r5, 0x44 - movs r0, 0x1 - add r8, r0 - mov r1, r8 - cmp r1, 0x3 - ble _080E842E - movs r0, 0 -_080E845E: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_80E841C thumb_func_start sub_80E8468 sub_80E8468: @ 80E8468 diff --git a/include/global.h b/include/global.h index bd2dbe7a6..fe82ea9a7 100644 --- a/include/global.h +++ b/include/global.h @@ -281,7 +281,11 @@ struct SaveBlock2 /*0xAC*/ u32 encryptionKey; // TODO: fix and verify labels - /*0xB0*/ u8 field_B0[0x2c]; + /*0xB0*/ u8 field_B0; + /*0xB1*/ u8 field_B1; + /*0xB2*/ u8 field_B2_0:3; + /*0xB2*/ u8 field_B2_1:2; + /*0xB3*/ u8 field_B3[0x29]; /*0xDC*/ u8 field_0DC[0x110]; /*0x1EC*/ struct BerryCrush berryCrush; /*0x1FC*/ struct PokemonJumpResults pokeJump; @@ -308,22 +312,64 @@ struct SaveBlock2 /*0xCA9*/ u8 field_CA9_f : 1; // 0x80 /*0xCAA*/ u16 field_CAA[4]; /*0xCB2*/ u16 battlePyramidWildHeaderId; - /*0xCB4*/ u16 field_CB4[41]; + /*0xCB4*/ u16 field_CB4[30]; + /*0xCF0*/ u16 field_CF0[2]; + /*0xCF4*/ u16 field_CF4[2]; + /*0xCF8*/ u16 field_CF8[2]; + /*0xCFC*/ u16 field_CFC[5]; /*0xD06*/ u8 field_D06; /*0xD07*/ u8 field_D07; - /*0xD08*/ u8 filler_D08[0x112]; + /*0xD08*/ u8 filler_D08; + /*0xD09*/ u8 filler_D09; + /*0xD0A*/ u8 filler_D0A; + /*0xD0B*/ u8 filler_D0B; + /*0xD0C*/ u8 filler_D0C; + /*0xD0D*/ u8 filler_D0D; + /*0xD0E*/ u8 filler_D0E; + /*0xD0F*/ u8 filler_D0F; + /*0xD10*/ u8 filler_D10; + /*0xD11*/ u8 filler_D11; + /*0xD12*/ u8 filler_D12; + /*0xD13*/ u8 filler_D13; + /*0xD14*/ u16 field_D14[2]; + /*0xD18*/ u8 field_D18[0xB8]; + /*0xDD0*/ u16 field_DD0[2]; + /*0xDD4*/ u16 field_DD4[2]; + /*0xDD8*/ u16 field_DD8; + /*0xDDA*/ u16 field_DDA; + /*0xDDC*/ u16 field_DDC; + /*0xDDE*/ u16 field_DDE[2]; + /*0xDE2*/ u16 field_DE2; + /*0xDE4*/ u16 field_DE4; + /*0xDE6*/ u16 field_DE6; + /*0xDE8*/ u16 field_DE8; + /*0xDEA*/ u16 field_DEA[2]; + /*0xDEE*/ u16 field_DEE; + /*0xDF0*/ u16 field_DF0; + /*0xDF2*/ u16 field_DF2; + /*0xDF4*/ u16 field_DF4; + /*0xDF6*/ u16 field_DF6; + /*0xDF8*/ u16 field_DF8; + /*0xDFA*/ u16 field_DFA; + /*0xDFC*/ u16 field_DFC; + /*0xDFE*/ u16 field_DFE; + /*0xE00*/ u16 field_E00; + /*0xE02*/ u16 field_E02; + /*0xE04*/ u16 field_E04; + /*0xE06*/ u16 field_E06; + /*0xE08*/ u16 field_E08[9]; /*0xE1A*/ u16 battlePyramidFloor; // possibly? - /*0xE1C*/ u8 field_E1C[16]; + /*0xE1C*/ u16 field_E1C; + /*0xE1E*/ u16 field_E1E[7]; /*0xE2C*/ struct PyramidBag pyramidBag; /*0x???*/ u8 field_unkown[6]; /*0xE6E*/ u16 battleTentWinStreak; /*0xE70*/ u8 field_E70[72]; /*0xEB8*/ u16 frontierBattlePoints; /*0xEBA*/ u8 field_EBA[39]; - /*0xEE1*/ u8 field_EE1; - /*0xEE2*/ u8 field_EE2[7]; - /*0xEE9*/ u8 field_EE9; - /*0xEEA*/ u8 field_EEA[66]; + /*0xEE1*/ u8 field_EE1[2][PLAYER_NAME_LENGTH]; + /*0xEF1*/ u8 field_EF1[2][4]; + /*0xEF9*/ u8 field_EF9[51]; // sizeof=0xF2C }; diff --git a/include/record_mixing.h b/include/record_mixing.h index e327d1510..875eca815 100644 --- a/include/record_mixing.h +++ b/include/record_mixing.h @@ -2,25 +2,34 @@ #define GUARD_RECORD_MIXING_H // Exported type declarations - -struct DayCareMailRecordMixing { - struct MailStruct mail; - u8 OT_name[OT_NAME_LENGTH + 1]; - u8 monName[11]; - u8 language_maybe:4; - u8 unknown:4; +struct UnkRecordMixingStruct2a +{ + u8 playerId[4]; + u16 field_4; + u8 playerName[PLAYER_NAME_LENGTH]; + u8 language; }; -struct UnkStruct_80E7B60 { - struct DayCareMailRecordMixing unk_00[2]; - u32 unk_70; - u16 unk_74[2]; -}; // size = 0x78 +struct UnkRecordMixingStruct2b +{ + u8 playerId1[4]; + u8 playerId2[4]; + u16 field_8; + u8 playerName1[PLAYER_NAME_LENGTH]; + u8 playerName2[PLAYER_NAME_LENGTH]; + u8 language; +}; + +struct UnkRecordMixingStruct2 +{ + struct UnkRecordMixingStruct2a field_0[9][2]; + struct UnkRecordMixingStruct2b field_120[2]; +}; // Exported RAM declarations // Exported ROM declarations -void sub_80E8260(void *); +void sub_80E8260(struct UnkRecordMixingStruct2 *arg0); #endif //GUARD_RECORD_MIXING_H diff --git a/src/record_mixing.c b/src/record_mixing.c index e03702759..553174325 100644 --- a/src/record_mixing.c +++ b/src/record_mixing.c @@ -38,31 +38,35 @@ struct UnkRecordMixingStruct { - u8 field_0[0x44]; + u8 field_0[0x34]; + u8 playerId[4]; + u8 field_38[10]; }; -struct PlayerRecordsRS { +struct PlayerRecordsRS +{ struct SecretBaseRecord secretBases[20]; TVShow tvShows[25]; PokeNews pokeNews[16]; OldMan oldMan; struct EasyChatPair easyChatPairs[5]; - struct UnkStruct_80E7B60 dayCareMail; + struct RecordMixingDayCareMail dayCareMail; struct RSBattleTowerRecord battleTowerRecord; u16 filler11C8[0x32]; }; -struct PlayerRecords { +struct PlayerRecords +{ /* 0x0000 */ struct SecretBaseRecord secretBases[20]; /* 0x0c80 */ TVShow tvShows[25]; /* 0x1004 */ PokeNews pokeNews[16]; /* 0x1044 */ OldMan oldMan; /* 0x1084 */ struct EasyChatPair easyChatPair[5]; - /* 0x10ac */ struct UnkStruct_80E7B60 dayCareMail; + /* 0x10ac */ struct RecordMixingDayCareMail dayCareMail; /* 0x1124 */ union BattleTowerRecord battleTowerRecord; /* 0x1210 */ u16 unk_1210; /* 0x1214 */ LilycoveLady lilycoveLady; - /* 0x1254 */ u8 unk_1254[0x88]; + /* 0x1254 */ struct UnkRecordMixingStruct unk_1254[2]; /* 0x12dc */ u8 unk_12dc[0x168]; }; // 1444 @@ -74,7 +78,7 @@ IWRAM_DATA TVShow *gUnknown_03001138; IWRAM_DATA PokeNews *gUnknown_0300113C; IWRAM_DATA OldMan *gUnknown_03001140; IWRAM_DATA struct EasyChatPair *gUnknown_03001144; -IWRAM_DATA struct UnkStruct_80E7B60 *gUnknown_03001148; +IWRAM_DATA struct RecordMixingDayCareMail *gUnknown_03001148; IWRAM_DATA void *gUnknown_0300114C; // gSaveBlock2Ptr->field_64C IWRAM_DATA LilycoveLady *gUnknown_03001150; IWRAM_DATA void *gUnknown_03001154; // gSaveBlock2Ptr->field_0DC; @@ -84,7 +88,7 @@ IWRAM_DATA u8 gUnknown_03001160; IWRAM_DATA u32 filler_03001164; IWRAM_DATA u32 gUnknown_03001168[3]; -EWRAM_DATA struct UnkStruct_80E7B60 gUnknown_02039F9C = {}; +EWRAM_DATA struct RecordMixingDayCareMail gUnknown_02039F9C = {}; EWRAM_DATA struct PlayerRecords *gUnknown_0203A014 = NULL; EWRAM_DATA struct PlayerRecords *gUnknown_0203A018 = NULL; @@ -103,10 +107,10 @@ static void sub_80E78C4(OldMan *, size_t, u8); static void sub_80E7948(union BattleTowerRecord *, size_t, u8); static void sub_80E7A14(LilycoveLady *, size_t, u8); static void sub_80E7B2C(const u8 *); -static void sub_80E7B60(struct UnkStruct_80E7B60 *, size_t, u8, TVShow *); +static void sub_80E7B60(struct RecordMixingDayCareMail *, size_t, u8, TVShow *); static void sub_80E7F68(u16 *item, u8 which); static void sub_80E7FF8(u8 taskId); -/*static*/ void sub_80E8110(struct UnkRecordMixingStruct *arg0, struct UnkRecordMixingStruct *arg1); +static void sub_80E8110(struct UnkRecordMixingStruct *arg0, struct UnkRecordMixingStruct *arg1); void sub_80E8468(void *, size_t, u8); void sub_80E89AC(void *, size_t, u8); void sub_80E89F8(void *dest); @@ -213,8 +217,8 @@ void sub_80E6E24(void) { gUnknown_0203A018->unk_1210 = GetRecordMixingGift(); } - sub_80E8110((void*) gUnknown_0203A018->unk_1254, gUnknown_03001154); - sub_80E8260(gUnknown_0203A018->unk_12dc); + sub_80E8110(gUnknown_0203A018->unk_1254, gUnknown_03001154); + sub_80E8260((void*)gUnknown_0203A018->unk_12dc); } } @@ -688,22 +692,22 @@ static void sub_80E7A14(LilycoveLady *lilycoveLady, size_t recordSize, u8 which) } } -static u8 sub_80E7A9C(struct DayCareMailRecordMixing *rmMail) +static u8 sub_80E7A9C(struct DaycareMiscMon *rmMail) { return rmMail->mail.itemId; } -static void sub_80E7AA4(struct UnkStruct_80E7B60 *src, size_t recordSize, u8 (*idxs)[2], u8 which0, u8 which1) +static void sub_80E7AA4(struct RecordMixingDayCareMail *src, size_t recordSize, u8 (*idxs)[2], u8 which0, u8 which1) { - struct DayCareMailRecordMixing buffer; - struct UnkStruct_80E7B60 *_src1; - struct UnkStruct_80E7B60 *_src2; + struct DaycareMiscMon buffer; + struct RecordMixingDayCareMail *mail1; + struct RecordMixingDayCareMail *mail2; - _src1 = (void *)src + recordSize * idxs[which0][0]; - memcpy(&buffer, &_src1->unk_00[idxs[which0][1]], sizeof(struct DayCareMailRecordMixing)); - _src2 = (void *)src + recordSize * idxs[which1][0]; - memcpy(&_src1->unk_00[idxs[which0][1]], &_src2->unk_00[idxs[which1][1]], sizeof(struct DayCareMailRecordMixing)); - memcpy(&_src2->unk_00[idxs[which1][1]], &buffer, sizeof(struct DayCareMailRecordMixing)); + mail1 = (void *)src + recordSize * idxs[which0][0]; + memcpy(&buffer, &mail1->mail[idxs[which0][1]], sizeof(struct DaycareMiscMon)); + mail2 = (void *)src + recordSize * idxs[which1][0]; + memcpy(&mail1->mail[idxs[which0][1]], &mail2->mail[idxs[which1][1]], sizeof(struct DaycareMiscMon)); + memcpy(&mail2->mail[idxs[which1][1]], &buffer, sizeof(struct DaycareMiscMon)); } static void sub_80E7B2C(const u8 *src) @@ -725,7 +729,7 @@ static u8 sub_80E7B54(void) } #ifdef NONMATCHING -static void sub_80E7B60(struct UnkStruct_80E7B60 *src, size_t recordSize, u8 which, TVShow *shows) +static void sub_80E7B60(struct RecordMixingDayCareMail *src, size_t recordSize, u8 which, TVShow *shows) { // r9 = which u16 i; @@ -738,11 +742,11 @@ static void sub_80E7B60(struct UnkStruct_80E7B60 *src, size_t recordSize, u8 whi u8 dcMail1; u8 dcMail2; u8 r1_80e7b54; - struct DayCareMailRecordMixing *recordMixingMail; - struct UnkStruct_80E7B60 *_src; + struct DaycareMiscMon *recordMixingMail; + struct RecordMixingDayCareMail *_src; u8 sp04[4]; u8 sp08[4]; - struct UnkStruct_80E7B60 *sp0c[4]; // -> sp+48 + struct RecordMixingDayCareMail *sp0c[4]; // -> sp+48 u8 sp1c[4][2]; // [][0] -> sp+4c, [][1] -> sp+50 u8 sp24[4][2]; // sp+2c = src @@ -898,12 +902,12 @@ static void sub_80E7B60(struct UnkStruct_80E7B60 *src, size_t recordSize, u8 whi break; } _src = (void *)src + which * recordSize; - memcpy(&gSaveBlock1Ptr->daycare.mons[0].misc.mail, &_src->unk_00[0], sizeof(struct DayCareMailRecordMixing)); - memcpy(&gSaveBlock1Ptr->daycare.mons[1].misc.mail, &_src->unk_00[1], sizeof(struct DayCareMailRecordMixing)); + memcpy(&gSaveBlock1Ptr->daycare.mons[0].misc.mail, &_src->unk_00[0], sizeof(struct DaycareMiscMon)); + memcpy(&gSaveBlock1Ptr->daycare.mons[1].misc.mail, &_src->unk_00[1], sizeof(struct DaycareMiscMon)); SeedRng(oldSeed); } #else -__attribute__((naked)) static void sub_80E7B60(struct UnkStruct_80E7B60 *src, size_t recordSize, u8 which, TVShow *shows) +__attribute__((naked)) static void sub_80E7B60(struct RecordMixingDayCareMail *src, size_t recordSize, u8 which, TVShow *shows) { asm_unified("\tpush {r4-r7,lr}\n" "\tmov r7, r10\n" @@ -1529,15 +1533,15 @@ static void sub_80E7FF8(u8 taskId) } } -/* -static void sub_80E8110(struct UnkRecordMixingStruct *arg0, struct UnkRecordMixingStruct *arg1) +static void sub_80E8110(struct UnkRecordMixingStruct *dst, struct UnkRecordMixingStruct *src) { s32 i, id; - s32 var_28, var_24, var_2C, r8; + s32 var_2C, var_28, var_24, r8; - arg0[0].field_0[0x38] = 0xFF; - arg0[1].field_0[0x38] = 0xFF; - memcpy(&arg0[0], &arg1[0], sizeof(struct UnkRecordMixingStruct)); + dst[0].field_38[0] = 0xFF; + dst[1].field_38[0] = 0xFF; + + dst[0] = src[0]; var_28 = 0; var_24 = 0; @@ -1545,15 +1549,15 @@ static void sub_80E8110(struct UnkRecordMixingStruct *arg0, struct UnkRecordMixi r8 = 0; for (i = 0; i < 2; i++) { - id = ((i + (gSaveBlock2Ptr->field_B0[2] << 0x1B >> 0x1E)) % 3) + 1; - if (arg1[id].field_0[0x38] != 0xFF) + id = ((i + gSaveBlock2Ptr->field_B2_1) % 3) + 1; + if (src[id].field_38[0] != 0xFF) { - if (ReadUnalignedWord(&arg1[id].field_0[0x34]) != ReadUnalignedWord(gSaveBlock2Ptr->playerTrainerId)) + if (ReadUnalignedWord(src[id].playerId) != ReadUnalignedWord(gSaveBlock2Ptr->playerTrainerId)) { r8++; var_2C = id; } - if (ReadUnalignedWord(&arg1[id].field_0[0x34]) == ReadUnalignedWord(gSaveBlock2Ptr->playerTrainerId)) + if (ReadUnalignedWord(src[id].playerId) == ReadUnalignedWord(gSaveBlock2Ptr->playerTrainerId)) { var_24++; var_28 = id; @@ -1570,13 +1574,72 @@ static void sub_80E8110(struct UnkRecordMixingStruct *arg0, struct UnkRecordMixi switch (r8) { case 1: - memcpy(&arg0[0], &arg1[var_2C], sizeof(struct UnkRecordMixingStruct)); + dst[1] = src[var_2C]; break; case 2: if (Random2() > 0x3333) - memcpy(&arg0[1], &arg1[(gSaveBlock2Ptr->field_B0[2] << 0x1B >> 0x1E) + 1], sizeof(struct UnkRecordMixingStruct)); + { + dst[1] = src[gSaveBlock2Ptr->field_B2_1 + 1]; + } else - memcpy(&arg0[1], &arg1[((gSaveBlock2Ptr->field_B0[2] << 0x1B >> 0x1E) + 1) % 3 + 1], sizeof(struct UnkRecordMixingStruct)); + { + dst[1] = src[((gSaveBlock2Ptr->field_B2_1 + 1) % 3 + 1)]; + } break; } -}*/ +} + +void sub_80E8260(struct UnkRecordMixingStruct2 *dst) +{ + s32 i, j; + + for (i = 0; i < 9; i++) + { + for (j = 0; j < 2; j++) + { + CopyUnalignedWord(dst->field_0[i][j].playerId, gSaveBlock2Ptr->playerTrainerId); + dst->field_0[i][j].language = LANGUAGE_ENGLISH; + StringCopy(dst->field_0[i][j].playerName, gSaveBlock2Ptr->playerName); + } + } + + for (j = 0; j < 2; j++) + { + dst->field_120[j].language = LANGUAGE_ENGLISH; + CopyUnalignedWord(dst->field_120[j].playerId1, gSaveBlock2Ptr->playerTrainerId); + CopyUnalignedWord(dst->field_120[j].playerId2, gSaveBlock2Ptr->field_EF1[j]); + StringCopy(dst->field_120[j].playerName1, gSaveBlock2Ptr->playerName); + StringCopy(dst->field_120[j].playerName2, gSaveBlock2Ptr->field_EE1[j]); + } + + for (i = 0; i < 2; i++) + { + dst->field_0[0][i].field_4 = gSaveBlock2Ptr->field_CF0[i]; + dst->field_0[1][i].field_4 = gSaveBlock2Ptr->field_CF4[i]; + dst->field_0[2][i].field_4 = gSaveBlock2Ptr->field_CF8[i]; + dst->field_0[3][i].field_4 = gSaveBlock2Ptr->field_D14[i]; + dst->field_0[4][i].field_4 = gSaveBlock2Ptr->field_DD0[i]; + dst->field_0[5][i].field_4 = gSaveBlock2Ptr->field_DDE[i]; + dst->field_0[6][i].field_4 = gSaveBlock2Ptr->field_DEA[i]; + dst->field_0[7][i].field_4 = gSaveBlock2Ptr->field_E08[i]; + dst->field_0[8][i].field_4 = gSaveBlock2Ptr->field_E1E[i]; + + dst->field_120[i].field_8 = gSaveBlock2Ptr->field_CFC[i]; + } +} + +bool32 sub_80E841C(struct UnkRecordMixingStruct *arg0, struct UnkRecordMixingStruct *arg1) +{ + s32 i; + + for (i = 0; i < 4; i++) + { + if (ReadUnalignedWord(arg0->playerId) == ReadUnalignedWord(arg1[i].playerId) + && arg0->field_0[2] == arg1[i].field_0[2]) + { + return TRUE; + } + } + + return FALSE; +}