diff --git a/asm/musyx/txwin/txwin.s b/asm/musyx/txwin/txwin.s new file mode 100644 index 00000000..699c8a73 --- /dev/null +++ b/asm/musyx/txwin/txwin.s @@ -0,0 +1,858 @@ +.include "macros.inc" +.file "txwin.c" + +# 0x00000000 - 0x0000091C +.text +.balign 4 + +.fn winInit, global +/* 00000000 00000034 7C 08 02 A6 */ mflr r0 +/* 00000004 00000038 90 01 00 04 */ stw r0, 0x4(r1) +/* 00000008 0000003C 94 21 FF F0 */ stwu r1, -0x10(r1) +/* 0000000C 00000040 38 00 00 00 */ li r0, 0x0 +/* 00000010 00000044 90 00 00 00 */ stw r0, __FirstNode@sda21(r0) +/* 00000014 00000048 38 00 00 00 */ li r0, 0x0 +/* 00000018 0000004C 90 00 00 00 */ stw r0, __LastNode@sda21(r0) +/* 0000001C 00000050 38 00 00 00 */ li r0, 0x0 +/* 00000020 00000054 90 00 00 00 */ stw r0, __CurrNode@sda21(r0) +/* 00000024 00000058 38 60 00 08 */ li r3, 0x8 +/* 00000028 0000005C 48 00 00 01 */ bl winSetFontSize +/* 0000002C 00000060 48 00 00 01 */ bl DEMOGetRenderModeObj +/* 00000030 00000064 90 60 00 00 */ stw r3, __rmp@sda21(r0) +/* 00000034 00000068 80 00 00 00 */ lwz r0, "@13"@sda21(r0) +/* 00000038 0000006C 90 01 00 08 */ stw r0, 0x8(r1) +/* 0000003C 00000070 80 01 00 08 */ lwz r0, 0x8(r1) +/* 00000040 00000074 90 01 00 0C */ stw r0, 0xc(r1) +/* 00000044 00000078 38 61 00 0C */ addi r3, r1, 0xc +/* 00000048 0000007C 3C 80 01 00 */ lis r4, 0x100 +/* 0000004C 00000080 38 84 FF FF */ addi r4, r4, -0x1 +/* 00000050 00000084 48 00 00 01 */ bl GXSetCopyClear +/* 00000054 00000088 80 01 00 14 */ lwz r0, 0x14(r1) +/* 00000058 0000008C 38 21 00 10 */ addi r1, r1, 0x10 +/* 0000005C 00000090 7C 08 03 A6 */ mtlr r0 +/* 00000060 00000094 4E 80 00 20 */ blr +.endfn winInit + +.fn winOpenWindow, global +/* 00000064 00000098 7C 08 02 A6 */ mflr r0 +/* 00000068 0000009C 90 01 00 04 */ stw r0, 0x4(r1) +/* 0000006C 000000A0 94 21 FF C0 */ stwu r1, -0x40(r1) +/* 00000070 000000A4 BF 41 00 28 */ stmw r26, 0x28(r1) +/* 00000074 000000A8 3B 43 00 00 */ addi r26, r3, 0x0 +/* 00000078 000000AC 3B 64 00 00 */ addi r27, r4, 0x0 +/* 0000007C 000000B0 3B 85 00 00 */ addi r28, r5, 0x0 +/* 00000080 000000B4 3B A6 00 00 */ addi r29, r6, 0x0 +/* 00000084 000000B8 90 E1 00 18 */ stw r7, 0x18(r1) +/* 00000088 000000BC 91 01 00 1C */ stw r8, 0x1c(r1) +/* 0000008C 000000C0 91 21 00 20 */ stw r9, 0x20(r1) +/* 00000090 000000C4 3C 60 00 00 */ lis r3, ...data.0@ha +/* 00000094 000000C8 3B C3 00 00 */ addi r30, r3, ...data.0@l +/* 00000098 000000CC 7C 1A E0 00 */ cmpw r26, r28 +/* 0000009C 000000D0 41 80 00 18 */ blt .L_000000B4 +/* 000000A0 000000D4 38 60 00 00 */ li r3, "@19"@sda21 +/* 000000A4 000000D8 38 80 00 6D */ li r4, 0x6d +/* 000000A8 000000DC 38 BE 00 00 */ addi r5, r30, 0x0 +/* 000000AC 000000E0 4C C6 31 82 */ crclr 4*cr1+eq +/* 000000B0 000000E4 48 00 00 01 */ bl OSPanic +.L_000000B4: +/* 000000B4 000000E8 7C 1B E8 00 */ cmpw r27, r29 +/* 000000B8 000000EC 41 80 00 18 */ blt .L_000000D0 +/* 000000BC 000000F0 38 60 00 00 */ li r3, "@19"@sda21 +/* 000000C0 000000F4 38 80 00 6E */ li r4, 0x6e +/* 000000C4 000000F8 38 BE 00 24 */ addi r5, r30, 0x24 +/* 000000C8 000000FC 4C C6 31 82 */ crclr 4*cr1+eq +/* 000000CC 00000100 48 00 00 01 */ bl OSPanic +.L_000000D0: +/* 000000D0 00000104 80 60 00 00 */ lwz r3, __OSCurrHeap@sda21(r0) +/* 000000D4 00000108 38 80 00 4C */ li r4, 0x4c +/* 000000D8 0000010C 48 00 00 01 */ bl OSAllocFromHeap +/* 000000DC 00000110 7C 7F 1B 78 */ mr r31, r3 +/* 000000E0 00000114 28 1F 00 00 */ cmplwi r31, 0x0 +/* 000000E4 00000118 40 82 00 18 */ bne .L_000000FC +/* 000000E8 0000011C 38 60 00 00 */ li r3, "@19"@sda21 +/* 000000EC 00000120 38 80 00 72 */ li r4, 0x72 +/* 000000F0 00000124 38 BE 00 48 */ addi r5, r30, 0x48 +/* 000000F4 00000128 4C C6 31 82 */ crclr 4*cr1+eq +/* 000000F8 0000012C 48 00 00 01 */ bl OSPanic +.L_000000FC: +/* 000000FC 00000130 7F E3 FB 78 */ mr r3, r31 +/* 00000100 00000134 48 00 00 01 */ bl __win_add_node +/* 00000104 00000138 93 5F 00 00 */ stw r26, 0x0(r31) +/* 00000108 0000013C 93 7F 00 04 */ stw r27, 0x4(r31) +/* 0000010C 00000140 93 9F 00 08 */ stw r28, 0x8(r31) +/* 00000110 00000144 93 BF 00 0C */ stw r29, 0xc(r31) +/* 00000114 00000148 7C 7A E0 50 */ subf r3, r26, r28 +/* 00000118 0000014C 38 03 00 01 */ addi r0, r3, 0x1 +/* 0000011C 00000150 90 1F 00 20 */ stw r0, 0x20(r31) +/* 00000120 00000154 7C 7B E8 50 */ subf r3, r27, r29 +/* 00000124 00000158 38 03 00 01 */ addi r0, r3, 0x1 +/* 00000128 0000015C 90 1F 00 24 */ stw r0, 0x24(r31) +/* 0000012C 00000160 38 00 00 00 */ li r0, 0x0 +/* 00000130 00000164 90 1F 00 18 */ stw r0, 0x18(r31) +/* 00000134 00000168 38 00 00 00 */ li r0, 0x0 +/* 00000138 0000016C 90 1F 00 1C */ stw r0, 0x1c(r31) +/* 0000013C 00000170 80 01 00 18 */ lwz r0, 0x18(r1) +/* 00000140 00000174 90 1F 00 10 */ stw r0, 0x10(r31) +/* 00000144 00000178 80 1F 00 20 */ lwz r0, 0x20(r31) +/* 00000148 0000017C 7C 00 1E 70 */ srawi r0, r0, 3 +/* 0000014C 00000180 7C 00 01 94 */ addze r0, r0 +/* 00000150 00000184 90 1F 00 28 */ stw r0, 0x28(r31) +/* 00000154 00000188 80 1F 00 24 */ lwz r0, 0x24(r31) +/* 00000158 0000018C 7C 00 1E 70 */ srawi r0, r0, 3 +/* 0000015C 00000190 7C 00 01 94 */ addze r0, r0 +/* 00000160 00000194 90 1F 00 2C */ stw r0, 0x2c(r31) +/* 00000164 00000198 80 01 00 1C */ lwz r0, 0x1c(r1) +/* 00000168 0000019C 90 1F 00 40 */ stw r0, 0x40(r31) +/* 0000016C 000001A0 80 01 00 20 */ lwz r0, 0x20(r1) +/* 00000170 000001A4 90 1F 00 14 */ stw r0, 0x14(r31) +/* 00000174 000001A8 7F E3 FB 78 */ mr r3, r31 +/* 00000178 000001AC 80 01 00 44 */ lwz r0, 0x44(r1) +/* 0000017C 000001B0 BB 41 00 28 */ lmw r26, 0x28(r1) +/* 00000180 000001B4 38 21 00 40 */ addi r1, r1, 0x40 +/* 00000184 000001B8 7C 08 03 A6 */ mtlr r0 +/* 00000188 000001BC 4E 80 00 20 */ blr +.endfn winOpenWindow + +.fn winOpenLogWindow, global +/* 0000018C 000001C0 7C 08 02 A6 */ mflr r0 +/* 00000190 000001C4 90 01 00 04 */ stw r0, 0x4(r1) +/* 00000194 000001C8 94 21 FF D0 */ stwu r1, -0x30(r1) +/* 00000198 000001CC BF C1 00 28 */ stmw r30, 0x28(r1) +/* 0000019C 000001D0 90 61 00 08 */ stw r3, 0x8(r1) +/* 000001A0 000001D4 90 81 00 0C */ stw r4, 0xc(r1) +/* 000001A4 000001D8 90 A1 00 10 */ stw r5, 0x10(r1) +/* 000001A8 000001DC 90 C1 00 14 */ stw r6, 0x14(r1) +/* 000001AC 000001E0 90 E1 00 18 */ stw r7, 0x18(r1) +/* 000001B0 000001E4 B1 01 00 1C */ sth r8, 0x1c(r1) +/* 000001B4 000001E8 80 61 00 08 */ lwz r3, 0x8(r1) +/* 000001B8 000001EC 80 81 00 0C */ lwz r4, 0xc(r1) +/* 000001BC 000001F0 80 A1 00 10 */ lwz r5, 0x10(r1) +/* 000001C0 000001F4 80 C1 00 14 */ lwz r6, 0x14(r1) +/* 000001C4 000001F8 80 E1 00 18 */ lwz r7, 0x18(r1) +/* 000001C8 000001FC 39 00 00 00 */ li r8, 0x0 +/* 000001CC 00000200 39 20 00 00 */ li r9, 0x0 +/* 000001D0 00000204 48 00 00 01 */ bl winOpenWindow +/* 000001D4 00000208 7C 7F 1B 78 */ mr r31, r3 +/* 000001D8 0000020C 3C 60 00 00 */ lis r3, __win_log_refresh@ha +/* 000001DC 00000210 38 03 00 00 */ addi r0, r3, __win_log_refresh@l +/* 000001E0 00000214 90 1F 00 40 */ stw r0, 0x40(r31) +/* 000001E4 00000218 38 00 00 01 */ li r0, 0x1 +/* 000001E8 0000021C 90 1F 00 14 */ stw r0, 0x14(r31) +/* 000001EC 00000220 38 00 00 00 */ li r0, 0x0 +/* 000001F0 00000224 B0 1F 00 3A */ sth r0, 0x3a(r31) +/* 000001F4 00000228 38 00 00 00 */ li r0, 0x0 +/* 000001F8 0000022C B0 1F 00 3C */ sth r0, 0x3c(r31) +/* 000001FC 00000230 80 1F 00 2C */ lwz r0, 0x2c(r31) +/* 00000200 00000234 54 03 04 3E */ clrlwi r3, r0, 16 +/* 00000204 00000238 A0 01 00 1C */ lhz r0, 0x1c(r1) +/* 00000208 0000023C 7C 03 02 14 */ add r0, r3, r0 +/* 0000020C 00000240 B0 1F 00 38 */ sth r0, 0x38(r31) +/* 00000210 00000244 80 60 00 00 */ lwz r3, __OSCurrHeap@sda21(r0) +/* 00000214 00000248 A0 1F 00 38 */ lhz r0, 0x38(r31) +/* 00000218 0000024C 54 04 10 3A */ slwi r4, r0, 2 +/* 0000021C 00000250 48 00 00 01 */ bl OSAllocFromHeap +/* 00000220 00000254 90 7F 00 34 */ stw r3, 0x34(r31) +/* 00000224 00000258 80 1F 00 34 */ lwz r0, 0x34(r31) +/* 00000228 0000025C 28 00 00 00 */ cmplwi r0, 0x0 +/* 0000022C 00000260 40 82 00 1C */ bne .L_00000248 +/* 00000230 00000264 38 60 00 00 */ li r3, "@19"@sda21 +/* 00000234 00000268 38 80 00 C1 */ li r4, 0xc1 +/* 00000238 0000026C 3C A0 00 00 */ lis r5, "@29"@ha +/* 0000023C 00000270 38 A5 00 00 */ addi r5, r5, "@29"@l +/* 00000240 00000274 4C C6 31 82 */ crclr 4*cr1+eq +/* 00000244 00000278 48 00 00 01 */ bl OSPanic +.L_00000248: +/* 00000248 0000027C 3B C0 00 00 */ li r30, 0x0 +/* 0000024C 00000280 48 00 00 6C */ b .L_000002B8 +.L_00000250: +/* 00000250 00000284 80 60 00 00 */ lwz r3, __OSCurrHeap@sda21(r0) +/* 00000254 00000288 80 9F 00 28 */ lwz r4, 0x28(r31) +/* 00000258 0000028C 38 84 00 01 */ addi r4, r4, 0x1 +/* 0000025C 00000290 48 00 00 01 */ bl OSAllocFromHeap +/* 00000260 00000294 80 9F 00 34 */ lwz r4, 0x34(r31) +/* 00000264 00000298 57 C0 13 BA */ clrlslwi r0, r30, 16, 2 +/* 00000268 0000029C 7C 64 01 2E */ stwx r3, r4, r0 +/* 0000026C 000002A0 80 7F 00 34 */ lwz r3, 0x34(r31) +/* 00000270 000002A4 57 C0 13 BA */ clrlslwi r0, r30, 16, 2 +/* 00000274 000002A8 7C 63 00 2E */ lwzx r3, r3, r0 +/* 00000278 000002AC 38 80 00 00 */ li r4, 0x0 +/* 0000027C 000002B0 80 BF 00 28 */ lwz r5, 0x28(r31) +/* 00000280 000002B4 38 A5 00 01 */ addi r5, r5, 0x1 +/* 00000284 000002B8 48 00 00 01 */ bl memset +/* 00000288 000002BC 80 7F 00 34 */ lwz r3, 0x34(r31) +/* 0000028C 000002C0 57 C0 13 BA */ clrlslwi r0, r30, 16, 2 +/* 00000290 000002C4 7C 03 00 2E */ lwzx r0, r3, r0 +/* 00000294 000002C8 28 00 00 00 */ cmplwi r0, 0x0 +/* 00000298 000002CC 40 82 00 1C */ bne .L_000002B4 +/* 0000029C 000002D0 38 60 00 00 */ li r3, "@19"@sda21 +/* 000002A0 000002D4 38 80 00 C9 */ li r4, 0xc9 +/* 000002A4 000002D8 3C A0 00 00 */ lis r5, "@30"@ha +/* 000002A8 000002DC 38 A5 00 00 */ addi r5, r5, "@30"@l +/* 000002AC 000002E0 4C C6 31 82 */ crclr 4*cr1+eq +/* 000002B0 000002E4 48 00 00 01 */ bl OSPanic +.L_000002B4: +/* 000002B4 000002E8 3B DE 00 01 */ addi r30, r30, 0x1 +.L_000002B8: +/* 000002B8 000002EC 57 C3 04 3E */ clrlwi r3, r30, 16 +/* 000002BC 000002F0 A0 1F 00 38 */ lhz r0, 0x38(r31) +/* 000002C0 000002F4 7C 03 00 40 */ cmplw r3, r0 +/* 000002C4 000002F8 41 80 FF 8C */ blt .L_00000250 +/* 000002C8 000002FC 7F E3 FB 78 */ mr r3, r31 +/* 000002CC 00000300 80 01 00 34 */ lwz r0, 0x34(r1) +/* 000002D0 00000304 BB C1 00 28 */ lmw r30, 0x28(r1) +/* 000002D4 00000308 38 21 00 30 */ addi r1, r1, 0x30 +/* 000002D8 0000030C 7C 08 03 A6 */ mtlr r0 +/* 000002DC 00000310 4E 80 00 20 */ blr +.endfn winOpenLogWindow + +.fn winPrintfXY, global +/* 000002E0 00000314 7C 08 02 A6 */ mflr r0 +/* 000002E4 00000318 90 01 00 04 */ stw r0, 0x4(r1) +/* 000002E8 0000031C 94 21 FE F0 */ stwu r1, -0x110(r1) +/* 000002EC 00000320 BF 81 01 00 */ stmw r28, 0x100(r1) +/* 000002F0 00000324 40 86 00 24 */ bne cr1, .L_00000314 +/* 000002F4 00000328 D8 21 00 28 */ stfd f1, 0x28(r1) +/* 000002F8 0000032C D8 41 00 30 */ stfd f2, 0x30(r1) +/* 000002FC 00000330 D8 61 00 38 */ stfd f3, 0x38(r1) +/* 00000300 00000334 D8 81 00 40 */ stfd f4, 0x40(r1) +/* 00000304 00000338 D8 A1 00 48 */ stfd f5, 0x48(r1) +/* 00000308 0000033C D8 C1 00 50 */ stfd f6, 0x50(r1) +/* 0000030C 00000340 D8 E1 00 58 */ stfd f7, 0x58(r1) +/* 00000310 00000344 D9 01 00 60 */ stfd f8, 0x60(r1) +.L_00000314: +/* 00000314 00000348 90 61 00 08 */ stw r3, 0x8(r1) +/* 00000318 0000034C 90 81 00 0C */ stw r4, 0xc(r1) +/* 0000031C 00000350 90 A1 00 10 */ stw r5, 0x10(r1) +/* 00000320 00000354 90 C1 00 14 */ stw r6, 0x14(r1) +/* 00000324 00000358 90 E1 00 18 */ stw r7, 0x18(r1) +/* 00000328 0000035C 91 01 00 1C */ stw r8, 0x1c(r1) +/* 0000032C 00000360 91 21 00 20 */ stw r9, 0x20(r1) +/* 00000330 00000364 91 41 00 24 */ stw r10, 0x24(r1) +/* 00000334 00000368 7C 7F 1B 78 */ mr r31, r3 +/* 00000338 0000036C B0 81 00 6C */ sth r4, 0x6c(r1) +/* 0000033C 00000370 B0 A1 00 6E */ sth r5, 0x6e(r1) +/* 00000340 00000374 7C DC 33 78 */ mr r28, r6 +/* 00000344 00000378 3C 00 04 00 */ lis r0, 0x400 +/* 00000348 0000037C 90 01 00 F4 */ stw r0, 0xf4(r1) +/* 0000034C 00000380 38 01 01 18 */ addi r0, r1, 0x118 +/* 00000350 00000384 90 01 00 F8 */ stw r0, 0xf8(r1) +/* 00000354 00000388 38 01 00 08 */ addi r0, r1, 0x8 +/* 00000358 0000038C 90 01 00 FC */ stw r0, 0xfc(r1) +/* 0000035C 00000390 38 61 00 74 */ addi r3, r1, 0x74 +/* 00000360 00000394 38 9C 00 00 */ addi r4, r28, 0x0 +/* 00000364 00000398 38 A1 00 F4 */ addi r5, r1, 0xf4 +/* 00000368 0000039C 48 00 00 01 */ bl vsprintf +/* 0000036C 000003A0 38 61 00 74 */ addi r3, r1, 0x74 +/* 00000370 000003A4 48 00 00 01 */ bl strlen +/* 00000374 000003A8 80 1F 00 28 */ lwz r0, 0x28(r31) +/* 00000378 000003AC 7C 03 00 40 */ cmplw r3, r0 +/* 0000037C 000003B0 40 81 00 14 */ ble .L_00000390 +/* 00000380 000003B4 38 80 00 00 */ li r4, 0x0 +/* 00000384 000003B8 80 1F 00 28 */ lwz r0, 0x28(r31) +/* 00000388 000003BC 38 61 00 74 */ addi r3, r1, 0x74 +/* 0000038C 000003C0 7C 83 01 AE */ stbx r4, r3, r0 +.L_00000390: +/* 00000390 000003C4 80 7F 00 00 */ lwz r3, 0x0(r31) +/* 00000394 000003C8 A8 01 00 6C */ lha r0, 0x6c(r1) +/* 00000398 000003CC 54 00 18 38 */ slwi r0, r0, 3 +/* 0000039C 000003D0 7F C3 02 14 */ add r30, r3, r0 +/* 000003A0 000003D4 80 7F 00 04 */ lwz r3, 0x4(r31) +/* 000003A4 000003D8 A8 01 00 6E */ lha r0, 0x6e(r1) +/* 000003A8 000003DC 54 00 18 38 */ slwi r0, r0, 3 +/* 000003AC 000003E0 7F A3 02 14 */ add r29, r3, r0 +/* 000003B0 000003E4 38 7E 00 00 */ addi r3, r30, 0x0 +/* 000003B4 000003E8 38 9D 00 00 */ addi r4, r29, 0x0 +/* 000003B8 000003EC 38 A0 00 00 */ li r5, 0x0 +/* 000003BC 000003F0 38 C0 00 00 */ li r6, "@34"@sda21 +/* 000003C0 000003F4 38 E1 00 74 */ addi r7, r1, 0x74 +/* 000003C4 000003F8 4C C6 31 82 */ crclr 4*cr1+eq +/* 000003C8 000003FC 48 00 00 01 */ bl DEMOPrintf +/* 000003CC 00000400 80 01 01 14 */ lwz r0, 0x114(r1) +/* 000003D0 00000404 BB 81 01 00 */ lmw r28, 0x100(r1) +/* 000003D4 00000408 38 21 01 10 */ addi r1, r1, 0x110 +/* 000003D8 0000040C 7C 08 03 A6 */ mtlr r0 +/* 000003DC 00000410 4E 80 00 20 */ blr +.endfn winPrintfXY + +.fn winLogPrintf, global +/* 000003E0 00000414 7C 08 02 A6 */ mflr r0 +/* 000003E4 00000418 90 01 00 04 */ stw r0, 0x4(r1) +/* 000003E8 0000041C 94 21 FE F8 */ stwu r1, -0x108(r1) +/* 000003EC 00000420 BF C1 01 00 */ stmw r30, 0x100(r1) +/* 000003F0 00000424 40 86 00 24 */ bne cr1, .L_00000414 +/* 000003F4 00000428 D8 21 00 28 */ stfd f1, 0x28(r1) +/* 000003F8 0000042C D8 41 00 30 */ stfd f2, 0x30(r1) +/* 000003FC 00000430 D8 61 00 38 */ stfd f3, 0x38(r1) +/* 00000400 00000434 D8 81 00 40 */ stfd f4, 0x40(r1) +/* 00000404 00000438 D8 A1 00 48 */ stfd f5, 0x48(r1) +/* 00000408 0000043C D8 C1 00 50 */ stfd f6, 0x50(r1) +/* 0000040C 00000440 D8 E1 00 58 */ stfd f7, 0x58(r1) +/* 00000410 00000444 D9 01 00 60 */ stfd f8, 0x60(r1) +.L_00000414: +/* 00000414 00000448 90 61 00 08 */ stw r3, 0x8(r1) +/* 00000418 0000044C 90 81 00 0C */ stw r4, 0xc(r1) +/* 0000041C 00000450 90 A1 00 10 */ stw r5, 0x10(r1) +/* 00000420 00000454 90 C1 00 14 */ stw r6, 0x14(r1) +/* 00000424 00000458 90 E1 00 18 */ stw r7, 0x18(r1) +/* 00000428 0000045C 91 01 00 1C */ stw r8, 0x1c(r1) +/* 0000042C 00000460 91 21 00 20 */ stw r9, 0x20(r1) +/* 00000430 00000464 91 41 00 24 */ stw r10, 0x24(r1) +/* 00000434 00000468 3B E3 00 00 */ addi r31, r3, 0x0 +/* 00000438 0000046C 3B C4 00 00 */ addi r30, r4, 0x0 +/* 0000043C 00000470 3C 00 02 00 */ lis r0, 0x200 +/* 00000440 00000474 90 01 00 F0 */ stw r0, 0xf0(r1) +/* 00000444 00000478 38 01 01 10 */ addi r0, r1, 0x110 +/* 00000448 0000047C 90 01 00 F4 */ stw r0, 0xf4(r1) +/* 0000044C 00000480 38 01 00 08 */ addi r0, r1, 0x8 +/* 00000450 00000484 90 01 00 F8 */ stw r0, 0xf8(r1) +/* 00000454 00000488 38 61 00 70 */ addi r3, r1, 0x70 +/* 00000458 0000048C 38 9E 00 00 */ addi r4, r30, 0x0 +/* 0000045C 00000490 38 A1 00 F0 */ addi r5, r1, 0xf0 +/* 00000460 00000494 48 00 00 01 */ bl vsprintf +/* 00000464 00000498 38 61 00 70 */ addi r3, r1, 0x70 +/* 00000468 0000049C 48 00 00 01 */ bl strlen +/* 0000046C 000004A0 80 1F 00 28 */ lwz r0, 0x28(r31) +/* 00000470 000004A4 7C 03 00 40 */ cmplw r3, r0 +/* 00000474 000004A8 40 81 00 14 */ ble .L_00000488 +/* 00000478 000004AC 38 80 00 00 */ li r4, 0x0 +/* 0000047C 000004B0 80 1F 00 28 */ lwz r0, 0x28(r31) +/* 00000480 000004B4 38 61 00 70 */ addi r3, r1, 0x70 +/* 00000484 000004B8 7C 83 01 AE */ stbx r4, r3, r0 +.L_00000488: +/* 00000488 000004BC 80 7F 00 34 */ lwz r3, 0x34(r31) +/* 0000048C 000004C0 A0 1F 00 3A */ lhz r0, 0x3a(r31) +/* 00000490 000004C4 54 00 10 3A */ slwi r0, r0, 2 +/* 00000494 000004C8 7C 63 00 2E */ lwzx r3, r3, r0 +/* 00000498 000004CC 38 81 00 70 */ addi r4, r1, 0x70 +/* 0000049C 000004D0 48 00 00 01 */ bl strcpy +/* 000004A0 000004D4 A0 7F 00 3A */ lhz r3, 0x3a(r31) +/* 000004A4 000004D8 38 83 00 01 */ addi r4, r3, 0x1 +/* 000004A8 000004DC A0 7F 00 38 */ lhz r3, 0x38(r31) +/* 000004AC 000004E0 7C 04 1B D6 */ divw r0, r4, r3 +/* 000004B0 000004E4 7C 00 19 D6 */ mullw r0, r0, r3 +/* 000004B4 000004E8 7C 60 20 50 */ subf r3, r0, r4 +/* 000004B8 000004EC B0 7F 00 3A */ sth r3, 0x3a(r31) +/* 000004BC 000004F0 80 01 01 0C */ lwz r0, 0x10c(r1) +/* 000004C0 000004F4 BB C1 01 00 */ lmw r30, 0x100(r1) +/* 000004C4 000004F8 38 21 01 08 */ addi r1, r1, 0x108 +/* 000004C8 000004FC 7C 08 03 A6 */ mtlr r0 +/* 000004CC 00000500 4E 80 00 20 */ blr +.endfn winLogPrintf + +.fn winClearLogWindow, global +/* 000004D0 00000504 7C 08 02 A6 */ mflr r0 +/* 000004D4 00000508 90 01 00 04 */ stw r0, 0x4(r1) +/* 000004D8 0000050C 94 21 FF E8 */ stwu r1, -0x18(r1) +/* 000004DC 00000510 BF C1 00 10 */ stmw r30, 0x10(r1) +/* 000004E0 00000514 7C 7F 1B 78 */ mr r31, r3 +/* 000004E4 00000518 3B C0 00 00 */ li r30, 0x0 +/* 000004E8 0000051C 48 00 00 24 */ b .L_0000050C +.L_000004EC: +/* 000004EC 00000520 80 7F 00 34 */ lwz r3, 0x34(r31) +/* 000004F0 00000524 57 C0 13 BA */ clrlslwi r0, r30, 16, 2 +/* 000004F4 00000528 7C 63 00 2E */ lwzx r3, r3, r0 +/* 000004F8 0000052C 38 80 00 00 */ li r4, 0x0 +/* 000004FC 00000530 80 BF 00 28 */ lwz r5, 0x28(r31) +/* 00000500 00000534 38 A5 00 01 */ addi r5, r5, 0x1 +/* 00000504 00000538 48 00 00 01 */ bl memset +/* 00000508 0000053C 3B DE 00 01 */ addi r30, r30, 0x1 +.L_0000050C: +/* 0000050C 00000540 57 C3 04 3E */ clrlwi r3, r30, 16 +/* 00000510 00000544 A0 1F 00 38 */ lhz r0, 0x38(r31) +/* 00000514 00000548 7C 03 00 40 */ cmplw r3, r0 +/* 00000518 0000054C 41 80 FF D4 */ blt .L_000004EC +/* 0000051C 00000550 38 00 00 00 */ li r0, 0x0 +/* 00000520 00000554 B0 1F 00 3A */ sth r0, 0x3a(r31) +/* 00000524 00000558 38 00 00 00 */ li r0, 0x0 +/* 00000528 0000055C B0 1F 00 3C */ sth r0, 0x3c(r31) +/* 0000052C 00000560 80 01 00 1C */ lwz r0, 0x1c(r1) +/* 00000530 00000564 BB C1 00 10 */ lmw r30, 0x10(r1) +/* 00000534 00000568 38 21 00 18 */ addi r1, r1, 0x18 +/* 00000538 0000056C 7C 08 03 A6 */ mtlr r0 +/* 0000053C 00000570 4E 80 00 20 */ blr + +.fn winSetFontSize, global +.endfn winClearLogWindow +/* 00000540 00000574 94 21 FF D0 */ stwu r1, -0x30(r1) +/* 00000544 00000578 54 60 04 3E */ clrlwi r0, r3, 16 +/* 00000548 0000057C 28 00 00 08 */ cmplwi r0, 0x8 +/* 0000054C 00000580 41 80 00 84 */ blt .L_000005D0 +/* 00000550 00000584 54 60 04 3E */ clrlwi r0, r3, 16 +/* 00000554 00000588 28 00 00 28 */ cmplwi r0, 0x28 +/* 00000558 0000058C 41 81 00 78 */ bgt .L_000005D0 +/* 0000055C 00000590 C8 60 00 00 */ lfd f3, "@49"@sda21(r0) +/* 00000560 00000594 C8 40 00 00 */ lfd f2, "@50"@sda21(r0) +/* 00000564 00000598 54 60 04 3E */ clrlwi r0, r3, 16 +/* 00000568 0000059C C8 20 00 00 */ lfd f1, "@53"@sda21(r0) +/* 0000056C 000005A0 90 01 00 2C */ stw r0, 0x2c(r1) +/* 00000570 000005A4 3C 00 43 30 */ lis r0, 0x4330 +/* 00000574 000005A8 90 01 00 28 */ stw r0, 0x28(r1) +/* 00000578 000005AC C8 01 00 28 */ lfd f0, 0x28(r1) +/* 0000057C 000005B0 EC 00 08 28 */ fsubs f0, f0, f1 +/* 00000580 000005B4 FC 02 00 24 */ fdiv f0, f2, f0 +/* 00000584 000005B8 FC 03 00 32 */ fmul f0, f3, f0 +/* 00000588 000005BC FC 00 00 1E */ fctiwz f0, f0 +/* 0000058C 000005C0 D8 01 00 20 */ stfd f0, 0x20(r1) +/* 00000590 000005C4 80 01 00 24 */ lwz r0, 0x24(r1) +/* 00000594 000005C8 B0 00 00 00 */ sth r0, __X_Res@sda21(r0) +/* 00000598 000005CC C8 40 00 00 */ lfd f2, "@51"@sda21(r0) +/* 0000059C 000005D0 A0 00 00 00 */ lhz r0, __X_Res@sda21(r0) +/* 000005A0 000005D4 C8 20 00 00 */ lfd f1, "@53"@sda21(r0) +/* 000005A4 000005D8 90 01 00 1C */ stw r0, 0x1c(r1) +/* 000005A8 000005DC 3C 00 43 30 */ lis r0, 0x4330 +/* 000005AC 000005E0 90 01 00 18 */ stw r0, 0x18(r1) +/* 000005B0 000005E4 C8 01 00 18 */ lfd f0, 0x18(r1) +/* 000005B4 000005E8 EC 00 08 28 */ fsubs f0, f0, f1 +/* 000005B8 000005EC FC 02 00 32 */ fmul f0, f2, f0 +/* 000005BC 000005F0 FC 00 00 1E */ fctiwz f0, f0 +/* 000005C0 000005F4 D8 01 00 10 */ stfd f0, 0x10(r1) +/* 000005C4 000005F8 80 01 00 14 */ lwz r0, 0x14(r1) +/* 000005C8 000005FC B0 00 00 00 */ sth r0, __Y_Res@sda21(r0) +/* 000005CC 00000600 48 00 00 14 */ b .L_000005E0 +.L_000005D0: +/* 000005D0 00000604 38 00 02 80 */ li r0, 0x280 +/* 000005D4 00000608 B0 00 00 00 */ sth r0, __X_Res@sda21(r0) +/* 000005D8 0000060C 38 00 01 E0 */ li r0, 0x1e0 +/* 000005DC 00000610 B0 00 00 00 */ sth r0, __Y_Res@sda21(r0) +.L_000005E0: +/* 000005E0 00000614 38 21 00 30 */ addi r1, r1, 0x30 +/* 000005E4 00000618 4E 80 00 20 */ blr +.endfn winSetFontSize + +.fn winRefresh, global +/* 000005E8 0000061C 7C 08 02 A6 */ mflr r0 +/* 000005EC 00000620 90 01 00 04 */ stw r0, 0x4(r1) +/* 000005F0 00000624 94 21 FF F0 */ stwu r1, -0x10(r1) +/* 000005F4 00000628 93 E1 00 0C */ stw r31, 0xc(r1) +/* 000005F8 0000062C 80 00 00 00 */ lwz r0, __FirstNode@sda21(r0) +/* 000005FC 00000630 28 00 00 00 */ cmplwi r0, 0x0 +/* 00000600 00000634 40 82 00 1C */ bne .L_0000061C +/* 00000604 00000638 38 60 00 00 */ li r3, "@19"@sda21 +/* 00000608 0000063C 38 80 01 52 */ li r4, 0x152 +/* 0000060C 00000640 3C A0 00 00 */ lis r5, "@64"@ha +/* 00000610 00000644 38 A5 00 00 */ addi r5, r5, "@64"@l +/* 00000614 00000648 4C C6 31 82 */ crclr 4*cr1+eq +/* 00000618 0000064C 48 00 00 01 */ bl OSPanic +.L_0000061C: +/* 0000061C 00000650 83 E0 00 00 */ lwz r31, __FirstNode@sda21(r0) +/* 00000620 00000654 38 60 00 02 */ li r3, 0x2 +/* 00000624 00000658 A0 80 00 00 */ lhz r4, __X_Res@sda21(r0) +/* 00000628 0000065C A0 A0 00 00 */ lhz r5, __Y_Res@sda21(r0) +/* 0000062C 00000660 48 00 00 01 */ bl DEMOInitCaption +/* 00000630 00000664 48 00 00 24 */ b .L_00000654 +.L_00000634: +/* 00000634 00000668 80 1F 00 40 */ lwz r0, 0x40(r31) +/* 00000638 0000066C 28 00 00 00 */ cmplwi r0, 0x0 +/* 0000063C 00000670 41 82 00 14 */ beq .L_00000650 +/* 00000640 00000674 7F E3 FB 78 */ mr r3, r31 +/* 00000644 00000678 81 9F 00 40 */ lwz r12, 0x40(r31) +/* 00000648 0000067C 7D 88 03 A6 */ mtlr r12 +/* 0000064C 00000680 4E 80 00 21 */ blrl +.L_00000650: +/* 00000650 00000684 83 FF 00 44 */ lwz r31, 0x44(r31) +.L_00000654: +/* 00000654 00000688 28 1F 00 00 */ cmplwi r31, 0x0 +/* 00000658 0000068C 40 82 FF DC */ bne .L_00000634 +/* 0000065C 00000690 80 01 00 14 */ lwz r0, 0x14(r1) +/* 00000660 00000694 83 E1 00 0C */ lwz r31, 0xc(r1) +/* 00000664 00000698 38 21 00 10 */ addi r1, r1, 0x10 +/* 00000668 0000069C 7C 08 03 A6 */ mtlr r0 +/* 0000066C 000006A0 4E 80 00 20 */ blr + +.fn __win_add_node, local +.endfn winRefresh +/* 00000670 000006A4 7C 08 02 A6 */ mflr r0 +/* 00000674 000006A8 90 01 00 04 */ stw r0, 0x4(r1) +/* 00000678 000006AC 94 21 FF E8 */ stwu r1, -0x18(r1) +/* 0000067C 000006B0 93 E1 00 14 */ stw r31, 0x14(r1) +/* 00000680 000006B4 7C 7F 1B 78 */ mr r31, r3 +/* 00000684 000006B8 28 1F 00 00 */ cmplwi r31, 0x0 +/* 00000688 000006BC 40 82 00 1C */ bne .L_000006A4 +/* 0000068C 000006C0 38 60 00 00 */ li r3, "@19"@sda21 +/* 00000690 000006C4 38 80 01 86 */ li r4, 0x186 +/* 00000694 000006C8 3C A0 00 00 */ lis r5, "@69"@ha +/* 00000698 000006CC 38 A5 00 00 */ addi r5, r5, "@69"@l +/* 0000069C 000006D0 4C C6 31 82 */ crclr 4*cr1+eq +/* 000006A0 000006D4 48 00 00 01 */ bl OSPanic +.L_000006A4: +/* 000006A4 000006D8 38 60 00 00 */ li r3, 0x0 +/* 000006A8 000006DC 80 00 00 00 */ lwz r0, __LastNode@sda21(r0) +/* 000006AC 000006E0 7C 03 00 40 */ cmplw r3, r0 +/* 000006B0 000006E4 40 82 00 48 */ bne .L_000006F8 +/* 000006B4 000006E8 93 E0 00 00 */ stw r31, __CurrNode@sda21(r0) +/* 000006B8 000006EC 93 E0 00 00 */ stw r31, __LastNode@sda21(r0) +/* 000006BC 000006F0 93 E0 00 00 */ stw r31, __FirstNode@sda21(r0) +/* 000006C0 000006F4 38 00 00 00 */ li r0, 0x0 +/* 000006C4 000006F8 90 1F 00 44 */ stw r0, 0x44(r31) +/* 000006C8 000006FC 38 00 00 00 */ li r0, 0x0 +/* 000006CC 00000700 90 1F 00 48 */ stw r0, 0x48(r31) +/* 000006D0 00000704 80 00 00 00 */ lwz r0, __FirstNode@sda21(r0) +/* 000006D4 00000708 28 00 00 00 */ cmplwi r0, 0x0 +/* 000006D8 0000070C 40 82 00 3C */ bne .L_00000714 +/* 000006DC 00000710 38 60 00 00 */ li r3, "@19"@sda21 +/* 000006E0 00000714 38 80 01 94 */ li r4, 0x194 +/* 000006E4 00000718 3C A0 00 00 */ lis r5, "@70"@ha +/* 000006E8 0000071C 38 A5 00 00 */ addi r5, r5, "@70"@l +/* 000006EC 00000720 4C C6 31 82 */ crclr 4*cr1+eq +/* 000006F0 00000724 48 00 00 01 */ bl OSPanic +/* 000006F4 00000728 48 00 00 20 */ b .L_00000714 +.L_000006F8: +/* 000006F8 0000072C 80 60 00 00 */ lwz r3, __LastNode@sda21(r0) +/* 000006FC 00000730 93 E3 00 44 */ stw r31, 0x44(r3) +/* 00000700 00000734 38 00 00 00 */ li r0, 0x0 +/* 00000704 00000738 90 1F 00 44 */ stw r0, 0x44(r31) +/* 00000708 0000073C 80 00 00 00 */ lwz r0, __LastNode@sda21(r0) +/* 0000070C 00000740 90 1F 00 48 */ stw r0, 0x48(r31) +/* 00000710 00000744 93 E0 00 00 */ stw r31, __LastNode@sda21(r0) +.L_00000714: +/* 00000714 00000748 80 01 00 1C */ lwz r0, 0x1c(r1) +/* 00000718 0000074C 83 E1 00 14 */ lwz r31, 0x14(r1) +/* 0000071C 00000750 38 21 00 18 */ addi r1, r1, 0x18 +/* 00000720 00000754 7C 08 03 A6 */ mtlr r0 +/* 00000724 00000758 4E 80 00 20 */ blr +.endfn __win_add_node + +.fn __win_delete_node, local +/* 00000728 0000075C 7C 08 02 A6 */ mflr r0 +/* 0000072C 00000760 90 01 00 04 */ stw r0, 0x4(r1) +/* 00000730 00000764 94 21 FF E8 */ stwu r1, -0x18(r1) +/* 00000734 00000768 93 E1 00 14 */ stw r31, 0x14(r1) +/* 00000738 0000076C 7C 7F 1B 78 */ mr r31, r3 +/* 0000073C 00000770 28 1F 00 00 */ cmplwi r31, 0x0 +/* 00000740 00000774 40 82 00 1C */ bne .L_0000075C +/* 00000744 00000778 38 60 00 00 */ li r3, "@19"@sda21 +/* 00000748 0000077C 38 80 01 B2 */ li r4, 0x1b2 +/* 0000074C 00000780 3C A0 00 00 */ lis r5, "@84"@ha +/* 00000750 00000784 38 A5 00 00 */ addi r5, r5, "@84"@l +/* 00000754 00000788 4C C6 31 82 */ crclr 4*cr1+eq +/* 00000758 0000078C 48 00 00 01 */ bl OSPanic +.L_0000075C: +/* 0000075C 00000790 80 00 00 00 */ lwz r0, __FirstNode@sda21(r0) +/* 00000760 00000794 7C 00 F8 40 */ cmplw r0, r31 +/* 00000764 00000798 40 82 00 50 */ bne .L_000007B4 +/* 00000768 0000079C 80 1F 00 44 */ lwz r0, 0x44(r31) +/* 0000076C 000007A0 28 00 00 00 */ cmplwi r0, 0x0 +/* 00000770 000007A4 41 82 00 28 */ beq .L_00000798 +/* 00000774 000007A8 80 1F 00 44 */ lwz r0, 0x44(r31) +/* 00000778 000007AC 90 00 00 00 */ stw r0, __FirstNode@sda21(r0) +/* 0000077C 000007B0 38 00 00 00 */ li r0, 0x0 +/* 00000780 000007B4 80 7F 00 44 */ lwz r3, 0x44(r31) +/* 00000784 000007B8 90 03 00 48 */ stw r0, 0x48(r3) +/* 00000788 000007BC 80 60 00 00 */ lwz r3, __OSCurrHeap@sda21(r0) +/* 0000078C 000007C0 7F E4 FB 78 */ mr r4, r31 +/* 00000790 000007C4 48 00 00 01 */ bl OSFreeToHeap +/* 00000794 000007C8 48 00 00 9C */ b .L_00000830 +.L_00000798: +/* 00000798 000007CC 38 00 00 00 */ li r0, 0x0 +/* 0000079C 000007D0 90 00 00 00 */ stw r0, __LastNode@sda21(r0) +/* 000007A0 000007D4 90 00 00 00 */ stw r0, __FirstNode@sda21(r0) +/* 000007A4 000007D8 80 60 00 00 */ lwz r3, __OSCurrHeap@sda21(r0) +/* 000007A8 000007DC 7F E4 FB 78 */ mr r4, r31 +/* 000007AC 000007E0 48 00 00 01 */ bl OSFreeToHeap +/* 000007B0 000007E4 48 00 00 80 */ b .L_00000830 +.L_000007B4: +/* 000007B4 000007E8 80 00 00 00 */ lwz r0, __LastNode@sda21(r0) +/* 000007B8 000007EC 7C 00 F8 40 */ cmplw r0, r31 +/* 000007BC 000007F0 40 82 00 50 */ bne .L_0000080C +/* 000007C0 000007F4 80 1F 00 48 */ lwz r0, 0x48(r31) +/* 000007C4 000007F8 28 00 00 00 */ cmplwi r0, 0x0 +/* 000007C8 000007FC 41 82 00 28 */ beq .L_000007F0 +/* 000007CC 00000800 80 1F 00 48 */ lwz r0, 0x48(r31) +/* 000007D0 00000804 90 00 00 00 */ stw r0, __LastNode@sda21(r0) +/* 000007D4 00000808 38 00 00 00 */ li r0, 0x0 +/* 000007D8 0000080C 80 7F 00 48 */ lwz r3, 0x48(r31) +/* 000007DC 00000810 90 03 00 44 */ stw r0, 0x44(r3) +/* 000007E0 00000814 80 60 00 00 */ lwz r3, __OSCurrHeap@sda21(r0) +/* 000007E4 00000818 7F E4 FB 78 */ mr r4, r31 +/* 000007E8 0000081C 48 00 00 01 */ bl OSFreeToHeap +/* 000007EC 00000820 48 00 00 44 */ b .L_00000830 +.L_000007F0: +/* 000007F0 00000824 38 00 00 00 */ li r0, 0x0 +/* 000007F4 00000828 90 00 00 00 */ stw r0, __LastNode@sda21(r0) +/* 000007F8 0000082C 90 00 00 00 */ stw r0, __FirstNode@sda21(r0) +/* 000007FC 00000830 80 60 00 00 */ lwz r3, __OSCurrHeap@sda21(r0) +/* 00000800 00000834 7F E4 FB 78 */ mr r4, r31 +/* 00000804 00000838 48 00 00 01 */ bl OSFreeToHeap +/* 00000808 0000083C 48 00 00 28 */ b .L_00000830 +.L_0000080C: +/* 0000080C 00000840 80 1F 00 44 */ lwz r0, 0x44(r31) +/* 00000810 00000844 80 7F 00 48 */ lwz r3, 0x48(r31) +/* 00000814 00000848 90 03 00 44 */ stw r0, 0x44(r3) +/* 00000818 0000084C 80 1F 00 48 */ lwz r0, 0x48(r31) +/* 0000081C 00000850 80 7F 00 44 */ lwz r3, 0x44(r31) +/* 00000820 00000854 90 03 00 48 */ stw r0, 0x48(r3) +/* 00000824 00000858 80 60 00 00 */ lwz r3, __OSCurrHeap@sda21(r0) +/* 00000828 0000085C 7F E4 FB 78 */ mr r4, r31 +/* 0000082C 00000860 48 00 00 01 */ bl OSFreeToHeap +.L_00000830: +/* 00000830 00000864 80 01 00 1C */ lwz r0, 0x1c(r1) +/* 00000834 00000868 83 E1 00 14 */ lwz r31, 0x14(r1) +/* 00000838 0000086C 38 21 00 18 */ addi r1, r1, 0x18 +/* 0000083C 00000870 7C 08 03 A6 */ mtlr r0 +/* 00000840 00000874 4E 80 00 20 */ blr + +.fn __win_log_refresh, local +.endfn __win_delete_node +/* 00000844 00000878 7C 08 02 A6 */ mflr r0 +/* 00000848 0000087C 90 01 00 04 */ stw r0, 0x4(r1) +/* 0000084C 00000880 94 21 FF D8 */ stwu r1, -0x28(r1) +/* 00000850 00000884 BF 61 00 14 */ stmw r27, 0x14(r1) +/* 00000854 00000888 7C 7F 1B 78 */ mr r31, r3 +/* 00000858 0000088C 28 1F 00 00 */ cmplwi r31, 0x0 +/* 0000085C 00000890 40 82 00 1C */ bne .L_00000878 +/* 00000860 00000894 38 60 00 00 */ li r3, "@19"@sda21 +/* 00000864 00000898 38 80 01 FA */ li r4, 0x1fa +/* 00000868 0000089C 3C A0 00 00 */ lis r5, "@91"@ha +/* 0000086C 000008A0 38 A5 00 00 */ addi r5, r5, "@91"@l +/* 00000870 000008A4 4C C6 31 82 */ crclr 4*cr1+eq +/* 00000874 000008A8 48 00 00 01 */ bl OSPanic +.L_00000878: +/* 00000878 000008AC A3 DF 00 3A */ lhz r30, 0x3a(r31) +/* 0000087C 000008B0 80 1F 00 00 */ lwz r0, 0x0(r31) +/* 00000880 000008B4 54 1C 04 3E */ clrlwi r28, r0, 16 +/* 00000884 000008B8 3B A0 00 00 */ li r29, 0x0 +/* 00000888 000008BC 48 00 00 70 */ b .L_000008F8 +.L_0000088C: +/* 0000088C 000008C0 57 C4 04 3E */ clrlwi r4, r30, 16 +/* 00000890 000008C4 A0 7F 00 38 */ lhz r3, 0x38(r31) +/* 00000894 000008C8 38 03 FF FF */ addi r0, r3, -0x1 +/* 00000898 000008CC 7C 84 02 14 */ add r4, r4, r0 +/* 0000089C 000008D0 A0 7F 00 38 */ lhz r3, 0x38(r31) +/* 000008A0 000008D4 7C 04 1B D6 */ divw r0, r4, r3 +/* 000008A4 000008D8 7C 00 19 D6 */ mullw r0, r0, r3 +/* 000008A8 000008DC 7C 00 20 50 */ subf r0, r0, r4 +/* 000008AC 000008E0 54 1E 04 3E */ clrlwi r30, r0, 16 +/* 000008B0 000008E4 57 A3 18 38 */ slwi r3, r29, 3 +/* 000008B4 000008E8 80 1F 00 0C */ lwz r0, 0xc(r31) +/* 000008B8 000008EC 54 00 04 3E */ clrlwi r0, r0, 16 +/* 000008BC 000008F0 7F 63 00 50 */ subf r27, r3, r0 +/* 000008C0 000008F4 80 1F 00 28 */ lwz r0, 0x28(r31) +/* 000008C4 000008F8 54 00 04 3E */ clrlwi r0, r0, 16 +/* 000008C8 000008FC 7C 1E 01 D6 */ mullw r0, r30, r0 +/* 000008CC 00000900 B0 01 00 0C */ sth r0, 0xc(r1) +/* 000008D0 00000904 38 7C 00 00 */ addi r3, r28, 0x0 +/* 000008D4 00000908 38 9B 00 00 */ addi r4, r27, 0x0 +/* 000008D8 0000090C 38 A0 00 00 */ li r5, 0x0 +/* 000008DC 00000910 38 C0 00 00 */ li r6, "@34"@sda21 +/* 000008E0 00000914 80 FF 00 34 */ lwz r7, 0x34(r31) +/* 000008E4 00000918 57 C0 13 BA */ clrlslwi r0, r30, 16, 2 +/* 000008E8 0000091C 7C E7 00 2E */ lwzx r7, r7, r0 +/* 000008EC 00000920 4C C6 31 82 */ crclr 4*cr1+eq +/* 000008F0 00000924 48 00 00 01 */ bl DEMOPrintf +/* 000008F4 00000928 3B BD 00 01 */ addi r29, r29, 0x1 +.L_000008F8: +/* 000008F8 0000092C 57 A3 04 3E */ clrlwi r3, r29, 16 +/* 000008FC 00000930 80 1F 00 2C */ lwz r0, 0x2c(r31) +/* 00000900 00000934 7C 03 00 00 */ cmpw r3, r0 +/* 00000904 00000938 41 80 FF 88 */ blt .L_0000088C +/* 00000908 0000093C 80 01 00 2C */ lwz r0, 0x2c(r1) +/* 0000090C 00000940 BB 61 00 14 */ lmw r27, 0x14(r1) +/* 00000910 00000944 38 21 00 28 */ addi r1, r1, 0x28 +/* 00000914 00000948 7C 08 03 A6 */ mtlr r0 +/* 00000918 0000094C 4E 80 00 20 */ blr +.endfn __win_log_refresh + +# 0x00000000 - 0x00000176 +.data +.balign 8 +.sym ...data.0, local + +.obj "@20", local + .4byte 0x54585749 + .4byte 0x4E3A2049 + .4byte 0x6C6C6567 + .4byte 0x616C2058 + .4byte 0x20636F6F + .4byte 0x72647320 + .4byte 0x666F7220 + .4byte 0x77696E64 + .4byte 0x6F770A00 +.endobj "@20" + +.obj "@21", local + .4byte 0x54585749 + .4byte 0x4E3A2049 + .4byte 0x6C6C6567 + .4byte 0x616C2079 + .4byte 0x20636F6F + .4byte 0x72647320 + .4byte 0x666F7220 + .4byte 0x77696E64 + .4byte 0x6F770A00 +.endobj "@21" + +.obj "@22", local + .4byte 0x54585749 + .4byte 0x4E3A2046 + .4byte 0x41494C45 + .4byte 0x4420544F + .4byte 0x20414C4C + .4byte 0x4F434154 + .4byte 0x45205749 + .4byte 0x4E444F57 + .byte 0x21, 0x0A, 0x00 +.endobj "@22" + .byte 0x00 + +.obj "@29", local + .4byte 0x54585749 + .4byte 0x4E3A2055 + .4byte 0x6E61626C + .4byte 0x6520746F + .4byte 0x20616C6C + .4byte 0x6F636174 + .4byte 0x65206C6F + .4byte 0x67207769 + .4byte 0x6E646F77 + .4byte 0x20627566 + .4byte 0x6665722E + .2byte 0x0A00 +.endobj "@29" + .2byte 0x0000 + +.obj "@30", local + .4byte 0x54585749 + .4byte 0x4E3A2046 + .4byte 0x61696C65 + .4byte 0x6420746F + .4byte 0x20616C6C + .4byte 0x6F636174 + .4byte 0x65206275 + .4byte 0x66666572 + .4byte 0x20656C65 + .4byte 0x6D656E74 + .2byte 0x0A00 +.endobj "@30" + .2byte 0x0000 + +.obj "@64", local + .4byte 0x3E3E2077 + .4byte 0x696E5265 + .4byte 0x66726573 + .4byte 0x6828293A + .4byte 0x2077696E + .4byte 0x646F7720 + .4byte 0x6C697374 + .4byte 0x20697320 + .4byte 0x656D7074 + .4byte 0x79210A00 +.endobj "@64" + +.obj "@69", local + .4byte 0x5F5F6164 + .4byte 0x645F6E6F + .4byte 0x64652829 + .4byte 0x3A20796F + .4byte 0x75277265 + .4byte 0x20616464 + .4byte 0x696E6720 + .4byte 0x61204E55 + .4byte 0x4C4C206E + .4byte 0x6F646521 + .2byte 0x0A00 +.endobj "@69" + .2byte 0x0000 + +.obj "@70", local + .4byte 0x20203E20 + .4byte 0x5F5F4669 + .4byte 0x7273744E + .4byte 0x6F64653A + .4byte 0x204E554C + .4byte 0x4C204841 + .4byte 0x4E444C45 + .byte 0x21, 0x0A, 0x00 +.endobj "@70" + .byte 0x00 + +.obj "@84", local + .4byte 0x5F5F6465 + .4byte 0x6C657465 + .4byte 0x5F6E6F64 + .4byte 0x6528293A + .4byte 0x20796F75 + .4byte 0x27726520 + .4byte 0x64656C65 + .4byte 0x74696E67 + .4byte 0x2061204E + .4byte 0x554C4C20 + .4byte 0x6E6F6465 + .byte 0x21, 0x0A, 0x00 +.endobj "@84" + .byte 0x00 + +.obj "@91", local + .4byte 0x4F484D59 + .4byte 0x47415744 + .2byte 0x0A00 +.endobj "@91" + +# 0x00000000 - 0x0000000B +.section .sdata, "wa" +.balign 8 + +.obj "@19", local + .4byte 0x74787769 + .4byte 0x6E2E6300 +.endobj "@19" + +.obj "@34", local + .byte 0x25, 0x73, 0x00 +.endobj "@34" + +# 0x00000000 - 0x00000014 +.section .sbss, "wa", @nobits +.balign 8 + +.obj __X_Res, local + .skip 0x2 +.endobj __X_Res + +.obj __Y_Res, local + .skip 0x2 +.endobj __Y_Res + +.obj __rmp, global + .skip 0x4 + +.obj __CurrNode, global +.endobj __rmp + .skip 0x4 + +.obj __LastNode, global +.endobj __CurrNode + .skip 0x4 + +.obj __FirstNode, global +.endobj __LastNode + .skip 0x4 +.endobj __FirstNode + +# 0x00000000 - 0x00000028 +.section .sdata2, "a" +.balign 8 + +.obj "@13", local + .4byte 0x0A1019FF +.endobj "@13" + .4byte 0x00000000 + +.obj "@49", local + .4byte 0x40840000 + .4byte 0x00000000 +.endobj "@49" + +.obj "@50", local + .4byte 0x40200000 + .4byte 0x00000000 +.endobj "@50" + +.obj "@51", local + .4byte 0x3FE80000 + .4byte 0x00000000 +.endobj "@51" + +.obj "@53", local + .4byte 0x43300000 + .4byte 0x00000000 +.endobj "@53" diff --git a/configure.py b/configure.py index 36c8003c..6933f49f 100755 --- a/configure.py +++ b/configure.py @@ -959,6 +959,15 @@ LIBS = [ ["musyx/runtime/profile", True], ], }, + { + "lib": "txwin", + "mw_version": "1.2.5", + "cflags": "-Cpp_exceptions off -proc gecko -fp hard -nodefaults -nosyspath -i include -i libc -g -sym on -D_DEBUG=1 -enum int ", + "host": False, + "objects": [ + ["musyx/txwin/txwin", False], + ], + }, { "lib": "dtk", "mw_version": "1.2.5", diff --git a/include/dolphin/os.h b/include/dolphin/os.h index 2e6d6d2e..e87a4daf 100644 --- a/include/dolphin/os.h +++ b/include/dolphin/os.h @@ -214,6 +214,7 @@ void OSFatal(GXColor fg, GXColor bg, const char* msg); #endif #include +#include #include #include #include diff --git a/include/dolphin/os/OSAlloc.h b/include/dolphin/os/OSAlloc.h new file mode 100644 index 00000000..afa1d9be --- /dev/null +++ b/include/dolphin/os/OSAlloc.h @@ -0,0 +1,30 @@ +#ifndef _DOLPHIN_OSALLOC +#define _DOLPHIN_OSALLOC + +#include + +#ifdef __cplusplus +extern "C" { +#endif +typedef int OSHeapHandle; +typedef void (*OSAllocVisitor)(void* obj, u32 size); +void* OSInitAlloc(void* arenaStart, void* arenaEnd, int maxHeaps); +OSHeapHandle OSCreateHeap(void* start, void* end); +void OSDestroyHeap(OSHeapHandle heap); +void OSAddToHeap(OSHeapHandle heap, void* start, void* end); +OSHeapHandle OSSetCurrentHeap(OSHeapHandle heap); +void* OSAllocFromHeap(OSHeapHandle heap, u32 size); +void* OSAllocFixed(void** rstart, void** rend); +void OSFreeToHeap(OSHeapHandle heap, void* ptr); +long OSCheckHeap(OSHeapHandle heap); +void OSDumpHeap(OSHeapHandle heap); +u32 OSReferentSize(void* ptr); +void OSVisitAllocated(OSAllocVisitor visitor); +extern volatile OSHeapHandle __OSCurrHeap; +#define OSAlloc(size) OSAllocFromHeap(__OSCurrHeap, (size)) +#define OSFree(ptr) OSFreeToHeap(__OSCurrHeap, (ptr)) +#ifdef __cplusplus +} +#endif + +#endif // _DOLPHIN_OSALLOC diff --git a/include/musyx/musyx_priv.h b/include/musyx/musyx_priv.h index 624b696b..d60dcdd8 100644 --- a/include/musyx/musyx_priv.h +++ b/include/musyx/musyx_priv.h @@ -856,6 +856,7 @@ u32 dataInsertMacro(u16 mid, void* macroaddr); u32 dataRemoveMacro(u16 mid); u32 dataInsertCurve(u16 cid, void* curvedata); u32 dataRemoveCurve(u16 sid); +long dataGetSample(u16 sid, SAMPLE_INFO* newsmp); u32 dataAddSampleReference(u16 sid); u32 dataRemoveSampleReference(u16 sid); u32 dataInsertKeymap(u16 cid, void* keymapdata); @@ -865,6 +866,8 @@ u32 dataRemoveLayer(u16 sid); u32 dataInsertFX(u16 gid, FX_TAB* fx, u16 fxNum); FX_TAB* dataGetFX(u16 fid); s32 hwInit(u32* frq, u16 numVoices, u16 numStudios, u32 flags); /* extern */ +void hwInitSamplePlayback(u32 v, u16 smpID, void* newsmp, u32 set_defadsr, u32 prio, + u32 callbackUserValue, u32 setSRC, u8 itdMode); void hwEnableIrq(); void hwDisableIrq(); void* hwTransAddr(void* samples); @@ -957,6 +960,11 @@ typedef struct SND_STREAM_INFO { } SND_STREAM_INFO; void streamOutputModeChanged(); +void inpSetExCtrl(struct SYNTH_VOICE* svoice, unsigned char ctrl, signed short v); +CHANNEL_DEFAULTS* inpGetChannelDefaults(unsigned char midi, unsigned char midiSet); +void inpSetMidiLastNote(u8 midi, u8 midiSet, u8 key); +u8 inpGetMidiLastNote(u8 midi, u8 midiSet); +unsigned short inpGetExCtrl(SYNTH_VOICE* svoice, unsigned char ctrl); unsigned short inpGetMidiCtrl(unsigned char ctrl, unsigned char channel, unsigned char set); void inpSetMidiLastNote(unsigned char midi, unsigned char midiSet, unsigned char key); u16 inpGetModulation(SYNTH_VOICE* svoice); diff --git a/include/musyx/txwin.h b/include/musyx/txwin.h new file mode 100644 index 00000000..746d9fc3 --- /dev/null +++ b/include/musyx/txwin.h @@ -0,0 +1,49 @@ +#ifndef _MUSYX_TXWIN +#define _MUSYX_TXWIN + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct STRUCT_WIN { + s32 x1; + s32 y1; + s32 x2; + s32 y2; + char* caption; + u32 flags; + s32 curr_x; + s32 curr_y; + s32 pixel_width; + s32 pixel_height; + s32 char_width; + s32 char_height; + u16 num_lines; + char** buffer; + u16 total_lines; + u16 curr_output_line; + u16 curr_view_line; + void (*refresh)(); + struct STRUCT_WIN* next; + struct STRUCT_WIN* prev; + +} sWIN; + +void winInit(void); +void winRefresh(void); +void winLogPrintf(sWIN* handle, char* fmt, ...); +void winPrintfXY(sWIN* handle, s16 char_x, s16 char_y, char* fmt, ...); +void winClearLogWindow(sWIN* handle); +void winSetFontSize(u16 size); + +sWIN* winOpenLogWindow(s32 x1, s32 y1, s32 x2, s32 y2, char* caption, u16 num_lines, u32 flags); +sWIN* winOpenWindow(s32 x1, s32 y1, s32 x2, s32 y2, char* caption, void* func, u32 flags); + +WXOpenWindow(); + +#ifdef __cpluplus +} +#endif // __cpluplus +#endif // _MUSYX_TXWIN diff --git a/src/musyx/runtime/hardware.c b/src/musyx/runtime/hardware.c index eb6ec987..5e8e7f7b 100644 --- a/src/musyx/runtime/hardware.c +++ b/src/musyx/runtime/hardware.c @@ -140,7 +140,7 @@ void hwSetMesgCallback(SND_MESSAGE_CALLBACK callback) { salMessageCallback = cal void hwSetPriority(u32 idx, u32 priority) { dspVoice[idx].prio = priority; } -void hwInitSamplePlayback(s32 v, u16 smpID, void* newsmp, u32 set_defadsr, u32 priority, +void hwInitSamplePlayback(u32 v, u16 smpID, void* newsmp, u32 set_defadsr, u32 prio, u32 callbackUserValue, u32 setSRC, u8 itdMode) { unsigned char i; // r30 unsigned long bf; // r29 @@ -151,7 +151,7 @@ void hwInitSamplePlayback(s32 v, u16 smpID, void* newsmp, u32 set_defadsr, u32 p } dspVoice[v].changed[0] = bf; - dspVoice[v].prio = priority; + dspVoice[v].prio = prio; dspVoice[v].mesgCallBackUserValue = callbackUserValue; dspVoice[v].flags = 0; dspVoice[v].smp_id = smpID; diff --git a/src/musyx/runtime/synthmacros.c b/src/musyx/runtime/synthmacros.c index 38eb51ef..06d6ff9e 100644 --- a/src/musyx/runtime/synthmacros.c +++ b/src/musyx/runtime/synthmacros.c @@ -8,16 +8,26 @@ static u8 DebugMacroSteps = 0; static SYNTH_VOICE* macActiveMacroRoot = NULL; static SYNTH_VOICE* macTimeQueueRoot = NULL; static u64 macRealTime; + static void TimeQueueAdd(SYNTH_VOICE* svoice); -void macMakeActive(struct SYNTH_VOICE* svoice); + +void macMakeActive(SYNTH_VOICE* svoice); + +void macSetExternalKeyoff(SYNTH_VOICE* svoice); + +static void DoSetPitch(SYNTH_VOICE* svoice); static int SendSingleKeyOff(u32 voiceid) { u32 i; // r31 if (voiceid != 0xFFFFFFFF) { + i = voiceid & 0xFF; + if (voiceid == synthVoice[i].id) { - macSetExternalKeyOff(&synthVoice[i]); + + macSetExternalKeyoff(&synthVoice[i]); + return 0; } } @@ -37,7 +47,7 @@ static u32 ExecuteTrap(SYNTH_VOICE* svoice, u8 trapType) { return 0; } -static bool HasHWEventTrap(SYNTH_VOICE* svoice) { +static u32 HasHWEventTrap(SYNTH_VOICE* svoice) { if (svoice->trapEventAny != '\0') { return svoice->trapEventAddr[1] != NULL; } @@ -45,7 +55,7 @@ static bool HasHWEventTrap(SYNTH_VOICE* svoice) { } static void CheckHWEventTrap(SYNTH_VOICE* svoice) { - if ((svoice->cFlags & 0x20) == 0 && hwIsActive(svoice->parent & 0xff)) { + if ((svoice->cFlags & 0x20) == 0 && !hwIsActive(svoice->id & 0xff)) { ExecuteTrap(svoice, 1); } } @@ -257,8 +267,8 @@ static void mcmdUntrapEvent(SYNTH_VOICE* svoice, MSTEP* cstep) { static void mcmdLoop(SYNTH_VOICE* svoice, MSTEP* cstep) {} static void mcmdPlayMacro(SYNTH_VOICE* svoice, MSTEP* cstep) { - long key; // r29 - unsigned long new_child; // r30 + s32 key; // r29 + u32 new_child; // r30 key = ((u32)svoice->orgNote + (s8)(u8)(cstep->para[0] >> 8)); if (key < 0) { @@ -295,8 +305,8 @@ static void mcmdPlayMacro(SYNTH_VOICE* svoice, MSTEP* cstep) { } static void mcmdSendKeyOff(SYNTH_VOICE* svoice, MSTEP* cstep) { - unsigned long voiceid; // r30 - unsigned long i; // r31 + u32 voiceid; // r30 + u32 i; // r31 voiceid = (svoice->orgNote + (u8)(cstep->para[0] >> 8)) << 8; voiceid |= ((u16)(cstep->para[0] >> 16)) << 16; @@ -308,8 +318,8 @@ static void mcmdSendKeyOff(SYNTH_VOICE* svoice, MSTEP* cstep) { } static void mcmdAddAgeCounter(SYNTH_VOICE* svoice, MSTEP* cstep) { - signed short step; // r29 - long age; // r30 + s16 step; // r29 + s32 age; // r30 step = (u16)(cstep->para[0] >> 16); age = (svoice->age >> 15) + step; @@ -347,8 +357,8 @@ static void mcmdSetAgeCounterByVolume(SYNTH_VOICE* svoice, MSTEP* cstep) { } static void mcmdAddPriority(SYNTH_VOICE* svoice, MSTEP* cstep) { - signed short add; // r30 - signed short prio; // r31 + s16 add; // r30 + s16 prio; // r31 add = (u16)(cstep->para[0] >> 16); prio = svoice->prio + add; prio = (prio < 0) ? 0 : (prio > 0xFF) ? 0xFF : prio; @@ -381,9 +391,9 @@ static u32 mcmdSetKey(SYNTH_VOICE* svoice, MSTEP* cstep) { static u32 mcmdAddKey(SYNTH_VOICE* svoice, MSTEP* cstep) { if (cstep->para[0] >> 0x18 == 0) { - svoice->curNote = svoice->curNote + (s8)(u16)(cstep->para[0] & 0xFFFF); + svoice->curNote = svoice->curNote + (s16)(s8)(u8)(cstep->para[0] >> 8); } else { - svoice->curNote = (u16)svoice->orgNote + (s16)(s8)(cstep->para[0] >> 8); + svoice->curNote = (u16)svoice->orgNote + (s16)(s8)(u8)(cstep->para[0] >> 8); } svoice->curNote = (s16)svoice->curNote < 0 ? 0 : svoice->curNote > 0x7f ? 0x7f : svoice->curNote; @@ -396,54 +406,177 @@ static u32 mcmdAddKey(SYNTH_VOICE* svoice, MSTEP* cstep) { return mcmdWait(svoice, cstep); } -static u32 mcmdLastKey(SYNTH_VOICE* svoice, MSTEP* cstep) {} +static u32 mcmdLastKey(SYNTH_VOICE* svoice, MSTEP* cstep) { + svoice->curNote = svoice->lastNote + (s8)(u8)(cstep->para[0] >> 8); + svoice->curNote = (s16)svoice->curNote < 0 ? 0 : svoice->curNote > 0x7f ? 0x7f : svoice->curNote; + svoice->curDetune = (s8)(cstep->para[0] >> 16); + if (svoice->midi != 0xFF) { + inpSetMidiLastNote(svoice->midi, svoice->midiSet, svoice->curNote); + } + cstep->para[0] = 4; + + return mcmdWait(svoice, cstep); +} static void mcmdStartSample(SYNTH_VOICE* svoice, MSTEP* cstep) { static SAMPLE_INFO newsmp; - unsigned short smp; // r28 + u16 smp; // r28 + smp = cstep->para[0] >> 8; + + if (dataGetSample(smp, &newsmp) != 0) { + return; + } + switch (cstep->para[0] >> 0x18) { + case 0: + newsmp.offset = cstep->para[1]; + break; + case 1: + newsmp.offset = ((u8)(0x7f - (svoice->volume >> 0x10)) * (u32)cstep->para[1]) / 0x7f; + ; + break; + case 2: + newsmp.offset = ((u8)((svoice->volume >> 0x10)) * (u32)cstep->para[1]) / 0x7f; + break; + default: + newsmp.offset = 0; + break; + } + + if (newsmp.offset >= newsmp.length) { + newsmp.offset = newsmp.length - 1; + } + + hwInitSamplePlayback(svoice->id & 0xFF, smp, &newsmp, (svoice->cFlags & 0x100) == 0, + ((u32)svoice->prio << 24) | ((u32)svoice->age >> 15), svoice->id, + (svoice->cFlags & 0x80000000000) == 0, svoice->itdMode); + + svoice->sInfo = newsmp.info; + + if (svoice->playFrq != -1) { + DoSetPitch(svoice); + } + svoice->cFlags |= 0x20; + synthKeyStateUpdate(svoice); } -static void mcmdStopSample(SYNTH_VOICE* svoice) {} -static void mcmdKeyOff(SYNTH_VOICE* svoice) {} -static void mcmdSetMod2Vibrato(SYNTH_VOICE* svoice, MSTEP* cstep) {} +static void mcmdStopSample(SYNTH_VOICE* svoice) { hwBreak(svoice->id & 0xFF); } +static void mcmdKeyOff(SYNTH_VOICE* svoice) { + svoice->cFlags |= 0x80; + synthKeyStateUpdate(svoice); +} + +static void mcmdSetMod2Vibrato(SYNTH_VOICE* svoice, MSTEP* cstep) { + svoice->vibModAddScale = (s8)(cstep->para[0] >> 8) << 8; + if (svoice->vibModAddScale >= 0) { + svoice->vibModAddScale += ((s16)(s8)(cstep->para[0] >> 0x10) << 8) / 100; + + } else { + svoice->vibModAddScale -= ((s16)(s8)(cstep->para[0] >> 0x10) << 8) / 100; + } +} static void mcmdVibrato(SYNTH_VOICE* svoice, MSTEP* cstep) { - unsigned long time; // r1+0x10 - signed char kr; // r29 - signed char cr; // r30 + u32 time; // r1+0x10 + s8 kr; // r29 + s8 cr; // r30 + + if ((u8)(cstep->para[0] >> 0x18) & 3) { + svoice->cFlags |= 0x4000; + } else { + svoice->cFlags &= ~0x4000; + } + + time = (u16)(cstep->para[1] >> 0x10); + if ((u16)(cstep->para[1] >> 8) & 1) { + sndConvertMs(&time); + } else { + sndConvertTicks(&time, svoice); + } + + if (time) { + svoice->cFlags |= 0x2000; + svoice->vibPeriod = time; + + kr = (s8)(cstep->para[0] >> 8); + cr = (s8)(cstep->para[0] >> 16); + + if (kr < 0) { + if (cr < 0) { + svoice->vibCentRange = -cr; + } else { + svoice->vibCentRange = cr; + } + + svoice->vibKeyRange = -kr; + svoice->vibCurTime = svoice->vibPeriod / 2; + } else { + if (cr < 0) { + if (kr == 0) { + svoice->vibCentRange = -cr; + svoice->vibCurTime = svoice->vibPeriod / 2; + } else { + --kr; + svoice->vibCentRange = 100 - cr; + svoice->vibCurTime = 0; + } + } else { + svoice->vibCentRange = cr; + svoice->vibCurTime = 0; + } + svoice->vibKeyRange = kr; + } + } else { + svoice->cFlags &= ~0x2000; + } } static void mcmdSetupLFO(SYNTH_VOICE* svoice, MSTEP* cstep) { - unsigned long time; // r1+0x14 - unsigned long phase; // r1+0x10 - unsigned char n; // r31 + u32 time; // r1+0x14 + u32 phase; // r1+0x10 + u8 n; // r31 + + n = (u8)(cstep->para[0] >> 8); + time = cstep->para[0] >> 0x10; + sndConvertMs(&time); + if (svoice->lfo[n].period != 0) { + phase = (u16)cstep->para[1]; + sndConvertMs(&phase); + svoice->lfo[n].time = phase; + } + svoice->lfo[n].period = time; } static void DoSetPitch(SYNTH_VOICE* svoice) { - unsigned long f; // r28 - unsigned long of; // r25 - unsigned long i; // r31 - unsigned long frq; // r27 - unsigned long ofrq; // r26 - unsigned long no; // r30 - long key; // r24 - unsigned char oKey; // r23 + u32 f; // r28 + u32 of; // r25 + u32 i; // r31 + u32 frq; // r27 + u32 ofrq; // r26 + u32 no; // r30 + s32 key; // r24 + u8 oKey; // r23 static u16 kf[13] = { 4096, 4339, 4597, 4871, 5160, 5467, 5792, 6137, 6502, 6888, 7298, 7732, 8192, }; } -static void mcmdSetPitch(SYNTH_VOICE* svoice, MSTEP* cstep) {} +static void mcmdSetPitch(SYNTH_VOICE* svoice, MSTEP* cstep) { + svoice->playFrq = (u32)(cstep->para[0] >> 8); + svoice->playFrq |= (u8)cstep->para[1]; + if (svoice->sInfo != -1) { + DoSetPitch(svoice); + } +} static void mcmdSetADSR(SYNTH_VOICE* svoice, MSTEP* cstep) { ADSR_INFO adsr; // r1+0x10 ADSR_INFO* adsr_ptr; // r31 - long ascale; // r29 - long dscale; // r28 + s32 ascale; // r29 + s32 dscale; // r28 float sScale; // r63 } -static long midi2TimeTab[128] = { +static s32 midi2TimeTab[128] = { 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 110, 120, 130, 140, 150, 160, 170, 190, 200, 220, 230, 250, 270, 290, 310, 330, 350, 380, 410, 440, 470, 500, 540, 580, @@ -464,58 +597,73 @@ static void mcmdSetADSRFromCtrl(SYNTH_VOICE* svoice, MSTEP* cstep) { static void mcmdSetPitchADSR(SYNTH_VOICE* svoice, MSTEP* cstep) { ADSR_INFO adsr; // r1+0x10 ADSR_INFO* adsr_ptr; // r31 - unsigned long sl; // r28 - long ascale; // r27 - long dscale; // r26 + u32 sl; // r28 + s32 ascale; // r27 + s32 dscale; // r26 } -unsigned long mcmdPitchSweep(SYNTH_VOICE* svoice, MSTEP* cstep, int num) { - long delta; // r31 +u32 mcmdPitchSweep(SYNTH_VOICE* svoice, MSTEP* cstep, int num) { + s32 delta; // r31 } -static void DoPanningSetup(SYNTH_VOICE* svoice, MSTEP* cstep, unsigned char pi) { - long width; // r29 - unsigned long mstime; // r27 + +static void DoPanningSetup(SYNTH_VOICE* svoice, MSTEP* cstep, u8 pi) { + s32 width; // r29 + u32 mstime; // r27 + svoice->panTime[pi] = width = (cstep->para[0] >> 16); + sndConvertMs(&svoice->panTime[pi]); + mstime = (s8)(cstep->para[1]); + svoice->panning[pi] = (cstep->para[0] & 0xFF00) << 8; + svoice->panTarget[pi] = svoice->panning[pi] + mstime * 0x10000; + if (svoice->panTime[pi] != 0) { + svoice->panDelta[pi] = (s32)(mstime << 16) / width; + } else { + svoice->panDelta[pi] = (s32)(mstime << 16); + } + + svoice->cFlags |= 0x200000000000; } -static void mcmdSetPanning(SYNTH_VOICE* svoice, MSTEP* cstep) {} + +static void mcmdSetPanning(SYNTH_VOICE* svoice, MSTEP* cstep) { DoPanningSetup(svoice, cstep, 0); } + static void mcmdSetSurroundPanning(SYNTH_VOICE* svoice, MSTEP* cstep) {} static void mcmdSetPianoPanning(SYNTH_VOICE* svoice, MSTEP* cstep) { - long delta; // r31 - long scale; // r30 + s32 delta; // r31 + s32 scale; // r30 } -unsigned long TranslateVolume(unsigned long volume, unsigned short curve) { - unsigned char* ptr; // r30 - unsigned long vlow; // r28 - unsigned long vhigh; // r31 - long d; // r27 +static u32 TranslateVolume(u32 volume, u16 curve) { + u8* ptr; // r30 + u32 vlow; // r28 + u32 vhigh; // r31 + s32 d; // r27 } static void mcmdScaleVolume(SYNTH_VOICE* svoice, MSTEP* cstep) { - unsigned short curve; // r29 - unsigned short scale; // r28 + u16 curve; // r29 + u16 scale; // r28 } static void mcmdScaleVolumeDLS(SYNTH_VOICE* svoice, MSTEP* cstep) { - unsigned short scale; // r31 + u16 scale; // r31 } -static void DoEnvelopeCalculation(SYNTH_VOICE* svoice, MSTEP* cstep, long start_vol) { - unsigned long tvol; // r31 - unsigned long time; // r1+0x14 - long mstime; // r28 - unsigned short curve; // r27 +static void DoEnvelopeCalculation(SYNTH_VOICE* svoice, MSTEP* cstep, s32 start_vol) { + u32 tvol; // r31 + u32 time; // r1+0x14 + s32 mstime; // r28 + u16 curve; // r27 } static void mcmdEnvelope(SYNTH_VOICE* svoice, MSTEP* cstep) {} static void mcmdFadeIn(SYNTH_VOICE* svoice, MSTEP* cstep) {} static void mcmdRandomKey(SYNTH_VOICE* svoice, MSTEP* cstep) { - unsigned char k1; // r30 - unsigned char k2; // r29 - unsigned char t; // r24 - long i1; // r28 - long i2; // r27 - unsigned char detune; // r26 + u8 k1; // r30 + u8 k2; // r29 + u8 t; // r24 + s32 i1; // r28 + s32 i2; // r27 + u8 detune; // r26 } static void mcmdSetPitchbendAfterKeyOff(SYNTH_VOICE* svoice) {} static void mcmdScaleReverb(SYNTH_VOICE* svoice, MSTEP* cstep) {} -static void SelectSource(SYNTH_VOICE* svoice, CTRL_DEST* dest, MSTEP* cstep, - unsigned long long tstflag, unsigned long dirtyFlag) { - unsigned char comb; // r28 - long scale; // r30 +static void SelectSource(SYNTH_VOICE* svoice, CTRL_DEST* dest, MSTEP* cstep, u64 tstflag, + u32 dirtyFlag) { + u8 comb; // r28 + s32 scale; // r30 } static void mcmdVolumeSelect(SYNTH_VOICE* svoice, MSTEP* cstep) {} @@ -544,96 +692,594 @@ static void mcmdDopplerSelect(SYNTH_VOICE* svoice, MSTEP* cstep) {} static void mcmdTremoloSelect(SYNTH_VOICE* svoice, MSTEP* cstep) {} static void mcmdAuxAFXSelect(SYNTH_VOICE* svoice, MSTEP* cstep) { - unsigned long i; // r31 + u32 i; // r31 static u64 mask[4] = {0x100000000, 0x200000000, 0x400000000, 0x800000000}; // size: 0x20 static u32 dirty[4] = {0x80000001, 0x80000002, 0x80000004, 0x80000008}; // size: 0x10 } static void mcmdAuxBFXSelect(SYNTH_VOICE* svoice, MSTEP* cstep) { - unsigned long i; // r31 + u32 i; // r31 static u64 mask[4] = {0x1000000000, 0x2000000000, 0x4000000000, 0x8000000000}; // size: 0x20 static u32 dirty[4] = {0x80000010, 0x80000020, 0x80000040, 0x80000080}; // size: 0x10 } static void mcmdPortamento(SYNTH_VOICE* svoice, MSTEP* cstep) { - unsigned long time; // r1+0x10 + u32 time; // r1+0x10 } -long varGet32(SYNTH_VOICE* svoice, unsigned long ctrl, unsigned char index) {} -signed short varGet(SYNTH_VOICE* svoice, unsigned long ctrl, unsigned char index) {} -void varSet32(SYNTH_VOICE* svoice, unsigned long ctrl, unsigned char index, long v) {} -void varSet(SYNTH_VOICE* svoice, unsigned long ctrl, unsigned char index, signed short v) {} -static void mcmdVarCalculation(SYNTH_VOICE* svoice, MSTEP* cstep, unsigned char op) { - signed short s1; // r28 - signed short s2; // r31 - long t; // r30 +s32 varGet32(SYNTH_VOICE* svoice, u32 ctrl, u8 index) { + if (ctrl != 0) { + return inpGetExCtrl(svoice, index); + } + + index &= 0x1f; + if (index < 16) { + return svoice->local_vars[index]; + } + + return synthGlobalVariable[index - 16]; +} + +s16 varGet(SYNTH_VOICE* svoice, u32 ctrl, u8 index) { return varGet32(svoice, ctrl, index); } + +void varSet32(SYNTH_VOICE* svoice, u32 ctrl, u8 index, s32 v) { + if (ctrl != 0) { + inpSetExCtrl(svoice, index, v); + return; + } + index &= 0x1f; + + if (index < 16) { + svoice->local_vars[index] = v; + return; + } + + synthGlobalVariable[index - 16] = v; +} +void varSet(SYNTH_VOICE* svoice, u32 ctrl, u8 index, s16 v) { varSet32(svoice, ctrl, index, v); } +static void mcmdVarCalculation(SYNTH_VOICE* svoice, MSTEP* cstep, u8 op) { + s16 s1; // r28 + s16 s2; // r31 + s32 t; // r30 } static void mcmdSetVarImmediate(SYNTH_VOICE* svoice, MSTEP* cstep) {} -static void mcmdIfVarCompare(SYNTH_VOICE* svoice, MSTEP* cstep, unsigned char cmp) { - long a; // r28 - long b; // r27 - unsigned char result; // r30 +static void mcmdIfVarCompare(SYNTH_VOICE* svoice, MSTEP* cstep, u8 cmp) { + s32 a; // r28 + s32 b; // r27 + u8 result; // r30 } -unsigned long macPostMessage(unsigned long vid, long mesg) { +u32 macPostMessage(u32 vid, s32 mesg) { SYNTH_VOICE* sv; // r31 } static void mcmdSendMessage(SYNTH_VOICE* svoice, MSTEP* cstep) { - unsigned char i; // r31 - long mesg; // r30 - unsigned short macro; // r28 + u8 i; // r31 + s32 mesg; // r30 + u16 macro; // r28 } static void mcmdGetMessage(SYNTH_VOICE* svoice, MSTEP* cstep) { - long mesg; // r30 + s32 mesg; // r30 } static void mcmdGetVID(SYNTH_VOICE* svoice, MSTEP* cstep) {} static void mcmdModeSelect(SYNTH_VOICE* svoice, MSTEP* cstep) {} static void mcmdSRCModeSelect(SYNTH_VOICE* svoice, MSTEP* cstep) {} static void mcmdSetKeyGroup(SYNTH_VOICE* svoice, MSTEP* cstep) { - unsigned long i; // r31 - unsigned char kg; // r30 - unsigned long kill; // r29 + u32 i; // r31 + u8 kg; // r30 + u32 kill; // r29 } static void mcmdSetupTremolo(SYNTH_VOICE* svoice, MSTEP* cstep) {} -void macHandleActive(struct SYNTH_VOICE* svoice) { - unsigned char i; // r29 - unsigned char lastNote; // r27 - unsigned long ex; // r30 +static void macHandleActive(SYNTH_VOICE* svoice) { + u8 i; // r29 + u8 lastNote; // r27 + u32 ex; // r30 CHANNEL_DEFAULTS* channelDefaults; // r28 static MSTEP cstep; + + if (svoice->cFlags & 3) { + if (svoice->cFlags & 1) { + svoice->cFlags &= ~1; + hwBreak(svoice->id & 0xFF); + } + + svoice->panning[0] = svoice->panTarget[0] = (u32)(svoice->setup.pan) << 16; + svoice->panning[1] = svoice->panTarget[1] = 0; + svoice->volume = (u32)(svoice->setup.vol << 16); + svoice->volTable = 0; + svoice->orgVolume = svoice->volume; + svoice->midi = svoice->setup.midi; + svoice->midiSet = svoice->setup.midiSet; + svoice->section = svoice->setup.section; + svoice->track = svoice->setup.track; + svoice->itdMode = svoice->setup.itdMode; + svoice->keyGroup = 0; + svoice->vibModAddScale = 0; + svoice->treScale = 0; + inpInit(svoice); + if ((lastNote = inpGetMidiLastNote(svoice->midi, svoice->midiSet)) != 0xFF) { + svoice->lastNote = lastNote; + } else { + svoice->lastNote = svoice->orgNote; + } + + inpSetMidiLastNote(svoice->midi, svoice->midiSet, svoice->orgNote); + voiceSetLastStarted(svoice); + svoice->vGroup = svoice->setup.vGroup; + svoice->studio = svoice->setup.studio; + svoice->portTime = 0; + svoice->portDuration = 25600; + svoice->portType = 0; + if (svoice->midi != 0xff) { + svoice->portLastCtrlState = inpGetMidiCtrl(65, svoice->midi, svoice->midiSet); + } else { + svoice->portLastCtrlState = 0; + } + channelDefaults = inpGetChannelDefaults(svoice->midi, svoice->midiSet); + svoice->pbLowerKeyRange = channelDefaults->pbRange; + svoice->pbUpperKeyRange = channelDefaults->pbRange; + svoice->revVolScale = 128; + svoice->revVolOffset = 0; + svoice->loop = 0; + svoice->sweepNum[0] = 0; + svoice->sweepNum[1] = 0; + svoice->sweepOff[0] = 0; + svoice->sweepOff[1] = 0; + svoice->lfo[0].period = 0; + svoice->lfo[0].value = 0; + svoice->lfo[0].lastValue = 0x7fff; + svoice->lfo[1].period = 0; + svoice->lfo[1].value = 0; + svoice->lfo[1].lastValue = 0x7fff; + + for (i = 0; i < 3; ++i) { + svoice->trapEventAddr[i] = NULL; + } + + svoice->trapEventAny = 0; + svoice->sInfo = -1; + svoice->playFrq = -1; + svoice->pbLast = 0x2000; + svoice->curOutputVolume = 0; + svoice->cFlags &= 8; + svoice->cFlags |= 0x300000000000; + memset(svoice->local_vars, 0, sizeof(svoice->local_vars)); + svoice->waitTime = macRealTime; + svoice->macStartTime = macRealTime; + synthStartSynthJobHandling(svoice); + } + +#ifdef _DEBUG + DebugMacroSteps = 0; +#endif + + do { +#ifdef _DEBUG + if (++DebugMacroSteps > 32) { + break; + } +#endif + + cstep.para[0] = svoice->curAddr->para[0]; + cstep.para[1] = svoice->curAddr->para[1]; + ++svoice->curAddr; + ex = 0; + switch (cstep.para[0] & 0x7f) { + case 0x0: + ex = mcmdEndOfMacro(svoice); + break; + case 0x1: + ex = mcmdStop(svoice); + break; + case 0x2: + mcmdIfKey(svoice, &cstep); + break; + case 0x3: + mcmdIfVelocity(svoice, &cstep); + break; + case 0x4: + ex = mcmdWait(svoice, &cstep); + break; + case 0x5: + mcmdLoop(svoice, &cstep); + break; + case 0x6: + ex = mcmdGoto(svoice, &cstep); + break; + case 0x7: + ex = mcmdWaitMs(svoice, &cstep); + break; + case 0x8: + mcmdPlayMacro(svoice, &cstep); + break; + case 0x9: + mcmdSendKeyOff(svoice, &cstep); + break; + case 0xa: + mcmdIfModulation(svoice, &cstep); + break; + case 0xb: + mcmdSetPianoPanning(svoice, &cstep); + break; + case 0xc: + mcmdSetADSR(svoice, &cstep); + break; + case 0xd: + mcmdScaleVolume(svoice, &cstep); + break; + case 0xe: + mcmdSetPanning(svoice, &cstep); + break; + case 0xf: + mcmdEnvelope(svoice, &cstep); + break; + case 0x10: + mcmdStartSample(svoice, &cstep); + break; + case 0x11: + mcmdStopSample(svoice); + break; + case 0x12: + mcmdKeyOff(svoice); + break; + case 0x13: + mcmdIfRandom(svoice, &cstep); + break; + case 0x14: + mcmdFadeIn(svoice, &cstep); + break; + case 0x15: + mcmdSetSurroundPanning(svoice, &cstep); + break; + case 0x16: + mcmdSetADSRFromCtrl(svoice, &cstep); + break; + case 0x17: + mcmdRandomKey(svoice, &cstep); + break; + case 0x18: + ex = mcmdAddKey(svoice, &cstep); + break; + case 0x19: + ex = mcmdSetKey(svoice, &cstep); + break; + case 0x1a: + ex = mcmdLastKey(svoice, &cstep); + break; + case 0x1b: + mcmdPortamento(svoice, &cstep); + break; + case 0x1c: + mcmdVibrato(svoice, &cstep); + break; + case 0x1d: + ex = mcmdPitchSweep(svoice, &cstep, 0); + break; + case 0x1e: + ex = mcmdPitchSweep(svoice, &cstep, 1); + break; + case 0x1f: + mcmdSetPitch(svoice, &cstep); + break; + case 0x20: + mcmdSetPitchADSR(svoice, &cstep); + break; + case 0x21: + mcmdScaleVolumeDLS(svoice, &cstep); + break; + case 0x22: + mcmdSetMod2Vibrato(svoice, &cstep); + break; + case 0x23: + mcmdSetupTremolo(svoice, &cstep); + break; + case 0x24: + mcmdReturn(svoice); + break; + case 0x25: + ex = mcmdGosub(svoice, &cstep); + break; + case 0x28: + mcmdTrapEvent(svoice, &cstep); + break; + case 0x29: + mcmdUntrapEvent(svoice, &cstep); + break; + case 0x2a: + mcmdSendMessage(svoice, &cstep); + break; + case 0x2b: + mcmdGetMessage(svoice, &cstep); + break; + case 0x2c: + mcmdGetVID(svoice, &cstep); + break; + case 0x30: + mcmdAddAgeCounter(svoice, &cstep); + break; + case 0x31: + mcmdSetAgeCounter(svoice, &cstep); + break; + case 0x32: + mcmdSendFlag(&cstep); + break; + case 0x33: + mcmdSetPitchWheelRange(svoice, &cstep); + break; + case 0x34: + mcmdScaleReverb(svoice, &cstep); + break; + case 0x35: + mcmdSetPitchbendAfterKeyOff(svoice); + break; + case 0x36: + mcmdSetPriority(svoice, &cstep); + break; + case 0x37: + mcmdAddPriority(svoice, &cstep); + break; + case 0x38: + mcmdSetAgeCounterSpeed(svoice, &cstep); + break; + case 0x39: + mcmdSetAgeCounterByVolume(svoice, &cstep); + break; + case 0x40: + mcmdVolumeSelect(svoice, &cstep); + break; + case 0x41: + mcmdPanningSelect(svoice, &cstep); + break; + case 0x42: + mcmdPitchWheelSelect(svoice, &cstep); + break; + case 0x43: + mcmdModWheelSelect(svoice, &cstep); + break; + case 0x44: + mcmdPedalSelect(svoice, &cstep); + break; + case 0x45: + mcmdPortamentoSelect(svoice, &cstep); + break; + case 0x46: + mcmdReverbSelect(svoice, &cstep); + break; + case 0x47: + mcmdSurroundPanningSelect(svoice, &cstep); + break; + case 0x48: + mcmdDopplerSelect(svoice, &cstep); + break; + case 0x49: + mcmdTremoloSelect(svoice, &cstep); + break; + case 0x4a: + mcmdPreAuxASelect(svoice, &cstep); + break; + case 0x4b: + mcmdPreAuxBSelect(svoice, &cstep); + break; + case 0x4c: + mcmdPostAuxBSelect(svoice, &cstep); + break; + case 0x4d: + mcmdAuxAFXSelect(svoice, &cstep); + break; + case 0x4e: + mcmdAuxBFXSelect(svoice, &cstep); + break; + case 0x50: + mcmdSetupLFO(svoice, &cstep); + break; + case 0x58: + mcmdModeSelect(svoice, &cstep); + break; + case 0x59: + mcmdSetKeyGroup(svoice, &cstep); + break; + case 0x5a: + mcmdSRCModeSelect(svoice, &cstep); + break; + case 0x60: + mcmdVarCalculation(svoice, &cstep, 0); + break; + case 0x61: + mcmdVarCalculation(svoice, &cstep, 1); + break; + case 0x62: + mcmdVarCalculation(svoice, &cstep, 2); + break; + case 0x63: + mcmdVarCalculation(svoice, &cstep, 3); + break; + case 0x64: + mcmdVarCalculation(svoice, &cstep, 4); + break; + case 0x65: + mcmdSetVarImmediate(svoice, &cstep); + break; + case 0x70: + mcmdIfVarCompare(svoice, &cstep, 0); + break; + case 0x71: + mcmdIfVarCompare(svoice, &cstep, 1); + } + } while (!ex); } -void macHandle(unsigned long deltaTime) { - struct SYNTH_VOICE* sv; // r31 - struct SYNTH_VOICE* nextSv; // r30 - unsigned long long w; // r28 +void macHandle(u32 deltaTime) { + SYNTH_VOICE* sv; // r31 + SYNTH_VOICE* nextSv; // r30 + u64 w; // r28 + + for (nextSv = macTimeQueueRoot; nextSv != NULL && nextSv->wait <= macRealTime;) { + sv = nextSv->nextTimeQueueMacro; + w = nextSv->wait; + macMakeActive(nextSv); + nextSv->waitTime = w; + nextSv = sv; + } + + nextSv = macActiveMacroRoot; + while (nextSv != NULL) { + if (HasHWEventTrap(nextSv) != 0) { + CheckHWEventTrap(nextSv); + } + + macHandleActive(nextSv); + nextSv = nextSv->nextMacActive; + } + macRealTime += deltaTime; } -void macSampleEndNotify(struct SYNTH_VOICE* sv) {} -void macSetExternalKeyoff(struct SYNTH_VOICE* svoice) {} -void macSetPedalState(struct SYNTH_VOICE* svoice, unsigned long state) {} -void TimeQueueAdd(SYNTH_VOICE* svoice) { + +void macSampleEndNotify(SYNTH_VOICE* sv) { + if (sv->macState != MAC_STATE_YIELDED) { + return; + } +#line 3156 /* clang-format off */ + ASSERT(sv->addr!=NULL); + /* clang-format on */ + + if (!ExecuteTrap(sv, 1) && (sv->cFlags & 0x40000)) { + macMakeActive(sv); + } +} +void macSetExternalKeyoff(SYNTH_VOICE* sv) { + sv->cFlags |= 8; + if (!sv->addr) { + return; + } + + if (!(sv->cFlags & 0x10000000000)) { + if (!ExecuteTrap(sv, 0) && (sv->cFlags & 0x4)) { + macMakeActive(sv); + } + } else { + sv->cFlags |= 0x40000000000; + } +} + +void macSetPedalState(SYNTH_VOICE* svoice, u32 state) { + if (state != 0) { + svoice->cFlags |= 0x10000000000; + } else { + if (svoice->addr && (svoice->cFlags & 0x40000000000)) { + if (!ExecuteTrap(svoice, 0) && (svoice->cFlags & 0x4)) { + macMakeActive(svoice); + } + } + + svoice->cFlags &= ~(0x10000000000 | 0x40000000000); + } +} + +static void TimeQueueAdd(SYNTH_VOICE* svoice) { SYNTH_VOICE* sv; // r31 SYNTH_VOICE* lastSv; // r30 -} -void UnYieldMacro(struct SYNTH_VOICE* svoice, unsigned long disableUpdate) {} -void macMakeActive(struct SYNTH_VOICE* svoice) {} -void macMakeInactive(struct SYNTH_VOICE* svoice, MAC_STATE newState) {} -unsigned long macStart(unsigned short macid, unsigned char priority, unsigned char maxVoices, - unsigned short allocId, unsigned char key, unsigned char vol, - unsigned char panning, unsigned char midi, unsigned char midiSet, - unsigned char section, unsigned short step, unsigned short trackid, - unsigned char new_vid, unsigned char vGroup, unsigned char studio, - unsigned long itd) { - unsigned long voice; // r30 - unsigned long vid; // r25 - struct MSTEP* addr; // r28 - struct SYNTH_VOICE* svoice; // r31 - unsigned short seqPrio; // r24 + lastSv = NULL; + for (sv = macTimeQueueRoot; sv != NULL && sv->wait < svoice->wait;) { + lastSv = sv; + sv = sv->nextTimeQueueMacro; + } + + if (sv == NULL) { + if (lastSv == NULL) { + macTimeQueueRoot = svoice; + svoice->nextTimeQueueMacro = NULL; + svoice->prevTimeQueueMacro = NULL; + } else { + lastSv->nextTimeQueueMacro = svoice; + svoice->prevTimeQueueMacro = lastSv; + svoice->nextTimeQueueMacro = NULL; + } + } else { + svoice->nextTimeQueueMacro = sv; + if (svoice->prevTimeQueueMacro = sv->prevTimeQueueMacro) { + sv->prevTimeQueueMacro->nextTimeQueueMacro = svoice; + } else { + macTimeQueueRoot = svoice; + } + sv->prevTimeQueueMacro = svoice; + } +} +static void UnYieldMacro(SYNTH_VOICE* svoice, u32 disableUpdate) { + if (svoice->wait != 0) { + if (svoice->wait != -1) { + if (svoice->prevTimeQueueMacro == NULL) { + macTimeQueueRoot = svoice->nextTimeQueueMacro; + } else { + svoice->prevTimeQueueMacro->nextTimeQueueMacro = svoice->nextTimeQueueMacro; + } + + if (svoice->nextTimeQueueMacro) { + svoice->nextTimeQueueMacro->prevTimeQueueMacro = svoice->prevTimeQueueMacro; + } + } + + if (!disableUpdate) { + synthForceLowPrecisionUpdate(svoice); + } + + svoice->wait = 0; + svoice->waitTime = macRealTime; + svoice->cFlags &= ~0x40004; + } +} +void macMakeActive(SYNTH_VOICE* sv) { + if (sv->macState == MAC_STATE_RUNNABLE) { + return; + } +#line 3297 /* clang-format off */ + ASSERT(sv->addr!=NULL); + /* clang-format on */ + UnYieldMacro(sv, 0); + if (sv->nextMacActive = macActiveMacroRoot) { + macActiveMacroRoot->prevMacActive = sv; + } + sv->prevMacActive = NULL; + macActiveMacroRoot = sv; + sv->macState = MAC_STATE_RUNNABLE; +} + +void macMakeInactive(SYNTH_VOICE* svoice, MAC_STATE newState) { + if (svoice->macState == newState) { + return; + } + +#line 3333 /* clang-format off */ + ASSERT(svoice->addr!=NULL); + /* clang-format on */ + if (svoice->macState == MAC_STATE_RUNNABLE) { + if (svoice->prevMacActive == NULL) { + macActiveMacroRoot = svoice->nextMacActive; + } else { + svoice->prevMacActive->nextMacActive = svoice->nextMacActive; + } + + if (svoice->nextMacActive != NULL) { + svoice->nextMacActive->prevMacActive = svoice->prevMacActive; + } + } + + if (newState == MAC_STATE_STOPPED) { + UnYieldMacro(svoice, 1); + } + svoice->macState = newState; +} + +u32 macStart(u16 macid, u8 priority, u8 maxVoices, u16 allocId, u8 key, u8 vol, u8 panning, u8 midi, + u8 midiSet, u8 section, u16 step, u16 trackid, u8 new_vid, u8 vGroup, u8 studio, + u32 itd) { + u32 voice; // r30 + u32 vid; // r25 + MSTEP* addr; // r28 + SYNTH_VOICE* svoice; // r31 + u16 seqPrio; // r24 } void macInit() { - unsigned long i; // r31 + u32 i; // r31 macActiveMacroRoot = 0; macTimeQueueRoot = 0; diff --git a/src/musyx/txwin/txwin.c b/src/musyx/txwin/txwin.c new file mode 100644 index 00000000..00535965 --- /dev/null +++ b/src/musyx/txwin/txwin.c @@ -0,0 +1,233 @@ +#include "musyx/txwin.h" +#include "dolphin/gx.h" +#include "dolphin/os.h" +#include "musyx/assert.h" + +#include +#include +#include + +/* TODO: TEMPORARY HACKS */ +extern GXRenderModeObj* DEMOGetRenderModeObj(); +extern void DEMOPrintf(s16, s16, s16, char*, ...); + +static void __win_log_refresh(sWIN* handle); +static void __win_add_node(sWIN* handle); +static void __win_delete_node(sWIN* handle); + +static unsigned short __X_Res = 0; +static unsigned short __Y_Res = 0; +GXRenderModeObj* __rmp = NULL; +sWIN* __CurrNode = NULL; +sWIN* __LastNode = NULL; // size: 0x4 +sWIN* __FirstNode = NULL; // size: 0x4 + +void winInit() { + __FirstNode = NULL; + __LastNode = NULL; + __CurrNode = NULL; + winSetFontSize(8); + __rmp = DEMOGetRenderModeObj(); + GXSetCopyClear((GXColor){0x0A, 0x10, 0x19, 0xFF}, 0xFFFFFF); +} + +sWIN* winOpenWindow(s32 x1, s32 y1, s32 x2, s32 y2, char* caption, void* func, u32 flags) { + sWIN* handle; // r31 +#line 109 + ASSERT_MSG(x1 < x2, "TXWIN: Illegal X coords for window\n"); + ASSERT_MSG(y1 < y2, "TXWIN: Illegal y coords for window\n"); + + handle = OSAlloc(sizeof(sWIN)); + + ASSERT_MSG(handle != NULL, "TXWIN: FAILED TO ALLOCATE WINDOW!\n"); + __win_add_node(handle); + handle->x1 = x1; + handle->y1 = y1; + handle->x2 = x2; + handle->y2 = y2; + handle->pixel_width = (x2 - x1) + 1; + handle->pixel_height = (y2 - y1) + 1; + handle->curr_x = 0; + handle->curr_y = 0; + handle->caption = caption; + handle->char_width = handle->pixel_width / 8; + handle->char_height = handle->pixel_height / 8; + handle->refresh = func; + handle->flags = flags; + return handle; +} + +sWIN* winOpenLogWindow(s32 x1, s32 y1, s32 x2, s32 y2, char* caption, u16 num_lines, u32 flags) { + sWIN* handle; // r31 + u16 i; // r30 + + handle = winOpenWindow(x1, y1, x2, y2, caption, NULL, 0); + handle->refresh = __win_log_refresh; + handle->flags = 1; + handle->curr_output_line = 0; + handle->curr_view_line = 0; + handle->total_lines = (u16)handle->char_height + num_lines; + handle->buffer = OSAlloc(handle->total_lines * 4); +#line 192 + + ASSERT_MSG(handle->buffer != NULL, "TXWIN: Unable to allocate log window buffer.\n"); + + for (i = 0; i < handle->total_lines; ++i) { + + handle->buffer[i] = OSAlloc(handle->char_width + 1); + + memset(handle->buffer[i], 0, handle->char_width + 1); + + ASSERT_MSG(handle->buffer[i] != NULL, "TXWIN: Failed to allocate buffer element\n"); + } + + return handle; +} + +void winPrintfXY(sWIN* handle, s16 char_x, s16 char_y, char* fmt, ...) { + va_list args; + char buffer[128]; + s16 x; + s16 y; + + va_start(args, fmt); + vsprintf(buffer, fmt, args); + va_end(args); + + if (strlen(buffer) > (u32)handle->char_width) { + buffer[handle->char_width] = '\0'; + } + x = handle->x1 + (char_x * 8); + y = handle->y1 + (char_y * 8); + DEMOPrintf(x, y, 0, "%s", buffer); +} + +void winLogPrintf(sWIN* handle, char* fmt, ...) { + va_list args; + char buffer[128]; + va_start(args, fmt); + vsprintf(buffer, fmt, args); + va_end(args); + + if (strlen(buffer) > (u32)handle->char_width) { + buffer[handle->char_width] = '\0'; + } + + strcpy(handle->buffer[handle->curr_output_line], buffer); + handle->curr_output_line = (handle->curr_output_line + 1) % handle->total_lines; +} + +void winClearLogWindow(sWIN* handle) { + u16 i; + for (i = 0; i < handle->total_lines; ++i) { + memset(handle->buffer[i], 0, handle->char_width + 1); + } + + handle->curr_output_line = 0; + handle->curr_view_line = 0; +} + +void winSetFontSize(u16 size) { + + if (size >= 8 && size <= 40) { + + __X_Res = (8.0 / (float)size) * 640.0; + + __Y_Res = (float)__X_Res * 0.75; + } else { + + __X_Res = 640; + + __Y_Res = 480; + } +} + +void winRefresh() { + sWIN* ptr; +#line 338 + ASSERT_MSG(__FirstNode != NULL, ">> winRefresh(): window list is empty!\n"); + + ptr = __FirstNode; + DEMOInitCaption(2, __X_Res, __Y_Res); + + while (ptr != NULL) { + if (ptr->refresh) { + ptr->refresh(ptr); + } + + ptr = ptr->next; + } +} +void __win_add_node(sWIN* handle) { +#line 390 + ASSERT_MSG(handle != NULL, "__add_node(): you're adding a NULL node!\n"); + + if ((sWIN*)NULL == __LastNode) { + + __CurrNode = handle; + + __LastNode = handle; + + __FirstNode = handle; + + handle->next = NULL; + + handle->prev = NULL; + + ASSERT_MSG(__FirstNode != NULL, " > __FirstNode: NULL HANDLE!\n"); + } else { + __LastNode->next = handle; + handle->next = NULL; + handle->prev = __LastNode; + __LastNode = handle; + } +} + +void __win_delete_node(sWIN* handle) { +#line 434 + ASSERT_MSG(handle != NULL, "__delete_node(): you're deleting a NULL node!\n"); + + if (__FirstNode == handle) { + if (handle->next != NULL) { + __FirstNode = handle->next; + handle->next->prev = NULL; + OSFree(handle); + } else { + __FirstNode = __LastNode = NULL; + OSFree(handle); + } + } else if (__LastNode == handle) { + if (handle->prev != NULL) { + __LastNode = handle->prev; + handle->prev->next = NULL; + OSFree(handle); + } else { + __FirstNode = __LastNode = NULL; + OSFree(handle); + } + } else { + handle->prev->next = handle->next; + handle->next->prev = handle->prev; + OSFree(handle); + } +} + +void __win_log_refresh(struct STRUCT_WIN* handle) { + u32 uVar1; + int iVar2; + unsigned short n; // r30 + unsigned short i; // r29 + unsigned short x; // r28 + unsigned short y; // r27 + unsigned short index; // r1+0xC +#line 506 + ASSERT_MSG(handle != NULL, "OHMYGAWD\n"); + n = (u32)handle->curr_output_line; + x = handle->x1; + y = handle->y2; + i = 0; + for (i = 0; i < handle->char_height; ++i) { + n = index = (u16)(n + (handle->total_lines - 1)) % (u32)handle->total_lines; + DEMOPrintf(x, (y + i) % 2, 0, "%s", handle->buffer[index]); + } +}