diff options
| author | hrydgard <hrydgard@gmail.com> | 2009-05-03 11:15:17 +0000 |
|---|---|---|
| committer | hrydgard <hrydgard@gmail.com> | 2009-05-03 11:15:17 +0000 |
| commit | 0772db6af6f35c700c6ff169bc94bef13d9b8cb7 (patch) | |
| tree | d04f72f205695cd4f0b068894b3a3959452c82f9 /Source | |
| parent | 90ae2a8e55362bc06867ba8d44a39818b7aa31b9 (diff) | |
DSP: add a crazy little shell script that will build DSPCore into DSPSpy. make DSPCore build in gekko mode. re-add GC-pad controls to DSPSpy (now it can run inside Dolphin, kind of neat but not super useful for the obvious reasons).
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3141 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source')
| -rw-r--r-- | Source/Core/Common/Src/CommonFuncs.h | 6 | ||||
| -rw-r--r-- | Source/Core/Common/Src/Log.h | 10 | ||||
| -rw-r--r-- | Source/Core/Common/Src/MsgHandler.h | 8 | ||||
| -rw-r--r-- | Source/Core/DSPCore/Src/DSPAnalyzer.h | 2 | ||||
| -rw-r--r-- | Source/Core/DSPCore/Src/DSPCodeUtil.cpp | 6 | ||||
| -rw-r--r-- | Source/Core/DSPCore/Src/DSPCodeUtil.h | 2 | ||||
| -rw-r--r-- | Source/Core/DSPCore/Src/DSPCore.cpp | 2 | ||||
| -rw-r--r-- | Source/Core/DSPCore/Src/DSPHost.h | 2 | ||||
| -rw-r--r-- | Source/Core/DSPCore/Src/DSPTables.cpp | 4 | ||||
| -rw-r--r-- | Source/Core/DSPCore/Src/DspIntMultiplier.cpp | 2 | ||||
| -rw-r--r-- | Source/Core/DSPCore/Src/assemble.cpp | 1 | ||||
| -rw-r--r-- | Source/Core/DSPCore/Src/disassemble.cpp | 1 | ||||
| -rw-r--r-- | Source/Core/DSPCore/Src/gdsp_interface.cpp | 3 | ||||
| -rw-r--r-- | Source/Core/DSPCore/Src/gdsp_interpreter.cpp | 2 | ||||
| -rw-r--r-- | Source/Core/DSPCore/Src/gdsp_registers.cpp | 2 | ||||
| -rw-r--r-- | Source/DSPSpy/DSPSpy.vcproj | 4 | ||||
| -rw-r--r-- | Source/DSPSpy/Makefile | 7 | ||||
| -rw-r--r-- | Source/DSPSpy/Stubs.cpp | 99 | ||||
| -rw-r--r-- | Source/DSPSpy/build.sh | 6 | ||||
| -rw-r--r-- | Source/DSPSpy/main_spy.cpp | 10 | ||||
| -rw-r--r-- | Source/DSPSpy/sbuild.sh | 4 |
21 files changed, 161 insertions, 22 deletions
diff --git a/Source/Core/Common/Src/CommonFuncs.h b/Source/Core/Common/Src/CommonFuncs.h index d71e9fe24d..4f128c4726 100644 --- a/Source/Core/Common/Src/CommonFuncs.h +++ b/Source/Core/Common/Src/CommonFuncs.h @@ -36,7 +36,11 @@ size_t strnlen(const char *s, size_t n); #endif // APPLE #include <errno.h> // go to debugger mode - #define Crash() {asm ("int $3");} + #ifdef GEKKO + #define Crash() + #else + #define Crash() {asm ("int $3");} + #endif #define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0])) inline u32 _rotl(u32 x, int shift) { shift &= 31; diff --git a/Source/Core/Common/Src/Log.h b/Source/Core/Common/Src/Log.h index a9f2833d07..e607c464c5 100644 --- a/Source/Core/Common/Src/Log.h +++ b/Source/Core/Common/Src/Log.h @@ -103,8 +103,13 @@ enum LOG_LEVELS { // FIXME can we get rid of this? #include "LogManager.h" +#ifdef GEKKO +#define GENERIC_LOG(t, v, ...) +#else + // Let the compiler optimize this out #define GENERIC_LOG(t, v, ...) {if (v <= MAX_LOGLEVEL) {LogManager::GetInstance()->Log(v, t, __VA_ARGS__);}} +#endif #if MAX_LOGLEVEL >= ERROR_LEVEL #undef ERROR_LOG @@ -155,6 +160,8 @@ enum LOG_LEVELS { #endif // MAX_LOGLEVEL DEBUG #define _assert_(_a_) _dbg_assert_(MASTER_LOG, _a_) + +#ifndef GEKKO #ifdef _WIN32 #define _assert_msg_(_t_, _a_, _fmt_, ...) \ if (!(_a_)) {\ @@ -166,5 +173,8 @@ enum LOG_LEVELS { if (!PanicYesNo(_fmt_, ##__VA_ARGS__)) {Crash();} \ } #endif // WIN32 +#else // GEKKO +#define _assert_msg_(_t_, _a_, _fmt_, ...) +#endif #endif // _LOG_H_ diff --git a/Source/Core/Common/Src/MsgHandler.h b/Source/Core/Common/Src/MsgHandler.h index fe9322f6ef..d128b0233c 100644 --- a/Source/Core/Common/Src/MsgHandler.h +++ b/Source/Core/Common/Src/MsgHandler.h @@ -31,6 +31,7 @@ void RegisterMsgAlertHandler(MsgAlertHandler handler); extern bool MsgAlert(const char* caption, bool yes_no, int Style, const char* format, ...); void SetEnableAlert(bool enable); +#ifndef GEKKO #ifdef _WIN32 #define SuccessAlert(format, ...) MsgAlert("Information", false, INFORMATION, format, __VA_ARGS__) #define PanicAlert(format, ...) MsgAlert("Warning", false, WARNING, format, __VA_ARGS__) @@ -42,5 +43,12 @@ void SetEnableAlert(bool enable); #define PanicYesNo(format, ...) MsgAlert("Warning", true, WARNING, format, ##__VA_ARGS__) #define AskYesNo(format, ...) MsgAlert("Question", true, QUESTION, format, ##__VA_ARGS__) #endif +#else +// GEKKO + #define SuccessAlert(format, ...) ; + #define PanicAlert(format, ...) ; + #define PanicYesNo(format, ...) ; + #define AskYesNo(format, ...) ; +#endif #endif // _MSGHANDLER_H_ diff --git a/Source/Core/DSPCore/Src/DSPAnalyzer.h b/Source/Core/DSPCore/Src/DSPAnalyzer.h index b187eef2a7..89e1e6c980 100644 --- a/Source/Core/DSPCore/Src/DSPAnalyzer.h +++ b/Source/Core/DSPCore/Src/DSPAnalyzer.h @@ -48,4 +48,4 @@ extern u8 code_flags[ISPACE]; // some pretty expensive analysis if necessary.
void Analyze();
-} // namespace
\ No newline at end of file +} // namespace
diff --git a/Source/Core/DSPCore/Src/DSPCodeUtil.cpp b/Source/Core/DSPCore/Src/DSPCodeUtil.cpp index a75582a5c8..2d247231e4 100644 --- a/Source/Core/DSPCore/Src/DSPCodeUtil.cpp +++ b/Source/Core/DSPCore/Src/DSPCodeUtil.cpp @@ -90,7 +90,7 @@ bool Compare(const std::vector<u16> &code1, const std::vector<u16> &code2) {
printf("Extra code words:\n");
const std::vector<u16> &longest = code1.size() > code2.size() ? code1 : code2;
- for (int i = min_size; i < longest.size(); i++)
+ for (int i = min_size; i < (int)longest.size(); i++)
{
u16 pc = i;
std::string line;
@@ -140,7 +140,7 @@ void CodeToHeader(const std::vector<u16> &code, const char *name, std::string &h void CodeToBinaryStringBE(const std::vector<u16> &code, std::string &str)
{
str.resize(code.size() * 2);
- for (int i = 0; i < code.size(); i++)
+ for (int i = 0; i < (int)code.size(); i++)
{
str[i * 2 + 0] = code[i] >> 8;
str[i * 2 + 1] = code[i] & 0xff;
@@ -150,7 +150,7 @@ void CodeToBinaryStringBE(const std::vector<u16> &code, std::string &str) void BinaryStringBEToCode(const std::string &str, std::vector<u16> &code)
{
code.resize(str.size() / 2);
- for (int i = 0; i < code.size(); i++)
+ for (int i = 0; i < (int)code.size(); i++)
{
code[i] = ((u16)(u8)str[i * 2 + 0] << 8) | ((u16)(u8)str[i * 2 + 1]);
}
diff --git a/Source/Core/DSPCore/Src/DSPCodeUtil.h b/Source/Core/DSPCore/Src/DSPCodeUtil.h index 5e4d32568c..86477051bc 100644 --- a/Source/Core/DSPCore/Src/DSPCodeUtil.h +++ b/Source/Core/DSPCore/Src/DSPCodeUtil.h @@ -37,4 +37,4 @@ void BinaryStringBEToCode(const std::string &str, std::vector<u16> &code); bool LoadBinary(const char *filename, std::vector<u16> &code);
bool SaveBinary(const std::vector<u16> &code, const char *filename);
-#endif // _DSPCODEUTIL_H
\ No newline at end of file +#endif // _DSPCODEUTIL_H
diff --git a/Source/Core/DSPCore/Src/DSPCore.cpp b/Source/Core/DSPCore/Src/DSPCore.cpp index 270952f8ed..ac684f5e9a 100644 --- a/Source/Core/DSPCore/Src/DSPCore.cpp +++ b/Source/Core/DSPCore/Src/DSPCore.cpp @@ -202,4 +202,4 @@ void gdsp_check_exceptions() }
}
-//} // namespace
\ No newline at end of file +//} // namespace
diff --git a/Source/Core/DSPCore/Src/DSPHost.h b/Source/Core/DSPCore/Src/DSPHost.h index 294af23c1e..7a96fd1ff3 100644 --- a/Source/Core/DSPCore/Src/DSPHost.h +++ b/Source/Core/DSPCore/Src/DSPHost.h @@ -28,4 +28,4 @@ bool DSPHost_OnThread(); bool DSPHost_Running();
u32 DSPHost_CodeLoaded(const u8 *ptr, int size);
-#endif
\ No newline at end of file +#endif
diff --git a/Source/Core/DSPCore/Src/DSPTables.cpp b/Source/Core/DSPCore/Src/DSPTables.cpp index 0eab6484ed..f1afb2074c 100644 --- a/Source/Core/DSPCore/Src/DSPTables.cpp +++ b/Source/Core/DSPCore/Src/DSPTables.cpp @@ -473,7 +473,7 @@ const char *pdregnamelong(int val) const DSPOPCTemplate *GetOpTemplate(const UDSPInstruction &inst)
{
- for (u32 i = 0; i < opcodes_size; i++)
+ for (int i = 0; i < opcodes_size; i++)
{
u16 mask = opcodes[i].opcode_mask;
if (opcodes[i].size & P_EXT) {
@@ -501,7 +501,7 @@ void InitInstructionTable() for (int i = 0; i < OPTABLE_SIZE; i++)
{
- for (u32 j = 0; j < opcodes_size; j++)
+ for (int j = 0; j < opcodes_size; j++)
{
u16 mask = opcodes[j].opcode_mask;
if (opcodes[j].size & P_EXT) {
diff --git a/Source/Core/DSPCore/Src/DspIntMultiplier.cpp b/Source/Core/DSPCore/Src/DspIntMultiplier.cpp index 54d9c69088..6a9cb47f30 100644 --- a/Source/Core/DSPCore/Src/DspIntMultiplier.cpp +++ b/Source/Core/DSPCore/Src/DspIntMultiplier.cpp @@ -148,7 +148,7 @@ void addpaxz(const UDSPInstruction& opc) u8 dreg = (opc.hex >> 8) & 0x1;
u8 sreg = (opc.hex >> 9) & 0x1;
- s64 prod = dsp_get_long_prod() & ~0x0ffff;
+ s64 prod = dsp_get_long_prod() & ~0xffff; // hm, should we really mask here?
s64 ax = dsp_get_long_acx(sreg);
s64 acc = (prod + ax) & ~0xffff;
diff --git a/Source/Core/DSPCore/Src/assemble.cpp b/Source/Core/DSPCore/Src/assemble.cpp index 45c63c12d7..8032a6e46a 100644 --- a/Source/Core/DSPCore/Src/assemble.cpp +++ b/Source/Core/DSPCore/Src/assemble.cpp @@ -38,7 +38,6 @@ Initial import ====================================================================*/
#include <cstdio>
-#include <memory.h>
#include <cstdlib>
#include <map>
diff --git a/Source/Core/DSPCore/Src/disassemble.cpp b/Source/Core/DSPCore/Src/disassemble.cpp index d15e45d2bb..dc3841745c 100644 --- a/Source/Core/DSPCore/Src/disassemble.cpp +++ b/Source/Core/DSPCore/Src/disassemble.cpp @@ -23,7 +23,6 @@ ====================================================================*/ -#include <memory.h> #include <stdio.h> #include <stdlib.h> diff --git a/Source/Core/DSPCore/Src/gdsp_interface.cpp b/Source/Core/DSPCore/Src/gdsp_interface.cpp index 84125c939f..8b6f4a65a4 100644 --- a/Source/Core/DSPCore/Src/gdsp_interface.cpp +++ b/Source/Core/DSPCore/Src/gdsp_interface.cpp @@ -138,6 +138,9 @@ void gdsp_ifx_write(u16 addr, u16 val) gdsp_ifx_regs[DSP_DSCR] &= ~0x0004; break; + case 0xde: + //if (val) + // PanicAlert("Gain written: %04x", val); // BMX XXX does, and sounds HORRIBLE. case 0xcd: case 0xce: case 0xcf: diff --git a/Source/Core/DSPCore/Src/gdsp_interpreter.cpp b/Source/Core/DSPCore/Src/gdsp_interpreter.cpp index 883e6e8881..757ddf9aac 100644 --- a/Source/Core/DSPCore/Src/gdsp_interpreter.cpp +++ b/Source/Core/DSPCore/Src/gdsp_interpreter.cpp @@ -185,4 +185,4 @@ void Stop() gdsp_running = false; } -} // namespace
\ No newline at end of file +} // namespace diff --git a/Source/Core/DSPCore/Src/gdsp_registers.cpp b/Source/Core/DSPCore/Src/gdsp_registers.cpp index ed6cef1685..091e5e0ca9 100644 --- a/Source/Core/DSPCore/Src/gdsp_registers.cpp +++ b/Source/Core/DSPCore/Src/gdsp_registers.cpp @@ -57,4 +57,4 @@ u16 dsp_reg_load_stack(u8 stack_reg) u16 val = g_dsp.r[DSP_REG_ST0 + stack_reg]; dsp_reg_stack_pop(stack_reg); return val; -}
\ No newline at end of file +} diff --git a/Source/DSPSpy/DSPSpy.vcproj b/Source/DSPSpy/DSPSpy.vcproj index 3ac1ce89b9..330cee16a7 100644 --- a/Source/DSPSpy/DSPSpy.vcproj +++ b/Source/DSPSpy/DSPSpy.vcproj @@ -152,6 +152,10 @@ RelativePath=".\processor.h"
>
</File>
+ <File
+ RelativePath=".\Stubs.cpp"
+ >
+ </File>
</Files>
<Globals>
</Globals>
diff --git a/Source/DSPSpy/Makefile b/Source/DSPSpy/Makefile index 402802394d..8797323dc1 100644 --- a/Source/DSPSpy/Makefile +++ b/Source/DSPSpy/Makefile @@ -17,16 +17,16 @@ include $(DEVKITPPC)/wii_rules #---------------------------------------------------------------------------------
TARGET := $(notdir $(CURDIR))
BUILD := build
-SOURCES := . source
+SOURCES := . emu
RESOURCES := ../resources
-DATA := data
+DATA := data
INCLUDES := include ../Core/Common/Src .
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
-CFLAGS = -save-temps -g -O2 -Wall --no-strict-aliasing $(MACHDEP) $(INCLUDE)
+CFLAGS = -save-temps -O2 -Wall --no-strict-aliasing $(MACHDEP) $(INCLUDE)
CXXFLAGS = $(CFLAGS)
LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map
@@ -66,6 +66,7 @@ sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
+
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
diff --git a/Source/DSPSpy/Stubs.cpp b/Source/DSPSpy/Stubs.cpp new file mode 100644 index 0000000000..23be8d2524 --- /dev/null +++ b/Source/DSPSpy/Stubs.cpp @@ -0,0 +1,99 @@ +// Stubs to make DSPCore compile as part of DSPSpy.
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <string>
+
+#include "Thread.h"
+
+void *AllocateMemoryPages(size_t size)
+{
+ return malloc(size);
+}
+
+void FreeMemoryPages(void *pages, size_t size)
+{
+ free(pages);
+}
+
+void WriteProtectMemory(void* ptr, size_t size, bool allowExecute)
+{
+}
+
+void UnWriteProtectMemory(void* ptr, size_t size, bool allowExecute)
+{
+}
+
+bool DSPHost_OnThread()
+{
+ return false;
+}
+
+// Well, it's just RAM right? :)
+u8 DSPHost_ReadHostMemory(u32 address)
+{
+ u8 *ptr = (u8*)address;
+ return *ptr;
+}
+
+void DSPHost_CodeLoaded(const u8 *code, int size)
+{
+}
+
+
+namespace Common
+{
+
+CriticalSection::CriticalSection(int)
+{
+}
+CriticalSection::~CriticalSection()
+{
+}
+
+void CriticalSection::Enter()
+{
+}
+
+void CriticalSection::Leave()
+{
+}
+
+} // namespace
+
+namespace File
+{
+
+bool WriteStringToFile(bool text_file, const std::string &str, const char *filename)
+{
+ FILE *f = fopen(filename, text_file ? "w" : "wb");
+ if (!f)
+ return false;
+ size_t len = str.size();
+ if (len != fwrite(str.data(), 1, str.size(), f))
+ {
+ fclose(f);
+ return false;
+ }
+ fclose(f);
+ return true;
+}
+
+bool ReadFileToString(bool text_file, const char *filename, std::string &str)
+{
+ FILE *f = fopen(filename, text_file ? "r" : "rb");
+ if (!f)
+ return false;
+ fseek(f, 0, SEEK_END);
+ size_t len = ftell(f);
+ fseek(f, 0, SEEK_SET);
+ char *buf = new char[len + 1];
+ buf[fread(buf, 1, len, f)] = 0;
+ str = std::string(buf, len);
+ fclose(f);
+ delete [] buf;
+ return true;
+}
+
+}
diff --git a/Source/DSPSpy/build.sh b/Source/DSPSpy/build.sh new file mode 100644 index 0000000000..bf71edccf5 --- /dev/null +++ b/Source/DSPSpy/build.sh @@ -0,0 +1,6 @@ +../../Binary/x64/DSPTool.exe -h dsp_code tests/mul_test.ds +mkdir emu +cp ../Core/DSPCore/Src/*.cpp emu +cp ../Core/DSPCore/Src/*.h emu +make + diff --git a/Source/DSPSpy/main_spy.cpp b/Source/DSPSpy/main_spy.cpp index 75bdc3e467..8e288fd825 100644 --- a/Source/DSPSpy/main_spy.cpp +++ b/Source/DSPSpy/main_spy.cpp @@ -303,7 +303,6 @@ void init_video(void) break;
}
- PAD_Init();
xfb = SYS_AllocateFramebuffer(rmode);
VIDEO_Configure(rmode);
@@ -366,6 +365,8 @@ int main() //printf("Network Intitalized\n");
#endif
+ // Both GC and Wii controls.
+ PAD_Init();
WPAD_Init();
int dsp_steps = 0;
@@ -424,6 +425,7 @@ int main() VIDEO_WaitVSync();
+ PAD_ScanPads();
WPAD_ScanPads();
if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME)
exit(0);
@@ -452,7 +454,7 @@ int main() DCFlushRange(xfb, 0x200000);
// Use B to start over.
- if (WPAD_ButtonsDown(0) & WPAD_BUTTON_B)
+ if ((WPAD_ButtonsDown(0) & WPAD_BUTTON_B) || (PAD_ButtonsDown(0) & PAD_BUTTON_START))
{
dsp_steps = 0; // Let's not add the new steps after the original ones. That was just annoying.
@@ -474,14 +476,14 @@ int main() // Navigate between results using + and - buttons.
- if (WPAD_ButtonsDown(0) & WPAD_BUTTON_PLUS)
+ if ((WPAD_ButtonsDown(0) & WPAD_BUTTON_PLUS) || (PAD_ButtonsDown(0) & PAD_BUTTON_X))
{
show_step++;
if (show_step >= dsp_steps)
show_step = 0;
}
- if (WPAD_ButtonsDown(0) & WPAD_BUTTON_MINUS)
+ if ((WPAD_ButtonsDown(0) & WPAD_BUTTON_MINUS) || (PAD_ButtonsDown(0) & PAD_BUTTON_Y))
{
show_step--;
if (show_step < 0)
diff --git a/Source/DSPSpy/sbuild.sh b/Source/DSPSpy/sbuild.sh new file mode 100644 index 0000000000..80038bf9f5 --- /dev/null +++ b/Source/DSPSpy/sbuild.sh @@ -0,0 +1,4 @@ +../../Binary/x64/DSPTool.exe -h dsp_code tests/mul_test.ds +rm -rf emu +make + |
