Merge pull request #8842 from Tilka/dsp

DSPSpy usability improvements
This commit is contained in:
Markus Wick 2020-06-10 09:14:30 +02:00 committed by GitHub
commit bf11c2b74b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 63 additions and 64 deletions

View File

@ -24,7 +24,6 @@ include $(DEVKITPPC)/$(HW_TYPE)_rules
TARGET := $(notdir $(CURDIR))_$(HW_TYPE) TARGET := $(notdir $(CURDIR))_$(HW_TYPE)
BUILD := build BUILD := build
SOURCES := . emu SOURCES := . emu
RESOURCES := ../resources
DATA := data DATA := data
INCLUDES := include ../Core/Common . INCLUDES := include ../Core/Common .
@ -33,7 +32,7 @@ INCLUDES := include ../Core/Common .
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
CFLAGS = -save-temps -O2 -Wall --no-strict-aliasing $(MACHDEP) $(INCLUDE) CFLAGS = -save-temps -O2 -Wall --no-strict-aliasing $(MACHDEP) $(INCLUDE)
CXXFLAGS = -std=c++0x $(CFLAGS) CXXFLAGS = -std=c++17 -Wno-register $(CFLAGS)
LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map
@ -41,9 +40,9 @@ LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map
# any extra libraries we wish to link with the project # any extra libraries we wish to link with the project
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
ifeq ($(HW_TYPE), gamecube) ifeq ($(HW_TYPE), gamecube)
LIBS := -lfat -lasnd -lmodplay -ldb -logc -lm LIBS := -lfat -ldb -logc -lm
else else
LIBS := -lfat -lasnd -lmodplay -lwiiuse -lbte -logc -lm LIBS := -lfat -lwiiuse -lbte -logc -lm
endif endif
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
@ -61,7 +60,7 @@ ifneq ($(BUILD),$(notdir $(CURDIR)))
export OUTPUT := $(CURDIR)/$(TARGET) export OUTPUT := $(CURDIR)/$(TARGET)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) $(foreach dir,$(RESOURCES),$(CURDIR)/$(dir))\ export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir)) $(foreach dir,$(DATA),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD) export DEPSDIR := $(CURDIR)/$(BUILD)
@ -70,7 +69,6 @@ export DEPSDIR := $(CURDIR)/$(BUILD)
# automatically build a list of object files for our project # automatically build a list of object files for our project
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CFILES += $(foreach dir,$(RESOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S))) SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
@ -86,14 +84,16 @@ else
export LD := $(CXX) export LD := $(CXX)
endif endif
export OFILES := $(addsuffix .o,$(BINFILES)) \ export OFILES_BIN := $(addsuffix .o,$(BINFILES))
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \ export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(sFILES:.s=.o) $(SFILES:.S=.o)
$(sFILES:.s=.o) $(SFILES:.S=.o) export OFILES := $(OFILES_BIN) $(OFILES_SOURCES)
export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES)))
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# build a list of include paths # build a list of include paths
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ export INCLUDE := $(foreach dir,$(INCLUDES), -iquote $(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \ $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD) \ -I$(CURDIR)/$(BUILD) \
-I$(LIBOGC_INC) -I$(LIBOGC_INC)
@ -101,8 +101,7 @@ export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# build a list of library paths # build a list of library paths
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \ export LIBPATHS := -L$(LIBOGC_LIB) $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
-L$(LIBOGC_LIB)
export OUTPUT := $(CURDIR)/$(TARGET) export OUTPUT := $(CURDIR)/$(TARGET)
.PHONY: $(BUILD) clean .PHONY: $(BUILD) clean
@ -116,6 +115,7 @@ $(BUILD):
clean: clean:
@echo clean ... @echo clean ...
@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).dol @rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).dol
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
run: run:
ifeq ($(HW_TYPE), gamecube) ifeq ($(HW_TYPE), gamecube)
@ -139,8 +139,9 @@ DEPENDS := $(OFILES:.o=.d)
# main targets # main targets
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
$(OUTPUT).dol: $(OUTPUT).elf $(OUTPUT).dol: $(OUTPUT).elf
$(OUTPUT).elf: $(OFILES) $(OUTPUT).elf: $(OFILES)
$(OFILES_SOURCES) : $(HFILES)
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# This rule links in binary data with the .bin extension # This rule links in binary data with the .bin extension

View File

@ -33,7 +33,7 @@ m0
clr15 clr15
;step 1: context setup ;step 1: context setup
call send_back_40 call send_back
call 0x807e ; loop until DSP->CPU mailbox is empty call 0x807e ; loop until DSP->CPU mailbox is empty
si @DMBH, #0xdcd1 si @DMBH, #0xdcd1
@ -342,44 +342,44 @@ call send_back
call send_back call send_back
set40 set40
call send_back_40 call send_back
lri $AR2, #0x0015 lri $AR2, #0x0015
call send_back_40 call send_back
lr $AC0.M, @0x0006 lr $AC0.M, @0x0006
call send_back_40 call send_back
lr $AX0.H, @0x165b lr $AX0.H, @0x165b
call send_back_40 call send_back
call 0x88e5 call 0x88e5
call send_back_40 call send_back
asr $ACC0, #-3 asr $ACC0, #-3
call send_back_40 call send_back
lsl $ACC0, #3 lsl $ACC0, #3
call send_back_40 call send_back
srri @$AR2, $AC0.M srri @$AR2, $AC0.M
call send_back_40 call send_back
srri @$AR2, $AC0.L srri @$AR2, $AC0.L
call send_back_40 call send_back
lri $AR2, #0x0016 lri $AR2, #0x0016
call send_back_40 call send_back
lr $AC0.M, @0x1723 lr $AC0.M, @0x1723
call send_back_40 call send_back
asr $ACC0, #-12 asr $ACC0, #-12
call send_back_40 call send_back
lr $AX0.H, @0x166b lr $AX0.H, @0x166b
call send_back_40 call send_back
call 0x88e5 call 0x88e5
call send_back_40 call send_back
tst $ACC0 tst $ACC0
call send_back_40 call send_back
jge Unk_012e jge Unk_012e
call send_back_40 call send_back
clr $ACC0 clr $ACC0
call send_back_40 call send_back
Unk_012e: Unk_012e:
asr $ACC0, #-3 asr $ACC0, #-3
call send_back_40 call send_back
set16 set16
;step 4 ;step 4
call send_back call send_back

View File

@ -9,6 +9,7 @@
// Use Dolphin's dsptool to generate a new dsp_code.h. // Use Dolphin's dsptool to generate a new dsp_code.h.
// Originally written by duddie and modified by FIRES. Then further modified by ector. // Originally written by duddie and modified by FIRES. Then further modified by ector.
#include <array>
#include <debug.h> #include <debug.h>
#include <fat.h> #include <fat.h>
#include <fcntl.h> #include <fcntl.h>
@ -137,14 +138,11 @@ int curUcode = 0, runningUcode = 1;
int dsp_steps = 0; int dsp_steps = 0;
// When comparing regs, ignore the loop stack registers. constexpr std::array reg_names = {
bool regs_equal(int reg, u16 value1, u16 value2) "ar0", "ar1", "ar2", "ar3", "ix0", "ix1", "ix2", "ix3", "wr0", "wr1", "wr2",
{ "wr3", "st0", "st1", "st2", "st3", "c0h", "c1h", "cr ", "sr ", "pl ", "pm1",
if (reg >= DSP_REG_ST0 && reg <= DSP_REG_ST3) "ph ", "pm2", "x0l", "x1l", "x0h", "x1h", "c0l", "c1l", "c0m", "c1m",
return true; };
else
return value1 == value2;
}
void print_reg_block(int x, int y, int sel, const u16* regs, const u16* compare_regs) void print_reg_block(int x, int y, int sel, const u16* regs, const u16* compare_regs)
{ {
@ -155,18 +153,17 @@ void print_reg_block(int x, int y, int sel, const u16* regs, const u16* compare_
// Do not even display the loop stack registers. // Do not even display the loop stack registers.
const int reg = j * 8 + i; const int reg = j * 8 + i;
CON_SetColor(sel == reg ? CON_BRIGHT_YELLOW : CON_GREEN); CON_SetColor(sel == reg ? CON_BRIGHT_YELLOW : CON_GREEN);
CON_Printf(x + j * 8, i + y, "%02x ", reg); CON_Printf(x + j * 9, i + y, "%s ", reg_names[reg]);
if (j != 1 || i < 4) if (j != 1 || i < 4)
{ {
u8 color1 = u8 color1 = regs[reg] == compare_regs[reg] ? CON_BRIGHT_WHITE : CON_BRIGHT_RED;
regs_equal(reg, regs[reg], compare_regs[reg]) ? CON_BRIGHT_WHITE : CON_BRIGHT_RED;
for (int k = 0; k < 4; k++) for (int k = 0; k < 4; k++)
{ {
if (sel == reg && k == small_cursor_x && ui_mode == UIM_EDIT_REG) if (sel == reg && k == small_cursor_x && ui_mode == UIM_EDIT_REG)
CON_SetColor(CON_BRIGHT_CYAN); CON_SetColor(CON_BRIGHT_CYAN);
else else
CON_SetColor(color1); CON_SetColor(color1);
CON_Printf(x + 3 + j * 8 + k, i + y, "%01x", (regs[reg] >> ((3 - k) * 4)) & 0xf); CON_Printf(x + 4 + j * 9 + k, i + y, "%01x", (regs[reg] >> ((3 - k) * 4)) & 0xf);
} }
} }
} }
@ -177,8 +174,18 @@ void print_reg_block(int x, int y, int sel, const u16* regs, const u16* compare_
regs[DSP_REG_ACL0]); regs[DSP_REG_ACL0]);
CON_Printf(x + 2, y + 10, "ACC1: %02x %04x %04x", regs[DSP_REG_ACH1] & 0xff, regs[DSP_REG_ACM1], CON_Printf(x + 2, y + 10, "ACC1: %02x %04x %04x", regs[DSP_REG_ACH1] & 0xff, regs[DSP_REG_ACM1],
regs[DSP_REG_ACL1]); regs[DSP_REG_ACL1]);
CON_Printf(x + 2, y + 11, "AX0: %04x %04x", regs[DSP_REG_AXH0], regs[DSP_REG_AXL0]); CON_Printf(x + 2, y + 11, "AX0: %04x %04x", regs[DSP_REG_AXH0], regs[DSP_REG_AXL0]);
CON_Printf(x + 2, y + 12, "AX1: %04x %04x", regs[DSP_REG_AXH1], regs[DSP_REG_AXL1]); CON_Printf(x + 2, y + 12, "AX1: %04x %04x", regs[DSP_REG_AXH1], regs[DSP_REG_AXL1]);
u64 prod = (u64(regs[DSP_REG_PRODH]) << 32) + (u64(regs[DSP_REG_PRODM]) << 16) +
(u64(regs[DSP_REG_PRODM2]) << 16) + u64(regs[DSP_REG_PRODL]);
CON_Printf(x + 2, y + 13, "PROD: %02x %04x %04x", (prod >> 32) & 0xff, (prod >> 16) & 0xffff,
prod & 0xffff);
CON_Printf(x + 2, y + 14, "SR:");
for (int i = 0; i < 16; ++i)
CON_Printf(x + 6 + i + i / 4, y + 14, "%c", regs[DSP_REG_SR] & (1 << (15 - i)) ? '1' : '0');
CON_Printf(x + 21, y + 15, "SZOC");
} }
void print_regs(int _step, int _dsp_steps) void print_regs(int _step, int _dsp_steps)
@ -187,7 +194,7 @@ void print_regs(int _step, int _dsp_steps)
const u16* regs2 = dspreg_out[_step]; const u16* regs2 = dspreg_out[_step];
print_reg_block(0, 2, _step == 0 ? cursor_reg : -1, regs, regs2); print_reg_block(0, 2, _step == 0 ? cursor_reg : -1, regs, regs2);
print_reg_block(33, 2, -1, regs2, regs); print_reg_block(38, 2, -1, regs2, regs);
CON_SetColor(CON_WHITE); CON_SetColor(CON_WHITE);
CON_Printf(33, 17, "%i / %i ", _step + 1, _dsp_steps); CON_Printf(33, 17, "%i / %i ", _step + 1, _dsp_steps);

View File

@ -169,10 +169,9 @@ irq:
; DMA:s the current state of the registers back to the PowerPC. To do this, ; DMA:s the current state of the registers back to the PowerPC. To do this,
; it must write the contents of all regs to DRAM. ; it must write the contents of all regs to DRAM.
; Unfortunately, this loop uses ar0 so it's best to use AR1 and friends for testing
; when messing with indexing.
send_back: send_back:
; make state safe. ; first, store $sr so we can modify it
sr @(REGS_BASE + 19), $sr
set16 set16
; store registers to reg table ; store registers to reg table
sr @REGS_BASE, $ar0 sr @REGS_BASE, $ar0
@ -195,7 +194,8 @@ send_back:
srri @$ar0, $ac0.h srri @$ar0, $ac0.h
srri @$ar0, $ac1.h srri @$ar0, $ac1.h
srri @$ar0, $cr srri @$ar0, $cr
srri @$ar0, $sr ; skip $sr since we already stored and modified it
iar $ar0
srri @$ar0, $prod.l srri @$ar0, $prod.l
srri @$ar0, $prod.m1 srri @$ar0, $prod.m1
srri @$ar0, $prod.h srri @$ar0, $prod.h
@ -257,7 +257,8 @@ dma_copy:
lrri $ac0.h, @$ar0 lrri $ac0.h, @$ar0
lrri $ac1.h, @$ar0 lrri $ac1.h, @$ar0
lrri $cr, @$ar0 lrri $cr, @$ar0
lrri $sr, @$ar0 ; leave $sr for later
iar $ar0
lrri $prod.l, @$ar0 lrri $prod.l, @$ar0
lrri $prod.m1, @$ar0 lrri $prod.m1, @$ar0
lrri $prod.h, @$ar0 lrri $prod.h, @$ar0
@ -270,17 +271,10 @@ dma_copy:
lrri $ac1.l, @$ar0 lrri $ac1.l, @$ar0
lrri $ac0.m, @$ar0 lrri $ac0.m, @$ar0
lrri $ac1.m, @$ar0 lrri $ac1.m, @$ar0
lr $ar0, @REGS_BASE lr $ar0, @REGS_BASE
lr $sr, @(REGS_BASE+19)
ret ; from send_back ret ; from send_back
; If you are in set40 mode, use this instead of send_back if you want to stay
; in set40 mode.
send_back_40:
set16
call send_back
set40
ret
; Obviously this must be included directly before your test code ; Obviously this must be included directly before your test code
start_of_test: start_of_test:

View File

@ -6,9 +6,6 @@ include "dsp_base.inc"
; We can call send_back at any time to send data back to the PowerPC. ; We can call send_back at any time to send data back to the PowerPC.
; Calling set40 here seemed to crash the dsp tester in strange ways
; until I added set16 in send_back. Seems clear that it affects something important.
lri $AC0.M, #0x1000 lri $AC0.M, #0x1000
call send_back call send_back