From 2122da5cd2b21aa6965c749181a32699219438ff Mon Sep 17 00:00:00 2001 From: "XTra.KrazzY" Date: Mon, 8 Jun 2009 21:15:01 +0000 Subject: [PATCH] DSPSpy: Added preliminary support for realtime multiple microcode processing git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3383 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/DSPCore/Src/DSPCodeUtil.cpp | 28 ++++++++++++++++--------- Source/DSPSpy/main_spy.cpp | 5 +++-- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/Source/Core/DSPCore/Src/DSPCodeUtil.cpp b/Source/Core/DSPCore/Src/DSPCodeUtil.cpp index c78f0caae3..5df23e09c8 100644 --- a/Source/Core/DSPCore/Src/DSPCodeUtil.cpp +++ b/Source/Core/DSPCore/Src/DSPCodeUtil.cpp @@ -113,6 +113,7 @@ void GenRandomCode(int size, std::vector &code) void CodeToHeader(const std::vector &code, const char *name, std::string &header) { + int const ucodes = 1; // TODO: Make variable size std::vector code_copy = code; // Add some nops at the end to align the size a bit. while (code_copy.size() & 7) @@ -120,21 +121,28 @@ void CodeToHeader(const std::vector &code, const char *name, std::string &h char buffer[1024]; header.clear(); header.reserve(code.size() * 4); + sprintf(buffer, "#define NUM_UCODES %d\n\n", ucodes); + header.append(buffer); header.append("#ifndef _MSCVER\n"); - sprintf(buffer, "const unsigned short %s[0x1000] = {\n", name); + sprintf(buffer, "const unsigned short %s[NUM_UCODES][0x1000] = {\n", name); header.append(buffer); header.append("#else\n"); - sprintf(buffer, "const unsigned short %s[0x1000] __attribute__ ((aligned (64))) = {\n", name); + sprintf(buffer, "const unsigned short %s[NUM_UCODES][0x1000] __attribute__ ((aligned (64))) = {\n", name); header.append(buffer); - header.append("#endif\n\n "); - for (int i = 0; i < code.size(); i++) - { - if (i && ((i & 15) == 0)) - header.append("\n "); - sprintf(buffer, "0x%04x, ", code[i]); - header.append(buffer); + header.append("#endif\n\n"); + + for(int i = 0; i < ucodes; i++) { + header.append("\t{\n\t\t"); + for (int j = 0; j < code.size(); j++) + { + if (j && ((j & 15) == 0)) + header.append("\n\t\t"); + sprintf(buffer, "0x%04x, ", code[j]); + header.append(buffer); + } + header.append("\n\t},\n"); } - header.append("\n};\n"); + header.append("};\n"); } void CodeToBinaryStringBE(const std::vector &code, std::string &str) diff --git a/Source/DSPSpy/main_spy.cpp b/Source/DSPSpy/main_spy.cpp index 1916d404a1..73518c5db6 100644 --- a/Source/DSPSpy/main_spy.cpp +++ b/Source/DSPSpy/main_spy.cpp @@ -339,8 +339,9 @@ int main() dspbufC[0x00 + n] = dspreg_in[n]; DCFlushRange(dspbufC, 0x2000); // Then send the code. - DCFlushRange((void *)dsp_code, 0x2000); - real_dsp.SendTask((void *)MEM_VIRTUAL_TO_PHYSICAL(dsp_code), 0, 4000, 0x10); + DCFlushRange((void *)dsp_code[0], 0x2000); + real_dsp.SendTask((void *)MEM_VIRTUAL_TO_PHYSICAL(dsp_code[0]), + 0, 4000, 0x10); } else if (mail == 0x8888dead) {