Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apbp fix #45

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions dspapbptester/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
*.3dsx
*.elf
*.cxi
*.cia
build/
hide/

# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Mac crap
.DS_Store

171 changes: 171 additions & 0 deletions dspapbptester/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------

ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif

TOPDIR ?= $(CURDIR)
include $(DEVKITARM)/3ds_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
# DATA is a list of directories containing data files
# INCLUDES is a list of directories containing header files
# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
#---------------------------------------------------------------------------------
TARGET := $(notdir $(CURDIR))
BUILD := build
SOURCES := source
DATA := data
INCLUDES := include
#ROMFS := romfs

#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft

CFLAGS := -g -Wall -O2 -mword-relocations \
-fomit-frame-pointer -ffunction-sections \
$(ARCH)

CFLAGS += $(INCLUDE) -DARM11 -D_3DS

CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11

ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)

LIBS := -lctru -lm

#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(CTRULIB)


ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------

export OUTPUT := $(CURDIR)/$(TARGET)
export TOPDIR := $(CURDIR)

export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))

export DEPSDIR := $(CURDIR)/$(BUILD)

CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
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)) \
$(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.o) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)

export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)

export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)

.PHONY: $(BUILD) clean all

#---------------------------------------------------------------------------------
all: $(BUILD)

$(BUILD):
@[ -d $@ ] || mkdir -p $@
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile

#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(TARGET).cxi $(TARGET).cia $(TARGET).elf


#---------------------------------------------------------------------------------
else

DEPENDS := $(OFILES:.o=.d)

#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
all: $(OUTPUT).3dsx $(OUTPUT).cia

ifeq ($(strip $(NO_SMDH)),)
$(OUTPUT).3dsx : $(OUTPUT).elf $(OUTPUT).smdh
else
$(OUTPUT).3dsx : $(OUTPUT).elf
endif

$(OUTPUT).cia : $(OUTPUT).cxi
@makerom -f cia -o $(OUTPUT).cia -target t -i $(OUTPUT).cxi:0:0
@echo built ... $(OUTPUT).cia

$(OUTPUT).cxi : $(OUTPUT).elf $(OUTPUT).smdh $(TOPDIR)/rsf.rsf $(TOPDIR)/banner.bnr
@makerom -o $(OUTPUT).cxi -rsf $(TOPDIR)/rsf.rsf -target t -elf $(OUTPUT).elf -icon $(OUTPUT).smdh -banner $(TOPDIR)/banner.bnr
@echo built ... $(OUTPUT).cxi

$(OUTPUT).elf : $(OFILES)

#---------------------------------------------------------------------------------
# you need a rule like this for each extension you use as binary data
#---------------------------------------------------------------------------------
%.bin.o : %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)

#---------------------------------------------------------------------------------
# rules for assembling GPU shaders
#---------------------------------------------------------------------------------
define shader-as
$(eval CURBIN := $(patsubst %.shbin.o,%.shbin,$(notdir $@)))
picasso -o $(CURBIN) $1
bin2s $(CURBIN) | $(AS) -o $@
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
endef

%.shbin.o : %.v.pica %.g.pica
@echo $(notdir $^)
@$(call shader-as,$^)

%.shbin.o : %.v.pica
@echo $(notdir $<)
@$(call shader-as,$<)

%.shbin.o : %.shlist
@echo $(notdir $<)
@$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file)))

-include $(DEPENDS)

#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------
Binary file added dspapbptester/banner.bnr
Binary file not shown.
Binary file added dspapbptester/data/cdc.bin
Binary file not shown.
Binary file added dspapbptester/dspapbptester.smdh
Binary file not shown.
135 changes: 135 additions & 0 deletions dspapbptester/firm/source
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
segment p 0000
br 0x00000000 always // reset vector
data 0800
reti always
data 0000
reti always
data 0000
br 0x00000000 always // int0
data 5000
data 0000
data 0000
data 0000
data 0000
data 0000
data 0000
reti always // int1
data 0000
data 0000
data 0000
data 0000
data 0000
data 0000
data 0000
reti always // int2

segment p 0800 // init
mov 0x0000 sp // set stack pointer
data 0xF000
mov 0x0000 mod3 // enable interrupt
data 0x0180
load 0x0082u8 page // configure ICU
mov 0x0000 r0
data 0x4000
mov r0 [page:0x000eu8]
mov r0 [page:0x0010u8]
mov r0 [page:0x0006u8] // enable apbp as int0
br 0x00000000 always
data 0x1000

segment p 1000 // Main loop
load 0x0000u8 page

mov 0x0000 r0 // transfer APBP register
data 0x80CC
mov [r0++] r1
mov r1 [page:0x0005u8]
modr [r0++]
mov [r0++] r1
mov r1 [page:0x0006u8]
modr [r0++]
mov [r0++] r1
mov r1 [page:0x0007u8]
modr [r0++]
mov [r0++] r1
mov r1 [page:0x0008u8]
modr [r0++]
mov [r0++] r1
mov r1 [page:0x0009u8]
modr [r0++]
mov [r0++] r1
mov r1 [page:0x000au8]
modr [r0++]
mov [r0++] r1
mov r1 [page:0x000bu8]
modr [r0++]


mov [page:0x0000u8] b0l // get signal
br 0x00000000 eq // loop back if no signal
data 1000

mov [page:0x0001u8] b0l // get command type

cmpv 0x0000 b0l
data 0000
br 0x00000000 eq
data 2000

cmpv 0x0000 b0l
data 0001
br 0x00000000 eq
data 3000

br 0x00000000 always
data 4000

segment p 2000 // read
mov [page:0x0002u8] r0
mov [r0] r1
mov r1 [page:0x0003u8]
br 0x00000000 always
data 4000

segment p 3000 // write
mov [page:0x0002u8] r0
mov [page:0x0003u8] r1
mov r1 [r0]
br 0x00000000 always
data 4000

segment p 4000 // end
clr b0 always
mov b0l [page:0x0000u8] // clear signal
br 0x00000000 always
data 1000 // loop back

segment p 5000 // interrupt handler
mov 0x0000 r5
data 0x4000
mov 0x0000 r4
data 0x8202
mov r5 [r4] // ack
mov 0x0000 r4
data 0x0004
mov [r4] r5
modr [r5++]
mov r5 [r4]
reti always




segment d 0000 // signal area
data 0000 // 0, Start signal
data 0000 // 1, Operation type
data 0000 // 2, Address
data 0000 // 3, Data
data 0000 // 4, interrupt counter
data 0000 // 5, 80CC
data 0000 // 6, 80CE
data 0000 // 7, 80D0
data 0000 // 8, 80D2
data 0000 // 9, 80D4
data 0000 // A, 80D6
data 0000 // B, 80D8
Loading