Skip to content

Commit

Permalink
Move sub_805A8B0 into non-matching
Browse files Browse the repository at this point in the history
  • Loading branch information
JaceCear committed Dec 13, 2024
1 parent 3f24147 commit bfc4228
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 100 deletions.
100 changes: 0 additions & 100 deletions asm/enemy_ape.s
Original file line number Diff line number Diff line change
Expand Up @@ -8,106 +8,6 @@
.if 0
.endif

thumb_func_start sub_805A8B0
sub_805A8B0: @ 0x0805A8B0
push {r4, lr}
adds r4, r0, #0
movs r1, #0xa0
adds r2, r4, #0
adds r2, #0x4c
ldrh r0, [r4, #8]
cmp r0, #0x2c
bls _0805A8C4
cmp r0, #0x54
blo _0805A8CC
_0805A8C4:
cmp r0, #0xac
bls _0805A8D2
cmp r0, #0xd4
bhs _0805A8D2
_0805A8CC:
ldrh r0, [r4, #8]
adds r0, #3
b _0805A8D6
_0805A8D2:
ldrh r0, [r4, #8]
adds r0, #1
_0805A8D6:
strh r0, [r4, #8]
ldrh r0, [r4, #8]
cmp r0, #0xe0
bls _0805A8E2
movs r0, #0x20
strh r0, [r4, #8]
_0805A8E2:
ldrh r0, [r4, #8]
cmp r0, #0x60
bls _0805A8EE
cmp r0, r1
bhs _0805A8EE
strh r1, [r4, #8]
_0805A8EE:
ldrh r1, [r4, #8]
subs r0, r1, #1
lsls r0, r0, #0x10
lsrs r0, r0, #0x10
cmp r0, #0x3e
bls _0805A906
adds r0, r1, #0
subs r0, #0xc1
lsls r0, r0, #0x10
lsrs r0, r0, #0x10
cmp r0, #0x3e
bhi _0805A910
_0805A906:
ldr r0, [r2, #8]
movs r1, #0x80
lsls r1, r1, #3
orrs r0, r1
b _0805A916
_0805A910:
ldr r0, [r2, #8]
ldr r1, _0805A958 @ =0xFFFFFBFF
ands r0, r1
_0805A916:
str r0, [r2, #8]
ldr r3, _0805A95C @ =gSineTable
ldrb r2, [r4, #8]
lsls r0, r2, #3
movs r1, #0x80
lsls r1, r1, #2
adds r0, r0, r1
adds r0, r0, r3
ldrh r0, [r0]
lsls r0, r0, #0x10
asrs r0, r0, #0x16
lsls r0, r0, #5
ldr r1, [r4, #0x14]
adds r1, r1, r0
str r1, [r4, #0x1c]
lsls r2, r2, #3
adds r2, r2, r3
ldrh r0, [r2]
lsls r0, r0, #0x10
asrs r0, r0, #0x16
lsls r1, r0, #5
cmp r1, #0
bge _0805A946
rsbs r1, r1, #0
_0805A946:
ldr r0, [r4, #0x18]
adds r0, r0, r1
ldr r1, _0805A960 @ =0xFFFFF600
adds r0, r0, r1
str r0, [r4, #0x20]
pop {r4}
pop {r0}
bx r0
.align 2, 0
_0805A958: .4byte 0xFFFFFBFF
_0805A95C: .4byte gSineTable
_0805A960: .4byte 0xFFFFF600

thumb_func_start sub_805A964
sub_805A964: @ 0x0805A964
push {r4, r5, r6, r7, lr}
Expand Down
102 changes: 102 additions & 0 deletions asm/non_matching/game/enemies/ape__sub_805A8B0.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@

.syntax unified
.text
push {r4, lr}
adds r4, r0, #0 @ r4 = enemy
movs r1, #0xa0
adds r2, r4, #0
adds r2, #0x4c
ldrh r0, [r4, #8]
cmp r0, #0x2c
bls _0805A8C4
cmp r0, #0x54
blo _0805A8CC
_0805A8C4:
cmp r0, #0xac
bls _0805A8D2
cmp r0, #0xd4
bhs _0805A8D2
_0805A8CC:
ldrh r0, [r4, #8]
adds r0, #3
b _0805A8D6
_0805A8D2:
ldrh r0, [r4, #8]
adds r0, #1
_0805A8D6:
strh r0, [r4, #8]
ldrh r0, [r4, #8]
cmp r0, #0xe0
bls _0805A8E2
movs r0, #0x20
strh r0, [r4, #8]
_0805A8E2:
ldrh r0, [r4, #8]
cmp r0, #0x60
bls _0805A8EE
cmp r0, r1
bhs _0805A8EE
strh r1, [r4, #8]
_0805A8EE:
ldrh r1, [r4, #8]
subs r0, r1, #1
lsls r0, r0, #0x10
lsrs r0, r0, #0x10
cmp r0, #0x3e
bls _0805A906
adds r0, r1, #0
subs r0, #0xc1
lsls r0, r0, #0x10
lsrs r0, r0, #0x10
cmp r0, #0x3e
bhi _0805A910
_0805A906:
ldr r0, [r2, #8]
movs r1, #0x80
lsls r1, r1, #3
orrs r0, r1
b _0805A916
_0805A910:
ldr r0, [r2, #8]
ldr r1, _0805A958 @ =0xFFFFFBFF
ands r0, r1
_0805A916:
str r0, [r2, #8]
ldr r3, _0805A95C @ =gSineTable
ldrb r2, [r4, #8]
lsls r0, r2, #3
movs r1, #0x80
lsls r1, r1, #2
adds r0, r0, r1
adds r0, r0, r3
ldrh r0, [r0]
lsls r0, r0, #0x10
asrs r0, r0, #0x16
lsls r0, r0, #5
ldr r1, [r4, #0x14]
adds r1, r1, r0
str r1, [r4, #0x1c]
lsls r2, r2, #3
adds r2, r2, r3
ldrh r0, [r2]
lsls r0, r0, #0x10
asrs r0, r0, #0x16
lsls r1, r0, #5
cmp r1, #0
bge _0805A946
rsbs r1, r1, #0
_0805A946:
ldr r0, [r4, #0x18]
adds r0, r0, r1
ldr r1, _0805A960 @ =0xFFFFF600
adds r0, r0, r1
str r0, [r4, #0x20]
pop {r4}
pop {r0}
bx r0
.align 2, 0
_0805A958: .4byte 0xFFFFFBFF
_0805A95C: .4byte gSineTable
_0805A960: .4byte 0xFFFFF600

.syntax divided
34 changes: 34 additions & 0 deletions src/game/enemies/ape.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,3 +224,37 @@ void Task_805A7F0(void)
}
}
}

NONMATCH("asm/non_matching/game/enemies/ape__sub_805A8B0.inc", void sub_805A8B0(Ape *enemy))
{
u32 r1 = 160;
u16 theta;
u32 chk;
Sprite *s2 = &enemy->s2;

chk = enemy->unk8;
if (((chk > 44) && (enemy->unk8 < 85)) || ((chk > 172) && (enemy->unk8 < 213))) {
enemy->unk8 += 3;
} else {
enemy->unk8 += 1;
}
// _0805A8D6

if (enemy->unk8 > 224) {
enemy->unk8 = 32;
}

if ((enemy->unk8 > 96) && (enemy->unk8 < r1)) {
enemy->unk8 = r1;
}

if (((u16)(enemy->unk8 - 1) <= 62) || ((u16)(enemy->unk8 - 193) <= 62)) {
SPRITE_FLAG_SET(s2, X_FLIP);
} else {
SPRITE_FLAG_CLEAR(s2, X_FLIP);
}

enemy->qPos.x = enemy->qUnk14.x + COS_24_8((u8)enemy->unk8 * 4) * 32;
enemy->qPos.y = enemy->qUnk14.y + ABS(SIN_24_8((u8)enemy->unk8 * 4) * 32) - Q(10);
}
END_NONMATCH

0 comments on commit bfc4228

Please sign in to comment.