get dspspy running on gamecube (wii people check this!)

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3246 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Shawn Hoffman 2009-05-15 20:10:02 +00:00
parent 91a3099a31
commit 14beb0ce7f
5 changed files with 94 additions and 166 deletions

View File

@ -36,7 +36,7 @@ void CON_Printf(int x, int y, const char* fmt, ...)
printf("\x1b[%d;%dH%s", y, x, tmpbuf);
}
void CON_SetColor(u8 foreground, u8 background)
void CON_SetColor(u8 foreground, u8 background = 0)
{
u8 bright = foreground & CON_BRIGHT ? 1 : 0;

View File

@ -75,9 +75,9 @@
>
<Tool
Name="VCNMakeTool"
BuildCommandLine="..\..\Binary\$(PlatformName)\DSPTool.exe -h dsp_code tests\dsp_test.ds&#x0D;&#x0A;make -f MakefileGC"
ReBuildCommandLine="make clean&#x0D;&#x0A;..\..\Binary\$(PlatformName)\DSPTool.exe -h dsp_code tests\dsp_code.ds&#x0D;&#x0A;make -f MakefileGC"
CleanCommandLine="make clean"
BuildCommandLine="..\..\Binary\$(PlatformName)\DSPTool.exe -h dsp_code tests\dsp_test.ds&#x0D;&#x0A;make HW_TYPE=gamecube"
ReBuildCommandLine="make HW_TYPE=gamecube clean&#x0D;&#x0A;..\..\Binary\$(PlatformName)\DSPTool.exe -h dsp_code tests\dsp_code.ds&#x0D;&#x0A;make HW_TYPE=gamecube"
CleanCommandLine="make HW_TYPE=gamecube clean"
Output="DSPSpyGC.dol"
PreprocessorDefinitions=""
IncludeSearchPath="$(ProjectDir);C:\devkitPro\libogc\include"
@ -98,9 +98,9 @@
>
<Tool
Name="VCNMakeTool"
BuildCommandLine="..\..\Binary\$(PlatformName)\DSPTool.exe -h dsp_code tests\dsp_test.ds&#x0D;&#x0A;make -f MakefileGC"
ReBuildCommandLine="make clean&#x0D;&#x0A;..\..\Binary\$(PlatformName)\DSPTool.exe -h dsp_code tests\dsp_code.ds&#x0D;&#x0A;make -f MakefileGC"
CleanCommandLine="make clean"
BuildCommandLine="..\..\Binary\$(PlatformName)\DSPTool.exe -h dsp_code tests\dsp_test.ds&#x0D;&#x0A;make HW_TYPE=gamecube"
ReBuildCommandLine="make HW_TYPE=gamecube clean&#x0D;&#x0A;..\..\Binary\$(PlatformName)\DSPTool.exe -h dsp_code tests\dsp_code.ds&#x0D;&#x0A;make HW_TYPE=gamecube"
CleanCommandLine="make HW_TYPE=gamecube clean"
Output="DSPSpyGC.dol"
PreprocessorDefinitions=""
IncludeSearchPath="$(ProjectDir);C:\devkitPro\libogc\include"
@ -130,10 +130,6 @@
RelativePath=".\Makefile"
>
</File>
<File
RelativePath=".\MakefileGC"
>
</File>
<File
RelativePath=".\mem_dump.h"
>

View File

@ -7,7 +7,12 @@ ifeq ($(strip $(DEVKITPPC)),)
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
endif
include $(DEVKITPPC)/wii_rules
#---------------------------------------------------------------------------------
# build for wii by default, make HW_TYPE=gamecube will do what it sounds like
#---------------------------------------------------------------------------------
HW_TYPE = wii
include $(DEVKITPPC)/$(HW_TYPE)_rules
#---------------------------------------------------------------------------------
# TARGET is the name of the output
@ -15,7 +20,7 @@ include $(DEVKITPPC)/wii_rules
# SOURCES is a list of directories containing source code
# INCLUDES is a list of directories containing extra header files
#---------------------------------------------------------------------------------
TARGET := $(notdir $(CURDIR))
TARGET := $(notdir $(CURDIR))_$(HW_TYPE)
BUILD := build
SOURCES := . emu
RESOURCES := ../resources
@ -34,7 +39,11 @@ LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
ifeq ($(HW_TYPE), gamecube)
LIBS := -lfat -lasnd -lmodplay -lz -logc -lm
else
LIBS := -lfat -lasnd -lmodplay -lwiiuse -lbte -lz -logc -lm
endif
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
@ -108,7 +117,11 @@ clean:
@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).dol
#---------------------------------------------------------------------------------
run:
ifeq ($(HW_TYPE), gamecube)
PSOload $(OUTPUT).dol
else
wiiload $(OUTPUT).dol
endif
#---------------------------------------------------------------------------------
else

View File

@ -1,145 +0,0 @@
#---------------------------------------------------------------------------------
# Clear the implicit built in rules
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITPPC)),)
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
endif
include $(DEVKITPPC)/gamecube_rules
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# INCLUDES is a list of directories containing extra header files
#---------------------------------------------------------------------------------
TARGET := $(notdir $(CURDIR))GC
BUILD := build
SOURCES := . emu
RESOURCES := ../resources
DATA := data
INCLUDES := include ../Core/Common/Src .
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
CFLAGS = -save-temps -O2 -Wall --no-strict-aliasing $(MACHDEP) $(INCLUDE)
CXXFLAGS = $(CFLAGS)
LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS := -lfat -lasnd -lmodplay -lz -logc -lm
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS :=
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/$(TARGET)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) $(foreach dir,$(RESOURCES),$(CURDIR)/$(dir))\
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
#---------------------------------------------------------------------------------
# automatically build a list of object files for our project
#---------------------------------------------------------------------------------
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CFILES += $(foreach dir,$(RESOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
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
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
export LD := $(CC)
else
export LD := $(CXX)
endif
export OFILES := $(addsuffix .o,$(BINFILES)) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
$(sFILES:.s=.o) $(SFILES:.S=.o)
#---------------------------------------------------------------------------------
# build a list of include paths
#---------------------------------------------------------------------------------
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD) \
-I$(LIBOGC_INC)
#---------------------------------------------------------------------------------
# build a list of library paths
#---------------------------------------------------------------------------------
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
-L$(LIBOGC_LIB)
export OUTPUT := $(CURDIR)/$(TARGET)
.PHONY: $(BUILD) clean
#---------------------------------------------------------------------------------
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).dol
#---------------------------------------------------------------------------------
run:
PSOload $(OUTPUT).dol
#---------------------------------------------------------------------------------
else
DEPENDS := $(OFILES:.o=.d)
#%.biz: %.ds
# gcdsptool -c $< -o $@
#%.h: %.biz
# raw2c $< $@
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT).dol: $(OUTPUT).elf
$(OUTPUT).elf: $(OFILES)
#---------------------------------------------------------------------------------
# This rule links in binary data with the .bin extension
#---------------------------------------------------------------------------------
#%.bin.o : %.bin
#---------------------------------------------------------------------------------
# @echo $(notdir $<)
# $(bin2o)
-include $(DEPENDS)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------

View File

@ -21,7 +21,9 @@
#include <ogc/irq.h>
#include <ogc/machine/asm.h>
#include <ogc/machine/processor.h>
#ifdef HW_RVL
#include <wiiuse/wpad.h>
#endif
#include "ConsoleHelper.h"
@ -195,6 +197,7 @@ void print_regs(int _step, int _dsp_steps)
void ui_pad_sel(void)
{
#ifdef HW_RVL
if (WPAD_ButtonsDown(0) & WPAD_BUTTON_RIGHT)
cursor_reg += 8;
if (WPAD_ButtonsDown(0) & WPAD_BUTTON_LEFT)
@ -209,10 +212,27 @@ void ui_pad_sel(void)
ui_mode = UIM_EDIT_REG;
reg_value = &dspreg_in[cursor_reg];
}
#else
if (PAD_ButtonsDown(0) & PAD_BUTTON_RIGHT)
cursor_reg += 8;
if (PAD_ButtonsDown(0) & PAD_BUTTON_LEFT)
cursor_reg -= 8;
if (PAD_ButtonsDown(0) & PAD_BUTTON_UP)
cursor_reg--;
if (PAD_ButtonsDown(0) & PAD_BUTTON_DOWN)
cursor_reg++;
cursor_reg &= 0x1f;
if (PAD_ButtonsDown(0) & PAD_BUTTON_A)
{
ui_mode = UIM_EDIT_REG;
reg_value = &dspreg_in[cursor_reg];
}
#endif
}
void ui_pad_edit_reg(void)
{
#ifdef HW_RVL
if (WPAD_ButtonsDown(0) & WPAD_BUTTON_RIGHT)
small_cursor_x++;
if (WPAD_ButtonsDown(0) & WPAD_BUTTON_LEFT)
@ -229,6 +249,24 @@ void ui_pad_edit_reg(void)
*reg_value = 0;
if (WPAD_ButtonsDown(0) & WPAD_BUTTON_2)
*reg_value = 0xffff;
#else
if (PAD_ButtonsDown(0) & PAD_BUTTON_RIGHT)
small_cursor_x++;
if (PAD_ButtonsDown(0) & PAD_BUTTON_LEFT)
small_cursor_x--;
small_cursor_x &= 0x3;
if (PAD_ButtonsDown(0) & PAD_BUTTON_UP)
*reg_value += 0x1 << (4 * (3 - small_cursor_x));
if (PAD_ButtonsDown(0) & PAD_BUTTON_DOWN)
*reg_value -= 0x1 << (4 * (3 - small_cursor_x));
if (PAD_ButtonsDown(0) & PAD_BUTTON_A)
ui_mode = UIM_SEL;
if (PAD_ButtonsDown(0) & PAD_BUTTON_X)
*reg_value = 0;
if (PAD_ButtonsDown(0) & PAD_BUTTON_Y)
*reg_value = 0xffff;
#endif
}
void init_video(void)
@ -313,7 +351,9 @@ int main()
// Both GC and Wii controls.
PAD_Init();
#ifdef HW_RVL
WPAD_Init();
#endif
int dsp_steps = 0;
int show_step = 0;
@ -370,18 +410,29 @@ int main()
VIDEO_WaitVSync();
#ifdef HW_RVL
PAD_ScanPads();
WPAD_ScanPads();
if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME)
if ((WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) || (PAD_ButtonsDown(0) & PAD_BUTTON_START))
exit(0);
print_regs(show_step, dsp_steps);
CON_Printf(2, 18, "Controls:");
CON_Printf(4, 19, "+/- to move");
CON_Printf(4, 20, "B to start over");
CON_Printf(4, 21, "Home to exit");
CON_Printf(4, 22, "2 to dump results to SD");
#else
PAD_ScanPads();
if (PAD_ButtonsDown(0) & PAD_BUTTON_START)
exit(0);
CON_Printf(2, 18, "Controls:");
CON_Printf(4, 19, "L/R to move");
CON_Printf(4, 20, "B to start over");
CON_Printf(4, 21, "Start to exit");
#endif
print_regs(show_step, dsp_steps);
CON_Printf(4, 24, last_message);
@ -402,7 +453,11 @@ int main()
DCFlushRange(xfb, 0x200000);
// Use B to start over.
if ((WPAD_ButtonsDown(0) & WPAD_BUTTON_B) || (PAD_ButtonsDown(0) & PAD_BUTTON_START))
#ifdef HW_RVL
if ((WPAD_ButtonsDown(0) & WPAD_BUTTON_B) || (PAD_ButtonsDown(0) & PAD_BUTTON_B))
#else
if (PAD_ButtonsDown(0) & PAD_BUTTON_B)
#endif
{
dsp_steps = 0; // Let's not add the new steps after the original ones. That was just annoying.
@ -424,16 +479,22 @@ int main()
}
// Navigate between results using + and - buttons.
if ((WPAD_ButtonsDown(0) & WPAD_BUTTON_PLUS) || (PAD_ButtonsDown(0) & PAD_BUTTON_X))
#ifdef HW_RVL
if ((WPAD_ButtonsDown(0) & WPAD_BUTTON_PLUS) || (PAD_ButtonsDown(0) & PAD_TRIGGER_R))
#else
if (PAD_ButtonsDown(0) & PAD_TRIGGER_R)
#endif
{
show_step++;
if (show_step >= dsp_steps)
show_step = 0;
strcpy(last_message, "OK");
}
if ((WPAD_ButtonsDown(0) & WPAD_BUTTON_MINUS) || (PAD_ButtonsDown(0) & PAD_BUTTON_Y))
#ifdef HW_RVL
if ((WPAD_ButtonsDown(0) & WPAD_BUTTON_MINUS) || (PAD_ButtonsDown(0) & PAD_TRIGGER_L))
#else
if (PAD_ButtonsDown(0) & PAD_TRIGGER_L)
#endif
{
show_step--;
if (show_step < 0)
@ -441,6 +502,8 @@ int main()
strcpy(last_message, "OK");
}
#ifdef HW_RVL
// Probably could offer to save to memcard (sd gecko) but i dont have one so meh
if (WPAD_ButtonsDown(0) & WPAD_BUTTON_2)
{
FILE *f = fopen("sd:/dsp_dump.bin", "wb");
@ -459,6 +522,7 @@ int main()
strcpy(last_message, "SD Write Error");
}
}
#endif
}
// Reset the DSP