sub_803DD30

This commit is contained in:
DizzyEggg 2024-09-22 11:34:40 +02:00
parent 1c9a67668a
commit c07d06ef3f
2 changed files with 143 additions and 334 deletions

View File

@ -6,340 +6,6 @@
.text
thumb_func_start sub_803DC14
sub_803DC14:
push {r4-r6,lr}
adds r4, r0, 0
adds r5, r1, 0
adds r6, r2, 0
b _0803DC5C
_0803DC1E:
ldrb r1, [r4]
adds r4, 0x1
cmp r1, 0x2F
bne _0803DC2C
movs r5, 0
adds r6, 0x18
b _0803DC5C
_0803DC2C:
cmp r1, 0x23
bne _0803DC34
adds r5, 0x8
b _0803DC5C
_0803DC34:
cmp r1, 0x20
bne _0803DC3C
adds r5, 0xC
b _0803DC5C
_0803DC3C:
movs r0, 0x80
ands r0, r1
cmp r0, 0
beq _0803DC50
ldrb r0, [r4]
cmp r0, 0
beq _0803DC50
lsls r1, 8
orrs r1, r0
adds r4, 0x1
_0803DC50:
adds r0, r1, 0
adds r1, r5, 0
adds r2, r6, 0
bl sub_803DC6C
adds r5, r0
_0803DC5C:
ldrb r0, [r4]
cmp r0, 0
bne _0803DC1E
adds r0, r6, 0
pop {r4-r6}
pop {r1}
bx r1
thumb_func_end sub_803DC14
thumb_func_start sub_803DC6C
sub_803DC6C:
push {r4-r7,lr}
mov r7, r9
mov r6, r8
push {r6,r7}
sub sp, 0x120
adds r7, r1, 0
adds r5, r2, 0
bl sub_803DEC8
adds r4, r0, 0
ldr r0, [r4]
mov r1, sp
bl sub_803DD30
ldrb r4, [r4, 0x6]
mov r9, r4
mov r6, sp
adds r0, r5, 0
cmp r5, 0
bge _0803DC96
adds r0, r5, 0x7
_0803DC96:
asrs r0, 3
lsls r3, r0, 3
subs r0, r3, r0
lsls r0, 2
adds r1, r7, 0
cmp r7, 0
bge _0803DCA6
adds r1, r7, 0x7
_0803DCA6:
asrs r1, 3
adds r0, r1
lsls r0, 5
ldr r4, _0803DD28
adds r2, r0, r4
subs r0, r5, r3
lsls r0, 2
adds r2, r0
lsls r1, 3
subs r1, r7, r1
lsls r1, 4
ldr r0, _0803DD2C
adds r4, r1, r0
movs r0, 0
_0803DCC2:
adds r3, r2, 0
adds r7, r3, 0x4
adds r5, 0x1
mov r12, r5
adds r0, 0x1
mov r8, r0
movs r5, 0x2
_0803DCD0:
ldr r2, [r6]
cmp r2, 0
beq _0803DCF6
ldr r1, [r4]
ands r1, r2
ldr r0, [r4, 0x8]
lsls r1, r0
ldr r0, [r3]
orrs r0, r1
str r0, [r3]
adds r3, 0x20
ldr r0, [r4, 0x4]
ands r2, r0
ldr r0, [r4, 0xC]
lsrs r2, r0
ldr r0, [r3]
orrs r0, r2
str r0, [r3]
subs r3, 0x20
_0803DCF6:
adds r6, 0x4
adds r3, 0x20
subs r5, 0x1
cmp r5, 0
bge _0803DCD0
adds r2, r7, 0
mov r5, r12
movs r0, 0x7
ands r0, r5
cmp r0, 0
bne _0803DD12
movs r0, 0xD8
lsls r0, 2
adds r2, r7, r0
_0803DD12:
mov r0, r8
cmp r0, 0x17
ble _0803DCC2
mov r0, r9
add sp, 0x120
pop {r3,r4}
mov r8, r3
mov r9, r4
pop {r4-r7}
pop {r1}
bx r1
.align 2, 0
_0803DD28: .4byte 0x06000140
_0803DD2C: .4byte gUnknown_80F6120
thumb_func_end sub_803DC6C
thumb_func_start sub_803DD30
sub_803DD30:
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
ldr r4, _0803DDBC
add sp, r4
adds r4, r0, 0
mov r10, r1
movs r3, 0
movs r5, 0
ldr r0, _0803DDC0
mov r8, r0
movs r6, 0xF
movs r7, 0xF
mov r2, sp
_0803DD50:
ldrb r0, [r4]
lsrs r1, r0, 4
ands r1, r6
strb r1, [r2]
adds r1, r7, 0
ands r1, r0
strb r1, [r2, 0x1]
adds r4, 0x1
adds r2, 0x2
adds r5, 0x2
cmp r5, r8
ble _0803DD50
ldr r1, _0803DDC0
cmp r3, r1
bgt _0803DDF8
movs r0, 0x90
lsls r0, 2
mov r2, sp
adds r2, r0
mov r12, r2
mov r8, r1
mov r2, sp
mov r9, r0
_0803DD7E:
ldrb r1, [r2]
adds r2, 0x1
movs r6, 0x7
ands r6, r1
movs r0, 0x8
ands r1, r0
cmp r1, 0
beq _0803DDC4
ldrb r1, [r2]
adds r2, 0x1
movs r4, 0
cmp r4, r6
bge _0803DDF4
mov r5, r12
adds r0, r5, r3
strb r1, [r0]
adds r3, 0x1
cmp r3, r8
bgt _0803DDF8
mov r5, sp
add r5, r9
ldr r7, _0803DDC0
_0803DDAA:
adds r4, 0x1
cmp r4, r6
bge _0803DDF4
adds r0, r5, r3
strb r1, [r0]
adds r3, 0x1
cmp r3, r7
ble _0803DDAA
b _0803DDF4
.align 2, 0
_0803DDBC: .4byte 0xfffffb80
_0803DDC0: .4byte 0x0000023f
_0803DDC4:
movs r4, 0
cmp r4, r6
bge _0803DDF4
ldrb r1, [r2]
adds r2, 0x1
mov r5, r12
adds r0, r5, r3
strb r1, [r0]
adds r3, 0x1
cmp r3, r8
bgt _0803DDF8
mov r5, sp
add r5, r9
ldr r7, _0803DE78
_0803DDE0:
adds r4, 0x1
cmp r4, r6
bge _0803DDF4
ldrb r1, [r2]
adds r2, 0x1
adds r0, r5, r3
strb r1, [r0]
adds r3, 0x1
cmp r3, r7
ble _0803DDE0
_0803DDF4:
cmp r3, r8
ble _0803DD7E
_0803DDF8:
movs r5, 0
ldr r4, _0803DE78
add r3, sp, 0x240
_0803DDFE:
ldrb r2, [r3, 0x7]
lsls r2, 28
ldrb r0, [r3, 0x6]
lsls r0, 24
movs r1, 0xF0
lsls r1, 20
ands r0, r1
orrs r2, r0
ldrb r0, [r3, 0x5]
lsls r0, 20
movs r1, 0xF0
lsls r1, 16
ands r0, r1
orrs r2, r0
ldrb r0, [r3, 0x4]
lsls r0, 16
movs r1, 0xF0
lsls r1, 12
ands r0, r1
orrs r2, r0
ldrb r0, [r3, 0x3]
lsls r0, 12
movs r1, 0xF0
lsls r1, 8
ands r0, r1
orrs r2, r0
ldrb r0, [r3, 0x2]
lsls r0, 8
movs r1, 0xF0
lsls r1, 4
ands r0, r1
orrs r2, r0
ldrb r0, [r3, 0x1]
lsls r0, 4
movs r1, 0xF0
ands r0, r1
orrs r2, r0
ldrb r1, [r3]
movs r0, 0xF
ands r0, r1
orrs r2, r0
mov r0, r10
adds r0, 0x4
mov r10, r0
subs r0, 0x4
stm r0!, {r2}
adds r3, 0x8
adds r5, 0x8
cmp r5, r4
ble _0803DDFE
movs r3, 0x90
lsls r3, 3
add sp, r3
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r0}
bx r0
.align 2, 0
_0803DE78: .4byte 0x0000023f
thumb_func_end sub_803DD30
thumb_func_start CalcStringWidth
CalcStringWidth:
push {r4,r5,lr}

View File

@ -574,3 +574,146 @@ void ShowDungeonNameBanner(void)
sub_803E46C(2);
}
s32 sub_803DC6C(u32 chr, s32 strWidth, s32 a2);
s32 sub_803DC14(const u8 *dungName, s32 strWidth, s32 a2)
{
while (*dungName != '\0') {
u32 currChar = *(dungName++);
if (currChar == '/') {
strWidth = 0;
a2 += 24;
}
else if (currChar == '#') {
strWidth += 8;
}
else if (currChar == ' ') {
strWidth += 12;
}
else {
if (currChar & 0x80 && *dungName != '\0') {
currChar = (currChar << 8) | *dungName;
dungName++;
}
strWidth += sub_803DC6C(currChar, strWidth, a2);
}
}
return a2;
}
struct UnkStruct_sub_803DC6C
{
u8 *unk0;
u8 unk4;
u8 unk5;
u8 unk6;
};
struct UnkStruct_sub_803DC6C *sub_803DEC8(u32 chr);
void sub_803DD30(u8 *a0, u32 *a1);
extern const u32 gUnknown_80F6120[];
s32 sub_803DC6C(u32 chr, s32 strWidth, s32 a2)
{
u32 *spPtr;
s32 i, j, a2DivMul;
u32 *vramPtr;
const u32 *constData;
u32 sp[72];
s32 r9;
struct UnkStruct_sub_803DC6C *strPtr = sub_803DEC8(chr);
sub_803DD30(strPtr->unk0, sp);
r9 = strPtr->unk6;
spPtr = sp;
a2DivMul = ((a2 / 8) * 8);
vramPtr = (void *)(VRAM + 0x140 + (((a2DivMul - a2 / 8) * 4) + (strWidth / 8)) * 32); // Pixels?
vramPtr += a2 - a2DivMul;
constData = &gUnknown_80F6120[(strWidth - ((strWidth / 8) * 8)) * 4];
for (i = 0; i < 24; i++) {
u32 *vramPtrLoop = vramPtr;
for (j = 0; j < 3; j++) {
// Sadly cannot match it without asm :/
#ifdef NONMATCHING
u32 spVal = *spPtr;
#else
register u32 spVal asm("r2") = *spPtr;
#endif // NONMATCHING
if (spVal != 0) {
*vramPtrLoop |= ((constData[0] & spVal) << constData[2]);
vramPtrLoop += 8;
spVal &= constData[1];
spVal >>= constData[3];
*vramPtrLoop |= spVal;
vramPtrLoop -= 8;
}
spPtr++;
vramPtrLoop += 8;
}
vramPtr++;
a2++;
if (!(a2 & 7)) {
vramPtr += 216;
}
}
return r9;
}
void sub_803DD30(u8 *a0, u32 *a1)
{
u8 sp[576];
u8 sp575[576];
s32 spId = 0;
s32 i, j = 0, k;
u32 currSp;
s32 r6;
for (i = 0; i < 576; i += 2) {
sp[i] = (*a0 >> 4) & 0xF;
sp[i+1] = *a0 & 0xF;
a0++;
}
while (j < 576) {
currSp = sp[spId++];
r6 = currSp & 7;
if (currSp & 8) {
currSp = sp[spId++];
for (k = 0; k < r6; k++) {
sp575[j] = currSp;
if (++j >= 576)
break;
}
}
else {
for (k = 0; k < r6; k++) {
currSp = sp[spId++];
sp575[j] = currSp;
if (++j >= 576)
break;
}
}
if (j >= 576)
break;
}
for (i = 0; i < 576; i += 8) {
u32 val = sp575[i + 7] << 0x1C;
val |= (sp575[i + 6] << 0x18) & 0xF000000;
val |= (sp575[i + 5] << 0x14) & 0xF00000;
val |= (sp575[i + 4] << 0x10) & 0xF0000;
val |= (sp575[i + 3] << 0xC) & 0xF000;
val |= (sp575[i + 2] << 0x8) & 0xF00;
val |= (sp575[i + 1] << 0x4) & 0xF0;
val |= (sp575[i]) & 0xF;
*(a1++) = val;
}
}