From 8381d2583ad76bbdf6ca4a7f6a3f840c4570129f Mon Sep 17 00:00:00 2001 From: Eebit Date: Tue, 4 Jun 2024 23:35:22 -0400 Subject: [PATCH] (sio_points) Decompile Link Arena points display --- asm/code_sio_8048260.s | 1304 ---------------------------------------- include/sio.h | 28 +- include/sio_core.h | 7 +- ldscript.txt | 1 + src/sio_points.c | 558 +++++++++++++++++ src/sio_postbattle.c | 7 - 6 files changed, 584 insertions(+), 1321 deletions(-) create mode 100644 src/sio_points.c diff --git a/asm/code_sio_8048260.s b/asm/code_sio_8048260.s index 67d3c708..2e2d36aa 100644 --- a/asm/code_sio_8048260.s +++ b/asm/code_sio_8048260.s @@ -2,1310 +2,6 @@ .SYNTAX UNIFIED - THUMB_FUNC_START sub_8048864 -sub_8048864: @ 0x08048864 - push {lr} - sub sp, #4 - ldr r3, _08048880 @ gUnknown_085A9F98 - movs r0, #0 - str r0, [sp] - movs r0, #4 - movs r1, #0x38 - movs r2, #4 - bl PutSprite - add sp, #4 - pop {r0} - bx r0 - .align 2, 0 -_08048880: .4byte gUnknown_085A9F98 - - THUMB_FUNC_END sub_8048864 - - THUMB_FUNC_START sub_8048884 -sub_8048884: @ 0x08048884 - push {r4, r5, r6, r7, lr} - mov r7, r8 - push {r7} - mov r8, r0 - ldr r0, _080488C8 @ gLinkArenaSt - adds r1, r0, #0 - adds r1, #0xa0 - ldrb r3, [r1] - adds r0, #0xec - ldrb r1, [r0] - movs r0, #2 - ands r0, r1 - cmp r0, #0 - beq _080488D0 - movs r6, #0 - cmp r6, r3 - bge _0804892A - ldr r4, _080488CC @ gUnk_Sio_0203DD9F - adds r5, r4, #5 - mov r2, r8 -_080488AC: - adds r1, r6, r4 - ldrb r0, [r1] - strb r0, [r2] - ldrb r0, [r1] - lsls r0, r0, #2 - adds r0, r0, r5 - ldr r0, [r0] - str r0, [r2, #4] - adds r2, #8 - adds r6, #1 - cmp r6, r3 - blt _080488AC - b _0804892A - .align 2, 0 -_080488C8: .4byte gLinkArenaSt -_080488CC: .4byte gUnk_Sio_0203DD9F -_080488D0: - movs r6, #0 - subs r0, r3, #2 - mov ip, r0 - cmp r6, r3 - bge _080488F0 - ldr r0, _080488F4 @ gUnk_Sio_0203DD90 - adds r2, r0, #0 - adds r2, #0x14 - mov r1, r8 -_080488E2: - strb r6, [r1] - ldm r2!, {r0} - str r0, [r1, #4] - adds r1, #8 - adds r6, #1 - cmp r6, r3 - blt _080488E2 -_080488F0: - movs r6, #0 - b _08048924 - .align 2, 0 -_080488F4: .4byte gUnk_Sio_0203DD90 -_080488F8: - adds r5, r0, #0 - adds r7, r6, #1 - cmp r0, r6 - blt _08048922 - lsls r0, r0, #3 - mov r1, r8 - adds r2, r0, r1 -_08048906: - ldr r4, [r2, #4] - ldr r3, [r2, #0xc] - cmp r4, r3 - bcs _0804891A - ldrb r1, [r2] - ldrb r0, [r2, #8] - strb r0, [r2] - strb r1, [r2, #8] - str r3, [r2, #4] - str r4, [r2, #0xc] -_0804891A: - subs r2, #8 - subs r5, #1 - cmp r5, r6 - bge _08048906 -_08048922: - adds r6, r7, #0 -_08048924: - mov r0, ip - cmp r6, r0 - ble _080488F8 -_0804892A: - pop {r3} - mov r8, r3 - pop {r4, r5, r6, r7} - pop {r0} - bx r0 - - THUMB_FUNC_END sub_8048884 - - THUMB_FUNC_START sub_8048934 -sub_8048934: @ 0x08048934 - push {r4, r5, r6, lr} - adds r6, r0, #0 - adds r5, r1, #0 - lsls r0, r2, #5 - adds r0, r0, r5 - lsls r0, r0, #1 - ldr r1, _08048980 @ gBG1TilemapBuffer - adds r0, r0, r1 - movs r1, #0 - adds r4, r2, #1 -_08048948: - adds r2, r1, #1 - movs r1, #5 -_0804894C: - strh r3, [r0] - adds r0, #2 - adds r3, #1 - subs r1, #1 - cmp r1, #0 - bge _0804894C - adds r0, #0x34 - adds r1, r2, #0 - cmp r1, #3 - ble _08048948 - adds r0, r6, #0 - bl ClearText - lsls r0, r4, #5 - adds r0, #4 - adds r0, r0, r5 - lsls r0, r0, #1 - ldr r1, _08048984 @ gBG0TilemapBuffer - adds r0, r0, r1 - movs r1, #2 - ldr r2, [sp, #0x10] - bl PutNumber - pop {r4, r5, r6} - pop {r0} - bx r0 - .align 2, 0 -_08048980: .4byte gBG1TilemapBuffer -_08048984: .4byte gBG0TilemapBuffer - - THUMB_FUNC_END sub_8048934 - - THUMB_FUNC_START sub_8048988 -sub_8048988: @ 0x08048988 - push {r4, r5, r6, r7, lr} - mov r7, sl - mov r6, r9 - mov r5, r8 - push {r5, r6, r7} - sub sp, #4 - adds r4, r0, #0 - ldr r0, _08048A48 @ gUnknown_085AD80C - ldr r1, _08048A4C @ 0x06002800 - bl Decompress - ldr r0, _08048A50 @ Pal_TacticianSelObj - movs r1, #0x40 - movs r2, #0x80 - bl CopyToPaletteBuffer - movs r0, #0 - bl SetTextFont - bl ResetTextFont - movs r0, #0 - mov r9, r0 - ldr r0, _08048A54 @ gUnknown_080D9F28 - mov sl, r0 - adds r6, r4, #0 - adds r6, #0x2c - ldr r7, _08048A58 @ gUnknown_080D9F98 -_080489C0: - ldr r0, _08048A5C @ gSioSt - ldr r0, [r0] - ldrb r0, [r0, #6] - lsls r0, r0, #0x18 - asrs r0, r0, #0x18 - lsls r0, r0, #2 - add r0, r9 - add r0, sl - ldrb r5, [r0] - adds r0, r5, #0 - bl sub_8042194 - lsls r0, r0, #0x18 - cmp r0, #0 - beq _08048A24 - ldr r0, _08048A60 @ gUnk_Sio_0203DD90 - mov r8, r0 - adds r0, #0xa - adds r0, r5, r0 - ldrb r0, [r0] - adds r4, r5, #2 - cmp r0, #0 - bne _080489F8 - lsls r1, r4, #5 - ldr r0, _08048A64 @ gUnknown_085ADDA8 - movs r2, #0x20 - bl CopyToPaletteBuffer -_080489F8: - movs r0, #0xf - ands r4, r0 - lsls r4, r4, #0xc - movs r0, #0xa0 - lsls r0, r0, #1 - adds r4, r4, r0 - adds r0, r6, #0 - movs r1, #4 - bl InitTextDb - ldrb r1, [r7] - ldrb r2, [r7, #1] - lsls r0, r5, #2 - mov r3, r8 - adds r3, #0x14 - adds r0, r0, r3 - ldr r0, [r0] - str r0, [sp] - adds r0, r6, #0 - adds r3, r4, #0 - bl sub_8048934 -_08048A24: - adds r6, #8 - adds r7, #2 - movs r0, #1 - add r9, r0 - mov r0, r9 - cmp r0, #3 - ble _080489C0 - movs r0, #3 - bl BG_EnableSyncByMask - add sp, #4 - pop {r3, r4, r5} - mov r8, r3 - mov r9, r4 - mov sl, r5 - pop {r4, r5, r6, r7} - pop {r0} - bx r0 - .align 2, 0 -_08048A48: .4byte gUnknown_085AD80C -_08048A4C: .4byte 0x06002800 -_08048A50: .4byte Pal_TacticianSelObj -_08048A54: .4byte gUnknown_080D9F28 -_08048A58: .4byte gUnknown_080D9F98 -_08048A5C: .4byte gSioSt -_08048A60: .4byte gUnk_Sio_0203DD90 -_08048A64: .4byte gUnknown_085ADDA8 - - THUMB_FUNC_END sub_8048988 - - THUMB_FUNC_START nullsub_43 -nullsub_43: @ 0x08048A68 - bx lr - - THUMB_FUNC_END nullsub_43 - - THUMB_FUNC_START sub_8048A6C -sub_8048A6C: @ 0x08048A6C - push {lr} - movs r0, #0 - movs r1, #0 - movs r2, #0 - bl BG_SetPosition - movs r0, #1 - movs r1, #0 - movs r2, #0 - bl BG_SetPosition - ldr r0, _08048A90 @ gUnknown_085AA06C - movs r1, #3 - bl Proc_Start - pop {r0} - bx r0 - .align 2, 0 -_08048A90: .4byte gUnknown_085AA06C - - THUMB_FUNC_END sub_8048A6C - - THUMB_FUNC_START sub_8048A94 -sub_8048A94: @ 0x08048A94 - push {lr} - ldr r0, _08048AA4 @ gUnknown_085AA06C - bl Proc_EndEach - bl ClearBg0Bg1 - pop {r0} - bx r0 - .align 2, 0 -_08048AA4: .4byte gUnknown_085AA06C - - THUMB_FUNC_END sub_8048A94 - - THUMB_FUNC_START sub_8048AA8 -sub_8048AA8: @ 0x08048AA8 - push {r4, r5, lr} - adds r5, r0, #0 - adds r0, #0x33 - ldrb r0, [r0] - bl GetUnit - adds r4, r0, #0 - ldr r1, _08048AFC @ gUnknown_080D9F38 - adds r2, r5, #0 - adds r2, #0x32 - ldr r0, _08048B00 @ gSioSt - ldr r0, [r0] - ldrb r0, [r0, #6] - lsls r0, r0, #0x18 - asrs r0, r0, #0x18 - lsls r0, r0, #2 - ldrb r2, [r2] - adds r0, r0, r2 - adds r0, r0, r1 - ldrb r2, [r0] - adds r0, r5, #0 - adds r0, #0x40 - ldrb r0, [r0] - lsls r0, r0, #0x18 - asrs r0, r0, #0x18 - cmp r0, #0 - beq _08048B04 - movs r0, #0x10 - ldrsb r0, [r4, r0] - cmp r0, #8 - beq _08048AEA - movs r0, #0x10 - ldrsb r0, [r4, r0] -_08048AEA: - lsls r0, r0, #4 - subs r0, #0x10 - strh r0, [r5, #0x2a] - movs r0, #0x11 - ldrsb r0, [r4, r0] - lsls r0, r0, #4 - strh r0, [r5, #0x2c] - lsls r2, r2, #1 - b _08048B2C - .align 2, 0 -_08048AFC: .4byte gUnknown_080D9F38 -_08048B00: .4byte gSioSt -_08048B04: - movs r1, #0x10 - ldrsb r1, [r4, r1] - lsls r1, r1, #4 - ldr r3, _08048B68 @ gUnknown_085AA084 - lsls r0, r2, #3 - adds r0, r0, r3 - ldr r0, [r0] - adds r0, r0, r1 - subs r0, #0xc - strh r0, [r5, #0x2a] - movs r1, #0x11 - ldrsb r1, [r4, r1] - lsls r1, r1, #4 - lsls r2, r2, #1 - adds r0, r2, #1 - lsls r0, r0, #2 - adds r0, r0, r3 - ldr r0, [r0] - adds r0, r0, r1 - strh r0, [r5, #0x2c] -_08048B2C: - ldr r1, _08048B6C @ gUnknown_080D9F98 - adds r0, r2, r1 - ldrb r0, [r0] - lsls r0, r0, #3 - adds r0, #8 - movs r4, #0 - strh r0, [r5, #0x2e] - adds r0, r2, #1 - adds r0, r0, r1 - ldrb r0, [r0] - lsls r0, r0, #3 - adds r0, #8 - strh r0, [r5, #0x30] - ldr r0, _08048B70 @ Font_Sio_02000C60 - bl SetTextFont - ldr r0, _08048B74 @ gUnk_Sio_02000C78 - adds r1, r5, #0 - adds r1, #0x32 - ldrb r1, [r1] - lsls r1, r1, #5 - adds r1, #0x18 - ldr r3, [r5, #0x34] - movs r2, #2 - bl SioDrawNumber - str r4, [r5, #0x3c] - pop {r4, r5} - pop {r0} - bx r0 - .align 2, 0 -_08048B68: .4byte gUnknown_085AA084 -_08048B6C: .4byte gUnknown_080D9F98 -_08048B70: .4byte Font_Sio_02000C60 -_08048B74: .4byte gUnk_Sio_02000C78 - - THUMB_FUNC_END sub_8048AA8 - - THUMB_FUNC_START sub_8048B78 -sub_8048B78: @ 0x08048B78 - push {r4, r5, r6, r7, lr} - mov r7, sl - mov r6, r9 - mov r5, r8 - push {r5, r6, r7} - sub sp, #8 - adds r7, r0, #0 - adds r0, #0x33 - ldrb r0, [r0] - bl GetUnit - str r0, [sp, #4] - ldr r3, [r7, #0x3c] - cmp r3, #0x10 - bhi _08048C0C - movs r0, #0x80 - lsls r0, r0, #1 - mov r8, r0 - movs r0, #0x10 - str r0, [sp] - movs r0, #1 - movs r1, #0x10 - mov r2, r8 - bl Interpolate - mov sl, r0 - ldr r4, _08048C40 @ gSinLookup - movs r1, #0x80 - adds r1, r1, r4 - mov r9, r1 - movs r2, #0 - ldrsh r0, [r1, r2] - lsls r0, r0, #4 - mov r1, r8 - bl Div - adds r6, r0, #0 - lsls r6, r6, #0x10 - asrs r6, r6, #0x10 - movs r1, #0 - ldrsh r0, [r4, r1] - negs r0, r0 - lsls r0, r0, #4 - mov r1, sl - bl Div - adds r5, r0, #0 - lsls r5, r5, #0x10 - asrs r5, r5, #0x10 - movs r2, #0 - ldrsh r0, [r4, r2] - lsls r0, r0, #4 - mov r1, r8 - bl Div - adds r4, r0, #0 - lsls r4, r4, #0x10 - asrs r4, r4, #0x10 - mov r1, r9 - movs r2, #0 - ldrsh r0, [r1, r2] - lsls r0, r0, #4 - mov r1, sl - bl Div - lsls r0, r0, #0x10 - asrs r0, r0, #0x10 - str r0, [sp] - movs r0, #0 - adds r1, r6, #0 - adds r2, r5, #0 - adds r3, r4, #0 - bl SetObjAffine -_08048C0C: - adds r0, r7, #0 - adds r0, #0x40 - ldrb r0, [r0] - lsls r0, r0, #0x18 - asrs r0, r0, #0x18 - cmp r0, #0 - beq _08048C64 - ldr r1, [r7, #0x3c] - cmp r1, #3 - bls _08048C64 - cmp r1, #0x16 - bhi _08048C64 - subs r2, r1, #4 - ldr r4, [sp, #4] - movs r0, #0x10 - ldrsb r0, [r4, r0] - cmp r0, #8 - bne _08048C48 - ldr r0, _08048C44 @ gUnknown_085AA0A4 - lsls r1, r2, #1 - adds r0, r1, r0 - ldrh r0, [r0] - ldrh r2, [r7, #0x2a] - adds r0, r0, r2 - strh r0, [r7, #0x2a] - b _08048C58 - .align 2, 0 -_08048C40: .4byte gSinLookup -_08048C44: .4byte gUnknown_085AA0A4 -_08048C48: - ldr r1, _08048CA8 @ gUnknown_085AA0A4 - lsls r2, r2, #1 - adds r1, r2, r1 - ldrh r0, [r7, #0x2a] - ldrh r1, [r1] - subs r0, r0, r1 - strh r0, [r7, #0x2a] - adds r1, r2, #0 -_08048C58: - ldr r0, _08048CAC @ gUnknown_085AA0CA - adds r0, r1, r0 - ldrh r1, [r7, #0x2c] - ldrh r0, [r0] - subs r1, r1, r0 - strh r1, [r7, #0x2c] -_08048C64: - movs r4, #0x2a - ldrsh r0, [r7, r4] - movs r2, #0x2c - ldrsh r1, [r7, r2] - movs r4, #0x80 - lsls r4, r4, #1 - adds r1, r1, r4 - ldr r2, _08048CB0 @ gObject_32x16 - adds r3, r7, #0 - adds r3, #0x32 - ldrb r3, [r3] - lsls r3, r3, #2 - ldr r4, _08048CB4 @ 0x00009340 - adds r3, r3, r4 - bl CallARM_PushToSecondaryOAM - ldr r0, [r7, #0x3c] - adds r0, #1 - str r0, [r7, #0x3c] - cmp r0, #0x40 - bls _08048C98 - movs r0, #0 - str r0, [r7, #0x3c] - adds r0, r7, #0 - bl Proc_Break -_08048C98: - add sp, #8 - pop {r3, r4, r5} - mov r8, r3 - mov r9, r4 - mov sl, r5 - pop {r4, r5, r6, r7} - pop {r0} - bx r0 - .align 2, 0 -_08048CA8: .4byte gUnknown_085AA0A4 -_08048CAC: .4byte gUnknown_085AA0CA -_08048CB0: .4byte gObject_32x16 -_08048CB4: .4byte 0x00009340 - - THUMB_FUNC_END sub_8048B78 - - THUMB_FUNC_START sub_8048CB8 -sub_8048CB8: @ 0x08048CB8 - push {r4, r5, r6, lr} - sub sp, #4 - adds r6, r0, #0 - movs r0, #0x2a - ldrsh r1, [r6, r0] - movs r0, #0x2e - ldrsh r2, [r6, r0] - ldr r3, [r6, #0x3c] - movs r4, #0x30 - str r4, [sp] - movs r0, #5 - bl Interpolate - adds r5, r0, #0 - movs r0, #0x2c - ldrsh r1, [r6, r0] - movs r0, #0x30 - ldrsh r2, [r6, r0] - ldr r3, [r6, #0x3c] - str r4, [sp] - movs r0, #5 - bl Interpolate - adds r1, r0, #0 - ldr r2, _08048D14 @ gObject_32x16 - adds r0, r6, #0 - adds r0, #0x32 - ldrb r3, [r0] - lsls r3, r3, #2 - ldr r0, _08048D18 @ 0x00009340 - adds r3, r3, r0 - adds r0, r5, #0 - bl CallARM_PushToSecondaryOAM - ldr r0, [r6, #0x3c] - adds r0, #1 - str r0, [r6, #0x3c] - cmp r0, #0x20 - bls _08048D0C - adds r0, r6, #0 - bl Proc_Break -_08048D0C: - add sp, #4 - pop {r4, r5, r6} - pop {r0} - bx r0 - .align 2, 0 -_08048D14: .4byte gObject_32x16 -_08048D18: .4byte 0x00009340 - - THUMB_FUNC_END sub_8048CB8 - - THUMB_FUNC_START sub_8048D1C -sub_8048D1C: @ 0x08048D1C - push {r4, r5, r6, lr} - mov r6, r8 - push {r6} - adds r5, r0, #0 - mov r8, r1 - adds r4, r2, #0 - adds r6, r3, #0 - bl ClearText - adds r0, r5, #0 - movs r1, #0x18 - movs r2, #2 - adds r3, r6, #0 - bl SioDrawNumber - adds r4, #1 - lsls r4, r4, #5 - adds r4, #1 - add r4, r8 - lsls r4, r4, #1 - ldr r0, _08048D60 @ gBG0TilemapBuffer - adds r4, r4, r0 - adds r0, r5, #0 - adds r1, r4, #0 - bl PutText - movs r0, #1 - bl BG_EnableSyncByMask - pop {r3} - mov r8, r3 - pop {r4, r5, r6} - pop {r0} - bx r0 - .align 2, 0 -_08048D60: .4byte gBG0TilemapBuffer - - THUMB_FUNC_END sub_8048D1C - - THUMB_FUNC_START sub_8048D64 -sub_8048D64: @ 0x08048D64 - push {r4, r5, r6, lr} - adds r6, r0, #0 - ldr r1, _08048DC4 @ gUnknown_080D9F38 - adds r2, r6, #0 - adds r2, #0x32 - ldr r0, _08048DC8 @ gSioSt - ldr r0, [r0] - ldrb r0, [r0, #6] - lsls r0, r0, #0x18 - asrs r0, r0, #0x18 - lsls r0, r0, #2 - ldrb r2, [r2] - adds r0, r0, r2 - adds r0, r0, r1 - ldrb r0, [r0] - ldr r2, _08048DCC @ gUnknown_080D9F98 - lsls r0, r0, #1 - adds r1, r0, r2 - ldrb r1, [r1] - movs r5, #0 - strh r1, [r6, #0x2a] - adds r0, #1 - adds r0, r0, r2 - ldrb r0, [r0] - strh r0, [r6, #0x2c] - movs r0, #0 - bl SetTextFont - adds r0, r6, #0 - adds r0, #0x48 - movs r2, #0x2a - ldrsh r1, [r6, r2] - movs r3, #0x2c - ldrsh r2, [r6, r3] - ldr r3, [r6, #0x38] - ldr r4, [r6, #0x34] - subs r3, r3, r4 - bl sub_8048D1C - str r5, [r6, #0x3c] - ldr r0, [r6, #0x38] - ldr r1, [r6, #0x34] - subs r0, r0, r1 - str r0, [r6, #0x44] - pop {r4, r5, r6} - pop {r0} - bx r0 - .align 2, 0 -_08048DC4: .4byte gUnknown_080D9F38 -_08048DC8: .4byte gSioSt -_08048DCC: .4byte gUnknown_080D9F98 - - THUMB_FUNC_END sub_8048D64 - - THUMB_FUNC_START sub_8048DD0 -sub_8048DD0: @ 0x08048DD0 - push {r4, r5, lr} - sub sp, #4 - adds r4, r0, #0 - ldr r2, [r4, #0x38] - ldr r1, [r4, #0x34] - subs r1, r2, r1 - ldr r3, [r4, #0x3c] - movs r0, #0xa - str r0, [sp] - movs r0, #0 - bl Interpolate - adds r5, r0, #0 - movs r0, #0 - bl SetTextFont - adds r0, r4, #0 - adds r0, #0x48 - movs r2, #0x2a - ldrsh r1, [r4, r2] - movs r3, #0x2c - ldrsh r2, [r4, r3] - adds r3, r5, #0 - bl sub_8048D1C - ldr r0, [r4, #0x44] - cmp r0, r5 - beq _08048E2E - adds r0, r4, #0 - adds r0, #0x32 - ldrb r1, [r0] - ldr r0, _08048E60 @ gSioSt - ldr r0, [r0] - ldrb r0, [r0, #6] - lsls r0, r0, #0x18 - asrs r0, r0, #0x18 - cmp r1, r0 - bne _08048E2E - ldr r0, _08048E64 @ gPlaySt - adds r0, #0x41 - ldrb r0, [r0] - lsls r0, r0, #0x1e - cmp r0, #0 - blt _08048E2E - movs r0, #0x80 - bl m4aSongNumStart -_08048E2E: - str r5, [r4, #0x44] - ldr r0, [r4, #0x3c] - adds r0, #1 - str r0, [r4, #0x3c] - cmp r0, #0xa - bls _08048E56 - movs r0, #0 - str r0, [r4, #0x3c] - ldr r1, _08048E68 @ gUnk_Sio_0203DD90 - adds r0, r4, #0 - adds r0, #0x32 - ldrb r0, [r0] - lsls r0, r0, #2 - adds r1, #0x14 - adds r0, r0, r1 - ldr r1, [r4, #0x38] - str r1, [r0] - adds r0, r4, #0 - bl Proc_Break -_08048E56: - add sp, #4 - pop {r4, r5} - pop {r0} - bx r0 - .align 2, 0 -_08048E60: .4byte gSioSt -_08048E64: .4byte gPlaySt -_08048E68: .4byte gUnk_Sio_0203DD90 - - THUMB_FUNC_END sub_8048DD0 - - THUMB_FUNC_START sub_8048E6C -sub_8048E6C: @ 0x08048E6C - push {lr} - adds r1, r0, #0 - ldr r0, [r1, #0x3c] - adds r0, #1 - str r0, [r1, #0x3c] - cmp r0, #0x14 - bls _08048E80 - adds r0, r1, #0 - bl Proc_Break -_08048E80: - pop {r0} - bx r0 - - THUMB_FUNC_END sub_8048E6C - - THUMB_FUNC_START sub_8048E84 -sub_8048E84: @ 0x08048E84 - push {r4, lr} - adds r4, r0, #0 - ldr r0, _08048EB0 @ Font_Sio_02000C60 - bl SetTextFont - ldr r1, [r4, #0x54] - movs r0, #0x50 - bl GetStringTextCenteredPos - adds r1, r0, #0 - ldr r0, _08048EB4 @ gUnk_Sio_02000C78 - adds r1, #0x80 - ldr r3, [r4, #0x54] - movs r2, #0 - bl Text_InsertDrawString - adds r4, #0x4c - movs r0, #0 - strh r0, [r4] - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_08048EB0: .4byte Font_Sio_02000C60 -_08048EB4: .4byte gUnk_Sio_02000C78 - - THUMB_FUNC_END sub_8048E84 - - THUMB_FUNC_START sub_8048EB8 -sub_8048EB8: @ 0x08048EB8 - push {r4, r5, r6, r7, lr} - mov r7, sl - mov r6, r9 - mov r5, r8 - push {r5, r6, r7} - sub sp, #4 - adds r7, r0, #0 - movs r0, #0x4c - adds r0, r0, r7 - mov r9, r0 - movs r1, #0 - ldrsh r0, [r0, r1] - cmp r0, #0x10 - bgt _08048F4A - movs r2, #0x80 - lsls r2, r2, #1 - mov r8, r2 - mov r0, r9 - movs r1, #0 - ldrsh r3, [r0, r1] - movs r0, #0x10 - str r0, [sp] - movs r0, #1 - movs r1, #0x10 - bl Interpolate - mov sl, r0 - ldr r4, _08048FB8 @ gSinLookup - ldr r2, _08048FBC @ gSinLookup+0x80 - movs r1, #0 - ldrsh r0, [r2, r1] - lsls r0, r0, #4 - mov r1, r8 - bl Div - adds r6, r0, #0 - lsls r6, r6, #0x10 - asrs r6, r6, #0x10 - movs r2, #0 - ldrsh r0, [r4, r2] - negs r0, r0 - lsls r0, r0, #4 - mov r1, sl - bl Div - adds r5, r0, #0 - lsls r5, r5, #0x10 - asrs r5, r5, #0x10 - movs r1, #0 - ldrsh r0, [r4, r1] - lsls r0, r0, #4 - mov r1, r8 - bl Div - adds r4, r0, #0 - lsls r4, r4, #0x10 - asrs r4, r4, #0x10 - ldr r2, _08048FBC @ gSinLookup+0x80 - movs r1, #0 - ldrsh r0, [r2, r1] - lsls r0, r0, #4 - mov r1, sl - bl Div - lsls r0, r0, #0x10 - asrs r0, r0, #0x10 - str r0, [sp] - movs r0, #1 - adds r1, r6, #0 - adds r2, r5, #0 - adds r3, r4, #0 - bl SetObjAffine -_08048F4A: - ldr r0, [r7, #0x2c] - movs r2, #0x80 - lsls r2, r2, #2 - adds r0, r0, r2 - ldr r1, [r7, #0x30] - movs r4, #0x80 - lsls r4, r4, #1 - adds r1, r1, r4 - ldr r5, _08048FC0 @ gObject_32x16 - ldr r3, _08048FC4 @ 0x00009350 - adds r2, r5, #0 - bl CallARM_PushToSecondaryOAM - ldr r0, [r7, #0x2c] - movs r1, #0x88 - lsls r1, r1, #2 - adds r0, r0, r1 - ldr r1, [r7, #0x30] - adds r1, r1, r4 - ldr r3, _08048FC8 @ 0x00009354 - adds r2, r5, #0 - bl CallARM_PushToSecondaryOAM - ldr r0, [r7, #0x2c] - movs r2, #0x90 - lsls r2, r2, #2 - adds r0, r0, r2 - ldr r1, [r7, #0x30] - adds r1, r1, r4 - ldr r2, _08048FCC @ gObject_16x16 - ldr r3, _08048FD0 @ 0x00009358 - bl CallARM_PushToSecondaryOAM - mov r1, r9 - ldrh r0, [r1] - adds r0, #1 - strh r0, [r1] - lsls r0, r0, #0x10 - asrs r0, r0, #0x10 - cmp r0, #0x40 - ble _08048FA6 - movs r0, #0 - strh r0, [r1] - adds r0, r7, #0 - bl Proc_Break -_08048FA6: - add sp, #4 - pop {r3, r4, r5} - mov r8, r3 - mov r9, r4 - mov sl, r5 - pop {r4, r5, r6, r7} - pop {r0} - bx r0 - .align 2, 0 -_08048FB8: .4byte gSinLookup -_08048FBC: .4byte gSinLookup+0x80 -_08048FC0: .4byte gObject_32x16 -_08048FC4: .4byte 0x00009350 -_08048FC8: .4byte 0x00009354 -_08048FCC: .4byte gObject_16x16 -_08048FD0: .4byte 0x00009358 - - THUMB_FUNC_END sub_8048EB8 - - THUMB_FUNC_START sub_8048FD4 -sub_8048FD4: @ 0x08048FD4 - push {r4, r5, r6, r7, lr} - mov r7, sl - mov r6, r9 - mov r5, r8 - push {r5, r6, r7} - sub sp, #8 - adds r7, r0, #0 - adds r0, #0x4c - str r0, [sp, #4] - movs r1, #0 - ldrsh r0, [r0, r1] - cmp r0, #0x10 - bgt _0804906A - movs r2, #0x80 - lsls r2, r2, #1 - mov r8, r2 - ldr r0, [sp, #4] - movs r1, #0 - ldrsh r3, [r0, r1] - movs r0, #0x10 - str r0, [sp] - movs r0, #4 - mov r1, r8 - movs r2, #0x10 - bl Interpolate - mov sl, r0 - ldr r4, _080490D4 @ gSinLookup - movs r2, #0x80 - adds r2, r2, r4 - mov r9, r2 - movs r1, #0 - ldrsh r0, [r2, r1] - lsls r0, r0, #4 - mov r1, r8 - bl Div - adds r6, r0, #0 - lsls r6, r6, #0x10 - asrs r6, r6, #0x10 - movs r2, #0 - ldrsh r0, [r4, r2] - negs r0, r0 - lsls r0, r0, #4 - mov r1, sl - bl Div - adds r5, r0, #0 - lsls r5, r5, #0x10 - asrs r5, r5, #0x10 - movs r1, #0 - ldrsh r0, [r4, r1] - lsls r0, r0, #4 - mov r1, r8 - bl Div - adds r4, r0, #0 - lsls r4, r4, #0x10 - asrs r4, r4, #0x10 - mov r2, r9 - movs r1, #0 - ldrsh r0, [r2, r1] - lsls r0, r0, #4 - mov r1, sl - bl Div - lsls r0, r0, #0x10 - asrs r0, r0, #0x10 - str r0, [sp] - movs r0, #1 - adds r1, r6, #0 - adds r2, r5, #0 - adds r3, r4, #0 - bl SetObjAffine -_0804906A: - ldr r0, [r7, #0x2c] - movs r2, #0x80 - lsls r2, r2, #2 - adds r0, r0, r2 - ldr r1, [r7, #0x30] - movs r4, #0x80 - lsls r4, r4, #1 - adds r1, r1, r4 - ldr r5, _080490D8 @ gObject_32x16 - ldr r3, _080490DC @ 0x00009350 - adds r2, r5, #0 - bl CallARM_PushToSecondaryOAM - ldr r0, [r7, #0x2c] - movs r1, #0x88 - lsls r1, r1, #2 - adds r0, r0, r1 - ldr r1, [r7, #0x30] - adds r1, r1, r4 - ldr r3, _080490E0 @ 0x00009354 - adds r2, r5, #0 - bl CallARM_PushToSecondaryOAM - ldr r0, [r7, #0x2c] - movs r2, #0x90 - lsls r2, r2, #2 - adds r0, r0, r2 - ldr r1, [r7, #0x30] - adds r1, r1, r4 - ldr r2, _080490E4 @ gObject_16x16 - ldr r3, _080490E8 @ 0x00009358 - bl CallARM_PushToSecondaryOAM - ldr r1, [sp, #4] - ldrh r0, [r1] - adds r0, #1 - strh r0, [r1] - lsls r0, r0, #0x10 - asrs r0, r0, #0x10 - cmp r0, #0x10 - ble _080490C2 - adds r0, r7, #0 - bl Proc_Break -_080490C2: - add sp, #8 - pop {r3, r4, r5} - mov r8, r3 - mov r9, r4 - mov sl, r5 - pop {r4, r5, r6, r7} - pop {r0} - bx r0 - .align 2, 0 -_080490D4: .4byte gSinLookup -_080490D8: .4byte gObject_32x16 -_080490DC: .4byte 0x00009350 -_080490E0: .4byte 0x00009354 -_080490E4: .4byte gObject_16x16 -_080490E8: .4byte 0x00009358 - - THUMB_FUNC_END sub_8048FD4 - - THUMB_FUNC_START sub_80490EC -sub_80490EC: @ 0x080490EC - push {r4, r5, r6, r7, lr} - mov r7, sl - mov r6, r9 - mov r5, r8 - push {r5, r6, r7} - sub sp, #0x14 - str r0, [sp, #8] - str r1, [sp, #0xc] - str r2, [sp, #0x10] - lsls r3, r3, #0x18 - lsrs r3, r3, #0x18 - mov r9, r3 - movs r0, #0 - mov sl, r0 - ldr r0, _080491C4 @ Pal_Text - movs r1, #0xc8 - lsls r1, r1, #2 - movs r2, #0x20 - bl CopyToPaletteBuffer - ldr r0, _080491C8 @ Font_Sio_02000C60 - ldr r1, _080491CC @ 0x06016800 - movs r2, #3 - bl InitSpriteTextFont - movs r0, #0 - bl SetTextFontGlyphs - bl ResetTextFont - ldr r4, _080491D0 @ gUnk_Sio_02000C78 - adds r0, r4, #0 - bl InitSpriteText - adds r0, r4, #0 - movs r1, #0 - bl SpriteText_DrawBackgroundExt - movs r0, #0 - bl SetTextFont - movs r1, #0 - mov r8, r1 -_08049142: - ldr r0, _080491D4 @ gSioSt - ldr r0, [r0] - ldrb r0, [r0, #6] - lsls r0, r0, #0x18 - asrs r0, r0, #0x18 - lsls r0, r0, #2 - add r0, r8 - ldr r1, _080491D8 @ gUnknown_080D9F38 - adds r0, r0, r1 - ldrb r4, [r0] - adds r0, r4, #0 - bl sub_8042194 - lsls r0, r0, #0x18 - cmp r0, #0 - beq _080491F0 - ldr r6, _080491DC @ gUnk_Sio_0203DD90 - lsls r5, r4, #3 - adds r0, r6, #0 - adds r0, #0x30 - adds r7, r5, r0 - ldr r0, [r7] - cmp r0, #0 - beq _080491E8 - ldr r0, _080491E0 @ gUnknown_085AA0F0 - ldr r1, [sp, #0x34] - bl Proc_StartBlocking - adds r2, r0, #0 - adds r0, #0x32 - strb r4, [r0] - adds r0, r5, r6 - adds r0, #0x2c - ldrb r0, [r0] - adds r1, r2, #0 - adds r1, #0x33 - strb r0, [r1] - lsls r1, r4, #2 - adds r0, r6, #0 - adds r0, #0x14 - adds r3, r1, r0 - ldr r1, [r3] - ldr r0, [r7] - adds r1, r1, r0 - str r1, [r2, #0x38] - ldr r0, _080491E4 @ 0x0000270F - cmp r1, r0 - bls _080491A4 - str r0, [r2, #0x38] -_080491A4: - ldr r0, [r2, #0x38] - ldr r1, [r3] - subs r0, r0, r1 - str r0, [r2, #0x34] - adds r0, r2, #0 - adds r0, #0x40 - mov r1, r9 - strb r1, [r0] - adds r0, #8 - movs r1, #4 - bl InitTextDb - movs r0, #1 - add sl, r0 - b _080491F0 - .align 2, 0 -_080491C4: .4byte Pal_Text -_080491C8: .4byte Font_Sio_02000C60 -_080491CC: .4byte 0x06016800 -_080491D0: .4byte gUnk_Sio_02000C78 -_080491D4: .4byte gSioSt -_080491D8: .4byte gUnknown_080D9F38 -_080491DC: .4byte gUnk_Sio_0203DD90 -_080491E0: .4byte gUnknown_085AA0F0 -_080491E4: .4byte 0x0000270F -_080491E8: - mov r0, sp - movs r1, #4 - bl InitTextDb -_080491F0: - movs r1, #1 - add r8, r1 - mov r0, r8 - cmp r0, #3 - ble _08049142 - mov r1, sl - cmp r1, #0 - beq _08049224 - mov r0, r9 - cmp r0, #0 - beq _0804921A - ldr r0, _08049220 @ gUnknown_085AA130 - ldr r1, [sp, #0x34] - bl Proc_StartBlocking - ldr r1, [sp, #8] - str r1, [r0, #0x2c] - ldr r1, [sp, #0xc] - str r1, [r0, #0x30] - ldr r1, [sp, #0x10] - str r1, [r0, #0x54] -_0804921A: - movs r0, #1 - b _08049226 - .align 2, 0 -_08049220: .4byte gUnknown_085AA130 -_08049224: - movs r0, #0 -_08049226: - add sp, #0x14 - pop {r3, r4, r5} - mov r8, r3 - mov r9, r4 - mov sl, r5 - pop {r4, r5, r6, r7} - pop {r1} - bx r1 - - THUMB_FUNC_END sub_80490EC - - THUMB_FUNC_START sub_8049238 -sub_8049238: @ 0x08049238 - push {r4, lr} - sub sp, #4 - adds r4, r0, #0 - bl sub_8048A6C - ldr r0, _08049268 @ 0x00000771 - bl GetStringFromIndex - adds r2, r0, #0 - str r4, [sp] - movs r0, #0x58 - movs r1, #0x3c - movs r3, #1 - bl sub_80490EC - lsls r0, r0, #0x18 - cmp r0, #0 - bne _08049260 - bl sub_8048A94 -_08049260: - add sp, #4 - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_08049268: .4byte 0x00000771 - - THUMB_FUNC_END sub_8049238 - - THUMB_FUNC_START sub_804926C -sub_804926C: @ 0x0804926C - push {r4, lr} - sub sp, #4 - adds r4, r0, #0 - bl sub_8048A6C - ldr r0, _08049294 @ 0x00000771 - bl GetStringFromIndex - adds r2, r0, #0 - str r4, [sp] - movs r0, #0x58 - movs r1, #0x3c - movs r3, #0 - bl sub_80490EC - add sp, #4 - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_08049294: .4byte 0x00000771 - - THUMB_FUNC_END sub_804926C - THUMB_FUNC_START sub_8049298 sub_8049298: @ 0x08049298 push {lr} diff --git a/include/sio.h b/include/sio.h index a999f862..75e9e11d 100644 --- a/include/sio.h +++ b/include/sio.h @@ -54,6 +54,12 @@ struct SioSaveConf { } __attribute__((packed)); extern struct SioSaveConf gSioSaveConfig; +struct SioUnknown_0203DD90_Unk2C +{ + /* 00 */ u8 unk_00; + /* 04 */ int unk_04; +}; + struct SioUnknown_0203DD90 { // 00 -- ?? @@ -64,15 +70,24 @@ struct SioUnknown_0203DD90 // 05 -- current selected combat target unit id // 06 -- weapon index maybe? // 07-09 -- ?? - // 0A-0D = byte array - num units alive per team - // 14-24? - scores - word array - STRUCT_PAD(0x00, 0x24); - u16 unk_24[4]; // leader face IDs - // more? + STRUCT_PAD(0x00, 0x0A); + /* 0A */ u8 unk_0A[4]; // num units alive per team? + /* 0E */ u8 unk_0E; // ? + /* 0F */ u8 unk_0F[4]; // player ids? + /* 14 */ int unk_14[4]; // scores + /* 24 */ u16 unk_24[4]; // leader face IDs + /* 2C */ struct SioUnknown_0203DD90_Unk2C unk_2c[4]; }; struct SioUnknown_0203DD90 gUnk_Sio_0203DD90; +struct SioProc85A971C_Unk44 +{ + /* 00 */ u8 playerId; + /* 01 */ STRUCT_PAD(0x01, 0x04); + /* 04 */ u32 points; +}; + u32 SioStrCpy(u8 const * src, u8 * dst); void SioDrawNumber(struct Text * text, int x, int color, int number); void SioInit(void); @@ -283,7 +298,7 @@ void sub_8048260(ProcPtr); // StartNameSelect // ??? EraseSaveData(???); void CallEraseSaveEvent(void); // ??? sub_8048864(???); -void sub_8048884(void *); // TODO: Fix param type +void sub_8048884(struct SioProc85A971C_Unk44 *); // ??? sub_8048934(???); // ??? sub_8048988(???); // ??? nullsub_43(???); @@ -532,7 +547,6 @@ extern int gUnk_Sio_0203DD8C; // extern ??? gUnk_Sio_0203DD94 // extern ??? gUnk_Sio_0203DD95 // extern ??? gUnk_Sio_0203DD9A -// extern ??? gUnk_Sio_0203DD9F // extern ??? gUnk_Sio_0203DDB4 // extern ??? gUnk_Sio_0203DDDC diff --git a/include/sio_core.h b/include/sio_core.h index af3c88df..a0ac1bf6 100644 --- a/include/sio_core.h +++ b/include/sio_core.h @@ -200,13 +200,14 @@ struct LinkArenaStMaybe /* 03 */ u8 unk_03; /* 04 */ u8 unk_04; /* 05 */ u8 unk_05; - u8 unk_06[4]; + /* 06 */ u8 unk_06[4]; /* 0A */ u8 unk_0A; /* 0B */ u8 unk_0B; /* 0C */ struct Text texts[11]; /* 64 */ struct Text unk_64[7]; // maybe not all text? - u8 unk_9C[5]; - u8 unk_A1[4][15]; + /* 9C */ u8 unk_9C[4]; + /* A0 */ u8 unk_A0; + /* A1 */ u8 unk_A1[4][15]; STRUCT_PAD(0xDD, 0xEC); struct LinkArenaStMaybe_ec { diff --git a/ldscript.txt b/ldscript.txt index 2f53162f..3d60f1a3 100644 --- a/ldscript.txt +++ b/ldscript.txt @@ -393,6 +393,7 @@ SECTIONS src/sio_rulesettings.o(.text); src/sio_menu.o(.text); src/sio_event.o(.text); + src/sio_points.o(.text); asm/code_sio_8048260.o(.text); src/uiutils.o(.text); src/uimenu.o(.text); diff --git a/src/sio_points.c b/src/sio_points.c new file mode 100644 index 00000000..d8bcd2a2 --- /dev/null +++ b/src/sio_points.c @@ -0,0 +1,558 @@ +#include "global.h" + +#include "ctc.h" +#include "hardware.h" +#include "fontgrp.h" +#include "bmlib.h" +#include "uiutils.h" +#include "bmunit.h" +#include "m4a.h" +#include "soundwrapper.h" + +#include "sio_core.h" +#include "sio.h" + +struct SioProc085AA06C +{ + /* 00 */ PROC_HEADER; + /* 2C */ struct Text unk_2c[4]; +}; + +struct SioProc85AA0F0 +{ + /* 00 */ PROC_HEADER; + /* 2A */ s16 unk_2a; + /* 2C */ s16 unk_2c; + /* 2E */ s16 unk_2e; + /* 30 */ s16 unk_30; + /* 32 */ u8 unk_32; + /* 33 */ u8 unk_33; + /* 34 */ int unk_34; + /* 38 */ u32 unk_38; + /* 3C */ u32 unk_3c; + /* 40 */ s8 unk_40; + /* 41 */ STRUCT_PAD(0x41, 0x44); + /* 44 */ int unk_44; + /* 48 */ struct Text unk_48; +}; + +struct SioProc85AA130 +{ + /* 00 */ PROC_HEADER; + /* 2C */ int unk_2c; + /* 30 */ int unk_30; + /* 34 */ STRUCT_PAD(0x34, 0x4C); + /* 4C */ s16 unk_4c; + /* 4E */ STRUCT_PAD(0x4E, 0x54); + /* 54 */ const char * unk_54; +}; + +extern u8 gUnknown_085AD80C[]; +extern u16 gUnknown_085ADDA8[]; + +extern int gUnknown_085AA084[]; +extern s16 gUnknown_085AA0A4[]; +extern s16 gUnknown_085AA0CA[]; + +extern u8 gUnknown_080D9F28[][4]; +extern u8 gUnknown_080D9F38[][4]; + +extern u8 gUnknown_080D9F98[]; + +extern struct Text gUnk_Sio_02000C78[]; + +extern u16 gUnknown_085A9F98[]; + +//! FE8U = 0x08048864 +void sub_8048864(void) +{ + PutSprite(4, 0x38, 4, gUnknown_085A9F98, 0); + return; +} + +//! FE8U = 0x08048884 +void sub_8048884(struct SioProc85A971C_Unk44 * buf) +{ + int i; + int j; + + int r3 = gLinkArenaSt.unk_A0; + + if (gLinkArenaSt.unk_ec.unk_0_1 != 0) // TODO: Survival mode? + { + for (i = 0; i < r3; i++) + { + buf[i].playerId = gUnk_Sio_0203DD90.unk_0F[i]; + buf[i].points = gUnk_Sio_0203DD90.unk_14[gUnk_Sio_0203DD90.unk_0F[i]]; + } + } + else + { + for (i = 0; i < r3; i++) + { + buf[i].playerId = i; + buf[i].points = gUnk_Sio_0203DD90.unk_14[i]; + } + + for (i = 0; i <= r3 - 2; i++) + { + for (j = r3 - 2; j >= i; j--) + { + if (buf[j].points < buf[j + 1].points) + { + int tmpPlayerId; + int tmpPoints; + + tmpPlayerId = buf[j].playerId; + buf[j].playerId = buf[j + 1].playerId; + buf[j + 1].playerId = tmpPlayerId; + + tmpPoints = buf[j].points; + buf[j].points = buf[j + 1].points; + buf[j + 1].points = tmpPoints; + } + } + } + } + + return; +} + +//! FE8U = 0x08048934 +void sub_8048934(struct Text * th, int x, int y, int var, int number) +{ + int ix; + int iy; + + u16 * tm = gBG1TilemapBuffer + TILEMAP_INDEX(x, y); + + for (iy = 0; iy < 4; iy++) + { + for (ix = 0; ix < 6; ix++) + { + *tm = var; + + tm++; + var++; + } + + tm += 0x1A; + } + + ClearText(th); + PutNumber(TILEMAP_LOCATED(gBG0TilemapBuffer, x + 4, y + 1), 2, number); + + return; +} + +//! FE8U = 0x08048988 +void sub_8048988(struct SioProc085AA06C * proc) +{ + int i; + int oam2; + + Decompress(gUnknown_085AD80C, (void *)(0x06002800)); + CopyToPaletteBuffer(Pal_TacticianSelObj, 0x40, 0x80); + + SetTextFont(NULL); + ResetTextFont(); + + for (i = 0; i < 4; i++) + { + int playerId = gUnknown_080D9F28[gSioSt->selfId][i]; + + if (sub_8042194(playerId) != 0) + { + if (gUnk_Sio_0203DD90.unk_0A[playerId] == 0) + { + CopyToPaletteBuffer(gUnknown_085ADDA8, (playerId + 2) * 0x20, 0x20); + } + + oam2 = 0x140 + (((playerId + 2) & 0xf) << 12); + + InitTextDb(&proc->unk_2c[i], 4); + sub_8048934( + &proc->unk_2c[i], gUnknown_080D9F98[i * 2 + 0], gUnknown_080D9F98[i * 2 + 1], oam2, + gUnk_Sio_0203DD90.unk_14[playerId]); + } + } + + BG_EnableSyncByMask(3); + + return; +} + +//! FE8U = 0x08048A68 +void nullsub_43(void) +{ + return; +} + +extern struct ProcCmd gUnknown_085AA06C[]; + +//! FE8U = 0x08048A6C +void sub_8048A6C(void) +{ + BG_SetPosition(0, 0, 0); + BG_SetPosition(1, 0, 0); + + Proc_Start(gUnknown_085AA06C, PROC_TREE_3); + + return; +} + +//! FE8U = 0x08048A94 +void sub_8048A94(void) +{ + Proc_EndEach(gUnknown_085AA06C); + ClearBg0Bg1(); + + return; +} + +//! FE8U = 0x08048AA8 +void sub_8048AA8(struct SioProc85AA0F0 * proc) +{ + struct Unit * unit = GetUnit(proc->unk_33); + + int idx = gUnknown_080D9F38[gSioSt->selfId][proc->unk_32]; + + if (proc->unk_40 != 0) + { + if (unit->xPos == 8) + { + proc->unk_2a = unit->xPos * 16 - 16; + } + else + { + proc->unk_2a = unit->xPos * 16 - 16; + } + + proc->unk_2c = unit->yPos * 16; + } + else + { + proc->unk_2a = unit->xPos * 0x10 + gUnknown_085AA084[idx * 2 + 0] - 12; + proc->unk_2c = unit->yPos * 0x10 + gUnknown_085AA084[idx * 2 + 1]; + } + + proc->unk_2e = gUnknown_080D9F98[idx * 2 + 0] * 8 + 8; + proc->unk_30 = gUnknown_080D9F98[idx * 2 + 1] * 8 + 8; + + SetTextFont(&Font_Sio_02000C60); + SioDrawNumber(&gUnk_Sio_02000C78[0], proc->unk_32 * 0x20 + 0x18, 2, proc->unk_34); + + proc->unk_3c = 0; + + return; +} + +//! FE8U = 0x08048B78 +void sub_8048B78(struct SioProc85AA0F0 * proc) +{ + struct Unit * unit = GetUnit(proc->unk_33); + + if (proc->unk_3c <= 0x10) + { + int scale = Interpolate(1, 0x10, 0x100, proc->unk_3c, 0x10); + + // clang-format off + SetObjAffine( + 0, + Div(+COS(0) * 16, 0x100), + Div(-SIN(0) * 16, scale), + Div(+SIN(0) * 16, 0x100), + Div(+COS(0) * 16, scale) + ); + // clang-format on + } + + if (proc->unk_40 != 0 && proc->unk_3c > 3 && proc->unk_3c < 0x17) + { + int idx = proc->unk_3c - 4; + + if (unit->xPos == 8) + { + proc->unk_2a = proc->unk_2a + gUnknown_085AA0A4[idx]; + } + else + { + proc->unk_2a = proc->unk_2a - gUnknown_085AA0A4[idx]; + } + + proc->unk_2c = proc->unk_2c - gUnknown_085AA0CA[idx]; + } + + CallARM_PushToSecondaryOAM(proc->unk_2a, proc->unk_2c + 0x100, gObject_32x16, 0x00009340 + proc->unk_32 * 4); + + proc->unk_3c++; + + if (proc->unk_3c > 0x40) + { + proc->unk_3c = 0; + Proc_Break(proc); + } + + return; +} + +//! FE8U = 0x08048CB8 +void sub_8048CB8(struct SioProc85AA0F0 * proc) +{ + int x = Interpolate(5, proc->unk_2a, proc->unk_2e, proc->unk_3c, 0x30); + int y = Interpolate(5, proc->unk_2c, proc->unk_30, proc->unk_3c, 0x30); + + CallARM_PushToSecondaryOAM(x, y, gObject_32x16, 0x00009340 + proc->unk_32 * 4); + + proc->unk_3c++; + + if (proc->unk_3c > 0x20) + { + Proc_Break(proc); + } + + return; +} + +//! FE8U = 0x08048D1C +void sub_8048D1C(struct Text * th, int x, int y, int number) +{ + ClearText(th); + SioDrawNumber(th, 0x18, 2, number); + PutText(th, TILEMAP_LOCATED(gBG0TilemapBuffer, x + 1, y + 1)); + BG_EnableSyncByMask(1); + return; +} + +//! FE8U = 0x08048D64 +void sub_8048D64(struct SioProc85AA0F0 * proc) +{ + int idx = gUnknown_080D9F38[gSioSt->selfId][proc->unk_32]; + + proc->unk_2a = gUnknown_080D9F98[idx * 2 + 0]; + proc->unk_2c = gUnknown_080D9F98[idx * 2 + 1]; + + SetTextFont(NULL); + + sub_8048D1C(&proc->unk_48, proc->unk_2a, proc->unk_2c, proc->unk_38 - proc->unk_34); + + proc->unk_3c = 0; + proc->unk_44 = proc->unk_38 - proc->unk_34; + + return; +} + +//! FE8U = 0x08048DD0 +void sub_8048DD0(struct SioProc85AA0F0 * proc) +{ + int number = Interpolate(0, proc->unk_38 - proc->unk_34, proc->unk_38, proc->unk_3c, 10); + + SetTextFont(NULL); + + sub_8048D1C(&proc->unk_48, proc->unk_2a, proc->unk_2c, number); + + if ((proc->unk_44 != number) && (proc->unk_32 == gSioSt->selfId)) + { + PlaySoundEffect(0x80); + } + + proc->unk_44 = number; + + proc->unk_3c++; + + if (proc->unk_3c > 10) + { + proc->unk_3c = 0; + gUnk_Sio_0203DD90.unk_14[proc->unk_32] = proc->unk_38; + Proc_Break(proc); + } + + return; +} + +//! FE8U = 0x08048E6C +void sub_8048E6C(struct SioProc85AA0F0 * proc) +{ + proc->unk_3c++; + + if (proc->unk_3c > 20) + { + Proc_Break(proc); + } + + return; +} + +//! FE8U = 0x08048E84 +void sub_8048E84(struct SioProc85AA130 * proc) +{ + int pos; + SetTextFont(&Font_Sio_02000C60); + + pos = GetStringTextCenteredPos(0x50, proc->unk_54); + Text_InsertDrawString(gUnk_Sio_02000C78, pos + 0x80, 0, proc->unk_54); + proc->unk_4c = 0; + + return; +} + +//! FE8U = 0x08048EB8 +void sub_8048EB8(struct SioProc85AA130 * proc) +{ + int scale; + + if (proc->unk_4c <= 0x10) + { + scale = Interpolate(1, 0x10, 0x100, proc->unk_4c, 0x10); + + // clang-format off + SetObjAffine( + 1, + Div(+COS(0) * 16, 0x100), + Div(-SIN(0) * 16, scale), + Div(+SIN(0) * 16, 0x100), + Div(+COS(0) * 16, scale) + ); + // clang-format on + } + + CallARM_PushToSecondaryOAM(proc->unk_2c + 0x200, proc->unk_30 + 0x100, gObject_32x16, 0x00009350); + CallARM_PushToSecondaryOAM(proc->unk_2c + 0x220, proc->unk_30 + 0x100, gObject_32x16, 0x00009354); + CallARM_PushToSecondaryOAM(proc->unk_2c + 0x240, proc->unk_30 + 0x100, gObject_16x16, 0x00009358); + + proc->unk_4c++; + + if (proc->unk_4c > 0x40) + { + proc->unk_4c = 0; + Proc_Break(proc); + } + + return; +} + +//! FE8U = 0x08048FD4 +void sub_8048FD4(struct SioProc85AA130 * proc) +{ + int scale; + + if (proc->unk_4c <= 0x10) + { + scale = Interpolate(4, 0x100, 0x10, proc->unk_4c, 0x10); + + // clang-format off + SetObjAffine( + 1, + Div(+COS(0) * 16, 0x100), + Div(-SIN(0) * 16, scale), + Div(+SIN(0) * 16, 0x100), + Div(+COS(0) * 16, scale) + ); + // clang-format on + } + + CallARM_PushToSecondaryOAM(proc->unk_2c + 0x200, proc->unk_30 + 0x100, gObject_32x16, 0x00009350); + CallARM_PushToSecondaryOAM(proc->unk_2c + 0x220, proc->unk_30 + 0x100, gObject_32x16, 0x00009354); + CallARM_PushToSecondaryOAM(proc->unk_2c + 0x240, proc->unk_30 + 0x100, gObject_16x16, 0x00009358); + + proc->unk_4c++; + + if (proc->unk_4c > 0x10) + { + Proc_Break(proc); + } + + return; +} + +extern struct ProcCmd gUnknown_085AA0F0[]; +extern struct ProcCmd gUnknown_085AA130[]; + +//! FE8U = 0x080490EC +s8 sub_80490EC(int x, int y, const char * str, u8 flag, ProcPtr parent) +{ + int i; + struct Text text; + + int count = 0; + + CopyToPaletteBuffer(Pal_Text, 0x320, 0x20); + + InitSpriteTextFont(&Font_Sio_02000C60, (void *)(0x06016800), 3); + + SetTextFontGlyphs(0); + ResetTextFont(); + + InitSpriteText(gUnk_Sio_02000C78); + SpriteText_DrawBackgroundExt(gUnk_Sio_02000C78, 0); + + SetTextFont(0); + + for (i = 0; i < 4; i++) + { + int playerId = gUnknown_080D9F38[gSioSt->selfId][i]; + + if (sub_8042194(playerId) != 0) + { + if (gUnk_Sio_0203DD90.unk_2c[playerId].unk_04 != 0) + { + struct SioProc85AA0F0 * proc = Proc_StartBlocking(gUnknown_085AA0F0, parent); + proc->unk_32 = playerId; + proc->unk_33 = gUnk_Sio_0203DD90.unk_2c[playerId].unk_00; + proc->unk_38 = gUnk_Sio_0203DD90.unk_14[playerId] + gUnk_Sio_0203DD90.unk_2c[playerId].unk_04; + + if (proc->unk_38 > 9999) + { + proc->unk_38 = 9999; + } + + proc->unk_34 = proc->unk_38 - gUnk_Sio_0203DD90.unk_14[playerId]; + proc->unk_40 = flag; + + InitTextDb(&proc->unk_48, 4); + + count++; + } + else + { + InitTextDb(&text, 4); + } + } + } + + if (count != 0) + { + if (flag != 0) + { + struct SioProc85AA130 * proc = Proc_StartBlocking(gUnknown_085AA130, parent); + proc->unk_2c = x; + proc->unk_30 = y; + proc->unk_54 = str; + } + + return 1; + } + + return 0; +} + +//! FE8U = 0x08049238 +void sub_8049238(ProcPtr proc) +{ + sub_8048A6C(); + + if (!sub_80490EC(0x58, 0x3c, GetStringFromIndex(0x00000771), 1, proc)) + { + sub_8048A94(); + } + + return; +} + +//! FE8U = 0x0804926C +void sub_804926C(ProcPtr param_1) +{ + sub_8048A6C(); + sub_80490EC(0x58, 0x3c, GetStringFromIndex(0x00000771), 0, param_1); + return; +} diff --git a/src/sio_postbattle.c b/src/sio_postbattle.c index c8b64fad..1f500817 100644 --- a/src/sio_postbattle.c +++ b/src/sio_postbattle.c @@ -18,13 +18,6 @@ * "Battle Data" UI. */ -struct SioProc85A971C_Unk44 -{ - /* 00 */ u8 playerId; - /* 01 */ STRUCT_PAD(0x01, 0x04); - /* 04 */ int points; -}; - struct SioPostBattleProc { /* 00 */ PROC_HEADER;