diff --git a/Source/Core/DSPCore/Src/DSPInterpreter.cpp b/Source/Core/DSPCore/Src/DSPInterpreter.cpp index e801e4e1b9..5f708c8d6d 100644 --- a/Source/Core/DSPCore/Src/DSPInterpreter.cpp +++ b/Source/Core/DSPCore/Src/DSPInterpreter.cpp @@ -1444,7 +1444,7 @@ void sbset(const UDSPInstruction& opc) // mode to explore for the moment: // SET40 // CLR15 -// M0 +// M0 // Gonna be fun to explore all 8 possible combinations .. ugh. void srbith(const UDSPInstruction& opc) { @@ -1453,37 +1453,37 @@ void srbith(const UDSPInstruction& opc) // M0 seems to be the default. M2 is used in functions in Zelda // and then reset with M0 at the end. Like the other bits here, it's // done around loops with lots of multiplications. - + // I've confirmed with DSPSpy that they flip this bit. case 0xa: // M2 - //ERROR_LOG(DSPLLE, "M2"); + g_dsp.r[DSP_REG_SR] &= ~SR_MUL_MODIFY; break; // FIXME: Both of these appear in the beginning of the Wind Waker case 0xb: // M0 - //ERROR_LOG(DSPLLE, "M0"); + g_dsp.r[DSP_REG_SR] |= SR_MUL_MODIFY; break; // 15-bit precision? clamping? no idea :( // CLR15 seems to be the default. // nakee: It seems to come around mul operation, and it explains what sets the mul bit. But if so why not set/clr14? case 0xc: // CLR15 - g_dsp.r[DSP_REG_SR] |= SR_MUL_MODIFY; + g_dsp.r[DSP_REG_SR] &= ~SR_TOP_BIT_UNK; //ERROR_LOG(DSPLLE, "CLR15"); break; case 0xd: // SET15 - g_dsp.r[DSP_REG_SR] &= ~SR_MUL_MODIFY; + g_dsp.r[DSP_REG_SR] |= SR_TOP_BIT_UNK; //ERROR_LOG(DSPLLE, "SET15"); break; // 40-bit precision? clamping? no idea :( // 40 seems to be the default. case 0xe: // SET40 (really, clear SR's 0x4000?) something about "set 40-bit operation"? - g_dsp.r[DSP_REG_SR] &= ~(1 << 14); + //g_dsp.r[DSP_REG_SR] &= ~(1 << 14); //ERROR_LOG(DSPLLE, "SET40"); break; case 0xf: // SET16 (really, set SR's 0x4000?) something about "set 16-bit operation"? // that doesnt happen on a real console << what does this comment mean? - g_dsp.r[DSP_REG_SR] |= (1 << 14); + //g_dsp.r[DSP_REG_SR] |= (1 << 14); //ERROR_LOG(DSPLLE, "SET16"); break; diff --git a/Source/Core/DSPCore/Src/gdsp_registers.h b/Source/Core/DSPCore/Src/gdsp_registers.h index 383ac5be66..8a0293e13c 100644 --- a/Source/Core/DSPCore/Src/gdsp_registers.h +++ b/Source/Core/DSPCore/Src/gdsp_registers.h @@ -100,6 +100,7 @@ #define SR_LOGIC_ZERO 0x0040 // ?? duddie's doc sometimes say & 1<<6 (0x40), sometimes 1<<14 (0x4000), while we have 0x20 .. eh #define SR_INT_ENABLE 0x0200 // Not 100% sure but duddie says so. This should replace the hack, if so. #define SR_MUL_MODIFY 0x2000 // 1 = normal. 0 = x2 +#define SR_TOP_BIT_UNK 0x8000 // 1 = normal. 0 = x2 void dsp_reg_store_stack(u8 stack_reg, u16 val); u16 dsp_reg_load_stack(u8 stack_reg); diff --git a/Source/DSPSpy/dsp_code.ds b/Source/DSPSpy/dsp_code.ds index f47fae728c..9076cc0ebd 100644 --- a/Source/DSPSpy/dsp_code.ds +++ b/Source/DSPSpy/dsp_code.ds @@ -180,15 +180,21 @@ main: ; We can call send_back at any time to send data back to the PowerPC. - nop - nop - nop - nop +; Calling set16 here seemed to crash the dsp tester in strange ways +; until I added set40 in send_back. Seems clear that it affects something important. - cw 0x8600 - - call send_back + nop + nop + nop + nop + inc $acc0 + call send_back + + s16 + inc $acc0 + call send_back + ; We're done - currently we only test one opcode, in this case 0x8600. ; It's possible to test many more in one go - just call send_back after each one. @@ -511,6 +517,8 @@ irq: ; DMA:s the current state of the registers back to the PowerPC. To do this, ; it must write the contents of all regs to DRAM. send_back: + ; make state safe. + set40 ; store registers to reg table sr @REGS_BASE, $r00 lri $r00, #(REGS_BASE + 1) diff --git a/Source/DSPSpy/dsp_code.h b/Source/DSPSpy/dsp_code.h index 1cfd278bea..a3f4ffbb10 100644 --- a/Source/DSPSpy/dsp_code.h +++ b/Source/DSPSpy/dsp_code.h @@ -4,38 +4,38 @@ const unsigned short dsp_code[0x1000] = { const unsigned short dsp_code[0x1000] __attribute__ ((aligned (64))) = { #endif - 0x029f, 0x015b, 0x029f, 0x015f, 0x029f, 0x0163, 0x029f, 0x0167, 0x029f, 0x016b, 0x029f, 0x016f, 0x029f, 0x0180, 0x029f, 0x0184, - 0x1302, 0x1303, 0x1204, 0x1305, 0x1306, 0x8e00, 0x0092, 0x00ff, 0x8900, 0x8100, 0x02bf, 0x014f, 0x16fc, 0x8888, 0x16fd, 0xdead, - 0x16fb, 0x0001, 0x02bf, 0x0155, 0x26ff, 0x0340, 0x7fff, 0x00ff, 0x0f7e, 0x00fe, 0x0f7f, 0x0098, 0x0000, 0x0099, 0x0000, 0x009a, - 0x2000, 0x00dc, 0x0f7e, 0x00de, 0x0f7f, 0x02bf, 0x013f, 0x02bf, 0x014f, 0x16fc, 0x8888, 0x16fd, 0xbeef, 0x16fb, 0x0001, 0x02bf, - 0x0155, 0x26ff, 0x0340, 0x7fff, 0x00ff, 0x0f7e, 0x00fe, 0x0f7f, 0x0098, 0x0f80, 0x0099, 0x0000, 0x009a, 0x0080, 0x00dc, 0x0f7e, - 0x00de, 0x0f7f, 0x02bf, 0x013f, 0x0080, 0x0f81, 0x1901, 0x1902, 0x1903, 0x1904, 0x1905, 0x1906, 0x1907, 0x1908, 0x1909, 0x190a, + 0x029f, 0x015f, 0x029f, 0x0163, 0x029f, 0x0167, 0x029f, 0x016b, 0x029f, 0x016f, 0x029f, 0x0173, 0x029f, 0x0184, 0x029f, 0x0188, + 0x1302, 0x1303, 0x1204, 0x1305, 0x1306, 0x8e00, 0x0092, 0x00ff, 0x8900, 0x8100, 0x02bf, 0x0153, 0x16fc, 0x8888, 0x16fd, 0xdead, + 0x16fb, 0x0001, 0x02bf, 0x0159, 0x26ff, 0x0340, 0x7fff, 0x00ff, 0x0f7e, 0x00fe, 0x0f7f, 0x0098, 0x0000, 0x0099, 0x0000, 0x009a, + 0x2000, 0x00dc, 0x0f7e, 0x00de, 0x0f7f, 0x02bf, 0x0143, 0x02bf, 0x0153, 0x16fc, 0x8888, 0x16fd, 0xbeef, 0x16fb, 0x0001, 0x02bf, + 0x0159, 0x26ff, 0x0340, 0x7fff, 0x00ff, 0x0f7e, 0x00fe, 0x0f7f, 0x0098, 0x0f80, 0x0099, 0x0000, 0x009a, 0x0080, 0x00dc, 0x0f7e, + 0x00de, 0x0f7f, 0x02bf, 0x0143, 0x0080, 0x0f81, 0x1901, 0x1902, 0x1903, 0x1904, 0x1905, 0x1906, 0x1907, 0x1908, 0x1909, 0x190a, 0x190b, 0x190c, 0x190d, 0x190e, 0x190f, 0x1910, 0x1911, 0x1912, 0x1913, 0x1914, 0x1915, 0x1916, 0x1917, 0x1918, 0x1919, 0x191a, - 0x191b, 0x191c, 0x191d, 0x191e, 0x191f, 0x00c0, 0x0f80, 0x0000, 0x0000, 0x0000, 0x0000, 0x8600, 0x02bf, 0x0194, 0x029f, 0x0136, - 0x00de, 0x03f1, 0x02bf, 0x0194, 0x0200, 0x0a60, 0x02bf, 0x0194, 0x1c7e, 0x02bf, 0x0194, 0x8100, 0x02bf, 0x0194, 0x8900, 0x02bf, - 0x0194, 0x009f, 0x00a0, 0x02bf, 0x0194, 0x00de, 0x03f1, 0x02bf, 0x0194, 0x5d00, 0x02bf, 0x0194, 0x0e50, 0x02bf, 0x0194, 0x0750, - 0x02bf, 0x0194, 0x0270, 0x02bf, 0x0194, 0x5d00, 0x02bf, 0x0194, 0x00da, 0x03f2, 0x02bf, 0x0194, 0x8600, 0x02bf, 0x0194, 0x0290, - 0x00e7, 0x00de, 0x03f3, 0x02bf, 0x0194, 0x5c00, 0x02bf, 0x0194, 0x0293, 0x00bc, 0x029f, 0x00f0, 0x00db, 0x03f7, 0x02bf, 0x0194, - 0x009e, 0x8000, 0x02bf, 0x0194, 0x4600, 0x02bf, 0x0194, 0x029f, 0x00d4, 0x00db, 0x03f7, 0x02bf, 0x0194, 0x009e, 0x8000, 0x02bf, - 0x0194, 0x5600, 0x02bf, 0x0194, 0x00fe, 0x03f5, 0x02bf, 0x0194, 0x1fda, 0x02bf, 0x0194, 0x7c00, 0x02bf, 0x0194, 0x1f5e, 0x02bf, - 0x0194, 0x00fe, 0x03f2, 0x02bf, 0x0194, 0x029f, 0x00f0, 0x00de, 0x03f4, 0x02bf, 0x0194, 0x5d00, 0x02bf, 0x0194, 0x0293, 0x00c9, - 0x8900, 0x02bf, 0x0194, 0x00dd, 0x03f5, 0x02bf, 0x0194, 0x1501, 0x02bf, 0x0194, 0x8100, 0x02bf, 0x0194, 0x00dc, 0x03f6, 0x02bf, - 0x0194, 0x008b, 0x009f, 0x02bf, 0x0194, 0x0080, 0x0a00, 0x02bf, 0x0194, 0x0900, 0x02bf, 0x0194, 0x1150, 0x011d, 0x1878, 0x02bf, - 0x0194, 0x4c00, 0x02bf, 0x0194, 0x1cfe, 0x02bf, 0x0194, 0x001f, 0x02bf, 0x0194, 0x1fd9, 0x02bf, 0x0194, 0x1b18, 0x02bf, 0x0194, - 0x009f, 0x0a60, 0x02bf, 0x0194, 0x1fc3, 0x02bf, 0x0194, 0x5c00, 0x02bf, 0x0194, 0x00fe, 0x03f1, 0x02bf, 0x0194, 0x00fc, 0x03f6, - 0x02bf, 0x0194, 0x008b, 0xffff, 0x02bf, 0x0194, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x029f, 0x013d, 0x00fc, - 0xffce, 0x00fe, 0xffcf, 0x00f8, 0xffcd, 0x00f9, 0xffc9, 0x00fa, 0xffcb, 0x27c9, 0x03c0, 0x0004, 0x029d, 0x0149, 0x02df, 0x27fc, - 0x03c0, 0x8000, 0x029d, 0x014f, 0x02df, 0x27fe, 0x03c0, 0x8000, 0x029c, 0x0155, 0x02df, 0x009e, 0x0000, 0x029f, 0x0188, 0x009e, - 0x0001, 0x029f, 0x0188, 0x009e, 0x0002, 0x029f, 0x0188, 0x009e, 0x0003, 0x029f, 0x0188, 0x009e, 0x0004, 0x029f, 0x0188, 0x8e00, - 0x1dbc, 0x1dbe, 0x8100, 0x1fcd, 0x1f8d, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x02ff, 0x009e, 0x0005, 0x029f, 0x0188, - 0x009e, 0x0006, 0x029f, 0x0188, 0x009e, 0x0007, 0x029f, 0x0188, 0x27fc, 0x03c0, 0x8000, 0x029d, 0x0188, 0x16fc, 0x8bad, 0x00eb, - 0xfffd, 0x16fb, 0x0001, 0x0021, 0x00e0, 0x0f80, 0x0080, 0x0f81, 0x1b01, 0x1b02, 0x1b03, 0x1b04, 0x1b05, 0x1b06, 0x1b07, 0x1b08, - 0x1b09, 0x1b0a, 0x1b0b, 0x1b0c, 0x1b0d, 0x1b0e, 0x1b0f, 0x1b10, 0x1b11, 0x1b12, 0x1b13, 0x1b14, 0x1b15, 0x1b16, 0x1b17, 0x1b18, - 0x1b19, 0x1b1a, 0x1b1b, 0x1b1c, 0x1b1d, 0x1b1e, 0x1b1f, 0x0098, 0x0000, 0x0099, 0x0001, 0x009a, 0x0200, 0x00dc, 0x0f7e, 0x00de, - 0x0f7f, 0x0081, 0x0010, 0x0061, 0x01ce, 0x02bf, 0x013f, 0x0200, 0x0200, 0x1ff8, 0x0300, 0x0100, 0x1f1f, 0x0000, 0x0000, 0x02bf, - 0x014f, 0x16fc, 0x8888, 0x16fd, 0xfeeb, 0x16fb, 0x0001, 0x02bf, 0x0155, 0x26ff, 0x0340, 0x7fff, 0x0080, 0x0f81, 0x1901, 0x1902, - 0x1903, 0x1904, 0x1905, 0x1906, 0x1907, 0x1908, 0x1909, 0x190a, 0x190b, 0x190c, 0x190d, 0x190e, 0x190f, 0x1910, 0x1911, 0x1912, - 0x1913, 0x1914, 0x1915, 0x1916, 0x1917, 0x1918, 0x1919, 0x191a, 0x191b, 0x191c, 0x191d, 0x191e, 0x191f, 0x00c0, 0x0f80, 0x02df, - 0x8e00, 0x02bf, 0x0194, 0x8f00, 0x02df, 0x0082, 0x0000, 0x009e, 0x1000, 0x0081, 0x1000, 0x0061, 0x0215, 0x1c7e, 0x80f0, 0x1fe0, - 0x1c02, 0x1b1b, 0x1c40, 0x1c1f, 0x0401, 0x0000, 0x02df, + 0x191b, 0x191c, 0x191d, 0x191e, 0x191f, 0x00c0, 0x0f80, 0x0000, 0x0000, 0x0000, 0x0000, 0x7600, 0x02bf, 0x0198, 0x8f00, 0x7600, + 0x02bf, 0x0198, 0x029f, 0x013a, 0x00de, 0x03f1, 0x02bf, 0x0198, 0x0200, 0x0a60, 0x02bf, 0x0198, 0x1c7e, 0x02bf, 0x0198, 0x8100, + 0x02bf, 0x0198, 0x8900, 0x02bf, 0x0198, 0x009f, 0x00a0, 0x02bf, 0x0198, 0x00de, 0x03f1, 0x02bf, 0x0198, 0x5d00, 0x02bf, 0x0198, + 0x0e50, 0x02bf, 0x0198, 0x0750, 0x02bf, 0x0198, 0x0270, 0x02bf, 0x0198, 0x5d00, 0x02bf, 0x0198, 0x00da, 0x03f2, 0x02bf, 0x0198, + 0x8600, 0x02bf, 0x0198, 0x0290, 0x00eb, 0x00de, 0x03f3, 0x02bf, 0x0198, 0x5c00, 0x02bf, 0x0198, 0x0293, 0x00c0, 0x029f, 0x00f4, + 0x00db, 0x03f7, 0x02bf, 0x0198, 0x009e, 0x8000, 0x02bf, 0x0198, 0x4600, 0x02bf, 0x0198, 0x029f, 0x00d8, 0x00db, 0x03f7, 0x02bf, + 0x0198, 0x009e, 0x8000, 0x02bf, 0x0198, 0x5600, 0x02bf, 0x0198, 0x00fe, 0x03f5, 0x02bf, 0x0198, 0x1fda, 0x02bf, 0x0198, 0x7c00, + 0x02bf, 0x0198, 0x1f5e, 0x02bf, 0x0198, 0x00fe, 0x03f2, 0x02bf, 0x0198, 0x029f, 0x00f4, 0x00de, 0x03f4, 0x02bf, 0x0198, 0x5d00, + 0x02bf, 0x0198, 0x0293, 0x00cd, 0x8900, 0x02bf, 0x0198, 0x00dd, 0x03f5, 0x02bf, 0x0198, 0x1501, 0x02bf, 0x0198, 0x8100, 0x02bf, + 0x0198, 0x00dc, 0x03f6, 0x02bf, 0x0198, 0x008b, 0x009f, 0x02bf, 0x0198, 0x0080, 0x0a00, 0x02bf, 0x0198, 0x0900, 0x02bf, 0x0198, + 0x1150, 0x0121, 0x1878, 0x02bf, 0x0198, 0x4c00, 0x02bf, 0x0198, 0x1cfe, 0x02bf, 0x0198, 0x001f, 0x02bf, 0x0198, 0x1fd9, 0x02bf, + 0x0198, 0x1b18, 0x02bf, 0x0198, 0x009f, 0x0a60, 0x02bf, 0x0198, 0x1fc3, 0x02bf, 0x0198, 0x5c00, 0x02bf, 0x0198, 0x00fe, 0x03f1, + 0x02bf, 0x0198, 0x00fc, 0x03f6, 0x02bf, 0x0198, 0x008b, 0xffff, 0x02bf, 0x0198, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x029f, 0x0141, 0x00fc, 0xffce, 0x00fe, 0xffcf, 0x00f8, 0xffcd, 0x00f9, 0xffc9, 0x00fa, 0xffcb, 0x27c9, 0x03c0, 0x0004, + 0x029d, 0x014d, 0x02df, 0x27fc, 0x03c0, 0x8000, 0x029d, 0x0153, 0x02df, 0x27fe, 0x03c0, 0x8000, 0x029c, 0x0159, 0x02df, 0x009e, + 0x0000, 0x029f, 0x018c, 0x009e, 0x0001, 0x029f, 0x018c, 0x009e, 0x0002, 0x029f, 0x018c, 0x009e, 0x0003, 0x029f, 0x018c, 0x009e, + 0x0004, 0x029f, 0x018c, 0x8e00, 0x1dbc, 0x1dbe, 0x8100, 0x1fcd, 0x1f8d, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x02ff, + 0x009e, 0x0005, 0x029f, 0x018c, 0x009e, 0x0006, 0x029f, 0x018c, 0x009e, 0x0007, 0x029f, 0x018c, 0x27fc, 0x03c0, 0x8000, 0x029d, + 0x018c, 0x16fc, 0x8bad, 0x00eb, 0xfffd, 0x16fb, 0x0001, 0x0021, 0x8e00, 0x00e0, 0x0f80, 0x0080, 0x0f81, 0x1b01, 0x1b02, 0x1b03, + 0x1b04, 0x1b05, 0x1b06, 0x1b07, 0x1b08, 0x1b09, 0x1b0a, 0x1b0b, 0x1b0c, 0x1b0d, 0x1b0e, 0x1b0f, 0x1b10, 0x1b11, 0x1b12, 0x1b13, + 0x1b14, 0x1b15, 0x1b16, 0x1b17, 0x1b18, 0x1b19, 0x1b1a, 0x1b1b, 0x1b1c, 0x1b1d, 0x1b1e, 0x1b1f, 0x0098, 0x0000, 0x0099, 0x0001, + 0x009a, 0x0200, 0x00dc, 0x0f7e, 0x00de, 0x0f7f, 0x0081, 0x0010, 0x0061, 0x01d3, 0x02bf, 0x0143, 0x0200, 0x0200, 0x1ff8, 0x0300, + 0x0100, 0x1f1f, 0x0000, 0x0000, 0x02bf, 0x0153, 0x16fc, 0x8888, 0x16fd, 0xfeeb, 0x16fb, 0x0001, 0x02bf, 0x0159, 0x26ff, 0x0340, + 0x7fff, 0x0080, 0x0f81, 0x1901, 0x1902, 0x1903, 0x1904, 0x1905, 0x1906, 0x1907, 0x1908, 0x1909, 0x190a, 0x190b, 0x190c, 0x190d, + 0x190e, 0x190f, 0x1910, 0x1911, 0x1912, 0x1913, 0x1914, 0x1915, 0x1916, 0x1917, 0x1918, 0x1919, 0x191a, 0x191b, 0x191c, 0x191d, + 0x191e, 0x191f, 0x00c0, 0x0f80, 0x02df, 0x8e00, 0x02bf, 0x0198, 0x8f00, 0x02df, 0x0082, 0x0000, 0x009e, 0x1000, 0x0081, 0x1000, + 0x0061, 0x021a, 0x1c7e, 0x80f0, 0x1fe0, 0x1c02, 0x1b1b, 0x1c40, 0x1c1f, 0x0401, 0x0000, 0x02df, }; diff --git a/Source/DSPSpy/dspbuild.bat b/Source/DSPSpy/dspbuild.bat index 821a5b47ca..3e4c266ee5 100644 --- a/Source/DSPSpy/dspbuild.bat +++ b/Source/DSPSpy/dspbuild.bat @@ -1 +1,2 @@ ../../Binary/x64/DSPTool.exe -h dsp_code dsp_code.ds +make diff --git a/Source/DSPSpy/main_spy.cpp b/Source/DSPSpy/main_spy.cpp index 4c3e962aeb..a5f777b1d4 100644 --- a/Source/DSPSpy/main_spy.cpp +++ b/Source/DSPSpy/main_spy.cpp @@ -58,11 +58,6 @@ u16 *dspbufP; u16 *dspbufC; u32 *dspbufU; -u16 opcode[4] = { - 0x0000, 0x0000, 0x0000, 0x0000, -}; - - u16 dspreg_in[32] = { 0x0410, 0x0510, 0x0610, 0x0710, 0x0810, 0x0910, 0x0a10, 0x0b10, 0x0411, 0x0522, 0x0633, 0x0744, 0x0855, 0x0966, 0x0a77, 0x0b88, @@ -161,11 +156,9 @@ vu16 val_x = 0x1234; void print_regs(u16 _step) { - int i, j; - - for(j = 0 ; j < 4 ; j++) + for (int j = 0 ; j < 4 ; j++) { - for(i = 0 ; i < 8 ; i++) + for (int i = 0 ; i < 8 ; i++) { int reg = j * 8 + i; ds_set_colour(COLOR_GREEN, COLOR_BLACK); @@ -188,9 +181,9 @@ void print_regs(u16 _step) ds_printf(10 + j, i + 11, "%d", (opcode[i] >> (15 - j)) & 0x1);*/ } - for(j = 0 ; j < 4 ; j++) + for (int j = 0 ; j < 4 ; j++) { - for(i = 0 ; i < 8 ; i++) + for (int i = 0 ; i < 8 ; i++) { char tmpbuf1[20]; int reg = j * 8 + i; @@ -224,7 +217,7 @@ void print_regs(u16 _step) ds_clear(); count = 0; ds_set_colour(COLOR_WHITE, COLOR_BLACK); - for (i = 0x0; i < 0xf70 ; i++) + for (int i = 0x0; i < 0xf70 ; i++) { if (dspbufC[i] != mem_dump[i]) { @@ -347,7 +340,7 @@ void ui_pad_sel(void) ui_mode = UIM_EDIT_REG; else ui_mode = UIM_EDIT_BIN; - reg_value = &opcode[cursor_y-8]; + // reg_value = &opcode[cursor_y-8]; } } } @@ -355,7 +348,6 @@ void ui_pad_sel(void) void ui_pad_edit_bin(void) { u8 pos; - if (gpad.button & PAD_BUTTON_RIGHT) { small_cursor_x++; @@ -415,7 +407,7 @@ void init_video(void) { VIDEO_Init(); - switch(VIDEO_GetCurrentTvMode()) + switch (VIDEO_GetCurrentTvMode()) { case VI_NTSC: rmode = &TVNtsc480IntDf; @@ -474,11 +466,11 @@ void my_send_task(void *addr, u16 iram_addr, u16 len, u16 start) int main() { - int i, j; u32 mail; u32 level; { + // WTF? vu16 *dicr = ((vu16 *)0xcc002002); *dicr = 0x100; *dicr = 0x002; @@ -492,7 +484,6 @@ int main() //console_init(xfb,20,64,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*2); ds_init(xfb,20,64,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*2); - ui_mode = UIM_SEL; dspbufP = (u16 *)MEM_VIRTUAL_TO_PHYSICAL(dspbuffer); @@ -500,7 +491,7 @@ int main() dspbufU = (u32 *)(MEM_K0_TO_K1(dspbuffer)); DCInvalidateRange(dspbuffer, 0x2000); - for(j = 0 ; j < 0x800 ; j++) + for (int j = 0 ; j < 0x800; j++) dspbufU[j] = 0xffffffff; _dspReg[5] = (_dspReg[5]&~(DSPCR_AIINT|DSPCR_ARINT|DSPCR_DSPINT))|DSPCR_DSPRESET; @@ -517,7 +508,7 @@ int main() WPAD_Init(); - while(1) + while (1) { if (DSP_CheckMailFrom()) { @@ -526,26 +517,11 @@ int main() if (mail == 0x8071feed) { - int n; - for (n = 0 ; n < 32 ; n++) + for (int n = 0 ; n < 32 ; n++) dspbufC[0x00 + n] = dspreg_in[n]; DCFlushRange(dspbufC, 0x2000); - /* - for (n = 0 ; n < 600 ; n++) - { - if (((u16*)dsp_test)[n] == 0x1234) - { - ((u16*)dsp_test)[n+0] = opcode[0]; - ((u16*)dsp_test)[n+1] = opcode[1]; - ((u16*)dsp_test)[n+2] = opcode[2]; - ((u16*)dsp_test)[n+3] = opcode[3]; - break; - } - } - */ DCFlushRange((void *)dsp_code, 0x1000); my_send_task((void *)MEM_VIRTUAL_TO_PHYSICAL(dsp_code), 0, 4000, 0x10); - ((u16*)dsp_code)[n] = 0x1234; // wtf? } else if (mail == 0x8888dead) { @@ -566,18 +542,17 @@ int main() else if (mail == 0x8888feeb) { DCInvalidateRange(dspbufC, 0x2000); - for(i = 0 ; i < 32 ; i++) + for (int i = 0 ; i < 32 ; i++) dspreg_out[dsp_steps][i] = dspbufC[0xf80 + i]; regs_refreshed = true; dsp_steps++; - while(DSP_CheckMailTo()); + while (DSP_CheckMailTo()); DSP_SendMailTo(0x8000DEAD); - while(DSP_CheckMailTo()); + while (DSP_CheckMailTo()); // dump_to_pc(); - } } @@ -619,33 +594,36 @@ int main() if (WPAD_ButtonsDown(0) & WPAD_BUTTON_B) { DCInvalidateRange(dspbufC, 0x2000); - int n; - for(n = 0 ; n < 0x2000 ; n++) + for (int n = 0 ; n < 0x2000 ; n++) { // dspbufU[n/2] = 0; dspbufC[n] = 0; } DCFlushRange(dspbufC, 0x2000); + + // Reset the DSP. _dspReg[5] = (_dspReg[5]&~(DSPCR_AIINT|DSPCR_ARINT|DSPCR_DSPINT))|DSPCR_DSPRESET; _dspReg[5] = (_dspReg[5]&~(DSPCR_HALT|DSPCR_AIINT|DSPCR_ARINT|DSPCR_DSPINT)); _dspReg[5] |= DSPCR_RES; - while(_dspReg[5]&DSPCR_RES); + while (_dspReg[5] & DSPCR_RES) + ; _dspReg[9] = 0x63; } if (WPAD_ButtonsDown(0) & WPAD_BUTTON_2) { + // WTF? vu16 *dicr = ((vu16 *)0xcc002002); *dicr = 0x001; val_x = *dicr; } + if (WPAD_ButtonsDown(0) & WPAD_BUTTON_A) { show_step++; if (show_step >= dsp_steps) show_step = 0; } - - }; + } // Reset the DSP _dspReg[5] = (_dspReg[5]&~(DSPCR_AIINT|DSPCR_ARINT|DSPCR_DSPINT))|DSPCR_DSPRESET;