From 6e61c3249545ea67ed746f078b3f696823ec1955 Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Sun, 16 Aug 2009 00:37:01 +0000 Subject: dspspy: fix a bug with ConsoleHelper dspspy: remove some alignment for some vars. (should not have caused issues anyways) dspCodeUtil: pad ucodes converted to headers to 32byte multiples with nops (this is only mimicing what is seen in nintendo ucodes, probably because their's are originating on disc) Common.h: fix typo for gcc version of GC_ALIGNED32 (wtf? how did this work before?!) createtest.pl: add "jmp end_of_test" to the end of generated ucodes. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3994 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/DSPCore/Src/DSPCodeUtil.cpp | 47 +++++++++++++++------------------ 1 file changed, 22 insertions(+), 25 deletions(-) (limited to 'Source/Core/DSPCore/Src/DSPCodeUtil.cpp') diff --git a/Source/Core/DSPCore/Src/DSPCodeUtil.cpp b/Source/Core/DSPCore/Src/DSPCodeUtil.cpp index af1656a6c5..250d42df10 100644 --- a/Source/Core/DSPCore/Src/DSPCodeUtil.cpp +++ b/Source/Core/DSPCore/Src/DSPCodeUtil.cpp @@ -116,29 +116,26 @@ void GenRandomCode(int size, std::vector &code) void CodeToHeader(const std::vector &code, std::string _filename, const char *name, std::string &header) { - std::vector code_copy = code; - // Add some nops at the end to align the size a bit. - while (code_copy.size() & 7) - code_copy.push_back(0); + std::vector code_padded = code; + // Pad with nops to 32byte boundary + while (code_padded.size() & 0x7f) + code_padded.push_back(0); + char buffer[1024]; header.clear(); - header.reserve(code.size() * 4); + header.reserve(code_padded.size() * 4); header.append("#define NUM_UCODES 1\n\n"); std::string filename; SplitPath(_filename, NULL, &filename, NULL); header.append(StringFromFormat("const char* UCODE_NAMES[NUM_UCODES] = {\"%s\"};\n\n", filename.c_str())); - header.append("#ifndef _MSCVER\n"); header.append("const unsigned short dsp_code[NUM_UCODES][0x1000] = {\n"); - header.append("#else\n"); - header.append("const unsigned short dsp_code[NUM_UCODES][0x1000] __attribute__ ((aligned (64))) = {\n"); - header.append("#endif\n\n"); - + header.append("\t{\n\t\t"); - for (u32 j = 0; j < code.size(); j++) + for (u32 j = 0; j < code_padded.size(); j++) { if (j && ((j & 15) == 0)) header.append("\n\t\t"); - sprintf(buffer, "0x%04x, ", code[j]); + sprintf(buffer, "0x%04x, ", code_padded[j]); header.append(buffer); } header.append("\n\t},\n"); @@ -149,10 +146,18 @@ void CodeToHeader(const std::vector &code, std::string _filename, void CodesToHeader(const std::vector *codes, const std::vector* filenames, int numCodes, const char *name, std::string &header) { + std::vector > codes_padded; char buffer[1024]; int reserveSize = 0; for(int i = 0; i < numCodes; i++) - reserveSize += (int)codes[i].size(); + { + codes_padded.push_back(codes[i]); + // Pad with nops to 32byte boundary + while (codes_padded.at(i).size() & 0x7f) + codes_padded.at(i).push_back(0); + + reserveSize += (int)codes_padded.at(i).size(); + } header.clear(); @@ -169,27 +174,19 @@ void CodesToHeader(const std::vector *codes, const std::vector header.append(buffer); } header.append("};\n\n"); - header.append("#ifndef _MSCVER\n"); header.append("const unsigned short dsp_code[NUM_UCODES][0x1000] = {\n"); - header.append("#else\n"); - header.append("const unsigned short dsp_code[NUM_UCODES][0x1000] __attribute__ ((aligned (64))) = {\n"); - header.append("#endif\n\n"); - for(int i = 0; i < numCodes; i++) { + for(int i = 0; i < numCodes; i++) + { if(codes[i].size() == 0) continue; - std::vector code_copy = codes[i]; - // Add some nops at the end to align the size a bit. - while (code_copy.size() & 7) - code_copy.push_back(0); - header.append("\t{\n\t\t"); - for (u32 j = 0; j < codes[i].size(); j++) + for (u32 j = 0; j < codes_padded.at(i).size(); j++) { if (j && ((j & 15) == 0)) header.append("\n\t\t"); - sprintf(buffer, "0x%04x, ", codes[i][j]); + sprintf(buffer, "0x%04x, ", codes_padded.at(i).at(j)); header.append(buffer); } header.append("\n\t},\n"); -- cgit v1.2.3