(bmudisp) Decompile up to SomethingSMS_32x32

This commit is contained in:
Eebit 2023-01-04 19:42:10 -05:00
parent 6af4e8ae00
commit 8914c3bf95
6 changed files with 285 additions and 806 deletions

View File

@ -4,804 +4,6 @@
@ Display standing map sprites and various tile/unit markers
THUMB_FUNC_START sub_8026618
sub_8026618: @ 0x08026618
ldr r1, _08026624 @ gUnknown_0203A4CC
ldr r0, [r1]
adds r0, #1
str r0, [r1]
bx lr
.align 2, 0
_08026624: .4byte gUnknown_0203A4CC
THUMB_FUNC_END sub_8026618
THUMB_FUNC_START SetupMapSpritesPalettes
SetupMapSpritesPalettes: @ 0x08026628
push {lr}
ldr r0, _08026650 @ unit_icon_pal_player
movs r1, #0xe0
lsls r1, r1, #2
movs r2, #0x80
bl CopyToPaletteBuffer
ldr r0, _08026654 @ gGameState
ldrb r1, [r0, #4]
movs r0, #0x40
ands r0, r1
cmp r0, #0
beq _0802665C
ldr r0, _08026658 @ unit_icon_pal_p4
movs r1, #0xd8
lsls r1, r1, #2
movs r2, #0x20
bl CopyToPaletteBuffer
b _08026668
.align 2, 0
_08026650: .4byte unit_icon_pal_player
_08026654: .4byte gGameState
_08026658: .4byte unit_icon_pal_p4
_0802665C:
ldr r0, _0802666C @ gUnknown_0859EEC0
movs r1, #0xd8
lsls r1, r1, #2
movs r2, #0x20
bl CopyToPaletteBuffer
_08026668:
pop {r0}
bx r0
.align 2, 0
_0802666C: .4byte gUnknown_0859EEC0
THUMB_FUNC_END SetupMapSpritesPalettes
THUMB_FUNC_START sub_8026670
sub_8026670: @ 0x08026670
push {lr}
ldr r0, _08026684 @ gUnknown_0859EEE0
movs r1, #0xf0
lsls r1, r1, #2
movs r2, #0x20
bl CopyToPaletteBuffer
pop {r0}
bx r0
.align 2, 0
_08026684: .4byte gUnknown_0859EEE0
THUMB_FUNC_END sub_8026670
THUMB_FUNC_START SMS_ClearUsageTable
SMS_ClearUsageTable: @ 0x08026688
push {r4, r5, r6, lr}
movs r2, #0xcf
ldr r5, _080266B0 @ gUnknown_0203A014
ldr r6, _080266B4 @ gUnknown_0203A010
ldr r4, _080266B8 @ gUnknown_02033F40
movs r3, #0xff
_08026694:
adds r1, r2, r4
ldrb r0, [r1]
orrs r0, r3
strb r0, [r1]
subs r2, #1
cmp r2, #0
bge _08026694
movs r0, #0
str r0, [r5]
movs r0, #0x3f
str r0, [r6]
pop {r4, r5, r6}
pop {r0}
bx r0
.align 2, 0
_080266B0: .4byte gUnknown_0203A014
_080266B4: .4byte gUnknown_0203A010
_080266B8: .4byte gUnknown_02033F40
THUMB_FUNC_END SMS_ClearUsageTable
THUMB_FUNC_START sub_80266BC
sub_80266BC: @ 0x080266BC
push {r4, r5, r6, lr}
movs r2, #0xcf
ldr r5, _080266E4 @ gUnknown_0203A014
ldr r6, _080266E8 @ gUnknown_0203A010
ldr r4, _080266EC @ gUnknown_02033F40
movs r3, #0xff
_080266C8:
adds r1, r2, r4
ldrb r0, [r1]
orrs r0, r3
strb r0, [r1]
subs r2, #1
cmp r2, #0
bge _080266C8
movs r0, #0
str r0, [r5]
movs r0, #0x5f
str r0, [r6]
pop {r4, r5, r6}
pop {r0}
bx r0
.align 2, 0
_080266E4: .4byte gUnknown_0203A014
_080266E8: .4byte gUnknown_0203A010
_080266EC: .4byte gUnknown_02033F40
THUMB_FUNC_END sub_80266BC
THUMB_FUNC_START SMS_80266F0
SMS_80266F0: @ 0x080266F0
push {r4, r5, r6, r7, lr}
mov r7, r8
push {r7}
adds r7, r0, #0
mov r8, r1
ldr r1, _0802672C @ gUnknown_0859B66C
mov r2, r8
lsls r0, r2, #2
adds r0, r0, r1
ldr r6, [r0]
ldr r5, _08026730 @ unit_icon_wait_table
movs r4, #0x7f
ands r4, r7
lsls r4, r4, #3
adds r0, r5, #4
adds r0, r4, r0
ldr r0, [r0]
ldr r1, _08026734 @ gUnknown_0859B668
ldr r1, [r1]
bl CopyDataWithPossibleUncomp
adds r4, r4, r5
ldrh r0, [r4, #2]
cmp r0, #1
beq _08026748
cmp r0, #1
bgt _08026738
cmp r0, #0
beq _0802673E
b _08026766
.align 2, 0
_0802672C: .4byte gUnknown_0859B66C
_08026730: .4byte unit_icon_wait_table
_08026734: .4byte gUnknown_0859B668
_08026738:
cmp r0, #2
beq _08026752
b _08026766
_0802673E:
adds r0, r6, #0
adds r1, r7, #0
bl SomethingSMS_16x16
b _0802675A
_08026748:
adds r0, r6, #0
adds r1, r7, #0
bl SomethingSMS_16x32
b _0802675A
_08026752:
adds r0, r6, #0
adds r1, r7, #0
bl SomethingSMS_32x32
_0802675A:
ldr r2, _08026778 @ gUnknown_02033F40
add r2, r8
lsrs r1, r0, #0x1f
adds r0, r0, r1
asrs r0, r0, #1
strb r0, [r2]
_08026766:
ldr r0, _08026778 @ gUnknown_02033F40
add r0, r8
ldrb r0, [r0]
lsls r0, r0, #1
pop {r3}
mov r8, r3
pop {r4, r5, r6, r7}
pop {r1}
bx r1
.align 2, 0
_08026778: .4byte gUnknown_02033F40
THUMB_FUNC_END SMS_80266F0
THUMB_FUNC_START SMS_SomethingGmapUnit
SMS_SomethingGmapUnit: @ 0x0802677C
push {r4, r5, r6, r7, lr}
mov r7, r8
push {r7}
adds r6, r0, #0
mov r8, r1
adds r7, r2, #0
ldr r5, _080267B0 @ unit_icon_wait_table
movs r4, #0x7f
ands r4, r6
lsls r4, r4, #3
adds r0, r5, #4
adds r0, r4, r0
ldr r0, [r0]
ldr r1, _080267B4 @ gUnknown_0859B668
ldr r1, [r1]
bl CopyDataWithPossibleUncomp
adds r4, r4, r5
ldrh r0, [r4, #2]
cmp r0, #1
beq _080267C8
cmp r0, #1
bgt _080267B8
cmp r0, #0
beq _080267BE
b _080267E6
.align 2, 0
_080267B0: .4byte unit_icon_wait_table
_080267B4: .4byte gUnknown_0859B668
_080267B8:
cmp r0, #2
beq _080267D2
b _080267E6
_080267BE:
adds r0, r7, #0
adds r1, r6, #0
bl SomethingSMS_16x16
b _080267DA
_080267C8:
adds r0, r7, #0
adds r1, r6, #0
bl SomethingSMS_16x32
b _080267DA
_080267D2:
adds r0, r7, #0
adds r1, r6, #0
bl SomethingSMS_32x32
_080267DA:
ldr r2, _080267F8 @ gUnknown_02033F40
add r2, r8
lsrs r1, r0, #0x1f
adds r0, r0, r1
asrs r0, r0, #1
strb r0, [r2]
_080267E6:
ldr r0, _080267F8 @ gUnknown_02033F40
add r0, r8
ldrb r0, [r0]
lsls r0, r0, #1
pop {r3}
mov r8, r3
pop {r4, r5, r6, r7}
pop {r1}
bx r1
.align 2, 0
_080267F8: .4byte gUnknown_02033F40
THUMB_FUNC_END SMS_SomethingGmapUnit
THUMB_FUNC_START SMS_RegisterUsage
SMS_RegisterUsage: @ 0x080267FC
push {r4, r5, r6, r7, lr}
adds r6, r0, #0
ldr r0, _08026834 @ gUnknown_02033F40
adds r7, r6, r0
ldrb r1, [r7]
cmp r1, #0xff
bne _080268B0
ldr r5, _08026838 @ unit_icon_wait_table
movs r4, #0x7f
ands r4, r6
lsls r4, r4, #3
adds r0, r5, #4
adds r0, r4, r0
ldr r0, [r0]
ldr r1, _0802683C @ gUnknown_0859B668
ldr r1, [r1]
bl CopyDataWithPossibleUncomp
adds r4, r4, r5
ldrh r0, [r4, #2]
cmp r0, #1
beq _08026864
cmp r0, #1
bgt _08026840
cmp r0, #0
beq _08026846
b _080268A6
.align 2, 0
_08026834: .4byte gUnknown_02033F40
_08026838: .4byte unit_icon_wait_table
_0802683C: .4byte gUnknown_0859B668
_08026840:
cmp r0, #2
beq _08026880
b _080268A6
_08026846:
ldr r4, _08026860 @ gUnknown_0203A010
ldr r0, [r4]
adds r1, r6, #0
bl SomethingSMS_16x16_0
lsrs r1, r0, #0x1f
adds r0, r0, r1
asrs r0, r0, #1
strb r0, [r7]
ldr r0, [r4]
subs r0, #1
b _080268A4
.align 2, 0
_08026860: .4byte gUnknown_0203A010
_08026864:
ldr r4, _0802687C @ gUnknown_0203A014
ldr r0, [r4]
adds r1, r6, #0
bl SomethingSMS_16x32
lsrs r1, r0, #0x1f
adds r0, r0, r1
asrs r0, r0, #1
strb r0, [r7]
ldr r0, [r4]
adds r0, #2
b _080268A4
.align 2, 0
_0802687C: .4byte gUnknown_0203A014
_08026880:
ldr r4, _080268BC @ gUnknown_0203A014
ldr r1, [r4]
movs r0, #0x1e
ands r0, r1
cmp r0, #0x1e
bne _08026890
adds r0, r1, #2
str r0, [r4]
_08026890:
ldr r0, [r4]
adds r1, r6, #0
bl SomethingSMS_32x32
lsrs r1, r0, #0x1f
adds r0, r0, r1
asrs r0, r0, #1
strb r0, [r7]
ldr r0, [r4]
adds r0, #4
_080268A4:
str r0, [r4]
_080268A6:
ldr r1, _080268C0 @ gUnknown_0203A4CC
ldr r0, [r1]
adds r0, #1
str r0, [r1]
ldr r0, _080268C4 @ gUnknown_02033F40
_080268B0:
adds r0, r6, r0
ldrb r0, [r0]
lsls r0, r0, #1
pop {r4, r5, r6, r7}
pop {r1}
bx r1
.align 2, 0
_080268BC: .4byte gUnknown_0203A014
_080268C0: .4byte gUnknown_0203A4CC
_080268C4: .4byte gUnknown_02033F40
THUMB_FUNC_END SMS_RegisterUsage
THUMB_FUNC_START SomethingSMS_16x16_0
SomethingSMS_16x16_0: @ 0x080268C8
push {r4, r5, r6, r7, lr}
mov r7, sl
mov r6, r9
mov r5, r8
push {r5, r6, r7}
sub sp, #4
str r0, [sp]
adds r2, r1, #0
ldr r1, _08026950 @ gUnknown_0859B67C
lsls r0, r0, #1
adds r0, r0, r1
ldrh r0, [r0]
lsls r0, r0, #5
mov r9, r0
lsrs r0, r2, #7
movs r1, #1
bics r1, r0
movs r6, #0
ldr r0, _08026954 @ gUnknown_0859B668
mov sl, r0
movs r0, #0x80
lsls r0, r0, #3
add r0, r9
ldr r2, _08026958 @ gUnknown_02034010
adds r4, r0, r2
movs r3, #0x40
mov r8, r3
movs r7, #0
lsls r5, r1, #7
_08026902:
mov r1, sl
ldr r0, [r1]
adds r0, r0, r7
lsls r1, r6, #0xd
ldr r2, _08026958 @ gUnknown_02034010
add r2, r9
adds r1, r1, r2
movs r2, #0x10
bl CpuFastSet
mov r2, sl
ldr r0, [r2]
add r0, r8
adds r1, r4, #0
movs r2, #0x10
bl CpuFastSet
movs r3, #0x80
lsls r3, r3, #6
adds r4, r4, r3
add r8, r5
adds r7, r7, r5
adds r6, #1
cmp r6, #2
ble _08026902
ldr r0, _08026950 @ gUnknown_0859B67C
ldr r2, [sp]
lsls r1, r2, #1
adds r1, r1, r0
ldrh r0, [r1]
add sp, #4
pop {r3, r4, r5}
mov r8, r3
mov r9, r4
mov sl, r5
pop {r4, r5, r6, r7}
pop {r1}
bx r1
.align 2, 0
_08026950: .4byte gUnknown_0859B67C
_08026954: .4byte gUnknown_0859B668
_08026958: .4byte gUnknown_02034010
THUMB_FUNC_END SomethingSMS_16x16_0
THUMB_FUNC_START SomethingSMS_16x16
SomethingSMS_16x16: @ 0x0802695C
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]
mov r9, r1
ldr r1, _08026A28 @ gUnknown_0859B67C
lsls r0, r0, #1
adds r0, r0, r1
ldrh r0, [r0]
lsls r5, r0, #5
mov r1, r9
lsrs r0, r1, #7
movs r2, #1
mov r9, r2
mov r1, r9
bics r1, r0
mov r9, r1
movs r7, #0
mov r2, sp
adds r2, #4
str r2, [sp, #0xc]
ldr r0, _08026A2C @ gUnknown_02034010
mov r8, r0
movs r1, #0xc0
lsls r1, r1, #4
adds r0, r5, r1
mov r2, r8
adds r6, r0, r2
movs r0, #0x40
str r0, [sp, #0x10]
movs r1, #0
mov sl, r1
_080269A2:
movs r2, #0
str r2, [sp]
lsls r4, r7, #0xd
mov r0, r8
adds r1, r5, r0
adds r1, r4, r1
mov r0, sp
ldr r2, _08026A30 @ 0x01000010
bl CpuFastSet
movs r1, #0
str r1, [sp, #4]
movs r1, #0x80
lsls r1, r1, #3
add r1, r8
adds r1, r4, r1
adds r1, r1, r5
ldr r0, [sp, #0xc]
ldr r2, _08026A30 @ 0x01000010
bl CpuFastSet
ldr r2, _08026A34 @ gUnknown_0859B668
ldr r0, [r2]
add r0, sl
movs r1, #0x80
lsls r1, r1, #4
add r1, r8
adds r4, r4, r1
adds r4, r4, r5
adds r1, r4, #0
movs r2, #0x10
bl CpuFastSet
ldr r1, _08026A34 @ gUnknown_0859B668
ldr r0, [r1]
ldr r2, [sp, #0x10]
adds r0, r0, r2
adds r1, r6, #0
movs r2, #0x10
bl CpuFastSet
movs r0, #0x80
lsls r0, r0, #6
adds r6, r6, r0
mov r1, r9
lsls r0, r1, #7
ldr r2, [sp, #0x10]
adds r2, r2, r0
str r2, [sp, #0x10]
add sl, r0
adds r7, #1
cmp r7, #2
ble _080269A2
ldr r0, _08026A28 @ gUnknown_0859B67C
ldr r2, [sp, #8]
lsls r1, r2, #1
adds r1, r1, r0
ldrh r0, [r1]
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
.align 2, 0
_08026A28: .4byte gUnknown_0859B67C
_08026A2C: .4byte gUnknown_02034010
_08026A30: .4byte 0x01000010
_08026A34: .4byte gUnknown_0859B668
THUMB_FUNC_END SomethingSMS_16x16
THUMB_FUNC_START SomethingSMS_16x32
SomethingSMS_16x32: @ 0x08026A38
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]
adds r2, r1, #0
ldr r1, _08026B1C @ gUnknown_0859B67C
lsls r0, r0, #1
adds r0, r0, r1
ldrh r0, [r0]
lsls r6, r0, #5
lsrs r0, r2, #7
movs r1, #1
bics r1, r0
movs r0, #0
mov r9, r0
ldr r2, _08026B20 @ gUnknown_0859B668
mov r8, r2
ldr r3, _08026B24 @ gUnknown_02034010
mov sl, r3
movs r2, #0xc0
lsls r2, r2, #4
adds r0, r6, r2
adds r7, r0, r3
movs r3, #0xc0
str r3, [sp, #4]
movs r0, #0x80
str r0, [sp, #8]
movs r2, #0x40
str r2, [sp, #0xc]
movs r3, #0
str r3, [sp, #0x10]
lsls r5, r1, #8
_08026A7E:
mov r1, r8
ldr r0, [r1]
ldr r2, [sp, #0x10]
adds r0, r0, r2
mov r3, r9
lsls r4, r3, #0xd
mov r2, sl
adds r1, r6, r2
adds r1, r4, r1
movs r2, #0x10
bl CpuFastSet
mov r3, r8
ldr r0, [r3]
ldr r1, [sp, #0xc]
adds r0, r0, r1
movs r1, #0x80
lsls r1, r1, #3
add r1, sl
adds r1, r4, r1
adds r1, r1, r6
movs r2, #0x10
bl CpuFastSet
mov r2, r8
ldr r0, [r2]
ldr r3, [sp, #8]
adds r0, r0, r3
movs r1, #0x80
lsls r1, r1, #4
add r1, sl
adds r4, r4, r1
adds r4, r4, r6
adds r1, r4, #0
movs r2, #0x10
bl CpuFastSet
mov r1, r8
ldr r0, [r1]
ldr r2, [sp, #4]
adds r0, r0, r2
adds r1, r7, #0
movs r2, #0x10
bl CpuFastSet
movs r3, #0x80
lsls r3, r3, #6
adds r7, r7, r3
ldr r0, [sp, #4]
adds r0, r0, r5
str r0, [sp, #4]
ldr r1, [sp, #8]
adds r1, r1, r5
str r1, [sp, #8]
ldr r2, [sp, #0xc]
adds r2, r2, r5
str r2, [sp, #0xc]
ldr r3, [sp, #0x10]
adds r3, r3, r5
str r3, [sp, #0x10]
movs r0, #1
add r9, r0
mov r1, r9
cmp r1, #2
ble _08026A7E
ldr r0, _08026B1C @ gUnknown_0859B67C
ldr r2, [sp]
lsls r1, r2, #1
adds r1, r1, r0
ldrh r0, [r1]
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
.align 2, 0
_08026B1C: .4byte gUnknown_0859B67C
_08026B20: .4byte gUnknown_0859B668
_08026B24: .4byte gUnknown_02034010
THUMB_FUNC_END SomethingSMS_16x32
THUMB_FUNC_START SomethingSMS_32x32
SomethingSMS_32x32: @ 0x08026B28
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]
adds r2, r1, #0
ldr r1, _08026C10 @ gUnknown_0859B67C
lsls r0, r0, #1
adds r0, r0, r1
ldrh r0, [r0]
lsls r6, r0, #5
lsrs r0, r2, #7
movs r1, #1
bics r1, r0
movs r0, #0
mov r9, r0
ldr r2, _08026C14 @ gUnknown_0859B668
mov r8, r2
ldr r3, _08026C18 @ gUnknown_02034010
mov sl, r3
movs r2, #0xc0
lsls r2, r2, #4
adds r0, r6, r2
adds r7, r0, r3
movs r3, #0xc0
lsls r3, r3, #1
str r3, [sp, #4]
movs r0, #0x80
lsls r0, r0, #1
str r0, [sp, #8]
movs r2, #0x80
str r2, [sp, #0xc]
movs r3, #0
str r3, [sp, #0x10]
lsls r5, r1, #9
_08026B72:
mov r1, r8
ldr r0, [r1]
ldr r2, [sp, #0x10]
adds r0, r0, r2
mov r3, r9
lsls r4, r3, #0xd
mov r2, sl
adds r1, r6, r2
adds r1, r4, r1
movs r2, #0x20
bl CpuFastSet
mov r3, r8
ldr r0, [r3]
ldr r1, [sp, #0xc]
adds r0, r0, r1
movs r1, #0x80
lsls r1, r1, #3
add r1, sl
adds r1, r4, r1
adds r1, r1, r6
movs r2, #0x20
bl CpuFastSet
mov r2, r8
ldr r0, [r2]
ldr r3, [sp, #8]
adds r0, r0, r3
movs r1, #0x80
lsls r1, r1, #4
add r1, sl
adds r4, r4, r1
adds r4, r4, r6
adds r1, r4, #0
movs r2, #0x20
bl CpuFastSet
mov r1, r8
ldr r0, [r1]
ldr r2, [sp, #4]
adds r0, r0, r2
adds r1, r7, #0
movs r2, #0x20
bl CpuFastSet
movs r3, #0x80
lsls r3, r3, #6
adds r7, r7, r3
ldr r0, [sp, #4]
adds r0, r0, r5
str r0, [sp, #4]
ldr r1, [sp, #8]
adds r1, r1, r5
str r1, [sp, #8]
ldr r2, [sp, #0xc]
adds r2, r2, r5
str r2, [sp, #0xc]
ldr r3, [sp, #0x10]
adds r3, r3, r5
str r3, [sp, #0x10]
movs r0, #1
add r9, r0
mov r1, r9
cmp r1, #2
ble _08026B72
ldr r0, _08026C10 @ gUnknown_0859B67C
ldr r2, [sp]
lsls r1, r2, #1
adds r1, r1, r0
ldrh r0, [r1]
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
.align 2, 0
_08026C10: .4byte gUnknown_0859B67C
_08026C14: .4byte gUnknown_0859B668
_08026C18: .4byte gUnknown_02034010
THUMB_FUNC_END SomethingSMS_32x32
THUMB_FUNC_START sub_8026C1C
sub_8026C1C: @ 0x08026C1C
push {r4, r5, r6, r7, lr}

View File

@ -893,9 +893,9 @@ void SetupMapSpritesPalettes(void);
// ??? sub_8026670(???);
void SMS_ClearUsageTable(void);
// ??? sub_80266BC(???);
void SMS_80266F0(int smsId, int frameId);
int SMS_80266F0(int smsId, int frameId);
// ??? SMS_SomethingGmapUnit(???);
void SMS_RegisterUsage(int);
int SMS_RegisterUsage(u32);
// ??? SomethingSMS_16x16_0(???);
// ??? SomethingSMS_16x16(???);
// ??? SomethingSMS_16x32(???);

View File

@ -6,8 +6,8 @@
#include "unit_icon_pointer.h"
typedef struct {
short pattern; // unknown, seems to be useless
short size; // icon size
unsigned short pattern; // unknown, seems to be useless
unsigned short size; // icon size
char *sheet; // animation sheet
} UnitIconWait, *pUnitIconWait;

View File

@ -94,6 +94,7 @@ SECTIONS
src/bmphase.o(.text);
src/bmgold.o(.text);
src/bmtarget.o(.text);
src/bmudisp.o(.text);
asm/bmudisp.o(.text);
src/bmreliance.o(.text);
src/bmitemuse.o(.text);

View File

@ -133,10 +133,6 @@ void BeginMapAnimForSteal(void);
void BeginMapAnimForSummon(void);
void BeginMapAnimForSummonDK(void);
// bmudisp.s
void SMS_RegisterUsage(int);
void PutUnitSprite(int, int, int, struct Unit*);
// code.s
void BWL_AddWinOrLossIdk(u8, u8, int);

280
src/bmudisp.c Normal file
View File

@ -0,0 +1,280 @@
#include "global.h"
#include "hardware.h"
#include "unit_icon_data.h"
/**
* Display standing map sprites and various tile/unit markers
*/
extern int gUnknown_0203A4CC; // gSMSSyncFlag
extern u8 gUnknown_02033F40[]; // gSMSGfxIndexLookup
extern int gUnknown_0203A010; // gSMS16xGfxIndexCounter
extern int gUnknown_0203A014; // gSMS32xGfxIndexCounter
extern UnitIconWait unit_icon_wait_table[];
extern u8* gUnknown_0859B668; // gpSMSGfxDecompBuffer
extern int gUnknown_0859B66C[]; // gSomeSMSLookupTable_859B66C
extern u16 gUnknown_0859B67C[]; // gSomeSMSLookupTable_859B67C
extern u8 gUnknown_02034010[3][8*0x20*0x20]; // gSMSGfxBuffer
// pal
extern u16 unit_icon_pal_player[]; // gPal_MapSprite
extern u16 gUnknown_0859EEC0[]; // gPal_NotMapSprite
extern u16 unit_icon_pal_p4[]; // gPal_MapSpriteArena
extern u16 gUnknown_0859EEE0[]; // gPal_MapSpriteSepia
// forward declarations
int SomethingSMS_16x16_0(int, u32);
int SomethingSMS_16x16(int, u32);
int SomethingSMS_16x32(int, u32);
int SomethingSMS_32x32(int, u32);
#define GetInfo(id) (unit_icon_wait_table[(id) & ((1<<7)-1)])
//! FE8U = 0x08026618
void sub_8026618(void) {
gUnknown_0203A4CC++;
return;
}
//! FE8U = 0x08026628
void SetupMapSpritesPalettes(void) {
CopyToPaletteBuffer(unit_icon_pal_player, 0x380, 0x80);
if ((gGameState.gameStateBits & 0x40) != 0) {
CopyToPaletteBuffer(unit_icon_pal_p4, 0x360, 0x20);
} else {
CopyToPaletteBuffer(gUnknown_0859EEC0, 0x360, 0x20);
}
return;
}
//! FE8U = 0x08026670
void sub_8026670(void) {
CopyToPaletteBuffer(gUnknown_0859EEE0, 0x3c0, 0x20);
return;
}
//! FE8U = 0x08026688
void SMS_ClearUsageTable(void) {
int i;
for (i = 0xD0-1; i >= 0; i--) {
gUnknown_02033F40[i] |= 0xff;
}
gUnknown_0203A014 = 0;
gUnknown_0203A010 = 0x40-1;
return;
}
//! FE8U = 0x080266BC
void sub_80266BC(void) {
int i;
for (i = 0xD0-1; i >= 0; i--) {
gUnknown_02033F40[i] |= 0xff;
}
gUnknown_0203A014 = 0;
gUnknown_0203A010 = 0x60-1;
return;
}
//! FE8U = 0x080266F0
int SMS_80266F0(int smsId, int frameId) {
int slot = gUnknown_0859B66C[frameId];
CopyDataWithPossibleUncomp(GetInfo(smsId).sheet, gUnknown_0859B668);
switch (GetInfo(smsId).size) {
case UNIT_ICON_SIZE_16x16:
gUnknown_02033F40[frameId] = SomethingSMS_16x16(slot, smsId) / 2;
break;
case UNIT_ICON_SIZE_16x32:
gUnknown_02033F40[frameId] = SomethingSMS_16x32(slot, smsId) / 2;
break;
case UNIT_ICON_SIZE_32x32:
gUnknown_02033F40[frameId] = SomethingSMS_32x32(slot, smsId) / 2;
break;
}
return gUnknown_02033F40[frameId] << 1;
}
//! FE8U = 0x0802677C
int SMS_SomethingGmapUnit(int smsId, int frameId, int slot) {
CopyDataWithPossibleUncomp(GetInfo(smsId).sheet, gUnknown_0859B668);
switch (GetInfo(smsId).size) {
case UNIT_ICON_SIZE_16x16:
gUnknown_02033F40[frameId] = SomethingSMS_16x16(slot, smsId) / 2;
break;
case UNIT_ICON_SIZE_16x32:
gUnknown_02033F40[frameId] = SomethingSMS_16x32(slot, smsId) / 2;
break;
case UNIT_ICON_SIZE_32x32:
gUnknown_02033F40[frameId] = SomethingSMS_32x32(slot, smsId) / 2;
break;
}
return gUnknown_02033F40[frameId] << 1;
}
//! FE8U = 0x080267FC
int SMS_RegisterUsage(u32 id) {
if (gUnknown_02033F40[id] == 0xFF) {
CopyDataWithPossibleUncomp(GetInfo(id).sheet, gUnknown_0859B668);
switch (GetInfo(id).size) {
case UNIT_ICON_SIZE_16x16:
gUnknown_02033F40[id] = SomethingSMS_16x16_0(gUnknown_0203A010, id) / 2;
gUnknown_0203A010 -= 1;
break;
case UNIT_ICON_SIZE_16x32:
gUnknown_02033F40[id] = SomethingSMS_16x32(gUnknown_0203A014, id) / 2;
gUnknown_0203A014 += 2;
break;
case UNIT_ICON_SIZE_32x32:
if ((gUnknown_0203A014 & 0x1e) == 0x1e) {
gUnknown_0203A014 += 2;
}
gUnknown_02033F40[id] = SomethingSMS_32x32(gUnknown_0203A014, id) / 2;
gUnknown_0203A014 += 4;
break;
}
gUnknown_0203A4CC++;
}
return gUnknown_02033F40[id] << 1;
}
//! FE8U = 0x080268C8
int SomethingSMS_16x16_0(int slot, u32 id) {
int i;
int outOff = gUnknown_0859B67C[slot] * CHR_SIZE;
id = ((id >> 7) ^ 1) & 1;
for (i = 0; i < 3; i++) {
int imgOff = (i * id) * 4 * CHR_SIZE;
CpuFastCopy(gUnknown_0859B668 + 0 * CHR_SIZE + imgOff, gUnknown_02034010[i] + 0 * CHR_SIZE * CHR_LINE + outOff, 2 * CHR_SIZE);
CpuFastCopy(gUnknown_0859B668 + 2 * CHR_SIZE + imgOff, gUnknown_02034010[i] + 1 * CHR_SIZE * CHR_LINE + outOff, 2 * CHR_SIZE);
}
return gUnknown_0859B67C[slot];
}
//! FE8U = 0x0802695C
int SomethingSMS_16x16(int slot, u32 id) {
int i;
int outOff = gUnknown_0859B67C[slot] * CHR_SIZE;
id = ((id >> 7) ^ 1) & 1;
for (i = 0; i < 3; i++) {
int imgOff = (i * id) * 4 * CHR_SIZE;
CpuFastFill(
0,
gUnknown_02034010[i] + 0 * CHR_SIZE * CHR_LINE + outOff,
2 * CHR_SIZE
);
CpuFastFill(
0,
gUnknown_02034010[i] + 1 * CHR_SIZE * CHR_LINE + outOff,
2 * CHR_SIZE
);
CpuFastCopy(
gUnknown_0859B668 + 0 * CHR_SIZE + imgOff,
gUnknown_02034010[i] + 2 * CHR_SIZE * CHR_LINE + outOff,
2 * CHR_SIZE
);
CpuFastCopy(
gUnknown_0859B668 + 2 * CHR_SIZE + imgOff,
gUnknown_02034010[i] + 3 * CHR_SIZE * CHR_LINE + outOff,
2 * CHR_SIZE
);
}
return gUnknown_0859B67C[slot];
}
//! FE8U = 0x08026A38
int SomethingSMS_16x32(int slot, u32 id) {
int i;
int outOff = gUnknown_0859B67C[slot] * CHR_SIZE;
id = ((id >> 7) ^ 1) & 1;
for (i = 0; i < 3; i++) {
int imgOff = (i * id) * 8 * CHR_SIZE;
CpuFastCopy(gUnknown_0859B668 + 0 * CHR_SIZE + imgOff, gUnknown_02034010[i] + 0 * CHR_SIZE * CHR_LINE + outOff, 2 * CHR_SIZE);
CpuFastCopy(gUnknown_0859B668 + 2 * CHR_SIZE + imgOff, gUnknown_02034010[i] + 1 * CHR_SIZE * CHR_LINE + outOff, 2 * CHR_SIZE);
CpuFastCopy(gUnknown_0859B668 + 4 * CHR_SIZE + imgOff, gUnknown_02034010[i] + 2 * CHR_SIZE * CHR_LINE + outOff, 2 * CHR_SIZE);
CpuFastCopy(gUnknown_0859B668 + 6 * CHR_SIZE + imgOff, gUnknown_02034010[i] + 3 * CHR_SIZE * CHR_LINE + outOff, 2 * CHR_SIZE);
}
return gUnknown_0859B67C[slot];
}
//! FE8U = 0x08026B28
int SomethingSMS_32x32(int slot, u32 id) {
int i;
int outOff = gUnknown_0859B67C[slot] * CHR_SIZE;
id = ((id >> 7) ^ 1) & 1;
for (i = 0; i < 3; i++) {
int imgOff = (i * id) * 16 * CHR_SIZE;
CpuFastCopy(gUnknown_0859B668 + 0 * CHR_SIZE + imgOff, gUnknown_02034010[i] + 0 * CHR_SIZE * CHR_LINE + outOff, 4 * CHR_SIZE);
CpuFastCopy(gUnknown_0859B668 + 4 * CHR_SIZE + imgOff, gUnknown_02034010[i] + 1 * CHR_SIZE * CHR_LINE + outOff, 4 * CHR_SIZE);
CpuFastCopy(gUnknown_0859B668 + 8 * CHR_SIZE + imgOff, gUnknown_02034010[i] + 2 * CHR_SIZE * CHR_LINE + outOff, 4 * CHR_SIZE);
CpuFastCopy(gUnknown_0859B668 + 12 * CHR_SIZE + imgOff, gUnknown_02034010[i] + 3 * CHR_SIZE * CHR_LINE + outOff, 4 * CHR_SIZE);
}
return gUnknown_0859B67C[slot];
}