From 5d4f161d4338f754c6d00956ddf504caa9a5c226 Mon Sep 17 00:00:00 2001 From: Pheenoh Date: Thu, 29 Dec 2022 17:30:35 -0700 Subject: [PATCH 1/2] f_op_msg_mng 19/20 matched (#227) --- .../createTimerAppend__FiUlUcUcffffUi.s | 66 ---- .../f_op_msg_mng/fopMsgM_Create__FsPFPv_iPv.s | 21 -- .../fopMsgM_messageSetDemo__FUl.s | 68 ----- .../fopMsgM_messageSet__FUlP10fopAc_ac_cUl.s | 92 ------ .../f_op_msg_mng/fopMsgM_messageSet__FUlUl.s | 86 ------ include/d/com/d_com_inf_game.h | 10 + include/d/msg/d_msg_object.h | 4 +- src/f_op/f_op_msg_mng.cpp | 286 ++++++++++++------ tools/package_game_assets.py | 4 +- tools/requirements.txt | 2 +- 10 files changed, 215 insertions(+), 424 deletions(-) delete mode 100644 asm/f_op/f_op_msg_mng/createTimerAppend__FiUlUcUcffffUi.s delete mode 100644 asm/f_op/f_op_msg_mng/fopMsgM_Create__FsPFPv_iPv.s delete mode 100644 asm/f_op/f_op_msg_mng/fopMsgM_messageSetDemo__FUl.s delete mode 100644 asm/f_op/f_op_msg_mng/fopMsgM_messageSet__FUlP10fopAc_ac_cUl.s delete mode 100644 asm/f_op/f_op_msg_mng/fopMsgM_messageSet__FUlUl.s diff --git a/asm/f_op/f_op_msg_mng/createTimerAppend__FiUlUcUcffffUi.s b/asm/f_op/f_op_msg_mng/createTimerAppend__FiUlUcUcffffUi.s deleted file mode 100644 index bda141af459..00000000000 --- a/asm/f_op/f_op_msg_mng/createTimerAppend__FiUlUcUcffffUi.s +++ /dev/null @@ -1,66 +0,0 @@ -lbl_8001FB50: -/* 8001FB50 94 21 FF 90 */ stwu r1, -0x70(r1) -/* 8001FB54 7C 08 02 A6 */ mflr r0 -/* 8001FB58 90 01 00 74 */ stw r0, 0x74(r1) -/* 8001FB5C DB E1 00 60 */ stfd f31, 0x60(r1) -/* 8001FB60 F3 E1 00 68 */ psq_st f31, 104(r1), 0, 0 /* qr0 */ -/* 8001FB64 DB C1 00 50 */ stfd f30, 0x50(r1) -/* 8001FB68 F3 C1 00 58 */ psq_st f30, 88(r1), 0, 0 /* qr0 */ -/* 8001FB6C DB A1 00 40 */ stfd f29, 0x40(r1) -/* 8001FB70 F3 A1 00 48 */ psq_st f29, 72(r1), 0, 0 /* qr0 */ -/* 8001FB74 DB 81 00 30 */ stfd f28, 0x30(r1) -/* 8001FB78 F3 81 00 38 */ psq_st f28, 56(r1), 0, 0 /* qr0 */ -/* 8001FB7C 39 61 00 30 */ addi r11, r1, 0x30 -/* 8001FB80 48 34 26 55 */ bl _savegpr_27 -/* 8001FB84 7C 7B 1B 78 */ mr r27, r3 -/* 8001FB88 7C 9C 23 78 */ mr r28, r4 -/* 8001FB8C 7C BD 2B 78 */ mr r29, r5 -/* 8001FB90 7C DE 33 78 */ mr r30, r6 -/* 8001FB94 FF 80 08 90 */ fmr f28, f1 -/* 8001FB98 FF A0 10 90 */ fmr f29, f2 -/* 8001FB9C FF C0 18 90 */ fmr f30, f3 -/* 8001FBA0 FF E0 20 90 */ fmr f31, f4 -/* 8001FBA4 7C FF 3B 78 */ mr r31, r7 -/* 8001FBA8 38 60 FF FC */ li r3, -4 -/* 8001FBAC 38 80 00 38 */ li r4, 0x38 -/* 8001FBB0 48 24 36 79 */ bl memalignB__3cMlFiUl -/* 8001FBB4 28 03 00 00 */ cmplwi r3, 0 -/* 8001FBB8 40 82 00 0C */ bne lbl_8001FBC4 -/* 8001FBBC 38 60 00 00 */ li r3, 0 -/* 8001FBC0 48 00 00 54 */ b lbl_8001FC14 -lbl_8001FBC4: -/* 8001FBC4 38 00 00 00 */ li r0, 0 -/* 8001FBC8 90 03 00 00 */ stw r0, 0(r3) -/* 8001FBCC 90 03 00 10 */ stw r0, 0x10(r3) -/* 8001FBD0 90 03 00 14 */ stw r0, 0x14(r3) -/* 8001FBD4 C0 02 82 70 */ lfs f0, lit_3902(r2) -/* 8001FBD8 D0 01 00 08 */ stfs f0, 8(r1) -/* 8001FBDC D0 01 00 0C */ stfs f0, 0xc(r1) -/* 8001FBE0 D0 01 00 10 */ stfs f0, 0x10(r1) -/* 8001FBE4 D0 03 00 04 */ stfs f0, 4(r3) -/* 8001FBE8 D0 03 00 08 */ stfs f0, 8(r3) -/* 8001FBEC D0 03 00 0C */ stfs f0, 0xc(r3) -/* 8001FBF0 93 E3 00 18 */ stw r31, 0x18(r3) -/* 8001FBF4 93 63 00 1C */ stw r27, 0x1c(r3) -/* 8001FBF8 93 83 00 20 */ stw r28, 0x20(r3) -/* 8001FBFC 9B A3 00 24 */ stb r29, 0x24(r3) -/* 8001FC00 9B C3 00 25 */ stb r30, 0x25(r3) -/* 8001FC04 D3 83 00 28 */ stfs f28, 0x28(r3) -/* 8001FC08 D3 A3 00 2C */ stfs f29, 0x2c(r3) -/* 8001FC0C D3 C3 00 30 */ stfs f30, 0x30(r3) -/* 8001FC10 D3 E3 00 34 */ stfs f31, 0x34(r3) -lbl_8001FC14: -/* 8001FC14 E3 E1 00 68 */ psq_l f31, 104(r1), 0, 0 /* qr0 */ -/* 8001FC18 CB E1 00 60 */ lfd f31, 0x60(r1) -/* 8001FC1C E3 C1 00 58 */ psq_l f30, 88(r1), 0, 0 /* qr0 */ -/* 8001FC20 CB C1 00 50 */ lfd f30, 0x50(r1) -/* 8001FC24 E3 A1 00 48 */ psq_l f29, 72(r1), 0, 0 /* qr0 */ -/* 8001FC28 CB A1 00 40 */ lfd f29, 0x40(r1) -/* 8001FC2C E3 81 00 38 */ psq_l f28, 56(r1), 0, 0 /* qr0 */ -/* 8001FC30 CB 81 00 30 */ lfd f28, 0x30(r1) -/* 8001FC34 39 61 00 30 */ addi r11, r1, 0x30 -/* 8001FC38 48 34 25 E9 */ bl _restgpr_27 -/* 8001FC3C 80 01 00 74 */ lwz r0, 0x74(r1) -/* 8001FC40 7C 08 03 A6 */ mtlr r0 -/* 8001FC44 38 21 00 70 */ addi r1, r1, 0x70 -/* 8001FC48 4E 80 00 20 */ blr diff --git a/asm/f_op/f_op_msg_mng/fopMsgM_Create__FsPFPv_iPv.s b/asm/f_op/f_op_msg_mng/fopMsgM_Create__FsPFPv_iPv.s deleted file mode 100644 index a7e38f98350..00000000000 --- a/asm/f_op/f_op_msg_mng/fopMsgM_Create__FsPFPv_iPv.s +++ /dev/null @@ -1,21 +0,0 @@ -lbl_80020108: -/* 80020108 94 21 FF E0 */ stwu r1, -0x20(r1) -/* 8002010C 7C 08 02 A6 */ mflr r0 -/* 80020110 90 01 00 24 */ stw r0, 0x24(r1) -/* 80020114 39 61 00 20 */ addi r11, r1, 0x20 -/* 80020118 48 34 20 C5 */ bl _savegpr_29 -/* 8002011C 7C 7D 1B 78 */ mr r29, r3 -/* 80020120 7C 9E 23 78 */ mr r30, r4 -/* 80020124 7C BF 2B 78 */ mr r31, r5 -/* 80020128 48 00 15 CD */ bl fpcLy_CurrentLayer__Fv -/* 8002012C 7F A4 EB 78 */ mr r4, r29 -/* 80020130 7F C5 F3 78 */ mr r5, r30 -/* 80020134 38 C0 00 00 */ li r6, 0 -/* 80020138 7F E7 FB 78 */ mr r7, r31 -/* 8002013C 48 00 3C 59 */ bl fpcSCtRq_Request__FP11layer_classsPFPvPv_iPvPv -/* 80020140 39 61 00 20 */ addi r11, r1, 0x20 -/* 80020144 48 34 20 E5 */ bl _restgpr_29 -/* 80020148 80 01 00 24 */ lwz r0, 0x24(r1) -/* 8002014C 7C 08 03 A6 */ mtlr r0 -/* 80020150 38 21 00 20 */ addi r1, r1, 0x20 -/* 80020154 4E 80 00 20 */ blr diff --git a/asm/f_op/f_op_msg_mng/fopMsgM_messageSetDemo__FUl.s b/asm/f_op/f_op_msg_mng/fopMsgM_messageSetDemo__FUl.s deleted file mode 100644 index 29797327275..00000000000 --- a/asm/f_op/f_op_msg_mng/fopMsgM_messageSetDemo__FUl.s +++ /dev/null @@ -1,68 +0,0 @@ -lbl_8001FFC4: -/* 8001FFC4 94 21 FF E0 */ stwu r1, -0x20(r1) -/* 8001FFC8 7C 08 02 A6 */ mflr r0 -/* 8001FFCC 90 01 00 24 */ stw r0, 0x24(r1) -/* 8001FFD0 93 E1 00 1C */ stw r31, 0x1c(r1) -/* 8001FFD4 93 C1 00 18 */ stw r30, 0x18(r1) -/* 8001FFD8 7C 7E 1B 78 */ mr r30, r3 -/* 8001FFDC 48 21 80 BD */ bl endFlowGroup__12dMsgObject_cFv -/* 8001FFE0 3C 60 80 40 */ lis r3, g_dComIfG_gameInfo@ha /* 0x804061C0@ha */ -/* 8001FFE4 3B E3 61 C0 */ addi r31, r3, g_dComIfG_gameInfo@l /* 0x804061C0@l */ -/* 8001FFE8 88 1F 5E 8F */ lbz r0, 0x5e8f(r31) -/* 8001FFEC 28 00 00 08 */ cmplwi r0, 8 -/* 8001FFF0 40 82 00 14 */ bne lbl_80020004 -/* 8001FFF4 3C 60 80 43 */ lis r3, g_meter2_info@ha /* 0x80430188@ha */ -/* 8001FFF8 38 63 01 88 */ addi r3, r3, g_meter2_info@l /* 0x80430188@l */ -/* 8001FFFC 80 63 00 1C */ lwz r3, 0x1c(r3) -/* 80020000 48 1F F6 ED */ bl emphasisButtonDelete__9dMeter2_cFv -lbl_80020004: -/* 80020004 88 1F 5E 8F */ lbz r0, 0x5e8f(r31) -/* 80020008 28 00 00 00 */ cmplwi r0, 0 -/* 8002000C 41 82 00 2C */ beq lbl_80020038 -/* 80020010 28 00 00 05 */ cmplwi r0, 5 -/* 80020014 41 82 00 24 */ beq lbl_80020038 -/* 80020018 28 00 00 02 */ cmplwi r0, 2 -/* 8002001C 41 82 00 1C */ beq lbl_80020038 -/* 80020020 28 00 00 03 */ cmplwi r0, 3 -/* 80020024 41 82 00 14 */ beq lbl_80020038 -/* 80020028 28 00 00 01 */ cmplwi r0, 1 -/* 8002002C 41 82 00 0C */ beq lbl_80020038 -/* 80020030 38 60 FF FF */ li r3, -1 -/* 80020034 48 00 00 74 */ b lbl_800200A8 -lbl_80020038: -/* 80020038 C0 02 82 70 */ lfs f0, lit_3902(r2) -/* 8002003C D0 01 00 10 */ stfs f0, 0x10(r1) -/* 80020040 D0 01 00 0C */ stfs f0, 0xc(r1) -/* 80020044 D0 01 00 08 */ stfs f0, 8(r1) -/* 80020048 80 6D 80 48 */ lwz r3, i_msgID(r13) -/* 8002004C 4B FF F9 D9 */ bl fopMsgM_SearchByID__FUi -/* 80020050 28 03 00 00 */ cmplwi r3, 0 -/* 80020054 41 82 00 50 */ beq lbl_800200A4 -/* 80020058 A0 03 00 F8 */ lhz r0, 0xf8(r3) -/* 8002005C 28 00 00 01 */ cmplwi r0, 1 -/* 80020060 40 82 00 44 */ bne lbl_800200A4 -/* 80020064 C0 01 00 08 */ lfs f0, 8(r1) -/* 80020068 D0 03 00 E0 */ stfs f0, 0xe0(r3) -/* 8002006C C0 01 00 0C */ lfs f0, 0xc(r1) -/* 80020070 D0 03 00 E4 */ stfs f0, 0xe4(r3) -/* 80020074 C0 01 00 10 */ lfs f0, 0x10(r1) -/* 80020078 D0 03 00 E8 */ stfs f0, 0xe8(r3) -/* 8002007C 93 C3 00 EC */ stw r30, 0xec(r3) -/* 80020080 38 00 03 E8 */ li r0, 0x3e8 -/* 80020084 90 03 00 F0 */ stw r0, 0xf0(r3) -/* 80020088 38 00 00 00 */ li r0, 0 -/* 8002008C 90 03 00 DC */ stw r0, 0xdc(r3) -/* 80020090 7F C4 F3 78 */ mr r4, r30 -/* 80020094 38 A0 00 00 */ li r5, 0 -/* 80020098 48 21 3D D9 */ bl setMessageIndexDemo__12dMsgObject_cFUlb -/* 8002009C 80 6D 80 48 */ lwz r3, i_msgID(r13) -/* 800200A0 48 00 00 08 */ b lbl_800200A8 -lbl_800200A4: -/* 800200A4 38 60 00 00 */ li r3, 0 -lbl_800200A8: -/* 800200A8 83 E1 00 1C */ lwz r31, 0x1c(r1) -/* 800200AC 83 C1 00 18 */ lwz r30, 0x18(r1) -/* 800200B0 80 01 00 24 */ lwz r0, 0x24(r1) -/* 800200B4 7C 08 03 A6 */ mtlr r0 -/* 800200B8 38 21 00 20 */ addi r1, r1, 0x20 -/* 800200BC 4E 80 00 20 */ blr diff --git a/asm/f_op/f_op_msg_mng/fopMsgM_messageSet__FUlP10fopAc_ac_cUl.s b/asm/f_op/f_op_msg_mng/fopMsgM_messageSet__FUlP10fopAc_ac_cUl.s deleted file mode 100644 index 17862926300..00000000000 --- a/asm/f_op/f_op_msg_mng/fopMsgM_messageSet__FUlP10fopAc_ac_cUl.s +++ /dev/null @@ -1,92 +0,0 @@ -lbl_8001FD34: -/* 8001FD34 94 21 FF D0 */ stwu r1, -0x30(r1) -/* 8001FD38 7C 08 02 A6 */ mflr r0 -/* 8001FD3C 90 01 00 34 */ stw r0, 0x34(r1) -/* 8001FD40 39 61 00 30 */ addi r11, r1, 0x30 -/* 8001FD44 48 34 24 95 */ bl _savegpr_28 -/* 8001FD48 7C 7C 1B 78 */ mr r28, r3 -/* 8001FD4C 7C 9D 23 78 */ mr r29, r4 -/* 8001FD50 7C BE 2B 78 */ mr r30, r5 -/* 8001FD54 3C 60 80 40 */ lis r3, g_dComIfG_gameInfo@ha /* 0x804061C0@ha */ -/* 8001FD58 3B E3 61 C0 */ addi r31, r3, g_dComIfG_gameInfo@l /* 0x804061C0@l */ -/* 8001FD5C 88 1F 5E 8F */ lbz r0, 0x5e8f(r31) -/* 8001FD60 28 00 00 08 */ cmplwi r0, 8 -/* 8001FD64 40 82 00 14 */ bne lbl_8001FD78 -/* 8001FD68 3C 60 80 43 */ lis r3, g_meter2_info@ha /* 0x80430188@ha */ -/* 8001FD6C 38 63 01 88 */ addi r3, r3, g_meter2_info@l /* 0x80430188@l */ -/* 8001FD70 80 63 00 1C */ lwz r3, 0x1c(r3) -/* 8001FD74 48 1F F9 79 */ bl emphasisButtonDelete__9dMeter2_cFv -lbl_8001FD78: -/* 8001FD78 88 1F 5E 8F */ lbz r0, 0x5e8f(r31) -/* 8001FD7C 28 00 00 00 */ cmplwi r0, 0 -/* 8001FD80 41 82 00 2C */ beq lbl_8001FDAC -/* 8001FD84 28 00 00 05 */ cmplwi r0, 5 -/* 8001FD88 41 82 00 24 */ beq lbl_8001FDAC -/* 8001FD8C 28 00 00 02 */ cmplwi r0, 2 -/* 8001FD90 41 82 00 1C */ beq lbl_8001FDAC -/* 8001FD94 28 00 00 03 */ cmplwi r0, 3 -/* 8001FD98 41 82 00 14 */ beq lbl_8001FDAC -/* 8001FD9C 28 00 00 01 */ cmplwi r0, 1 -/* 8001FDA0 41 82 00 0C */ beq lbl_8001FDAC -/* 8001FDA4 38 60 FF FF */ li r3, -1 -/* 8001FDA8 48 00 00 C4 */ b lbl_8001FE6C -lbl_8001FDAC: -/* 8001FDAC 38 00 00 FF */ li r0, 0xff -/* 8001FDB0 3C 60 80 40 */ lis r3, g_dComIfG_gameInfo@ha /* 0x804061C0@ha */ -/* 8001FDB4 38 63 61 C0 */ addi r3, r3, g_dComIfG_gameInfo@l /* 0x804061C0@l */ -/* 8001FDB8 98 03 5E 7C */ stb r0, 0x5e7c(r3) -/* 8001FDBC 38 00 FF FF */ li r0, -1 -/* 8001FDC0 90 03 5E E8 */ stw r0, 0x5ee8(r3) -/* 8001FDC4 28 1D 00 00 */ cmplwi r29, 0 -/* 8001FDC8 41 82 00 20 */ beq lbl_8001FDE8 -/* 8001FDCC C0 1D 05 38 */ lfs f0, 0x538(r29) -/* 8001FDD0 D0 01 00 08 */ stfs f0, 8(r1) -/* 8001FDD4 C0 1D 05 3C */ lfs f0, 0x53c(r29) -/* 8001FDD8 D0 01 00 0C */ stfs f0, 0xc(r1) -/* 8001FDDC C0 1D 05 40 */ lfs f0, 0x540(r29) -/* 8001FDE0 D0 01 00 10 */ stfs f0, 0x10(r1) -/* 8001FDE4 48 00 00 14 */ b lbl_8001FDF8 -lbl_8001FDE8: -/* 8001FDE8 C0 02 82 70 */ lfs f0, lit_3902(r2) -/* 8001FDEC D0 01 00 08 */ stfs f0, 8(r1) -/* 8001FDF0 D0 01 00 0C */ stfs f0, 0xc(r1) -/* 8001FDF4 D0 01 00 10 */ stfs f0, 0x10(r1) -lbl_8001FDF8: -/* 8001FDF8 3C 60 80 43 */ lis r3, g_MsgObject_HIO_c@ha /* 0x8043028C@ha */ -/* 8001FDFC 38 63 02 8C */ addi r3, r3, g_MsgObject_HIO_c@l /* 0x8043028C@l */ -/* 8001FE00 88 03 03 1F */ lbz r0, 0x31f(r3) -/* 8001FE04 28 00 00 01 */ cmplwi r0, 1 -/* 8001FE08 40 82 00 08 */ bne lbl_8001FE10 -/* 8001FE0C AB 83 02 F4 */ lha r28, 0x2f4(r3) -lbl_8001FE10: -/* 8001FE10 80 6D 80 48 */ lwz r3, i_msgID(r13) -/* 8001FE14 4B FF FC 11 */ bl fopMsgM_SearchByID__FUi -/* 8001FE18 28 03 00 00 */ cmplwi r3, 0 -/* 8001FE1C 41 82 00 4C */ beq lbl_8001FE68 -/* 8001FE20 A0 03 00 F8 */ lhz r0, 0xf8(r3) -/* 8001FE24 28 00 00 01 */ cmplwi r0, 1 -/* 8001FE28 40 82 00 40 */ bne lbl_8001FE68 -/* 8001FE2C C0 01 00 08 */ lfs f0, 8(r1) -/* 8001FE30 D0 03 00 E0 */ stfs f0, 0xe0(r3) -/* 8001FE34 C0 01 00 0C */ lfs f0, 0xc(r1) -/* 8001FE38 D0 03 00 E4 */ stfs f0, 0xe4(r3) -/* 8001FE3C C0 01 00 10 */ lfs f0, 0x10(r1) -/* 8001FE40 D0 03 00 E8 */ stfs f0, 0xe8(r3) -/* 8001FE44 93 83 00 EC */ stw r28, 0xec(r3) -/* 8001FE48 93 C3 00 F0 */ stw r30, 0xf0(r3) -/* 8001FE4C 93 A3 00 DC */ stw r29, 0xdc(r3) -/* 8001FE50 7F 84 E3 78 */ mr r4, r28 -/* 8001FE54 7F C5 F3 78 */ mr r5, r30 -/* 8001FE58 38 C0 00 00 */ li r6, 0 -/* 8001FE5C 48 21 3E A9 */ bl setMessageIndex__12dMsgObject_cFUlUlb -/* 8001FE60 80 6D 80 48 */ lwz r3, i_msgID(r13) -/* 8001FE64 48 00 00 08 */ b lbl_8001FE6C -lbl_8001FE68: -/* 8001FE68 38 60 00 00 */ li r3, 0 -lbl_8001FE6C: -/* 8001FE6C 39 61 00 30 */ addi r11, r1, 0x30 -/* 8001FE70 48 34 23 B5 */ bl _restgpr_28 -/* 8001FE74 80 01 00 34 */ lwz r0, 0x34(r1) -/* 8001FE78 7C 08 03 A6 */ mtlr r0 -/* 8001FE7C 38 21 00 30 */ addi r1, r1, 0x30 -/* 8001FE80 4E 80 00 20 */ blr diff --git a/asm/f_op/f_op_msg_mng/fopMsgM_messageSet__FUlUl.s b/asm/f_op/f_op_msg_mng/fopMsgM_messageSet__FUlUl.s deleted file mode 100644 index b8f008de04e..00000000000 --- a/asm/f_op/f_op_msg_mng/fopMsgM_messageSet__FUlUl.s +++ /dev/null @@ -1,86 +0,0 @@ -lbl_8001FE84: -/* 8001FE84 94 21 FF D0 */ stwu r1, -0x30(r1) -/* 8001FE88 7C 08 02 A6 */ mflr r0 -/* 8001FE8C 90 01 00 34 */ stw r0, 0x34(r1) -/* 8001FE90 39 61 00 30 */ addi r11, r1, 0x30 -/* 8001FE94 48 34 23 49 */ bl _savegpr_29 -/* 8001FE98 7C 7D 1B 78 */ mr r29, r3 -/* 8001FE9C 7C 9E 23 78 */ mr r30, r4 -/* 8001FEA0 3C 60 80 40 */ lis r3, g_dComIfG_gameInfo@ha /* 0x804061C0@ha */ -/* 8001FEA4 3B E3 61 C0 */ addi r31, r3, g_dComIfG_gameInfo@l /* 0x804061C0@l */ -/* 8001FEA8 88 1F 5E 8F */ lbz r0, 0x5e8f(r31) -/* 8001FEAC 28 00 00 08 */ cmplwi r0, 8 -/* 8001FEB0 40 82 00 14 */ bne lbl_8001FEC4 -/* 8001FEB4 3C 60 80 43 */ lis r3, g_meter2_info@ha /* 0x80430188@ha */ -/* 8001FEB8 38 63 01 88 */ addi r3, r3, g_meter2_info@l /* 0x80430188@l */ -/* 8001FEBC 80 63 00 1C */ lwz r3, 0x1c(r3) -/* 8001FEC0 48 1F F8 2D */ bl emphasisButtonDelete__9dMeter2_cFv -lbl_8001FEC4: -/* 8001FEC4 88 1F 5E 8F */ lbz r0, 0x5e8f(r31) -/* 8001FEC8 28 00 00 00 */ cmplwi r0, 0 -/* 8001FECC 41 82 00 2C */ beq lbl_8001FEF8 -/* 8001FED0 28 00 00 05 */ cmplwi r0, 5 -/* 8001FED4 41 82 00 24 */ beq lbl_8001FEF8 -/* 8001FED8 28 00 00 02 */ cmplwi r0, 2 -/* 8001FEDC 41 82 00 1C */ beq lbl_8001FEF8 -/* 8001FEE0 28 00 00 03 */ cmplwi r0, 3 -/* 8001FEE4 41 82 00 14 */ beq lbl_8001FEF8 -/* 8001FEE8 28 00 00 01 */ cmplwi r0, 1 -/* 8001FEEC 41 82 00 0C */ beq lbl_8001FEF8 -/* 8001FEF0 38 60 FF FF */ li r3, -1 -/* 8001FEF4 48 00 00 B8 */ b lbl_8001FFAC -lbl_8001FEF8: -/* 8001FEF8 C0 02 82 70 */ lfs f0, lit_3902(r2) -/* 8001FEFC D0 01 00 10 */ stfs f0, 0x10(r1) -/* 8001FF00 D0 01 00 0C */ stfs f0, 0xc(r1) -/* 8001FF04 D0 01 00 08 */ stfs f0, 8(r1) -/* 8001FF08 80 6D 80 48 */ lwz r3, i_msgID(r13) -/* 8001FF0C 4B FF FB 19 */ bl fopMsgM_SearchByID__FUi -/* 8001FF10 7C 7F 1B 79 */ or. r31, r3, r3 -/* 8001FF14 41 82 00 94 */ beq lbl_8001FFA8 -/* 8001FF18 A0 1F 00 F8 */ lhz r0, 0xf8(r31) -/* 8001FF1C 28 00 00 01 */ cmplwi r0, 1 -/* 8001FF20 40 82 00 50 */ bne lbl_8001FF70 -/* 8001FF24 C0 01 00 08 */ lfs f0, 8(r1) -/* 8001FF28 D0 1F 00 E0 */ stfs f0, 0xe0(r31) -/* 8001FF2C C0 01 00 0C */ lfs f0, 0xc(r1) -/* 8001FF30 D0 1F 00 E4 */ stfs f0, 0xe4(r31) -/* 8001FF34 C0 01 00 10 */ lfs f0, 0x10(r1) -/* 8001FF38 D0 1F 00 E8 */ stfs f0, 0xe8(r31) -/* 8001FF3C 93 BF 00 EC */ stw r29, 0xec(r31) -/* 8001FF40 93 DF 00 F0 */ stw r30, 0xf0(r31) -/* 8001FF44 38 00 00 00 */ li r0, 0 -/* 8001FF48 90 1F 00 DC */ stw r0, 0xdc(r31) -/* 8001FF4C 38 60 00 00 */ li r3, 0 -/* 8001FF50 48 21 7B 25 */ bl setTalkPartner__12dMsgObject_cFP10fopAc_ac_c -/* 8001FF54 7F E3 FB 78 */ mr r3, r31 -/* 8001FF58 7F A4 EB 78 */ mr r4, r29 -/* 8001FF5C 7F C5 F3 78 */ mr r5, r30 -/* 8001FF60 38 C0 00 00 */ li r6, 0 -/* 8001FF64 48 21 3D A1 */ bl setMessageIndex__12dMsgObject_cFUlUlb -/* 8001FF68 80 6D 80 48 */ lwz r3, i_msgID(r13) -/* 8001FF6C 48 00 00 40 */ b lbl_8001FFAC -lbl_8001FF70: -/* 8001FF70 28 00 00 0F */ cmplwi r0, 0xf -/* 8001FF74 40 82 00 34 */ bne lbl_8001FFA8 -/* 8001FF78 C0 01 00 08 */ lfs f0, 8(r1) -/* 8001FF7C D0 1F 00 E0 */ stfs f0, 0xe0(r31) -/* 8001FF80 C0 01 00 0C */ lfs f0, 0xc(r1) -/* 8001FF84 D0 1F 00 E4 */ stfs f0, 0xe4(r31) -/* 8001FF88 C0 01 00 10 */ lfs f0, 0x10(r1) -/* 8001FF8C D0 1F 00 E8 */ stfs f0, 0xe8(r31) -/* 8001FF90 93 BF 00 EC */ stw r29, 0xec(r31) -/* 8001FF94 93 DF 00 F0 */ stw r30, 0xf0(r31) -/* 8001FF98 38 00 00 00 */ li r0, 0 -/* 8001FF9C 90 1F 00 DC */ stw r0, 0xdc(r31) -/* 8001FFA0 80 6D 80 48 */ lwz r3, i_msgID(r13) -/* 8001FFA4 48 00 00 08 */ b lbl_8001FFAC -lbl_8001FFA8: -/* 8001FFA8 38 60 00 00 */ li r3, 0 -lbl_8001FFAC: -/* 8001FFAC 39 61 00 30 */ addi r11, r1, 0x30 -/* 8001FFB0 48 34 22 79 */ bl _restgpr_29 -/* 8001FFB4 80 01 00 34 */ lwz r0, 0x34(r1) -/* 8001FFB8 7C 08 03 A6 */ mtlr r0 -/* 8001FFBC 38 21 00 30 */ addi r1, r1, 0x30 -/* 8001FFC0 4E 80 00 20 */ blr diff --git a/include/d/com/d_com_inf_game.h b/include/d/com/d_com_inf_game.h index c38edee974a..93c13630630 100644 --- a/include/d/com/d_com_inf_game.h +++ b/include/d/com/d_com_inf_game.h @@ -287,6 +287,8 @@ public: s16 getItemMaxLifeCount() { return mItemMaxLifeCount; } f32 getItemLifeCount() { return mItemLifeCount; } s16 getItemMaxArrowNumCount() { return mItemMaxArrowNumCount; } + void clearNowAnimeID() { mNowAnimeID = -1; } + void clearMesgCamInfoID() { mMesgCamInfo = (void*)-1; } void clearItemMaxLifeCount() { mItemMaxLifeCount = 0; } void clearItemLifeCount() { mItemLifeCount = 0.0f; @@ -2568,6 +2570,14 @@ inline int dComIfG_setTimerNowTimeMs(int time) { g_dComIfG_gameInfo.play.setTimerNowTimeMs(time); } +inline void dComIfGp_clearMesgAnimeTagInfo() { + g_dComIfG_gameInfo.play.clearNowAnimeID(); +} + +inline void dComIfGp_clearMesgCameraTagInfo() { + g_dComIfG_gameInfo.play.clearMesgCamInfoID(); +} + inline u32 dComIfGp_particle_set(u32 param_0, u16 param_1, const cXyz* param_2, const dKy_tevstr_c* param_3, const csXyz* param_4, const cXyz* param_5, u8 param_6, dPa_levelEcallBack* param_7, diff --git a/include/d/msg/d_msg_object.h b/include/d/msg/d_msg_object.h index fedaa1cef26..45fe7786065 100644 --- a/include/d/msg/d_msg_object.h +++ b/include/d/msg/d_msg_object.h @@ -93,7 +93,7 @@ public: /* 80237994 */ static void onKillMessageFlag(); /* 802379AC */ static void setKillMessageFlag(); /* 802379D8 */ void setKillMessageFlagLocal(); - /* 80237A74 */ void setTalkPartner(fopAc_ac_c*); + /* 80237A74 */ static void setTalkPartner(fopAc_ac_c*); /* 80237A88 */ void setNowTalkFlowNo(s16); /* 80237A9C */ void getNowTalkFlowNo(); /* 80237AB0 */ void setDemoMessage(u32); @@ -460,7 +460,7 @@ public: /* 0x2EC */ f32 mPikariAnmSpeed; /* 0x2F0 */ u16 mPikariHaloDelay_spirit; /* 0x2F2 */ u8 mStageTitleDisplayType; - /* 0x2F4 */ u16 mMsgIndex; + /* 0x2F4 */ s16 mMsgIndex; /* 0x2F6 */ u16 mFlowIndex; /* 0x2F8 */ u16 mSaveSeqMsgIndex; /* 0x2FA */ u16 mSelWeightFrame; diff --git a/src/f_op/f_op_msg_mng.cpp b/src/f_op/f_op_msg_mng.cpp index 297feec8b40..a32943bbd8e 100644 --- a/src/f_op/f_op_msg_mng.cpp +++ b/src/f_op/f_op_msg_mng.cpp @@ -10,66 +10,21 @@ #include "d/msg/d_msg_object.h" #include "dol2asm.h" #include "dolphin/types.h" +#include "JSystem/JMath/JMath.h" +#include "SSystem/SComponent/c_math.h" // // Forward References: // -extern "C" void fopMsgM_setStageLayer__FPv(); -extern "C" void fopMsgM_SearchByID__FUi(); -extern "C" void fopMsgM_GetAppend__FPv(); -extern "C" void fopMsgM_Delete__FPv(); -extern "C" static void createAppend__FP10fopAc_ac_cP4cXyzPUlPUlUi(); -extern "C" static void createTimerAppend__FiUlUcUcffffUi(); -extern "C" void fopMsgM_create__FsP10fopAc_ac_cP4cXyzPUlPUlPFPv_i(); -extern "C" void fop_Timer_create__FsUcUlUcUcffffPFPv_i(); -extern "C" void fopMsgM_messageSet__FUlP10fopAc_ac_cUl(); -extern "C" void fopMsgM_messageSet__FUlUl(); -extern "C" void fopMsgM_messageSetDemo__FUl(); -extern "C" void fopMsgM_messageGet__FPcUl(); -extern "C" void fopMsgM_setMessageID__FUi(); -extern "C" void fopMsgM_Create__FsPFPv_iPv(); -extern "C" void setAlpha__7J2DPaneFUc(); extern "C" void fopMsgM_valueIncrease__FiiUc(); -extern "C" void setBlendRatio__10J2DPictureFff(); -extern "C" void append__10J2DPictureFPCcf(); -extern "C" void insert__10J2DPictureFPCcUcf(); -extern "C" void fopMsgM_createExpHeap__FUlP7JKRHeap(); -extern "C" void fopMsgM_destroyExpHeap__FP10JKRExpHeap(); +extern "C" extern dMsgObject_HIO_c g_MsgObject_HIO_c; // // External References: // -extern "C" void mDoExt_getGameHeap__Fv(); -extern "C" void fopScnM_SearchByID__FUi(); -extern "C" void fpcBs_Is_JustOfType__Fii(); -extern "C" void fpcEx_SearchByID__FUi(); -extern "C" void fpcLy_CurrentLayer__Fv(); -extern "C" void fpcM_Delete__FPv(); -extern "C" void fpcPi_Change__FP22process_priority_classUiUsUs(); -extern "C" void fpcSCtRq_Request__FP11layer_classsPFPvPv_iPvPv(); -extern "C" void getString__13dMeter2Info_cFUlPcP14JMSMesgEntry_c(); -extern "C" void emphasisButtonDelete__9dMeter2_cFv(); -extern "C" void setMessageIndex__12dMsgObject_cFUlUlb(); -extern "C" void setMessageIndexDemo__12dMsgObject_cFUlb(); -extern "C" void setTalkPartner__12dMsgObject_cFP10fopAc_ac_c(); -extern "C" void endFlowGroup__12dMsgObject_cFv(); -extern "C" void setTalkActor__12dMsgObject_cFP10fopAc_ac_c(); -extern "C" void memalignB__3cMlFiUl(); -extern "C" void destroy__7JKRHeapFv(); -extern "C" void create__10JKRExpHeapFUlP7JKRHeapb(); -extern "C" void _savegpr_26(); -extern "C" void _savegpr_27(); -extern "C" void _savegpr_28(); -extern "C" void _savegpr_29(); -extern "C" void _restgpr_26(); -extern "C" void _restgpr_27(); -extern "C" void _restgpr_28(); -extern "C" void _restgpr_29(); -extern "C" extern u8 g_MsgObject_HIO_c[1040]; extern "C" u8 sincosTable___5JMath[65536]; -extern "C" u8 mProcID__20dStage_roomControl_c[4]; // // Declarations: @@ -145,16 +100,33 @@ static fopMsg_prm_class* createAppend(fopAc_ac_c* param_0, cXyz* param_1, u32* p /* 8001FB50-8001FC4C 01A490 00FC+00 1/1 0/0 0/0 .text createTimerAppend__FiUlUcUcffffUi */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm fopMsg_prm_timer* createTimerAppend(int param_0, u32 param_1, u8 param_2, u8 param_3, - f32 param_4, f32 param_5, f32 param_6, f32 param_7, - unsigned int param_8) { - nofralloc -#include "asm/f_op/f_op_msg_mng/createTimerAppend__FiUlUcUcffffUi.s" +static fopMsg_prm_timer* createTimerAppend(int param_0, u32 param_1, u8 param_2, u8 param_3, + f32 param_4, f32 param_5, f32 param_6, f32 param_7, + unsigned int param_8) { + fopMsg_prm_timer* timer = (fopMsg_prm_timer*)cMl::memalignB(-4,0x38); + + if (timer == 0) { + timer = 0; + } else { + timer->field_0x0 = 0; + timer->field_0x10 = 0; + timer->field_0x14 = 0; + cXyz pos(FLOAT_LABEL(lit_3902),FLOAT_LABEL(lit_3902),FLOAT_LABEL(lit_3902)); + timer->field_0x4 = pos; + timer->field_0x18 = param_8; + timer->field_0x1c = param_0; + timer->field_0x20 = param_1; + timer->field_0x24 = param_2; + timer->field_0x25 = param_3; + timer->field_0x28 = param_4; + timer->field_0x2c = param_5; + timer->field_0x30 = param_6; + timer->field_0x34 = param_7; + } + + return timer; + } -#pragma pop /* 8001FC4C-8001FCC0 01A58C 0074+00 0/0 1/1 0/0 .text * fopMsgM_create__FsP10fopAc_ac_cP4cXyzPUlPUlPFPv_i */ @@ -185,37 +157,128 @@ s32 fop_Timer_create(s16 param_0, u8 param_1, u32 param_2, u8 param_3, u8 param_ /* ############################################################################################## */ /* 804505C8-804505D0 000048 0004+04 4/4 0/0 0/0 .sdata i_msgID */ -SECTION_SDATA static u32 i_msgID = 0xFFFFFFFF; +static u32 i_msgID = 0xFFFFFFFF; /* 8001FD34-8001FE84 01A674 0150+00 0/0 2/2 1/1 .text fopMsgM_messageSet__FUlP10fopAc_ac_cUl */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void fopMsgM_messageSet(u32 param_0, fopAc_ac_c* param_1, u32 param_2) { - nofralloc -#include "asm/f_op/f_op_msg_mng/fopMsgM_messageSet__FUlP10fopAc_ac_cUl.s" +int fopMsgM_messageSet(u32 i_msgIdx, fopAc_ac_c* i_actorP, u32 param_2) { + if (dComIfGp_isHeapLockFlag() == 8) { + dMeter2Info_getMeterClass()->emphasisButtonDelete(); + } + + if (dComIfGp_isHeapLockFlag() != 0 && dComIfGp_isHeapLockFlag() != 5 && + dComIfGp_isHeapLockFlag() != 2 && + dComIfGp_isHeapLockFlag() != 3 && + dComIfGp_isHeapLockFlag() != 1) { + return -1; + + } else { + dComIfGp_clearMesgAnimeTagInfo(); + dComIfGp_clearMesgCameraTagInfo(); + + cXyz pos; + if (i_actorP) { + pos = i_actorP->mEyePos; + } else { + pos.set(FLOAT_LABEL(lit_3902),FLOAT_LABEL(lit_3902),FLOAT_LABEL(lit_3902)); + } + + if (g_MsgObject_HIO_c.mMsgDebug == true) { + i_msgIdx = g_MsgObject_HIO_c.mMsgIndex; + } + + dMsgObject_c* msg = (dMsgObject_c*)fopMsgM_SearchByID(i_msgID); + + if (msg && msg->field_0xf8 == 1) { + msg->field_0xe0.set(pos); + msg->field_0xec = i_msgIdx; + msg->field_0xf0 = param_2; + msg->field_0xdc = i_actorP; + msg->setMessageIndex(i_msgIdx,param_2,false); + return i_msgID; + } else { + return 0; + } + } } -#pragma pop /* 8001FE84-8001FFC4 01A7C4 0140+00 0/0 6/6 4/4 .text fopMsgM_messageSet__FUlUl */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm int fopMsgM_messageSet(u32 param_0, u32 param_1) { - nofralloc -#include "asm/f_op/f_op_msg_mng/fopMsgM_messageSet__FUlUl.s" +int fopMsgM_messageSet(u32 param_0, u32 param_1) { + if (dComIfGp_isHeapLockFlag() == 8) { + dMeter2Info_getMeterClass()->emphasisButtonDelete(); + } + + if (dComIfGp_isHeapLockFlag() != 0 && dComIfGp_isHeapLockFlag() != 5 && + dComIfGp_isHeapLockFlag() != 2 && + dComIfGp_isHeapLockFlag() != 3 && + dComIfGp_isHeapLockFlag() != 1) { + return -1; + + } else { + + cXyz pos; + pos.z = FLOAT_LABEL(lit_3902); + pos.y = FLOAT_LABEL(lit_3902); + pos.x = FLOAT_LABEL(lit_3902); + + dMsgObject_c* msg = (dMsgObject_c*)fopMsgM_SearchByID(i_msgID); + + if (msg) { + if (msg->field_0xf8 == 1) { + msg->field_0xe0.set(pos); + msg->field_0xec = param_0; + msg->field_0xf0 = param_1; + msg->field_0xdc = 0; + msg->setTalkPartner(0); + msg->setMessageIndex(param_0,param_1,false); + return i_msgID; + } + + if (msg->field_0xf8 == 15) { + msg->field_0xe0.set(pos); + msg->field_0xec = param_0; + msg->field_0xf0 = param_1; + msg->field_0xdc = 0; + return i_msgID; + } + } + + return 0; + } } -#pragma pop /* 8001FFC4-800200C0 01A904 00FC+00 0/0 1/1 13/13 .text fopMsgM_messageSetDemo__FUl */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm int fopMsgM_messageSetDemo(u32 param_0) { - nofralloc -#include "asm/f_op/f_op_msg_mng/fopMsgM_messageSetDemo__FUl.s" +int fopMsgM_messageSetDemo(u32 param_0) { + dMsgObject_endFlowGroup(); + if (dComIfGp_isHeapLockFlag() == 8) { + dMeter2Info_getMeterClass()->emphasisButtonDelete(); + } + + if (dComIfGp_isHeapLockFlag() != 0 && dComIfGp_isHeapLockFlag() != 5 && + dComIfGp_isHeapLockFlag() != 2 && + dComIfGp_isHeapLockFlag() != 3 && + dComIfGp_isHeapLockFlag() != 1) { + return -1; + + } else { + cXyz pos; + pos.z = FLOAT_LABEL(lit_3902); + pos.y = FLOAT_LABEL(lit_3902); + pos.x = FLOAT_LABEL(lit_3902); + + dMsgObject_c* msg = (dMsgObject_c*)fopMsgM_SearchByID(i_msgID); + + if (msg && msg->field_0xf8 == 1) { + msg->field_0xe0.set(pos); + msg->field_0xec = param_0; + msg->field_0xf0 = 1000; + msg->field_0xdc = 0; + msg->setMessageIndexDemo(param_0,false); + return i_msgID; + } else { + return 0; + } + } } -#pragma pop /* 800200C0-80020100 01AA00 0040+00 0/0 7/7 1/1 .text fopMsgM_messageGet__FPcUl */ char* fopMsgM_messageGet(char* msg, u32 string_id) { @@ -229,14 +292,9 @@ void fopMsgM_setMessageID(unsigned int msg_id) { } /* 80020108-80020158 01AA48 0050+00 0/0 2/2 0/0 .text fopMsgM_Create__FsPFPv_iPv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm u32 fopMsgM_Create(s16 param_0, int (*param_1)(void*), void* param_2) { - nofralloc -#include "asm/f_op/f_op_msg_mng/fopMsgM_Create__FsPFPv_iPv.s" +u32 fopMsgM_Create(s16 param_0, int (*param_1)(void*), void* param_2) { + fpcM_Create(param_0,param_1,param_2); } -#pragma pop /* 80020158-80020160 -00001 0008+00 0/0 0/0 0/0 .text setAlpha__7J2DPaneFUc */ void J2DPane::setAlpha(u8 alpha) { @@ -276,6 +334,61 @@ SECTION_SDATA2 static f32 lit_4301 = 65535.0f; SECTION_SDATA2 static f64 lit_4303 = 4503601774854144.0 /* cast s32 to float */; /* 80020160-800202CC 01AAA0 016C+00 1/0 4/4 2/2 .text fopMsgM_valueIncrease__FiiUc */ +#ifdef NONMATCHING +// regalloc + something up with case 2 +f64 fopMsgM_valueIncrease(int param_0, int param_1, u8 param_2) { + f32 ret; + + if (param_0 <= 0) { + return FLOAT_LABEL(lit_4298); + } else { + if (param_1 < 0) { + param_1 = 0; + } else if (param_1 > param_0) { + param_1 = param_0; + } + + ret = param_1; + f32 out_tmp = ret / param_0; + + switch(param_2) { + case 0: { + ret = out_tmp * out_tmp; + break; + } + case 1: { + ret = JMAFastSqrt(out_tmp); + break; + } + case 2: { // seems like this should be default case, but it causes other issues + ret = out_tmp; + break; + } + case 3: { + f32 tmp = (FLOAT_LABEL(lit_4299) * out_tmp) - FLOAT_LABEL(lit_4298); + tmp = out_tmp * tmp; + ret = tmp - FLOAT_LABEL(lit_4298); + break; + } + case 4: { + f32 tmp = cM_ssin(FLOAT_LABEL(lit_4167) * (FLOAT_LABEL(lit_4300) * out_tmp)); + ret = tmp * tmp; + break; + } + case 5: { + f32 tmp = cM_ssin(FLOAT_LABEL(lit_4167) * (FLOAT_LABEL(lit_4301) * out_tmp)); + ret = tmp * tmp; + break; + } + case 6: { + ret = cM_ssin(FLOAT_LABEL(lit_4300) * out_tmp); + } + } + } + + return ret; +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -284,6 +397,7 @@ asm void fopMsgM_valueIncrease(int param_0, int param_1, u8 param_2) { #include "asm/f_op/f_op_msg_mng/fopMsgM_valueIncrease__FiiUc.s" } #pragma pop +#endif /* 800202CC-80020338 01AC0C 006C+00 0/0 2/0 0/0 .text setBlendRatio__10J2DPictureFff */ void J2DPicture::setBlendRatio(f32 param_0, f32 param_1) { diff --git a/tools/package_game_assets.py b/tools/package_game_assets.py index 20bcf18f224..0f88ca2ecec 100644 --- a/tools/package_game_assets.py +++ b/tools/package_game_assets.py @@ -224,7 +224,7 @@ def addFile(index,sizeIndex,dirs,name,stringTable,paths,data): path = relPath file.unk1 = 0 fileData = open(path,"rb") - compressedData = syaz0.compress(fileData.read()) + compressedData = oead.yaz0.compress(fileData.read()) padding = (0x20-(len(compressedData)%0x20)) file.fileLength = len(compressedData) file.fileOffset = sizeIndex @@ -255,7 +255,7 @@ def copyRelFiles(buildPath,aMemList,mMemList): relSource = open(fullPath,"rb") data = relSource.read() relSource.close() - data = syaz0.compress(data) + data = oead.yaz0.compress(data) relNew = open(buildPath/"game/files/rel/Final/Release"/file,"wb") relNew.write(data) relNew.truncate() diff --git a/tools/requirements.txt b/tools/requirements.txt index 12119dbe8f3..3bd1bb7a620 100644 --- a/tools/requirements.txt +++ b/tools/requirements.txt @@ -8,5 +8,5 @@ ansiwrap watchdog python-Levenshtein cxxfilt -syaz0 +oead pyelftools \ No newline at end of file From 463348bfc7f2360d9bb0a6205b8aa4602c8c03d0 Mon Sep 17 00:00:00 2001 From: jdflyer Date: Fri, 30 Dec 2022 16:19:57 -0700 Subject: [PATCH 2/2] JAudio2 Work (#228) --- Makefile | 5 +- asm/JSystem/JAudio2/JAISound/func_802A2474.s | 28 --- ...reasePrepareCount_JAISound___8JAISoundFv.s | 21 --- ...nitTrack_JAISound___8JAISoundFP8JASTrack.s | 59 ------- .../JAudio2/JAISound/stop__8JAISoundFv.s | 17 -- .../calc__15JASAudioReseterFv.s | 59 ------- .../start__15JASAudioReseterFUlb.s | 43 ----- .../JAudio2/dspproc/setup_callback__FUs.s | 4 - include/JSystem/JAudio2/JAIAudible.h | 3 +- include/JSystem/JAudio2/JAIAudience.h | 4 +- include/JSystem/JAudio2/JAISound.h | 126 +++++++++++-- include/JSystem/JAudio2/JAISoundHandles.h | 2 +- include/JSystem/JAudio2/JAISoundParams.h | 6 +- include/JSystem/JAudio2/JASAudioReseter.h | 9 +- include/JSystem/JAudio2/JASAudioThread.h | 12 ++ include/JSystem/JAudio2/JASGadget.h | 14 +- include/JSystem/JAudio2/JASReport.h | 2 + include/JSystem/JAudio2/dspproc.h | 1 + include/Z2AudioLib/Z2Audience.h | 4 +- include/Z2AudioLib/Z2WolfHowlMgr.h | 45 ++--- include/dolphin/dsp/dsp.h | 6 + include/m_Do/m_Do_audio.h | 12 +- libs/JSystem/JAudio2/JAISound.cpp | 167 +++++++++++------- libs/JSystem/JAudio2/JASAudioReseter.cpp | 78 ++++---- libs/JSystem/JAudio2/JASAudioThread.cpp | 12 -- libs/JSystem/JAudio2/dspproc.cpp | 61 +++++-- libs/Z2AudioLib/Z2Audience.cpp | 4 +- libs/Z2AudioLib/Z2SceneMgr.cpp | 14 +- libs/Z2AudioLib/Z2WolfHowlMgr.cpp | 49 ++++- src/m_Do/m_Do_main.cpp | 3 + 30 files changed, 429 insertions(+), 441 deletions(-) delete mode 100644 asm/JSystem/JAudio2/JAISound/func_802A2474.s delete mode 100644 asm/JSystem/JAudio2/JAISound/increasePrepareCount_JAISound___8JAISoundFv.s delete mode 100644 asm/JSystem/JAudio2/JAISound/initTrack_JAISound___8JAISoundFP8JASTrack.s delete mode 100644 asm/JSystem/JAudio2/JAISound/stop__8JAISoundFv.s delete mode 100644 asm/JSystem/JAudio2/JASAudioReseter/calc__15JASAudioReseterFv.s delete mode 100644 asm/JSystem/JAudio2/JASAudioReseter/start__15JASAudioReseterFUlb.s delete mode 100644 asm/JSystem/JAudio2/dspproc/setup_callback__FUs.s diff --git a/Makefile b/Makefile index 29a48139249..1929850be58 100644 --- a/Makefile +++ b/Makefile @@ -45,11 +45,13 @@ include obj_files.mk MWCC_VERSION := 2.7 # Programs +ifeq ($(WINE),) #if WINE varible is unset (wine can be replaced with a less bloated translation layer such as wibo if needed) ifeq ($(WINDOWS),1) WINE := else WINE := wine endif +endif # Hack for OSX ifeq ($(UNAME_S),Darwin) @@ -168,7 +170,8 @@ $(DOL_SHIFT): $(ELF_SHIFT) | tools shift: dirs $(DOL_SHIFT) -game: | shift rels +game: shift + $(MAKE) rels @mkdir -p game @$(PYTHON) tools/package_game_assets.py game $(BUILD_DIR) diff --git a/asm/JSystem/JAudio2/JAISound/func_802A2474.s b/asm/JSystem/JAudio2/JAISound/func_802A2474.s deleted file mode 100644 index b677eb5c103..00000000000 --- a/asm/JSystem/JAudio2/JAISound/func_802A2474.s +++ /dev/null @@ -1,28 +0,0 @@ -lbl_802A2474: -/* 802A2474 94 21 FF E0 */ stwu r1, -0x20(r1) -/* 802A2478 7C 08 02 A6 */ mflr r0 -/* 802A247C 90 01 00 24 */ stw r0, 0x24(r1) -/* 802A2480 93 E1 00 1C */ stw r31, 0x1c(r1) -/* 802A2484 7C 7F 1B 78 */ mr r31, r3 -/* 802A2488 7C A9 2B 78 */ mr r9, r5 -/* 802A248C 7C C8 33 78 */ mr r8, r6 -/* 802A2490 28 07 00 00 */ cmplwi r7, 0 -/* 802A2494 41 82 00 08 */ beq lbl_802A249C -/* 802A2498 90 FF 00 0C */ stw r7, 0xc(r31) -lbl_802A249C: -/* 802A249C 80 1F 00 18 */ lwz r0, 0x18(r31) -/* 802A24A0 90 01 00 08 */ stw r0, 8(r1) -/* 802A24A4 80 7F 00 0C */ lwz r3, 0xc(r31) -/* 802A24A8 38 A1 00 08 */ addi r5, r1, 8 -/* 802A24AC 7D 26 4B 78 */ mr r6, r9 -/* 802A24B0 7D 07 43 78 */ mr r7, r8 -/* 802A24B4 81 83 00 00 */ lwz r12, 0(r3) -/* 802A24B8 81 8C 00 0C */ lwz r12, 0xc(r12) -/* 802A24BC 7D 89 03 A6 */ mtctr r12 -/* 802A24C0 4E 80 04 21 */ bctrl -/* 802A24C4 90 7F 00 08 */ stw r3, 8(r31) -/* 802A24C8 83 E1 00 1C */ lwz r31, 0x1c(r1) -/* 802A24CC 80 01 00 24 */ lwz r0, 0x24(r1) -/* 802A24D0 7C 08 03 A6 */ mtlr r0 -/* 802A24D4 38 21 00 20 */ addi r1, r1, 0x20 -/* 802A24D8 4E 80 00 20 */ blr diff --git a/asm/JSystem/JAudio2/JAISound/increasePrepareCount_JAISound___8JAISoundFv.s b/asm/JSystem/JAudio2/JAISound/increasePrepareCount_JAISound___8JAISoundFv.s deleted file mode 100644 index 3ae33c8ba93..00000000000 --- a/asm/JSystem/JAudio2/JAISound/increasePrepareCount_JAISound___8JAISoundFv.s +++ /dev/null @@ -1,21 +0,0 @@ -lbl_802A266C: -/* 802A266C 94 21 FF F0 */ stwu r1, -0x10(r1) -/* 802A2670 7C 08 02 A6 */ mflr r0 -/* 802A2674 90 01 00 14 */ stw r0, 0x14(r1) -/* 802A2678 7C 66 1B 78 */ mr r6, r3 -/* 802A267C 80 63 00 14 */ lwz r3, 0x14(r3) -/* 802A2680 38 03 00 01 */ addi r0, r3, 1 -/* 802A2684 90 06 00 14 */ stw r0, 0x14(r6) -/* 802A2688 54 00 06 3F */ clrlwi. r0, r0, 0x18 -/* 802A268C 40 82 00 1C */ bne lbl_802A26A8 -/* 802A2690 3C 60 80 3A */ lis r3, JAISound__stringBase0@ha /* 0x8039B910@ha */ -/* 802A2694 38 63 B9 10 */ addi r3, r3, JAISound__stringBase0@l /* 0x8039B910@l */ -/* 802A2698 80 86 00 14 */ lwz r4, 0x14(r6) -/* 802A269C 80 A6 00 18 */ lwz r5, 0x18(r6) -/* 802A26A0 4C C6 31 82 */ crclr 6 -/* 802A26A4 4B FE E8 C1 */ bl JASReport__FPCce -lbl_802A26A8: -/* 802A26A8 80 01 00 14 */ lwz r0, 0x14(r1) -/* 802A26AC 7C 08 03 A6 */ mtlr r0 -/* 802A26B0 38 21 00 10 */ addi r1, r1, 0x10 -/* 802A26B4 4E 80 00 20 */ blr diff --git a/asm/JSystem/JAudio2/JAISound/initTrack_JAISound___8JAISoundFP8JASTrack.s b/asm/JSystem/JAudio2/JAISound/initTrack_JAISound___8JAISoundFP8JASTrack.s deleted file mode 100644 index fdf4bf80740..00000000000 --- a/asm/JSystem/JAudio2/JAISound/initTrack_JAISound___8JAISoundFP8JASTrack.s +++ /dev/null @@ -1,59 +0,0 @@ -lbl_802A29DC: -/* 802A29DC 94 21 FF C0 */ stwu r1, -0x40(r1) -/* 802A29E0 7C 08 02 A6 */ mflr r0 -/* 802A29E4 90 01 00 44 */ stw r0, 0x44(r1) -/* 802A29E8 39 61 00 40 */ addi r11, r1, 0x40 -/* 802A29EC 48 0B F7 E5 */ bl _savegpr_26 -/* 802A29F0 7C 7A 1B 78 */ mr r26, r3 -/* 802A29F4 7C 9B 23 78 */ mr r27, r4 -/* 802A29F8 3B A0 00 00 */ li r29, 0 -/* 802A29FC 3B E0 00 00 */ li r31, 0 -/* 802A2A00 3B 80 00 00 */ li r28, 0 -/* 802A2A04 3B C1 00 08 */ addi r30, r1, 8 -/* 802A2A08 48 00 00 34 */ b lbl_802A2A3C -lbl_802A2A0C: -/* 802A2A0C 80 7A 00 08 */ lwz r3, 8(r26) -/* 802A2A10 7F 84 E3 78 */ mr r4, r28 -/* 802A2A14 81 83 00 00 */ lwz r12, 0(r3) -/* 802A2A18 81 8C 00 0C */ lwz r12, 0xc(r12) -/* 802A2A1C 7D 89 03 A6 */ mtctr r12 -/* 802A2A20 4E 80 04 21 */ bctrl -/* 802A2A24 28 03 00 00 */ cmplwi r3, 0 -/* 802A2A28 41 82 00 10 */ beq lbl_802A2A38 -/* 802A2A2C 7C 7E F9 2E */ stwx r3, r30, r31 -/* 802A2A30 3B BD 00 01 */ addi r29, r29, 1 -/* 802A2A34 3B FF 00 04 */ addi r31, r31, 4 -lbl_802A2A38: -/* 802A2A38 3B 9C 00 01 */ addi r28, r28, 1 -lbl_802A2A3C: -/* 802A2A3C 80 7A 00 0C */ lwz r3, 0xc(r26) -/* 802A2A40 81 83 00 00 */ lwz r12, 0(r3) -/* 802A2A44 81 8C 00 10 */ lwz r12, 0x10(r12) -/* 802A2A48 7D 89 03 A6 */ mtctr r12 -/* 802A2A4C 4E 80 04 21 */ bctrl -/* 802A2A50 7C 1C 18 00 */ cmpw r28, r3 -/* 802A2A54 41 80 FF B8 */ blt lbl_802A2A0C -/* 802A2A58 7F 63 DB 78 */ mr r3, r27 -/* 802A2A5C 7F A4 EB 78 */ mr r4, r29 -/* 802A2A60 4B FE E9 E5 */ bl setChannelMgrCount__8JASTrackFUl -/* 802A2A64 3B 80 00 00 */ li r28, 0 -/* 802A2A68 3B E0 00 00 */ li r31, 0 -/* 802A2A6C 3B C1 00 08 */ addi r30, r1, 8 -/* 802A2A70 48 00 00 1C */ b lbl_802A2A8C -lbl_802A2A74: -/* 802A2A74 7F 63 DB 78 */ mr r3, r27 -/* 802A2A78 7F 84 E3 78 */ mr r4, r28 -/* 802A2A7C 7C BE F8 2E */ lwzx r5, r30, r31 -/* 802A2A80 4B FE EF 75 */ bl assignExtBuffer__8JASTrackFUlP14JASSoundParams -/* 802A2A84 3B 9C 00 01 */ addi r28, r28, 1 -/* 802A2A88 3B FF 00 04 */ addi r31, r31, 4 -lbl_802A2A8C: -/* 802A2A8C 80 1B 01 D0 */ lwz r0, 0x1d0(r27) -/* 802A2A90 7C 1C 00 40 */ cmplw r28, r0 -/* 802A2A94 41 80 FF E0 */ blt lbl_802A2A74 -/* 802A2A98 39 61 00 40 */ addi r11, r1, 0x40 -/* 802A2A9C 48 0B F7 81 */ bl _restgpr_26 -/* 802A2AA0 80 01 00 44 */ lwz r0, 0x44(r1) -/* 802A2AA4 7C 08 03 A6 */ mtlr r0 -/* 802A2AA8 38 21 00 40 */ addi r1, r1, 0x40 -/* 802A2AAC 4E 80 00 20 */ blr diff --git a/asm/JSystem/JAudio2/JAISound/stop__8JAISoundFv.s b/asm/JSystem/JAudio2/JAISound/stop__8JAISoundFv.s deleted file mode 100644 index be2ecbbd20e..00000000000 --- a/asm/JSystem/JAudio2/JAISound/stop__8JAISoundFv.s +++ /dev/null @@ -1,17 +0,0 @@ -lbl_802A2598: -/* 802A2598 94 21 FF F0 */ stwu r1, -0x10(r1) -/* 802A259C 7C 08 02 A6 */ mflr r0 -/* 802A25A0 90 01 00 14 */ stw r0, 0x14(r1) -/* 802A25A4 38 80 00 00 */ li r4, 0 -/* 802A25A8 88 03 00 1F */ lbz r0, 0x1f(r3) -/* 802A25AC 50 80 1F 38 */ rlwimi r0, r4, 3, 0x1c, 0x1c -/* 802A25B0 98 03 00 1F */ stb r0, 0x1f(r3) -/* 802A25B4 38 80 00 01 */ li r4, 1 -/* 802A25B8 88 03 00 1F */ lbz r0, 0x1f(r3) -/* 802A25BC 50 80 3E 30 */ rlwimi r0, r4, 7, 0x18, 0x18 -/* 802A25C0 98 03 00 1F */ stb r0, 0x1f(r3) -/* 802A25C4 4B FF FB DD */ bl releaseHandle__8JAISoundFv -/* 802A25C8 80 01 00 14 */ lwz r0, 0x14(r1) -/* 802A25CC 7C 08 03 A6 */ mtlr r0 -/* 802A25D0 38 21 00 10 */ addi r1, r1, 0x10 -/* 802A25D4 4E 80 00 20 */ blr diff --git a/asm/JSystem/JAudio2/JASAudioReseter/calc__15JASAudioReseterFv.s b/asm/JSystem/JAudio2/JASAudioReseter/calc__15JASAudioReseterFv.s deleted file mode 100644 index beab1fea431..00000000000 --- a/asm/JSystem/JAudio2/JASAudioReseter/calc__15JASAudioReseterFv.s +++ /dev/null @@ -1,59 +0,0 @@ -lbl_8029D200: -/* 8029D200 94 21 FF E0 */ stwu r1, -0x20(r1) -/* 8029D204 7C 08 02 A6 */ mflr r0 -/* 8029D208 90 01 00 24 */ stw r0, 0x24(r1) -/* 8029D20C 93 E1 00 1C */ stw r31, 0x1c(r1) -/* 8029D210 93 C1 00 18 */ stw r30, 0x18(r1) -/* 8029D214 7C 7E 1B 78 */ mr r30, r3 -/* 8029D218 80 63 00 00 */ lwz r3, 0(r3) -/* 8029D21C 28 03 00 00 */ cmplwi r3, 0 -/* 8029D220 40 82 00 50 */ bne lbl_8029D270 -/* 8029D224 3B E0 00 00 */ li r31, 0 -lbl_8029D228: -/* 8029D228 7F E3 FB 78 */ mr r3, r31 -/* 8029D22C 48 00 07 1D */ bl getHandle__13JASDSPChannelFUl -/* 8029D230 80 03 00 00 */ lwz r0, 0(r3) -/* 8029D234 54 00 06 3F */ clrlwi. r0, r0, 0x18 -/* 8029D238 40 82 00 08 */ bne lbl_8029D240 -/* 8029D23C 48 00 01 05 */ bl drop__13JASDSPChannelFv -lbl_8029D240: -/* 8029D240 3B FF 00 01 */ addi r31, r31, 1 -/* 8029D244 28 1F 00 40 */ cmplwi r31, 0x40 -/* 8029D248 41 80 FF E0 */ blt lbl_8029D228 -/* 8029D24C 88 1E 00 0C */ lbz r0, 0xc(r30) -/* 8029D250 28 00 00 00 */ cmplwi r0, 0 -/* 8029D254 41 82 00 0C */ beq lbl_8029D260 -/* 8029D258 80 6D 86 0C */ lwz r3, data_80450B8C(r13) -/* 8029D25C 4B FF FB 65 */ bl stop__14JASAudioThreadFv -lbl_8029D260: -/* 8029D260 38 00 00 01 */ li r0, 1 -/* 8029D264 90 1E 00 08 */ stw r0, 8(r30) -/* 8029D268 38 60 FF FF */ li r3, -1 -/* 8029D26C 48 00 00 50 */ b lbl_8029D2BC -lbl_8029D270: -/* 8029D270 38 03 FF FF */ addi r0, r3, -1 -/* 8029D274 90 1E 00 00 */ stw r0, 0(r30) -/* 8029D278 83 FE 00 00 */ lwz r31, 0(r30) -/* 8029D27C 48 00 0E DD */ bl getDSPLevel__9JASDriverFv -/* 8029D280 C8 42 BD 40 */ lfd f2, lit_156(r2) -/* 8029D284 93 E1 00 0C */ stw r31, 0xc(r1) -/* 8029D288 3C 60 43 30 */ lis r3, 0x4330 -/* 8029D28C 90 61 00 08 */ stw r3, 8(r1) -/* 8029D290 C8 01 00 08 */ lfd f0, 8(r1) -/* 8029D294 EC 00 10 28 */ fsubs f0, f0, f2 -/* 8029D298 EC 20 00 72 */ fmuls f1, f0, f1 -/* 8029D29C 38 1F 00 01 */ addi r0, r31, 1 -/* 8029D2A0 90 01 00 14 */ stw r0, 0x14(r1) -/* 8029D2A4 90 61 00 10 */ stw r3, 0x10(r1) -/* 8029D2A8 C8 01 00 10 */ lfd f0, 0x10(r1) -/* 8029D2AC EC 00 10 28 */ fsubs f0, f0, f2 -/* 8029D2B0 EC 21 00 24 */ fdivs f1, f1, f0 -/* 8029D2B4 48 00 0E 7D */ bl setDSPLevel__9JASDriverFf -/* 8029D2B8 38 60 00 00 */ li r3, 0 -lbl_8029D2BC: -/* 8029D2BC 83 E1 00 1C */ lwz r31, 0x1c(r1) -/* 8029D2C0 83 C1 00 18 */ lwz r30, 0x18(r1) -/* 8029D2C4 80 01 00 24 */ lwz r0, 0x24(r1) -/* 8029D2C8 7C 08 03 A6 */ mtlr r0 -/* 8029D2CC 38 21 00 20 */ addi r1, r1, 0x20 -/* 8029D2D0 4E 80 00 20 */ blr diff --git a/asm/JSystem/JAudio2/JASAudioReseter/start__15JASAudioReseterFUlb.s b/asm/JSystem/JAudio2/JASAudioReseter/start__15JASAudioReseterFUlb.s deleted file mode 100644 index 40bd2006aa1..00000000000 --- a/asm/JSystem/JAudio2/JASAudioReseter/start__15JASAudioReseterFUlb.s +++ /dev/null @@ -1,43 +0,0 @@ -lbl_8029D138: -/* 8029D138 94 21 FF E0 */ stwu r1, -0x20(r1) -/* 8029D13C 7C 08 02 A6 */ mflr r0 -/* 8029D140 90 01 00 24 */ stw r0, 0x24(r1) -/* 8029D144 93 E1 00 1C */ stw r31, 0x1c(r1) -/* 8029D148 93 C1 00 18 */ stw r30, 0x18(r1) -/* 8029D14C 7C 7E 1B 78 */ mr r30, r3 -/* 8029D150 7C 9F 23 78 */ mr r31, r4 -/* 8029D154 80 03 00 08 */ lwz r0, 8(r3) -/* 8029D158 2C 00 00 00 */ cmpwi r0, 0 -/* 8029D15C 40 82 00 0C */ bne lbl_8029D168 -/* 8029D160 38 60 00 00 */ li r3, 0 -/* 8029D164 48 00 00 58 */ b lbl_8029D1BC -lbl_8029D168: -/* 8029D168 98 BE 00 0C */ stb r5, 0xc(r30) -/* 8029D16C 48 0A 05 89 */ bl OSDisableInterrupts -/* 8029D170 90 61 00 08 */ stw r3, 8(r1) -/* 8029D174 3C 60 80 2A */ lis r3, callback__15JASAudioReseterFPv@ha /* 0x8029D2D4@ha */ -/* 8029D178 38 63 D2 D4 */ addi r3, r3, callback__15JASAudioReseterFPv@l /* 0x8029D2D4@l */ -/* 8029D17C 7F C4 F3 78 */ mr r4, r30 -/* 8029D180 48 00 10 C1 */ bl registerDspSyncCallback__9JASDriverFPFPv_lPv -/* 8029D184 54 60 06 3F */ clrlwi. r0, r3, 0x18 -/* 8029D188 40 82 00 14 */ bne lbl_8029D19C -/* 8029D18C 80 61 00 08 */ lwz r3, 8(r1) -/* 8029D190 48 0A 05 8D */ bl OSRestoreInterrupts -/* 8029D194 38 60 00 00 */ li r3, 0 -/* 8029D198 48 00 00 24 */ b lbl_8029D1BC -lbl_8029D19C: -/* 8029D19C 48 00 0F BD */ bl getDSPLevel__9JASDriverFv -/* 8029D1A0 D0 3E 00 04 */ stfs f1, 4(r30) -/* 8029D1A4 93 FE 00 00 */ stw r31, 0(r30) -/* 8029D1A8 38 00 00 00 */ li r0, 0 -/* 8029D1AC 90 1E 00 08 */ stw r0, 8(r30) -/* 8029D1B0 80 61 00 08 */ lwz r3, 8(r1) -/* 8029D1B4 48 0A 05 69 */ bl OSRestoreInterrupts -/* 8029D1B8 38 60 00 01 */ li r3, 1 -lbl_8029D1BC: -/* 8029D1BC 83 E1 00 1C */ lwz r31, 0x1c(r1) -/* 8029D1C0 83 C1 00 18 */ lwz r30, 0x18(r1) -/* 8029D1C4 80 01 00 24 */ lwz r0, 0x24(r1) -/* 8029D1C8 7C 08 03 A6 */ mtlr r0 -/* 8029D1CC 38 21 00 20 */ addi r1, r1, 0x20 -/* 8029D1D0 4E 80 00 20 */ blr diff --git a/asm/JSystem/JAudio2/dspproc/setup_callback__FUs.s b/asm/JSystem/JAudio2/dspproc/setup_callback__FUs.s deleted file mode 100644 index ddb13445571..00000000000 --- a/asm/JSystem/JAudio2/dspproc/setup_callback__FUs.s +++ /dev/null @@ -1,4 +0,0 @@ -lbl_8029E540: -/* 8029E540 38 00 00 00 */ li r0, 0 -/* 8029E544 90 0D 8D 78 */ stw r0, flag(r13) -/* 8029E548 4E 80 00 20 */ blr diff --git a/include/JSystem/JAudio2/JAIAudible.h b/include/JSystem/JAudio2/JAIAudible.h index d42029bec94..047b9132953 100644 --- a/include/JSystem/JAudio2/JAIAudible.h +++ b/include/JSystem/JAudio2/JAIAudible.h @@ -2,10 +2,11 @@ #define JAIAUDIBLE_H #include "dolphin/types.h" +#include "JSystem/JAudio2/JASSoundParams.h" struct JAIAudible { virtual ~JAIAudible(); - virtual void getOuterParams(int) = 0; + virtual JASSoundParams* getOuterParams(int) = 0; virtual void calc() = 0; }; diff --git a/include/JSystem/JAudio2/JAIAudience.h b/include/JSystem/JAudio2/JAIAudience.h index 2f2586bf2d0..1621386ad8a 100644 --- a/include/JSystem/JAudio2/JAIAudience.h +++ b/include/JSystem/JAudio2/JAIAudience.h @@ -13,9 +13,9 @@ struct JAIAudience { virtual ~JAIAudience(); virtual JAIAudible* newAudible(JGeometry::TVec3 const&, JAISoundID, JGeometry::TVec3 const*, u32) = 0; - virtual void getMaxChannels() = 0; + virtual int getMaxChannels() = 0; virtual void deleteAudible(JAIAudible*) = 0; - virtual void calcPriority(JAIAudible*) = 0; + virtual u32 calcPriority(JAIAudible*) = 0; virtual void mixChannelOut(JASSoundParams const&, JAIAudible*, int) = 0; }; diff --git a/include/JSystem/JAudio2/JAISound.h b/include/JSystem/JAudio2/JAISound.h index 61bac44a425..f027ab22cdd 100644 --- a/include/JSystem/JAudio2/JAISound.h +++ b/include/JSystem/JAudio2/JAISound.h @@ -11,11 +11,11 @@ class JAISoundID { public: operator u32() const { return this->mId; } - void operator=(JAISoundID const&); + void operator=(JAISoundID const& other) {mId = other.mId;}; JAISoundID(u32 pId) { mId = pId; }; - JAISoundID(JAISoundID const& other); + JAISoundID(JAISoundID const& other) {mId = other.mId;}; JAISoundID() {} @@ -29,6 +29,13 @@ struct JASTrack { /* 80291C30 */ void openChild(u32); /* 80292918 */ void writePort(u32, u16); /* 8029297C */ void readPort(u32); + + inline int getChannelMgrCount() { + return channelMgrCount; + } + + /* 0x0 */u8 field_0x0[0x1d0]; + /* 0x1d0 */ int channelMgrCount; }; struct JAISoundStatus_ { @@ -36,26 +43,92 @@ struct JAISoundStatus_ { /* 802A2244 */ s32 unlockIfLocked(); void init() { - field_0x0 = 0; - field_0x1 = 0; - *((u16*)(this) + 2) = 0; + field_0x0.value = 0; + field_0x1.value = 0; + *((u16*)&state) = 0; user_data = 0; } - /* 0x0 */ u8 field_0x0; - /* 0x1 */ u8 field_0x1; - /* 0x2 */ u8 state[2]; // debug accesses like "state.flags.calcedOnce" + bool isAlive(); //used in assert + + inline bool isPlaying() { + return state.unk==5; + } + + inline bool isPaused() { + return field_0x0.flags.paused; + } + + /* 0x0 */ union { + u8 value; + struct{ + u8 flag1:1; + u8 paused:1; + u8 flag3:1; + u8 flag4:1; + u8 flag5:1; + u8 flag6:1; + u8 flag7:1; + u8 flag8:1; + }flags; + }field_0x0; + /* 0x1 */ union { + u8 value; + struct{ + u8 flag1:1; + u8 flag2:1; + u8 flag3:1; + u8 flag4:1; + u8 flag5:1; + u8 flag6:1; + u8 flag7:1; + u8 flag8:1; + }flags; + }field_0x1; + /* 0x2 */ struct { + u8 unk; + struct { + u8 flag1:1; + u8 flag2:1; + u8 flag3:1; + u8 flag4:1; + u8 flag5:1; + u8 flag6:1; + u8 flag7:1; + u8 flag8:1; + }flags; + } state; /* 0x4 */ u32 user_data; }; // Size: 0x6 struct JAISoundFader { void forceIn() { mIntensity = 1.0f; - field_0x4.zero(); + mTransition.zero(); + } + void forceOut() { + mIntensity = 0.0f; + mTransition.zero(); + } + void fadeOut(u32 fadeCount) { + if (fadeCount!=0) { + mTransition.set(0.0f,mIntensity,fadeCount); + }else{ + forceOut(); + } + } + bool isOut() { + if(mTransition.mCount != 0 || mIntensity < 0.01f) { + return true; + } + return false; + } + inline void calc() { + mIntensity = mTransition.apply(mIntensity); } /* 0x00 */ f32 mIntensity; - /* 0x04 */ JAISoundParamsTransition::TTransition field_0x4; + /* 0x04 */ JAISoundParamsTransition::TTransition mTransition; }; // Size: 0x10 template @@ -88,29 +161,50 @@ public: JAIAudience*); /* 802A2598 */ void stop(); /* 802A24DC */ void stop(u32 fadeout); - /* 802A25D8 */ bool asSe(); - /* 802A25E0 */ bool asSeq(); - /* 802A25E8 */ bool asStream(); /* 802A25F0 */ void die_JAISound_(); /* 802A266C */ void increasePrepareCount_JAISound_(); - /* 802A26B8 */ void calc_JAISound_(); + /* 802A26B8 */ bool calc_JAISound_(); /* 802A29DC */ void initTrack_JAISound_(JASTrack*); virtual void getNumChild() = 0; + virtual void getChild() = 0; + virtual void releaseChild() = 0; + /* 802A25D8 */ virtual bool asSe(); + /* 802A25E0 */ virtual bool asSeq(); + /* 802A25E8 */ virtual bool asStream(); + virtual void getTrack() = 0; + virtual void getChildTrack() = 0; + virtual void getTempoMgr() = 0; + virtual bool JAISound_tryDie_() = 0; JAISoundID getID() const; u32 getUserData() const { return status_.user_data; } bool isHandleAttached() const { return handle_ != NULL; } + void removeLifeTime_() { + status_.field_0x1.flags.flag1 = false; + } + void stop_JAISound_() { + status_.state.flags.flag5 = 0; + status_.state.flags.flag1 = 1; + } + bool isStopping() { + bool isStopping = false; + if(status_.state.flags.flag1) { + isStopping = status_.state.flags.flag5 ? fader.isOut() : true; + } + return isStopping; + } + /* 0x04 */ JAISoundHandle* handle_; /* 0x08 */ JAIAudible* audible_; /* 0x0C */ JAIAudience* audience_; - /* 0x10 */ s32 lifeTime; + /* 0x10 */ u32 lifeTime; /* 0x14 */ s32 prepareCount; /* 0x18 */ JAISoundID soundID; /* 0x1C */ JAISoundStatus_ status_; /* 0x24 */ JAISoundFader fader; - /* 0x34 */ s32 field_0x34; + /* 0x34 */ s32 mPriority; /* 0x38 */ s32 mCount; /* 0x3C */ JAISoundParams params; }; // Size: 0x98 diff --git a/include/JSystem/JAudio2/JAISoundHandles.h b/include/JSystem/JAudio2/JAISoundHandles.h index 850358facd2..d79baaa2dc6 100644 --- a/include/JSystem/JAudio2/JAISoundHandles.h +++ b/include/JSystem/JAudio2/JAISoundHandles.h @@ -10,7 +10,7 @@ class JAISoundID; class JAISoundHandle { public: - JAISoundHandle(); + JAISoundHandle() {sound_ = NULL;}; ~JAISoundHandle() {} bool isSoundAttached() const { return sound_ != NULL; } diff --git a/include/JSystem/JAudio2/JAISoundParams.h b/include/JSystem/JAudio2/JAISoundParams.h index 6984c0a912d..f9befe83e08 100644 --- a/include/JSystem/JAudio2/JAISoundParams.h +++ b/include/JSystem/JAudio2/JAISoundParams.h @@ -24,9 +24,9 @@ struct JAISoundParamsTransition { field_0x4 = 0.0f; } - void set(f32 newValue, f32 param_1, u32 param_2) { - mCount = param_2; - field_0x0 = (newValue - param_1) / mCount; + void set(f32 newValue, f32 intensity, u32 fadeCount) { + mCount = fadeCount; + field_0x0 = (newValue - intensity) / mCount; field_0x4 = newValue; } diff --git a/include/JSystem/JAudio2/JASAudioReseter.h b/include/JSystem/JAudio2/JASAudioReseter.h index 25e6af4a336..66d466f3f51 100644 --- a/include/JSystem/JAudio2/JASAudioReseter.h +++ b/include/JSystem/JAudio2/JASAudioReseter.h @@ -3,6 +3,13 @@ #include "JSystem/JAudio2/JASDriverIF.h" #include "dolphin/types.h" +#include "dolphin/os/OS.h" + +struct JASCriticalSection { + inline JASCriticalSection() {mInterruptState = OSDisableInterrupts();}; + inline ~JASCriticalSection() {OSRestoreInterrupts(mInterruptState);}; + u32 mInterruptState; +}; struct JASAudioReseter { /* 8029D0B4 */ JASAudioReseter(); @@ -10,7 +17,7 @@ struct JASAudioReseter { /* 8029D138 */ bool start(u32, bool); /* 8029D1D4 */ void resume(); /* 8029D1F8 */ s32 checkDone() const; - /* 8029D200 */ static s32 calc(); + /* 8029D200 */ s32 calc(); /* 8029D2D4 */ static s32 callback(void*); /* 0x0 */ u32 field_0x0; diff --git a/include/JSystem/JAudio2/JASAudioThread.h b/include/JSystem/JAudio2/JASAudioThread.h index 2ed9d02f549..e8da1c883b6 100644 --- a/include/JSystem/JAudio2/JASAudioThread.h +++ b/include/JSystem/JAudio2/JASAudioThread.h @@ -3,4 +3,16 @@ #include "dolphin/types.h" +struct JASAudioThread { + /* 8029CCDC */ JASAudioThread(int, int, u32); + /* 8029CD4C */ void create(s32); + /* 8029CDC0 */ void stop(); + /* 8029CDEC */ void run(); + /* 8029CF68 */ void DMACallback(); + /* 8029CFBC */ void DSPCallback(void*); + /* 8029D028 */ ~JASAudioThread(); + + static u8 snIntCount[4 + 4 /* padding */]; +}; + #endif /* JASAUDIOTHREAD_H */ diff --git a/include/JSystem/JAudio2/JASGadget.h b/include/JSystem/JAudio2/JASGadget.h index 6edcf6961a5..9af40931c49 100644 --- a/include/JSystem/JAudio2/JASGadget.h +++ b/include/JSystem/JAudio2/JASGadget.h @@ -6,9 +6,19 @@ template class JASGlobalInstance { public: - // T* getInstance() { return sInstance; } + inline T* getInstance() { return sInstance; } - // static T* sInstance; + inline JASGlobalInstance(bool param) { + if (param) { + ASSERT(sInstance == 0); + //if (this!=NULL) { + sInstance = (T*)this; + //We need a better way to compute the location of sInstance + //sInstance = (T*)((char*)this-(char*)&(((T*)NULL)->JASGlobalInstance)); + //} + } + } + static T* sInstance; }; #endif /* JASGADGET_H */ diff --git a/include/JSystem/JAudio2/JASReport.h b/include/JSystem/JAudio2/JASReport.h index 6f0c1a0fae5..86b0944e835 100644 --- a/include/JSystem/JAudio2/JASReport.h +++ b/include/JSystem/JAudio2/JASReport.h @@ -3,4 +3,6 @@ #include "dolphin/types.h" +void JASReport(const char* message, ...); + #endif /* JASREPORT_H */ diff --git a/include/JSystem/JAudio2/dspproc.h b/include/JSystem/JAudio2/dspproc.h index e624638ec31..5f1c5304954 100644 --- a/include/JSystem/JAudio2/dspproc.h +++ b/include/JSystem/JAudio2/dspproc.h @@ -2,5 +2,6 @@ #define DSPPROC_H #include "dolphin/types.h" +#include "dolphin/dsp/dsp.h" #endif /* DSPPROC_H */ diff --git a/include/Z2AudioLib/Z2Audience.h b/include/Z2AudioLib/Z2Audience.h index d3ea344af88..a3af8c114d3 100644 --- a/include/Z2AudioLib/Z2Audience.h +++ b/include/Z2AudioLib/Z2Audience.h @@ -121,9 +121,9 @@ struct Z2Audience : public JAIAudience { /* 802BD1FC */ virtual ~Z2Audience(); /* 802BD338 */ virtual JAIAudible* newAudible(JGeometry::TVec3 const&, JAISoundID, JGeometry::TVec3 const*, u32); - /* 802BDED4 */ virtual void getMaxChannels(); + /* 802BDED4 */ virtual int getMaxChannels(); /* 802BD4D4 */ virtual void deleteAudible(JAIAudible*); - /* 802BD5B8 */ virtual void calcPriority(JAIAudible*); + /* 802BD5B8 */ virtual u32 calcPriority(JAIAudible*); /* 802BD71C */ virtual void mixChannelOut(JASSoundParams const&, JAIAudible*, int); /* 0x004 */ f32 field_0x4; diff --git a/include/Z2AudioLib/Z2WolfHowlMgr.h b/include/Z2AudioLib/Z2WolfHowlMgr.h index ba41b0539e4..224aa60485b 100644 --- a/include/Z2AudioLib/Z2WolfHowlMgr.h +++ b/include/Z2AudioLib/Z2WolfHowlMgr.h @@ -1,8 +1,9 @@ #ifndef Z2WOLFHOWLMGR_H #define Z2WOLFHOWLMGR_H -#include "Z2AudioLib/Z2SoundObject.h" #include "dolphin/types.h" +#include "Z2AudioLib/Z2SoundObject.h" +#include "JSystem/JAudio2/JASGadget.h" /* * Z2WolfHowlData @@ -17,7 +18,7 @@ struct Z2WolfHowlData { u16* mSongData; }; -class Z2WolfHowlMgr { +class Z2WolfHowlMgr : public JASGlobalInstance { public: Z2WolfHowlMgr(); @@ -36,10 +37,11 @@ public: void startGuideMelody(bool); void skipCorrectDemo(); + private: - /* 0x00 */ JAISoundHandle* field_0x00; - /* 0x04 */ JAISoundHandle* field_0x04; - /* 0x08 */ JAISoundHandle* field_0x08; + /* 0x00 */ JAISoundHandle field_0x00; + /* 0x04 */ JAISoundHandle field_0x04; + /* 0x08 */ JAISoundHandle field_0x08; /* 0x0C */ Z2WolfHowlData* mpCurSong; /* 0x10 */ Z2WolfHowlData** mpSongList; /* 0x14 */ f32 mNowInputValue; @@ -51,37 +53,18 @@ private: /* 0x2C */ u8 field_0x2c[4]; /* 0x30 */ f32 field_0x30; /* 0x34 */ f32 field_0x34; - /* 0x38 */ f32 field_0x38; - /* 0x3C */ f32 field_0x3c; - /* 0x40 */ f32 field_0x40; - /* 0x44 */ f32 field_0x44; - /* 0x48 */ f32 field_0x48; - /* 0x4C */ f32 field_0x4c; - /* 0x50 */ f32 field_0x50; - /* 0x54 */ f32 field_0x54; - /* 0x58 */ f32 field_0x58; - /* 0x5C */ f32 field_0x5c; - /* 0x60 */ f32 field_0x60; - /* 0x64 */ f32 field_0x64; - /* 0x68 */ f32 field_0x68; - /* 0x6C */ f32 field_0x6c; - /* 0x70 */ f32 field_0x70; - /* 0x74 */ f32 field_0x74; - /* 0x78 */ f32 field_0x78; - /* 0x7C */ f32 field_0x7c; - /* 0x80 */ f32 field_0x80; - /* 0x84 */ f32 field_0x84; + /* 0x38 */ f32 field_0x38[10]; + /* 0x60 */ f32 field_0x60[10]; /* 0x88 */ void* mTimer; /* 0x8C */ u8 mReleaseTimer; /* 0x8D */ u8 field_0x8d; - /* 0x8E */ u8 mCorrectCurveID; + /* 0x8E */ s8 mCorrectCurveID; /* 0x8F */ u8 field_0x8f; /* 0x90 */ s16 field_0x90; - /* 0x92 */ u8 field_0x92[20]; - /* 0xA6 */ u8 field_0xa6[0x14]; - /* 0xBA */ u8 field_0xba; - /* 0xBB */ u8 field_0xbb; - /* 0xBC */ u8 field_0xbc; + /* 0x92 */ u16 field_0x92[20]; + /* 0xBA */ s8 field_0xba; + /* 0xBB */ s8 field_0xbb; + /* 0xBC */ s8 field_0xbc; }; #endif /* Z2WOLFHOWLMGR_H */ diff --git a/include/dolphin/dsp/dsp.h b/include/dolphin/dsp/dsp.h index f7cb94b2912..65c00614896 100644 --- a/include/dolphin/dsp/dsp.h +++ b/include/dolphin/dsp/dsp.h @@ -3,4 +3,10 @@ #include "dolphin/types.h" +void DSPReleaseHalt2(u32 msg); +u16 DSP_CreateMap2(u32 msg); +void DSPSendCommands2(u32* msgs, u32 param_1, void (*param_2)(u16)); +void DsetupTable(u32 param_0, u32 param_1, u32 param_2, u32 param_3, u32 param_4); +void DsetMixerLevel(f32 level); + #endif /* DSP_H */ diff --git a/include/m_Do/m_Do_audio.h b/include/m_Do/m_Do_audio.h index 3cc4b621608..898f8344891 100644 --- a/include/m_Do/m_Do_audio.h +++ b/include/m_Do/m_Do_audio.h @@ -1,18 +1,10 @@ #ifndef M_DO_M_DO_AUDIO_H #define M_DO_M_DO_AUDIO_H +#include "dolphin/types.h" +#include "JSystem/JAudio2/JASGadget.h" #include "Z2AudioLib/Z2AudioMgr.h" #include "Z2AudioLib/Z2EnvSeMgr.h" -#include "dolphin/types.h" - -// move/fix later -template -class JASGlobalInstance { -public: - T* getInstance() { return sInstance; }; - - static T* sInstance; -}; class mDoAud_zelAudio_c { public: diff --git a/libs/JSystem/JAudio2/JAISound.cpp b/libs/JSystem/JAudio2/JAISound.cpp index 2f943947c1e..9f9e3162d1e 100644 --- a/libs/JSystem/JAudio2/JAISound.cpp +++ b/libs/JSystem/JAudio2/JAISound.cpp @@ -6,6 +6,7 @@ #include "JSystem/JAudio2/JAISound.h" #include "dol2asm.h" #include "dolphin/types.h" +#include "JSystem/JAudio2/JASReport.h" // // Forward References: @@ -79,8 +80,8 @@ void JAISound::attachHandle(JAISoundHandle* handle) { /* 802A2220-802A2244 29CB60 0024+00 0/0 2/2 0/0 .text lockWhenPrepared__15JAISoundStatus_Fv */ s32 JAISoundStatus_::lockWhenPrepared() { - if (state[0] == 0) { - state[0] = 1; + if (state.unk == 0) { + state.unk = 1; return 1; } return 0; @@ -89,12 +90,12 @@ s32 JAISoundStatus_::lockWhenPrepared() { /* 802A2244-802A2280 29CB84 003C+00 0/0 2/2 0/0 .text unlockIfLocked__15JAISoundStatus_Fv */ s32 JAISoundStatus_::unlockIfLocked() { - if (state[0] == 3) { - state[0] = 4; + if (state.unk == 3) { + state.unk = 4; return 1; } - if (state[0] == 1) { - state[0] = 0; + if (state.unk == 1) { + state.unk = 0; return 1; } return 0; @@ -171,11 +172,10 @@ void JAISound::start_JAISound_(JAISoundID param_0, JGeometry::TVec3 const* prepareCount = 0; mCount = 0; - if (param_1 == NULL || audience_ == NULL) { - audible_ = NULL; + if (param_1 != 0 && audience_ != NULL) { + audible_ = audience_->newAudible(*param_1, soundID, NULL, 0); } else { - JAISoundID sound = soundID; - audible_ = audience_->newAudible(*param_1, sound, NULL, 0); + audible_ = NULL; } field_0x34 = 0; } @@ -194,7 +194,7 @@ asm void JAISound::start_JAISound_(JAISoundID param_0, JGeometry::TVec3 con /* 802A244C-802A2474 29CD8C 0028+00 0/0 2/2 0/0 .text acceptsNewAudible__8JAISoundCFv */ bool JAISound::acceptsNewAudible() const { bool accepts = false; - if (audible_ == NULL && !(status_.state[1] >> 6 & 1)) { + if (audible_ == NULL && status_.state.flags.flag2==0) { accepts = true; } return accepts; @@ -202,7 +202,6 @@ bool JAISound::acceptsNewAudible() const { /* 802A2474-802A24DC 29CDB4 0068+00 0/0 2/2 0/0 .text /* * newAudible__8JAISoundFRCQ29JGeometry8TVec3PCQ29JGeometry8TVec3UlP11JAIAudience */ -#ifdef NONMATCHING void JAISound::newAudible(JGeometry::TVec3 const& param_0, JGeometry::TVec3 const* param_1, u32 param_2, JAIAudience* param_3) { if (param_3 != NULL) { @@ -211,24 +210,27 @@ void JAISound::newAudible(JGeometry::TVec3 const& param_0, JAISoundID sound = soundID; audible_ = audience_->newAudible(param_0, sound, param_1, param_2); } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void JAISound::newAudible(JGeometry::TVec3 const& param_0, - JGeometry::TVec3 const* param_1, u32 param_2, - JAIAudience* param_3) { - nofralloc -#include "asm/JSystem/JAudio2/JAISound/func_802A2474.s" -} -#pragma pop -#endif /* ############################################################################################## */ /* 804557C8-804557D0 003DC8 0008+00 1/1 0/0 0/0 .sdata2 @766 */ SECTION_SDATA2 static f64 lit_766 = 4503599627370496.0 /* cast u32 to float */; /* 802A24DC-802A2598 29CE1C 00BC+00 0/0 24/24 0/0 .text stop__8JAISoundFUl */ +#ifdef NONMATCHING +void JAISound::stop(u32 fadeCount) { + ASSERT(status_.isAlive()); + if (fadeCount==0) { + stop(); + return; + }else{ + fader.fadeOut(fadeCount); + removeLifeTime_(); + status_.field_0x1.flags.flag2 = 0; + status_.state.flags.flag5 = 1; + status_.state.flags.flag1 = 1; + } +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -237,16 +239,13 @@ asm void JAISound::stop(u32 param_0) { #include "asm/JSystem/JAudio2/JAISound/stop__8JAISoundFUl.s" } #pragma pop +#endif /* 802A2598-802A25D8 29CED8 0040+00 2/2 21/21 0/0 .text stop__8JAISoundFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void JAISound::stop() { - nofralloc -#include "asm/JSystem/JAudio2/JAISound/stop__8JAISoundFv.s" +void JAISound::stop() { + stop_JAISound_(); + releaseHandle(); } -#pragma pop /* 802A25D8-802A25E0 29CF18 0008+00 1/0 2/0 0/0 .text asSe__8JAISoundFv */ bool JAISound::asSe() { @@ -264,6 +263,18 @@ bool JAISound::asStream() { } /* 802A25F0-802A266C 29CF30 007C+00 0/0 3/3 0/0 .text die_JAISound___8JAISoundFv */ +#ifdef NONMATCHING +void JAISound::die_JAISound_() { + if (audible_!=NULL){ + audience_->deleteAudible(audible_); + audible_ = NULL; + audience_ = NULL; + } + fader.forceOut(); + releaseHandle(); + status_.state.unk = 6; +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -272,28 +283,15 @@ asm void JAISound::die_JAISound_() { #include "asm/JSystem/JAudio2/JAISound/die_JAISound___8JAISoundFv.s" } #pragma pop - -/* ############################################################################################## */ -/* 8039B910-8039B910 027F70 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */ -#pragma push -#pragma force_active on -SECTION_DEAD static char const* const stringBase_8039B910 = - "It cost %d steps to prepare Sound(ID:%08x, Addre" - "ss%08x).\n"; -/* @stringBase0 padding */ -SECTION_DEAD static char const* const pad_8039B94A = "\0\0\0\0\0"; -#pragma pop +#endif /* 802A266C-802A26B8 29CFAC 004C+00 0/0 3/3 0/0 .text increasePrepareCount_JAISound___8JAISoundFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void JAISound::increasePrepareCount_JAISound_() { - nofralloc -#include "asm/JSystem/JAudio2/JAISound/increasePrepareCount_JAISound___8JAISoundFv.s" +void JAISound::increasePrepareCount_JAISound_() { + if((++prepareCount&0xFF) == 0) { + JASReport("It cost %d steps to prepare Sound(ID:%08x, Address%08x).\n",prepareCount,(u32)soundID,this); + } } -#pragma pop /* ############################################################################################## */ /* 804557D0-804557D8 003DD0 0004+04 1/1 0/0 0/0 .sdata2 @887 */ @@ -304,23 +302,74 @@ SECTION_SDATA2 static f32 lit_887[1 + 1 /* padding */] = { }; /* 802A26B8-802A29DC 29CFF8 0324+00 0/0 3/3 0/0 .text calc_JAISound___8JAISoundFv */ +#ifdef NONMATCHING +bool JAISound::calc_JAISound_() { + status_.state.flags.flag2 = 1; + if(isStopping()&&JAISound_tryDie_()) { + return false; + } + ASSERT(status_.isAlive()); + bool isPlaying = status_.isPlaying(); + if(isPlaying) { + mCount++; + } + bool isPaused = status_.isPaused(); + if(isPaused==false) { + fader.calc(); + } + bool playing = isPlaying&&isPaused == false; + if (playing) { + params.mMove.calc(); + if (audible_!=NULL) { + audible_->calc(); + } + if(status_.field_0x1.flags.flag2!=0) { + if(lifeTime==0) { + stop_JAISound_(); + }else{ + lifeTime--; + } + } + } + if(audience_!=NULL&&audible_!=NULL) { + u32 priority = audience_->calcPriority(audible_); + mPriority = priority; + if (priority==0xFFFFFFFF&&status_.field_0x1.flags.flag1==0) { + stop_JAISound_(); + } + }else{ + mPriority = 0; + } + + return playing; +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off -asm void JAISound::calc_JAISound_() { +asm bool JAISound::calc_JAISound_() { nofralloc #include "asm/JSystem/JAudio2/JAISound/calc_JAISound___8JAISoundFv.s" } #pragma pop +#endif /* 802A29DC-802A2AB0 29D31C 00D4+00 0/0 2/2 0/0 .text initTrack_JAISound___8JAISoundFP8JASTrack */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void JAISound::initTrack_JAISound_(JASTrack* param_0) { - nofralloc -#include "asm/JSystem/JAudio2/JAISound/initTrack_JAISound___8JAISoundFP8JASTrack.s" +void JAISound::initTrack_JAISound_(JASTrack* track) { + JASSoundParams* soundParams[8]; + ASSERT(audience_); + ASSERT(audible_); + int numChannels = 0; + for (int i = 0; igetMaxChannels(); i++) { + JASSoundParams* currentParams = audible_->getOuterParams(i); + if (currentParams!=NULL) { + soundParams[numChannels] = currentParams; + numChannels++; + } + } + ASSERT(numChannels >= 1) + track->setChannelMgrCount(numChannels); + for (size_t i = 0; igetChannelMgrCount(); i++) { + track->assignExtBuffer(i,soundParams[i]); + } } -#pragma pop - -/* 8039B910-8039B910 027F70 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */ diff --git a/libs/JSystem/JAudio2/JASAudioReseter.cpp b/libs/JSystem/JAudio2/JASAudioReseter.cpp index 3ed33e6dd33..b253f6c3f26 100644 --- a/libs/JSystem/JAudio2/JASAudioReseter.cpp +++ b/libs/JSystem/JAudio2/JASAudioReseter.cpp @@ -7,6 +7,9 @@ #include "dol2asm.h" #include "dolphin/os/OS.h" #include "dolphin/types.h" +#include "JSystem/JAudio2/JAISoundHandles.h" +#include "JSystem/JAudio2/JASGadget.h" +#include "JSystem/JAudio2/JASAudioThread.h" // // Types: @@ -14,11 +17,10 @@ struct JASDSPChannel { /* 8029D340 */ void drop(); - /* 8029D948 */ void getHandle(u32); -}; + /* 8029D948 */ static JASDSPChannel* getHandle(u32); -struct JASAudioThread { - /* 8029CDC0 */ void stop(); + inline u32 getStatus() {return mStatus;} + u32 mStatus; }; // @@ -44,7 +46,7 @@ extern "C" void setDSPLevel__9JASDriverFf(); extern "C" void getDSPLevel__9JASDriverFv(); extern "C" void registerDspSyncCallback__9JASDriverFPFPv_lPv(); extern "C" void __dl__FPv(); -extern "C" extern u8 data_80450B8C[4]; +extern "C" extern JASAudioThread* data_80450B8C; // // Declarations: @@ -62,38 +64,21 @@ JASAudioReseter::JASAudioReseter() { JASAudioReseter::~JASAudioReseter() {} /* 8029D138-8029D1D4 297A78 009C+00 0/0 1/1 0/0 .text start__15JASAudioReseterFUlb */ -#ifdef NONMATCHING bool JASAudioReseter::start(u32 param_0, bool param_1) { - u32 interrupt_status; - if (mIsDone == false) { return false; + } + field_0xc = param_1; + JASCriticalSection critical; + if (!JASDriver::registerDspSyncCallback(callback, this)) { + return false; } else { - field_0xc = param_1; - interrupt_status = OSDisableInterrupts(); - - if (!JASDriver::registerDspSyncCallback(callback, (void*)param_0)) { - OSRestoreInterrupts(interrupt_status); - return false; - } else { - mDSPLevel = JASDriver::getDSPLevel(); - field_0x0 = param_0; - mIsDone = false; - OSRestoreInterrupts(interrupt_status); - return true; - } + mDSPLevel = JASDriver::getDSPLevel(); + field_0x0 = param_0; + mIsDone = false; + return true; } } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm bool JASAudioReseter::start(u32 param_0, bool param_1) { - nofralloc -#include "asm/JSystem/JAudio2/JASAudioReseter/start__15JASAudioReseterFUlb.s" -} -#pragma pop -#endif /* 8029D1D4-8029D1F8 297B14 0024+00 0/0 1/1 0/0 .text resume__15JASAudioReseterFv */ void JASAudioReseter::resume() { @@ -105,21 +90,30 @@ s32 JASAudioReseter::checkDone() const { return mIsDone; } -/* ############################################################################################## */ -/* 80455740-80455748 003D40 0008+00 1/1 0/0 0/0 .sdata2 @156 */ -SECTION_SDATA2 static f64 lit_156 = 4503599627370496.0 /* cast u32 to float */; /* 8029D200-8029D2D4 297B40 00D4+00 1/1 0/0 0/0 .text calc__15JASAudioReseterFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm s32 JASAudioReseter::calc() { - nofralloc -#include "asm/JSystem/JAudio2/JASAudioReseter/calc__15JASAudioReseterFv.s" +s32 JASAudioReseter::calc() { + if(field_0x0==0) { + for(size_t i = 0; i<64; i++) { + JASDSPChannel* handle = JASDSPChannel::getHandle(i); + if ((handle->getStatus()&0xFF)==0) { + handle->drop(); + } + } + if(field_0xc!=false) { + data_80450B8C->stop();//JASGlobalInstance::sInstance->stop(); + } + mIsDone = 1; + return -1; + } + field_0x0--; + u32 unk = field_0x0; + float dspLevel = JASDriver::getDSPLevel(); + JASDriver::setDSPLevel(((float)unk*dspLevel)/(float)(unk+1)); + return 0; } -#pragma pop /* 8029D2D4-8029D2F4 297C14 0020+00 1/1 0/0 0/0 .text callback__15JASAudioReseterFPv */ s32 JASAudioReseter::callback(void* param_0) { - return calc(); + return ((JASAudioReseter*)param_0)->calc(); } diff --git a/libs/JSystem/JAudio2/JASAudioThread.cpp b/libs/JSystem/JAudio2/JASAudioThread.cpp index 0667bfb0cc1..415d62b23db 100644 --- a/libs/JSystem/JAudio2/JASAudioThread.cpp +++ b/libs/JSystem/JAudio2/JASAudioThread.cpp @@ -58,18 +58,6 @@ struct JASDSPChannel { /* 8029D3C8 */ void initAll(); }; -struct JASAudioThread { - /* 8029CCDC */ JASAudioThread(int, int, u32); - /* 8029CD4C */ void create(s32); - /* 8029CDC0 */ void stop(); - /* 8029CDEC */ void run(); - /* 8029CF68 */ void DMACallback(); - /* 8029CFBC */ void DSPCallback(void*); - /* 8029D028 */ ~JASAudioThread(); - - static u8 snIntCount[4 + 4 /* padding */]; -}; - // // Forward References: // diff --git a/libs/JSystem/JAudio2/dspproc.cpp b/libs/JSystem/JAudio2/dspproc.cpp index f91c6ff13e2..e034a347bd3 100644 --- a/libs/JSystem/JAudio2/dspproc.cpp +++ b/libs/JSystem/JAudio2/dspproc.cpp @@ -29,7 +29,19 @@ extern "C" void DSPSendCommands2__FPUlUlPFUs_v(); // Declarations: // +//Different compiler version for this TU? Something to note is that JAudio 1 is 32 byte aligned like this file + +#pragma function_align 32 + /* 8029E4E0-8029E528 298E20 0048+00 0/0 1/1 0/0 .text DSPReleaseHalt2__FUl */ +#ifdef NONMATCHING +void DSPReleaseHalt2(u32 msg) { + u32 msgs[2]; + msgs[0] = (msg<<16) | DSP_CreateMap2(msg); + + DSPSendCommands2(msgs,0,NULL); +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -39,23 +51,32 @@ asm void DSPReleaseHalt2(u32 param_0) { #include "asm/JSystem/JAudio2/dspproc/DSPReleaseHalt2__FUl.s" } #pragma pop +#endif /* ############################################################################################## */ /* 804512F8-80451300 0007F8 0004+04 2/2 0/0 0/0 .sbss flag */ -static u8 flag[4 + 4 /* padding */]; +static u32 flag; /* 8029E540-8029E54C 298E80 000C+00 1/1 0/0 0/0 .text setup_callback__FUs */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -#pragma function_align 32 -static asm void setup_callback(u16 param_0) { - nofralloc -#include "asm/JSystem/JAudio2/dspproc/setup_callback__FUs.s" +static void setup_callback(u16 param_0) { + flag = 0; } -#pragma pop /* 8029E560-8029E5C4 298EA0 0064+00 0/0 1/1 0/0 .text DsetupTable__FUlUlUlUlUl */ +#ifdef NONMATCHING +void DsetupTable(u32 param_0, u32 param_1, u32 param_2, u32 param_3, u32 param_4) { + u32 r8 = 1; + void(*callback_func)(u16) = setup_callback; + u32 table[5] = {param_0&0xFFFF,param_1,param_2,param_3,param_4}; + flag = r8; + DSPSendCommands2(table,5,callback_func); + while (true) { + if (flag==0) { + return; + } + } +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -65,16 +86,22 @@ asm void DsetupTable(u32 param_0, u32 param_1, u32 param_2, u32 param_3, u32 par #include "asm/JSystem/JAudio2/dspproc/DsetupTable__FUlUlUlUlUl.s" } #pragma pop +#endif /* ############################################################################################## */ /* 804507C8-804507D0 000248 0002+06 3/3 0/0 0/0 .sdata DSP_MIXERLEVEL */ -SECTION_SDATA static u16 DSP_MIXERLEVEL[1 + 3 /* padding */] = { - 0x4000, - /* padding */ - 0x0000, - 0x0000, - 0x0000, -}; +static u16 DSP_MIXERLEVEL = 0x4000; + +/* 8029E5E0-8029E604 298F20 0024+00 0/0 1/1 0/0 .text DsetMixerLevel__Ff */ +#ifdef NONMATCHING +void DsetMixerLevel(f32 level) { + DSP_MIXERLEVEL = 4096.0f*level; +} +#else +#pragma push +#pragma optimization_level 0 +#pragma optimizewithasm off +#pragma function_align 32 /* 80455770-80455778 003D70 0004+04 1/1 0/0 0/0 .sdata2 @333 */ SECTION_SDATA2 static f32 lit_333[1 + 1 /* padding */] = { @@ -83,7 +110,6 @@ SECTION_SDATA2 static f32 lit_333[1 + 1 /* padding */] = { 0.0f, }; -/* 8029E5E0-8029E604 298F20 0024+00 0/0 1/1 0/0 .text DsetMixerLevel__Ff */ #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -93,6 +119,7 @@ asm void DsetMixerLevel(f32 param_0) { #include "asm/JSystem/JAudio2/dspproc/DsetMixerLevel__Ff.s" } #pragma pop +#endif /* 8029E620-8029E674 298F60 0054+00 0/0 1/1 0/0 .text DsyncFrame2ch__FUlUlUl */ #pragma push diff --git a/libs/Z2AudioLib/Z2Audience.cpp b/libs/Z2AudioLib/Z2Audience.cpp index 4bf359b0d55..a38aeb57533 100644 --- a/libs/Z2AudioLib/Z2Audience.cpp +++ b/libs/Z2AudioLib/Z2Audience.cpp @@ -739,7 +739,7 @@ asm Z2Audible::~Z2Audible() { #pragma push #pragma optimization_level 0 #pragma optimizewithasm off -asm void Z2Audience::calcPriority(JAIAudible* param_0) { +asm u32 Z2Audience::calcPriority(JAIAudible* param_0) { nofralloc #include "asm/Z2AudioLib/Z2Audience/calcPriority__10Z2AudienceFP10JAIAudible.s" } @@ -882,7 +882,7 @@ asm void Z2Audience::calcPitch_(Z2AudibleChannel* param_0, Z2Audible const* para #pragma push #pragma optimization_level 0 #pragma optimizewithasm off -asm void Z2Audience::getMaxChannels() { +asm int Z2Audience::getMaxChannels() { nofralloc #include "asm/Z2AudioLib/Z2Audience/getMaxChannels__10Z2AudienceFv.s" } diff --git a/libs/Z2AudioLib/Z2SceneMgr.cpp b/libs/Z2AudioLib/Z2SceneMgr.cpp index c139fc41202..4f0a62b583a 100644 --- a/libs/Z2AudioLib/Z2SceneMgr.cpp +++ b/libs/Z2AudioLib/Z2SceneMgr.cpp @@ -79,7 +79,7 @@ extern "C" void setSceneExist__10Z2SceneMgrFb(); extern "C" void setFadeOutStart__10Z2SceneMgrFUc(); extern "C" void setFadeInStart__10Z2SceneMgrFUc(); extern "C" void setSceneName__10Z2SceneMgrFPcll(); -extern "C" void __ct__10JAISoundIDFRC10JAISoundID(); +extern "C" void __ct__10JAISoundIDFRC10JAISoundID(JAISoundID* this_, JAISoundID const& soundIdToSet); extern "C" void setFieldBgmPlay__8Z2SeqMgrFb(); extern "C" void isActive__12JAIStreamMgrCFv(); extern "C" void getID__8JAISoundCFv(); @@ -87,12 +87,11 @@ extern "C" void func_802B9994(void* _this); extern "C" static void dComIfGs_getStartPoint__Fv(); extern "C" void unMuteSceneBgm__8Z2SeqMgrFUl(); extern "C" void muteSceneBgm__8Z2SeqMgrFUlf(); -extern "C" void __as__10JAISoundIDFRC10JAISoundID(); extern "C" static void dComIfGs_isSaveSwitch__Fi(); extern "C" void resetCrowdSize__7Z2SeMgrFv(); extern "C" void setTwilightGateVol__8Z2SeqMgrFf(); extern "C" void setWindStoneVol__8Z2SeqMgrFfUl(); -extern "C" void __ct__10JAISoundIDFUl(void* param_0, u32 param_1); +extern "C" void __as__10JAISoundIDFRC10JAISoundID(JAISoundID* this_, JAISoundID const& param_0); extern "C" void sceneChange__10Z2SceneMgrF10JAISoundIDUcUcUcUcUcb(); extern "C" void framework__10Z2SceneMgrFv(); extern "C" void load1stDynamicWave__10Z2SceneMgrFv(); @@ -108,6 +107,7 @@ extern "C" void eraseBgmWave__10Z2SceneMgrFUl(); extern "C" void getWaveLoadStatus__10Z2SceneMgrFUlUl(); extern "C" void loadSeWave__10Z2SceneMgrFUl(); extern "C" void loadBgmWave__10Z2SceneMgrFUl(); +extern "C" void __ct__10JAISoundIDFUl(void* param_0, u32 param_1); extern "C" extern char const* const Z2SceneMgr__stringBase0; // @@ -707,9 +707,9 @@ asm void Z2SceneMgr::setSceneName(char* param_0, s32 param_1, s32 param_2) { } #pragma pop -//! @meme this looks to be non-inlined here because @ref setSceneName is too large -JAISoundID::JAISoundID(JAISoundID const& soundIdToSet) { - mId = soundIdToSet.mId; +//! @meme this looks to be non-inlined here because @ref setSceneName is too large* +extern "C" void __ct__10JAISoundIDFRC10JAISoundID(JAISoundID* this_, JAISoundID const& soundIdToSet) { + *this_ = soundIdToSet; } /* 802B9968-802B9978 2B42A8 0010+00 1/1 0/0 0/0 .text setFieldBgmPlay__8Z2SeqMgrFb */ @@ -795,7 +795,7 @@ asm void Z2SeqMgr::muteSceneBgm(u32 param_0, f32 param_1) { #pragma push #pragma optimization_level 0 #pragma optimizewithasm off -asm void JAISoundID::operator=(JAISoundID const& param_0) { +extern "C" asm void __as__10JAISoundIDFRC10JAISoundID(JAISoundID* this_, JAISoundID const& param_0) { nofralloc #include "asm/Z2AudioLib/Z2SceneMgr/__as__10JAISoundIDFRC10JAISoundID.s" } diff --git a/libs/Z2AudioLib/Z2WolfHowlMgr.cpp b/libs/Z2AudioLib/Z2WolfHowlMgr.cpp index e99da12893a..dcb579b215d 100644 --- a/libs/Z2AudioLib/Z2WolfHowlMgr.cpp +++ b/libs/Z2AudioLib/Z2WolfHowlMgr.cpp @@ -71,7 +71,7 @@ extern "C" void _savegpr_29(); extern "C" void _restgpr_28(); extern "C" void _restgpr_29(); extern "C" extern u32 __float_nan; -extern "C" extern u8 data_80450B38[4]; +extern "C" extern Z2WolfHowlMgr* data_80450B38; extern "C" extern u8 data_80450B44[4]; extern "C" extern u8 data_80450B60[4]; extern "C" extern u8 data_80450B74[4]; @@ -194,6 +194,35 @@ SECTION_SDATA2 static u8 lit_3485[4] = { SECTION_SDATA2 static f32 lit_3486 = 1.0f; /* 802CAAC0-802CAB8C 2C5400 00CC+00 0/0 1/1 0/0 .text __ct__13Z2WolfHowlMgrFv */ +#ifdef NONMATCHING +Z2WolfHowlMgr* JASGlobalInstance::sInstance = reinterpret_cast(data_80450B38); +Z2WolfHowlMgr::Z2WolfHowlMgr() : JASGlobalInstance(true) { + mpCurSong = NULL; + mNowInputValue = 0.0f; + field_0x18 = 1.0f; + field_0x1c = 1.0f; + field_0x20 = cPitchCenter; + field_0x24 = cPitchCenter; + field_0x28 = 1.0f; + mTimer = NULL; + mReleaseTimer = 0; + mCorrectCurveID = -1; + field_0x90 = -1; + field_0xba = 0; + field_0xbb = 0; + field_0xbc = 0; + for (u8 i = 0; i<20; i++) { + field_0x92[i] = 0; + } + for (u8 i = 0; i<10; i++) { + field_0x38[i] = 0.0f; + field_0x60[i] = 0.0f; + } + field_0x34 = 0.0f; + field_0x30 = 0.0f; + mpSongList = (Z2WolfHowlData**)&sGuideData; +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -202,8 +231,25 @@ asm Z2WolfHowlMgr::Z2WolfHowlMgr() { #include "asm/Z2AudioLib/Z2WolfHowlMgr/__ct__13Z2WolfHowlMgrFv.s" } #pragma pop +#endif /* 802CAB8C-802CABEC 2C54CC 0060+00 1/1 0/0 0/0 .text resetState__13Z2WolfHowlMgrFv */ +#ifdef NONMATCHING +void Z2WolfHowlMgr::resetState() { + field_0x18 = 1.0f; + field_0x24 = cPitchCenter; + field_0x28 = 1.0f; + mTimer = NULL; + mReleaseTimer = 0; + field_0xba = 0; + for (u8 i = 0; i<10; i++) { + field_0x38[i] = 0.0f; + field_0x60[i] = 0.0f; + } + field_0x34 = 0.0f; + field_0x30 = 0.0f; +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -212,6 +258,7 @@ asm void Z2WolfHowlMgr::resetState() { #include "asm/Z2AudioLib/Z2WolfHowlMgr/resetState__13Z2WolfHowlMgrFv.s" } #pragma pop +#endif /* ############################################################################################## */ /* 80455E68-80455E6C 004468 0004+00 2/2 0/0 0/0 .sdata2 @3527 */ diff --git a/src/m_Do/m_Do_main.cpp b/src/m_Do/m_Do_main.cpp index 5cd9a893aac..fe03c669103 100644 --- a/src/m_Do/m_Do_main.cpp +++ b/src/m_Do/m_Do_main.cpp @@ -20,6 +20,8 @@ #include "m_Do/m_Do_dvd_thread.h" #include "m_Do/m_Do_graphic.h" #include "m_Do/m_Do_machine.h" +#include "JSystem/JAudio2/JASGadget.h" +#include "JSystem/JAudio2/JASAudioThread.h" // // Forward References: @@ -735,6 +737,7 @@ u8 data_80450B88[4]; * sInstance__35JASGlobalInstance<14JASAudioThread> */ extern u8 data_80450B8C[4]; u8 data_80450B8C[4]; +//JASAudioThread* JASGlobalInstance::sInstance; /* 80450B90-80450B98 000090 0004+04 0/0 4/4 0/0 .sbss * sInstance__40JASGlobalInstance<19JASDefaultBankTable> */