From 460af32c4a34a5753a36d051d753527517dc79c9 Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Sun, 27 Apr 2025 09:36:45 -0500 Subject: [PATCH] sub_13934 --- asm/rom_11B9C.s | 244 -------------------------------------------- include/functions.h | 1 - include/global.h | 6 +- src/rom_1332C.c | 72 +++++++++++-- 4 files changed, 67 insertions(+), 256 deletions(-) diff --git a/asm/rom_11B9C.s b/asm/rom_11B9C.s index a42302f..e559e2e 100644 --- a/asm/rom_11B9C.s +++ b/asm/rom_11B9C.s @@ -917,250 +917,6 @@ _08013328: .4byte 0x000001FF .section .text1333C - thumb_func_start sub_13934 -sub_13934: @ 0x08013934 - push {r4, r5, r6, r7, lr} - adds r6, r0, #0 - adds r5, r1, #0 - lsls r2, r2, #0x10 - lsrs r4, r2, #0x10 - movs r0, #0 - strh r0, [r5] - strh r0, [r5, #2] - ldr r7, _0801399C @ =gCurrentPinballGame - ldr r1, [r7] - movs r0, #0x91 - lsls r0, r0, #1 - adds r2, r1, r0 - movs r0, #0 - ldrsb r0, [r2, r0] - cmp r0, #0 - beq _080139D6 - movs r3, #0x92 - lsls r3, r3, #1 - adds r0, r1, r3 - movs r1, #0 - ldrsb r1, [r0, r1] - ldrh r0, [r6] - subs r0, r0, r1 - strh r0, [r6] - movs r0, #0 - ldrsb r0, [r2, r0] - cmp r0, #0 - ble _080139A4 - adds r0, r4, #0 - bl Cos - lsls r0, r0, #0x10 - cmp r0, #0 - bge _080139D6 - adds r0, r4, #0 - bl Cos - lsls r0, r0, #0x10 - asrs r0, r0, #0x10 - movs r1, #0x46 - muls r0, r1, r0 - ldr r1, _080139A0 @ =0x00004E20 - bl __divsi3 - strh r0, [r5] - ldr r0, [r7] - movs r2, #0x93 - lsls r2, r2, #1 - adds r1, r0, r2 - b _080139D2 - .align 2, 0 -_0801399C: .4byte gCurrentPinballGame -_080139A0: .4byte 0x00004E20 -_080139A4: - cmp r0, #0 - bge _080139D6 - adds r0, r4, #0 - bl Cos - lsls r0, r0, #0x10 - cmp r0, #0 - ble _080139D6 - adds r0, r4, #0 - bl Cos - lsls r0, r0, #0x10 - asrs r0, r0, #0x10 - movs r1, #0x46 - muls r0, r1, r0 - ldr r1, _08013A30 @ =0x00004E20 - bl __divsi3 - strh r0, [r5] - ldr r0, [r7] - movs r3, #0x93 - lsls r3, r3, #1 - adds r1, r0, r3 -_080139D2: - movs r0, #1 - strb r0, [r1] -_080139D6: - ldr r1, _08013A34 @ =gCurrentPinballGame - ldr r2, [r1] - ldr r3, _08013A38 @ =0x00000123 - adds r0, r2, r3 - ldrb r0, [r0] - lsls r0, r0, #0x18 - asrs r0, r0, #0x18 - adds r3, r1, #0 - cmp r0, #0 - bgt _080139EC - b _08013AF4 -_080139EC: - ldr r1, _08013A3C @ =0x00000125 - adds r0, r2, r1 - movs r1, #0 - ldrsb r1, [r0, r1] - ldrh r0, [r6, #2] - subs r0, r0, r1 - strh r0, [r6, #2] - ldr r3, _08013A40 @ =0x0000132C - adds r0, r2, r3 - ldr r0, [r0] - movs r3, #0x12 - ldrsh r1, [r0, r3] - movs r0, #0xb6 - lsls r0, r0, #1 - cmp r1, r0 - ble _08013A64 - movs r1, #0x91 - lsls r1, r1, #1 - adds r0, r2, r1 - ldrb r0, [r0] - lsls r0, r0, #0x18 - asrs r0, r0, #0x18 - cmp r0, #0 - bne _08013A44 - adds r0, r4, #0 - bl Sin - adds r1, r0, #0 - lsls r1, r1, #0x10 - asrs r1, r1, #0x10 - lsls r0, r1, #6 - adds r0, r0, r1 - lsls r0, r0, #1 - b _08013A52 - .align 2, 0 -_08013A30: .4byte 0x00004E20 -_08013A34: .4byte gCurrentPinballGame -_08013A38: .4byte 0x00000123 -_08013A3C: .4byte 0x00000125 -_08013A40: .4byte 0x0000132C -_08013A44: - adds r0, r4, #0 - bl Sin - lsls r0, r0, #0x10 - asrs r0, r0, #0x10 - movs r1, #0x64 - muls r0, r1, r0 -_08013A52: - rsbs r0, r0, #0 - ldr r1, _08013A60 @ =0x00004E20 - bl __divsi3 - strh r0, [r5, #2] - b _08013AE4 - .align 2, 0 -_08013A60: .4byte 0x00004E20 -_08013A64: - movs r3, #0x91 - lsls r3, r3, #1 - adds r0, r2, r3 - ldrb r0, [r0] - lsls r0, r0, #0x18 - asrs r0, r0, #0x18 - cmp r0, #0 - bne _08013A8C - adds r0, r4, #0 - bl Sin - lsls r0, r0, #0x10 - asrs r0, r0, #0x10 - movs r1, #0x64 - muls r0, r1, r0 - rsbs r0, r0, #0 - ldr r1, _08013A88 @ =0x00004E20 - b _08013AA2 - .align 2, 0 -_08013A88: .4byte 0x00004E20 -_08013A8C: - adds r0, r4, #0 - bl Sin - lsls r0, r0, #0x10 - asrs r0, r0, #0x10 - lsls r2, r0, #2 - adds r2, r2, r0 - lsls r0, r2, #4 - subs r2, r2, r0 - ldr r1, _08013ABC @ =0x00004E20 - adds r0, r2, #0 -_08013AA2: - bl __divsi3 - strh r0, [r5, #2] - movs r0, #2 - ldrsh r1, [r5, r0] - cmp r1, #0x59 - ble _08013AC8 - ldr r0, _08013AC0 @ =gCurrentPinballGame - ldr r0, [r0] - ldr r1, _08013AC4 @ =0x0000132C - adds r0, r0, r1 - b _08013AD4 - .align 2, 0 -_08013ABC: .4byte 0x00004E20 -_08013AC0: .4byte gCurrentPinballGame -_08013AC4: .4byte 0x0000132C -_08013AC8: - cmp r1, #0x45 - ble _08013AE4 - ldr r0, _08013B1C @ =gCurrentPinballGame - ldr r0, [r0] - ldr r3, _08013B20 @ =0x0000132C - adds r0, r0, r3 -_08013AD4: - ldr r1, [r0] - movs r2, #0x30 - ldrsh r0, [r1, r2] - cmp r0, #0 - bge _08013AE0 - adds r0, #3 -_08013AE0: - asrs r0, r0, #2 - strh r0, [r1, #0x30] -_08013AE4: - ldr r0, _08013B1C @ =gCurrentPinballGame - ldr r1, [r0] - movs r3, #0x93 - lsls r3, r3, #1 - adds r2, r1, r3 - movs r1, #1 - strb r1, [r2] - adds r3, r0, #0 -_08013AF4: - ldr r1, [r3] - movs r2, #0x93 - lsls r2, r2, #1 - adds r0, r1, r2 - ldrb r0, [r0] - lsls r0, r0, #0x18 - asrs r0, r0, #0x18 - cmp r0, #0 - beq _08013B16 - subs r2, #4 - adds r0, r1, r2 - movs r1, #0 - strb r1, [r0] - ldr r0, [r3] - ldr r3, _08013B24 @ =0x00000123 - adds r0, r0, r3 - strb r1, [r0] -_08013B16: - pop {r4, r5, r6, r7} - pop {r0} - bx r0 - .align 2, 0 -_08013B1C: .4byte gCurrentPinballGame -_08013B20: .4byte 0x0000132C -_08013B24: .4byte 0x00000123 - thumb_func_start sub_13B28 sub_13B28: @ 0x08013B28 push {r4, r5, r6, r7, lr} diff --git a/include/functions.h b/include/functions.h index 4ee1851..11446b0 100644 --- a/include/functions.h +++ b/include/functions.h @@ -375,7 +375,6 @@ extern void ClearSomeArray(void); extern void sub_1332C(); extern void sub_1333C(); extern u16 sub_13824(struct Vector16*); -extern void sub_13934(struct Vector16*, struct Vector16*, u16); extern void sub_13B28(struct Vector16*, struct Vector16*, s16); extern void sub_13D24(u16, struct Vector16*, struct Vector16*); //extern ? sub_14074(); diff --git a/include/global.h b/include/global.h index 6225dbe..7e733ca 100644 --- a/include/global.h +++ b/include/global.h @@ -174,9 +174,9 @@ struct PinballGame /*0x121*/ s8 unk121; /*0x122*/ s8 unk122; /*0x123*/ s8 unk123; - /*0x124*/ u8 unk124; - /*0x125*/ u8 unk125; - /*0x126*/ u8 filler126[0x1]; + /*0x124*/ s8 unk124; + /*0x125*/ s8 unk125; + /*0x126*/ s8 unk126; /*0x127*/ s8 unk127; /*0x128*/ u8 filler128[0x3]; /*0x12B*/ s8 forceSpecialMons; // When on, force next catch mode species to be special mons diff --git a/src/rom_1332C.c b/src/rom_1332C.c index 16e4755..8d5e144 100644 --- a/src/rom_1332C.c +++ b/src/rom_1332C.c @@ -1,19 +1,13 @@ #include "global.h" + u16 sub_13824(struct Vector16*); - void sub_13D24(u16,struct Vector16*, struct Vector16*); - -void sub_13934(struct Vector16*,struct Vector16*,u16); - -void sub_13B28(struct Vector16*, struct Vector16*, s16); - +void sub_13934(struct Vector16 *arg0, struct Vector16 *arg1, u16 angle); void sub_1493C(void); - u16 sub_14488(struct Vector16*, struct Vector16); void sub_1332C() - { gCurrentPinballGame->unk26 = 60; } @@ -193,3 +187,65 @@ u16 sub_13824(struct Vector16* param) } return retVal; } + +void sub_13934(struct Vector16 *arg0, struct Vector16 *arg1, u16 angle) +{ + s16 cos; + + arg1->x = 0; + arg1->y = 0; + if (gCurrentPinballGame->unk122) + { + arg0->x -= gCurrentPinballGame->unk124; + if (gCurrentPinballGame->unk122 > 0) + { + cos = Cos(angle); + if (cos < 0) + { + arg1->x = (Cos(angle) * 70) / 20000; + gCurrentPinballGame->unk126 = 1; + } + } + else if (gCurrentPinballGame->unk122 < 0) + { + cos = Cos(angle); + if (cos > 0) + { + arg1->x = (Cos(angle) * 70) / 20000; + gCurrentPinballGame->unk126 = 1; + } + } + } + + if (gCurrentPinballGame->unk123 > 0) + { + arg0->y -= gCurrentPinballGame->unk125; + if (gCurrentPinballGame->unk132c->unk10.y > 364) + { + if (gCurrentPinballGame->unk122 == 0) + arg1->y = -(Sin(angle) * 130) / 20000; + else + arg1->y = -(Sin(angle) * 100) / 20000; + } + else + { + if (gCurrentPinballGame->unk122 == 0) + arg1->y = -(Sin(angle) * 100) / 20000; + else + arg1->y = -(Sin(angle) * 75) / 20000; + + if (arg1->y >= 90) + gCurrentPinballGame->unk132c->velocity.x /= 4; + else if (arg1->y >= 70) + gCurrentPinballGame->unk132c->velocity.x /= 4; + } + + gCurrentPinballGame->unk126 = 1; + } + + if (gCurrentPinballGame->unk126) + { + gCurrentPinballGame->unk122 = 0; + gCurrentPinballGame->unk123 = 0; + } +}