Skip to content

Commit 1cd427d

Browse files
committed
Switch port
1 parent fbb708c commit 1cd427d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+28283
-26760
lines changed

.clang-format

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
Language: Cpp
3+
# BasedOnStyle: Google
4+
AccessModifierOffset: -1
5+
AlignAfterOpenBracket: true
6+
AlignConsecutiveAssignments: false
7+
AlignEscapedNewlinesLeft: true
8+
AlignOperands: true
9+
AlignTrailingComments: true
10+
AllowAllParametersOfDeclarationOnNextLine: true
11+
AllowShortBlocksOnASingleLine: false
12+
AllowShortCaseLabelsOnASingleLine: false
13+
AllowShortFunctionsOnASingleLine: All
14+
AllowShortIfStatementsOnASingleLine: true
15+
AllowShortLoopsOnASingleLine: true
16+
AlwaysBreakAfterDefinitionReturnType: None
17+
AlwaysBreakBeforeMultilineStrings: true
18+
AlwaysBreakTemplateDeclarations: true
19+
BinPackArguments: true
20+
BinPackParameters: true
21+
BreakBeforeBinaryOperators: None
22+
BreakBeforeBraces: Attach
23+
BreakBeforeTernaryOperators: true
24+
BreakConstructorInitializersBeforeComma: false
25+
ColumnLimit: 140
26+
CommentPragmas: '^ IWYU pragma:'
27+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
28+
ConstructorInitializerIndentWidth: 4
29+
ContinuationIndentWidth: 4
30+
Cpp11BracedListStyle: true
31+
DerivePointerAlignment: true
32+
DisableFormat: false
33+
ExperimentalAutoDetectBinPacking: false
34+
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH, vec_foreach ]
35+
IndentCaseLabels: true
36+
IndentWidth: 8
37+
IndentWrappedFunctionNames: false
38+
KeepEmptyLinesAtTheStartOfBlocks: false
39+
MacroBlockBegin: ''
40+
MacroBlockEnd: ''
41+
MaxEmptyLinesToKeep: 1
42+
NamespaceIndentation: None
43+
ObjCBlockIndentWidth: 2
44+
ObjCSpaceAfterProperty: false
45+
ObjCSpaceBeforeProtocolList: false
46+
PenaltyBreakBeforeFirstCallParameter: 1
47+
PenaltyBreakComment: 300
48+
PenaltyBreakFirstLessLess: 120
49+
PenaltyBreakString: 1000
50+
PenaltyExcessCharacter: 1000000
51+
PenaltyReturnTypeOnItsOwnLine: 200
52+
PointerAlignment: Left
53+
SpaceAfterCStyleCast: false
54+
SpaceBeforeAssignmentOperators: true
55+
SpaceBeforeParens: ControlStatements
56+
SpaceInEmptyParentheses: false
57+
SpacesBeforeTrailingComments: 2
58+
SpacesInAngles: false
59+
SpacesInContainerLiterals: true
60+
SpacesInCStyleCastParentheses: false
61+
SpacesInParentheses: false
62+
SpacesInSquareBrackets: false
63+
Standard: Auto
64+
TabWidth: 8
65+
UseTab: Always
66+
...
67+

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,8 @@ EBOOT.BIN
1414
*.dylib
1515
package.json
1616
.npmignore
17+
18+
*.nacp
19+
*.nro
20+
*.nso
21+
*.pfs0

.travis.yml

-35
This file was deleted.

.vscode/launch.json

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
// Verwendet IntelliSense zum Ermitteln möglicher Attribute.
3+
// Zeigen Sie auf vorhandene Attribute, um die zugehörigen Beschreibungen anzuzeigen.
4+
// Weitere Informationen finden Sie unter https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "(gdb) Launch",
9+
"type": "cppdbg",
10+
"request": "launch",
11+
"program": "enter program name, for example ${workspaceFolder}/a.exe",
12+
"args": [],
13+
"stopAtEntry": false,
14+
"cwd": "${workspaceFolder}",
15+
"environment": [],
16+
"externalConsole": true,
17+
"MIMode": "gdb",
18+
"miDebuggerPath": "/path/to/gdb",
19+
"setupCommands": [
20+
{
21+
"description": "Enable pretty-printing for gdb",
22+
"text": "-enable-pretty-printing",
23+
"ignoreFailures": true
24+
}
25+
]
26+
}
27+
]
28+
}

.vscode/settings.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"files.associations": {
3+
"*.h": "c",
4+
"*.inc": "z80-asm",
5+
"*.asm": "z80-asm",
6+
"*.cfg": "ini",
7+
"*.shr": "glsl",
8+
"vector": "cpp",
9+
"xstring": "cpp",
10+
"xutility": "cpp",
11+
"initializer_list": "cpp",
12+
"type_traits": "cpp",
13+
"iosfwd": "cpp"
14+
}
15+
}

Makefile

+194-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,194 @@
1-
include Makefile.libretro
1+
#---------------------------------------------------------------------------------
2+
.SUFFIXES:
3+
#---------------------------------------------------------------------------------
4+
5+
ifeq ($(strip $(DEVKITPRO)),)
6+
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>/devkitpro")
7+
endif
8+
9+
TOPDIR ?= $(CURDIR)
10+
include $(DEVKITPRO)/libnx/switch_rules
11+
12+
#---------------------------------------------------------------------------------
13+
# TARGET is the name of the output
14+
# BUILD is the directory where object files & intermediate files will be placed
15+
# SOURCES is a list of directories containing source code
16+
# DATA is a list of directories containing data files
17+
# INCLUDES is a list of directories containing header files
18+
# EXEFS_SRC is the optional input directory containing data copied into exefs, if anything this normally should only contain "main.npdm".
19+
# ROMFS is the directory containing data to be added to RomFS, relative to the Makefile (Optional)
20+
#
21+
# NO_ICON: if set to anything, do not use icon.
22+
# NO_NACP: if set to anything, no .nacp file is generated.
23+
# APP_TITLE is the name of the app stored in the .nacp file (Optional)
24+
# APP_AUTHOR is the author of the app stored in the .nacp file (Optional)
25+
# APP_VERSION is the version of the app stored in the .nacp file (Optional)
26+
# APP_TITLEID is the titleID of the app stored in the .nacp file (Optional)
27+
# ICON is the filename of the icon (.jpg), relative to the project folder.
28+
# If not set, it attempts to use one of the following (in this order):
29+
# - <Project name>.jpg
30+
# - icon.jpg
31+
# - <libnx folder>/default_icon.jpg
32+
#---------------------------------------------------------------------------------
33+
TARGET := $(notdir $(CURDIR))
34+
BUILD := build
35+
SOURCES := source source/switch
36+
DATA := data
37+
INCLUDES := include
38+
EXEFS_SRC := exefs_src
39+
#ROMFS := romfs
40+
41+
#---------------------------------------------------------------------------------
42+
# options for code generation
43+
#---------------------------------------------------------------------------------
44+
ARCH := -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE
45+
46+
CFLAGS := -g -Wall -Ofast -ffunction-sections \
47+
$(ARCH) $(DEFINES)
48+
49+
CFLAGS += $(INCLUDE) -D__SWITCH__ -DNXLINK_STDIO -DTILED_RENDERING -DBRANCHLESS_GBA_GFX \
50+
-DUSE_FRAME_SKIP #-DTHREADED_RENDERER
51+
52+
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
53+
54+
ASFLAGS := -g $(ARCH)
55+
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
56+
57+
LIBS := -lnx
58+
59+
#---------------------------------------------------------------------------------
60+
# list of directories containing libraries, this must be the top level containing
61+
# include and lib
62+
#---------------------------------------------------------------------------------
63+
LIBDIRS := $(PORTLIBS) $(LIBNX)
64+
65+
66+
#---------------------------------------------------------------------------------
67+
# no real need to edit anything past this point unless you need to add additional
68+
# rules for different file extensions
69+
#---------------------------------------------------------------------------------
70+
ifneq ($(BUILD),$(notdir $(CURDIR)))
71+
#---------------------------------------------------------------------------------
72+
73+
export OUTPUT := $(CURDIR)/$(TARGET)
74+
export TOPDIR := $(CURDIR)
75+
76+
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
77+
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
78+
79+
export DEPSDIR := $(CURDIR)/$(BUILD)
80+
81+
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
82+
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
83+
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
84+
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
85+
86+
#---------------------------------------------------------------------------------
87+
# use CXX for linking C++ projects, CC for standard C
88+
#---------------------------------------------------------------------------------
89+
ifeq ($(strip $(CPPFILES)),)
90+
#---------------------------------------------------------------------------------
91+
export LD := $(CC)
92+
#---------------------------------------------------------------------------------
93+
else
94+
#---------------------------------------------------------------------------------
95+
export LD := $(CXX)
96+
#---------------------------------------------------------------------------------
97+
endif
98+
#---------------------------------------------------------------------------------
99+
100+
export OFILES_BIN := $(addsuffix .o,$(BINFILES))
101+
export OFILES_SRC := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
102+
export OFILES := $(OFILES_BIN) $(OFILES_SRC)
103+
export HFILES_BIN := $(addsuffix .h,$(subst .,_,$(BINFILES)))
104+
105+
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
106+
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
107+
-I$(CURDIR)/$(BUILD)
108+
109+
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
110+
111+
export BUILD_EXEFS_SRC := $(TOPDIR)/$(EXEFS_SRC)
112+
113+
ifeq ($(strip $(ICON)),)
114+
icons := $(wildcard *.jpg)
115+
ifneq (,$(findstring $(TARGET).jpg,$(icons)))
116+
export APP_ICON := $(TOPDIR)/$(TARGET).jpg
117+
else
118+
ifneq (,$(findstring icon.jpg,$(icons)))
119+
export APP_ICON := $(TOPDIR)/icon.jpg
120+
endif
121+
endif
122+
else
123+
export APP_ICON := $(TOPDIR)/$(ICON)
124+
endif
125+
126+
ifeq ($(strip $(NO_ICON)),)
127+
export NROFLAGS += --icon=$(APP_ICON)
128+
endif
129+
130+
ifeq ($(strip $(NO_NACP)),)
131+
export NROFLAGS += --nacp=$(CURDIR)/$(TARGET).nacp
132+
endif
133+
134+
ifneq ($(APP_TITLEID),)
135+
export NACPFLAGS += --titleid=$(APP_TITLEID)
136+
endif
137+
138+
ifneq ($(ROMFS),)
139+
export NROFLAGS += --romfsdir=$(CURDIR)/$(ROMFS)
140+
endif
141+
142+
.PHONY: $(BUILD) clean all
143+
144+
#---------------------------------------------------------------------------------
145+
all: $(BUILD)
146+
147+
$(BUILD):
148+
@[ -d $@ ] || mkdir -p $@
149+
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
150+
151+
#---------------------------------------------------------------------------------
152+
clean:
153+
@echo clean ...
154+
@rm -fr $(BUILD) $(TARGET).pfs0 $(TARGET).nso $(TARGET).nro $(TARGET).nacp $(TARGET).elf
155+
156+
157+
#---------------------------------------------------------------------------------
158+
else
159+
.PHONY: all
160+
161+
DEPENDS := $(OFILES:.o=.d)
162+
163+
#---------------------------------------------------------------------------------
164+
# main targets
165+
#---------------------------------------------------------------------------------
166+
all : $(OUTPUT).pfs0 $(OUTPUT).nro
167+
168+
$(OUTPUT).pfs0 : $(OUTPUT).nso
169+
170+
$(OUTPUT).nso : $(OUTPUT).elf
171+
172+
ifeq ($(strip $(NO_NACP)),)
173+
$(OUTPUT).nro : $(OUTPUT).elf $(OUTPUT).nacp
174+
else
175+
$(OUTPUT).nro : $(OUTPUT).elf
176+
endif
177+
178+
$(OUTPUT).elf : $(OFILES)
179+
180+
$(OFILES_SRC) : $(HFILES_BIN)
181+
182+
#---------------------------------------------------------------------------------
183+
# you need a rule like this for each extension you use as binary data
184+
#---------------------------------------------------------------------------------
185+
%.bin.o : %.bin
186+
#---------------------------------------------------------------------------------
187+
@echo $(notdir $<)
188+
@$(bin2o)
189+
190+
-include $(DEPENDS)
191+
192+
#---------------------------------------------------------------------------------------
193+
endif
194+
#---------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)