Skip to content

Commit 186e6b2

Browse files
Upgrade to pp2d
1 parent c7943aa commit 186e6b2

File tree

9 files changed

+570
-145
lines changed

9 files changed

+570
-145
lines changed

.gitmodules

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
[submodule "buildtools"]
2-
path = buildtools
3-
url = https://github.com/Steveice10/buildtools.git
1+
[submodule "source/pp2d"]
2+
path = source/pp2d
3+
url = https://github.com/BernardoGiordano/pp2d

Makefile

Lines changed: 232 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,258 @@
1-
# TARGET #
1+
#---------------------------------------------------------------------------------
2+
.SUFFIXES:
3+
#---------------------------------------------------------------------------------
24

3-
TARGET := 3DS
4-
LIBRARY := 0
5-
6-
ifeq ($(TARGET),$(filter $(TARGET),3DS WIIU))
7-
ifeq ($(strip $(DEVKITPRO)),)
8-
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPro")
9-
endif
5+
ifeq ($(strip $(DEVKITARM)),)
6+
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
107
endif
118

12-
# COMMON CONFIGURATION #
9+
TOPDIR ?= $(CURDIR)
10+
include $(DEVKITARM)/3ds_rules
11+
12+
# Your values.
13+
APP_TITLE := Pickr3DS
14+
APP_DESCRIPTION := Pickr port for 3DS
15+
APP_AUTHOR := Bernardo Giordano
1316

14-
NAME := Pickr3DS
17+
TARGET := $(subst $e ,_,$(notdir $(APP_TITLE)))
18+
OUTDIR := output
19+
BUILD := build
20+
SOURCES := source/pp2d/pp2d source
21+
INCLUDES := include
22+
ROMFS := assets/romfs
1523

16-
BUILD_DIR := build
17-
OUTPUT_DIR := output
18-
INCLUDE_DIRS :=
19-
SOURCE_DIRS := source
24+
# Path to the files
25+
# If left blank, will try to use "icon.png", "$(TARGET).png", or the default ctrulib icon, in that order
26+
ICON := assets/icon.png
2027

21-
EXTRA_OUTPUT_FILES :=
28+
BANNER_AUDIO := assets/audio.wav
29+
BANNER_IMAGE := assets/banner.png
2230

23-
PORTLIBS_PATH := $(DEVKITPRO)/portlibs
24-
PORTLIBS := $(PORTLIBS_PATH)/armv6k $(PORTLIBS_PATH)/3ds
25-
CTRULIB ?= $(DEVKITPRO)/libctru
31+
RSF_PATH := assets/app.rsf
2632

27-
LIBRARY_DIRS := $(PORTLIBS) $(CTRULIB)
28-
LIBRARIES := sfil sftd freetype png z sf2d citro3d ctru m
33+
# If left blank, makerom will use the default Homebrew logo
34+
LOGO :=
2935

30-
BUILD_FLAGS := -march=armv6k -mtune=mpcore -mfloat-abi=hard
31-
BUILD_FLAGS_CC := -g -Wall -O2 -mword-relocations \
32-
-fomit-frame-pointer -ffast-math \
33-
$(BUILD_FLAGS) $(INCLUDE) -DARM11 -D_3DS
34-
BUILD_FLAGS_CXX := $(BUILD_FLAGS_CC) -fno-rtti -fno-exceptions -std=gnu++11
35-
RUN_FLAGS :=
36+
37+
# If left blank, makerom will use default values (0xff3ff and CTR-P-CTAP, respectively)
38+
# Be careful if UNIQUE_ID is the same as other apps: it will overwrite the previously installed one
39+
UNIQUE_ID := 0x1CF00
40+
PRODUCT_CODE := CTR-HB-PICK
3641

3742
VERSION_MAJOR := 1
38-
VERSION_MINOR := 0
43+
VERSION_MINOR := 1
3944
VERSION_MICRO := 0
4045

41-
REMOTE_IP := 192.168.1.6
46+
ROSALINA := 0
47+
48+
# Don't really need to change this
49+
ICON_FLAGS := nosavebackups,visible
50+
51+
#---------------------------------------------------------------------------------
52+
# options for code generation
53+
#---------------------------------------------------------------------------------
54+
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
55+
56+
CFLAGS := -g -Wall -Wextra -O3 -mword-relocations \
57+
-fomit-frame-pointer -ffunction-sections \
58+
$(ARCH) \
59+
-DVERSION_MAJOR=${VERSION_MAJOR} \
60+
-DVERSION_MINOR=${VERSION_MINOR} \
61+
-DVERSION_MICRO=${VERSION_MICRO}
62+
63+
CFLAGS += $(INCLUDE) -DARM11 -D_3DS -D_GNU_SOURCE
64+
65+
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
66+
67+
ASFLAGS := -g $(ARCH)
68+
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
69+
70+
LIBS := -lcitro3d -lctru -lm
71+
72+
#---------------------------------------------------------------------------------
73+
# list of directories containing libraries, this must be the top level containing
74+
# include and lib
75+
#---------------------------------------------------------------------------------
76+
LIBDIRS := $(CTRULIB)
77+
78+
79+
#---------------------------------------------------------------------------------
80+
# no real need to edit anything past this point unless you need to add additional
81+
# rules for different file extensions
82+
#---------------------------------------------------------------------------------
83+
ifneq ($(BUILD),$(notdir $(CURDIR)))
84+
#---------------------------------------------------------------------------------
4285

43-
# 3DS/Wii U CONFIGURATION #
86+
export OUTPUT := $(CURDIR)/$(OUTDIR)/$(TARGET)
87+
export TOPDIR := $(CURDIR)
88+
89+
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
90+
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
91+
92+
export DEPSDIR := $(CURDIR)/$(BUILD)
93+
94+
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
95+
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
96+
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
97+
PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
98+
SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
99+
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
100+
101+
#---------------------------------------------------------------------------------
102+
# use CXX for linking C++ projects, CC for standard C
103+
#---------------------------------------------------------------------------------
104+
ifeq ($(strip $(CPPFILES)),)
105+
#---------------------------------------------------------------------------------
106+
export LD := $(CC)
107+
#---------------------------------------------------------------------------------
108+
else
109+
#---------------------------------------------------------------------------------
110+
export LD := $(CXX)
111+
#---------------------------------------------------------------------------------
112+
endif
113+
#---------------------------------------------------------------------------------
114+
115+
export OFILES := $(addsuffix .o,$(BINFILES)) \
116+
$(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.o) \
117+
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
118+
119+
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
120+
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
121+
-I$(CURDIR)/$(BUILD)
122+
123+
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
124+
125+
ifeq ($(strip $(ICON)),)
126+
icons := $(wildcard *.png)
127+
ifneq (,$(findstring $(TARGET).png,$(icons)))
128+
export APP_ICON := $(TOPDIR)/$(TARGET).png
129+
else
130+
ifneq (,$(findstring icon.png,$(icons)))
131+
export APP_ICON := $(TOPDIR)/icon.png
132+
endif
133+
endif
134+
else
135+
export APP_ICON := $(TOPDIR)/$(ICON)
136+
endif
137+
138+
ifeq ($(strip $(NO_SMDH)),)
139+
export _3DSXFLAGS += --smdh=$(OUTPUT).smdh
140+
endif
44141

45-
ifeq ($(TARGET),$(filter $(TARGET),3DS WIIU))
46-
TITLE := $(NAME)
47-
DESCRIPTION := Pickr port for 3DS
48-
AUTHOR := Bernardo Giordano
142+
ifneq ($(ROMFS),)
143+
export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
49144
endif
50145

51-
# 3DS CONFIGURATION #
146+
.PHONY: $(BUILD) clean all
52147

53-
ifeq ($(TARGET),3DS)
54-
LIBRARY_DIRS +=
55-
LIBRARIES +=
148+
#---------------------------------------------------------------------------------
149+
3dsx: $(BUILD) $(OUTPUT).3dsx
56150

57-
PRODUCT_CODE := CTR-HB-PICK
58-
UNIQUE_ID := 0x1CF00
151+
cia : $(BUILD) $(OUTPUT).cia
59152

60-
CATEGORY := Application
61-
USE_ON_SD := true
153+
all: 3dsx cia
62154

63-
MEMORY_TYPE := Application
64-
SYSTEM_MODE := 64MB
65-
SYSTEM_MODE_EXT := Legacy
66-
CPU_SPEED := 268MHz
67-
ENABLE_L2_CACHE := true
155+
#---------------------------------------------------------------------------------
156+
$(BUILD):
157+
@mkdir -p $(OUTDIR)
158+
@[ -d "$@" ] || mkdir -p "$@"
159+
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
68160

69-
ICON_FLAGS := --flags visible,ratingrequired,recordusage --cero 153 --esrb 153 --usk 153 --pegigen 153 --pegiptr 153 --pegibbfc 153 --cob 153 --grb 153 --cgsrr 153
161+
#---------------------------------------------------------------------------------
162+
clean:
163+
@echo clean ...
164+
@rm -fr $(BUILD) $(OUTDIR)
70165

71-
ROMFS_DIR := assets/romfs
72-
BANNER_AUDIO := assets/audio.wav
73-
BANNER_IMAGE := assets/banner.png
74-
ICON := assets/icon.png
75-
LOGO :=
166+
#---------------------------------------------------------------------------------
167+
ifeq ($(strip $(NO_SMDH)),)
168+
$(OUTPUT).3dsx : $(OUTPUT).elf $(OUTPUT).smdh
169+
else
170+
$(OUTPUT).3dsx : $(OUTPUT).elf
76171
endif
77172

78-
# INTERNAL #
173+
#---------------------------------------------------------------------------------
174+
MAKEROM ?= makerom
79175

80-
include buildtools/make_base
176+
MAKEROM_ARGS := -elf "$(OUTPUT).elf" -rsf "$(RSF_PATH)" -ver "$$(($(VERSION_MAJOR)*1024+$(VERSION_MINOR)*16+$(VERSION_MICRO)))" -banner "$(BUILD)/banner.bnr" -icon "$(BUILD)/icon.icn" -DAPP_TITLE="$(APP_TITLE)" -DAPP_PRODUCT_CODE="$(PRODUCT_CODE)" -DAPP_UNIQUE_ID="$(UNIQUE_ID)"
177+
178+
ifneq ($(strip $(LOGO)),)
179+
MAKEROM_ARGS += -logo "$(LOGO)"
180+
endif
181+
182+
ifeq ($(strip $(ROMFS)),)
183+
$(OUTPUT).cia: $(OUTPUT).elf $(BUILD)/banner.bnr $(BUILD)/icon.icn
184+
$(MAKEROM) -f cia -o "$@" -target t -exefslogo $(MAKEROM_ARGS)
185+
else
186+
$(OUTPUT).cia: $(OUTPUT).elf $(BUILD)/banner.bnr $(BUILD)/icon.icn
187+
$(MAKEROM) -f cia -o "$@" -target t -exefslogo $(MAKEROM_ARGS)
188+
endif
189+
190+
191+
BANNERTOOL ?= bannertool
192+
193+
ifeq ($(suffix $(BANNER_IMAGE)),.cgfx)
194+
BANNER_IMAGE_ARG := -ci
195+
else
196+
BANNER_IMAGE_ARG := -i
197+
endif
198+
199+
ifeq ($(suffix $(BANNER_AUDIO)),.cwav)
200+
BANNER_AUDIO_ARG := -ca
201+
else
202+
BANNER_AUDIO_ARG := -a
203+
endif
204+
205+
$(BUILD)/banner.bnr : $(BANNER_IMAGE) $(BANNER_AUDIO)
206+
$(BANNERTOOL) makebanner $(BANNER_IMAGE_ARG) "$(BANNER_IMAGE)" $(BANNER_AUDIO_ARG) "$(BANNER_AUDIO)" -o "$@"
207+
208+
$(BUILD)/icon.icn : $(APP_ICON)
209+
$(BANNERTOOL) makesmdh -s "$(APP_TITLE)" -l "$(APP_DESCRIPTION)" -p "$(APP_AUTHOR)" -i "$(APP_ICON)" -f "$(ICON_FLAGS)" -o "$@"
210+
211+
#---------------------------------------------------------------------------------
212+
else
213+
214+
DEPENDS := $(OFILES:.o=.d)
215+
216+
#---------------------------------------------------------------------------------
217+
# main targets
218+
#---------------------------------------------------------------------------------
219+
220+
$(OUTPUT).elf : $(OFILES)
221+
222+
#---------------------------------------------------------------------------------
223+
# you need a rule like this for each extension you use as binary data
224+
#---------------------------------------------------------------------------------
225+
%.bin.o : %.bin
226+
#---------------------------------------------------------------------------------
227+
@echo $(notdir $<)
228+
@$(bin2o)
229+
230+
#---------------------------------------------------------------------------------
231+
# rules for assembling GPU shaders
232+
#---------------------------------------------------------------------------------
233+
define shader-as
234+
$(eval CURBIN := $(patsubst %.shbin.o,%.shbin,$(notdir $@)))
235+
picasso -o $(CURBIN) $1
236+
bin2s $(CURBIN) | $(AS) -o $@
237+
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
238+
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
239+
echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
240+
endef
241+
242+
%.shbin.o : %.v.pica %.g.pica
243+
@echo $(notdir $^)
244+
@$(call shader-as,$^)
245+
246+
%.shbin.o : %.v.pica
247+
@echo $(notdir $<)
248+
@$(call shader-as,$<)
249+
250+
%.shbin.o : %.shlist
251+
@echo $(notdir $<)
252+
@$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file)))
253+
254+
-include $(DEPENDS)
255+
256+
#---------------------------------------------------------------------------------------
257+
endif
258+
#---------------------------------------------------------------------------------------

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,4 @@ This completely is a **just for fun** project; I actually decided to challenge m
1111
## Credits
1212

1313
* Sean M. Tracey, for the idea
14-
* Madebyoliver, for the heart icon
15-
* [Cocogoose font](http://www.zetafonts.com/collection/308) by Zetafonts.
14+
* Madebyoliver, for the heart icon

0 commit comments

Comments
 (0)