commit
bf11c2b74b
|
@ -24,7 +24,6 @@ include $(DEVKITPPC)/$(HW_TYPE)_rules
|
|||
TARGET := $(notdir $(CURDIR))_$(HW_TYPE)
|
||||
BUILD := build
|
||||
SOURCES := . emu
|
||||
RESOURCES := ../resources
|
||||
DATA := data
|
||||
INCLUDES := include ../Core/Common .
|
||||
|
||||
|
@ -33,7 +32,7 @@ INCLUDES := include ../Core/Common .
|
|||
#---------------------------------------------------------------------------------
|
||||
|
||||
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
|
||||
|
||||
|
@ -41,9 +40,9 @@ 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 -ldb -logc -lm
|
||||
LIBS := -lfat -ldb -logc -lm
|
||||
else
|
||||
LIBS := -lfat -lasnd -lmodplay -lwiiuse -lbte -logc -lm
|
||||
LIBS := -lfat -lwiiuse -lbte -logc -lm
|
||||
endif
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
|
@ -61,7 +60,7 @@ ifneq ($(BUILD),$(notdir $(CURDIR)))
|
|||
|
||||
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))
|
||||
|
||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||
|
@ -70,7 +69,6 @@ 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)))
|
||||
|
@ -86,14 +84,16 @@ else
|
|||
export LD := $(CXX)
|
||||
endif
|
||||
|
||||
export OFILES := $(addsuffix .o,$(BINFILES)) \
|
||||
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
|
||||
$(sFILES:.s=.o) $(SFILES:.S=.o)
|
||||
export OFILES_BIN := $(addsuffix .o,$(BINFILES))
|
||||
export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.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
|
||||
#---------------------------------------------------------------------------------
|
||||
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
||||
export INCLUDE := $(foreach dir,$(INCLUDES), -iquote $(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||
-I$(CURDIR)/$(BUILD) \
|
||||
-I$(LIBOGC_INC)
|
||||
|
@ -101,8 +101,7 @@ export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
|||
#---------------------------------------------------------------------------------
|
||||
# build a list of library paths
|
||||
#---------------------------------------------------------------------------------
|
||||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
|
||||
-L$(LIBOGC_LIB)
|
||||
export LIBPATHS := -L$(LIBOGC_LIB) $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
||||
|
||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||
.PHONY: $(BUILD) clean
|
||||
|
@ -116,6 +115,7 @@ $(BUILD):
|
|||
clean:
|
||||
@echo clean ...
|
||||
@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).dol
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
run:
|
||||
ifeq ($(HW_TYPE), gamecube)
|
||||
|
@ -139,8 +139,9 @@ DEPENDS := $(OFILES:.o=.d)
|
|||
# main targets
|
||||
#---------------------------------------------------------------------------------
|
||||
$(OUTPUT).dol: $(OUTPUT).elf
|
||||
$(OUTPUT).elf: $(OFILES)
|
||||
$(OUTPUT).elf: $(OFILES)
|
||||
|
||||
$(OFILES_SOURCES) : $(HFILES)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# This rule links in binary data with the .bin extension
|
||||
|
|
|
@ -33,7 +33,7 @@ m0
|
|||
clr15
|
||||
|
||||
;step 1: context setup
|
||||
call send_back_40
|
||||
call send_back
|
||||
|
||||
call 0x807e ; loop until DSP->CPU mailbox is empty
|
||||
si @DMBH, #0xdcd1
|
||||
|
@ -342,44 +342,44 @@ call send_back
|
|||
|
||||
call send_back
|
||||
set40
|
||||
call send_back_40
|
||||
call send_back
|
||||
lri $AR2, #0x0015
|
||||
call send_back_40
|
||||
call send_back
|
||||
lr $AC0.M, @0x0006
|
||||
call send_back_40
|
||||
call send_back
|
||||
lr $AX0.H, @0x165b
|
||||
call send_back_40
|
||||
call send_back
|
||||
call 0x88e5
|
||||
call send_back_40
|
||||
call send_back
|
||||
asr $ACC0, #-3
|
||||
call send_back_40
|
||||
call send_back
|
||||
lsl $ACC0, #3
|
||||
call send_back_40
|
||||
call send_back
|
||||
srri @$AR2, $AC0.M
|
||||
call send_back_40
|
||||
call send_back
|
||||
srri @$AR2, $AC0.L
|
||||
call send_back_40
|
||||
call send_back
|
||||
lri $AR2, #0x0016
|
||||
call send_back_40
|
||||
call send_back
|
||||
lr $AC0.M, @0x1723
|
||||
call send_back_40
|
||||
call send_back
|
||||
asr $ACC0, #-12
|
||||
call send_back_40
|
||||
call send_back
|
||||
lr $AX0.H, @0x166b
|
||||
call send_back_40
|
||||
call send_back
|
||||
call 0x88e5
|
||||
call send_back_40
|
||||
call send_back
|
||||
tst $ACC0
|
||||
call send_back_40
|
||||
call send_back
|
||||
jge Unk_012e
|
||||
call send_back_40
|
||||
call send_back
|
||||
|
||||
clr $ACC0
|
||||
call send_back_40
|
||||
call send_back
|
||||
|
||||
Unk_012e:
|
||||
asr $ACC0, #-3
|
||||
call send_back_40
|
||||
call send_back
|
||||
set16
|
||||
;step 4
|
||||
call send_back
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
// Use Dolphin's dsptool to generate a new dsp_code.h.
|
||||
// Originally written by duddie and modified by FIRES. Then further modified by ector.
|
||||
|
||||
#include <array>
|
||||
#include <debug.h>
|
||||
#include <fat.h>
|
||||
#include <fcntl.h>
|
||||
|
@ -137,14 +138,11 @@ int curUcode = 0, runningUcode = 1;
|
|||
|
||||
int dsp_steps = 0;
|
||||
|
||||
// When comparing regs, ignore the loop stack registers.
|
||||
bool regs_equal(int reg, u16 value1, u16 value2)
|
||||
{
|
||||
if (reg >= DSP_REG_ST0 && reg <= DSP_REG_ST3)
|
||||
return true;
|
||||
else
|
||||
return value1 == value2;
|
||||
}
|
||||
constexpr std::array reg_names = {
|
||||
"ar0", "ar1", "ar2", "ar3", "ix0", "ix1", "ix2", "ix3", "wr0", "wr1", "wr2",
|
||||
"wr3", "st0", "st1", "st2", "st3", "c0h", "c1h", "cr ", "sr ", "pl ", "pm1",
|
||||
"ph ", "pm2", "x0l", "x1l", "x0h", "x1h", "c0l", "c1l", "c0m", "c1m",
|
||||
};
|
||||
|
||||
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.
|
||||
const int reg = j * 8 + i;
|
||||
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)
|
||||
{
|
||||
u8 color1 =
|
||||
regs_equal(reg, regs[reg], compare_regs[reg]) ? CON_BRIGHT_WHITE : CON_BRIGHT_RED;
|
||||
u8 color1 = regs[reg] == compare_regs[reg] ? CON_BRIGHT_WHITE : CON_BRIGHT_RED;
|
||||
for (int k = 0; k < 4; k++)
|
||||
{
|
||||
if (sel == reg && k == small_cursor_x && ui_mode == UIM_EDIT_REG)
|
||||
CON_SetColor(CON_BRIGHT_CYAN);
|
||||
else
|
||||
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]);
|
||||
CON_Printf(x + 2, y + 10, "ACC1: %02x %04x %04x", regs[DSP_REG_ACH1] & 0xff, regs[DSP_REG_ACM1],
|
||||
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 + 12, "AX1: %04x %04x", regs[DSP_REG_AXH1], regs[DSP_REG_AXL1]);
|
||||
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]);
|
||||
|
||||
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)
|
||||
|
@ -187,7 +194,7 @@ void print_regs(int _step, int _dsp_steps)
|
|||
const u16* regs2 = dspreg_out[_step];
|
||||
|
||||
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_Printf(33, 17, "%i / %i ", _step + 1, _dsp_steps);
|
||||
|
|
|
@ -169,10 +169,9 @@ irq:
|
|||
|
||||
; 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.
|
||||
; Unfortunately, this loop uses ar0 so it's best to use AR1 and friends for testing
|
||||
; when messing with indexing.
|
||||
send_back:
|
||||
; make state safe.
|
||||
; first, store $sr so we can modify it
|
||||
sr @(REGS_BASE + 19), $sr
|
||||
set16
|
||||
; store registers to reg table
|
||||
sr @REGS_BASE, $ar0
|
||||
|
@ -195,7 +194,8 @@ send_back:
|
|||
srri @$ar0, $ac0.h
|
||||
srri @$ar0, $ac1.h
|
||||
srri @$ar0, $cr
|
||||
srri @$ar0, $sr
|
||||
; skip $sr since we already stored and modified it
|
||||
iar $ar0
|
||||
srri @$ar0, $prod.l
|
||||
srri @$ar0, $prod.m1
|
||||
srri @$ar0, $prod.h
|
||||
|
@ -257,7 +257,8 @@ dma_copy:
|
|||
lrri $ac0.h, @$ar0
|
||||
lrri $ac1.h, @$ar0
|
||||
lrri $cr, @$ar0
|
||||
lrri $sr, @$ar0
|
||||
; leave $sr for later
|
||||
iar $ar0
|
||||
lrri $prod.l, @$ar0
|
||||
lrri $prod.m1, @$ar0
|
||||
lrri $prod.h, @$ar0
|
||||
|
@ -270,17 +271,10 @@ dma_copy:
|
|||
lrri $ac1.l, @$ar0
|
||||
lrri $ac0.m, @$ar0
|
||||
lrri $ac1.m, @$ar0
|
||||
lr $ar0, @REGS_BASE
|
||||
lr $ar0, @REGS_BASE
|
||||
lr $sr, @(REGS_BASE+19)
|
||||
|
||||
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
|
||||
start_of_test:
|
||||
|
|
|
@ -6,9 +6,6 @@ include "dsp_base.inc"
|
|||
|
||||
; 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
|
||||
call send_back
|
||||
|
||||
|
|
Loading…
Reference in New Issue