Merge pull request #172 from ElectroDeoxys/master

Decompile some code_8094148
This commit is contained in:
AnonymousRandomPerson 2024-03-04 21:01:33 -05:00 committed by GitHub
commit 914d19a1fa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 155 additions and 152 deletions

View File

@ -5,158 +5,6 @@
.text
thumb_func_start sub_8094268
sub_8094268:
push {r4-r6,lr}
adds r5, r0, 0
adds r3, r1, 0
asrs r0, r3, 16
asrs r1, r2, 16
adds r0, r1
lsls r0, 16
ldr r6, _080942B0
ands r3, r6
orrs r3, r0
adds r2, r3, r2
lsls r2, 16
lsrs r2, 16
ldr r4, _080942B4
ands r3, r4
orrs r3, r2
asrs r1, r3, 16
ldr r0, _080942B8
cmp r1, r0
ble _080942A6
adds r0, r3, 0x1
lsls r0, 16
lsrs r0, 16
ands r3, r4
orrs r3, r0
asrs r0, r3, 16
ldr r1, _080942BC
adds r0, r1
lsls r0, 16
ands r3, r6
orrs r3, r0
_080942A6:
str r3, [r5]
adds r0, r5, 0
pop {r4-r6}
pop {r1}
bx r1
.align 2, 0
_080942B0: .4byte 0x0000ffff
_080942B4: .4byte 0xffff0000
_080942B8: .4byte 0x000003e7
_080942BC: .4byte 0xfffffc18
thumb_func_end sub_8094268
thumb_func_start sub_80942C0
sub_80942C0:
push {r4,r5,lr}
adds r5, r0, 0
adds r3, r1, 0
asrs r0, r3, 16
asrs r1, r2, 16
subs r0, r1
lsls r0, 16
ldr r4, _08094310
ands r3, r4
orrs r3, r0
subs r2, r3, r2
lsls r2, 16
lsrs r2, 16
ldr r1, _08094314
ands r3, r1
orrs r3, r2
cmp r3, 0
bge _080942FC
subs r0, r3, 0x1
lsls r0, 16
lsrs r0, 16
ands r3, r1
orrs r3, r0
asrs r0, r3, 16
movs r2, 0xFA
lsls r2, 2
adds r0, r2
lsls r0, 16
ands r3, r4
orrs r3, r0
_080942FC:
lsls r0, r3, 16
cmp r0, 0
bge _08094304
movs r3, 0
_08094304:
str r3, [r5]
adds r0, r5, 0
pop {r4,r5}
pop {r1}
bx r1
.align 2, 0
_08094310: .4byte 0x0000ffff
_08094314: .4byte 0xffff0000
thumb_func_end sub_80942C0
thumb_func_start sub_8094318
sub_8094318:
push {r4,lr}
adds r4, r0, 0
adds r3, r1, 0
lsls r0, r3, 16
asrs r1, r0, 16
lsls r0, r2, 16
asrs r0, 16
cmp r1, r0
bgt _08094336
cmp r1, r0
blt _0809433A
asrs r1, r3, 16
asrs r0, r2, 16
cmp r1, r0
ble _0809433A
_08094336:
str r2, [r4]
b _0809433C
_0809433A:
str r3, [r4]
_0809433C:
adds r0, r4, 0
pop {r4}
pop {r1}
bx r1
thumb_func_end sub_8094318
thumb_func_start sub_8094344
sub_8094344:
push {r4,lr}
adds r4, r0, 0
adds r3, r1, 0
lsls r0, r3, 16
asrs r1, r0, 16
lsls r0, r2, 16
asrs r0, 16
cmp r1, r0
bgt _08094362
cmp r1, r0
blt _08094366
asrs r1, r3, 16
asrs r0, r2, 16
cmp r1, r0
ble _08094366
_08094362:
str r3, [r4]
b _08094368
_08094366:
str r2, [r4]
_08094368:
adds r0, r4, 0
pop {r4}
pop {r1}
bx r1
thumb_func_end sub_8094344
thumb_func_start sub_8094370
sub_8094370:
push {r4,r5,lr}

View File

@ -303,6 +303,7 @@ SECTIONS {
src/text_util.o(.text);
src/friend_area.o(.text);
src/moves.o(.text);
src/code_8094148.o(.text);
asm/code_8094148.o(.text);
src/number_util.o(.text);
src/code_809447C.o(.text);

154
src/code_8094148.c Normal file
View File

@ -0,0 +1,154 @@
#include "global.h"
s32 *sub_8094268(s32 *param_1, s32 param_2, s32 param_3)
{
s32 x;
s32 y;
u16 z;
y = param_2;
x = ((y >> 0x10) + (param_3 >> 0x10)) << 0x10;
y = (y & 0x0000ffff) | x;
z = y + param_3;
y = (y & 0xffff0000) | z;
if ((y >> 0x10) > 999) {
u16 b;
s32 c;
b = y + 1;
y = (y & 0xffff0000) | b;
c = ((y >> 0x10) - 1000) << 0x10;
y = (y & 0x0000ffff) | c;
}
*param_1 = y;
return param_1;
}
#ifdef NONMATCHING
// https://decomp.me/scratch/RUfc2 (99.52% matching)
s32* sub_80942C0(s32* param_1, s32 param_2, s32 param_3)
{
s32 x;
s32 y;
u16 z;
s32* dest;
dest = param_1;
y = param_2;
x = ((y >> 0x10) - (param_3 >> 0x10)) << 0x10;
y = (y & 0x0000ffff) | x;
z = y - param_3;
y = (y & 0xffff0000) | z;
if (y < 0) {
u16 b;
s32 c;
b = (y - 1);
y = (y & 0xffff0000) | b;
c = ((y >> 0x10) + 1000) << 0x10;
y = (y & 0x0000ffff) | c;
}
if ((y << 0x10) < 0) {
y = 0;
}
*dest = y;
return dest;
}
#else
NAKED
void sub_80942C0(s32* param_1, s32 param_2, s32 param_3)
{
asm_unified(
"\tpush {r4,r5,lr}\n"
"\tadds r5, r0, 0\n"
"\tadds r3, r1, 0\n"
"\tasrs r0, r3, 16\n"
"\tasrs r1, r2, 16\n"
"\tsubs r0, r1\n"
"\tlsls r0, 16\n"
"\tldr r4, _08094310\n"
"\tands r3, r4\n"
"\torrs r3, r0\n"
"\tsubs r2, r3, r2\n"
"\tlsls r2, 16\n"
"\tlsrs r2, 16\n"
"\tldr r1, _08094314\n"
"\tands r3, r1\n"
"\torrs r3, r2\n"
"\tcmp r3, 0\n"
"\tbge _080942FC\n"
"\tsubs r0, r3, 0x1\n"
"\tlsls r0, 16\n"
"\tlsrs r0, 16\n"
"\tands r3, r1\n"
"\torrs r3, r0\n"
"\tasrs r0, r3, 16\n"
"\tmovs r2, 0xFA\n"
"\tlsls r2, 2\n"
"\tadds r0, r2\n"
"\tlsls r0, 16\n"
"\tands r3, r4\n"
"\torrs r3, r0\n"
"_080942FC:\n"
"\tlsls r0, r3, 16\n"
"\tcmp r0, 0\n"
"\tbge _08094304\n"
"\tmovs r3, 0\n"
"_08094304:\n"
"\tstr r3, [r5]\n"
"\tadds r0, r5, 0\n"
"\tpop {r4,r5}\n"
"\tpop {r1}\n"
"\tbx r1\n"
"\t.align 2, 0\n"
"_08094310: .4byte 0x0000ffff\n"
"_08094314: .4byte 0xffff0000\n"
);
}
#endif
s32* sub_8094318(s32* param_1, s32 param_2, s32 param_3)
{
s16 a;
s16 b;
a = param_3;
b = param_2;
if ((b > a) || (b >= a && (param_2 >> 0x10 > param_3 >> 0x10))) {
*param_1 = param_3;
}
else {
*param_1 = param_2;
}
return param_1;
}
s32* sub_8094344(s32* param_1, s32 param_2, s32 param_3)
{
s16 a;
s16 b;
a = param_3;
b = param_2;
if ((b > a) || (b >= a && (param_2 >> 0x10 > param_3 >> 0x10)))
{
*param_1 = param_2;
}
else
{
*param_1 = param_3;
}
return param_1;
}