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
This commit is contained in:
hrydgard 2009-05-03 11:15:17 +00:00
parent 90ae2a8e55
commit 0772db6af6
21 changed files with 161 additions and 22 deletions

View File

@ -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;

View File

@ -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_

View File

@ -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_

View File

@ -48,4 +48,4 @@ extern u8 code_flags[ISPACE];
// some pretty expensive analysis if necessary.
void Analyze();
} // namespace
} // namespace

View File

@ -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]);
}

View File

@ -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
#endif // _DSPCODEUTIL_H

View File

@ -202,4 +202,4 @@ void gdsp_check_exceptions()
}
}
//} // namespace
//} // namespace

View File

@ -28,4 +28,4 @@ bool DSPHost_OnThread();
bool DSPHost_Running();
u32 DSPHost_CodeLoaded(const u8 *ptr, int size);
#endif
#endif

View File

@ -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) {

View File

@ -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;

View File

@ -38,7 +38,6 @@ Initial import
====================================================================*/
#include <cstdio>
#include <memory.h>
#include <cstdlib>
#include <map>

View File

@ -23,7 +23,6 @@
====================================================================*/
#include <memory.h>
#include <stdio.h>
#include <stdlib.h>

View File

@ -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:

View File

@ -185,4 +185,4 @@ void Stop()
gdsp_running = false;
}
} // namespace
} // namespace

View File

@ -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;
}
}

View File

@ -152,6 +152,10 @@
RelativePath=".\processor.h"
>
</File>
<File
RelativePath=".\Stubs.cpp"
>
</File>
</Files>
<Globals>
</Globals>

View File

@ -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
#---------------------------------------------------------------------------------

99
Source/DSPSpy/Stubs.cpp Normal file
View File

@ -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;
}
}

6
Source/DSPSpy/build.sh Normal file
View File

@ -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

View File

@ -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)

4
Source/DSPSpy/sbuild.sh Normal file
View File

@ -0,0 +1,4 @@
../../Binary/x64/DSPTool.exe -h dsp_code tests/mul_test.ds
rm -rf emu
make