diff --git a/asm/battle_frontier_2.s b/asm/battle_frontier_2.s index b17daa99e..7887ff999 100644 --- a/asm/battle_frontier_2.s +++ b/asm/battle_frontier_2.s @@ -7,805 +7,6 @@ - thumb_func_start sub_81A447C -sub_81A447C: @ 81A447C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x8 - movs r0, 0 - str r0, [sp] -_081A448C: - ldr r1, =gSaveBlock2Ptr - ldr r0, [r1] - ldr r2, [sp] - lsls r1, r2, 1 - ldr r4, =0x00000caa - adds r0, r4 - adds r0, r1 - ldrh r0, [r0] - subs r0, 0x1 - lsls r0, 16 - lsrs r0, 16 - mov r9, r1 - adds r2, 0x1 - str r2, [sp, 0x4] - cmp r0, 0x5 - bhi _081A454E - movs r6, 0 - ldr r0, [sp] - movs r2, 0x64 - adds r1, r0, 0 - muls r1, r2 - ldr r0, =gPlayerParty - adds r7, r1, r0 -_081A44BA: - movs r5, 0 - movs r4, 0xD - adds r4, r6 - mov r8, r4 - adds r0, r6, 0x1 - mov r10, r0 -_081A44C6: - ldr r1, =gSaveBlock2Ptr - ldr r0, [r1] - ldr r2, =0x00000caa - adds r0, r2 - add r0, r9 - ldrh r0, [r0] - movs r4, 0x64 - adds r1, r0, 0 - muls r1, r4 - movs r0, 0xEA - lsls r0, 1 - adds r1, r0 - ldr r2, =gSaveBlock1Ptr - ldr r0, [r2] - adds r0, r1 - adds r1, r5, 0 - adds r1, 0xD - movs r2, 0 - bl GetMonData - adds r4, r0, 0 - adds r0, r7, 0 - mov r1, r8 - movs r2, 0 - bl GetMonData - cmp r4, r0 - beq _081A4508 - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x3 - bls _081A44C6 -_081A4508: - cmp r5, 0x4 - bne _081A4516 - adds r0, r7, 0 - movs r1, 0xA6 - adds r2, r6, 0 - bl SetMonMoveSlot -_081A4516: - mov r4, r10 - lsls r0, r4, 24 - lsrs r6, r0, 24 - cmp r6, 0x3 - bls _081A44BA - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r2, =gSaveBlock2Ptr - ldr r1, [r2] - ldr r4, =0x00000caa - adds r1, r4 - add r1, r9 - ldrh r1, [r1] - subs r1, 0x1 - movs r3, 0x64 - muls r1, r3 - adds r0, r1 - movs r1, 0x8E - lsls r1, 2 - adds r0, r1 - ldr r2, =gPlayerParty - ldr r4, [sp] - adds r1, r4, 0 - muls r1, r3 - adds r1, r2 - movs r2, 0x64 - bl memcpy -_081A454E: - ldr r1, [sp, 0x4] - lsls r0, r1, 24 - lsrs r0, 24 - str r0, [sp] - cmp r0, 0x3 - bls _081A448C - add sp, 0x8 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81A447C - - thumb_func_start sub_81A457C -sub_81A457C: @ 81A457C - push {lr} - ldr r0, =0x000040cf - bl VarGet - lsls r0, 24 - lsrs r0, 24 - bl sub_81A5030 - pop {r0} - bx r0 - .pool - thumb_func_end sub_81A457C - - thumb_func_start sub_81A4594 -sub_81A4594: @ 81A4594 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x2C - mov r8, r1 - adds r6, r3, 0 - ldr r1, =gRecordsWindowId - ldrb r5, [r1] - lsls r4, r0, 1 - adds r4, r0 - ldr r1, =gText_1Dot - adds r4, r1 - mov r1, r8 - lsls r3, r1, 27 - lsrs r3, 24 - lsls r1, r0, 2 - adds r1, r0 - adds r2, r1 - lsls r2, 3 - adds r2, 0x1 - lsls r2, 24 - lsrs r7, r2, 24 - str r7, [sp] - movs r0, 0xFF - mov r10, r0 - str r0, [sp, 0x4] - movs r1, 0 - mov r9, r1 - str r1, [sp, 0x8] - adds r0, r5, 0 - movs r1, 0x1 - adds r2, r4, 0 - bl AddTextPrinterParameterized - movs r0, 0xFF - strb r0, [r6, 0xD] - ldrh r0, [r6, 0x4] - cmp r0, 0 - beq _081A465C - adds r1, r6, 0x6 - ldrb r2, [r6, 0xE] - add r0, sp, 0xC - bl TVShowConvertInternationalString - ldr r1, =gRecordsWindowId - ldrb r0, [r1] - mov r3, r8 - adds r3, 0x2 - lsls r3, 27 - lsrs r3, 24 - str r7, [sp] - mov r1, r10 - str r1, [sp, 0x4] - mov r1, r9 - str r1, [sp, 0x8] - movs r1, 0x1 - add r2, sp, 0xC - bl AddTextPrinterParameterized - ldrh r1, [r6, 0x4] - ldr r0, =0x0000270f - cmp r1, r0 - bls _081A4618 - adds r1, r0, 0 -_081A4618: - ldr r0, =gStringVar2 - movs r2, 0x1 - movs r3, 0x4 - bl ConvertIntToDecimalStringN - ldr r5, =gStringVar4 - ldr r1, =gUnknown_08611D08 - ldr r0, [sp, 0x4C] - lsls r0, 2 - adds r0, r1 - ldr r4, [r0] - adds r0, r5, 0 - adds r1, r4, 0 - bl StringExpandPlaceholders - movs r0, 0x1 - adds r1, r4, 0 - movs r2, 0xC8 - bl GetStringRightAlignXOffset - adds r3, r0, 0 - lsls r3, 24 - lsrs r3, 24 - ldr r1, =gRecordsWindowId - ldrb r0, [r1] - str r7, [sp] - mov r1, r10 - str r1, [sp, 0x4] - mov r1, r9 - str r1, [sp, 0x8] - movs r1, 0x1 - adds r2, r5, 0 - bl AddTextPrinterParameterized -_081A465C: - add sp, 0x2C - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81A4594 - - thumb_func_start sub_81A4684 -sub_81A4684: @ 81A4684 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x2C - adds r6, r0, 0 - adds r7, r1, 0 - mov r10, r2 - adds r5, r3, 0 - ldr r1, =gRecordsWindowId - ldrb r0, [r1] - lsls r2, r6, 1 - adds r2, r6 - ldr r1, =gText_1Dot - adds r2, r1 - lsls r3, r7, 27 - lsrs r3, 24 - mov r12, r3 - lsls r1, r6, 2 - adds r1, r6 - mov r3, r10 - adds r4, r3, r1 - lsls r1, r4, 3 - adds r1, 0x1 - lsls r1, 24 - lsrs r1, 24 - str r1, [sp] - movs r1, 0xFF - mov r9, r1 - str r1, [sp, 0x4] - movs r3, 0 - mov r8, r3 - str r3, [sp, 0x8] - movs r1, 0x1 - mov r3, r12 - bl AddTextPrinterParameterized - ldrh r0, [r5, 0x8] - cmp r0, 0 - beq _081A47BC - movs r0, 0xFF - strb r0, [r5, 0x11] - movs r0, 0x1 - negs r0, r0 - strb r0, [r5, 0x19] - adds r1, r5, 0 - adds r1, 0xA - ldrb r2, [r5, 0x1A] - add r0, sp, 0xC - bl TVShowConvertInternationalString - ldr r1, =gRecordsWindowId - ldrb r0, [r1] - adds r3, r7, 0x2 - lsls r3, 27 - lsrs r3, 24 - subs r1, r4, 0x1 - lsls r1, 3 - adds r1, 0x1 - lsls r1, 24 - lsrs r1, 24 - str r1, [sp] - mov r2, r9 - str r2, [sp, 0x4] - mov r1, r8 - str r1, [sp, 0x8] - movs r1, 0x1 - add r2, sp, 0xC - bl AddTextPrinterParameterized - adds r4, r5, 0 - adds r4, 0x12 - adds r0, r4, 0 - bl IsStringJapanese - cmp r0, 0 - beq _081A4734 - add r0, sp, 0xC - adds r1, r4, 0 - movs r2, 0x1 - bl TVShowConvertInternationalString - b _081A473C - .pool -_081A4734: - add r0, sp, 0xC - adds r1, r4, 0 - bl StringCopy -_081A473C: - ldr r2, =gRecordsWindowId - mov r9, r2 - ldrb r0, [r2] - adds r3, r7, 0x4 - lsls r3, 27 - lsrs r3, 24 - lsls r1, r6, 2 - adds r1, r6 - mov r2, r10 - adds r6, r2, r1 - adds r1, r6, 0x1 - lsls r1, 3 - adds r1, 0x1 - lsls r1, 24 - lsrs r1, 24 - str r1, [sp] - movs r1, 0xFF - mov r8, r1 - str r1, [sp, 0x4] - movs r7, 0 - str r7, [sp, 0x8] - movs r1, 0x1 - add r2, sp, 0xC - bl AddTextPrinterParameterized - ldrh r1, [r5, 0x8] - ldr r0, =0x0000270f - cmp r1, r0 - bls _081A4778 - adds r1, r0, 0 -_081A4778: - ldr r0, =gStringVar2 - movs r2, 0x1 - movs r3, 0x4 - bl ConvertIntToDecimalStringN - ldr r5, =gStringVar4 - ldr r0, =gUnknown_08611D08 - ldr r4, [r0, 0x24] - adds r0, r5, 0 - adds r1, r4, 0 - bl StringExpandPlaceholders - movs r0, 0x1 - adds r1, r4, 0 - movs r2, 0xC8 - bl GetStringRightAlignXOffset - adds r3, r0, 0 - lsls r3, 24 - lsrs r3, 24 - mov r2, r9 - ldrb r0, [r2] - lsls r1, r6, 3 - adds r1, 0x1 - lsls r1, 24 - lsrs r1, 24 - str r1, [sp] - mov r1, r8 - str r1, [sp, 0x4] - str r7, [sp, 0x8] - movs r1, 0x1 - adds r2, r5, 0 - bl AddTextPrinterParameterized -_081A47BC: - add sp, 0x2C - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81A4684 - - thumb_func_start sub_81A47E0 -sub_81A47E0: @ 81A47E0 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x44 - mov r9, r0 - mov r10, r1 - str r2, [sp, 0x40] - movs r0, 0xAC - lsls r0, 1 - bl AllocZeroed - mov r8, r0 - bl sub_80E8260 - add r0, sp, 0x30 - mov r12, r0 - ldr r0, =gSaveBlock2Ptr - ldr r2, [r0] - ldr r3, [sp, 0x40] - lsls r1, r3, 1 - adds r1, r3 - lsls r1, 4 - mov r4, r10 - lsls r0, r4, 1 - add r0, r10 - lsls r0, 5 - adds r1, r0 - adds r4, r1, r2 - mov r3, sp - movs r2, 0x2 -_081A4820: - adds r0, r3, 0 - movs r5, 0x87 - lsls r5, 2 - adds r1, r4, r5 - ldm r1!, {r5-r7} - stm r0!, {r5-r7} - ldr r1, [r1] - str r1, [r0] - adds r4, 0x10 - adds r3, 0x10 - subs r2, 0x1 - cmp r2, 0 - bge _081A4820 - ldr r6, [sp, 0x40] - lsls r0, r6, 4 - mov r7, r10 - lsls r1, r7, 5 - adds r0, r1 - mov r1, r12 - add r0, r8 - ldm r0!, {r2-r4} - stm r1!, {r2-r4} - ldr r0, [r0] - str r0, [r1] - movs r2, 0 -_081A4852: - movs r1, 0 - movs r4, 0 - movs r3, 0 - lsls r5, r2, 4 - adds r6, r2, 0x1 - mov r2, sp -_081A485E: - ldrh r0, [r2, 0x4] - cmp r0, r1 - ble _081A4868 - adds r4, r3, 0 - adds r1, r0, 0 -_081A4868: - adds r2, 0x10 - adds r3, 0x1 - cmp r3, 0x3 - ble _081A485E - mov r0, sp - ldrh r0, [r0, 0x34] - cmp r0, r1 - blt _081A487A - movs r4, 0x3 -_081A487A: - lsls r0, r4, 4 - mov r7, sp - adds r2, r7, r0 - mov r0, r9 - adds r1, r5, r0 - adds r0, r2, 0 - ldm r0!, {r3-r5} - stm r1!, {r3-r5} - ldr r0, [r0] - str r0, [r1] - movs r0, 0 - strh r0, [r2, 0x4] - adds r2, r6, 0 - cmp r2, 0x2 - ble _081A4852 - mov r0, r8 - bl Free - add sp, 0x44 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81A47E0 - - thumb_func_start sub_81A48B4 -sub_81A48B4: @ 81A48B4 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x74 - mov r9, r0 - mov r10, r1 - movs r0, 0xAC - lsls r0, 1 - bl AllocZeroed - mov r8, r0 - bl sub_80E8260 - mov r0, sp - adds r0, 0x54 - str r0, [sp, 0x70] - add r1, sp, 0x5C - mov r12, r1 - ldr r0, =gSaveBlock2Ptr - ldr r1, [r0] - movs r0, 0x54 - mov r2, r10 - muls r2, r0 - adds r0, r2, 0 - adds r3, r0, r1 - mov r2, sp - movs r4, 0x2 -_081A48EE: - adds r0, r2, 0 - ldr r5, =0x0000057c - adds r1, r3, r5 - ldm r1!, {r5-r7} - stm r0!, {r5-r7} - ldm r1!, {r5-r7} - stm r0!, {r5-r7} - ldr r1, [r1] - str r1, [r0] - adds r3, 0x1C - adds r2, 0x1C - subs r4, 0x1 - cmp r4, 0 - bge _081A48EE - mov r6, r10 - lsls r0, r6, 3 - subs r0, r6 - lsls r0, 2 - add r0, r8 - ldr r1, [sp, 0x70] - movs r7, 0x90 - lsls r7, 1 - adds r0, r7 - ldm r0!, {r2-r4} - stm r1!, {r2-r4} - ldm r0!, {r5-r7} - stm r1!, {r5-r7} - ldr r0, [r0] - str r0, [r1] - movs r4, 0 -_081A492A: - movs r1, 0 - movs r5, 0 - movs r3, 0 - lsls r6, r4, 3 - adds r7, r4, 0x1 - mov r2, sp -_081A4936: - ldrh r0, [r2, 0x8] - cmp r0, r1 - ble _081A4940 - adds r5, r3, 0 - adds r1, r0, 0 -_081A4940: - adds r2, 0x1C - adds r3, 0x1 - cmp r3, 0x2 - ble _081A4936 - mov r2, r12 - ldrh r0, [r2] - cmp r0, r1 - blt _081A4952 - movs r5, 0x3 -_081A4952: - subs r1, r6, r4 - lsls r1, 2 - lsls r0, r5, 3 - subs r0, r5 - lsls r0, 2 - mov r3, sp - adds r2, r3, r0 - add r1, r9 - adds r0, r2, 0 - ldm r0!, {r4-r6} - stm r1!, {r4-r6} - ldm r0!, {r3-r5} - stm r1!, {r3-r5} - ldr r0, [r0] - str r0, [r1] - movs r0, 0 - strh r0, [r2, 0x8] - adds r4, r7, 0 - cmp r4, 0x2 - ble _081A492A - mov r0, r8 - bl Free - add sp, 0x74 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81A48B4 - - thumb_func_start sub_81A4998 -sub_81A4998: @ 81A4998 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x94 - adds r7, r0, 0 - str r1, [sp, 0x90] - ldr r0, =gStringVar1 - ldr r4, =gUnknown_08611CB0 - lsls r5, r7, 3 - adds r1, r5, r4 - ldr r1, [r1] - bl StringCopy - ldr r6, =gStringVar4 - adds r4, 0x4 - adds r5, r4 - ldr r1, [r5] - adds r0, r6, 0 - bl StringExpandPlaceholders - ldr r0, =gRecordsWindowId - mov r8, r0 - ldrb r0, [r0] - movs r1, 0x1 - mov r10, r1 - str r1, [sp] - movs r2, 0xFF - mov r9, r2 - str r2, [sp, 0x4] - movs r5, 0 - str r5, [sp, 0x8] - adds r2, r6, 0 - movs r3, 0 - bl AddTextPrinterParameterized - ldr r1, =gUnknown_08611D00 - ldr r2, [sp, 0x90] - lsls r0, r2, 2 - adds r0, r1 - ldr r4, [r0] - movs r0, 0x1 - adds r1, r4, 0 - movs r2, 0xD0 - bl GetStringRightAlignXOffset - adds r3, r0, 0 - mov r1, r8 - ldrb r0, [r1] - lsls r3, 24 - lsrs r3, 24 - mov r2, r10 - str r2, [sp] - mov r1, r9 - str r1, [sp, 0x4] - str r5, [sp, 0x8] - movs r1, 0x1 - adds r2, r4, 0 - bl AddTextPrinterParameterized - cmp r7, 0x9 - bne _081A4A6C - ldr r2, =gSaveBlock2Ptr - ldr r0, [r2] - ldr r1, =0x00000ee8 - adds r0, r1 - movs r1, 0xFF - strb r1, [r0] - ldr r0, [r2] - movs r2, 0xEF - lsls r2, 4 - adds r0, r2 - movs r1, 0x1 - negs r1, r1 - strb r1, [r0] - add r4, sp, 0x3C - adds r0, r4, 0 - ldr r1, [sp, 0x90] - bl sub_81A48B4 -_081A4A3A: - adds r0, r5, 0 - movs r1, 0x1 - movs r2, 0x4 - adds r3, r4, 0 - bl sub_81A4684 - adds r4, 0x1C - adds r5, 0x1 - cmp r5, 0x2 - ble _081A4A3A - b _081A4A90 - .pool -_081A4A6C: - add r0, sp, 0xC - adds r1, r7, 0 - ldr r2, [sp, 0x90] - bl sub_81A47E0 - movs r5, 0 - add r4, sp, 0xC -_081A4A7A: - str r7, [sp] - adds r0, r5, 0 - movs r1, 0x1 - movs r2, 0x4 - adds r3, r4, 0 - bl sub_81A4594 - adds r4, 0x10 - adds r5, 0x1 - cmp r5, 0x2 - ble _081A4A7A -_081A4A90: - add sp, 0x94 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_81A4998 - - thumb_func_start sub_81A4AA0 -sub_81A4AA0: @ 81A4AA0 - push {r4,lr} - ldr r4, =gRecordsWindowId - ldr r0, =gUnknown_08611C84 - bl AddWindow - strb r0, [r4] - ldrb r0, [r4] - movs r1, 0 - bl NewMenuHelpers_DrawStdWindowFrame - ldrb r0, [r4] - movs r1, 0x11 - bl FillWindowPixelBuffer - ldr r0, =gSpecialVar_0x8005 - ldrh r0, [r0] - movs r1, 0 - bl sub_81A4998 - ldrb r0, [r4] - bl PutWindowTilemap - ldrb r0, [r4] - movs r1, 0x3 - bl CopyWindowToVram - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81A4AA0 - - thumb_func_start sub_81A4AE8 -sub_81A4AE8: @ 81A4AE8 - push {r4,lr} - ldr r4, =gRecordsWindowId - ldrb r0, [r4] - movs r1, 0x11 - bl FillWindowPixelBuffer - ldr r0, =gSpecialVar_0x8005 - ldrh r0, [r0] - movs r1, 0x1 - bl sub_81A4998 - ldrb r0, [r4] - movs r1, 0x2 - bl CopyWindowToVram - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81A4AE8 - thumb_func_start sub_81A4B14 sub_81A4B14: @ 81A4B14 push {r4-r7,lr} diff --git a/data/battle_frontier_2.s b/data/battle_frontier_2.s index fbe9e8798..6c4f342cc 100644 --- a/data/battle_frontier_2.s +++ b/data/battle_frontier_2.s @@ -6,9 +6,6 @@ .section .rodata - .align 2 -gUnknown_08611550:: @ 8611550 - .byte 0x23, 0x46, 0x23, 0x01, 0x04, 0x09, 0x05, 0x00, 0x15, 0x2a, 0x15, 0x01, 0x1c, 0x38, 0x1c, 0x01, 0x15, 0x2a, 0x15, 0x01, 0x1c, 0x8c, 0x38, 0x01, 0x15, 0x46, 0x23, 0x00 .align 2 gUnknown_0861156C:: @ 861156C diff --git a/data/maps/BattleFrontier_RankingHall/scripts.inc b/data/maps/BattleFrontier_RankingHall/scripts.inc index e469024e9..9015694eb 100644 --- a/data/maps/BattleFrontier_RankingHall/scripts.inc +++ b/data/maps/BattleFrontier_RankingHall/scripts.inc @@ -62,9 +62,9 @@ BattleFrontier_RankingHall_EventScript_25E516:: @ 825E516 end BattleFrontier_RankingHall_EventScript_25E522:: @ 825E522 - special sub_81A4AA0 + special ShowRankingHallRecordsWindow waitbuttonpress - special sub_81A4AE8 + special ScrollRankingHallRecordsWindow waitbuttonpress special RemoveRecordsWindow releaseall diff --git a/data/specials.inc b/data/specials.inc index 08e12e5e0..d5133aae2 100644 --- a/data/specials.inc +++ b/data/specials.inc @@ -448,8 +448,8 @@ gSpecials:: @ 81DBA64 def_special sub_80F90DC def_special sub_80F910C def_special sub_80F9160 - def_special sub_81A4AA0 - def_special sub_81A4AE8 + def_special ShowRankingHallRecordsWindow + def_special ScrollRankingHallRecordsWindow def_special sub_8139F20 def_special sub_80F9134 def_special sub_80F9154 diff --git a/include/battle_frontier_2.h b/include/frontier_util.h similarity index 81% rename from include/battle_frontier_2.h rename to include/frontier_util.h index c4639aded..6740e5cda 100644 --- a/include/battle_frontier_2.h +++ b/include/frontier_util.h @@ -1,5 +1,5 @@ -#ifndef GUARD_BATTLE_FRONTIER_2_H -#define GUARD_BATTLE_FRONTIER_2_H +#ifndef GUARD_FRONTIER_UTIL_H +#define GUARD_FRONTIER_UTIL_H #define FRONTIER_BEFORE_TEXT 0 #define FRONTIER_PLAYER_LOST_TEXT 1 @@ -18,4 +18,4 @@ u8 sub_81A6CA8(u8, u8); void sub_81A3908(void); u32 GetCurrentFacilityWinStreak(void); -#endif // GUARD_BATTLE_FRONTIER_2_H +#endif // GUARD_FRONTIER_UTIL_H diff --git a/include/global.h b/include/global.h index 9a03300b2..c2b139e7a 100644 --- a/include/global.h +++ b/include/global.h @@ -137,6 +137,7 @@ enum LanguageId #define BAG_BERRIES_COUNT 46 #define PYRAMID_BAG_ITEMS_COUNT 10 +#define HALL_FACILITIES_COUNT 9 // 7 facilities for single mode + tower double mode + tower multi mode. // string lengths #define ITEM_NAME_LENGTH 14 @@ -402,9 +403,9 @@ struct BattleFrontier /*0xCDC*/ u32 field_CDC; /*0xCE0*/ u16 towerWinStreaks[4][2]; /*0xCF0*/ u16 towerRecordWinStreaks[4][2]; - /*0xD06*/ u16 field_D00; - /*0xD06*/ u16 field_D02; - /*0xD06*/ u16 field_D04; + /*0xD00*/ u16 field_D00; + /*0xD02*/ u16 field_D02; + /*0xD04*/ u16 field_D04; /*0xD06*/ u8 field_D06; /*0xD07*/ u8 field_D07; /*0xD08*/ u8 field_D08_0:1; @@ -482,6 +483,24 @@ struct PlayersApprentice /*0xB8*/ struct Sav2_B8 field_B8[9]; }; +struct RankingHall1P +{ + u8 id[4]; + u16 winStreak; + u8 name[PLAYER_NAME_LENGTH + 1]; + u8 language; +}; + +struct RankingHall2P +{ + u8 id1[4]; + u8 id2[4]; + u16 winStreak; + u8 name1[PLAYER_NAME_LENGTH + 1]; + u8 name2[PLAYER_NAME_LENGTH + 1]; + u8 language; +}; + struct SaveBlock2 { /*0x00*/ u8 playerName[PLAYER_NAME_LENGTH + 1]; @@ -506,11 +525,12 @@ struct SaveBlock2 /*0xA8*/ u32 field_A8; /*0xAC*/ u32 encryptionKey; /*0xB0*/ struct PlayersApprentice playerApprentice; - /*0xDC*/ struct Apprentice apprentices[4]; + /*0xDC*/ struct Apprentice apprentices[4]; // From record mixing. /*0x1EC*/ struct BerryCrush berryCrush; /*0x1FC*/ struct PokemonJumpResults pokeJump; /*0x20C*/ struct BerryPickingResults berryPick; - /*0x21C*/ u8 field_21C[1032]; + /*0x21C*/ struct RankingHall1P hallRecords1P[HALL_FACILITIES_COUNT][2][3]; // From record mixing. + /*0x57C*/ struct RankingHall2P hallRecords2P[2][3]; // From record mixing. /*0x624*/ u16 contestLinkResults[5][4]; // 4 positions for 5 categories. /*0x64C*/ struct BattleFrontier frontier; }; // sizeof=0xF2C diff --git a/include/menu.h b/include/menu.h index d105eb5ec..175eabc07 100644 --- a/include/menu.h +++ b/include/menu.h @@ -26,7 +26,6 @@ u16 RunTextPrintersAndIsPrinter0Active(void); void sub_81973A4(void); void NewMenuHelpers_DrawDialogueFrame(u8, u8); void sub_819746C(u8 windowId, bool8 copyToVram); -void NewMenuHelpers_DrawStdWindowFrame(u8, u8); u16 AddTextPrinterParameterized2(u8 windowId, u8 fontId, const u8 *str, u8 speed, void (*callback)(struct TextSubPrinter *, u16), u8 fgColor, u8 bgColor, u8 shadowColor); void PrintPlayerNameOnWindow(u8, const u8*, u16, u16); void DisplayItemMessageOnField(u8 taskId, const u8 *src, TaskFunc callback); diff --git a/include/record_mixing.h b/include/record_mixing.h index f1b74c143..0d50f46f9 100644 --- a/include/record_mixing.h +++ b/include/record_mixing.h @@ -1,35 +1,13 @@ #ifndef GUARD_RECORD_MIXING_H #define GUARD_RECORD_MIXING_H -// Exported type declarations -struct UnkRecordMixingStruct2a +struct PlayerHallRecords { - u8 playerId[4]; - u16 field_4; - u8 playerName[PLAYER_NAME_LENGTH + 1]; - u8 language; + struct RankingHall1P onePlayer[9][2]; + struct RankingHall2P twoPlayers[2]; }; -struct UnkRecordMixingStruct2b -{ - u8 playerId1[4]; - u8 playerId2[4]; - u16 field_8; - u8 playerName1[PLAYER_NAME_LENGTH + 1]; - u8 playerName2[PLAYER_NAME_LENGTH + 1]; - u8 language; -}; - -struct UnkRecordMixingStruct2 -{ - struct UnkRecordMixingStruct2a field_0[9][2]; - struct UnkRecordMixingStruct2b field_120[2]; -}; - -// Exported RAM declarations - -// Exported ROM declarations void sub_80E6BE8(void); -void sub_80E8260(struct UnkRecordMixingStruct2 *arg0); +void GetPlayerHallRecords(struct PlayerHallRecords *dst); #endif //GUARD_RECORD_MIXING_H diff --git a/include/strings.h b/include/strings.h index c563353ec..9338ae624 100644 --- a/include/strings.h +++ b/include/strings.h @@ -877,4 +877,47 @@ extern const u8 gText_PokemonOnHook[]; extern const u8 gText_NotEvenANibble[]; extern const u8 gText_ItGotAway[]; +// Frontier records. +extern const u8 gText_WinStreak[]; +extern const u8 gText_Record[]; +extern const u8 gText_Current[]; +extern const u8 gText_RoomsCleared[]; +extern const u8 gText_Prev[]; +extern const u8 gText_SingleBattleRoomResults[]; +extern const u8 gText_DoubleBattleRoomResults[]; +extern const u8 gText_MultiBattleRoomResults[]; +extern const u8 gText_LinkMultiBattleRoomResults[]; +extern const u8 gText_Lv502[]; +extern const u8 gText_OpenLv[]; +extern const u8 gText_RentalSwap[]; +extern const u8 gText_ClearStreak[]; +extern const u8 gText_Total[]; +extern const u8 gText_Championships[]; +extern const u8 gText_SingleBattleTourneyResults[]; +extern const u8 gText_DoubleBattleTourneyResults[]; +extern const u8 gText_SingleBattleHallResults[]; +extern const u8 gText_DoubleBattleHallResults[]; +extern const u8 gText_BattleChoiceResults[]; +extern const u8 gText_TimesCleared[]; +extern const u8 gText_KOsInARow[]; +extern const u8 gText_SetKOTourneyResults[]; +extern const u8 gText_TimesVar1[]; +extern const u8 gText_BattleSwapSingleResults[]; +extern const u8 gText_BattleSwapDoubleResults[]; +extern const u8 gText_FloorsCleared[]; +extern const u8 gText_BattleQuestResults[]; +extern const u8 gText_LinkContestResults[]; +extern const u8 gText_4th[]; +extern const u8 gText_3rd[]; +extern const u8 gText_2nd[]; +extern const u8 gText_1st[]; +extern const u8 gText_SpaceAndSpace[]; +extern const u8 gText_CommaSpace[]; +extern const u8 gText_NewLine[]; +extern const u8 gText_ScrollTextUp[]; +extern const u8 gText_Space2[]; +extern const u8 gText_Are[]; +extern const u8 gText_Are2[]; +extern const u8 gText_123Dot[][3]; + #endif //GUARD_STRINGS_H diff --git a/ld_script.txt b/ld_script.txt index 8d07bbe9b..14e47157f 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -246,7 +246,7 @@ SECTIONS { src/menu.o(.text); src/battle_factory.o(.text); src/apprentice.o(.text); - src/battle_frontier_2.o(.text); + src/frontier_util.o(.text); asm/battle_frontier_2.o(.text); src/item_menu.o(.text); src/list_menu.o(.text); @@ -533,6 +533,7 @@ SECTIONS { src/menu.o(.rodata); src/battle_factory.o(.rodata); src/apprentice.o(.rodata); + src/frontier_util.o(.rodata); data/battle_frontier_2.o(.rodata); src/item_menu.o(.rodata); src/list_menu.o(.rodata); diff --git a/src/battle_frontier_2.c b/src/frontier_util.c similarity index 81% rename from src/battle_frontier_2.c rename to src/frontier_util.c index eefa95ab0..bb349f6db 100644 --- a/src/battle_frontier_2.c +++ b/src/frontier_util.c @@ -1,5 +1,5 @@ #include "global.h" -#include "battle_frontier_2.h" +#include "frontier_util.h" #include "event_data.h" #include "battle_setup.h" #include "overworld.h" @@ -22,10 +22,14 @@ #include "pokedex.h" #include "recorded_battle.h" #include "data2.h" +#include "record_mixing.h" +#include "strings.h" +#include "malloc.h" #include "constants/battle_frontier.h" #include "constants/trainers.h" #include "constants/species.h" #include "constants/game_stat.h" +#include "constants/moves.h" extern u8 gUnknown_0203CEF8[]; @@ -34,22 +38,42 @@ extern const u16 gUnknown_08611BFC[][2]; extern const struct BattleFrontierTrainer gBattleFrontierTrainers[]; extern const struct WindowTemplate gUnknown_08611C74; extern const struct WindowTemplate gUnknown_08611C7C; +extern const struct WindowTemplate gUnknown_08611C84; +extern const u8 gUnknown_086118B4[29][7][4]; +extern const u16 gUnknown_08611C9A[]; +extern const u8 *const gUnknown_08611D08[]; +extern const u8 *const gUnknown_08611CB0[][2]; +extern const u8 *const gUnknown_08611D00[]; extern void sub_81B8558(void); // This file's functions. u8 sub_81A3B30(u8 facility); -void ShowTowerResultsWindow(u8); -void ShowDomeResultsWindow(u8); -void ShowPalaceResultsWindow(u8); -void ShowPikeResultsWindow(void); -void ShowFactoryResultsWindow(u8); -void ShowArenaResultsWindow(void); -void ShowPyramidResultsWindow(void); -void ShowLinkContestResultsWindow(void); +static void ShowTowerResultsWindow(u8); +static void ShowDomeResultsWindow(u8); +static void ShowPalaceResultsWindow(u8); +static void ShowPikeResultsWindow(void); +static void ShowFactoryResultsWindow(u8); +static void ShowArenaResultsWindow(void); +static void ShowPyramidResultsWindow(void); +static void ShowLinkContestResultsWindow(void); u8 sub_81A3610(void); void sub_81A51A8(u8); +void sub_81A5030(u8); +// const rom data +const u8 gUnknown_08611550[][4] = +{ + [FRONTIER_FACILITY_TOWER] = {0x23, 0x46, 0x23, 0x01}, + [FRONTIER_FACILITY_DOME] = {0x04, 0x09, 0x05, 0x00}, + [FRONTIER_FACILITY_PALACE] = {0x15, 0x2a, 0x15, 0x01}, + [FRONTIER_FACILITY_ARENA] = {0x1c, 0x38, 0x1c, 0x01}, + [FRONTIER_FACILITY_FACTORY] = {0x15, 0x2a, 0x15, 0x01}, + [FRONTIER_FACILITY_PIKE] = {0x1c, 0x8c, 0x38, 0x01}, + [FRONTIER_FACILITY_PYRAMID] = {0x15, 0x46, 0x23, 0x00}, +}; + +// code void sub_81A1780(void) { gUnknown_08611C18[gSpecialVar_0x8004](); @@ -214,7 +238,7 @@ void sub_81A1B98(void) } } -bool8 sub_81A1C24(u32 flags) +static bool8 sub_81A1C24(u32 flags) { if (gSaveBlock2Ptr->frontier.field_CDC & flags) return TRUE; @@ -222,14 +246,14 @@ bool8 sub_81A1C24(u32 flags) return FALSE; } -void sub_81A1C4C(const u8 *str, s32 y) +static void sub_81A1C4C(const u8 *str, s32 y) { s32 x = GetStringCenterAlignXOffset(1, str, 0xE0); y = (y * 8) + 1; AddTextPrinterParameterized(gRecordsWindowId, 1, str, x, y, TEXT_SPEED_FF, NULL); } -void PrintHyphens(s32 y) +static void PrintHyphens(s32 y) { s32 i; u8 text[37]; @@ -242,47 +266,8 @@ void PrintHyphens(s32 y) AddTextPrinterParameterized(gRecordsWindowId, 1, text, 4, y, TEXT_SPEED_FF, NULL); } -extern const u8 gText_WinStreak[]; -extern const u8 gText_Record[]; -extern const u8 gText_Current[]; -extern const u8 gText_RoomsCleared[]; -extern const u8 gText_Prev[]; -extern const u8 gText_SingleBattleRoomResults[]; -extern const u8 gText_DoubleBattleRoomResults[]; -extern const u8 gText_MultiBattleRoomResults[]; -extern const u8 gText_LinkMultiBattleRoomResults[]; -extern const u8 gText_Lv502[]; -extern const u8 gText_OpenLv[]; -extern const u8 gText_RentalSwap[]; -extern const u8 gText_ClearStreak[]; -extern const u8 gText_Total[]; -extern const u8 gText_Championships[]; -extern const u8 gText_SingleBattleTourneyResults[]; -extern const u8 gText_DoubleBattleTourneyResults[]; -extern const u8 gText_SingleBattleHallResults[]; -extern const u8 gText_DoubleBattleHallResults[]; -extern const u8 gText_BattleChoiceResults[]; -extern const u8 gText_TimesCleared[]; -extern const u8 gText_KOsInARow[]; -extern const u8 gText_SetKOTourneyResults[]; -extern const u8 gText_TimesVar1[]; -extern const u8 gText_BattleSwapSingleResults[]; -extern const u8 gText_BattleSwapDoubleResults[]; -extern const u8 gText_FloorsCleared[]; -extern const u8 gText_BattleQuestResults[]; -extern const u8 gText_LinkContestResults[]; -extern const u8 gText_4th[]; -extern const u8 gText_3rd[]; -extern const u8 gText_2nd[]; -extern const u8 gText_1st[]; -extern const u8 gText_Cool[]; -extern const u8 gText_Beauty[]; -extern const u8 gText_Cute[]; -extern const u8 gText_Smart[]; -extern const u8 gText_Tough[]; - -// Battle Tower. -void TowerPrintStreak(const u8 *str, u16 num, u8 x1, u8 x2, u8 y) +// Battle Tower records. +static void TowerPrintStreak(const u8 *str, u16 num, u8 x1, u8 x2, u8 y) { AddTextPrinterParameterized(gRecordsWindowId, 1, str, x1, y, TEXT_SPEED_FF, NULL); if (num > 9999) @@ -292,13 +277,13 @@ void TowerPrintStreak(const u8 *str, u16 num, u8 x1, u8 x2, u8 y) AddTextPrinterParameterized(gRecordsWindowId, 1, gStringVar4, x2, y, TEXT_SPEED_FF, NULL); } -void TowerPrintRecordStreak(u8 battleMode, u8 lvlMode, u8 x1, u8 x2, u8 y) +static void TowerPrintRecordStreak(u8 battleMode, u8 lvlMode, u8 x1, u8 x2, u8 y) { u16 num = gSaveBlock2Ptr->frontier.towerRecordWinStreaks[battleMode][lvlMode]; TowerPrintStreak(gText_Record, num, x1, x2, y); } -u16 TowerGetWinStreak(u8 battleMode, u8 lvlMode) +static u16 TowerGetWinStreak(u8 battleMode, u8 lvlMode) { u16 winStreak = gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode]; if (winStreak > 9999) @@ -307,7 +292,7 @@ u16 TowerGetWinStreak(u8 battleMode, u8 lvlMode) return winStreak; } -void TowerPrintPrevOrCurrentStreak(u8 battleMode, u8 lvlMode, u8 x1, u8 x2, u8 y) +static void TowerPrintPrevOrCurrentStreak(u8 battleMode, u8 lvlMode, u8 x1, u8 x2, u8 y) { bool8 isCurrent; u16 winStreak = TowerGetWinStreak(battleMode, lvlMode); @@ -346,7 +331,7 @@ void TowerPrintPrevOrCurrentStreak(u8 battleMode, u8 lvlMode, u8 x1, u8 x2, u8 y TowerPrintStreak(gText_Prev, winStreak, x1, x2, y); } -void ShowTowerResultsWindow(u8 battleMode) +static void ShowTowerResultsWindow(u8 battleMode) { gRecordsWindowId = AddWindow(&gUnknown_08611C74); NewMenuHelpers_DrawStdWindowFrame(gRecordsWindowId, FALSE); @@ -372,8 +357,8 @@ void ShowTowerResultsWindow(u8 battleMode) CopyWindowToVram(gRecordsWindowId, 3); } -// Battle Dome. -u16 DomeGetWinStreak(u8 battleMode, u8 lvlMode) +// Battle Dome records. +static u16 DomeGetWinStreak(u8 battleMode, u8 lvlMode) { u16 winStreak = gSaveBlock2Ptr->frontier.domeWinStreaks[battleMode][lvlMode]; if (winStreak > 9999) @@ -382,7 +367,7 @@ u16 DomeGetWinStreak(u8 battleMode, u8 lvlMode) return winStreak; } -void PrintTwoStrings(const u8 *str1, const u8 *str2, u16 num, u8 x1, u8 x2, u8 y) +static void PrintTwoStrings(const u8 *str1, const u8 *str2, u16 num, u8 x1, u8 x2, u8 y) { AddTextPrinterParameterized(gRecordsWindowId, 1, str1, x1, y, TEXT_SPEED_FF, NULL); ConvertIntToDecimalStringN(gStringVar1, num, STR_CONV_MODE_RIGHT_ALIGN, 4); @@ -390,7 +375,7 @@ void PrintTwoStrings(const u8 *str1, const u8 *str2, u16 num, u8 x1, u8 x2, u8 y AddTextPrinterParameterized(gRecordsWindowId, 1, gStringVar4, x2, y, TEXT_SPEED_FF, NULL); } -void DomePrintPrevOrCurrentStreak(u8 battleMode, u8 lvlMode, u8 x1, u8 x2, u8 y) +static void DomePrintPrevOrCurrentStreak(u8 battleMode, u8 lvlMode, u8 x1, u8 x2, u8 y) { bool8 isCurrent; u16 winStreak = DomeGetWinStreak(battleMode, lvlMode); @@ -417,7 +402,7 @@ void DomePrintPrevOrCurrentStreak(u8 battleMode, u8 lvlMode, u8 x1, u8 x2, u8 y) PrintTwoStrings(gText_Prev, gText_ClearStreak, winStreak, x1, x2, y); } -void ShowDomeResultsWindow(u8 battleMode) +static void ShowDomeResultsWindow(u8 battleMode) { gRecordsWindowId = AddWindow(&gUnknown_08611C74); NewMenuHelpers_DrawStdWindowFrame(gRecordsWindowId, FALSE); @@ -441,8 +426,8 @@ void ShowDomeResultsWindow(u8 battleMode) CopyWindowToVram(gRecordsWindowId, 3); } -// Battle Palace. -void PalacePrintStreak(const u8 *str, u16 num, u8 x1, u8 x2, u8 y) +// Battle Palace records. +static void PalacePrintStreak(const u8 *str, u16 num, u8 x1, u8 x2, u8 y) { AddTextPrinterParameterized(gRecordsWindowId, 1, str, x1, y, TEXT_SPEED_FF, NULL); if (num > 9999) @@ -452,13 +437,13 @@ void PalacePrintStreak(const u8 *str, u16 num, u8 x1, u8 x2, u8 y) AddTextPrinterParameterized(gRecordsWindowId, 1, gStringVar4, x2, y, TEXT_SPEED_FF, NULL); } -void PalacePrintRecordStreak(u8 battleMode, u8 lvlMode, u8 x1, u8 x2, u8 y) +static void PalacePrintRecordStreak(u8 battleMode, u8 lvlMode, u8 x1, u8 x2, u8 y) { u16 num = gSaveBlock2Ptr->frontier.palaceRecordWinStreaks[battleMode][lvlMode]; PalacePrintStreak(gText_Record, num, x1, x2, y); } -u16 PalaceGetWinStreak(u8 battleMode, u8 lvlMode) +static u16 PalaceGetWinStreak(u8 battleMode, u8 lvlMode) { u16 winStreak = gSaveBlock2Ptr->frontier.palaceWinStreaks[battleMode][lvlMode]; if (winStreak > 9999) @@ -467,7 +452,7 @@ u16 PalaceGetWinStreak(u8 battleMode, u8 lvlMode) return winStreak; } -void PalacePrintPrevOrCurrentStreak(u8 battleMode, u8 lvlMode, u8 x1, u8 x2, u8 y) +static void PalacePrintPrevOrCurrentStreak(u8 battleMode, u8 lvlMode, u8 x1, u8 x2, u8 y) { bool8 isCurrent; u16 winStreak = PalaceGetWinStreak(battleMode, lvlMode); @@ -493,7 +478,7 @@ void PalacePrintPrevOrCurrentStreak(u8 battleMode, u8 lvlMode, u8 x1, u8 x2, u8 PalacePrintStreak(gText_Prev, winStreak, x1, x2, y); } -void ShowPalaceResultsWindow(u8 battleMode) +static void ShowPalaceResultsWindow(u8 battleMode) { gRecordsWindowId = AddWindow(&gUnknown_08611C74); NewMenuHelpers_DrawStdWindowFrame(gRecordsWindowId, FALSE); @@ -515,8 +500,8 @@ void ShowPalaceResultsWindow(u8 battleMode) CopyWindowToVram(gRecordsWindowId, 3); } -// Battle Pike. -u16 PikeGetWinStreak(u8 lvlMode) +// Battle Pike records. +static u16 PikeGetWinStreak(u8 lvlMode) { u16 winStreak = gSaveBlock2Ptr->frontier.pikeWinStreaks[lvlMode]; if (winStreak > 9999) @@ -525,7 +510,7 @@ u16 PikeGetWinStreak(u8 lvlMode) return winStreak; } -void PikePrintCleared(const u8 *str1, const u8 *str2, u16 num, u8 x1, u8 x2, u8 y) +static void PikePrintCleared(const u8 *str1, const u8 *str2, u16 num, u8 x1, u8 x2, u8 y) { AddTextPrinterParameterized(gRecordsWindowId, 1, str1, x1, y, TEXT_SPEED_FF, NULL); ConvertIntToDecimalStringN(gStringVar1, num, STR_CONV_MODE_RIGHT_ALIGN, 4); @@ -533,7 +518,7 @@ void PikePrintCleared(const u8 *str1, const u8 *str2, u16 num, u8 x1, u8 x2, u8 AddTextPrinterParameterized(gRecordsWindowId, 1, gStringVar4, x2, y, TEXT_SPEED_FF, NULL); } -void PikePrintPrevOrCurrentStreak(u8 lvlMode, u8 x1, u8 x2, u8 y) +static void PikePrintPrevOrCurrentStreak(u8 lvlMode, u8 x1, u8 x2, u8 y) { bool8 isCurrent; u16 winStreak = PikeGetWinStreak(lvlMode); @@ -549,7 +534,7 @@ void PikePrintPrevOrCurrentStreak(u8 lvlMode, u8 x1, u8 x2, u8 y) PrintTwoStrings(gText_Prev, gText_RoomsCleared, winStreak, x1, x2, y); } -void ShowPikeResultsWindow(void) +static void ShowPikeResultsWindow(void) { gRecordsWindowId = AddWindow(&gUnknown_08611C74); NewMenuHelpers_DrawStdWindowFrame(gRecordsWindowId, FALSE); @@ -569,8 +554,8 @@ void ShowPikeResultsWindow(void) CopyWindowToVram(gRecordsWindowId, 3); } -// Battle Arena. -void ArenaPrintStreak(const u8 *str, u16 num, u8 x1, u8 x2, u8 y) +// Battle Arena records. +static void ArenaPrintStreak(const u8 *str, u16 num, u8 x1, u8 x2, u8 y) { AddTextPrinterParameterized(gRecordsWindowId, 1, str, x1, y, TEXT_SPEED_FF, NULL); if (num > 9999) @@ -580,13 +565,13 @@ void ArenaPrintStreak(const u8 *str, u16 num, u8 x1, u8 x2, u8 y) AddTextPrinterParameterized(gRecordsWindowId, 1, gStringVar4, x2, y, TEXT_SPEED_FF, NULL); } -void ArenaPrintRecordStreak(u8 lvlMode, u8 x1, u8 x2, u8 y) +static void ArenaPrintRecordStreak(u8 lvlMode, u8 x1, u8 x2, u8 y) { u16 num = gSaveBlock2Ptr->frontier.arenaRecordStreaks[lvlMode]; ArenaPrintStreak(gText_Record, num, x1, x2, y); } -u16 ArenaGetWinStreak(u8 lvlMode) +static u16 ArenaGetWinStreak(u8 lvlMode) { u16 winStreak = gSaveBlock2Ptr->frontier.arenaWinStreaks[lvlMode]; if (winStreak > 9999) @@ -595,7 +580,7 @@ u16 ArenaGetWinStreak(u8 lvlMode) return winStreak; } -void ArenaPrintPrevOrCurrentStreak(u8 lvlMode, u8 x1, u8 x2, u8 y) +static void ArenaPrintPrevOrCurrentStreak(u8 lvlMode, u8 x1, u8 x2, u8 y) { bool8 isCurrent; u16 winStreak = ArenaGetWinStreak(lvlMode); @@ -611,7 +596,7 @@ void ArenaPrintPrevOrCurrentStreak(u8 lvlMode, u8 x1, u8 x2, u8 y) ArenaPrintStreak(gText_Prev, winStreak, x1, x2, y); } -void ShowArenaResultsWindow(void) +static void ShowArenaResultsWindow(void) { gRecordsWindowId = AddWindow(&gUnknown_08611C74); NewMenuHelpers_DrawStdWindowFrame(gRecordsWindowId, FALSE); @@ -629,8 +614,8 @@ void ShowArenaResultsWindow(void) CopyWindowToVram(gRecordsWindowId, 3); } -// Battle Factory. -void FactoryPrintStreak(const u8 *str, u16 num1, u16 num2, u8 x1, u8 x2, u8 x3, u8 y) +// Battle Factory records. +static void FactoryPrintStreak(const u8 *str, u16 num1, u16 num2, u8 x1, u8 x2, u8 x3, u8 y) { AddTextPrinterParameterized(gRecordsWindowId, 1, str, x1, y, TEXT_SPEED_FF, NULL); if (num1 > 9999) @@ -644,14 +629,14 @@ void FactoryPrintStreak(const u8 *str, u16 num1, u16 num2, u8 x1, u8 x2, u8 x3, AddTextPrinterParameterized(gRecordsWindowId, 1, gStringVar4, x3, y, TEXT_SPEED_FF, NULL); } -void FactoryPrintRecordStreak(u8 battleMode, u8 lvlMode, u8 x1, u8 x2, u8 x3, u8 y) +static void FactoryPrintRecordStreak(u8 battleMode, u8 lvlMode, u8 x1, u8 x2, u8 x3, u8 y) { u16 num1 = gSaveBlock2Ptr->frontier.factoryRecordWinStreaks[battleMode][lvlMode]; u16 num2 = gSaveBlock2Ptr->frontier.factoryRecordRentsCount[battleMode][lvlMode]; FactoryPrintStreak(gText_Record, num1, num2, x1, x2, x3, y); } -u16 FactoryGetWinStreak(u8 battleMode, u8 lvlMode) +static u16 FactoryGetWinStreak(u8 battleMode, u8 lvlMode) { u16 winStreak = gSaveBlock2Ptr->frontier.factoryWinStreaks[battleMode][lvlMode]; if (winStreak > 9999) @@ -660,7 +645,7 @@ u16 FactoryGetWinStreak(u8 battleMode, u8 lvlMode) return winStreak; } -u16 FactoryGetRentsCount(u8 battleMode, u8 lvlMode) +static u16 FactoryGetRentsCount(u8 battleMode, u8 lvlMode) { u16 rents = gSaveBlock2Ptr->frontier.factoryRentsCount[battleMode][lvlMode]; if (rents > 9999) @@ -669,7 +654,7 @@ u16 FactoryGetRentsCount(u8 battleMode, u8 lvlMode) return rents; } -void FactoryPrintPrevOrCurrentStreak(u8 battleMode, u8 lvlMode, u8 x1, u8 x2, u8 x3, u8 y) +static void FactoryPrintPrevOrCurrentStreak(u8 battleMode, u8 lvlMode, u8 x1, u8 x2, u8 x3, u8 y) { bool8 isCurrent; u16 winStreak = FactoryGetWinStreak(battleMode, lvlMode); @@ -697,7 +682,7 @@ void FactoryPrintPrevOrCurrentStreak(u8 battleMode, u8 lvlMode, u8 x1, u8 x2, u8 FactoryPrintStreak(gText_Prev, winStreak, rents, x1, x2, x3, y); } -void ShowFactoryResultsWindow(u8 battleMode) +static void ShowFactoryResultsWindow(u8 battleMode) { gRecordsWindowId = AddWindow(&gUnknown_08611C74); NewMenuHelpers_DrawStdWindowFrame(gRecordsWindowId, FALSE); @@ -720,8 +705,8 @@ void ShowFactoryResultsWindow(u8 battleMode) CopyWindowToVram(gRecordsWindowId, 3); } -// Battle Pyramid. -void PyramidPrintStreak(const u8 *str, u16 num, u8 x1, u8 x2, u8 y) +// Battle Pyramid records. +static void PyramidPrintStreak(const u8 *str, u16 num, u8 x1, u8 x2, u8 y) { AddTextPrinterParameterized(gRecordsWindowId, 1, str, x1, y, TEXT_SPEED_FF, NULL); if (num > 9999) @@ -731,13 +716,13 @@ void PyramidPrintStreak(const u8 *str, u16 num, u8 x1, u8 x2, u8 y) AddTextPrinterParameterized(gRecordsWindowId, 1, gStringVar4, x2, y, TEXT_SPEED_FF, NULL); } -void PyramidPrintRecordStreak(u8 lvlMode, u8 x1, u8 x2, u8 y) +static void PyramidPrintRecordStreak(u8 lvlMode, u8 x1, u8 x2, u8 y) { u16 num = gSaveBlock2Ptr->frontier.pyramidRecordStreaks[lvlMode]; PyramidPrintStreak(gText_Record, num, x1, x2, y); } -u16 PyramidGetWinStreak(u8 lvlMode) +static u16 PyramidGetWinStreak(u8 lvlMode) { u16 winStreak = gSaveBlock2Ptr->frontier.pyramidWinStreaks[lvlMode]; if (winStreak > 9999) @@ -746,7 +731,7 @@ u16 PyramidGetWinStreak(u8 lvlMode) return winStreak; } -void PyramidPrintPrevOrCurrentStreak(u8 lvlMode, u8 x1, u8 x2, u8 y) +static void PyramidPrintPrevOrCurrentStreak(u8 lvlMode, u8 x1, u8 x2, u8 y) { bool8 isCurrent; u16 winStreak = PyramidGetWinStreak(lvlMode); @@ -762,7 +747,7 @@ void PyramidPrintPrevOrCurrentStreak(u8 lvlMode, u8 x1, u8 x2, u8 y) PyramidPrintStreak(gText_Prev, winStreak, x1, x2, y); } -void ShowPyramidResultsWindow(void) +static void ShowPyramidResultsWindow(void) { gRecordsWindowId = AddWindow(&gUnknown_08611C74); NewMenuHelpers_DrawStdWindowFrame(gRecordsWindowId, FALSE); @@ -780,8 +765,8 @@ void ShowPyramidResultsWindow(void) CopyWindowToVram(gRecordsWindowId, 3); } -// Link contest. Why is it in this file? -void ShowLinkContestResultsWindow(void) +// Link contest records. Why is it in this file? +static void ShowLinkContestResultsWindow(void) { const u8 *str; s32 i, j; @@ -957,8 +942,6 @@ void sub_81A35EC(void) gSpecialVar_Result = sub_81A3610(); } -extern const u8 gUnknown_08611550[][4]; - u8 sub_81A3610(void) { s32 ret = 0; @@ -1151,8 +1134,6 @@ u8 sub_81A3B30(u8 facility) + FlagGet(FLAG_SYS_TOWER_GOLD + facility * 2); } -extern const u8 gUnknown_086118B4[29][7][4]; - void sub_81A3B64(void) { s32 challengeNum = 0; @@ -1235,15 +1216,7 @@ void sub_81A3DA0(void) gSpecialVar_Result = FALSE; } -extern const u8 gText_SpaceAndSpace[]; -extern const u8 gText_CommaSpace[]; -extern const u8 gText_NewLine[]; -extern const u8 gText_ScrollTextUp[]; -extern const u8 gText_Space2[]; -extern const u8 gText_Are[]; -extern const u8 gText_Are2[]; - -u8 sub_81A3DD0(u16 species, u8 arg1, s32 arg2) +static u8 sub_81A3DD0(u16 species, u8 arg1, s32 arg2) { if (GetSetPokedexFlag(SpeciesToNationalPokedexNum(species), FLAG_GET_CAUGHT)) { @@ -1282,9 +1255,7 @@ u8 sub_81A3DD0(u16 species, u8 arg1, s32 arg2) return arg1; } -extern const u16 gUnknown_08611C9A[]; - -void AppendIfValid(u16 species, u16 heldItem, u16 hp, u8 lvlMode, u8 monLevel, u16 *speciesArray, u16 *itemsArray, u8 *count) +static void AppendIfValid(u16 species, u16 heldItem, u16 hp, u8 lvlMode, u8 monLevel, u16 *speciesArray, u16 *itemsArray, u8 *count) { s32 i = 0; @@ -1494,3 +1465,194 @@ void sub_81A443C(void) break; } } + +void sub_81A447C(void) +{ + u8 i, j, k; + + for (i = 0; i < 4; i++) + { + u16 monId = gSaveBlock2Ptr->frontier.selectedPartyMons[i] - 1; + if (monId < PARTY_SIZE) + { + for (j = 0; j < 4; j++) + { + for (k = 0; k < 4; k++) + { + if (GetMonData(&gSaveBlock1Ptr->playerParty[gSaveBlock2Ptr->frontier.selectedPartyMons[i] - 1], MON_DATA_MOVE1 + k, NULL) + == GetMonData(&gPlayerParty[i], MON_DATA_MOVE1 + j, NULL)) + break; + } + if (k == 4) + SetMonMoveSlot(&gPlayerParty[i], MOVE_SKETCH, j); + } + gSaveBlock1Ptr->playerParty[gSaveBlock2Ptr->frontier.selectedPartyMons[i] - 1] = gPlayerParty[i]; + } + } +} + +void sub_81A457C(void) +{ + sub_81A5030(VarGet(VAR_FRONTIER_FACILITY)); +} + +// Battle Frontier Ranking Hall records. +static void Print1PRecord(s32 position, s32 x, s32 y, struct RankingHall1P *hallRecord, s32 hallFacilityId) +{ + u8 text[32]; + u16 winStreak; + + AddTextPrinterParameterized(gRecordsWindowId, 1, gText_123Dot[position], x * 8, (8 * (y + 5 * position)) + 1, TEXT_SPEED_FF, NULL); + hallRecord->name[PLAYER_NAME_LENGTH] = EOS; + if (hallRecord->winStreak) + { + TVShowConvertInternationalString(text, hallRecord->name, hallRecord->language); + AddTextPrinterParameterized(gRecordsWindowId, 1, text, (x + 2) * 8, (8 * (y + 5 * position)) + 1, TEXT_SPEED_FF, NULL); + winStreak = hallRecord->winStreak; + if (winStreak > 9999) + winStreak = 9999; + ConvertIntToDecimalStringN(gStringVar2, winStreak, STR_CONV_MODE_RIGHT_ALIGN, 4); + StringExpandPlaceholders(gStringVar4, gUnknown_08611D08[hallFacilityId]); + AddTextPrinterParameterized(gRecordsWindowId, 1, gStringVar4, GetStringRightAlignXOffset(1, gUnknown_08611D08[hallFacilityId], 0xC8), (8 * (y + 5 * position)) + 1, TEXT_SPEED_FF, NULL); + } +} + +static void Print2PRecord(s32 position, s32 x, s32 y, struct RankingHall2P *hallRecord) +{ + u8 text[32]; + u16 winStreak; + + AddTextPrinterParameterized(gRecordsWindowId, 1, gText_123Dot[position], x * 8, (8 * (y + 5 * position)) + 1, TEXT_SPEED_FF, NULL); + if (hallRecord->winStreak) + { + hallRecord->name1[PLAYER_NAME_LENGTH] = EOS; + hallRecord->name2[PLAYER_NAME_LENGTH] = EOS; + TVShowConvertInternationalString(text, hallRecord->name1, hallRecord->language); + AddTextPrinterParameterized(gRecordsWindowId, 1, text, (x + 2) * 8, (8 * (y + 5 * position - 1)) + 1, TEXT_SPEED_FF, NULL); + if (IsStringJapanese(hallRecord->name2)) + TVShowConvertInternationalString(text, hallRecord->name2, LANGUAGE_JAPANESE); + else + StringCopy(text, hallRecord->name2); + AddTextPrinterParameterized(gRecordsWindowId, 1, text, (x + 4) * 8, (8 * (y + 5 * position + 1)) + 1, TEXT_SPEED_FF, NULL); + + winStreak = hallRecord->winStreak; + if (winStreak > 9999) + winStreak = 9999; + ConvertIntToDecimalStringN(gStringVar2, winStreak, STR_CONV_MODE_RIGHT_ALIGN, 4); + StringExpandPlaceholders(gStringVar4, gUnknown_08611D08[9]); + AddTextPrinterParameterized(gRecordsWindowId, 1, gStringVar4, GetStringRightAlignXOffset(1, gUnknown_08611D08[9], 0xC8), (8 * (y + 5 * position)) + 1, TEXT_SPEED_FF, NULL); + } +} + +static void Fill1PRecords(struct RankingHall1P *dst, s32 hallFacilityId, s32 lvlMode) +{ + s32 i, j; + struct RankingHall1P record1P[4]; + struct PlayerHallRecords *playerHallRecords = calloc(1, sizeof(struct PlayerHallRecords)); + GetPlayerHallRecords(playerHallRecords); + + for (i = 0; i < 3; i++) + record1P[i] = gSaveBlock2Ptr->hallRecords1P[hallFacilityId][lvlMode][i]; + + record1P[3] = playerHallRecords->onePlayer[hallFacilityId][lvlMode]; + + for (i = 0; i < 3; i++) + { + s32 highestWinStreak = 0; + s32 highestId = 0; + for (j = 0; j < 4; j++) + { + if (record1P[j].winStreak > highestWinStreak) + { + highestId = j; + highestWinStreak = record1P[j].winStreak; + } + } + if (record1P[3].winStreak >= highestWinStreak) + highestId = 3; + + dst[i] = record1P[highestId]; + record1P[highestId].winStreak = 0; + } + + free(playerHallRecords); +} + +static void Fill2PRecords(struct RankingHall2P *dst, s32 lvlMode) +{ + s32 i, j; + struct RankingHall2P record2P[4]; + struct PlayerHallRecords *playerHallRecords = calloc(1, sizeof(struct PlayerHallRecords)); + GetPlayerHallRecords(playerHallRecords); + + for (i = 0; i < 3; i++) + record2P[i] = gSaveBlock2Ptr->hallRecords2P[lvlMode][i]; + + record2P[3] = playerHallRecords->twoPlayers[lvlMode]; + + for (i = 0; i < 3; i++) + { + s32 highestWinStreak = 0; + s32 highestId = 0; + for (j = 0; j < 3; j++) + { + if (record2P[j].winStreak > highestWinStreak) + { + highestId = j; + highestWinStreak = record2P[j].winStreak; + } + } + if (record2P[3].winStreak >= highestWinStreak) + highestId = 3; + + dst[i] = record2P[highestId]; + record2P[highestId].winStreak = 0; + } + + free(playerHallRecords); +} + +static void PrintHallRecords(s32 hallFacilityId, s32 lvlMode) +{ + s32 i; + s32 x; + struct RankingHall1P records1P[3]; + struct RankingHall2P records2P[3]; + + StringCopy(gStringVar1, gUnknown_08611CB0[hallFacilityId][0]); + StringExpandPlaceholders(gStringVar4, gUnknown_08611CB0[hallFacilityId][1]); + AddTextPrinterParameterized(gRecordsWindowId, 1, gStringVar4, 0, 1, TEXT_SPEED_FF, NULL); + x = GetStringRightAlignXOffset(1, gUnknown_08611D00[lvlMode], 0xD0); + AddTextPrinterParameterized(gRecordsWindowId, 1, gUnknown_08611D00[lvlMode], x, 1, TEXT_SPEED_FF, NULL); + if (hallFacilityId == HALL_FACILITIES_COUNT) + { + gSaveBlock2Ptr->frontier.field_EE1[0][PLAYER_NAME_LENGTH] = EOS; + gSaveBlock2Ptr->frontier.field_EE1[1][PLAYER_NAME_LENGTH] = EOS; + Fill2PRecords(records2P, lvlMode); + for (i = 0; i < 3; i++) + Print2PRecord(i, 1, 4, &records2P[i]); + } + else + { + Fill1PRecords(records1P, hallFacilityId, lvlMode); + for (i = 0; i < 3; i++) + Print1PRecord(i, 1, 4, &records1P[i], hallFacilityId); + } +} + +void ShowRankingHallRecordsWindow(void) +{ + gRecordsWindowId = AddWindow(&gUnknown_08611C84); + NewMenuHelpers_DrawStdWindowFrame(gRecordsWindowId, FALSE); + FillWindowPixelBuffer(gRecordsWindowId, 0x11); + PrintHallRecords(gSpecialVar_0x8005, FRONTIER_LVL_50); + PutWindowTilemap(gRecordsWindowId); + CopyWindowToVram(gRecordsWindowId, 3); +} + +void ScrollRankingHallRecordsWindow(void) +{ + FillWindowPixelBuffer(gRecordsWindowId, 0x11); + PrintHallRecords(gSpecialVar_0x8005, FRONTIER_LVL_OPEN); + CopyWindowToVram(gRecordsWindowId, 2); +} diff --git a/src/record_mixing.c b/src/record_mixing.c index 4bb97cf1d..6caea7239 100644 --- a/src/record_mixing.c +++ b/src/record_mixing.c @@ -33,31 +33,17 @@ #include "new_game.h" #include "daycare.h" #include "international_string_util.h" +#include "constants/battle_frontier.h" extern void ReceiveSecretBasesData(struct SecretBaseRecord *, size_t, u8); extern void ReceiveEasyChatPairsData(struct EasyChatPair *, size_t, u8); // Static type declarations -struct UnknownRecMixingStruct +struct RecordMixingHallRecords { - u32 field_0; - u16 field_4; - u8 field_6[9]; -}; - -struct UnknownRecMixingStruct2 -{ - u32 field_0; - u16 field_4; - u16 field_6; - u16 field_8; - u8 field_A[16]; -}; - -struct UnknownRecMixingStruct3 -{ - u8 field_0[0x810]; + struct RankingHall1P hallRecords1P[HALL_FACILITIES_COUNT][2][6]; + struct RankingHall2P hallRecords2P[2][6]; }; struct PlayerRecordsRS @@ -85,7 +71,7 @@ struct PlayerRecordsEmerald /* 0x1210 */ u16 giftItem; /* 0x1214 */ LilycoveLady lilycoveLady; /* 0x1254 */ struct Apprentice apprentice[2]; - /* 0x12dc */ struct UnkRecordMixingStruct2 unk_12dc; + /* 0x12dc */ struct PlayerHallRecords hallRecords; /* 0x1434 */ u8 field_1434[0x10]; }; // 0x1444 @@ -106,7 +92,7 @@ static IWRAM_DATA struct EasyChatPair *sEasyChatPairsSave; static IWRAM_DATA struct RecordMixingDayCareMail *gUnknown_03001148; static IWRAM_DATA void *sBattleTowerSave; static IWRAM_DATA LilycoveLady *sLilycoveLadySave; -static IWRAM_DATA void *gUnknown_03001154; // gSaveBlock2Ptr->field_0DC; +static IWRAM_DATA void *sApprenticesSave; static IWRAM_DATA void *sBattleTowerSave_Duplicate; static IWRAM_DATA u32 sRecordStructSize; static IWRAM_DATA u8 gUnknown_03001160; @@ -137,7 +123,7 @@ static void ReceiveGiftItem(u16 *item, u8 which); static void sub_80E7FF8(u8 taskId); static void sub_80E8110(struct Apprentice *arg0, struct Apprentice *arg1); static void ReceiveApprenticeData(struct Apprentice *arg0, size_t arg1, u32 arg2); -static void sub_80E89AC(struct UnkRecordMixingStruct2 *arg0, size_t arg1, u32 arg2); +static void ReceiveRankingHallRecords(struct PlayerHallRecords *hallRecords, size_t arg1, u32 arg2); static void sub_80E89F8(struct RecordMixingDayCareMail *dst); static void SanitizeDayCareMailForRuby(struct RecordMixingDayCareMail *src); static void SanitizeEmeraldBattleTowerRecord(struct EmeraldBattleTowerRecord *arg0); @@ -200,7 +186,7 @@ static void SetSrcLookupPointers(void) gUnknown_03001148 = &gUnknown_02039F9C; sBattleTowerSave = &gSaveBlock2Ptr->frontier.towerPlayer; sLilycoveLadySave = &gSaveBlock1Ptr->lilycoveLady; - gUnknown_03001154 = gSaveBlock2Ptr->apprentices; + sApprenticesSave = gSaveBlock2Ptr->apprentices; sBattleTowerSave_Duplicate = &gSaveBlock2Ptr->frontier.towerPlayer; } @@ -266,8 +252,8 @@ static void PrepareExchangePacket(void) if (GetMultiplayerId() == 0) sSentRecord->emerald.giftItem = GetRecordMixingGift(); - sub_80E8110(sSentRecord->emerald.apprentice, gUnknown_03001154); - sub_80E8260(&sSentRecord->emerald.unk_12dc); + sub_80E8110(sSentRecord->emerald.apprentice, sApprenticesSave); + GetPlayerHallRecords(&sSentRecord->emerald.hallRecords); } } @@ -300,7 +286,7 @@ static void ReceiveExchangePacket(u32 which) ReceiveGiftItem(&sReceivedRecords->emerald.giftItem, which); ReceiveLilycoveLadyData(&sReceivedRecords->emerald.lilycoveLady, sizeof(struct PlayerRecordsEmerald), which); ReceiveApprenticeData(sReceivedRecords->emerald.apprentice, sizeof(struct PlayerRecordsEmerald), (u8) which); - sub_80E89AC(&sReceivedRecords->emerald.unk_12dc, sizeof(struct PlayerRecordsEmerald), (u8) which); + ReceiveRankingHallRecords(&sReceivedRecords->emerald.hallRecords, sizeof(struct PlayerRecordsEmerald), (u8) which); } } @@ -1608,42 +1594,42 @@ static void sub_80E8110(struct Apprentice *dst, struct Apprentice *src) } } -void sub_80E8260(struct UnkRecordMixingStruct2 *dst) +void GetPlayerHallRecords(struct PlayerHallRecords *dst) { s32 i, j; - for (i = 0; i < 9; i++) + for (i = 0; i < HALL_FACILITIES_COUNT; i++) { for (j = 0; j < 2; j++) { - CopyUnalignedWord(dst->field_0[i][j].playerId, gSaveBlock2Ptr->playerTrainerId); - dst->field_0[i][j].language = GAME_LANGUAGE; - StringCopy(dst->field_0[i][j].playerName, gSaveBlock2Ptr->playerName); + CopyUnalignedWord(dst->onePlayer[i][j].id, gSaveBlock2Ptr->playerTrainerId); + dst->onePlayer[i][j].language = GAME_LANGUAGE; + StringCopy(dst->onePlayer[i][j].name, gSaveBlock2Ptr->playerName); } } for (j = 0; j < 2; j++) { - dst->field_120[j].language = GAME_LANGUAGE; - CopyUnalignedWord(dst->field_120[j].playerId1, gSaveBlock2Ptr->playerTrainerId); - CopyUnalignedWord(dst->field_120[j].playerId2, gSaveBlock2Ptr->frontier.field_EF1[j]); - StringCopy(dst->field_120[j].playerName1, gSaveBlock2Ptr->playerName); - StringCopy(dst->field_120[j].playerName2, gSaveBlock2Ptr->frontier.field_EE1[j]); + dst->twoPlayers[j].language = GAME_LANGUAGE; + CopyUnalignedWord(dst->twoPlayers[j].id1, gSaveBlock2Ptr->playerTrainerId); + CopyUnalignedWord(dst->twoPlayers[j].id2, gSaveBlock2Ptr->frontier.field_EF1[j]); + StringCopy(dst->twoPlayers[j].name1, gSaveBlock2Ptr->playerName); + StringCopy(dst->twoPlayers[j].name2, gSaveBlock2Ptr->frontier.field_EE1[j]); } for (i = 0; i < 2; i++) { - dst->field_0[0][i].field_4 = gSaveBlock2Ptr->frontier.field_CF0[i]; - dst->field_0[1][i].field_4 = gSaveBlock2Ptr->frontier.field_CF4[i]; - dst->field_0[2][i].field_4 = gSaveBlock2Ptr->frontier.field_CF8[i]; - dst->field_0[3][i].field_4 = gSaveBlock2Ptr->frontier.field_D14[0][i]; - dst->field_0[4][i].field_4 = gSaveBlock2Ptr->frontier.field_DD0[0][i]; - dst->field_0[5][i].field_4 = gSaveBlock2Ptr->frontier.field_DDE[i]; - dst->field_0[6][i].field_4 = gSaveBlock2Ptr->frontier.field_DEA[i]; - dst->field_0[7][i].field_4 = gSaveBlock2Ptr->frontier.field_E08[i]; - dst->field_0[8][i].field_4 = gSaveBlock2Ptr->frontier.field_E1E[i]; + dst->onePlayer[0][i].winStreak = gSaveBlock2Ptr->frontier.towerRecordWinStreaks[FRONTIER_MODE_SINGLES][i]; + dst->onePlayer[1][i].winStreak = gSaveBlock2Ptr->frontier.towerRecordWinStreaks[FRONTIER_MODE_DOUBLES][i]; + dst->onePlayer[2][i].winStreak = gSaveBlock2Ptr->frontier.towerRecordWinStreaks[FRONTIER_MODE_MULTIS][i]; + dst->onePlayer[3][i].winStreak = gSaveBlock2Ptr->frontier.domeRecordWinStreaks[FRONTIER_MODE_SINGLES][i]; + dst->onePlayer[4][i].winStreak = gSaveBlock2Ptr->frontier.palaceRecordWinStreaks[FRONTIER_MODE_SINGLES][i]; + dst->onePlayer[5][i].winStreak = gSaveBlock2Ptr->frontier.arenaRecordStreaks[i]; + dst->onePlayer[6][i].winStreak = gSaveBlock2Ptr->frontier.factoryRecordWinStreaks[FRONTIER_MODE_SINGLES][i]; + dst->onePlayer[7][i].winStreak = gSaveBlock2Ptr->frontier.pikeRecordStreaks[i]; + dst->onePlayer[8][i].winStreak = gSaveBlock2Ptr->frontier.pyramidRecordStreaks[i]; - dst->field_120[i].field_8 = gSaveBlock2Ptr->frontier.field_CFC[i]; + dst->twoPlayers[i].winStreak = gSaveBlock2Ptr->frontier.towerRecordWinStreaks[FRONTIER_MODE_LINK_MULTIS][i]; } } @@ -1702,7 +1688,7 @@ static void ReceiveApprenticeData(struct Apprentice *arg0, size_t arg1, u32 arg2 } NAKED -static void sub_80E8578(struct UnknownRecMixingStruct3 *arg0, struct UnkRecordMixingStruct2 *arg1, size_t arg2, u32 arg3, u32 arg4) +static void sub_80E8578(struct RecordMixingHallRecords *arg0, struct PlayerHallRecords *arg1, size_t arg2, u32 arg3, u32 arg4) { asm_unified(" push {r4-r7,lr}\n\ mov r7, r10\n\ @@ -2106,133 +2092,75 @@ _080E8864:\n\ "); } -static void sub_80E8880(struct UnknownRecMixingStruct *arg0, struct UnknownRecMixingStruct *arg1) +static void sub_80E8880(struct RankingHall1P *arg0, struct RankingHall1P *arg1) { s32 i, j; for (i = 0; i < 3; i++) { - s32 r2 = 0; - s32 r4 = -1; + s32 highestWinStreak = 0; + s32 highestId = -1; for (j = 0; j < 6; j++) { - if (arg1[j].field_4 > r2) + if (arg1[j].winStreak > highestWinStreak) { - r4 = j; - r2 = arg1[j].field_4; + highestId = j; + highestWinStreak = arg1[j].winStreak; } } - if (r4 >= 0) + if (highestId >= 0) { - arg0[i] = arg1[r4]; - arg1[r4].field_4 = 0; + arg0[i] = arg1[highestId]; + arg1[highestId].winStreak = 0; } } } -static void sub_80E88CC(struct UnknownRecMixingStruct2 *arg0, struct UnknownRecMixingStruct2 *arg1) +static void sub_80E88CC(struct RankingHall2P *arg0, struct RankingHall2P *arg1) { s32 i, j; for (i = 0; i < 3; i++) { - s32 r2 = 0; - s32 r4 = -1; + s32 highestWinStreak = 0; + s32 highestId = -1; for (j = 0; j < 6; j++) { - if (arg1[j].field_8 > r2) + if (arg1[j].winStreak > highestWinStreak) { - r4 = j; - r2 = arg1[j].field_8; + highestId = j; + highestWinStreak = arg1[j].winStreak; } } - if (r4 >= 0) + if (highestId >= 0) { - arg0[i] = arg1[r4]; - arg1[r4].field_8 = 0; + arg0[i] = arg1[highestId]; + arg1[highestId].winStreak = 0; } } } -NAKED -static void sub_80E8924(struct UnknownRecMixingStruct3 *arg0) +static void sub_80E8924(struct RecordMixingHallRecords *arg0) { - asm_unified("push {r4-r7,lr}\n\ - mov r7, r10\n\ - mov r6, r9\n\ - mov r5, r8\n\ - push {r5-r7}\n\ - mov r9, r0\n\ - movs r0, 0\n\ - ldr r1, =gSaveBlock2Ptr\n\ - mov r10, r1\n\ -_080E8936:\n\ - lsls r1, r0, 1\n\ - adds r2, r0, 0x1\n\ - mov r8, r2\n\ - adds r1, r0\n\ - lsls r0, r1, 5\n\ - movs r2, 0x87\n\ - lsls r2, 2\n\ - adds r7, r0, r2\n\ - lsls r1, 6\n\ - mov r0, r9\n\ - adds r4, r0, r1\n\ - movs r6, 0\n\ - movs r5, 0x1\n\ -_080E8950:\n\ - mov r1, r10\n\ - ldr r0, [r1]\n\ - adds r0, r7\n\ - adds r0, r6\n\ - adds r1, r4, 0\n\ - bl sub_80E8880\n\ - adds r4, 0x60\n\ - adds r6, 0x30\n\ - subs r5, 0x1\n\ - cmp r5, 0\n\ - bge _080E8950\n\ - mov r0, r8\n\ - cmp r0, 0x8\n\ - ble _080E8936\n\ - movs r5, 0\n\ - ldr r4, =gSaveBlock2Ptr\n\ -_080E8972:\n\ - movs r0, 0x54\n\ - adds r1, r5, 0\n\ - muls r1, r0\n\ - ldr r2, =0x0000057c\n\ - adds r1, r2\n\ - ldr r0, [r4]\n\ - adds r0, r1\n\ - movs r1, 0xA8\n\ - muls r1, r5\n\ - movs r2, 0xD8\n\ - lsls r2, 3\n\ - adds r1, r2\n\ - add r1, r9\n\ - bl sub_80E88CC\n\ - adds r5, 0x1\n\ - cmp r5, 0x1\n\ - ble _080E8972\n\ - pop {r3-r5}\n\ - mov r8, r3\n\ - mov r9, r4\n\ - mov r10, r5\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .pool"); + s32 i, j; + + for (i = 0; i < HALL_FACILITIES_COUNT; i++) + { + for (j = 0; j < 2; j++) + sub_80E8880(gSaveBlock2Ptr->hallRecords1P[i][j], arg0->hallRecords1P[i][j]); + } + for (j = 0; j < 2; j++) + sub_80E88CC(gSaveBlock2Ptr->hallRecords2P[j], arg0->hallRecords2P[j]); } -static void sub_80E89AC(struct UnkRecordMixingStruct2 *arg0, size_t arg1, u32 arg2) +static void ReceiveRankingHallRecords(struct PlayerHallRecords *hallRecords, size_t arg1, u32 arg2) { u8 linkPlayerCount = GetLinkPlayerCount(); - struct UnknownRecMixingStruct3 *largeStructPtr = AllocZeroed(sizeof(struct UnknownRecMixingStruct3)); + struct RecordMixingHallRecords *largeStructPtr = AllocZeroed(sizeof(struct RecordMixingHallRecords)); - sub_80E8578(largeStructPtr, arg0, arg1, arg2, linkPlayerCount); + sub_80E8578(largeStructPtr, hallRecords, arg1, arg2, linkPlayerCount); sub_80E8924(largeStructPtr); Free(largeStructPtr); diff --git a/src/strings.c b/src/strings.c index 15c247744..9cb384e70 100644 --- a/src/strings.c +++ b/src/strings.c @@ -1569,9 +1569,7 @@ asm(".align 2"); const u8 gUnknown_085EE410[] = _("Floors cleared: {STR_VAR_2}"); asm(".align 2"); -const u8 gText_1Dot[] = _("1."); -const u8 gUnknown_085EE427[] = _("2."); -const u8 gUnknown_085EE42A[] = _("3."); +const u8 gText_123Dot[][3] = {_("1."), _("2."), _("3.")}; const u8 gText_SavingDontTurnOff2[] = _("SAVING…\nDON’T TURN OFF THE POWER."); const u8 gText_BlenderMaxSpeedRecord[] = _("BERRY BLENDER\nMAXIMUM SPEED RECORD!"); const u8 gText_234Players[] = _("2 PLAYERS\n3 PLAYERS\n4 PLAYERS");