From 895b02f4102885d8ab8c4419d76dfef7f4c21703 Mon Sep 17 00:00:00 2001 From: hrydgard Date: Sun, 28 Jun 2009 10:00:25 +0000 Subject: [PATCH] DSP: Add txt file with luigi ucode comments (very basic). Rename some stuff. Remove function pointer in g_dsp structure, replace with a "Host" function call. Fix a problem where symbols weren't loaded into DSP debugger. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3563 8ced0084-cf51-0410-be5f-012b33b47a6e --- .../Src/IPC_HLE/WII_IPC_HLE_Device_net.cpp | 7 +- Source/Core/DSPCore/DSPCore.vcproj | 56 +- .../Src/{gdsp_aram.cpp => DSPAccelerator.cpp} | 0 .../Src/{gdsp_aram.h => DSPAccelerator.h} | 4 +- Source/Core/DSPCore/Src/DSPAnalyzer.cpp | 11 +- Source/Core/DSPCore/Src/DSPCore.cpp | 5 +- Source/Core/DSPCore/Src/DSPCore.h | 28 +- Source/Core/DSPCore/Src/DSPHost.h | 1 + .../Src/{gdsp_ext_op.cpp => DSPIntExtOps.cpp} | 4 +- .../Src/{gdsp_ext_op.h => DSPIntExtOps.h} | 0 .../{gdsp_opcodes_helper.h => DSPIntUtil.h} | 31 +- .../Src/{gdsp_memory.cpp => DSPMemoryMap.cpp} | 21 +- .../Src/{gdsp_memory.h => DSPMemoryMap.h} | 1 + Source/Core/DSPCore/Src/DSPTables.cpp | 2 +- Source/Core/DSPCore/Src/DspIntArithmetic.cpp | 2 +- Source/Core/DSPCore/Src/DspIntBranch.cpp | 5 +- Source/Core/DSPCore/Src/DspIntLoadStore.cpp | 4 +- Source/Core/DSPCore/Src/DspIntMisc.cpp | 2 +- Source/Core/DSPCore/Src/DspIntMultiplier.cpp | 2 +- Source/Core/DSPCore/Src/gdsp_interface.cpp | 6 +- Source/Core/DSPCore/Src/gdsp_interpreter.cpp | 6 +- Source/Core/DSPCore/Src/gdsp_registers.h | 3 +- Source/DSPTool/Src/main.cpp | 3 +- .../Plugin_DSP_HLE/Src/UCodes/UCodes.cpp | 4 +- .../Plugin_DSP_LLE/Src/DSPDebugInterface.cpp | 2 +- Source/Plugins/Plugin_DSP_LLE/Src/DSPHost.cpp | 29 +- .../Src/Debugger/DSPRegisterView.cpp | 2 +- .../Plugin_DSP_LLE/Src/Debugger/Debugger.cpp | 50 +- .../Plugin_DSP_LLE/Src/Debugger/Debugger.h | 3 +- Source/Plugins/Plugin_DSP_LLE/Src/Globals.cpp | 8 +- Source/Plugins/Plugin_DSP_LLE/Src/main.cpp | 9 - docs/DSP/DSP_UC_Luigi.txt | 2496 +++++++++++++++++ docs/DSP/DSP_UC_Zelda.txt | 224 +- docs/DSP/prefix_replace.py | 45 + 34 files changed, 2826 insertions(+), 250 deletions(-) rename Source/Core/DSPCore/Src/{gdsp_aram.cpp => DSPAccelerator.cpp} (100%) rename Source/Core/DSPCore/Src/{gdsp_aram.h => DSPAccelerator.h} (93%) rename Source/Core/DSPCore/Src/{gdsp_ext_op.cpp => DSPIntExtOps.cpp} (99%) rename Source/Core/DSPCore/Src/{gdsp_ext_op.h => DSPIntExtOps.h} (100%) rename Source/Core/DSPCore/Src/{gdsp_opcodes_helper.h => DSPIntUtil.h} (97%) rename Source/Core/DSPCore/Src/{gdsp_memory.cpp => DSPMemoryMap.cpp} (80%) rename Source/Core/DSPCore/Src/{gdsp_memory.h => DSPMemoryMap.h} (99%) create mode 100644 docs/DSP/DSP_UC_Luigi.txt create mode 100644 docs/DSP/prefix_replace.py diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.cpp index 5194f9c378..4bc4ca42a0 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.cpp @@ -58,8 +58,7 @@ #include "WII_IPC_HLE_Device_net.h" #include #ifdef _WIN32 -#include -typedef int socklen_t; +#include #else #include #include @@ -287,7 +286,7 @@ u32 CWII_IPC_HLE_Device_net_ip_top::ExecuteCommand(u32 _Command, u32 _BufferIn, // Clean the location of the output buffer to zeroes as a safety precaution */ Memory::Memset(BufferOut, 0, BufferOutSize); - switch(_Command) + switch (_Command) { case IOCTL_SO_STARTUP: break; @@ -297,7 +296,7 @@ u32 CWII_IPC_HLE_Device_net_ip_top::ExecuteCommand(u32 _Command, u32 _BufferIn, u32 TYPE = Memory::Read_U32(_BufferIn + 0x04); u32 PROT = Memory::Read_U32(_BufferIn + 0x04 * 2); u32 Unk1 = Memory::Read_U32(_BufferIn + 0x04 * 3); - u32 Socket = socket(AF,TYPE,PROT); + u32 Socket = socket(AF, TYPE, PROT); return Common::swap32(Socket); // So it doesn't get mangled later on } break; diff --git a/Source/Core/DSPCore/DSPCore.vcproj b/Source/Core/DSPCore/DSPCore.vcproj index 520c603292..0bb68fce9e 100644 --- a/Source/Core/DSPCore/DSPCore.vcproj +++ b/Source/Core/DSPCore/DSPCore.vcproj @@ -413,6 +413,14 @@ RelativePath=".\Src\DspIntBranch.cpp" > + + + + @@ -425,6 +433,10 @@ RelativePath=".\Src\DspIntMultiplier.cpp" > + + + + + + @@ -486,6 +506,14 @@ RelativePath=".\Src\DSPJit.h" > + + + + @@ -494,14 +522,6 @@ RelativePath=".\Src\DSPTables.h" > - - - - @@ -510,14 +530,6 @@ RelativePath=".\Src\gdsp_condition_codes.h" > - - - - @@ -534,18 +546,6 @@ RelativePath=".\Src\gdsp_interpreter.h" > - - - - - - diff --git a/Source/Core/DSPCore/Src/gdsp_aram.cpp b/Source/Core/DSPCore/Src/DSPAccelerator.cpp similarity index 100% rename from Source/Core/DSPCore/Src/gdsp_aram.cpp rename to Source/Core/DSPCore/Src/DSPAccelerator.cpp diff --git a/Source/Core/DSPCore/Src/gdsp_aram.h b/Source/Core/DSPCore/Src/DSPAccelerator.h similarity index 93% rename from Source/Core/DSPCore/Src/gdsp_aram.h rename to Source/Core/DSPCore/Src/DSPAccelerator.h index b291406d9c..00992a430c 100644 --- a/Source/Core/DSPCore/Src/gdsp_aram.h +++ b/Source/Core/DSPCore/Src/DSPAccelerator.h @@ -15,8 +15,8 @@ // Official SVN repository and contact information can be found at // http://code.google.com/p/dolphin-emu/ -#ifndef _GDSP_ARAM_H -#define _GDSP_ARAM_H +#ifndef _DSP_ACCELERATOR_H +#define _DSP_ACCELERATOR_H u16 dsp_read_accelerator(); diff --git a/Source/Core/DSPCore/Src/DSPAnalyzer.cpp b/Source/Core/DSPCore/Src/DSPAnalyzer.cpp index c182fa33c8..db08157299 100644 --- a/Source/Core/DSPCore/Src/DSPAnalyzer.cpp +++ b/Source/Core/DSPCore/Src/DSPAnalyzer.cpp @@ -18,7 +18,7 @@ #include "DSPAnalyzer.h" #include "DSPInterpreter.h" #include "DSPTables.h" -#include "gdsp_memory.h" +#include "DSPMemoryMap.h" namespace DSPAnalyzer { @@ -30,12 +30,13 @@ u8 code_flags[ISPACE]; // as well give up its time slice immediately, after executing once. // Max signature length is 6. A 0 in a signature is ignored. -#define NUM_IDLE_SIGS 4 +#define NUM_IDLE_SIGS 5 #define MAX_IDLE_SIG_SIZE 6 // 0xFFFF means ignore. const u16 idle_skip_sigs[NUM_IDLE_SIGS][MAX_IDLE_SIG_SIZE + 1] = { + // From AX: { 0x26fc, // LRS $30, @DMBH 0x02c0, 0x8000, // ANDCF $30, #0x8000 0x029d, 0xFFFF, // JLZ 0x027a @@ -52,6 +53,12 @@ const u16 idle_skip_sigs[NUM_IDLE_SIGS][MAX_IDLE_SIG_SIZE + 1] = 0x03c0, 0x8000, // ANDCF $31, #0x8000 0x029c, 0xFFFF, // JLNZ 0x0280 0, 0 }, // RET + + // From Zelda: + { 0x00de, 0xFFFE, // LR $AC0.M, @CMBH + 0x02c0, 0x8000, // ANDCF $AC0.M, #0x8000 + 0x029c, 0xFFFF, // JLNZ 0x05cf + 0 } }; void Reset() diff --git a/Source/Core/DSPCore/Src/DSPCore.cpp b/Source/Core/DSPCore/Src/DSPCore.cpp index 692a202109..d3cdf76159 100644 --- a/Source/Core/DSPCore/Src/DSPCore.cpp +++ b/Source/Core/DSPCore/Src/DSPCore.cpp @@ -30,7 +30,7 @@ #include "gdsp_interface.h" #include "gdsp_registers.h" -#include "gdsp_opcodes_helper.h" +#include "DSPIntUtil.h" SDSP g_dsp; @@ -156,8 +156,7 @@ void DSPCore_CheckExternalInterrupt() // level 7 is the interrupt exception DSPCore_SetException(7); - // Uh, confusing. Can this really be right? - g_dsp.cr &= ~0x0002; + g_dsp.cr &= ~CR_EXTERNAL_INT; } } } diff --git a/Source/Core/DSPCore/Src/DSPCore.h b/Source/Core/DSPCore/Src/DSPCore.h index 4d0537adf4..ae0228a2da 100644 --- a/Source/Core/DSPCore/Src/DSPCore.h +++ b/Source/Core/DSPCore/Src/DSPCore.h @@ -59,23 +59,35 @@ struct SDSP #if PROFILE u16 err_pc; #endif - u16 *iram; - u16 *dram; - u16 *irom; - u16 *coef; - u8 *cpu_ram; + + // This is NOT the same cr as r[DSP_REG_CR]. + // This register is shared with the main emulation, see DSP.cpp + // The plugin has control over 0x0C07 of this reg. + // Bits are defined in a struct in DSP.cpp. u16 cr; + u8 reg_stack_ptr[4]; u8 exceptions; // pending exceptions? bool exception_in_progress_hack; // is this the same as "exception enabled"? - // lets make stack depth to 32 for now + // Let's make stack depth 32 for now. The real DSP has different depths + // for the different stacks, but it would be strange if any ucode relied on stack + // overflows since on the DSP, when the stack overflows, you're screwed. u16 reg_stack[4][DSP_STACK_DEPTH]; - void (*irq_request)(void); - // for debugger only + // For debugging. u32 iram_crc; u64 step_counter; + + // When state saving, all of the above can just be memcpy'd into the save state. + // The below needs special handling. + u16 *iram; + u16 *dram; + u16 *irom; + u16 *coef; + + // This one doesn't really belong here. + u8 *cpu_ram; }; extern SDSP g_dsp; diff --git a/Source/Core/DSPCore/Src/DSPHost.h b/Source/Core/DSPCore/Src/DSPHost.h index e154ddba19..631620e6fb 100644 --- a/Source/Core/DSPCore/Src/DSPHost.h +++ b/Source/Core/DSPCore/Src/DSPHost.h @@ -27,6 +27,7 @@ u8 DSPHost_ReadHostMemory(u32 addr); void DSPHost_WriteHostMemory(u8 value, u32 addr); bool DSPHost_OnThread(); bool DSPHost_Running(); +void DSPHost_InterruptRequest(); u32 DSPHost_CodeLoaded(const u8 *ptr, int size); #endif diff --git a/Source/Core/DSPCore/Src/gdsp_ext_op.cpp b/Source/Core/DSPCore/Src/DSPIntExtOps.cpp similarity index 99% rename from Source/Core/DSPCore/Src/gdsp_ext_op.cpp rename to Source/Core/DSPCore/Src/DSPIntExtOps.cpp index e0b0009faf..c9671e139b 100644 --- a/Source/Core/DSPCore/Src/gdsp_ext_op.cpp +++ b/Source/Core/DSPCore/Src/DSPIntExtOps.cpp @@ -23,8 +23,8 @@ ====================================================================*/ -#include "gdsp_opcodes_helper.h" -#include "gdsp_memory.h" +#include "DSPIntUtil.h" +#include "DSPMemoryMap.h" // Extended opcodes do not exist on their own. These opcodes can only be // attached to opcodes that allow extending (8 lower bits of opcode not used by diff --git a/Source/Core/DSPCore/Src/gdsp_ext_op.h b/Source/Core/DSPCore/Src/DSPIntExtOps.h similarity index 100% rename from Source/Core/DSPCore/Src/gdsp_ext_op.h rename to Source/Core/DSPCore/Src/DSPIntExtOps.h diff --git a/Source/Core/DSPCore/Src/gdsp_opcodes_helper.h b/Source/Core/DSPCore/Src/DSPIntUtil.h similarity index 97% rename from Source/Core/DSPCore/Src/gdsp_opcodes_helper.h rename to Source/Core/DSPCore/Src/DSPIntUtil.h index 2936c1f512..a4210b9ee0 100644 --- a/Source/Core/DSPCore/Src/gdsp_opcodes_helper.h +++ b/Source/Core/DSPCore/Src/DSPIntUtil.h @@ -23,19 +23,18 @@ ====================================================================*/ -#ifndef _GDSP_OPCODES_HELPER_H -#define _GDSP_OPCODES_HELPER_H +#ifndef _DSP_INT_UTIL_H +#define _DSP_INT_UTIL_H #include "Common.h" #include "DSPInterpreter.h" #include "DSPCore.h" +#include "DSPMemoryMap.h" -#include "gdsp_memory.h" #include "gdsp_interpreter.h" #include "gdsp_registers.h" -#include "gdsp_ext_op.h" - +// #include "DSPIntExtOps.h" // --------------------------------------------------------------------------------------- // --- SR @@ -51,20 +50,8 @@ inline bool dsp_SR_is_flag_set(int flag) } -// See http://code.google.com/p/dolphin-emu/source/detail?r=3125 -inline void dsp_decrement_addr_reg(int reg) -{ - // This one was easy. increment is worse... - if ((g_dsp.r[reg] & g_dsp.r[DSP_REG_WR0 + reg]) == 0) - g_dsp.r[reg] |= g_dsp.r[DSP_REG_WR0 + reg]; - else - g_dsp.r[reg]--; -} - - // HORRIBLE UGLINESS, someone please fix. // See http://code.google.com/p/dolphin-emu/source/detail?r=3125 - inline u16 ToMask(u16 a) { a = a | (a >> 8); @@ -82,6 +69,16 @@ inline void dsp_increment_addr_reg(int reg) g_dsp.r[reg]++; } +// See http://code.google.com/p/dolphin-emu/source/detail?r=3125 +inline void dsp_decrement_addr_reg(int reg) +{ + // This one is easy. Looks like a hw implementation. Increment is worse... + if ((g_dsp.r[reg] & g_dsp.r[DSP_REG_WR0 + reg]) == 0) + g_dsp.r[reg] |= g_dsp.r[DSP_REG_WR0 + reg]; + else + g_dsp.r[reg]--; +} + inline void dsp_increase_addr_reg(int reg, s16 value) { // TODO: DO RIGHT! diff --git a/Source/Core/DSPCore/Src/gdsp_memory.cpp b/Source/Core/DSPCore/Src/DSPMemoryMap.cpp similarity index 80% rename from Source/Core/DSPCore/Src/gdsp_memory.cpp rename to Source/Core/DSPCore/Src/DSPMemoryMap.cpp index 46ca4a98d5..ac772fec63 100644 --- a/Source/Core/DSPCore/Src/gdsp_memory.cpp +++ b/Source/Core/DSPCore/Src/DSPMemoryMap.cpp @@ -26,20 +26,20 @@ #include #include "gdsp_interpreter.h" -#include "gdsp_memory.h" #include "gdsp_interface.h" +#include "DSPMemoryMap.h" #include "DSPCore.h" u16 dsp_imem_read(u16 addr) { switch (addr >> 12) { - case 0: + case 0: // 0xxx IRAM return g_dsp.iram[addr & DSP_IRAM_MASK]; - case 8: + case 8: // 8xxx IROM - contains code to receive code for IRAM, and a bunch of mixing loops. return g_dsp.irom[addr & DSP_IROM_MASK]; - default: + default: // Unmapped/non-existing memory ERROR_LOG(DSPLLE, "%04x DSP ERROR: Executing from invalid (%04x) memory", g_dsp.pc, addr); return 0; } @@ -49,16 +49,17 @@ u16 dsp_dmem_read(u16 addr) { switch (addr >> 12) { - case 0x0: // 0xxx DRAM + case 0x0: // 0xxx DRAM return g_dsp.dram[addr & DSP_DRAM_MASK]; - case 0x1: // 1xxx COEF + case 0x1: // 1xxx COEF + // DEBUG_LOG(DSPLLE, "%04x : Coef Read @ %04x", g_dsp.pc, addr); return g_dsp.coef[addr & DSP_COEF_MASK]; - case 0xf: // Fxxx HW regs + case 0xf: // Fxxx HW regs return gdsp_ifx_read(addr); - default: // error + default: // Unmapped/non-existing memory ERROR_LOG(DSPLLE, "%04x DSP ERROR: Read from UNKNOWN (%04x) memory", g_dsp.pc, addr); return 0; } @@ -73,14 +74,14 @@ void dsp_dmem_write(u16 addr, u16 val) break; case 0x1: // 1xxx COEF - ERROR_LOG(DSPLLE, "someone writes to COEF (pc = %02x)", g_dsp.pc); + ERROR_LOG(DSPLLE, "Illegal write to COEF (pc = %02x)", g_dsp.pc); break; case 0xf: // Fxxx HW regs gdsp_ifx_write(addr, val); break; - default: // error + default: // Unmapped/non-existing memory ERROR_LOG(DSPLLE, "%04x DSP ERROR: Write to UNKNOWN (%04x) memory", g_dsp.pc, addr); break; } diff --git a/Source/Core/DSPCore/Src/gdsp_memory.h b/Source/Core/DSPCore/Src/DSPMemoryMap.h similarity index 99% rename from Source/Core/DSPCore/Src/gdsp_memory.h rename to Source/Core/DSPCore/Src/DSPMemoryMap.h index 21a2d648f0..46f6f1e7dd 100644 --- a/Source/Core/DSPCore/Src/gdsp_memory.h +++ b/Source/Core/DSPCore/Src/DSPMemoryMap.h @@ -22,6 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ====================================================================*/ + #ifndef _GDSP_MEMORY_H #define _GDSP_MEMORY_H diff --git a/Source/Core/DSPCore/Src/DSPTables.cpp b/Source/Core/DSPCore/Src/DSPTables.cpp index 588fe569ee..9e7a17df0d 100644 --- a/Source/Core/DSPCore/Src/DSPTables.cpp +++ b/Source/Core/DSPCore/Src/DSPTables.cpp @@ -53,7 +53,7 @@ jnz, ifs, retlnz #include "DSPInterpreter.h" #include "DSPJit.h" -#include "gdsp_ext_op.h" +#include "DSPIntExtOps.h" void nop(const UDSPInstruction& opc) { diff --git a/Source/Core/DSPCore/Src/DspIntArithmetic.cpp b/Source/Core/DSPCore/Src/DspIntArithmetic.cpp index 65b8bf3ac9..9949cfc7fc 100644 --- a/Source/Core/DSPCore/Src/DspIntArithmetic.cpp +++ b/Source/Core/DSPCore/Src/DspIntArithmetic.cpp @@ -20,7 +20,7 @@ #include "DSPInterpreter.h" #include "gdsp_condition_codes.h" -#include "gdsp_opcodes_helper.h" +#include "DSPIntUtil.h" // Arithmetic and accumulator control. diff --git a/Source/Core/DSPCore/Src/DspIntBranch.cpp b/Source/Core/DSPCore/Src/DspIntBranch.cpp index 78ef2adf46..cab5027f56 100644 --- a/Source/Core/DSPCore/Src/DspIntBranch.cpp +++ b/Source/Core/DSPCore/Src/DspIntBranch.cpp @@ -21,9 +21,8 @@ #include "DSPCore.h" #include "gdsp_condition_codes.h" -#include "gdsp_opcodes_helper.h" -#include "gdsp_memory.h" - +#include "DSPIntUtil.h" +#include "DSPMemoryMap.h" namespace DSPInterpreter { diff --git a/Source/Core/DSPCore/Src/DspIntLoadStore.cpp b/Source/Core/DSPCore/Src/DspIntLoadStore.cpp index 82bc101c66..5346a4ed41 100644 --- a/Source/Core/DSPCore/Src/DspIntLoadStore.cpp +++ b/Source/Core/DSPCore/Src/DspIntLoadStore.cpp @@ -19,8 +19,8 @@ #include "DSPInterpreter.h" -#include "gdsp_memory.h" -#include "gdsp_opcodes_helper.h" +#include "DSPMemoryMap.h" +#include "DSPIntUtil.h" namespace DSPInterpreter { diff --git a/Source/Core/DSPCore/Src/DspIntMisc.cpp b/Source/Core/DSPCore/Src/DspIntMisc.cpp index 732739c0f1..a52fc93c56 100644 --- a/Source/Core/DSPCore/Src/DspIntMisc.cpp +++ b/Source/Core/DSPCore/Src/DspIntMisc.cpp @@ -23,7 +23,7 @@ #include "DSPCore.h" #include "gdsp_registers.h" -#include "gdsp_opcodes_helper.h" +#include "DSPIntUtil.h" namespace DSPInterpreter { diff --git a/Source/Core/DSPCore/Src/DspIntMultiplier.cpp b/Source/Core/DSPCore/Src/DspIntMultiplier.cpp index 853e51b8c7..38c98487e6 100644 --- a/Source/Core/DSPCore/Src/DspIntMultiplier.cpp +++ b/Source/Core/DSPCore/Src/DspIntMultiplier.cpp @@ -23,7 +23,7 @@ #include "DSPInterpreter.h" #include "gdsp_condition_codes.h" -#include "gdsp_opcodes_helper.h" +#include "DSPIntUtil.h" #include "gdsp_registers.h" namespace DSPInterpreter { diff --git a/Source/Core/DSPCore/Src/gdsp_interface.cpp b/Source/Core/DSPCore/Src/gdsp_interface.cpp index 8693b2ef36..806d42ddd9 100644 --- a/Source/Core/DSPCore/Src/gdsp_interface.cpp +++ b/Source/Core/DSPCore/Src/gdsp_interface.cpp @@ -32,7 +32,7 @@ #include "DSPHost.h" #include "DSPTables.h" #include "DSPAnalyzer.h" -#include "gdsp_aram.h" +#include "DSPAccelerator.h" #include "gdsp_interpreter.h" #include "gdsp_interface.h" @@ -124,7 +124,7 @@ void gdsp_ifx_write(u16 addr, u16 val) { case 0xfb: // DIRQ if (val & 0x1) - g_dsp.irq_request(); + DSPHost_InterruptRequest(); break; case 0xfc: // DMBH @@ -311,5 +311,3 @@ void gdsp_dma() break; } } - - diff --git a/Source/Core/DSPCore/Src/gdsp_interpreter.cpp b/Source/Core/DSPCore/Src/gdsp_interpreter.cpp index 4b1d137425..3c8050e5e5 100644 --- a/Source/Core/DSPCore/Src/gdsp_interpreter.cpp +++ b/Source/Core/DSPCore/Src/gdsp_interpreter.cpp @@ -32,12 +32,14 @@ #include "DSPAnalyzer.h" #include "gdsp_interface.h" -#include "gdsp_opcodes_helper.h" +#include "DSPIntUtil.h" namespace DSPInterpreter { volatile u32 gdsp_running; +// NOTE: These have nothing to do with g_dsp.r[DSP_REG_CR]. + // Hm, should instructions that change CR use this? Probably not (but they // should call UpdateCachedCR()) void WriteCR(u16 val) @@ -69,6 +71,8 @@ u16 ReadCR() return g_dsp.cr; } + + void HandleLoop() { // Handle looping hardware. diff --git a/Source/Core/DSPCore/Src/gdsp_registers.h b/Source/Core/DSPCore/Src/gdsp_registers.h index 825dbb6d20..79e5b1c004 100644 --- a/Source/Core/DSPCore/Src/gdsp_registers.h +++ b/Source/Core/DSPCore/Src/gdsp_registers.h @@ -93,7 +93,8 @@ #define DSP_STACK_D 1 -// CR bits +// cr (Not g_dsp.r[CR]) bits +// See HW/DSP.cpp. #define CR_HALT 0x0004 #define CR_EXTERNAL_INT 0x0002 diff --git a/Source/DSPTool/Src/main.cpp b/Source/DSPTool/Src/main.cpp index dc89544777..582ccdf5ed 100644 --- a/Source/DSPTool/Src/main.cpp +++ b/Source/DSPTool/Src/main.cpp @@ -19,14 +19,13 @@ #include "FileUtil.h" #include "DSPCodeUtil.h" -//#include "dsp_test.h" - // Stub out the dsplib host stuff, since this is just a simple cmdline tools. u8 DSPHost_ReadHostMemory(u32 addr) { return 0; } void DSPHost_WriteHostMemory(u8 value, u32 addr) {} bool DSPHost_OnThread() { return false; } bool DSPHost_Running() { return true; } u32 DSPHost_CodeLoaded(const u8 *ptr, int size) {return 0x1337c0de;} +void DSPHost_InterruptRequest() {} // This test goes from text ASM to binary to text ASM and once again back to binary. // Then the two binaries are compared. diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCodes.cpp b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCodes.cpp index 6921a353b4..24339daca8 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCodes.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCodes.cpp @@ -54,8 +54,8 @@ IUCode* UCodeFactory(u32 _CRC, CMailHandler& _rMailHandler) case 0x088e38a5: // IPL - JAP case 0xd73338cf: // IPL - case 0x42f64ac4: // Luigi (after fix) - case 0x4be6a5cb: // AC, Pikmin (after fix) + case 0x42f64ac4: // Luigi + case 0x4be6a5cb: // AC, Pikmin INFO_LOG(CONSOLE, "JAC (early Zelda) ucode chosen\n"); return new CUCode_Jac(_rMailHandler); // return new CUCode_Zelda(_rMailHandler, false); diff --git a/Source/Plugins/Plugin_DSP_LLE/Src/DSPDebugInterface.cpp b/Source/Plugins/Plugin_DSP_LLE/Src/DSPDebugInterface.cpp index d8385d1fd0..7150d187a7 100644 --- a/Source/Plugins/Plugin_DSP_LLE/Src/DSPDebugInterface.cpp +++ b/Source/Plugins/Plugin_DSP_LLE/Src/DSPDebugInterface.cpp @@ -21,7 +21,7 @@ #include "disassemble.h" #include "DSPSymbols.h" -#include "gdsp_memory.h" +#include "DSPMemoryMap.h" void DSPDebugInterface::disasm(unsigned int address, char *dest, int max_size) { diff --git a/Source/Plugins/Plugin_DSP_LLE/Src/DSPHost.cpp b/Source/Plugins/Plugin_DSP_LLE/Src/DSPHost.cpp index dbaddedd8b..e8b9ec6d21 100644 --- a/Source/Plugins/Plugin_DSP_LLE/Src/DSPHost.cpp +++ b/Source/Plugins/Plugin_DSP_LLE/Src/DSPHost.cpp @@ -23,6 +23,14 @@ extern DSPInitialize g_dspInitialize; +#if defined(HAVE_WX) && HAVE_WX + +#include "DSPConfigDlgLLE.h" +#include "Debugger/Debugger.h" // For the DSPDebuggerLLE class +extern DSPDebuggerLLE* m_DebuggerFrame; + +#endif + // The user of the DSPCore library must supply a few functions so that the // emulation core can access the environment it runs in. If the emulation // core isn't used, for example in an asm/disasm tool, then most of these @@ -48,6 +56,12 @@ bool DSPHost_Running() return !(*g_dspInitialize.pEmulatorState); } +void DSPHost_InterruptRequest() +{ + // Fire an interrupt on the PPC ASAP. + g_dspInitialize.pGenerateDSPInterrupt(); +} + u32 DSPHost_CodeLoaded(const u8 *ptr, int size) { u32 crc = GenerateCRC(ptr, size); @@ -68,13 +82,22 @@ u32 DSPHost_CodeLoaded(const u8 *ptr, int size) // TODO: Don't hardcode for Zelda. NOTICE_LOG(DSPLLE, "CRC: %08x", ector_crc); - if (ector_crc != 0x86840740 || !DSPSymbols::ReadAnnotatedAssembly("../../Docs/DSP/DSP_UC_Zelda.txt")) - { - DSPSymbols::Clear(); + + DSPSymbols::Clear(); + bool success = false; + switch (ector_crc) { + case 0x86840740: success = DSPSymbols::ReadAnnotatedAssembly("../../Docs/DSP/DSP_UC_Zelda.txt"); break; + case 0x42f64ac4: success = DSPSymbols::ReadAnnotatedAssembly("../../Docs/DSP/DSP_UC_Luigi.txt"); break; + default: success = false; break; + } + + if (!success) { DSPSymbols::AutoDisassembly(0x0, 0x1000); } // Always add the ROM. DSPSymbols::AutoDisassembly(0x8000, 0x9000); + + m_DebuggerFrame->Refresh(); return crc; } \ No newline at end of file diff --git a/Source/Plugins/Plugin_DSP_LLE/Src/Debugger/DSPRegisterView.cpp b/Source/Plugins/Plugin_DSP_LLE/Src/Debugger/DSPRegisterView.cpp index 6fef8b8937..3f455e287d 100644 --- a/Source/Plugins/Plugin_DSP_LLE/Src/Debugger/DSPRegisterView.cpp +++ b/Source/Plugins/Plugin_DSP_LLE/Src/Debugger/DSPRegisterView.cpp @@ -77,7 +77,7 @@ wxGridCellAttr *CRegTable::GetAttr(int row, int col, wxGridCellAttr::wxAttrKind) } DSPRegisterView::DSPRegisterView(wxWindow *parent, wxWindowID id) -: wxGrid(parent, id) + : wxGrid(parent, id, wxDefaultPosition, wxSize(130, 120)) { SetTable(new CRegTable(), true); SetRowLabelSize(0); diff --git a/Source/Plugins/Plugin_DSP_LLE/Src/Debugger/Debugger.cpp b/Source/Plugins/Plugin_DSP_LLE/Src/Debugger/Debugger.cpp index 8e4106ae15..8ea21b0680 100644 --- a/Source/Plugins/Plugin_DSP_LLE/Src/Debugger/Debugger.cpp +++ b/Source/Plugins/Plugin_DSP_LLE/Src/Debugger/Debugger.cpp @@ -41,7 +41,6 @@ DSPDebuggerLLE::DSPDebuggerLLE(wxWindow *parent, wxWindowID id, const wxString & , m_CachedStepCounter(-1) , m_CachedCR(-1) , m_State(RUN) - , m_CachedUCodeCRC(-1) { CreateGUIControls(); } @@ -64,31 +63,27 @@ void DSPDebuggerLLE::CreateGUIControls() m_Toolbar->AddTool(ID_JUMPTOTOOL, wxT("Jump"), wxNullBitmap, wxT("Jump to a specific Address"), wxITEM_NORMAL); m_Toolbar->AddSeparator(); - m_Toolbar->AddCheckTool(ID_CHECK_ASSERTINT, wxT("AssertInt"), wxNullBitmap, wxNullBitmap, wxEmptyString); - m_Toolbar->AddCheckTool(ID_CHECK_HALT, wxT("Halt"), wxNullBitmap, wxNullBitmap, wxEmptyString); - m_Toolbar->AddCheckTool(ID_CHECK_INIT, wxT("Init"), wxNullBitmap, wxNullBitmap, wxEmptyString); - m_Toolbar->AddSeparator(); - m_Toolbar->AddControl(new wxTextCtrl(m_Toolbar, ID_ADDRBOX, _T(""))); m_Toolbar->Realize(); wxBoxSizer* sMain = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* sizerLeft = new wxBoxSizer(wxVERTICAL); - sizerLeft->Add(m_SymbolList = new wxListBox(this, ID_SYMBOLLIST, wxDefaultPosition, wxSize(90, 100), 0, NULL, wxLB_SORT), 1, wxEXPAND); + sizerLeft->Add(m_SymbolList = new wxListBox(this, ID_SYMBOLLIST, wxDefaultPosition, wxSize(140, 100), 0, NULL, wxLB_SORT), + 1, wxEXPAND); m_CodeView = new CCodeView(&debug_interface, &DSPSymbols::g_dsp_symbol_db, this, ID_CODEVIEW); m_CodeView->SetPlain(); - sMain->Add(sizerLeft, 1, wxALL|wxEXPAND, 0); + sMain->Add(sizerLeft, 0, wxEXPAND, 0); - sMain->Add(m_CodeView, 4, wxALL|wxEXPAND, 5); + sMain->Add(m_CodeView, 4, wxEXPAND, 0); wxStaticLine* m_staticline = new wxStaticLine(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL); - sMain->Add(m_staticline, 0, wxEXPAND|wxALL, 5); + sMain->Add(m_staticline, 0, wxEXPAND|wxALL, 0); m_Regs = new DSPRegisterView(this, ID_DSP_REGS); - sMain->Add(m_Regs, 1, wxEXPAND|wxALL, 5); + sMain->Add(m_Regs, 0, wxEXPAND|wxALL, 5); this->SetSizer(sMain); this->Layout(); @@ -165,28 +160,15 @@ void DSPDebuggerLLE::UpdateSymbolMap() if (g_dsp.dram == NULL) return; - if (m_CachedUCodeCRC != g_dsp.iram_crc) + m_SymbolList->Freeze(); // HyperIris: wx style fast filling + m_SymbolList->Clear(); + for (SymbolDB::XFuncMap::iterator iter = DSPSymbols::g_dsp_symbol_db.GetIterator(); + iter != DSPSymbols::g_dsp_symbol_db.End(); iter++) { - // load symbol map (if there is one) - m_CachedUCodeCRC = g_dsp.iram_crc; - char FileName[256]; - sprintf(FileName, "%sDSP_%08x.map", FULL_MAPS_DIR, m_CachedUCodeCRC); - - // LoadSymbolMap(FileName); - - m_SymbolList->Freeze(); // HyperIris: wx style fast filling - m_SymbolList->Clear(); - for (SymbolDB::XFuncMap::iterator iter = DSPSymbols::g_dsp_symbol_db.GetIterator(); - iter != DSPSymbols::g_dsp_symbol_db.End(); iter++) - { - int idx = m_SymbolList->Append(wxString::FromAscii(iter->second.name.c_str())); - m_SymbolList->SetClientData(idx, (void*)&iter->second); - } - m_SymbolList->Thaw(); - - // rebuild the disasm - // RebuildDisAsmListView(); + int idx = m_SymbolList->Append(wxString::FromAscii(iter->second.name.c_str())); + m_SymbolList->SetClientData(idx, (void*)&iter->second); } + m_SymbolList->Thaw(); } void DSPDebuggerLLE::OnSymbolListChange(wxCommandEvent& event) @@ -209,9 +191,9 @@ void DSPDebuggerLLE::UpdateRegisterFlags() if (m_CachedCR == g_dsp.cr) return; - m_Toolbar->ToggleTool(ID_CHECK_ASSERTINT, g_dsp.cr & 0x02 ? true : false); - m_Toolbar->ToggleTool(ID_CHECK_HALT, g_dsp.cr & 0x04 ? true : false); - m_Toolbar->ToggleTool(ID_CHECK_INIT, g_dsp.cr & 0x800 ? true : false); + // m_Toolbar->ToggleTool(ID_CHECK_ASSERTINT, g_dsp.cr & 0x02 ? true : false); + // m_Toolbar->ToggleTool(ID_CHECK_HALT, g_dsp.cr & 0x04 ? true : false); + // m_Toolbar->ToggleTool(ID_CHECK_INIT, g_dsp.cr & 0x800 ? true : false); m_CachedCR = g_dsp.cr; } diff --git a/Source/Plugins/Plugin_DSP_LLE/Src/Debugger/Debugger.h b/Source/Plugins/Plugin_DSP_LLE/Src/Debugger/Debugger.h index e0581d1fb1..777d4ad4ce 100644 --- a/Source/Plugins/Plugin_DSP_LLE/Src/Debugger/Debugger.h +++ b/Source/Plugins/Plugin_DSP_LLE/Src/Debugger/Debugger.h @@ -36,7 +36,7 @@ #include "disassemble.h" #include "gdsp_interpreter.h" -#include "gdsp_memory.h" +#include "DSPMemoryMap.h" #include "../DSPDebugInterface.h" class DSPRegisterView; @@ -107,7 +107,6 @@ private: DSPDebugInterface debug_interface; u64 m_CachedStepCounter; u16 m_CachedCR; - u32 m_CachedUCodeCRC; // GUI updaters void UpdateDisAsmListView(); diff --git a/Source/Plugins/Plugin_DSP_LLE/Src/Globals.cpp b/Source/Plugins/Plugin_DSP_LLE/Src/Globals.cpp index 377386af15..555ef649c2 100644 --- a/Source/Plugins/Plugin_DSP_LLE/Src/Globals.cpp +++ b/Source/Plugins/Plugin_DSP_LLE/Src/Globals.cpp @@ -26,18 +26,18 @@ // ======================================================================================= // For PB address detection // -------------- + +// This will only work on GC, not Wii. u32 RAM_MASK = 0x1FFFFFF; u16 Memory_Read_U16(u32 _uAddress) { - _uAddress &= RAM_MASK; - return Common::swap16(*(u16*)&g_dsp.cpu_ram[_uAddress]); + return Common::swap16(*(u16*)&g_dsp.cpu_ram[_uAddress & RAM_MASK]); } u32 Memory_Read_U32(u32 _uAddress) { - _uAddress &= RAM_MASK; - return Common::swap32(*(u32*)&g_dsp.cpu_ram[_uAddress]); + return Common::swap32(*(u32*)&g_dsp.cpu_ram[_uAddress & RAM_MASK]); } #if PROFILE diff --git a/Source/Plugins/Plugin_DSP_LLE/Src/main.cpp b/Source/Plugins/Plugin_DSP_LLE/Src/main.cpp index 4b4dabf79d..4c74722ac0 100644 --- a/Source/Plugins/Plugin_DSP_LLE/Src/main.cpp +++ b/Source/Plugins/Plugin_DSP_LLE/Src/main.cpp @@ -193,13 +193,6 @@ void DSP_DebugBreak() #endif } - -void dspi_req_dsp_irq() -{ - // Fire an interrupt on the PPC ASAP. - g_dspInitialize.pGenerateDSPInterrupt(); -} - void Initialize(void *init) { bCanWork = true; @@ -211,8 +204,6 @@ void Initialize(void *init) std::string coef_filename = File::GetSysDirectory() + GC_SYS_DIR + DIR_SEP + DSP_COEF; bCanWork = DSPCore_Init(irom_filename.c_str(), coef_filename.c_str()); g_dsp.cpu_ram = g_dspInitialize.pGetMemoryPointer(0); - g_dsp.irq_request = dspi_req_dsp_irq; -// g_dsp.exception_in_progress_hack = false; DSPCore_Reset(); if (!bCanWork) diff --git a/docs/DSP/DSP_UC_Luigi.txt b/docs/DSP/DSP_UC_Luigi.txt new file mode 100644 index 0000000000..c98ea6dc81 --- /dev/null +++ b/docs/DSP/DSP_UC_Luigi.txt @@ -0,0 +1,2496 @@ +// This ucode is interesting because it is very similar to the Zelda ucode, +// but does not make use of exceptions. Hence, it might be possible to get +// it running okay even without understanding how the exceptions work. + +// CRC: 379F1139 +// ector-CRC: 42f64ac4 + +// Notable differences: +// Luigi init: +// sbset #0x02 +// sbset #0x03 +// sbclr #0x04 +// sbset #0x05 +// sbset #0x06 +// set16 +// clr15 +// m0 + +// Zelda init: +// sbclr #0x02 ! +// sbclr #0x03 ! +// sbclr #0x04 +// sbset #0x05 (late, just when it's time to receive messages) +// sbset #0x06 +// set16 +// clr15 +// m0 + + + +// exception vectors +0000 029f 0010 jmp 0x0010 +0002 0000 nop +0003 0000 nop +0004 02ff rti +0005 0000 nop +0006 02ff rti +0007 0000 nop +0008 02ff rti +0009 0000 nop +000a 02ff rti +000b 0000 nop +000c 02ff rti +000d 0000 nop +000e 02ff rti // This is Zelda's message exception. +000f 0000 nop + +// Reset vector +void 0010_ResetVector() { + // Compare to 0057 in the Zelda ucode + 0010 1302 sbset #0x02 + 0011 1303 sbset #0x03 + 0012 1204 sbclr #0x04 + 0013 1305 sbset #0x05 + 0014 1306 sbset #0x06 + 0015 8e00 set16 + 0016 8c00 clr15 + 0017 8b00 m0 + 0018 009e ffff lri $AC0.M, #0xffff + 001a 1d1e mrr $WR0, $AC0.M + 001b 1d3e mrr $WR1, $AC0.M + 001c 1d5e mrr $WR2, $AC0.M + 001d 1d7e mrr $WR3, $AC0.M + 001e 0092 00ff lri $CR, #0x00ff + 0020 8100 clr $ACC0 + // Clear memory + 0021 009f 1000 lri $AC1.M, #0x1000 + 0023 0080 0000 lri $AR0, #0x0000 + 0025 005f loop $AC1.M + 0026 1b1e srri @$AR0, $AC0.M + 0027 26ff lrs $AC0.M, @CMBL + 0028 16fc 8888 si @DMBH, #0x8888 + 002a 16fd 1111 si @DMBL, #0x1111 + 002c 26fc lrs $AC0.M, @DMBH + 002d 02a0 8000 andf $AC0.M, #0x8000 + 002f 029c 002c jlnz 0x002c + + while (true) { + 0031 8100 clr $ACC0 + 0032 8900 clr $ACC1 + 0033 26fe lrs $AC0.M, @CMBH + 0034 02c0 8000 andcf $AC0.M, #0x8000 + 0036 029c 0031 jlnz 0x0031 + 0038 27ff lrs $AC1.M, @CMBL + 0039 00ff 0345 sr @0x0345, $AC1.M + 003b 1ffe mrr $AC1.M, $AC0.M + 003c 0340 00ff andi $AC1.M, #0x00ff + 003e 00ff 0344 sr @0x0344, $AC1.M + 0040 1479 lsr $ACC0, #-7 + + // Jump table below + 0041 0240 007e andi $AC0.M, #0x007e + 0043 0200 0062 addi $AC0.M, #0x0062 + 0045 00fe 0343 sr @0x0343, $AC0.M + 0047 1c1e mrr $AR0, $AC0.M + 0048 170f jmpr $AR0 + 0049 009e 8000 lri $AC0.M, #0x8000 + 004b 00dc 0343 lr $AC0.L, @0x0343 + 004d 02bf 005a call 0x005a + 004f 029f 0031 jmp 0x0031 + } +} + +void 0051_Unk_Mail() { + 0051 26fe lrs $AC0.M, @CMBH + 0052 02c0 8000 andcf $AC0.M, #0x8000 + 0054 029c 0051 jlnz 0x0051 + 0056 24ff lrs $AC0.L, @CMBL + 0057 1b1e srri @$AR0, $AC0.M + 0058 1b1c srri @$AR0, $AC0.L + 0059 02df ret +} + +void 005a_Unk_Mail() { + 005a 2efc srs @DMBH, $AC0.M + 005b 2cfd srs @DMBL, $AC0.L + 005c 26fc lrs $AC0.M, @DMBH + 005d 02a0 8000 andf $AC0.M, #0x8000 + 005f 029c 005c jlnz 0x005c + 0061 02df ret +} + +// Just a jump table. +0062 029f 0049 jmp 0x0049 +0064 029f 0349 jmp 0x0349 // Command 01 +0066 029f 04eb jmp 0x04eb // Command 02 +0068 029f 0031 jmp 0x0031 +006a 029f 00df jmp 0x00df +006c 029f 00f1 jmp 0x00f1 +006e 029f 06e7 jmp 0x06e7 +0070 029f 069b jmp 0x069b +0072 029f 0703 jmp 0x0703 +0074 029f 06cb jmp 0x06cb +0076 029f 0870 jmp 0x0870 +0078 029f 0744 jmp 0x0744 +007a 029f 0238 jmp 0x0238 + + +void 007c_Unk() { + 007c 193e lrri $AC0.M, @$AR1 + 007d 193c lrri $AC0.L, @$AR1 + 007e 2fcd srs @DSPA, $AC1.M + 007f 0f00 lris $AC1.M, #0x00 + 0080 2fc9 srs @DSCR, $AC1.M + 0081 2ece srs @DSMAH, $AC0.M + 0082 2ccf srs @DSMAL, $AC0.L + 0083 1fe0 mrr $AC1.M, $AR0 + 0084 1501 lsl $ACC1, #1 + 0085 2fcb srs @DSBL, $AC1.M + 0086 02bf 008f call 0x008f + 0088 02df ret +} + + +void 0089_Unk() { + 0089 193e lrri $AC0.M, @$AR1 + 008a 193c lrri $AC0.L, @$AR1 + 008b 2fcd srs @DSPA, $AC1.M + 008c 0f01 lris $AC1.M, #0x01 + 008d 029f 0080 jmp 0x0080 + 008f 26c9 lrs $AC0.M, @DSCR + 0090 02a0 0004 andf $AC0.M, #0x0004 + 0092 029c 008f jlnz 0x008f + 0094 02df ret +} + +void 0095_Unk() { + 0095 193e lrri $AC0.M, @$AR1 + 0096 193c lrri $AC0.L, @$AR1 + 0097 00ff ffcd sr @DSPA, $AC1.M + 0099 0f00 lris $AC1.M, #0x00 + 009a 00ff ffc9 sr @DSCR, $AC1.M + 009c 00fe ffce sr @DSMAH, $AC0.M + 009e 00fc ffcf sr @DSMAL, $AC0.L + 00a0 1fe0 mrr $AC1.M, $AR0 + 00a1 1501 lsl $ACC1, #1 + 00a2 00ff ffcb sr @DSBL, $AC1.M + 00a4 02df ret +} + +void 00a5_Unk() { + 00a5 00de ffc9 lr $AC0.M, @DSCR + 00a7 02a0 0004 andf $AC0.M, #0x0004 + 00a9 029c 00a5 jlnz 0x00a5 + 00ab 02df ret +} + +void 00ac_ReadBlockFromAccelerator() { + 00ac 193e lrri $AC0.M, @$AR1 + 00ad 193c lrri $AC0.L, @$AR1 + 00ae 0240 7fff andi $AC0.M, #0x7fff + // 00b0 02bf 00ba call 0x00ba + 00ba_SetupAccelerator() + + 00b2 007a 00b8 bloop $AX0.H, 0x00b8 + 00b4 26d3 lrs $AC0.M, @UnkZelda + 00b5 1b3e srri @$AR1, $AC0.M + 00b6 0000 nop + 00b7 0000 nop + 00b8 0000 nop + 00b9 02df ret +} + +void 00ba_SetupAccelerator() { + 00ba 1c3f mrr $AR1, $AC1.M + 00bb 009f 0005 lri $AC1.M, #0x0005 + 00bd 2fd1 srs @SampleFormat, $AC1.M + 00be 1f5e mrr $AX0.H, $AC0.M + 00bf 1f1c mrr $AX0.L, $AC0.L + 00c0 2ed4 srs @ACSAH, $AC0.M + 00c1 2cd5 srs @ACSAL, $AC0.L + 00c2 8900 clr $ACC1 + 00c3 1fa0 mrr $AC1.L, $AR0 + 00c4 4c00 add $ACC0, $AC1.L + 00c5 0200 0030 addi $AC0.M, #0x0030 + 00c7 2ed6 srs @ACEAH, $AC0.M + 00c8 2cd7 srs @ACEAL, $AC0.L + 00c9 1fda mrr $AC0.M, $AX0.H + 00ca 1f98 mrr $AC0.L, $AX0.L + 00cb 147f lsr $ACC0, #-1 + 00cc 2ed8 srs @ACCAH, $AC0.M + 00cd 2cd9 srs @ACCAL, $AC0.L + 00ce 1f40 mrr $AX0.H, $AR0 + 00cf 02df ret +} + + +void 00d0_Unk() { + 00d0 193e lrri $AC0.M, @$AR1 + 00d1 193c lrri $AC0.L, @$AR1 + 00d2 0260 8000 ori $AC0.M, #0x8000 + // 00d4 02bf 00ba call 0x00ba + 00ba_SetupAccelerator() + 00d6 007a 00dd bloop $AX0.H, 0x00dd + 00d8 193e lrri $AC0.M, @$AR1 + 00d9 2ed3 srs @UnkZelda, $AC0.M + 00da 0000 nop + 00db 0000 nop + 00dc 0000 nop + 00dd 0000 nop + 00de 02df ret +} + +void 00df_Unk() { + 00df 0080 0346 lri $AR0, #0x0346 + 00e1 02bf 0051 call 0x0051 + 00e3 02bf 0051 call 0x0051 + 00e5 0081 0346 lri $AR1, #0x0346 + 00e7 00df 0349 lr $AC1.M, @0x0349 + 00e9 0340 ffff andi $AC1.M, #0xffff + 00eb 00c0 0345 lr $AR0, @0x0345 + 00ed 02bf 007c call 0x007c + 00ef 029f 0049 jmp 0x0049 + 00f1 0080 0346 lri $AR0, #0x0346 + 00f3 02bf 0051 call 0x0051 + 00f5 02bf 0051 call 0x0051 + 00f7 0081 0346 lri $AR1, #0x0346 + 00f9 00df 0349 lr $AC1.M, @0x0349 + 00fb 0340 ffff andi $AC1.M, #0xffff + 00fd 00c0 0345 lr $AR0, @0x0345 + 00ff 02bf 0089 call 0x0089 + 0101 029f 0049 jmp 0x0049 +} + +void 0103_SetupAcceleratorMystery() { + 0103 0092 00ff lri $CR, #0x00ff + 0105 2fd1 srs @SampleFormat, $AC1.M + 0106 0340 0003 andi $AC1.M, #0x0003 + 0108 1f7f mrr $AX1.H, $AC1.M + 0109 1f5e mrr $AX0.H, $AC0.M + 010a 1f1c mrr $AX0.L, $AC0.L + 010b 0200 0010 addi $AC0.M, #0x0010 + 010d 2ed4 srs @ACSAH, $AC0.M + 010e 2cd5 srs @ACSAL, $AC0.L + 010f 8900 clr $ACC1 + 0110 1fa0 mrr $AC1.L, $AR0 + 0111 4c00 add $ACC0, $AC1.L + 0112 0200 0030 addi $AC0.M, #0x0030 + 0114 2ed6 srs @ACEAH, $AC0.M + 0115 2cd7 srs @ACEAL, $AC0.L + 0116 1fda mrr $AC0.M, $AX0.H + 0117 1f98 mrr $AC0.L, $AX0.L + 0118 1ffb mrr $AC1.M, $AX1.H + 0119 7900 decm $AC1.M + 011a 02ca lsrn + 011b 2ed8 srs @ACCAH, $AC0.M + 011c 2cd9 srs @ACCAL, $AC0.L + 011d 02df ret +} + +void 011e_Unk() { + 011e 1c23 mrr $AR1, $AR3 + 011f 197e lrri $AC0.M, @$AR3 + 0120 191b lrri $AX1.H, @$AR0 + 0121 d858 mulc'l $AC1.M, $AX1.H : $AX1.H, @$AR0 + 0122 1120 0128 bloopi #0x20, 0x0128 + 0124 dcd3 mulcac'ld $AC1.M, $AX1.H, $ACC0 : $AX0.L, $AX1.H, @$AR3 + 0125 6231 movr's $ACC0, $AX1.L : @$AR1, $AC0.M + 0126 dcd3 mulcac'ld $AC1.M, $AX1.H, $ACC0 : $AX0.L, $AX1.H, @$AR3 + 0127 6231 movr's $ACC0, $AX1.L : @$AR1, $AC0.M + 0128 4900 addax $ACC1, $AX0.L + 0129 1108 012e bloopi #0x08, 0x012e + 012b dcd3 mulcac'ld $AC1.M, $AX1.H, $ACC0 : $AX0.L, $AX1.H, @$AR3 + 012c 6231 movr's $ACC0, $AX1.L : @$AR1, $AC0.M + 012d dcd3 mulcac'ld $AC1.M, $AX1.H, $ACC0 : $AX0.L, $AX1.H, @$AR3 + 012e 6231 movr's $ACC0, $AX1.L : @$AR1, $AC0.M + 012f 02df ret +} + + +void 0130_Unk() { + 0130 8f00 set40 + 0131 1c03 mrr $AR0, $AR3 + 0132 00db 038e lr $AX1.H, @0x038e + 0134 009a 0004 lri $AX0.H, #0x0004 + 0136 1978 lrri $AX0.L, @$AR3 + 0137 a843 mulx'l $AX0.L, $AX1.H : $AX0.L, @$AR3 + 0138 ae00 mulxmv $AX0.L, $AX1.H, $ACC0 + 0139 1128 013e bloopi #0x28, 0x013e + 013b 38c3 orr'ld $AC0.M, $AX0.H : $AX0.L, $AX1.L, @$AR3 + 013c ae30 mulxmv's $AX0.L, $AX1.H, $ACC0 : @$AR0, $AC0.M + 013d 38c3 orr'ld $AC0.M, $AX0.H : $AX0.L, $AX1.L, @$AR3 + 013e ae30 mulxmv's $AX0.L, $AX1.H, $ACC0 : @$AR0, $AC0.M + 013f 8e00 set16 + 0140 02df ret +} + +void 0141_Unk() { + 0141 00f9 0361 sr @0x0361, $AX1.L + 0143 1fc0 mrr $AC0.M, $AR0 + 0144 0200 fffc addi $AC0.M, #0xfffc + 0146 1c1e mrr $AR0, $AC0.M + 0147 1c5e mrr $AR2, $AC0.M + 0148 0083 043c lri $AR3, #0x043c + 014a 197e lrri $AC0.M, @$AR3 + 014b 197f lrri $AC1.M, @$AR3 + 014c 80a2 nx'sl : $AC0.M, $AX0.H + 014d 64a3 movr'sl $ACC0, $AX0.H : $AC1.M, $AX0.H + 014e 6530 movr's $ACC1, $AX0.H : @$AR0, $AC0.M + 014f 1b1f srri @$AR0, $AC1.M + 0150 1c02 mrr $AR0, $AR2 + 0151 8100 clr $ACC0 + 0152 00de 0402 lr $AC0.M, @0x0402 + 0154 00fe 0362 sr @0x0362, $AC0.M + 0156 1474 lsr $ACC0, #-12 + 0157 1f7e mrr $AX1.H, $AC0.M + 0158 1f3c mrr $AX1.L, $AC0.L + 0159 8900 clr $ACC1 + 015a 00dd 0430 lr $AC1.L, @0x0430 + 015c 1504 lsl $ACC1, #4 + 015d 0604 cmpis $ACC0, #0x04 + 015e 0290 01b6 jns 0x01b6 + 0160 1fdd mrr $AC0.M, $AC1.L + 0161 0082 0c00 lri $AR2, #0x0c00 + 0163 1050 loopi #0x50 + 0164 4b2a addax's $ACC1, $AX1.L : @$AR2, $AC1.L + 0165 1fbe mrr $AC1.L, $AC0.M + 0166 00fe 0360 sr @0x0360, $AC0.M + 0168 8900 clr $ACC1 + 0169 1fbe mrr $AC1.L, $AC0.M + 016a 009a fff8 lri $AX0.H, #0xfff8 + 016c 009b 00fc lri $AX1.H, #0x00fc + 016e 00d8 0361 lr $AX0.L, @0x0361 + 0170 0082 0c00 lri $AR2, #0x0c00 + 0172 0083 0c00 lri $AR3, #0x0c00 + 0174 195e lrri $AC0.M, @$AR2 + 0175 3480 andr'ls $AC0.M, $AX0.H : $AX0.L, $AC0.M + 0176 1128 017b bloopi #0x28, 0x017b + 0178 367a andr'l $AC0.M, $AX1.H : $AC1.M, @$AR2 + 0179 35b3 andr'sl $AC1.M, $AX0.H : $AC1.M, $AX1.H + 017a 3772 andr'l $AC1.M, $AX1.H : $AC0.M, @$AR2 + 017b 34bb andr'slm $AC0.M, $AX0.H : $AC1.M, $AX1.H + 017c 8a00 m2 + 017d 0082 0c00 lri $AR2, #0x0c00 + 017f 00dd 0430 lr $AC1.L, @0x0430 + 0181 1504 lsl $ACC1, #4 + 0182 1fe0 mrr $AC1.M, $AR0 + 0183 8100 clr $ACC0 + 0184 00de 0362 lr $AC0.M, @0x0362 + 0186 1474 lsr $ACC0, #-12 + 0187 1f7e mrr $AX1.H, $AC0.M + 0188 1f3c mrr $AX1.L, $AC0.L + 0189 8f00 set40 + 018a 1943 lrri $AR3, @$AR2 + 018b 4bc3 addax'ld $ACC1, $AX1.L : $AX0.L, $AX1.L, @$AR3 + 018c 90c3 mul'ld $AX0.L, $AX0.H : $AX0.L, $AX1.L, @$AR3 + 018d f2c3 madd'ld $AX0.L, $AX0.H : $AX0.L, $AX1.L, @$AR3 + 018e f2c3 madd'ld $AX0.L, $AX0.H : $AX0.L, $AX1.L, @$AR3 + 018f f200 madd $AX0.L, $AX0.H + 0190 fe00 movpz $ACC0 + 0191 1c1f mrr $AR0, $AC1.M + + 0192 1943 lrri $AR3, @$AR2 + 0193 4bc3 addax'ld $ACC1, $AX1.L : $AX0.L, $AX1.L, @$AR3 + 0194 90c3 mul'ld $AX0.L, $AX0.H : $AX0.L, $AX1.L, @$AR3 + 0195 114e 019d bloopi #0x4e, 0x019d + 0197 f2c3 madd'ld $AX0.L, $AX0.H : $AX0.L, $AX1.L, @$AR3 + 0198 f2c3 madd'ld $AX0.L, $AX0.H : $AX0.L, $AX1.L, @$AR3 + 0199 f231 madd's $AX0.L, $AX0.H : @$AR1, $AC0.M + + 019a 1c1f mrr $AR0, $AC1.M + 019b 1943 lrri $AR3, @$AR2 + 019c 4bc3 addax'ld $ACC1, $AX1.L : $AX0.L, $AX1.L, @$AR3 + 019d 92c3 mulmvz'ld $AX0.L, $AX0.H, $ACC0 : $AX0.L, $AX1.L, @$AR3 + 019e f2c3 madd'ld $AX0.L, $AX0.H : $AX0.L, $AX1.L, @$AR3 + 019f f2c3 madd'ld $AX0.L, $AX0.H : $AX0.L, $AX1.L, @$AR3 + 01a0 f231 madd's $AX0.L, $AX0.H : @$AR1, $AC0.M + 01a1 fe00 movpz $ACC0 + 01a2 1b3e srri @$AR1, $AC0.M + + 01a3 8b00 m0 + 01a4 8e00 set16 + 01a5 00fe 0433 sr @0x0433, $AC0.M + 01a7 1c1f mrr $AR0, $AC1.M + 01a8 150c lsl $ACC1, #12 + 01a9 0340 0fff andi $AC1.M, #0x0fff + 01ab 00ff 0430 sr @0x0430, $AC1.M + 01ad 0083 043c lri $AR3, #0x043c + 01af 191e lrri $AC0.M, @$AR0 + 01b0 191f lrri $AC1.M, @$AR0 + 01b1 80a0 nx'ls : $AX0.H, $AC0.M + 01b2 64a1 movr'ls $ACC0, $AX0.H : $AX0.H, $AC1.M + 01b3 6533 movr's $ACC1, $AX0.H : @$AR3, $AC0.M + 01b4 1b7f srri @$AR3, $AC1.M + 01b5 02df ret + +subroutine: + 01b6 1fe0 mrr $AC1.M, $AR0 + 01b7 1c1f mrr $AR0, $AC1.M + 01b8 1128 01bf bloopi #0x28, 0x01bf + 01ba 4b70 addax'l $ACC1, $AX1.L : $AC0.M, @$AR0 + 01bb 1b3e srri @$AR1, $AC0.M + 01bc 1c1f mrr $AR0, $AC1.M + 01bd 4b70 addax'l $ACC1, $AX1.L : $AC0.M, @$AR0 + 01be 1b3e srri @$AR1, $AC0.M + 01bf 1c1f mrr $AR0, $AC1.M + 01c0 029f 01a5 jmp 0x01a5 +} + +void 01c2_Unk() { + 01c2 8a00 m2 + 01c3 0083 03e8 lri $AR3, #0x03e8 + 01c5 191e lrri $AC0.M, @$AR0 + 01c6 191a lrri $AX0.H, @$AR0 + 01c7 1006 loopi #0x06 + 01c8 64a0 movr'ls $ACC0, $AX0.H : $AX0.H, $AC0.M + 01c9 1b7e srri @$AR3, $AC0.M + 01ca 1b7a srri @$AR3, $AX0.H + 01cb 0080 03e8 lri $AR0, #0x03e8 + 01cd 0088 0007 lri $WR0, #0x0007 + 01cf 1150 01dc bloopi #0x50, 0x01dc + 01d1 1c61 mrr $AR3, $AR1 + 01d2 84c3 clrp'ld : $AX0.L, $AX1.L, @$AR3 + 01d3 f2c3 madd'ld $AX0.L, $AX0.H : $AX0.L, $AX1.L, @$AR3 + 01d4 f2c3 madd'ld $AX0.L, $AX0.H : $AX0.L, $AX1.L, @$AR3 + 01d5 f2c3 madd'ld $AX0.L, $AX0.H : $AX0.L, $AX1.L, @$AR3 + 01d6 f2c3 madd'ld $AX0.L, $AX0.H : $AX0.L, $AX1.L, @$AR3 + 01d7 f2c3 madd'ld $AX0.L, $AX0.H : $AX0.L, $AX1.L, @$AR3 + 01d8 f2c3 madd'ld $AX0.L, $AX0.H : $AX0.L, $AX1.L, @$AR3 + 01d9 f2c3 madd'ld $AX0.L, $AX0.H : $AX0.L, $AX1.L, @$AR3 + 01da f200 madd $AX0.L, $AX0.H + 01db fe00 movpz $ACC0 + 01dc 1b3e srri @$AR1, $AC0.M + 01dd 0088 ffff lri $WR0, #0xffff + 01df 8b00 m0 + 01e0 02df ret +} + +void 01e1_Unk() { // ZWW: 0b4d_IIR_Filter + 01e1 8a00 m2 + 01e2 05fe addis $ACC1, #0xfe + 01e3 0083 03e8 lri $AR3, #0x03e8 + 01e5 191e lrri $AC0.M, @$AR0 + 01e6 191a lrri $AX0.H, @$AR0 + 01e7 005f loop $AC1.M + 01e8 64a0 movr'ls $ACC0, $AX0.H : $AX0.H, $AC0.M + 01e9 1b7e srri @$AR3, $AC0.M + 01ea 1b7a srri @$AR3, $AX0.H + 01eb 0080 03e8 lri $AR0, #0x03e8 + 01ed 0501 addis $ACC1, #0x01 + 01ee 1d1f mrr $WR0, $AC1.M + 01ef 1150 01f7 bloopi #0x50, 0x01f7 + 01f1 1c61 mrr $AR3, $AR1 + 01f2 84c3 clrp'ld : $AX0.L, $AX1.L, @$AR3 + 01f3 005f loop $AC1.M + 01f4 f2c3 madd'ld $AX0.L, $AX0.H : $AX0.L, $AX1.L, @$AR3 + 01f5 f200 madd $AX0.L, $AX0.H + 01f6 fe00 movpz $ACC0 + 01f7 1b3e srri @$AR1, $AC0.M + 01f8 0088 ffff lri $WR0, #0xffff + 01fa 8b00 m0 + 01fb 02df ret +} + +void 01fc_Unk() { // ZWW: 0b68_4TapFIR + 01fc 0083 03e8 lri $AR3, #0x03e8 + 01fe 191e lrri $AC0.M, @$AR0 + 01ff 191a lrri $AX0.H, @$AR0 + 0200 64a0 movr'ls $ACC0, $AX0.H : $AX0.H, $AC0.M + 0201 64a0 movr'ls $ACC0, $AX0.H : $AX0.H, $AC0.M + 0202 1b7e srri @$AR3, $AC0.M + 0203 1b7a srri @$AR3, $AX0.H + 0204 0080 03e8 lri $AR0, #0x03e8 + 0206 0088 0003 lri $WR0, #0x0003 + 0208 0085 0000 lri $IX1, #0x0000 + 020a 0087 0000 lri $IX3, #0x0000 + 020c 1fc2 mrr $AC0.M, $AR2 + 020d 195b lrri $AX1.H, @$AR2 + 020e 1959 lrri $AX1.L, @$AR2 + 020f 195f lrri $AC1.M, @$AR2 + 0210 195a lrri $AX0.H, @$AR2 + 0211 1c5e mrr $AR2, $AC0.M + 0212 1fda mrr $AC0.M, $AX0.H + 0213 1c61 mrr $AR3, $AR1 + 0214 8a00 m2 + 0215 8f00 set40 + 0216 191a lrri $AX0.H, @$AR0 + 0217 b850 mulx'l $AX0.H, $AX1.H : $AX0.H, @$AR0 + 0218 e250 maddx'l $AX0.H, $AX1.L : $AX0.H, @$AR0 + 0219 ea50 maddc'l $AC1.M, $AX1.L : $AX0.H, @$AR0 + 021a e8e8 maddc'ldm $AC0.M, $AX1.L : $AX0.H, $AX1.L, @$AR0 + 021b b650 mulxmv'l $AX0.H, $AX1.L, $ACC0 : $AX0.H, @$AR0 + 021c 1127 0227 bloopi #0x27, 0x0227 + 021e e3a8 maddx'lsm $AX0.H, $AX1.H : $AX0.H, $AC0.M + + 021f 197e lrri $AC0.M, @$AR3 + 0220 e850 maddc'l $AC0.M, $AX1.L : $AX0.H, @$AR0 + 0221 eaf8 maddc'ldm $AC1.M, $AX1.L : $AX0.H, $AX1.H, @$AR0 + 0222 bf50 mulxmv'l $AX0.H, $AX1.H, $ACC1 : $AX0.H, @$AR0 + 0223 e2a9 maddx'lsm $AX0.H, $AX1.L : $AX0.H, $AC1.M + + 0224 197f lrri $AC1.M, @$AR3 + 0225 ea50 maddc'l $AC1.M, $AX1.L : $AX0.H, @$AR0 + 0226 e8e8 maddc'ldm $AC0.M, $AX1.L : $AX0.H, $AX1.L, @$AR0 + 0227 b650 mulxmv'l $AX0.H, $AX1.L, $ACC0 : $AX0.H, @$AR0 + 0228 e3a8 maddx'lsm $AX0.H, $AX1.H : $AX0.H, $AC0.M + 0229 197e lrri $AC0.M, @$AR3 + 022a e850 maddc'l $AC0.M, $AX1.L : $AX0.H, @$AR0 + 022b eaf8 maddc'ldm $AC1.M, $AX1.L : $AX0.H, $AX1.H, @$AR0 + 022c bf00 mulxmv $AX0.H, $AX1.H, $ACC1 + 022d 1bff srrn @$AR3, $AC1.M + 022e 197f lrri $AC1.M, @$AR3 + 022f 8e00 set16 + 0230 8b00 m0 + 0231 0088 ffff lri $WR0, #0xffff + 0233 1b5b srri @$AR2, $AX1.H + 0234 1b59 srri @$AR2, $AX1.L + 0235 1b5f srri @$AR2, $AC1.M + 0236 1b5e srri @$AR2, $AC0.M + 0237 02df ret +} + +void 0238_Unk() { + 0238 0080 0346 lri $AR0, #0x0346 + 023a 02bf 0051 call 0x0051 + 023c 02bf 0051 call 0x0051 + 023e 0081 0346 lri $AR1, #0x0346 + 0240 009f 0580 lri $AC1.M, #0x0580 + 0242 0080 0080 lri $AR0, #0x0080 + 0244 02bf 007c call 0x007c + 0246 0081 0348 lri $AR1, #0x0348 + 0248 009f 0c00 lri $AC1.M, #0x0c00 + 024a 0080 0080 lri $AR0, #0x0080 + 024c 02bf 007c call 0x007c + 024e 0080 0c00 lri $AR0, #0x0c00 + 0250 0081 0580 lri $AR1, #0x0580 + 0252 02bf 01fc call 0x01fc + 0254 0081 0346 lri $AR1, #0x0346 + 0256 009f 0580 lri $AC1.M, #0x0580 + 0258 0080 0080 lri $AR0, #0x0080 + 025a 02bf 0089 call 0x0089 + 025c 0081 0348 lri $AR1, #0x0348 + 025e 009f 0c00 lri $AC1.M, #0x0c00 + 0260 0080 0080 lri $AR0, #0x0080 + 0262 02bf 0089 call 0x0089 + 0264 029f 0049 jmp 0x0049 + 0266 8100 clr $ACC0 + 0267 1f5e mrr $AX0.H, $AC0.M + 0268 00d8 0402 lr $AX0.L, @0x0402 + 026a 00dc 0430 lr $AC0.L, @0x0430 + 026c 0080 0520 lri $AR0, #0x0520 + 026e 00df 0480 lr $AC1.M, @0x0480 + 0270 1501 lsl $ACC1, #1 + 0271 0340 007e andi $AC1.M, #0x007e + 0273 0300 027b addi $AC1.M, #0x027b + 0275 1c5f mrr $AR2, $AC1.M + 0276 175f callr $AR2 + 0277 00fc 0430 sr @0x0430, $AC0.L + 0279 029f 056d jmp 0x056d + 027b 029f 029c jmp 0x029c + 027d 029f 02d7 jmp 0x02d7 + 027f 029f 02bf jmp 0x02bf + 0281 029f 02ac jmp 0x02ac + 0283 029f 02e5 jmp 0x02e5 + 0285 029f 029b jmp 0x029b + 0287 029f 0303 jmp 0x0303 + 0289 029f 0306 jmp 0x0306 + 028b 029f 029b jmp 0x029b + 028d 029f 029b jmp 0x029b + 028f 029f 0324 jmp 0x0324 + 0291 029f 02dd jmp 0x02dd + 0293 029f 02e1 jmp 0x02e1 + 0295 029f 029b jmp 0x029b + 0297 029f 029b jmp 0x029b + 0299 029f 029b jmp 0x029b + 029b 02df ret +} + +void 029c_Unk() { + 029c 1401 lsl $ACC0, #1 + 029d 009b c000 lri $AX1.H, #0xc000 + 029f 0099 4000 lri $AX1.L, #0x4000 + 02a1 1150 02a9 bloopi #0x50, 0x02a9 + 02a3 02c0 0001 andcf $AC0.M, #0x0001 + 02a5 027c iflnz + 02a6 1b1b srri @$AR0, $AX1.H + 02a7 027d iflz + 02a8 1b19 srri @$AR0, $AX1.L + 02a9 4800 addax $ACC0, $AX0.L + 02aa 147f lsr $ACC0, #-1 + 02ab 02df ret +} + +void 02ac_Unk() { + 02ac 1402 lsl $ACC0, #2 + 02ad 8900 clr $ACC1 + 02ae 1fb8 mrr $AC1.L, $AX0.L + 02af 1501 lsl $ACC1, #1 + 02b0 009b c000 lri $AX1.H, #0xc000 + 02b2 0099 4000 lri $AX1.L, #0x4000 + 02b4 1150 02bc bloopi #0x50, 0x02bc + 02b6 02c0 0003 andcf $AC0.M, #0x0003 + 02b8 027c iflnz + 02b9 1b1b srri @$AR0, $AX1.H + 02ba 027d iflz + 02bb 1b19 srri @$AR0, $AX1.L + 02bc 4c00 add $ACC0, $AC1.L + 02bd 147e lsr $ACC0, #-2 + 02be 02df ret +} + +void 02bf_Unk() { // ZWW:08d5 + 02bf 1401 lsl $ACC0, #1 + 02c0 0081 0ca0 lri $AR1, #0x0ca0 + 02c2 009b c000 lri $AX1.H, #0xc000 + 02c4 0099 4000 lri $AX1.L, #0x4000 + 02c6 8900 clr $ACC1 + 02c7 0082 0000 lri $AR2, #0x0000 + 02c9 1150 02d4 bloopi #0x50, 0x02d4 + 02cb 02c0 0001 andcf $AC0.M, #0x0001 + 02cd 027c iflnz + 02ce 1b1b srri @$AR0, $AX1.H + 02cf 027d iflz + 02d0 1b19 srri @$AR0, $AX1.L + 02d1 183d lrr $AC1.L, @$AR1 + 02d2 4900 addax $ACC1, $AX0.L + 02d3 1fe2 mrr $AC1.M, $AR2 + 02d4 4c39 add's $ACC0, $AC1.L : @$AR1, $AC1.M + 02d5 147f lsr $ACC0, #-1 + 02d6 02df ret +} + +void 02d7_Unk() { // ZWW:08ed + 02d7 8900 clr $ACC1 + 02d8 1fb8 mrr $AC1.L, $AX0.L + 02d9 157f lsr $ACC1, #-1 + 02da 1050 loopi #0x50 + 02db 4c20 add's $ACC0, $AC1.L : @$AR0, $AC0.L + 02dc 02df ret +} + +void 02dd_Unk() { // ZWW:08f3 + 02dd 0082 0180 lri $AR2, #0x0180 // Three entrances + 02df 029f 02e7 jmp 0x02e7 + 02e1 0082 01c0 lri $AR2, #0x01c0 + 02e3 029f 02e7 jmp 0x02e7 + 02e5 0082 0140 lri $AR2, #0x0140 + 02e7 008a 003f lri $WR2, #0x003f + 02e9 0086 0000 lri $IX2, #0x0000 + 02eb 1406 lsl $ACC0, #6 + 02ec 8900 clr $ACC1 + 02ed 1fb8 mrr $AC1.L, $AX0.L + 02ee 1505 lsl $ACC1, #5 + 02ef 009b 003f lri $AX1.H, #0x003f + 02f1 009a 0000 lri $AX0.H, #0x0000 + 02f3 3600 andr $AC0.M, $AX1.H + 02f4 1cde mrr $IX2, $AC0.M + 02f5 001a addarn $AR2, $IX2 + 02f6 3400 andr $AC0.M, $AX0.H + 02f7 1150 02fd bloopi #0x50, 0x02fd + 02f9 4c4a add'l $ACC0, $AC1.L : $AX1.L, @$AR2 + 02fa 3606 andr'dr $AC0.M, $AX1.H : $AR2 + 02fb 1cde mrr $IX2, $AC0.M + 02fc 340e andr'nr $AC0.M, $AX0.H : $AR2 + 02fd 1b19 srri @$AR0, $AX1.L + 02fe 1fc2 mrr $AC0.M, $AR2 + 02ff 147a lsr $ACC0, #-6 + 0300 008a ffff lri $WR2, #0xffff + 0302 02df ret +} + +void 030_MemsetBlock() { + 0303 1050 loopi #0x50 + 0304 1b18 srri @$AR0, $AX0.L + // 0305 02df ret +} + +void 0306_Unk() { + 0306 0082 0100 lri $AR2, #0x0100 + 0308 008a 003f lri $WR2, #0x003f + 030a 0086 0000 lri $IX2, #0x0000 + 030c 1406 lsl $ACC0, #6 + 030d 8900 clr $ACC1 + 030e 1fb8 mrr $AC1.L, $AX0.L + 030f 1505 lsl $ACC1, #5 + 0310 009b 003f lri $AX1.H, #0x003f + 0312 009a 0000 lri $AX0.H, #0x0000 + 0314 3600 andr $AC0.M, $AX1.H + 0315 1cde mrr $IX2, $AC0.M + 0316 001a addarn $AR2, $IX2 + 0317 3400 andr $AC0.M, $AX0.H + 0318 1150 031e bloopi #0x50, 0x031e + 031a 4c4a add'l $ACC0, $AC1.L : $AX1.L, @$AR2 + 031b 3606 andr'dr $AC0.M, $AX1.H : $AR2 + 031c 1cde mrr $IX2, $AC0.M + 031d 340e andr'nr $AC0.M, $AX0.H : $AR2 + 031e 1b19 srri @$AR0, $AX1.L + 031f 1fc2 mrr $AC0.M, $AR2 + 0320 147a lsr $ACC0, #-6 + 0321 008a ffff lri $WR2, #0xffff + 0323 02df ret +} + +void 0324_Unk() { + 0324 0082 0100 lri $AR2, #0x0100 + 0326 008a 003f lri $WR2, #0x003f + 0328 0086 0000 lri $IX2, #0x0000 + 032a 0081 0ca0 lri $AR1, #0x0ca0 + 032c 1406 lsl $ACC0, #6 + 032d 8900 clr $ACC1 + 032e 1fb8 mrr $AC1.L, $AX0.L + 032f 1505 lsl $ACC1, #5 + 0330 009b 003f lri $AX1.H, #0x003f + 0332 009a 0000 lri $AX0.H, #0x0000 + 0334 3600 andr $AC0.M, $AX1.H + 0335 1cde mrr $IX2, $AC0.M + 0336 001a addarn $AR2, $IX2 + 0337 3400 andr $AC0.M, $AX0.H + 0338 1150 0343 bloopi #0x50, 0x0343 + 033a 1939 lrri $AX1.L, @$AR1 + 033b a000 mulx $AX0.L, $AX1.L + 033c 140a lsl $ACC0, #10 + 033d 4e00 addp $ACC0 + 033e 1476 lsr $ACC0, #-10 + 033f 4c4a add'l $ACC0, $AC1.L : $AX1.L, @$AR2 + 0340 3606 andr'dr $AC0.M, $AX1.H : $AR2 + 0341 1cde mrr $IX2, $AC0.M + 0342 340e andr'nr $AC0.M, $AX0.H : $AR2 + 0343 1b19 srri @$AR0, $AX1.L + 0344 1fc2 mrr $AC0.M, $AR2 + 0345 147a lsr $ACC0, #-6 + 0346 008a ffff lri $WR2, #0xffff + 0348 02df ret +} + +// DsetupTable +void 0349_COMMAND_01() { + 0349 0080 0380 lri $AR0, #0x0380 + 034b 02bf 0051 call 0x0051 + 034d 02bf 0051 call 0x0051 + 034f 02bf 0051 call 0x0051 + 0351 02bf 0051 call 0x0051 + + 0353 0081 0382 lri $AR1, #0x0382 + 0355 009f 0000 lri $AC1.M, #0x0000 + 0357 0080 0200 lri $AR0, #0x0200 + // 0359 02bf 007c call 0x007c + 007c_CopyRAMtoDMEM() + + 035b 0081 0384 lri $AR1, #0x0384 + 035d 009f 0300 lri $AC1.M, #0x0300 + 035f 0080 0020 lri $AR0, #0x0020 + 0361 02bf 007c call 0x007c + 007c_CopyRAMtoDMEM() + + + 0363 02bf 03cc call 0x03cc + 0365 00de 0345 lr $AC0.M, @0x0345 + 0367 00fe 0342 sr @0x0342, $AC0.M + 0369 02bf 0af0 call 0x0af0 + 036b 029f 0049 jmp 0x0049 + 036d 00de 0344 lr $AC0.M, @0x0344 + 036f 1404 lsl $ACC0, #4 + 0370 0200 03a8 addi $AC0.M, #0x03a8 + 0372 1c1e mrr $AR0, $AC0.M + 0373 02bf 0051 call 0x0051 + 0375 02bf 0051 call 0x0051 + 0377 02bf 0051 call 0x0051 + 0379 00de 0345 lr $AC0.M, @0x0345 + 037b 1b1e srri @$AR0, $AC0.M + 037c 00de 0344 lr $AC0.M, @0x0344 + 037e 0200 03a4 addi $AC0.M, #0x03a4 + 0380 1c1e mrr $AR0, $AC0.M + 0381 8100 clr $ACC0 + 0382 1b1e srri @$AR0, $AC0.M + 0383 02df ret +} + +void 0384_Unk() { + 0384 00de 0344 lr $AC0.M, @0x0344 + 0386 1404 lsl $ACC0, #4 + 0387 0200 03b0 addi $AC0.M, #0x03b0 + 0389 1c1e mrr $AR0, $AC0.M + 038a 02bf 0051 call 0x0051 + 038c 02bf 0051 call 0x0051 + 038e 02bf 0051 call 0x0051 + 0390 02bf 0051 call 0x0051 + 0392 02df ret +} + +void 0393_Unk() { + 0393 0081 034c lri $AR1, #0x034c + 0395 009f 0400 lri $AC1.M, #0x0400 + 0397 0080 00c0 lri $AR0, #0x00c0 + 0399 02bf 007c call 0x007c + 039b 02df ret +} + +void 039c_Unk() { + 039c 0081 034c lri $AR1, #0x034c + 039e 009f 0400 lri $AC1.M, #0x0400 + 03a0 0080 0080 lri $AR0, #0x0080 + 03a2 0081 034c lri $AR1, #0x034c + 03a4 193e lrri $AC0.M, @$AR1 + 03a5 193c lrri $AC0.L, @$AR1 + 03a6 0098 0000 lri $AX0.L, #0x0000 + 03a8 7000 addaxl $ACC0, $AX0.L + 03a9 02bf 008b call 0x008b + 03ab 02df ret +} + +void 03ac_Unk() { + 03ac 191e lrri $AC0.M, @$AR0 + 03ad 191a lrri $AX0.H, @$AR0 + 03ae 005f loop $AC1.M + 03af 64a0 movr'ls $ACC0, $AX0.H : $AX0.H, $AC0.M + 03b0 1b7e srri @$AR3, $AC0.M + 03b1 1b7a srri @$AR3, $AX0.H + 03b2 02df ret +} + +// Example call: +//a 03d9 0080 0f40 lri $AR0, #0x0f40 +//a 03db 0082 0d00 lri $AR2, #0x0d00 +//a 03dd 0083 0d60 lri $AR3, #0x0d60 +//a 03df 009f 0028 lri $AC1.M, #0x0028 +//a 03e1 02bf 03b3 call 0x03b3 +// Not sure how AR2 fits into the picture... +void 03b3_XorBuffer(InputBuffer($AR0), OutputBuffer($AR3), HalfLength($AC1.M)) { + 03b3 191e lrri $AC0.M, @$AR0 + 03b4 191a lrri $AX0.H, @$AR0 + 03b5 007f 03ba bloop $AC1.M, 0x03ba + 03b7 32b2 xorr'sl $AC0.M, $AX1.H : $AC0.M, $AX1.H + 03b8 65a0 movr'ls $ACC1, $AX0.H : $AX0.H, $AC0.M + 03b9 33ba xorr'slm $AC1.M, $AX1.H : $AC0.M, $AX1.H + 03ba 64a1 movr'ls $ACC0, $AX0.H : $AX0.H, $AC1.M + 03bb 0000 nop + 03bc 02df ret +} + +void 03bd_Unk() { + 03bd 8a00 m2 + 03be 157f lsr $ACC1, #-1 + 03bf 1c20 mrr $AR1, $AR0 + 03c0 1c03 mrr $AR0, $AR3 + 03c1 193a lrri $AX0.H, @$AR1 + 03c2 9051 mul'l $AX0.L, $AX0.H : $AX0.H, @$AR1 + 03c3 925b mulmvz'l $AX0.L, $AX0.H, $ACC0 : $AX1.H, @$AR3 + 03c4 007f 03c9 bloop $AC1.M, 0x03c9 + 03c6 4651 addr'l $ACC0, $AX1.H : $AX0.H, @$AR1 + 03c7 92b2 mulmvz'sl $AX0.L, $AX0.H, $ACC0 : $AC0.M, $AX1.H + 03c8 4651 addr'l $ACC0, $AX1.H : $AX0.H, @$AR1 + 03c9 92b2 mulmvz'sl $AX0.L, $AX0.H, $ACC0 : $AC0.M, $AX1.H + 03ca 8b00 m0 + 03cb 02df ret +} + +void 03cc_Unk() { + 03cc 0083 ffa0 lri $AR3, #0xffa0 + 03ce 0080 0300 lri $AR0, #0x0300 + 03d0 009f 000e lri $AC1.M, #0x000e + 03d2 1108 03d7 bloopi #0x08, 0x03d7 + 03d4 191e lrri $AC0.M, @$AR0 + 03d5 1b7e srri @$AR3, $AC0.M + 03d6 191e lrri $AC0.M, @$AR0 + 03d7 1b7e srri @$AR3, $AC0.M + 03d8 02df ret +} + +void 03d9_Unk() { + + 03d9 0080 0f40 lri $AR0, #0x0f40 + 03db 0082 0d00 lri $AR2, #0x0d00 + 03dd 0083 0d60 lri $AR3, #0x0d60 + 03df 009f 0028 lri $AC1.M, #0x0028 + // XorBuffer, why?? + 03e1 02bf 03b3 call 0x03b3 + + // Clear a bunch of buffers. + 03e3 8900 clr $ACC1 + 03e4 009e 0050 lri $AC0.M, #0x0050 + 03e6 0080 0ca0 lri $AR0, #0x0ca0 + 03e8 005e loop $AC0.M + 03e9 1b1f srri @$AR0, $AC1.M + 03ea 0080 0f40 lri $AR0, #0x0f40 + 03ec 005e loop $AC0.M + 03ed 1b1f srri @$AR0, $AC1.M + 03ee 0080 0fa0 lri $AR0, #0x0fa0 + 03f0 005e loop $AC0.M + 03f1 1b1f srri @$AR0, $AC1.M + 03f2 0080 0b00 lri $AR0, #0x0b00 + 03f4 005e loop $AC0.M + 03f5 1b1f srri @$AR0, $AC1.M + 03f6 0080 09a0 lri $AR0, #0x09a0 + 03f8 005e loop $AC0.M + 03f9 1b1f srri @$AR0, $AC1.M + + 03fa 02df ret +} + +void 03fb_Unk() { + 03fb 00c0 03a0 lr $AR0, @0x03a0 + 03fd 191a lrri $AX0.H, @$AR0 + 03fe 00df 03a1 lr $AC1.M, @0x03a1 + 0400 009b 00a0 lri $AX1.H, #0x00a0 + 0402 0081 0393 lri $AR1, #0x0393 + 0404 18bc lrrd $AC0.L, @$AR1 + 0405 b871 mulx'l $AX0.H, $AX1.H : $AC0.M, @$AR1 + 0406 bc00 mulxac $AX0.H, $AX1.H, $ACC0 + 0407 0080 0050 lri $AR0, #0x0050 + 0409 0508 addis $ACC1, #0x08 + 040a 02bf 007e call 0x007e + 040c 00de 0390 lr $AC0.M, @0x0390 + 040e 02a0 0001 andf $AC0.M, #0x0001 + 0410 029d 041a jlz 0x041a + 0412 0080 0398 lri $AR0, #0x0398 + 0414 009e 0008 lri $AC0.M, #0x0008 + 0416 00c1 03a1 lr $AR1, @0x03a1 + 0418 02bf 01c2 call 0x01c2 + 041a 009f 0050 lri $AC1.M, #0x0050 + 041c 00c0 03a1 lr $AR0, @0x03a1 + 041e 8100 clr $ACC0 + 041f 00de 0394 lr $AC0.M, @0x0394 + 0421 b100 tst $ACC0 + 0422 0295 0429 jz 0x0429 + 0424 1c7e mrr $AR3, $AC0.M + 0425 00d8 0395 lr $AX0.L, @0x0395 + 0427 02bf 03bd call 0x03bd + 0429 009f 0050 lri $AC1.M, #0x0050 + 042b 00c0 03a1 lr $AR0, @0x03a1 + 042d 8100 clr $ACC0 + 042e 00de 0396 lr $AC0.M, @0x0396 + 0430 b100 tst $ACC0 + 0431 0295 0438 jz 0x0438 + 0433 1c7e mrr $AR3, $AC0.M + 0434 00d8 0397 lr $AX0.L, @0x0397 + 0436 02bf 03bd call 0x03bd + 0438 00de 0390 lr $AC0.M, @0x0390 + 043a 02a0 0002 andf $AC0.M, #0x0002 + 043c 02dd retlz + + 043d 0080 0398 lri $AR0, #0x0398 + 043f 009e 0008 lri $AC0.M, #0x0008 + 0441 00c1 03a1 lr $AR1, @0x03a1 + 0443 02bf 01c2 call 0x01c2 + 0445 02df ret +} + +void 0446_Unk() { + 0446 009f 0dc0 lri $AC1.M, #0x0dc0 + 0448 00ff 03a1 sr @0x03a1, $AC1.M + 044a 009f 03a8 lri $AC1.M, #0x03a8 + 044c 00ff 03a2 sr @0x03a2, $AC1.M + 044e 009f 03a4 lri $AC1.M, #0x03a4 + 0450 00ff 03a0 sr @0x03a0, $AC1.M + 0452 1104 047b bloopi #0x04, 0x047b + 0454 00c0 03a2 lr $AR0, @0x03a2 + 0456 0083 0390 lri $AR3, #0x0390 + 0458 009f 000e lri $AC1.M, #0x000e + 045a 02bf 03ac call 0x03ac + 045c 00da 0390 lr $AX0.H, @0x0390 + 045e 8600 tstaxh $AX0.H + 045f 0295 046c jz 0x046c + 0461 00df 03a1 lr $AC1.M, @0x03a1 + 0463 1c7f mrr $AR3, $AC1.M + 0464 0550 addis $ACC1, #0x50 + 0465 1c1f mrr $AR0, $AC1.M + 0466 009f 0006 lri $AC1.M, #0x0006 + 0468 02bf 03ac call 0x03ac + 046a 02bf 03fb call 0x03fb + 046c 00de 03a2 lr $AC0.M, @0x03a2 + 046e 0410 addis $ACC0, #0x10 + 046f 00fe 03a2 sr @0x03a2, $AC0.M + 0471 00de 03a1 lr $AC0.M, @0x03a1 + 0473 0460 addis $ACC0, #0x60 + 0474 00fe 03a1 sr @0x03a1, $AC0.M + 0476 00de 03a0 lr $AC0.M, @0x03a0 + 0478 7400 incm $AC0.M + 0479 00fe 03a0 sr @0x03a0, $AC0.M + 047b 0000 nop + 047c 02df ret +} + +void 047d_Unk() { + 047d 00c0 03a0 lr $AR0, @0x03a0 + 047f 181a lrr $AX0.H, @$AR0 + 0480 8100 clr $ACC0 + 0481 181e lrr $AC0.M, @$AR0 + 0482 00db 0391 lr $AX1.H, @0x0391 + 0484 7400 incm $AC0.M + 0485 d100 cmpar $ACC1, $AX0.H + 0486 0270 ifns + 0487 8100 clr $ACC0 + 0488 1b1e srri @$AR0, $AC0.M + 0489 00df 03a1 lr $AC1.M, @0x03a1 + 048b 009b 00a0 lri $AX1.H, #0x00a0 + 048d 0081 0393 lri $AR1, #0x0393 + 048f 18bc lrrd $AC0.L, @$AR1 + 0490 b871 mulx'l $AX0.H, $AX1.H : $AC0.M, @$AR1 + 0491 bc00 mulxac $AX0.H, $AX1.H, $ACC0 + 0492 0080 0050 lri $AR0, #0x0050 + 0494 02bf 008b call 0x008b + 0496 02df ret +} + +void 0497_Unk() { + 0497 009f 0dc0 lri $AC1.M, #0x0dc0 + 0499 00ff 03a1 sr @0x03a1, $AC1.M + 049b 009f 03a8 lri $AC1.M, #0x03a8 + 049d 00ff 03a2 sr @0x03a2, $AC1.M + 049f 009f 03a4 lri $AC1.M, #0x03a4 + 04a1 00ff 03a0 sr @0x03a0, $AC1.M + 04a3 1104 04c3 bloopi #0x04, 0x04c3 + 04a5 00c0 03a2 lr $AR0, @0x03a2 + 04a7 0083 0390 lri $AR3, #0x0390 + 04a9 009f 000e lri $AC1.M, #0x000e + 04ab 02bf 03ac call 0x03ac + 04ad 00da 0390 lr $AX0.H, @0x0390 + 04af 8600 tstaxh $AX0.H + 04b0 0295 04b4 jz 0x04b4 + 04b2 02bf 047d call 0x047d + 04b4 00de 03a2 lr $AC0.M, @0x03a2 + 04b6 0410 addis $ACC0, #0x10 + 04b7 00fe 03a2 sr @0x03a2, $AC0.M + 04b9 00de 03a1 lr $AC0.M, @0x03a1 + 04bb 0460 addis $ACC0, #0x60 + 04bc 00fe 03a1 sr @0x03a1, $AC0.M + 04be 00de 03a0 lr $AC0.M, @0x03a0 + 04c0 7400 incm $AC0.M + 04c1 00fe 03a0 sr @0x03a0, $AC0.M + 04c3 0000 nop + 04c4 02df ret +} + +void 04c5_Unk() { + 04c5 0081 0386 lri $AR1, #0x0386 + 04c7 009f 03a8 lri $AC1.M, #0x03a8 + 04c9 0080 0040 lri $AR0, #0x0040 + 04cb 02bf 007c call 0x007c + 04cd 02df ret +} + +void 04ce_Increment32BitAddressAtAR0() { + 04ce 191e lrri $AC0.M, @$AR0 + 04cf 189c lrrd $AC0.L, @$AR0 + 04d0 4800 addax $ACC0, $AX0.L + 04d1 1b1e srri @$AR0, $AC0.M + 04d2 1b1c srri @$AR0, $AC0.L + 04d3 02df ret +} + +void 04d4_Unk() { + 04d4 8100 clr $ACC0 + 04d5 26fe lrs $AC0.M, @CMBH + 04d6 02c0 8000 andcf $AC0.M, #0x8000 + 04d8 029c 04d5 jlnz 0x04d5 + 04da 26ff lrs $AC0.M, @CMBL + 04db 02df ret +} + +void 04dc_Unk() { + 04dc 0080 0388 lri $AR0, #0x0388 + 04de 0081 0051 lri $AR1, #0x0051 + 04e0 173f callr $AR1 + 04e1 00de 0344 lr $AC0.M, @0x0344 + 04e3 00fe 0341 sr @0x0341, $AC0.M + 04e5 00de 0345 lr $AC0.M, @0x0345 + 04e7 00fe 038e sr @0x038e, $AC0.M + 04e9 173f callr $AR1 + 04ea 02df ret +} + +///////////////////////// +// +// +// 0x0341: Number of Frames to render ... + +// 0x034c + 0x034d: RAM address of the current PB block + +// 0x034e: Last Sync message for rendered frame +// 0x0354: PB loop counter + +// 0x0355: Current Frame + +// 0x0380: ??? +// 0x0381: ??? + +// 0x0388: RAM Address of Output Buffer1 +// 0x038a: RAM Address of Output Buffer2 +// +// 0x038f: Output Buffer Address (0x0520 most of the time) +// +// 0x03f8: *0x0433 +// 0x0520: Some kind of sample buffer + +// 0x0d00: Left mix buffer +// 0x0d60: Right mix buffer + +void 04eb_COMMAND_02() // sync frame + 04eb 02bf 04dc call 0x04dc + 04ed 009e 8000 lri $AC0.M, #0x8000 + 04ef 00dc 0341 lr $AC0.L, @0x0341 + 04f1 02bf 005a call 0x005a + 04f3 8100 clr $ACC0 + 04f4 00fe 0355 sr @0x0355, $AC0.M + 04f6 02bf 04c5 call 0x04c5 + 04f8 00de 0341 lr $AC0.M, @0x0341 + 04fa 007e 0698 bloop $AC0.M, 0x0698 + 04fc 02bf 03d9 call 0x03d9 + + 04fe 02bf 0446 call 0x0446 + 0500 02bf 0bb6 call 0x0bb6 + 0502 02bf 04d4 call 0x04d4 + 0504 8100 clr $ACC0 + 0505 00fe 0354 sr @0x0354, $AC0.M + 0507 00de 0342 lr $AC0.M, @0x0342 + 0509 007e 064c bloop $AC0.M, 0x064c + 050b 00d8 0354 lr $AX0.L, @0x0354 + 050d 009a 0180 lri $AX0.H, #0x0180 + 050f 8100 clr $ACC0 + 0510 00de 0380 lr $AC0.M, @0x0380 + 0512 00dc 0381 lr $AC0.L, @0x0381 + 0514 9000 mul $AX0.L, $AX0.H + 0515 9400 mulac $AX0.L, $AX0.H, $ACC0 + 0516 00fe 034c sr @0x034c, $AC0.M + 0518 00fc 034d sr @0x034d, $AC0.L + 051a 02bf 0393 call 0x0393 + 051c 00da 0400 lr $AX0.H, @0x0400 + 051e 8600 tstaxh $AX0.H + 051f 0295 0647 jz 0x0647 + 0521 00da 0401 lr $AX0.H, @0x0401 + 0523 8600 tstaxh $AX0.H + 0524 0294 0647 jnz 0x0647 + 0526 00da 0433 lr $AX0.H, @0x0433 + 0528 00fa 03f8 sr @0x03f8, $AX0.H + 052a 00da 0406 lr $AX0.H, @0x0406 + 052c 8600 tstaxh $AX0.H + 052d 0294 0a5e jnz 0x0a5e + 052f 8100 clr $ACC0 + 0530 00de 0480 lr $AC0.M, @0x0480 + 0532 0609 cmpis $ACC0, #0x09 + 0533 0295 0540 jz 0x0540 + 0535 0620 cmpis $ACC0, #0x20 + 0536 0295 08cd jz 0x08cd + 0538 0621 cmpis $ACC0, #0x21 + 0539 0295 08d6 jz 0x08d6 + 053b 0608 cmpis $ACC0, #0x08 + 053c 0295 0a66 jz 0x0a66 + 053e 029f 0266 jmp 0x0266 + 0540 00d8 0402 lr $AX0.L, @0x0402 + 0542 8100 clr $ACC0 + 0543 8900 clr $ACC1 + 0544 00dc 0430 lr $AC0.L, @0x0430 + 0546 8d00 set15 + 0547 0099 0050 lri $AX1.L, #0x0050 + 0549 a000 mulx $AX0.L, $AX1.L + 054a a400 mulxac $AX0.L, $AX1.L, $ACC0 + 054b 1404 lsl $ACC0, #4 + 054c 8c00 clr15 + 054d 1ffe mrr $AC1.M, $AC0.M + 054e 0083 0580 lri $AR3, #0x0580 + 0550 00da 0481 lr $AX0.H, @0x0481 + 0552 8600 tstaxh $AX0.H + 0553 0295 0563 jz 0x0563 + 0555 00da 0489 lr $AX0.H, @0x0489 + 0557 8100 clr $ACC0 + 0558 00de 048b lr $AC0.M, @0x048b + 055a 3800 orr $AC0.M, $AX0.H + 055b 0240 000f andi $AC0.M, #0x000f + 055d 0295 0563 jz 0x0563 + 055f 02bf 07d5 call 0x07d5 + 0561 029f 0565 jmp 0x0565 + 0563 02bf 0966 call 0x0966 + 0565 0080 0580 lri $AR0, #0x0580 + 0567 0081 0520 lri $AR1, #0x0520 + 0569 0099 0000 lri $AX1.L, #0x0000 + 056b 02bf 0141 call 0x0141 + 056d 00da 04a8 lr $AX0.H, @0x04a8 + 056f 8600 tstaxh $AX0.H + 0570 0295 0576 jz 0x0576 + 0572 0080 0520 lri $AR0, #0x0520 + 0574 02bf 0b90 call 0x0b90 + 0576 009e 0520 lri $AC0.M, #0x0520 + 0578 00fe 038f sr @0x038f, $AC0.M + 057a 8900 clr $ACC1 + 057b 00df 0484 lr $AC1.M, @0x0484 + 057d 0340 001f andi $AC1.M, #0x001f + 057f b900 tst $ACC1 + 0580 0295 05a6 jz 0x05a6 + 0582 00de 038f lr $AC0.M, @0x038f + 0584 5c00 sub $ACC0, $AC1.L + 0585 00fe 038f sr @0x038f, $AC0.M + 0587 1c7e mrr $AR3, $AC0.M + 0588 0080 0440 lri $AR0, #0x0440 + 058a 05fe addis $ACC1, #0xfe + 058b 02bf 03ac call 0x03ac + 058d 0080 0490 lri $AR0, #0x0490 + 058f 00c1 038f lr $AR1, @0x038f + 0591 8900 clr $ACC1 + 0592 00df 0484 lr $AC1.M, @0x0484 + 0594 0340 001f andi $AC1.M, #0x001f + 0596 02bf 01e1 call 0x01e1 + 0598 00de 038f lr $AC0.M, @0x038f + 059a 0450 addis $ACC0, #0x50 + 059b 1c1e mrr $AR0, $AC0.M + 059c 0083 0440 lri $AR3, #0x0440 + 059e 8900 clr $ACC1 + 059f 00df 0484 lr $AC1.M, @0x0484 + 05a1 0340 001f andi $AC1.M, #0x001f + 05a3 05fe addis $ACC1, #0xfe + 05a4 02bf 03ac call 0x03ac + 05a6 00de 0484 lr $AC0.M, @0x0484 + 05a8 0240 0020 andi $AC0.M, #0x0020 + 05aa 0295 05c8 jz 0x05c8 + 05ac 0080 04a4 lri $AR0, #0x04a4 + 05ae 00c1 038f lr $AR1, @0x038f + 05b0 0082 0454 lri $AR2, #0x0454 + 05b2 0083 04a7 lri $AR3, #0x04a7 + 05b4 18fa lrrd $AX0.H, @$AR3 + 05b5 8600 tstaxh $AX0.H + 05b6 0294 05c6 jnz 0x05c6 + 05b8 18fa lrrd $AX0.H, @$AR3 + 05b9 8600 tstaxh $AX0.H + 05ba 0294 05c6 jnz 0x05c6 + 05bc 18fa lrrd $AX0.H, @$AR3 + 05bd 8600 tstaxh $AX0.H + 05be 0294 05c6 jnz 0x05c6 + 05c0 8100 clr $ACC0 + 05c1 18fe lrrd $AC0.M, @$AR3 + 05c2 0280 7fff cmpi $AC0.M, #0x7fff + 05c4 0295 05c8 jz 0x05c8 + 05c6 02bf 01fc call 0x01fc + 05c8 8100 clr $ACC0 + 05c9 1c9e mrr $IX0, $AC0.M + 05ca 1cde mrr $IX2, $AC0.M + 05cb 7400 incm $AC0.M + 05cc 1cfe mrr $IX3, $AC0.M + 05cd 8100 clr $ACC0 + 05ce 00de 0407 lr $AC0.M, @0x0407 + 05d0 b100 tst $ACC0 + 05d1 0295 05e0 jz 0x05e0 + 05d3 00c3 038f lr $AR3, @0x038f + 05d5 0007 dar $AR3 + 05d6 0080 0477 lri $AR0, #0x0477 + 05d8 0084 ffff lri $IX0, #0xffff + 05da 0087 ffff lri $IX3, #0xffff + 05dc 199a lrrn $AX0.H, @$AR0 + 05dd 6554 movr'ln $ACC1, $AX0.H : $AX0.H, @$AR0 + 05de 005e loop $AC0.M + 05df 65ad movr'lsnm $ACC1, $AX0.H : $AX0.H, $AC1.M + 05e0 00da 0485 lr $AX0.H, @0x0485 + 05e2 8600 tstaxh $AX0.H + 05e3 0295 05f6 jz 0x05f6 + 05e5 8900 clr $ACC1 + 05e6 0086 0005 lri $IX2, #0x0005 + 05e8 0082 040a lri $AR2, #0x040a + 05ea 1106 05ee bloopi #0x06, 0x05ee + 05ec 18de lrrd $AC0.M, @$AR2 + 05ed 147f lsr $ACC0, #-1 + 05ee 4d36 add'sn $ACC1, $AC0.L : @$AR2, $AC0.M + 05ef b900 tst $ACC1 + 05f0 0294 05f6 jnz 0x05f6 + 05f2 009a 0001 lri $AX0.H, #0x0001 + 05f4 00fa 0401 sr @0x0401, $AX0.H + 05f6 8f00 set40 + 05f7 0086 0002 lri $IX2, #0x0002 + 05f9 0082 0408 lri $AR2, #0x0408 + 05fb 1106 0626 bloopi #0x06, 0x0626 + 05fd 8100 clr $ACC0 + 05fe 195e lrri $AC0.M, @$AR2 + 05ff 1200 sbclr #0x00 + 0600 b100 tst $ACC0 + 0601 0275 ifz + 0602 1300 sbset #0x00 + 0603 1c7e mrr $AR3, $AC0.M + 0604 195e lrri $AC0.M, @$AR2 + 0605 195f lrri $AC1.M, @$AR2 + 0606 5c00 sub $ACC0, $AC1.L + 0607 14fb asr $ACC0, #-5 + 0608 1f5e mrr $AX0.H, $AC0.M + 0609 1f1c mrr $AX0.L, $AC0.L + 060a 185e lrr $AC0.M, @$AR2 + 060b 0240 00ff andi $AC0.M, #0x00ff + 060d 1f7e mrr $AX1.H, $AC0.M + 060e 185e lrr $AC0.M, @$AR2 + 060f 1478 lsr $ACC0, #-8 + 0610 009c 0000 lri $AC0.L, #0x0000 + 0612 d100 cmpar $ACC1, $AX0.H + 0613 0295 061b jz 0x061b + 0615 185e lrr $AC0.M, @$AR2 + 0616 0272 ifg + 0617 7400 incm $AC0.M + 0618 0271 ifs + 0619 7800 decm $AC0.M + 061a 1a5e srr @$AR2, $AC0.M + 061b 0006 dar $AR2 + 061c 00de 038f lr $AC0.M, @0x038f + 061e 5600 subr $ACC0, $AX1.H + 061f 029d 0624 jlz 0x0624 + 0621 1c1e mrr $AR0, $AC0.M + 0622 02bf 011e call 0x011e + 0624 0000 nop + 0625 1b5f srri @$AR2, $AC1.M + 0626 000a iar $AR2 + 0627 8e00 set16 + 0628 8100 clr $ACC0 + 0629 00de 0407 lr $AC0.M, @0x0407 + 062b b100 tst $ACC0 + 062c 0295 063d jz 0x063d + 062e 00c3 038f lr $AR3, @0x038f + 0630 0087 004f lri $IX3, #0x004f + 0632 001f addarn $AR3, $IX3 + 0633 0080 0477 lri $AR0, #0x0477 + 0635 0084 ffff lri $IX0, #0xffff + 0637 0087 ffff lri $IX3, #0xffff + 0639 19fa lrrn $AX0.H, @$AR3 + 063a 6557 movr'ln $ACC1, $AX0.H : $AX0.H, @$AR3 + 063b 005e loop $AC0.M + 063c 65af movr'slnm $ACC1, $AX0.H : $AC1.M, $AX0.H + 063d 00da 0406 lr $AX0.H, @0x0406 + 063f 8600 tstaxh $AX0.H + 0640 0294 0645 jnz 0x0645 + 0642 8100 clr $ACC0 + 0643 00fe 0404 sr @0x0404, $AC0.M + 0645 02bf 039c call 0x039c + + + 0647 00de 0354 lr $AC0.M, @0x0354 + 0649 7400 incm $AC0.M + 064a 00fe 0354 sr @0x0354, $AC0.M + 064c 0000 nop + 064d 16fb 0001 si @DIRQ, #0x0001 + 064f 02bf 0b11 call 0x0b11 + 0651 02bf 0b24 call 0x0b24 + 0653 02bf 0b7b call 0x0b7b + 0655 0080 09a0 lri $AR0, #0x09a0 + 0657 0083 0d00 lri $AR3, #0x0d00 + 0659 009f 0050 lri $AC1.M, #0x0050 + 065b 0098 5a82 lri $AX0.L, #0x5a82 + 065d 02bf 03bd call 0x03bd + 065f 0080 09a0 lri $AR0, #0x09a0 + 0661 0083 0d60 lri $AR3, #0x0d60 + 0663 009f 0050 lri $AC1.M, #0x0050 + 0665 02bf 03bd call 0x03bd + 0667 0083 0d00 lri $AR3, #0x0d00 + 0669 02bf 0130 call 0x0130 + 066b 0081 0388 lri $AR1, #0x0388 + 066d 009f 0d00 lri $AC1.M, #0x0d00 + 066f 0080 0050 lri $AR0, #0x0050 + 0671 02bf 0089 call 0x0089 + 0673 0080 0fa0 lri $AR0, #0x0fa0 + 0675 0083 0d60 lri $AR3, #0x0d60 + 0677 009f 0050 lri $AC1.M, #0x0050 + 0679 0098 8000 lri $AX0.L, #0x8000 + 067b 02bf 03bd call 0x03bd + 067d 0083 0d60 lri $AR3, #0x0d60 + 067f 02bf 0130 call 0x0130 + 0681 0081 038a lri $AR1, #0x038a + 0683 009f 0d60 lri $AC1.M, #0x0d60 + 0685 0080 0050 lri $AR0, #0x0050 + 0687 02bf 0089 call 0x0089 + 0689 009a 0000 lri $AX0.H, #0x0000 + 068b 0098 00a0 lri $AX0.L, #0x00a0 + 068d 0080 0388 lri $AR0, #0x0388 + 068f 02bf 04ce call 0x04ce + 0691 0080 038a lri $AR0, #0x038a + 0693 02bf 04ce call 0x04ce + 0695 02bf 0497 call 0x0497 + 0697 0000 nop + 0698 0000 nop + } + 0699 029f 0031 jmp 0x0031 + 069b 0080 0346 lri $AR0, #0x0346 + 069d 02bf 0051 call 0x0051 + 069f 02bf 0051 call 0x0051 + 06a1 0081 0346 lri $AR1, #0x0346 + 06a3 193e lrri $AC0.M, @$AR1 + 06a4 193c lrri $AC0.L, @$AR1 + 06a5 009f 0400 lri $AC1.M, #0x0400 + 06a7 00c0 0345 lr $AR0, @0x0345 + 06a9 02bf 007e call 0x007e + + 06ab 0081 0348 lri $AR1, #0x0348 + 06ad 193e lrri $AC0.M, @$AR1 + 06ae 193c lrri $AC0.L, @$AR1 + 06af 009f 0800 lri $AC1.M, #0x0800 + 06b1 00c0 0345 lr $AR0, @0x0345 + 06b3 02bf 007e call 0x007e + + 06b5 0081 0346 lri $AR1, #0x0346 + 06b7 193e lrri $AC0.M, @$AR1 + 06b8 193c lrri $AC0.L, @$AR1 + 06b9 009f 0800 lri $AC1.M, #0x0800 + 06bb 00c0 0345 lr $AR0, @0x0345 + 06bd 02bf 008b call 0x008b + + 06bf 0081 0348 lri $AR1, #0x0348 + 06c1 193e lrri $AC0.M, @$AR1 + 06c2 193c lrri $AC0.L, @$AR1 + 06c3 009f 0400 lri $AC1.M, #0x0400 + 06c5 00c0 0345 lr $AR0, @0x0345 + 06c7 02bf 008b call 0x008b + + 06c9 029f 0049 jmp 0x0049 +} + +void 06cb_Unk() { + 06cb 0080 0346 lri $AR0, #0x0346 + 06cd 02bf 0051 call 0x0051 + 06cf 02bf 0051 call 0x0051 + 06d1 0081 0346 lri $AR1, #0x0346 + 06d3 193e lrri $AC0.M, @$AR1 + 06d4 193c lrri $AC0.L, @$AR1 + 06d5 009f 0400 lri $AC1.M, #0x0400 + 06d7 00c0 0345 lr $AR0, @0x0345 + 06d9 02bf 007e call 0x007e + 06db 0081 0348 lri $AR1, #0x0348 + 06dd 193e lrri $AC0.M, @$AR1 + 06de 193c lrri $AC0.L, @$AR1 + 06df 009f 0400 lri $AC1.M, #0x0400 + 06e1 00c0 0345 lr $AR0, @0x0345 + 06e3 02bf 008b call 0x008b + 06e5 029f 0049 jmp 0x0049 +} + +void 06e7_Unk() { + 06e7 0080 0346 lri $AR0, #0x0346 + 06e9 02bf 0051 call 0x0051 + 06eb 02bf 0051 call 0x0051 + 06ed 0081 0346 lri $AR1, #0x0346 + 06ef 193e lrri $AC0.M, @$AR1 + 06f0 193c lrri $AC0.L, @$AR1 + 06f1 009f 0400 lri $AC1.M, #0x0400 + 06f3 00c0 0345 lr $AR0, @0x0345 + 06f5 02bf 00ae call 0x00ae + 06f7 0081 0348 lri $AR1, #0x0348 + 06f9 193e lrri $AC0.M, @$AR1 + 06fa 193c lrri $AC0.L, @$AR1 + 06fb 009f 0400 lri $AC1.M, #0x0400 + 06fd 00c0 0345 lr $AR0, @0x0345 + 06ff 02bf 008b call 0x008b + 0701 029f 0049 jmp 0x0049 + 0703 0080 0346 lri $AR0, #0x0346 + 0705 02bf 0051 call 0x0051 + 0707 02bf 0051 call 0x0051 + 0709 0081 0346 lri $AR1, #0x0346 + 070b 193e lrri $AC0.M, @$AR1 + 070c 193c lrri $AC0.L, @$AR1 + 070d 009f 0400 lri $AC1.M, #0x0400 + 070f 00c0 0344 lr $AR0, @0x0344 + 0711 02bf 007e call 0x007e + 0713 0081 0348 lri $AR1, #0x0348 + 0715 193e lrri $AC0.M, @$AR1 + 0716 193c lrri $AC0.L, @$AR1 + 0717 009f 0800 lri $AC1.M, #0x0800 + 0719 00c0 0344 lr $AR0, @0x0344 + 071b 02bf 007e call 0x007e + 071d 0080 0400 lri $AR0, #0x0400 + 071f 0083 0800 lri $AR3, #0x0800 + 0721 0084 0000 lri $IX0, #0x0000 + 0723 00da 0345 lr $AX0.H, @0x0345 + 0725 00df 0344 lr $AC1.M, @0x0344 + 0727 8f00 set40 + 0728 197b lrri $AX1.H, @$AR3 + 0729 b800 mulx $AX0.H, $AX1.H + 072a 197b lrri $AX1.H, @$AR3 + 072b 007f 0730 bloop $AC1.M, 0x0730 + 072d 199e lrrn $AC0.M, @$AR0 + 072e bc00 mulxac $AX0.H, $AX1.H, $ACC0 + 072f 80b2 nx'sl : $AC0.M, $AX1.H + 0730 0000 nop + 0731 8e00 set16 + 0732 0081 0346 lri $AR1, #0x0346 + 0734 193e lrri $AC0.M, @$AR1 + 0735 193c lrri $AC0.L, @$AR1 + 0736 009f 0400 lri $AC1.M, #0x0400 + 0738 00c0 0344 lr $AR0, @0x0344 + 073a 02bf 008b call 0x008b + 073c 009e 8200 lri $AC0.M, #0x8200 + 073e 00dc 0344 lr $AC0.L, @0x0344 + 0740 02bf 005a call 0x005a + 0742 029f 0031 jmp 0x0031 + 0744 0080 0346 lri $AR0, #0x0346 + 0746 02bf 0051 call 0x0051 + 0748 0081 0346 lri $AR1, #0x0346 + 074a 009f 0400 lri $AC1.M, #0x0400 + 074c 00c0 0345 lr $AR0, @0x0345 + 074e 02bf 007c call 0x007c + 0750 02bf 8644 call 0x8644 + 0752 029f 0049 jmp 0x0049 +} + +void 0754_Unk() { + 0754 009e 0458 lri $AC0.M, #0x0458 + 0756 2231 lrs $AX0.H, @0x0031 + 0757 4400 addr $ACC0, $AX0.H + 0758 1c1e mrr $AR0, $AC0.M + 0759 1fda mrr $AC0.M, $AX0.H + 075a 3280 xorr'ls $AC0.M, $AX1.H : $AX0.L, $AC0.M + 075b 7400 incm $AC0.M + 075c 2232 lrs $AX0.H, @0x0032 + 075d 4400 addr $ACC0, $AX0.H + 075e 0090 0000 lri $AC0.H, #0x0000 + 0760 029f 0771 jmp 0x0771 + 0762 009e 0458 lri $AC0.M, #0x0458 + 0764 2231 lrs $AX0.H, @0x0031 + 0765 4400 addr $ACC0, $AX0.H + 0766 1c1e mrr $AR0, $AC0.M + 0767 1fda mrr $AC0.M, $AX0.H + 0768 3280 xorr'ls $AC0.M, $AX1.H : $AX0.L, $AC0.M + 0769 7400 incm $AC0.M + 076a 2232 lrs $AX0.H, @0x0032 + 076b 4400 addr $ACC0, $AX0.H + 076c 0090 0000 lri $AC0.H, #0x0000 + 076e 8200 cmp + 076f 0270 ifns + 0770 1fdf mrr $AC0.M, $AC1.M + 0771 1f3e mrr $AX1.L, $AC0.M + 0772 02bf 07c8 call 0x07c8 + 0774 2634 lrs $AC0.M, @0x0034 + 0775 2435 lrs $AC0.L, @0x0035 + 0776 7200 addaxl $ACC0, $AX1.L + 0777 5300 subr $ACC1, $AX1.L + 0778 2e34 srs @0x0034, $AC0.M + 0779 2c35 srs @0x0035, $AC0.L + 077a 02df ret +} + +void 077b_Unk() { + 077b 8100 clr $ACC0 + 077c 2234 lrs $AX0.H, @0x0034 + 077d 2035 lrs $AX0.L, @0x0035 + 077e 4800 addax $ACC0, $AX0.L + 077f 147c lsr $ACC0, #-4 + 0780 2e36 srs @0x0036, $AC0.M + 0781 2c37 srs @0x0037, $AC0.L + 0782 2380 lrs $AX1.H, @0xff80 + 0783 8d00 set15 + 0784 c810 mulc'mv $AC0.M, $AX1.H : $AX0.L, $AC0.L + 0785 ae00 mulxmv $AX0.L, $AX1.H, $ACC0 + 0786 8c00 clr15 + 0787 2035 lrs $AX0.L, @0x0035 + 0788 f000 lsl16 $ACC0 + 0789 4e00 addp $ACC0 + 078a 238c lrs $AX1.H, @0xff8c + 078b 218d lrs $AX1.L, @0xff8d + 078c 4a00 addax $ACC0, $AX1.L + 078d 2e38 srs @0x0038, $AC0.M + 078e 2c39 srs @0x0039, $AC0.L + 078f 1fd8 mrr $AC0.M, $AX0.L + 0790 0240 000f andi $AC0.M, #0x000f + 0792 2e31 srs @0x0031, $AC0.M + 0793 268a lrs $AC0.M, @0xff8a + 0794 248b lrs $AC0.L, @0xff8b + 0795 5800 subax $ACC0, $AX0.L + 0796 2e3a srs @0x003a, $AC0.M + 0797 2c3b srs @0x003b, $AC0.L + 0798 02df ret +} + +void 0799_Unk() { + 0799 2236 lrs $AX0.H, @0x0036 + 079a 2037 lrs $AX0.L, @0x0037 + 079b 8100 clr $ACC0 + 079c 268a lrs $AC0.M, @0xff8a + 079d 248b lrs $AC0.L, @0xff8b + 079e 147c lsr $ACC0, #-4 + 079f 5800 subax $ACC0, $AX0.L + 07a0 0295 07a9 jz 0x07a9 + 07a2 02bf 081b call 0x081b + 07a4 0e10 lris $AC0.M, #0x10 + 07a5 2e32 srs @0x0032, $AC0.M + 07a6 8100 clr $ACC0 + 07a7 2e31 srs @0x0031, $AC0.M + 07a8 02df ret +} + +void 07a9_Unk() { + 07a9 228a lrs $AX0.H, @0xff8a + 07aa 208b lrs $AX0.L, @0xff8b + 07ab 8100 clr $ACC0 + 07ac 2634 lrs $AC0.M, @0x0034 + 07ad 2435 lrs $AC0.L, @0x0035 + 07ae 5800 subax $ACC0, $AX0.L + 07af 0290 07b6 jns 0x07b6 + 07b1 02bf 081b call 0x081b + 07b3 263b lrs $AC0.M, @0x003b + 07b4 029f 07a5 jmp 0x07a5 + 07b6 2688 lrs $AC0.M, @0xff88 + 07b7 2489 lrs $AC0.L, @0xff89 + 07b8 2e34 srs @0x0034, $AC0.M + 07b9 2c35 srs @0x0035, $AC0.L + 07ba 0e10 lris $AC0.M, #0x10 + 07bb 2e32 srs @0x0032, $AC0.M + 07bc 02bf 077b call 0x077b + 07be 2682 lrs $AC0.M, @0xff82 + 07bf 2e67 srs @0x0067, $AC0.M + 07c0 2683 lrs $AC0.M, @0xff83 + 07c1 2e66 srs @0x0066, $AC0.M + 07c2 8100 clr $ACC0 + 07c3 00fe 0362 sr @0x0362, $AC0.M + 07c5 02bf 081b call 0x081b + 07c7 02df ret +} + +void 07c8_Unk() { + 07c8 b100 tst $ACC0 + 07c9 02d5 retz + 07ca 04fe addis $ACC0, #0xfe + 07cb 1f1e mrr $AX0.L, $AC0.M + 07cc 191e lrri $AC0.M, @$AR0 + 07cd 0291 07d3 js 0x07d3 + 07cf 191a lrri $AX0.H, @$AR0 + 07d0 0058 loop $AX0.L + 07d1 64a0 movr'ls $ACC0, $AX0.H : $AX0.H, $AC0.M + 07d2 6433 movr's $ACC0, $AX0.H : @$AR3, $AC0.M + 07d3 1b7e srri @$AR3, $AC0.M + 07d4 02df ret +} + +void 07d5_Unk() { + 07d5 0092 0004 lri $CR, #0x0004 + 07d7 02bf 077b call 0x077b + 07d9 8100 clr $ACC0 + 07da 00fe 0362 sr @0x0362, $AC0.M + 07dc 8100 clr $ACC0 + 07dd 263a lrs $AC0.M, @0x003a + 07de 243b lrs $AC0.L, @0x003b + 07df b100 tst $ACC0 + 07e0 0294 07f2 jnz 0x07f2 + 07e2 02bf 0799 call 0x0799 + 07e4 2231 lrs $AX0.H, @0x0031 + 07e5 8600 tstaxh $AX0.H + 07e6 0294 07ef jnz 0x07ef + 07e8 02bf 0762 call 0x0762 + 07ea b900 tst $ACC1 + 07eb 0295 0818 jz 0x0818 + 07ed 02bf 077b call 0x077b + 07ef 8100 clr $ACC0 + 07f0 263a lrs $AC0.M, @0x003a + 07f1 243b lrs $AC0.L, @0x003b + 07f2 1f1f mrr $AX0.L, $AC1.M + 07f3 009a 0000 lri $AX0.H, #0x0000 + 07f5 5800 subax $ACC0, $AX0.L + 07f6 0290 0805 jns 0x0805 + 07f8 8100 clr $ACC0 + 07f9 2631 lrs $AC0.M, @0x0031 + 07fa b100 tst $ACC0 + 07fb 0294 07ff jnz 0x07ff + 07fd 02bf 0799 call 0x0799 + 07ff 02bf 0754 call 0x0754 + 0801 02bf 077b call 0x077b + 0803 029f 07dc jmp 0x07dc + 0805 8100 clr $ACC0 + 0806 2631 lrs $AC0.M, @0x0031 + 0807 b100 tst $ACC0 + 0808 0294 080c jnz 0x080c + 080a 02bf 0799 call 0x0799 + 080c 02bf 0762 call 0x0762 + 080e b900 tst $ACC1 + 080f 0295 0818 jz 0x0818 + 0811 02bf 077b call 0x077b + 0813 029f 0805 jmp 0x0805 + 0815 8100 clr $ACC0 + 0816 005f loop $AC1.M + 0817 1b7e srri @$AR3, $AC0.M + 0818 0092 00ff lri $CR, #0x00ff + 081a 02df ret +} + +void 081b_Unk() { + 081b 00ff 0360 sr @0x0360, $AC1.M + 081d 00da 0362 lr $AX0.H, @0x0362 + 081f 8600 tstaxh $AX0.H + 0820 0294 082d jnz 0x082d + 0822 0a01 lris $AX0.H, #0x01 + 0823 00fa 0362 sr @0x0362, $AX0.H + 0825 2638 lrs $AC0.M, @0x0038 + 0826 2439 lrs $AC0.L, @0x0039 + 0827 009f 0005 lri $AC1.M, #0x0005 + 0829 02bf 0103 call 0x0103 + 082b 0092 0004 lri $CR, #0x0004 + 082d 0080 ffd3 lri $AR0, #0xffd3 + 082f 0084 0000 lri $IX0, #0x0000 + 0831 199e lrrn $AC0.M, @$AR0 + 0832 1ffe mrr $AC1.M, $AC0.M + 0833 1401 lsl $ACC0, #1 + 0834 0240 001e andi $AC0.M, #0x001e + 0836 0200 0300 addi $AC0.M, #0x0300 + 0838 1c3e mrr $AR1, $AC0.M + 0839 157c lsr $ACC1, #-4 + 083a 0340 000f andi $AC1.M, #0x000f + 083c 0a11 lris $AX0.H, #0x11 + 083d 5500 subr $ACC1, $AX0.H + 083e 009a 00f0 lri $AX0.H, #0x00f0 + 0840 009b 000f lri $AX1.H, #0x000f + 0842 0082 0370 lri $AR2, #0x0370 + 0844 1998 lrrn $AX0.L, @$AR0 + 0845 6000 movr $ACC0, $AX0.L + 0846 1107 084d bloopi #0x07, 0x084d + 0848 3400 andr $AC0.M, $AX0.H + 0849 1408 lsl $ACC0, #8 + 084a 6032 movr's $ACC0, $AX0.L : @$AR2, $AC0.M + 084b 3644 andr'ln $AC0.M, $AX1.H : $AX0.L, @$AR0 + 084c 140c lsl $ACC0, #12 + 084d 6032 movr's $ACC0, $AX0.L : @$AR2, $AC0.M + 084e 3400 andr $AC0.M, $AX0.H + 084f 1408 lsl $ACC0, #8 + 0850 6032 movr's $ACC0, $AX0.L : @$AR2, $AC0.M + 0851 3600 andr $AC0.M, $AX1.H + 0852 140c lsl $ACC0, #12 + 0853 1b5e srri @$AR2, $AC0.M + 0854 8f00 set40 + 0855 1f7f mrr $AX1.H, $AC1.M + 0856 2066 lrs $AX0.L, @0x0066 + 0857 2767 lrs $AC1.M, @0x0067 + 0858 193a lrri $AX0.H, @$AR1 + 0859 1939 lrri $AX1.L, @$AR1 + 085a 0080 0370 lri $AR0, #0x0370 + 085c 0081 0458 lri $AR1, #0x0458 + 085e 1c80 mrr $IX0, $AR0 + 085f a000 mulx $AX0.L, $AX1.L + 0860 ea70 maddc'l $AC1.M, $AX1.L : $AC0.M, @$AR0 + 0861 1108 086a bloopi #0x08, 0x086a + 0863 3a93 orr'sl $AC0.M, $AX1.H : $AC1.M, $AX1.L + 0864 a478 mulxac'l $AX0.L, $AX1.L, $ACC0 : $AC1.M, @$AR0 + 0865 1485 asl $ACC0, #5 + 0866 e831 maddc's $AC0.M, $AX1.L : @$AR1, $AC0.M + 0867 3b92 orr'sl $AC1.M, $AX1.H : $AC0.M, $AX1.L + 0868 a570 mulxac'l $AX0.L, $AX1.L, $ACC1 : $AC0.M, @$AR0 + 0869 1585 asl $ACC1, #5 + 086a ea39 maddc's $AC1.M, $AX1.L : @$AR1, $AC1.M + 086b 8e00 set16 + 086c 8900 clr $ACC1 + 086d 00df 0360 lr $AC1.M, @0x0360 + 086f 02df ret +} + +void 0870_Unk() { + 0870 0080 0346 lri $AR0, #0x0346 + 0872 02bf 0051 call 0x0051 + 0874 8100 clr $ACC0 + 0875 0080 0458 lri $AR0, #0x0458 + 0877 1010 loopi #0x10 + 0878 1b1e srri @$AR0, $AC0.M + 0879 00fe 0482 sr @0x0482, $AC0.M + 087b 00fe 0483 sr @0x0483, $AC0.M + 087d 009c 0000 lri $AC0.L, #0x0000 + 087f 00fe 0434 sr @0x0434, $AC0.M + 0881 00fc 0435 sr @0x0435, $AC0.L + 0883 009e 0100 lri $AC0.M, #0x0100 + 0885 009c f100 lri $AC0.L, #0xf100 + 0887 00fe 048e sr @0x048e, $AC0.M + 0889 00fc 048f sr @0x048f, $AC0.L + 088b 009e 0040 lri $AC0.M, #0x0040 + 088d 009c 0000 lri $AC0.L, #0x0000 + 088f 00fe 048c sr @0x048c, $AC0.M + 0891 00fc 048d sr @0x048d, $AC0.L + 0893 009e 0009 lri $AC0.M, #0x0009 + 0895 00fe 0480 sr @0x0480, $AC0.M + 0897 009e 0010 lri $AC0.M, #0x0010 + 0899 00fe 0432 sr @0x0432, $AC0.M + 089b 009e 0100 lri $AC0.M, #0x0100 + 089d 009c f250 lri $AC0.L, #0xf250 + 089f 00fe 048a sr @0x048a, $AC0.M + 08a1 00fc 048b sr @0x048b, $AC0.L + 08a3 009c 0000 lri $AC0.L, #0x0000 + 08a5 00fe 0488 sr @0x0488, $AC0.M + 08a7 00fc 0489 sr @0x0489, $AC0.L + 08a9 009e 0001 lri $AC0.M, #0x0001 + 08ab 00fe 0481 sr @0x0481, $AC0.M + 08ad 8900 clr $ACC1 + 08ae 00ff 0401 sr @0x0401, $AC1.M + 08b0 1180 08ca bloopi #0x80, 0x08ca + 08b2 0083 0580 lri $AR3, #0x0580 + 08b4 009f 0100 lri $AC1.M, #0x0100 + 08b6 02bf 07d5 call 0x07d5 + 08b8 0081 0346 lri $AR1, #0x0346 + 08ba 193e lrri $AC0.M, @$AR1 + 08bb 18bc lrrd $AC0.L, @$AR1 + 08bc 009f 0580 lri $AC1.M, #0x0580 + 08be 0080 0100 lri $AR0, #0x0100 + 08c0 02bf 008b call 0x008b + 08c2 0081 0346 lri $AR1, #0x0346 + 08c4 193e lrri $AC0.M, @$AR1 + 08c5 18bc lrrd $AC0.L, @$AR1 + 08c6 0098 0200 lri $AX0.L, #0x0200 + 08c8 7000 addaxl $ACC0, $AX0.L + 08c9 1b3e srri @$AR1, $AC0.M + 08ca 1abc srrd @$AR1, $AC0.L + 08cb 029f 0049 jmp 0x0049 +} + +void 08cd_Unk() { + 08cd 8900 clr $ACC1 + 08ce 009f 0050 lri $AC1.M, #0x0050 + 08d0 0083 0520 lri $AR3, #0x0520 + 08d2 02bf 08e8 call 0x08e8 + 08d4 029f 056d jmp 0x056d +} + +void 08d6_Unk() { + 08d6 00d8 0402 lr $AX0.L, @0x0402 + 08d8 8100 clr $ACC0 + 08d9 8900 clr $ACC1 + 08da 00dc 0430 lr $AC0.L, @0x0430 + 08dc 009a 0050 lri $AX0.H, #0x0050 + 08de 9000 mul $AX0.L, $AX0.H + 08df 9400 mulac $AX0.L, $AX0.H, $ACC0 + 08e0 1404 lsl $ACC0, #4 + 08e1 1ffe mrr $AC1.M, $AC0.M + 08e2 0083 0580 lri $AR3, #0x0580 + 08e4 02bf 08e8 call 0x08e8 + 08e6 029f 0565 jmp 0x0565 +} + +void 08e8_Unk() { + 08e8 0092 0004 lri $CR, #0x0004 + 08ea 8100 clr $ACC0 + 08eb 263a lrs $AC0.M, @0x003a + 08ec 243b lrs $AC0.L, @0x003b + 08ed 1f1f mrr $AX0.L, $AC1.M + 08ee 009a 0000 lri $AX0.H, #0x0000 + 08f0 5800 subax $ACC0, $AX0.L + 08f1 0290 0908 jns 0x0908 + 08f3 8900 clr $ACC1 + 08f4 00c0 043b lr $AR0, @0x043b + 08f6 02bf 092d call 0x092d + 08f8 8100 clr $ACC0 + 08f9 1fd8 mrr $AC0.M, $AX0.L + 08fa 223b lrs $AX0.H, @0x003b + 08fb 5400 subr $ACC0, $AX0.H + 08fc 0007 dar $AR3 + 08fd 1979 lrri $AX1.L, @$AR3 + 08fe 005e loop $AC0.M + 08ff 1b79 srri @$AR3, $AX1.L + 0900 009f 0001 lri $AC1.M, #0x0001 + 0902 2f01 srs @0x0001, $AC1.M + 0903 8900 clr $ACC1 + 0904 2f3b srs @0x003b, $AC1.M + 0905 0092 00ff lri $CR, #0x00ff + 0907 02df ret +} + +void 0908_Unk() { + 0908 2e3a srs @0x003a, $AC0.M + 0909 2c3b srs @0x003b, $AC0.L + 090a 8100 clr $ACC0 + 090b 8900 clr $ACC1 + 090c 268a lrs $AC0.M, @0xff8a + 090d 2734 lrs $AC1.M, @0x0034 + 090e 5c00 sub $ACC0, $AC1.L + 090f 2e36 srs @0x0036, $AC0.M + 0910 5000 subr $ACC0, $AX0.L + 0911 0290 0927 jns 0x0927 + 0913 00c0 0436 lr $AR0, @0x0436 + 0915 02bf 092d call 0x092d + 0917 8100 clr $ACC0 + 0918 1fd8 mrr $AC0.M, $AX0.L + 0919 2236 lrs $AX0.H, @0x0036 + 091a 5400 subr $ACC0, $AX0.H + 091b 1c1e mrr $AR0, $AC0.M + 091c 8100 clr $ACC0 + 091d 2e34 srs @0x0034, $AC0.M + 091e 2688 lrs $AC0.M, @0xff88 + 091f 2489 lrs $AC0.L, @0xff89 + 0920 2e8c srs @0xff8c, $AC0.M + 0921 2c8d srs @0xff8d, $AC0.L + 0922 02bf 092d call 0x092d + 0924 0092 00ff lri $CR, #0x00ff + 0926 02df ret +} + +void 0927_Unk() { + 0927 1c18 mrr $AR0, $AX0.L + 0928 02bf 092d call 0x092d + 092a 0092 00ff lri $CR, #0x00ff + 092c 02df ret +} + +void 092d_Unk() { + 092d 8100 clr $ACC0 + 092e 1fc0 mrr $AC0.M, $AR0 + 092f b100 tst $ACC0 + 0930 02d5 retz + 0931 8900 clr $ACC1 + 0932 2734 lrs $AC1.M, @0x0034 + 0933 0340 0001 andi $AC1.M, #0x0001 + 0935 009b 0000 lri $AX1.H, #0x0000 + 0937 1f3f mrr $AX1.L, $AC1.M + 0938 268c lrs $AC0.M, @0xff8c + 0939 248d lrs $AC0.L, @0xff8d + 093a 8900 clr $ACC1 + 093b 2534 lrs $AC1.L, @0x0034 + 093c 1501 lsl $ACC1, #1 + 093d 4c00 add $ACC0, $AC1.L + 093e 5a00 subax $ACC0, $AX1.L + 093f 5a00 subax $ACC0, $AX1.L + 0940 1c20 mrr $AR1, $AR0 + 0941 1fe0 mrr $AC1.M, $AR0 + 0942 0502 addis $ACC1, #0x02 + 0943 1c1f mrr $AR0, $AC1.M + 0944 009f 0a00 lri $AC1.M, #0x0a00 + 0946 0092 00ff lri $CR, #0x00ff + 0948 02bf 007e call 0x007e + 094a 0092 0004 lri $CR, #0x0004 + 094c 2734 lrs $AC1.M, @0x0034 + 094d 1f61 mrr $AX1.H, $AR1 + 094e 4700 addr $ACC1, $AX1.H + 094f 2f34 srs @0x0034, $AC1.M + 0950 0080 0a00 lri $AR0, #0x0a00 + 0952 8900 clr $ACC1 + 0953 1ff9 mrr $AC1.M, $AX1.L + 0954 b900 tst $ACC1 + 0955 0274 ifnz + 0956 0008 iar $AR0 + 0957 8900 clr $ACC1 + 0958 1fe1 mrr $AC1.M, $AR1 + 0959 191e lrri $AC0.M, @$AR0 + 095a 0701 cmpis $ACC1, #0x01 + 095b 0293 0964 jle 0x0964 + 095d 191a lrri $AX0.H, @$AR0 + 095e 05fe addis $ACC1, #0xfe + 095f 005f loop $AC1.M + 0960 64a0 movr'ls $ACC0, $AX0.H : $AX0.H, $AC0.M + 0961 1b7e srri @$AR3, $AC0.M + 0962 1b7a srri @$AR3, $AX0.H + 0963 02df ret +} + +void 0964_Unk() { + 0964 1b7e srri @$AR3, $AC0.M + 0965 02df ret +} + +void 0966_Unk() { + 0966 0092 0004 lri $CR, #0x0004 + 0968 2201 lrs $AX0.H, @0x0001 + 0969 8600 tstaxh $AX0.H + 096a 0294 0997 jnz 0x0997 + 096c 2204 lrs $AX0.H, @0x0004 + 096d 8600 tstaxh $AX0.H + 096e 02b4 09eb callne 0x09eb + 0970 2231 lrs $AX0.H, @0x0031 + 0971 8600 tstaxh $AX0.H + 0972 0295 098c jz 0x098c + 0974 009e 0458 lri $AC0.M, #0x0458 + 0976 4400 addr $ACC0, $AX0.H + 0977 1c1e mrr $AR0, $AC0.M + 0978 0e10 lris $AC0.M, #0x10 + 0979 5400 subr $ACC0, $AX0.H + 097a 1f7e mrr $AX1.H, $AC0.M + 097b 02bf 07c8 call 0x07c8 + 097d d900 cmpar $ACC1, $AX1.H + 097e 0292 098b jg 0x098b + 0980 0295 0987 jz 0x0987 + 0982 2631 lrs $AC0.M, @0x0031 + 0983 4c00 add $ACC0, $AC1.L + 0984 2e31 srs @0x0031, $AC0.M + 0985 029f 09e8 jmp 0x09e8 + 0987 8100 clr $ACC0 + 0988 2e31 srs @0x0031, $AC0.M + 0989 029f 09e8 jmp 0x09e8 + 098b 5700 subr $ACC1, $AX1.H + 098c 8100 clr $ACC0 + 098d 2605 lrs $AC0.M, @0x0005 + 098e b100 tst $ACC0 + 098f 0295 09a8 jz 0x09a8 + 0991 8100 clr $ACC0 + 0992 2e05 srs @0x0005, $AC0.M + 0993 2281 lrs $AX0.H, @0xff81 + 0994 8600 tstaxh $AX0.H + 0995 0294 099e jnz 0x099e + 0997 8100 clr $ACC0 + 0998 005f loop $AC1.M + 0999 1b7e srri @$AR3, $AC0.M + 099a 7400 incm $AC0.M + 099b 2e01 srs @0x0001, $AC0.M + 099c 029f 09e8 jmp 0x09e8 + 099e 2688 lrs $AC0.M, @0xff88 + 099f 2489 lrs $AC0.L, @0xff89 + 09a0 2e34 srs @0x0034, $AC0.M + 09a1 2c35 srs @0x0035, $AC0.L + 09a2 02bf 09f0 call 0x09f0 + 09a4 2682 lrs $AC0.M, @0xff82 + 09a5 2483 lrs $AC0.L, @0xff83 + 09a6 2e67 srs @0x0067, $AC0.M + 09a7 2c66 srs @0x0066, $AC0.L + 09a8 00ff 0360 sr @0x0360, $AC1.M + 09aa 2638 lrs $AC0.M, @0x0038 + 09ab 2439 lrs $AC0.L, @0x0039 + 09ac 009f 0005 lri $AC1.M, #0x0005 + 09ae 02bf 0103 call 0x0103 + 09b0 0092 0004 lri $CR, #0x0004 + 09b2 8900 clr $ACC1 + 09b3 00ff 0362 sr @0x0362, $AC1.M + 09b5 00df 0360 lr $AC1.M, @0x0360 + 09b7 02bf 0a09 call 0x0a09 + 09b9 8100 clr $ACC0 + 09ba 00de 0362 lr $AC0.M, @0x0362 + 09bc 2280 lrs $AX0.H, @0xff80 + 09bd 4400 addr $ACC0, $AX0.H + 09be 00fe 0362 sr @0x0362, $AC0.M + 09c0 8100 clr $ACC0 + 09c1 263a lrs $AC0.M, @0x003a + 09c2 243b lrs $AC0.L, @0x003b + 09c3 0a01 lris $AX0.H, #0x01 + 09c4 0081 0405 lri $AR1, #0x0405 + 09c6 7a00 dec $ACC0 + 09c7 b100 tst $ACC0 + 09c8 0275 ifz + 09c9 1a3a srr @$AR1, $AX0.H + 09ca 2e3a srs @0x003a, $AC0.M + 09cb 2c3b srs @0x003b, $AC0.L + 09cc 0710 cmpis $ACC1, #0x10 + 09cd 0293 09d6 jle 0x09d6 + 09cf 05f0 addis $ACC1, #0xf0 + 09d0 2205 lrs $AX0.H, @0x0005 + 09d1 8600 tstaxh $AX0.H + 09d2 0294 0991 jnz 0x0991 + 09d4 029f 09b7 jmp 0x09b7 + 09d6 0275 ifz + 09d7 8900 clr $ACC1 + 09d8 2f31 srs @0x0031, $AC1.M + 09d9 1fc3 mrr $AC0.M, $AR3 + 09da 04f0 addis $ACC0, #0xf0 + 09db 1c1e mrr $AR0, $AC0.M + 09dc 0083 0458 lri $AR3, #0x0458 + 09de 0e10 lris $AC0.M, #0x10 + 09df 02bf 07c8 call 0x07c8 + 09e1 2638 lrs $AC0.M, @0x0038 + 09e2 2439 lrs $AC0.L, @0x0039 + 09e3 00d8 0362 lr $AX0.L, @0x0362 + 09e5 7000 addaxl $ACC0, $AX0.L + 09e6 2c39 srs @0x0039, $AC0.L + 09e7 2e38 srs @0x0038, $AC0.M + 09e8 0092 00ff lri $CR, #0x00ff + 09ea 02df ret +} + +void 09eb_Unk() { + 09eb 8100 clr $ACC0 + 09ec 2e34 srs @0x0034, $AC0.M + 09ed 2e35 srs @0x0035, $AC0.M + 09ee 2e66 srs @0x0066, $AC0.M + 09ef 2e67 srs @0x0067, $AC0.M + 09f0 2334 lrs $AX1.H, @0x0034 + 09f1 2135 lrs $AX1.L, @0x0035 + 09f2 268a lrs $AC0.M, @0xff8a + 09f3 248b lrs $AC0.L, @0xff8b + 09f4 5a00 subax $ACC0, $AX1.L + 09f5 147c lsr $ACC0, #-4 + 09f6 2e3a srs @0x003a, $AC0.M + 09f7 2c3b srs @0x003b, $AC0.L + 09f8 2634 lrs $AC0.M, @0x0034 + 09f9 2435 lrs $AC0.L, @0x0035 + 09fa 147c lsr $ACC0, #-4 + 09fb 2280 lrs $AX0.H, @0xff80 + 09fc c010 mulc'mv $AC0.M, $AX0.H : $AX0.L, $AC0.L + 09fd 9600 mulmv $AX0.L, $AX0.H, $ACC0 + 09fe f000 lsl16 $ACC0 + 09ff 4e00 addp $ACC0 + 0a00 238c lrs $AX1.H, @0xff8c + 0a01 218d lrs $AX1.L, @0xff8d + 0a02 4a00 addax $ACC0, $AX1.L + 0a03 2e38 srs @0x0038, $AC0.M + 0a04 2c39 srs @0x0039, $AC0.L + 0a05 8100 clr $ACC0 + 0a06 2e05 srs @0x0005, $AC0.M + 0a07 2e31 srs @0x0031, $AC0.M + 0a08 02df ret +} + + +void 0a09_Unk() { + 0a09 00ff 0360 sr @0x0360, $AC1.M + 0a0b 0080 ffd3 lri $AR0, #0xffd3 + 0a0d 0084 0000 lri $IX0, #0x0000 + 0a0f 199e lrrn $AC0.M, @$AR0 + 0a10 1ffe mrr $AC1.M, $AC0.M + 0a11 1401 lsl $ACC0, #1 + 0a12 0240 001e andi $AC0.M, #0x001e + 0a14 0200 0300 addi $AC0.M, #0x0300 + 0a16 1c3e mrr $AR1, $AC0.M + 0a17 157c lsr $ACC1, #-4 + 0a18 0340 000f andi $AC1.M, #0x000f + 0a1a 0a11 lris $AX0.H, #0x11 + 0a1b 5500 subr $ACC1, $AX0.H + 0a1c 009a 00f0 lri $AX0.H, #0x00f0 + 0a1e 009b 000f lri $AX1.H, #0x000f + 0a20 0082 0370 lri $AR2, #0x0370 + 0a22 1998 lrrn $AX0.L, @$AR0 + 0a23 6000 movr $ACC0, $AX0.L + 0a24 1107 0a2b bloopi #0x07, 0x0a2b + 0a26 3400 andr $AC0.M, $AX0.H + 0a27 1408 lsl $ACC0, #8 + 0a28 6032 movr's $ACC0, $AX0.L : @$AR2, $AC0.M + 0a29 3644 andr'ln $AC0.M, $AX1.H : $AX0.L, @$AR0 + 0a2a 140c lsl $ACC0, #12 + 0a2b 6032 movr's $ACC0, $AX0.L : @$AR2, $AC0.M + 0a2c 3400 andr $AC0.M, $AX0.H + 0a2d 1408 lsl $ACC0, #8 + 0a2e 6032 movr's $ACC0, $AX0.L : @$AR2, $AC0.M + 0a2f 3600 andr $AC0.M, $AX1.H + 0a30 140c lsl $ACC0, #12 + 0a31 1b5e srri @$AR2, $AC0.M + 0a32 8f00 set40 + 0a33 1f7f mrr $AX1.H, $AC1.M + 0a34 2066 lrs $AX0.L, @0x0066 + 0a35 2767 lrs $AC1.M, @0x0067 + 0a36 193a lrri $AX0.H, @$AR1 + 0a37 1939 lrri $AX1.L, @$AR1 + 0a38 0080 0370 lri $AR0, #0x0370 + 0a3a 1c80 mrr $IX0, $AR0 + 0a3b a000 mulx $AX0.L, $AX1.L + 0a3c ea70 maddc'l $AC1.M, $AX1.L : $AC0.M, @$AR0 + 0a3d 3a93 orr'sl $AC0.M, $AX1.H : $AC1.M, $AX1.L + 0a3e a478 mulxac'l $AX0.L, $AX1.L, $ACC0 : $AC1.M, @$AR0 + 0a3f 1485 asl $ACC0, #5 + 0a40 e833 maddc's $AC0.M, $AX1.L : @$AR3, $AC0.M + 0a41 3b92 orr'sl $AC1.M, $AX1.H : $AC0.M, $AX1.L + 0a42 a570 mulxac'l $AX0.L, $AX1.L, $ACC1 : $AC0.M, @$AR0 + 0a43 1585 asl $ACC1, #5 + 0a44 ea3b maddc's $AC1.M, $AX1.L : @$AR3, $AC1.M + 0a45 1106 0a4e bloopi #0x06, 0x0a4e + 0a47 3a93 orr'sl $AC0.M, $AX1.H : $AC1.M, $AX1.L + 0a48 a478 mulxac'l $AX0.L, $AX1.L, $ACC0 : $AC1.M, @$AR0 + 0a49 1485 asl $ACC0, #5 + 0a4a e833 maddc's $AC0.M, $AX1.L : @$AR3, $AC0.M + 0a4b 3b92 orr'sl $AC1.M, $AX1.H : $AC0.M, $AX1.L + 0a4c a570 mulxac'l $AX0.L, $AX1.L, $ACC1 : $AC0.M, @$AR0 + 0a4d 1585 asl $ACC1, #5 + 0a4e ea3b maddc's $AC1.M, $AX1.L : @$AR3, $AC1.M + 0a4f 3a93 orr'sl $AC0.M, $AX1.H : $AC1.M, $AX1.L + 0a50 a478 mulxac'l $AX0.L, $AX1.L, $ACC0 : $AC1.M, @$AR0 + 0a51 1485 asl $ACC0, #5 + 0a52 e833 maddc's $AC0.M, $AX1.L : @$AR3, $AC0.M + 0a53 3b92 orr'sl $AC1.M, $AX1.H : $AC0.M, $AX1.L + 0a54 a500 mulxac $AX0.L, $AX1.L, $ACC1 + 0a55 1585 asl $ACC1, #5 + 0a56 1b7f srri @$AR3, $AC1.M + 0a57 2e66 srs @0x0066, $AC0.M + 0a58 2f67 srs @0x0067, $AC1.M + 0a59 8e00 set16 + 0a5a 8900 clr $ACC1 + 0a5b 00df 0360 lr $AC1.M, @0x0360 + 0a5d 02df ret +} + +void 0a5e_Unk() { + 0a5e 0083 0520 lri $AR3, #0x0520 + 0a60 00de 0433 lr $AC0.M, @0x0433 + 0a62 1050 loopi #0x50 + 0a63 1b7e srri @$AR3, $AC0.M + 0a64 029f 056d jmp 0x056d + 0a66 0092 0004 lri $CR, #0x0004 + 0a68 2002 lrs $AX0.L, @0x0002 + 0a69 8100 clr $ACC0 + 0a6a 8900 clr $ACC1 + 0a6b 2430 lrs $AC0.L, @0x0030 + 0a6c 8d00 set15 + 0a6d 0099 0050 lri $AX1.L, #0x0050 + 0a6f a000 mulx $AX0.L, $AX1.L + 0a70 a400 mulxac $AX0.L, $AX1.L, $ACC0 + 0a71 1404 lsl $ACC0, #4 + 0a72 8c00 clr15 + 0a73 1ffe mrr $AC1.M, $AC0.M + 0a74 0083 0580 lri $AR3, #0x0580 + 0a76 2201 lrs $AX0.H, @0x0001 + 0a77 8600 tstaxh $AX0.H + 0a78 0294 0a89 jnz 0x0a89 + 0a7a 2204 lrs $AX0.H, @0x0004 + 0a7b 8600 tstaxh $AX0.H + 0a7c 02b4 0ad2 callne 0x0ad2 + 0a7e 8100 clr $ACC0 + 0a7f 2605 lrs $AC0.M, @0x0005 + 0a80 b100 tst $ACC0 + 0a81 0295 0a96 jz 0x0a96 + 0a83 8100 clr $ACC0 + 0a84 2e05 srs @0x0005, $AC0.M + 0a85 2281 lrs $AX0.H, @0xff81 + 0a86 8600 tstaxh $AX0.H + 0a87 0294 0a90 jnz 0x0a90 + 0a89 8100 clr $ACC0 + 0a8a 005f loop $AC1.M + 0a8b 1b7e srri @$AR3, $AC0.M + 0a8c 7400 incm $AC0.M + 0a8d 2e01 srs @0x0001, $AC0.M + 0a8e 029f 0ace jmp 0x0ace + 0a90 2688 lrs $AC0.M, @0xff88 + 0a91 2489 lrs $AC0.L, @0xff89 + 0a92 2e34 srs @0x0034, $AC0.M + 0a93 2c35 srs @0x0035, $AC0.L + 0a94 02bf 0ad5 call 0x0ad5 + 0a96 00ff 0360 sr @0x0360, $AC1.M + 0a98 2638 lrs $AC0.M, @0x0038 + 0a99 2439 lrs $AC0.L, @0x0039 + 0a9a 009f 0005 lri $AC1.M, #0x0005 + 0a9c 02bf 0103 call 0x0103 + 0a9e 0092 0004 lri $CR, #0x0004 + 0aa0 00df 0360 lr $AC1.M, @0x0360 + 0aa2 8100 clr $ACC0 + 0aa3 263a lrs $AC0.M, @0x003a + 0aa4 b100 tst $ACC0 + 0aa5 0294 0ab5 jnz 0x0ab5 + 0aa7 263b lrs $AC0.M, @0x003b + 0aa8 5c00 sub $ACC0, $AC1.L + 0aa9 0290 0ab5 jns 0x0ab5 + 0aab 223b lrs $AX0.H, @0x003b + 0aac 02bf 0ae6 call 0x0ae6 + 0aae 5500 subr $ACC1, $AX0.H + 0aaf 009a 0001 lri $AX0.H, #0x0001 + 0ab1 00fa 0405 sr @0x0405, $AX0.H + 0ab3 029f 0a83 jmp 0x0a83 + 0ab5 1f5f mrr $AX0.H, $AC1.M + 0ab6 02bf 0ae6 call 0x0ae6 + 0ab8 00fa 0362 sr @0x0362, $AX0.H + 0aba 8100 clr $ACC0 + 0abb 263a lrs $AC0.M, @0x003a + 0abc 243b lrs $AC0.L, @0x003b + 0abd 1570 lsr $ACC1, #-16 + 0abe 0a01 lris $AX0.H, #0x01 + 0abf 0081 0405 lri $AR1, #0x0405 + 0ac1 5c00 sub $ACC0, $AC1.L + 0ac2 b100 tst $ACC0 + 0ac3 0275 ifz + 0ac4 1a3a srr @$AR1, $AX0.H + 0ac5 2e3a srs @0x003a, $AC0.M + 0ac6 2c3b srs @0x003b, $AC0.L + 0ac7 2638 lrs $AC0.M, @0x0038 + 0ac8 2439 lrs $AC0.L, @0x0039 + 0ac9 00d8 0362 lr $AX0.L, @0x0362 + 0acb 7000 addaxl $ACC0, $AX0.L + 0acc 2c39 srs @0x0039, $AC0.L + 0acd 2e38 srs @0x0038, $AC0.M + 0ace 0092 00ff lri $CR, #0x00ff + 0ad0 029f 0565 jmp 0x0565 + 0ad2 8100 clr $ACC0 + 0ad3 2e34 srs @0x0034, $AC0.M + 0ad4 2e35 srs @0x0035, $AC0.M + 0ad5 2334 lrs $AX1.H, @0x0034 + 0ad6 2135 lrs $AX1.L, @0x0035 + 0ad7 268a lrs $AC0.M, @0xff8a + 0ad8 248b lrs $AC0.L, @0xff8b + 0ad9 5a00 subax $ACC0, $AX1.L + 0ada 2e3a srs @0x003a, $AC0.M + 0adb 2c3b srs @0x003b, $AC0.L + 0adc 2634 lrs $AC0.M, @0x0034 + 0add 2435 lrs $AC0.L, @0x0035 + 0ade 238c lrs $AX1.H, @0xff8c + 0adf 218d lrs $AX1.L, @0xff8d + 0ae0 4a00 addax $ACC0, $AX1.L + 0ae1 2e38 srs @0x0038, $AC0.M + 0ae2 2c39 srs @0x0039, $AC0.L + 0ae3 8100 clr $ACC0 + 0ae4 2e05 srs @0x0005, $AC0.M + 0ae5 02df ret +} + +void 0ae6_ConvSigned8bitToSigned16bit() { + 0ae6 0080 ffd3 lri $AR0, #0xffd3 + 0ae8 0084 0000 lri $IX0, #0x0000 + 0aea 007a 0aee bloop $AX0.H, 0x0aee + 0aec 199e lrrn $AC0.M, @$AR0 + 0aed 1488 asl $ACC0, #8 + 0aee 1b7e srri @$AR3, $AC0.M + 0aef 02df ret +} + +void 0af0_Unk() { + 0af0 009e ffff lri $AC0.M, #0xffff + 0af2 00fe 03f2 sr @0x03f2, $AC0.M + 0af4 8100 clr $ACC0 + 0af5 00fe 03f0 sr @0x03f0, $AC0.M + 0af7 00fe 03f6 sr @0x03f6, $AC0.M + 0af9 009e 0100 lri $AC0.M, #0x0100 + 0afb 00fe 03f7 sr @0x03f7, $AC0.M + 0afd 00da 03f7 lr $AX0.H, @0x03f7 + 0aff 009e 8000 lri $AC0.M, #0x8000 + 0b01 5400 subr $ACC0, $AX0.H + 0b02 00fe 03f5 sr @0x03f5, $AC0.M + 0b04 009e 0030 lri $AC0.M, #0x0030 + 0b06 00fe 03f3 sr @0x03f3, $AC0.M + 0b08 009e 0010 lri $AC0.M, #0x0010 + 0b0a 00fe 03f4 sr @0x03f4, $AC0.M + 0b0c 009e 0096 lri $AC0.M, #0x0096 + 0b0e 00fe 03f1 sr @0x03f1, $AC0.M + 0b10 02df ret +} + +void 0b11_Unk() { + 0b11 0080 0b00 lri $AR0, #0x0b00 + 0b13 8100 clr $ACC0 + 0b14 00de 03f0 lr $AC0.M, @0x03f0 + 0b16 8900 clr $ACC1 + 0b17 b100 tst $ACC0 + 0b18 0275 ifz + 0b19 0550 addis $ACC1, #0x50 + 0b1a 00ff 03f0 sr @0x03f0, $AC1.M + 0b1c 0200 0b60 addi $AC0.M, #0x0b60 + 0b1e 1c7e mrr $AR3, $AC0.M + 0b1f 009f 004e lri $AC1.M, #0x004e + 0b21 02bf 03ac call 0x03ac + 0b23 02df ret +} + +void 0b24_Unk() { + + 0b24 00de 03f1 lr $AC0.M, @0x03f1 + 0b26 0200 0b60 addi $AC0.M, #0x0b60 + 0b28 1c7e mrr $AR3, $AC0.M + 0b29 8100 clr $ACC0 + 0b2a 8900 clr $ACC1 + 0b2b 009f 00a0 lri $AC1.M, #0x00a0 + 0b2d 00de 03f1 lr $AC0.M, @0x03f1 + 0b2f 5d00 sub $ACC1, $AC0.L + 0b30 009e 0050 lri $AC0.M, #0x0050 + 0b32 0750 cmpis $ACC1, #0x50 + 0b33 0270 ifns + 0b34 5d00 sub $ACC1, $AC0.L + 0b35 00da 03f2 lr $AX0.H, @0x03f2 + 0b37 8600 tstaxh $AX0.H + 0b38 0290 0b56 jns 0x0b56 + 0b3a 00de 03f3 lr $AC0.M, @0x03f3 + 0b3c 5c00 sub $ACC0, $AC1.L + 0b3d 0293 0b41 jle 0x0b41 + 0b3f 029f 0b5b jmp 0x0b5b + 0b41 00db 03f7 lr $AX1.H, @0x03f7 + 0b43 009e 8000 lri $AC0.M, #0x8000 + 0b45 4600 addr $ACC0, $AX1.H + 0b46 029f 0b4d jmp 0x0b4d + 0b48 00db 03f7 lr $AX1.H, @0x03f7 + 0b4a 009e 8000 lri $AC0.M, #0x8000 + 0b4c 5600 subr $ACC0, $AX1.H + 0b4d 00fe 03f5 sr @0x03f5, $AC0.M + 0b4f 1fda mrr $AC0.M, $AX0.H + 0b50 7c00 neg $ACC0 + 0b51 1f5e mrr $AX0.H, $AC0.M + 0b52 00fe 03f2 sr @0x03f2, $AC0.M + 0b54 029f 0b5b jmp 0x0b5b + 0b56 00de 03f4 lr $AC0.M, @0x03f4 + 0b58 5d00 sub $ACC1, $AC0.L + 0b59 0293 0b48 jle 0x0b48 + 0b5b 8900 clr $ACC1 + 0b5c 00dd 03f5 lr $AC1.L, @0x03f5 + 0b5e 1501 lsl $ACC1, #1 + 0b5f 8100 clr $ACC0 + 0b60 00dc 03f6 lr $AC0.L, @0x03f6 + 0b62 008b 009f lri $WR3, #0x009f + 0b64 0080 0b00 lri $AR0, #0x0b00 + 0b66 0099 0000 lri $AX1.L, #0x0000 + 0b68 1150 0b6f bloopi #0x50, 0x0b6f + 0b6a 1878 lrr $AX0.L, @$AR3 + 0b6b 4c00 add $ACC0, $AC1.L + 0b6c 1cfe mrr $IX3, $AC0.M + 0b6d 001f addarn $AR3, $IX3 + 0b6e 1fd9 mrr $AC0.M, $AX1.L + 0b6f 1b18 srri @$AR0, $AX0.L + 0b70 009f 0b60 lri $AC1.M, #0x0b60 + 0b72 1fc3 mrr $AC0.M, $AR3 + 0b73 5c00 sub $ACC0, $AC1.L + 0b74 00fe 03f1 sr @0x03f1, $AC0.M + 0b76 00fc 03f6 sr @0x03f6, $AC0.L + 0b78 008b ffff lri $WR3, #0xffff + 0b7a 02df ret +} + +void 0b7b_Unk() { + 0b7b 009f 0050 lri $AC1.M, #0x0050 + 0b7d 0080 0b00 lri $AR0, #0x0b00 + 0b7f 0083 0d60 lri $AR3, #0x0d60 + 0b81 0098 3fff lri $AX0.L, #0x3fff + 0b83 02bf 03bd call 0x03bd + 0b85 009f 0050 lri $AC1.M, #0x0050 + 0b87 0080 0b00 lri $AR0, #0x0b00 + 0b89 0083 0d00 lri $AR3, #0x0d00 + 0b8b 0098 3fff lri $AX0.L, #0x3fff + 0b8d 02bf 03bd call 0x03bd + 0b8f 02df ret +} + +void 0b90_Unk() { + 0b90 8a00 m2 + 0b91 8f00 set40 + 0b92 8100 clr $ACC0 + 0b93 00de 0404 lr $AC0.M, @0x0404 + 0b95 b100 tst $ACC0 + 0b96 0295 0b9d jz 0x0b9d + 0b98 8100 clr $ACC0 + 0b99 00fe 0478 sr @0x0478, $AC0.M + 0b9b 00fe 0479 sr @0x0479, $AC0.M + 0b9d 00df 0479 lr $AC1.M, @0x0479 + 0b9f 00db 0478 lr $AX1.H, @0x0478 + 0ba1 0099 0000 lri $AX1.L, #0x0000 + 0ba3 0084 0000 lri $IX0, #0x0000 + 0ba5 1150 0bae bloopi #0x50, 0x0bae + 0ba7 199e lrrn $AC0.M, @$AR0 + 0ba8 5c7c sub'ln $ACC0, $AC1.L : $AC1.M, @$AR0 + 0ba9 c000 mulc $AC0.M, $AX0.H + 0baa 6e00 movp $ACC0 + 0bab 1488 asl $ACC0, #8 + 0bac 4a00 addax $ACC0, $AX1.L + 0bad 1b1e srri @$AR0, $AC0.M + 0bae 1f7e mrr $AX1.H, $AC0.M + 0baf 00fb 0478 sr @0x0478, $AX1.H + 0bb1 00ff 0479 sr @0x0479, $AC1.M + 0bb3 8b00 m0 + 0bb4 8e00 set16 + 0bb5 02df ret +} + +void 0bb6_Unk() { + 0bb6 0080 01be lri $AR0, #0x01be + 0bb8 1918 lrri $AX0.L, @$AR0 + 0bb9 191a lrri $AX0.H, @$AR0 + 0bba 0080 0180 lri $AR0, #0x0180 + 0bbc 0083 0180 lri $AR3, #0x0180 + 0bbe 9070 mul'l $AX0.L, $AX0.H : $AC0.M, @$AR0 + 0bbf 1ffe mrr $AC1.M, $AC0.M + 0bc0 1120 0bc7 bloopi #0x20, 0x0bc7 + 0bc2 7c00 neg $ACC0 + 0bc3 d450 mulcac'l $AC1.M, $AX0.H, $ACC0 : $AX0.H, @$AR0 + 0bc4 6533 movr's $ACC1, $AX0.H : @$AR3, $AC0.M + 0bc5 c550 mulcac'l $AC0.M, $AX0.H, $ACC1 : $AX0.H, @$AR0 + 0bc6 1501 lsl $ACC1, #1 + 0bc7 643b movr's $ACC0, $AX0.H : @$AR3, $AC1.M + 0bc8 0080 01fe lri $AR0, #0x01fe + 0bca 191a lrri $AX0.H, @$AR0 + 0bcb 1918 lrri $AX0.L, @$AR0 + 0bcc 0080 01c0 lri $AR0, #0x01c0 + 0bce 0083 01c0 lri $AR3, #0x01c0 + 0bd0 1ff8 mrr $AC1.M, $AX0.L + 0bd1 9070 mul'l $AX0.L, $AX0.H : $AC0.M, @$AR0 + 0bd2 f800 addpaxz $ACC0, $AX0.H + 0bd3 0240 01ff andi $AC0.M, #0x01ff + 0bd5 0260 2000 ori $AC0.M, #0x2000 + 0bd7 02bf 0bda call 0x0bda + 0bd9 02df ret +} + +void 0bda_Unk() { + 0bda b900 tst $ACC1 + 0bdb 0272 ifg + 0bdc 7c00 neg $ACC0 + 0bdd 1f7e mrr $AX1.H, $AC0.M + 0bde 4700 addr $ACC1, $AX1.H + 0bdf 1110 0be4 bloopi #0x10, 0x0be4 + 0be1 473b addr's $ACC1, $AX1.H : @$AR3, $AC1.M + 0be2 473b addr's $ACC1, $AX1.H : @$AR3, $AC1.M + 0be3 473b addr's $ACC1, $AX1.H : @$AR3, $AC1.M + 0be4 473b addr's $ACC1, $AX1.H : @$AR3, $AC1.M + 0be5 02df ret +} + +void 0be6_Nop() { + 0be6 0000 nop + 0be7 0000 nop + 0be8 0000 nop + 0be9 0000 nop + 0bea 0000 nop + 0beb 0000 nop + 0bec 0000 nop + 0bed 0000 nop + 0bee 0000 nop + 0bef 0000 nop +} \ No newline at end of file diff --git a/docs/DSP/DSP_UC_Zelda.txt b/docs/DSP/DSP_UC_Zelda.txt index 59e71ef38f..733b922793 100644 --- a/docs/DSP/DSP_UC_Zelda.txt +++ b/docs/DSP/DSP_UC_Zelda.txt @@ -6,7 +6,7 @@ can parse this file and auto read symbols using those. BIG Questions: - - Who resets the 0x0350 to the beginning of the command block? + - Who resets the 0x0350 to the beginning of the command block? Wrap register? - What does 00eb_Unk_BufferMultWithDest?? - Why is a PB-Transfer from RAM to DMEM 0xC0 shorts long but DMEM to RAM just 0x80 @@ -170,6 +170,7 @@ There's definitely a bunch of sample data stored in each PB but I don't know exa 000c 02ff rti 000d 0000 nop 000e 029f 05b8 jmp 0x05b8 -> 05b8_NewMail() + 0010 029f 004e jmp 0x004e -> 004e_ContinueUCode() ??? // reset vector @@ -220,7 +221,7 @@ void 0012_ResetVector() // 002a 00fe 034e sr @0x034e, $AC0.M *0x034e = 0x00 - # 002c 1305 sbset #0x05 + 002c 1305 sbset #0x05 // 002d 029f 06c5 jmp 0x06c5 @@ -251,12 +252,10 @@ void 0012_ResetVector() upperCommand = (upperCommand >> 7) & 0x7e // F|RES: i think duddy is wrong here ... a negative must be a shift right *0x0343 = upperCommand - /* - 003f 0200 0075 addi $AC0.M, #0x0075 - 0041 1c1e mrr $AR0, $AC0.M - 0042 170f jmpr $AR0 - switch casement of the commands.. jump table is at 0075 - */ + // 003f 0200 0075 addi $AC0.M, #0x0075 + // 0041 1c1e mrr $AR0, $AC0.M + // 0042 170f jmpr $AR0 + // switch casement of the commands.. jump table is at 0075 switch (upperCommand >> 1) // command must be shift >> 1 in our source code because the jump table is aligned with 2 Bytes { @@ -319,14 +318,18 @@ void 0057_InitHardware() 005b 8e00 set16 005c 8c00 clr15 005d 8b00 m0 + + // Set all indexing wrappers to max range. 005e 009e ffff lri $AC0.M, #0xffff 0060 1d1e mrr $WR0, $AC0.M 0061 1d3e mrr $WR1, $AC0.M 0062 1d5e mrr $WR2, $AC0.M 0063 1d7e mrr $WR3, $AC0.M + + // Have CR point to the HW interface. 0064 0092 00ff lri $CR, #0x00ff - 0066 02df ret -} + // 0066 02df ret +} void 0067_CopyCommand(_destAddr($AR0), _loopCount($AC0.M)) { @@ -597,13 +600,16 @@ void 0127_Unk() { 0135 0508 addis $ACC1, #0x08 0136 02bf 0525 call 0x0525 // 0525_CopyRAMtoDMEM // 0525_CopyRAMtoDMEM(... ,.. , 0x50) - 0138 00de 0390 lr $AC0.M, @0x0390 - 013a 02a0 0001 andf $AC0.M, #0x0001 - 013c 029d 0145 jlz 0x0145 - 013e 0080 0398 lri $AR0, #0x0398 - 0140 0e08 lris $AC0.M, #0x08 - 0141 00c1 03a1 lr $AR1, @0x03a1 - 0143 02bf 0b2e call 0x0b2e // 0b2e_Unk_Multiply + + // 0138 00de 0390 lr $AC0.M, @0x0390 + // 013a 02a0 0001 andf $AC0.M, #0x0001 + // 013c 029d 0145 jlz 0x0145 + if (*0x0390 & 1) { + 013e 0080 0398 lri $AR0, #0x0398 + 0140 0e08 lris $AC0.M, #0x08 + 0141 00c1 03a1 lr $AR1, @0x03a1 + 0143 02bf 0b2e call 0x0b2e // 0b2e_Unk_Multiply + } 0145 0f50 lris $AC1.M, #0x50 0146 00c0 03a1 lr $AR0, @0x03a1 0148 00da 0394 lr $AX0.H, @0x0394 @@ -619,12 +625,16 @@ void 0127_Unk() { 0155 00da 0396 lr $AX0.H, @0x0396 0157 8600 tstaxh $AX0.H 0158 0295 015f jz 0x015f - 015a 1c7a mrr $AR3, $AX0.H - 015b 00d8 0397 lr $AX0.L, @0x0397 - 015d 02bf 00eb call 0x00eb // 00eb_Unk_BufferMultWithDest - 015f 00de 0390 lr $AC0.M, @0x0390 - 0161 02a0 0002 andf $AC0.M, #0x0002 - 0163 02dd retlz + 015a 1c7a mrr $AR3, $AX0.H + 015b 00d8 0397 lr $AX0.L, @0x0397 + 015d 02bf 00eb call 0x00eb // 00eb_Unk_BufferMultWithDest + + // 015f 00de 0390 lr $AC0.M, @0x0390 + // 0161 02a0 0002 andf $AC0.M, #0x0002 + // 0163 02dd retlz + if (*0x390 & 2) + return; + 0164 0080 0398 lri $AR0, #0x0398 0166 0e08 lris $AC0.M, #0x08 0167 00c1 03a1 lr $AR1, @0x03a1 @@ -1089,56 +1099,56 @@ void 0243_COMMAND_02() // sync frame // A block of audio is now present at 0x520. ContinueWithBlock: - // 02d8 00da 04a8 lr $AX0.H, @0x04a8 - // 02da 8600 tstaxh $AX0.H - // 02db 0295 02e1 jz 0x02e1 - // 02dd 0080 0520 lri $AR0, #0x0520 - // 02df 02bf 0c84 call 0x0c84 - - if (0x04a8 != 0) + // 02d8 00da 04a8 lr $AX0.H, @0x04a8 + // 02da 8600 tstaxh $AX0.H + // 02db 0295 02e1 jz 0x02e1 + // 02dd 0080 0520 lri $AR0, #0x0520 + // 02df 02bf 0c84 call 0x0c84 + + if (0x04a8 != 0) 0c84_ModifySample(0x0520) - - // 02e1 009e 0520 lri $AC0.M, #0x0520 - // 02e3 00fe 038f sr @0x038f, $AC0.M - *0x038f = 0x0520 + + // 02e1 009e 0520 lri $AC0.M, #0x0520 + // 02e3 00fe 038f sr @0x038f, $AC0.M + *0x038f = 0x0520 - // 02e5 8900 clr $ACC1 - // 02e6 00df 0484 lr $AC1.M, @0x0484 - // 02e8 0340 001f andi $AC1.M, #0x001f - // 02ea b900 tst $ACC1 - // 02eb 0295 0311 jz 0x0311 - if ((*0x0484 & 0x1f) != 0x00) - { - // 02ed 00de 038f lr $AC0.M, @0x038f - // 02ef 5c00 sub $ACC0, $AC1.L - // 02f0 00fe 038f sr @0x038f, $AC0.M - (*0x038f) -= AC1.L; // where did AC1.L get its value? should be 0, unless sub is wrong? - - // 02f2 1c7e mrr $AR3, $AC0.M - // 02f3 0080 0440 lri $AR0, #0x0440 - // 02f5 05fe addis $ACC1, #0xfe - // 02f6 02bf 00da call 0x00da - 00da_CopyBuffer(0x0440, (*0x038f), (*0x0484) + 0xfe) - - // 02f8 0080 0490 lri $AR0, #0x0490 - // 02fa 00c1 038f lr $AR1, @0x038f - // 02fc 8900 clr $ACC1 - // 02fd 00df 0484 lr $AC1.M, @0x0484 - // 02ff 0340 001f andi $AC1.M, #0x001f - // 0301 02bf 0b4d call 0x0b4d - 0b4d_IIR_Filter(In(0x0490), Out(*0x038f), FilterLength(*0x0484 & 0x1f)) - - 0303 00de 038f lr $AC0.M, @0x038f - 0305 0450 addis $ACC0, #0x50 - 0306 1c1e mrr $AR0, $AC0.M - // 0307 0083 0440 lri $AR3, #0x0440 - 0309 8900 clr $ACC1 - 030a 00df 0484 lr $AC1.M, @0x0484 - 030c 0340 001f andi $AC1.M, #0x001f - 030e 05fe addis $ACC1, #0xfe - // 030f 02bf 00da call 0x00da - 00da_CopyBuffer(, 0x0440) - } + // 02e5 8900 clr $ACC1 + // 02e6 00df 0484 lr $AC1.M, @0x0484 + // 02e8 0340 001f andi $AC1.M, #0x001f + // 02ea b900 tst $ACC1 + // 02eb 0295 0311 jz 0x0311 + if ((*0x0484 & 0x1f) != 0x00) + { + // 02ed 00de 038f lr $AC0.M, @0x038f + // 02ef 5c00 sub $ACC0, $AC1.L + // 02f0 00fe 038f sr @0x038f, $AC0.M + (*0x038f) -= AC1.L; // where did AC1.L get its value? should be 0, unless sub is wrong? + + // 02f2 1c7e mrr $AR3, $AC0.M + // 02f3 0080 0440 lri $AR0, #0x0440 + // 02f5 05fe addis $ACC1, #0xfe + // 02f6 02bf 00da call 0x00da + 00da_CopyBuffer(0x0440, (*0x038f), (*0x0484) + 0xfe) + + // 02f8 0080 0490 lri $AR0, #0x0490 + // 02fa 00c1 038f lr $AR1, @0x038f + // 02fc 8900 clr $ACC1 + // 02fd 00df 0484 lr $AC1.M, @0x0484 + // 02ff 0340 001f andi $AC1.M, #0x001f + // 0301 02bf 0b4d call 0x0b4d + 0b4d_IIR_Filter(In(0x0490), Out(*0x038f), FilterLength(*0x0484 & 0x1f)) + + 0303 00de 038f lr $AC0.M, @0x038f + 0305 0450 addis $ACC0, #0x50 + 0306 1c1e mrr $AR0, $AC0.M + // 0307 0083 0440 lri $AR3, #0x0440 + 0309 8900 clr $ACC1 + 030a 00df 0484 lr $AC1.M, @0x0484 + 030c 0340 001f andi $AC1.M, #0x001f + 030e 05fe addis $ACC1, #0xfe + // 030f 02bf 00da call 0x00da + 00da_CopyBuffer(, 0x0440) + } // 0311 00de 0484 lr $AC0.M, @0x0484 // 0313 0240 0020 andi $AC0.M, #0x0020 @@ -2182,18 +2192,25 @@ void 0688_InitCommandBlock() 0694 00e8 03fc sr @0x03fc, $WR0 0696 00c0 0350 lr $AR0, @0x0350 0698 0088 002f lri $WR0, #0x002f - 069a 1b1a srri @$AR0, $AX0.H - 069b 00de fffe lr $AC0.M, @CMBH - 069d 02c0 8000 andcf $AC0.M, #0x8000 - 069f 029c 069b jlnz 0x069b - 06a1 00dc ffff lr $AC0.L, @CMBL - 06a3 1b1e srri @$AR0, $AC0.M - 06a4 1b1c srri @$AR0, $AC0.L - 06a5 1fda mrr $AC0.M, $AX0.H - 06a6 7800 decm $AC0.M - 06a7 1f5e mrr $AX0.H, $AC0.M - 06a8 8600 tstaxh $AX0.H - 06a9 0294 069b jnz 0x069b + + do { + 069a 1b1a srri @$AR0, $AX0.H + + // 069b 00de fffe lr $AC0.M, @CMBH + // 069d 02c0 8000 andcf $AC0.M, #0x8000 + // 069f 029c 069b jlnz 0x069b + while (!CMBH & 0x8000) + ; + 06a1 00dc ffff lr $AC0.L, @CMBL + 06a3 1b1e srri @$AR0, $AC0.M + 06a4 1b1c srri @$AR0, $AC0.L + 06a5 1fda mrr $AC0.M, $AX0.H + 06a6 7800 decm $AC0.M + 06a7 1f5e mrr $AX0.H, $AC0.M + + // 06a8 8600 tstaxh $AX0.H + // 06a9 0294 069b jnz 0x069b + } while (AX0.H); /* 06ab 8100 clr $ACC0 @@ -2213,6 +2230,7 @@ void 0688_InitCommandBlock() GOTO EndOfMailException // return values and leave exception // looks like a read from ring buffer [0x350, 0x37f] + // note the use of the wrap register WR0. 06b9 00e0 03fb sr @0x03fb, $AR0 06bb 00e8 03fc sr @0x03fc, $WR0 06bd 00c0 0350 lr $AR0, @0x0350 @@ -2260,16 +2278,14 @@ void 06c5_CopyCommandBlock() // 06d6 0081 0356 lri $AR1, #0x0356 short destCommandQueueAddr = 0x0356 - /* - 06d8 191e lrri $AC0.M, @$AR0 - 06d9 02c0 8000 andcf $AC0.M, #0x8000 - 06db 029d 06f1 jlz 0x06f1 - 06dd 1f5e mrr $AX0.H, $AC0.M - 06de 8600 tstaxh $AX0.H - 06df 0295 06f5 jz 0x06f5 + // 06d8 191e lrri $AC0.M, @$AR0 + // 06d9 02c0 8000 andcf $AC0.M, #0x8000 + // 06db 029d 06f1 jlz 0x06f1 + // 06dd 1f5e mrr $AX0.H, $AC0.M + // 06de 8600 tstaxh $AX0.H + // 06df 0295 06f5 jz 0x06f5 // check if command is valid - */ short numCommands = *srcCommandQueueAddr++ numCommands &= 0x8000 @@ -2333,8 +2349,11 @@ void 06f9_Unk_PrepareSampleDecode() 06f9 8100 clr $ACC0 06fa 0e10 lris $AC0.M, #0x10 06fb 2232 lrs $AX0.H, @0x0032 - 06fc 8600 tstaxh $AX0.H - 06fd 02d5 retz + // 06fc 8600 tstaxh $AX0.H + // 06fd 02d5 retz + if (!*0x0432) + return; + 06fe 5400 subr $ACC0, $AX0.H 06ff 0200 0458 addi $AC0.M, #0x0458 0701 1c1e mrr $AR0, $AC0.M @@ -2342,18 +2361,21 @@ void 06f9_Unk_PrepareSampleDecode() 0703 04fe addis $ACC0, #0xfe 0704 1f1e mrr $AX0.L, $AC0.M 0705 191e lrri $AC0.M, @$AR0 - 0706 0291 070c js 0x070c - 0708 191a lrri $AX0.H, @$AR0 - 0709 0058 loop $AX0.L - 070a 64a0 movr'ls $ACC0, $AX0.H : $AX0.H, $AC0.M - 070b 6433 movr's $ACC0, $AX0.H : @$AR3, $AC0.M + // 0706 0291 070c js 0x070c + if ( .. ?? ..) { + 0708 191a lrri $AX0.H, @$AR0 + // Copy-loop + 0709 0058 loop $AX0.L + 070a 64a0 movr'ls $ACC0, $AX0.H : $AX0.H, $AC0.M + 070b 6433 movr's $ACC0, $AX0.H : @$AR3, $AC0.M + } 070c 1b7e srri @$AR3, $AC0.M 070d 02df ret } // early out for 073d_DECODE_0x05_0x09 - { +void EarlyOutFrom_073d_DECODE_0x05_0x09() { //070e 02bf 06f9 call 0x06f9 06f9_Unk_PrepareSampleDecode() 0710 8100 clr $ACC0 @@ -3501,7 +3523,7 @@ void 0af6_Unk() { 0b1d 0274 ifnz if (ACC1) { 0b1e 0008 iar $AR0 - } + } 0b1f 8900 clr $ACC1 0b20 1fe1 mrr $AC1.M, $AR1 0b21 191e lrri $AC0.M, @$AR0 @@ -3522,7 +3544,7 @@ void 0af6_Unk() { } -void 0b2e_Unk_Multiply() { +void 0b2e_Unk_Multiply() { // ZWW: 01c2_Unk 0b2e 8a00 m2 0b2f 0083 03e8 lri $AR3, #0x03e8 0b31 191e lrri $AC0.M, @$AR0 diff --git a/docs/DSP/prefix_replace.py b/docs/DSP/prefix_replace.py new file mode 100644 index 0000000000..5c2c80f11a --- /dev/null +++ b/docs/DSP/prefix_replace.py @@ -0,0 +1,45 @@ +# this can be used to upgrade disassemblies that aren't too annotated. +# won't do very well on the current zelda disasm. + +import os +import sys + +def GetPrefixLine(l, a): + for s in a: + if s[0:len(l)] == l: + return s + return "" + +def GetComment(l): + comment_start = l.find("//") + if comment_start < 0: + comment_start = l.find("->") + if comment_start < 0: + return "" + + while (l[comment_start-1] == ' ') or (l[comment_start-1] == '\t'): + comment_start -= 1 + + return l[comment_start:] + + +def main(): + old_lines = open("DSP_UC_Zelda.txt", "r").readlines() + # for l in old_lines: + # print l + new_lines = open("zeldanew.txt", "r").readlines() + + for i in range(0, len(old_lines)): + prefix = old_lines[i][0:14] + comment = GetComment(old_lines[i]) + new_line = GetPrefixLine(prefix, new_lines) + if new_line: + old_lines[i] = new_line[:-1] + comment[:-1] + "\n" + + for i in range(0, len(old_lines)): + print old_lines[i], + + new_file = open("output.txt", "w") + new_file.writelines(old_lines) + +main() \ No newline at end of file