mirror of
				https://gitlab.com/octospacc/MultiSpaccSDK
				synced 2025-06-05 22:09:21 +02:00 
			
		
		
		
	Cleaner Makefile, add Switch build and initial support
This commit is contained in:
		
							
								
								
									
										195
									
								
								LibMultiSpacc/Examples/3DS.mk
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										195
									
								
								LibMultiSpacc/Examples/3DS.mk
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,195 @@ | |||||||
|  | #--------------------------------------------------------------------------------- | ||||||
|  | .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 | ||||||
|  | # | ||||||
|  | # NO_SMDH: if set to anything, no SMDH file is generated. | ||||||
|  | # ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional) | ||||||
|  | # APP_TITLE is the name of the app stored in the SMDH file (Optional) | ||||||
|  | # APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional) | ||||||
|  | # APP_AUTHOR is the author of the app stored in the SMDH file (Optional) | ||||||
|  | # ICON is the filename of the icon (.png), relative to the project folder. | ||||||
|  | #   If not set, it attempts to use one of the following (in this order): | ||||||
|  | #     - <Project name>.png | ||||||
|  | #     - icon.png | ||||||
|  | #     - <libctru folder>/default_icon.png | ||||||
|  | #--------------------------------------------------------------------------------- | ||||||
|  | BUILD		:=	build | ||||||
|  | SOURCES		:=	sources   | ||||||
|  | INCLUDES	:=	sources   | ||||||
|  | ROMFS       :=  data | ||||||
|  |  | ||||||
|  | #--------------------------------------------------------------------------------- | ||||||
|  | # options for code generation | ||||||
|  | #--------------------------------------------------------------------------------- | ||||||
|  | ARCH	:=	-march=armv6k -mtune=mpcore -mfloat-abi=hard | ||||||
|  |  | ||||||
|  | CFLAGS	:=	-g -Wall -O2 -mword-relocations \ | ||||||
|  | 			-fomit-frame-pointer -ffast-math \ | ||||||
|  | 			$(ARCH)  | ||||||
|  |  | ||||||
|  | CFLAGS	+=	$(INCLUDE) -DARM11 -D_3DS -D__3DS__ $(MultiSpacc_Defines) | ||||||
|  |  | ||||||
|  | CXXFLAGS	:= $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11 -findirect-inlining | ||||||
|  |  | ||||||
|  | ASFLAGS	:=	-g $(ARCH) | ||||||
|  | LDFLAGS	=	-specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)  | ||||||
|  |  | ||||||
|  | LIBS	:=  `sdl-config --libs` -lSDL_mixer -lmikmod -lmad -lvorbisidec -logg -lSDL_image -lSDL -lpng -ljpeg -lz -lcitro3d -lctru -lm | ||||||
|  |  | ||||||
|  | #--------------------------------------------------------------------------------- | ||||||
|  | # list of directories containing libraries, this must be the top level containing | ||||||
|  | # include and lib | ||||||
|  | #--------------------------------------------------------------------------------- | ||||||
|  | LIBDIRS	:= $(CTRULIB) $(PORTLIBS) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | #--------------------------------------------------------------------------------- | ||||||
|  | # no real need to edit anything past this point unless you need to add additional | ||||||
|  | # rules for different file extensions | ||||||
|  | #--------------------------------------------------------------------------------- | ||||||
|  | ifneq ($(BUILD),$(notdir $(CURDIR))) | ||||||
|  | #--------------------------------------------------------------------------------- | ||||||
|  |  | ||||||
|  | export OUTPUT	:=	$(CURDIR)/$(TARGET) | ||||||
|  | export TOPDIR	:=	$(CURDIR) | ||||||
|  |  | ||||||
|  | export VPATH	:=	$(foreach dir,$(SOURCES),$(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))) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | #--------------------------------------------------------------------------------- | ||||||
|  | # 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),$(foreach dir,$(LIBDIRS),-I$(dir)/include/SDL) \ | ||||||
|  | 			-I$(CURDIR)/$(BUILD) | ||||||
|  |  | ||||||
|  | export LIBPATHS	:=	$(foreach dir,$(LIBDIRS),-L$(dir)/lib) | ||||||
|  |  | ||||||
|  | ifeq ($(strip $(ICON)),) | ||||||
|  | 	icons := $(wildcard *.png) | ||||||
|  | 	ifneq (,$(findstring $(TARGET).png,$(icons))) | ||||||
|  | 		export APP_ICON := $(TOPDIR)/$(TARGET).png | ||||||
|  | 	else | ||||||
|  | 		ifneq (,$(findstring icon.png,$(icons))) | ||||||
|  | 			export APP_ICON := $(TOPDIR)/icon.png | ||||||
|  | 		endif | ||||||
|  | 	endif | ||||||
|  | else | ||||||
|  | 	export APP_ICON := $(TOPDIR)/$(ICON) | ||||||
|  | endif | ||||||
|  |  | ||||||
|  | ifeq ($(strip $(NO_SMDH)),) | ||||||
|  | 	export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh | ||||||
|  | endif | ||||||
|  |  | ||||||
|  | ifneq ($(ROMFS),) | ||||||
|  | 	export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS) | ||||||
|  | endif | ||||||
|  |  | ||||||
|  | .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).3dsx $(OUTPUT).smdh $(TARGET).elf $(TARGET)-strip.elf $(TARGET).cia $(TARGET).3ds | ||||||
|  | #--------------------------------------------------------------------------------- | ||||||
|  | $(TARGET)-strip.elf: $(BUILD) | ||||||
|  | 	@$(STRIP) $(TARGET).elf -o $(TARGET)-strip.elf | ||||||
|  | #--------------------------------------------------------------------------------- | ||||||
|  | cci: $(TARGET)-strip.elf | ||||||
|  | 	@makerom -f cci -rsf resources/$(TARGET).rsf -target d -exefslogo -elf $(TARGET)-strip.elf -o $(TARGET).3ds | ||||||
|  | 	@echo "built ... 3ds" | ||||||
|  | #--------------------------------------------------------------------------------- | ||||||
|  | cia: $(TARGET)-strip.elf | ||||||
|  | 	@makerom -f cia -o $(TARGET).cia -elf $(TARGET)-strip.elf -rsf resources/$(TARGET).rsf -icon resources/icon.bin -banner resources/banner.bin -exefslogo -target t | ||||||
|  | 	@echo "built ... cia" | ||||||
|  | #--------------------------------------------------------------------------------- | ||||||
|  | else | ||||||
|  |  | ||||||
|  | DEPENDS	:=	$(OFILES:.o=.d) | ||||||
|  |  | ||||||
|  | #--------------------------------------------------------------------------------- | ||||||
|  | # main targets | ||||||
|  | #--------------------------------------------------------------------------------- | ||||||
|  | ifeq ($(strip $(NO_SMDH)),) | ||||||
|  | $(OUTPUT).3dsx	:	$(OUTPUT).elf $(OUTPUT).smdh | ||||||
|  | else | ||||||
|  | $(OUTPUT).3dsx	:	$(OUTPUT).elf | ||||||
|  | endif | ||||||
|  |  | ||||||
|  | $(OUTPUT).elf	:	$(OFILES) | ||||||
|  |  | ||||||
|  | #--------------------------------------------------------------------------------- | ||||||
|  | # 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 | ||||||
|  | #--------------------------------------------------------------------------------------- | ||||||
| @@ -6,6 +6,9 @@ SpaccSources = $(wildcard ../../LibMultiSpacc/*.c) | |||||||
| SpaccHeaders = $(wildcard ../../LibMultiSpacc/*.h) | SpaccHeaders = $(wildcard ../../LibMultiSpacc/*.h) | ||||||
| CFlags = -Os -Werror -Wpedantic -Wdeclaration-after-statement | CFlags = -Os -Werror -Wpedantic -Wdeclaration-after-statement | ||||||
|  |  | ||||||
|  | # Defaults | ||||||
|  | BuildProcess = Normal | ||||||
|  |  | ||||||
| # TODO: handle other unixes | # TODO: handle other unixes | ||||||
| ifeq ($(shell uname --operating-system), Msys) | ifeq ($(shell uname --operating-system), Msys) | ||||||
| 	Host = Windows | 	Host = Windows | ||||||
| @@ -54,6 +57,14 @@ else ifeq ($(Target), Web) | |||||||
| 	Defines += -DTarget_Web | 	Defines += -DTarget_Web | ||||||
| 	MultiSpacc_Target = Web | 	MultiSpacc_Target = Web | ||||||
|  |  | ||||||
|  | else ifeq ($(Target), Switch) | ||||||
|  | 	Defines += -DTarget_Switch | ||||||
|  | 	MultiSpacc_Target = Switch | ||||||
|  |  | ||||||
|  | else ifeq ($(Target), 3DS) | ||||||
|  | 	Defines += -DTarget_3DS | ||||||
|  | 	MultiSpacc_Target = 3DS | ||||||
|  |  | ||||||
| else ifeq ($(Target), NDS) | else ifeq ($(Target), NDS) | ||||||
| 	Defines += -DTarget_NDS | 	Defines += -DTarget_NDS | ||||||
| 	MultiSpacc_Target = NDS | 	MultiSpacc_Target = NDS | ||||||
| @@ -68,29 +79,39 @@ ifeq ($(MultiSpacc_Target), SDL12) | |||||||
| 	Defines += -DMultiSpacc_Target_SDL12 -DMultiSpacc_Target_SDLCom -DMultiSpacc_Target_SDLCommon -DMultiSpacc_Target_SDLStandard | 	Defines += -DMultiSpacc_Target_SDL12 -DMultiSpacc_Target_SDLCom -DMultiSpacc_Target_SDLCommon -DMultiSpacc_Target_SDLStandard | ||||||
| 	CFlags += $(shell sdl-config --cflags) | 	CFlags += $(shell sdl-config --cflags) | ||||||
| 	LdFlags += $(shell sdl-config --libs) -lSDLmain -lSDL -lSDL_image -lSDL_mixer -lSDL_ttf | 	LdFlags += $(shell sdl-config --libs) -lSDLmain -lSDL -lSDL_image -lSDL_mixer -lSDL_ttf | ||||||
| 	BuildProcess = __Normal__ |  | ||||||
|  |  | ||||||
| else ifeq ($(MultiSpacc_Target), SDL20) | else ifeq ($(MultiSpacc_Target), SDL20) | ||||||
| 	Defines += -DMultiSpacc_Target_SDL20 -DMultiSpacc_Target_SDLCom -DMultiSpacc_Target_SDLCommon -DMultiSpacc_Target_SDLStandard | 	Defines += -DMultiSpacc_Target_SDL20 -DMultiSpacc_Target_SDLCom -DMultiSpacc_Target_SDLCommon -DMultiSpacc_Target_SDLStandard | ||||||
| 	CFlags += $(shell sdl2-config --cflags) | 	CFlags += $(shell sdl2-config --cflags) | ||||||
| 	LdFlags += $(shell sdl2-config --libs) -lSDL2main -lSDL2 -lSDL2_image -lSDL2_mixer -lSDL2_ttf | 	LdFlags += $(shell sdl2-config --libs) -lSDL2main -lSDL2 -lSDL2_image -lSDL2_mixer -lSDL2_ttf | ||||||
| 	BuildProcess = __Normal__ |  | ||||||
|  |  | ||||||
| else ifeq ($(MultiSpacc_Target), Web) | else ifeq ($(MultiSpacc_Target), Web) | ||||||
| 	Defines += -DMultiSpacc_Target_Web -DMultiSpacc_Target_SDL20 -DMultiSpacc_Target_SDLCom -DMultiSpacc_Target_SDLCommon -DMultiSpacc_Target_SDLWeb | 	Defines += -DMultiSpacc_Target_Web -DMultiSpacc_Target_SDL20 -DMultiSpacc_Target_SDLCom -DMultiSpacc_Target_SDLCommon -DMultiSpacc_Target_SDLWeb | ||||||
| 	LdFlags += -sWASM=1 -sUSE_SDL=2 -sUSE_SDL_IMAGE=2 -sSDL2_IMAGE_FORMATS='["png"]' -sUSE_SDL_TTF=2 -sUSE_SDL_MIXER=2 | 	LdFlags += -sWASM=1 -sUSE_SDL=2 -sUSE_SDL_IMAGE=2 -sSDL2_IMAGE_FORMATS='["png"]' -sUSE_SDL_TTF=2 -sUSE_SDL_MIXER=2 | ||||||
| 	BuildProcess = __Web__ | 	BuildProcess = Web | ||||||
|  |  | ||||||
|  | else ifeq ($(MultiSpacc_Target), Switch) | ||||||
|  | 	ExeSuffix = .nro | ||||||
|  | 	Defines += -DMultiSpacc_Target_Switch -DMultiSpacc_Target_SDL20 -DMultiSpacc_Target_SDLCom -DMultiSpacc_Target_SDLCommon | ||||||
|  | 	Libs += -lSDL2main -lSDL2 -lSDL2_image -lSDL2_mixer -lSDL2_ttf -lpng -ljpeg -lwebp -lm -lz -lminizip -lbz2 | ||||||
|  | 	BuildProcess = Switch | ||||||
|  |  | ||||||
|  | else ifeq ($(MultiSpacc_Target), 3DS) | ||||||
|  | 	ExeSuffix = .3dsx | ||||||
|  | 	Defines += -DMultiSpacc_Target_3DS | ||||||
|  | 	BuildProcess = 3DS | ||||||
|  | 	OutLauncher = citra | ||||||
|  |  | ||||||
| else ifeq ($(MultiSpacc_Target), NDS) | else ifeq ($(MultiSpacc_Target), NDS) | ||||||
| 	ExeSuffix = .nds | 	ExeSuffix = .nds | ||||||
| 	Defines += -DMultiSpacc_Target_NDS | 	Defines += -DMultiSpacc_Target_NDS | ||||||
| 	BuildProcess = __NDS__ | 	BuildProcess = NDS | ||||||
| 	OutLauncher = melonDS | 	OutLauncher = melonDS | ||||||
|  |  | ||||||
| else ifeq ($(MultiSpacc_Target), NES) | else ifeq ($(MultiSpacc_Target), NES) | ||||||
| 	ExeSuffix = .nes | 	ExeSuffix = .nes | ||||||
| 	Defines += -DMultiSpacc_Target_NES | 	Defines += -DMultiSpacc_Target_NES | ||||||
| 	BuildProcess = __NES__ | 	BuildProcess = NES | ||||||
| 	OutLauncher = fceux | 	OutLauncher = fceux | ||||||
|  |  | ||||||
| endif | endif | ||||||
| @@ -98,52 +119,70 @@ endif | |||||||
| BuildSources = $(AppSources) $(SpaccSources) | BuildSources = $(AppSources) $(SpaccSources) | ||||||
| BuildObjects = $(BuildSources:.c=.o) | BuildObjects = $(BuildSources:.c=.o) | ||||||
|  |  | ||||||
| ifeq ($(BuildProcess), __Normal__) | ifeq ($(BuildProcess), Normal) | ||||||
| 	CC = $(ToolsWrapper) $(ToolsPrefix)gcc$(ToolsSuffix) $(CFlags) $(Defines) | 	CC = $(ToolsWrapper) $(ToolsPrefix)gcc$(ToolsSuffix) $(CFlags) $(Defines) | ||||||
|  | 	BuildDir = . | ||||||
|  | else | ||||||
|  | 	BuildDir = ./Build/$(BuildProcess) | ||||||
| endif | endif | ||||||
|  |  | ||||||
| define BuildDirSourcesReformat | # TODO: Fix include substitutions properly in this, and make all custom build processes lest wasteful of operations | ||||||
|  | define PrepareTargetBuildDir | ||||||
|  | 	mkdir -p $(BuildDir)/.tmp $(BuildDirSources)/.tmp | ||||||
|  |  | ||||||
|  | 	echo > $(BuildDir)/Makefile | ||||||
|  | 	echo "TARGET = $(AppName)" >> $(BuildDir)/Makefile | ||||||
|  | 	echo "MultiSpacc_Defines = $(Defines)" >> $(BuildDir)/Makefile | ||||||
|  | 	echo "MultiSpacc_LdFlags = $(LdFlags)" >> $(BuildDir)/Makefile | ||||||
|  | 	echo "MultiSpacc_Libs = $(Libs)" >> $(BuildDir)/Makefile | ||||||
|  | 	if [ -f ../$(BuildProcess).mk ]; then cat ../$(BuildProcess).mk >> $(BuildDir)/Makefile; fi | ||||||
|  |  | ||||||
|  | 	cp $(SpaccSources) $(SpaccHeaders) $(BuildDirSources)/.tmp/ | ||||||
|  | 	cd $(BuildDirSources)/.tmp; for i in *; do mv ./$$i ../LibMultiSpacc_$$i; done | ||||||
|  | 	cp $(AppSources) $(AppHeaders) $(BuildDirSources)/ | ||||||
|  |  | ||||||
| 	for i in $(BuildDirSources)/*.c $(BuildDirSources)/*.h; do sed -i 's|#include[ \t]"../../LibMultiSpacc/|#include "LibMultiSpacc_|g' $$i; done | 	for i in $(BuildDirSources)/*.c $(BuildDirSources)/*.h; do sed -i 's|#include[ \t]"../../LibMultiSpacc/|#include "LibMultiSpacc_|g' $$i; done | ||||||
| 	for i in $(BuildDirSources)/*.c $(BuildDirSources)/*.h; do sed -i 's|#include[ \t]"../MultiSpacc|#include "LibMultiSpacc_MultiSpacc|g' $$i; done | 	for i in $(BuildDirSources)/*.c $(BuildDirSources)/*.h; do sed -i 's|#include[ \t]"../MultiSpacc|#include "LibMultiSpacc_MultiSpacc|g' $$i; done | ||||||
| 	for i in $(BuildDirSources)/*.c $(BuildDirSources)/*.h; do sed -i 's|#include[ \t]"./|#include "LibMultiSpacc_|g' $$i; done | 	for i in $(BuildDirSources)/*.c $(BuildDirSources)/*.h; do sed -i 's|#include[ \t]"./|#include "LibMultiSpacc_|g' $$i; done | ||||||
| endef | endef | ||||||
|  |  | ||||||
| All all: $(BuildProcess) | define TargetBuildAppToCpp | ||||||
|  | 	#mv $(BuildDirSources)/$(AppName).c $(BuildDirSources)/$(AppName).cpp | ||||||
|  | 	$(shell mv $(BuildDirSources)/MultiSpacc_* $(BuildDirSources)/.tmp/) | ||||||
|  | 	for File in $(BuildDirSources)/*.c; do mv $${File} $${File}pp; done | ||||||
|  | 	$(shell mv $(BuildDirSources)/.tmp/* $(BuildDirSources)/) | ||||||
|  | endef | ||||||
|  |  | ||||||
|  | All all: __$(BuildProcess)__ | ||||||
|  |  | ||||||
| # TODO: use virtual build dirs even for normals to allow linking against different libraries without recleaning | # TODO: use virtual build dirs even for normals to allow linking against different libraries without recleaning | ||||||
| __Normal__: $(BuildObjects) | __Normal__: $(BuildObjects) | ||||||
| 	$(eval BuildDir = .) | 	$(CC) $^ $(LdFlags) $(Libs) -o $(AppName)$(ExeSuffix) | ||||||
| 	$(CC) $^ $(LdFlags) -o $(AppName)$(ExeSuffix) |  | ||||||
| 	# TODO: copy required DLLs on PC for Dist | 	# TODO: copy required DLLs on PC for Dist | ||||||
|  |  | ||||||
| __Web__: | __Web__: | ||||||
| 	$(eval BuildDir = ./Build/Web) |  | ||||||
| 	mkdir -p $(BuildDir) | 	mkdir -p $(BuildDir) | ||||||
| 	emcc $(BuildSources) $(CFlags) $(Defines) $(LdFlags) --preload-file $(AppAssets)@CHARS.png -o $(BuildDir)/Emscripten.js | 	emcc $(BuildSources) $(CFlags) $(Defines) $(LdFlags) --preload-file $(AppAssets)@CHARS.png -o $(BuildDir)/Emscripten.js | ||||||
| 	cp ../Emscripten.html $(BuildDir)/$(AppName).html | 	cp ../Emscripten.html $(BuildDir)/$(AppName).html | ||||||
| 	# TODO: bundle JS, WASM, and assets package in HTML file for Dist | 	# TODO: bundle JS, WASM, and assets package in HTML file for Dist | ||||||
|  |  | ||||||
| # TODO: Fix include substitutions properly in non-standard build processes, and make all custom build processes lest wasteful | __Switch__: | ||||||
|  |  | ||||||
| __NDS__: |  | ||||||
| 	$(eval BuildDir = ./Build/NDS) |  | ||||||
| 	$(eval BuildDirSources = $(BuildDir)/source) | 	$(eval BuildDirSources = $(BuildDir)/source) | ||||||
| 	mkdir -p $(BuildDir)/source/.tmp | 	$(PrepareTargetBuildDir) | ||||||
| 	cp ../NDS.mk $(BuildDir)/Makefile | 	$(TargetBuildAppToCpp) | ||||||
| 	cp $(SpaccSources) $(SpaccHeaders) $(BuildDir)/source/.tmp/ | 	mkdir -p $(BuildDir)/romfs/.dummy | ||||||
| 	cd $(BuildDir)/source/.tmp; for i in *; do mv ./$$i ../LibMultiSpacc_$$i; done | 	touch $(BuildDir)/romfs/.dummy/.dummy | ||||||
| 	cp $(AppSources) $(AppHeaders) $(BuildDir)/source/ | 	cp $(AppAssets) $(BuildDir)/romfs/ | ||||||
| 	$(BuildDirSourcesReformat) | 	cd $(BuildDir); make | ||||||
|  |  | ||||||
|  | __3DS__ __NDS__: | ||||||
|  | 	$(eval BuildDirSources = $(BuildDir)/source) | ||||||
|  | 	$(PrepareTargetBuildDir) | ||||||
| 	cd $(BuildDir); make | 	cd $(BuildDir); make | ||||||
|  |  | ||||||
| __NES__: __neslib__ | __NES__: __neslib__ | ||||||
| 	$(eval BuildDir = ./Build/NES) |  | ||||||
| 	$(eval BuildDirSources = $(BuildDir)) | 	$(eval BuildDirSources = $(BuildDir)) | ||||||
| 	mkdir -p $(BuildDir)/.tmp | 	$(PrepareTargetBuildDir) | ||||||
| 	cp $(SpaccSources) $(SpaccHeaders) $(BuildDir)/.tmp/ |  | ||||||
| 	cd $(BuildDir)/.tmp; for i in *; do mv ./$$i ../LibMultiSpacc_$$i; done |  | ||||||
| 	cp $(AppSources) $(AppHeaders) $(BuildDir)/ |  | ||||||
| 	$(BuildDirSourcesReformat) |  | ||||||
| 	cp ../../neslib/*.cfg ../../neslib/crt0.o ../../neslib/*.lib ../../neslib/*.h $(BuildDir)/ | 	cp ../../neslib/*.cfg ../../neslib/crt0.o ../../neslib/*.lib ../../neslib/*.h $(BuildDir)/ | ||||||
| 	printf ".segment \"CHARS\"\n\t.incbin \"CHARS.chr\"" > $(BuildDir)/CHARS.s | 	printf ".segment \"CHARS\"\n\t.incbin \"CHARS.chr\"" > $(BuildDir)/CHARS.s | ||||||
| 	echo "ProjectRoot=../..; AppName='$(AppName)'; AppAssets='$(AppAssets)'; Defines='$(Defines)';" > $(BuildDir)/Make.sh | 	echo "ProjectRoot=../..; AppName='$(AppName)'; AppAssets='$(AppAssets)'; Defines='$(Defines)';" > $(BuildDir)/Make.sh | ||||||
|   | |||||||
| @@ -81,6 +81,9 @@ int main( int argc, char *argv[] ) | |||||||
| 	windowConfig.bits = 16; | 	windowConfig.bits = 16; | ||||||
| 	memcpy( windowConfig.palette, palette, 32 ); | 	memcpy( windowConfig.palette, palette, 32 ); | ||||||
|  |  | ||||||
|  | 	//romfsInit(); | ||||||
|  | 	//chdir("romfs:/.dummy"); | ||||||
|  |  | ||||||
| 	margs.window = MultiSpacc_SetWindow( &windowConfig ); | 	margs.window = MultiSpacc_SetWindow( &windowConfig ); | ||||||
| 	margs.screen = MultiSpacc_GetWindowSurface( margs.window ); | 	margs.screen = MultiSpacc_GetWindowSurface( margs.window ); | ||||||
| 	margs.background = MultiSpacc_CreateSurface( &windowConfig ); | 	margs.background = MultiSpacc_CreateSurface( &windowConfig ); | ||||||
|   | |||||||
| @@ -19,7 +19,7 @@ include $(DEVKITARM)/ds_rules | |||||||
| #--------------------------------------------------------------------------------- | #--------------------------------------------------------------------------------- | ||||||
| TARGET		:=	$(shell basename $(abspath $(CURDIR)/../..)) | TARGET		:=	$(shell basename $(abspath $(CURDIR)/../..)) | ||||||
| BUILD		:=	build | BUILD		:=	build | ||||||
| SOURCES		:=	gfx source data source/LibMultiSpacc source/LibMultiSpacc/NDS | SOURCES		:=	gfx source data | ||||||
| INCLUDES	:=	include build | INCLUDES	:=	include build | ||||||
|  |  | ||||||
| #--------------------------------------------------------------------------------- | #--------------------------------------------------------------------------------- | ||||||
| @@ -32,7 +32,7 @@ CFLAGS	:=	-g -Wall -O2\ | |||||||
| 			-ffast-math \ | 			-ffast-math \ | ||||||
| 			$(ARCH) | 			$(ARCH) | ||||||
|  |  | ||||||
| CFLAGS	+=	$(INCLUDE) -DARM9 -DMultiSpacc_Target_NDS | CFLAGS	+=	$(INCLUDE) -DARM9 $(MultiSpacc_Defines) | ||||||
| CXXFLAGS	:= $(CFLAGS) -fno-rtti -fno-exceptions | CXXFLAGS	:= $(CFLAGS) -fno-rtti -fno-exceptions | ||||||
|  |  | ||||||
| ASFLAGS	:=	-g $(ARCH) | ASFLAGS	:=	-g $(ARCH) | ||||||
|   | |||||||
| @@ -26,6 +26,9 @@ MultiSpacc_Surface *screen; | |||||||
| MultiSpacc_Surface *background; | MultiSpacc_Surface *background; | ||||||
| MultiSpacc_Surface *tilesImg; | MultiSpacc_Surface *tilesImg; | ||||||
|  |  | ||||||
|  | MultiSpacc_SpritesMap paddleSpriteMap; | ||||||
|  | MultiSpacc_TilesMap divisorTileMap, borderTileMap; | ||||||
|  |  | ||||||
| #define BallSize 8 | #define BallSize 8 | ||||||
| #define PaddleWidth 8 | #define PaddleWidth 8 | ||||||
| #define PaddleHeightTl 4 | #define PaddleHeightTl 4 | ||||||
| @@ -62,8 +65,6 @@ const char palette[32] = { | |||||||
| 	0x0d,0x27,0x2a,      // sprite 3 | 	0x0d,0x27,0x2a,      // sprite 3 | ||||||
| }; | }; | ||||||
|  |  | ||||||
| MultiSpacc_SpritesMap msdata; |  | ||||||
|  |  | ||||||
| void ResetBall(void) | void ResetBall(void) | ||||||
| { | { | ||||||
| 	ballX = windowConfig.width/2; | 	ballX = windowConfig.width/2; | ||||||
| @@ -215,8 +216,8 @@ bool RealUpdate( void *args, double deltaTime ) | |||||||
| 		#define PaddleAccelDelta PaddleAccel*deltaTime | 		#define PaddleAccelDelta PaddleAccel*deltaTime | ||||||
| 		#define PaddleSxYDisplay (paddleSxY + paddleSxMove*PaddleAccelDelta) | 		#define PaddleSxYDisplay (paddleSxY + paddleSxMove*PaddleAccelDelta) | ||||||
| 		#define PaddleDxYDisplay (paddleDxY + paddleDxMove*PaddleAccelDelta) | 		#define PaddleDxYDisplay (paddleDxY + paddleDxMove*PaddleAccelDelta) | ||||||
| 		MultiSpacc_SetMetaSprite( PaddleSxSprite, PaddleSxX, PaddleSxYDisplay, &msdata, PaddleHeightTl, tilesImg, screen ); | 		MultiSpacc_SetMetaSprite( PaddleSxSprite, PaddleSxX, PaddleSxYDisplay, &paddleSpriteMap, PaddleHeightTl, tilesImg, screen ); | ||||||
| 		MultiSpacc_SetMetaSprite( PaddleDxSprite, PaddleDxX, PaddleDxYDisplay, &msdata, PaddleHeightTl, tilesImg, screen ); | 		MultiSpacc_SetMetaSprite( PaddleDxSprite, PaddleDxX, PaddleDxYDisplay, &paddleSpriteMap, PaddleHeightTl, tilesImg, screen ); | ||||||
|  |  | ||||||
| 		//RefreshScore(): | 		//RefreshScore(): | ||||||
| 		//itoa(scoreSx, scoreChar, 10); | 		//itoa(scoreSx, scoreChar, 10); | ||||||
| @@ -255,12 +256,14 @@ bool RealUpdate( void *args, double deltaTime ) | |||||||
|  |  | ||||||
| int main( int argc, char *argv[] ) | int main( int argc, char *argv[] ) | ||||||
| { | { | ||||||
|  | 	int i; | ||||||
| 	int chr[] = { PaddleTile, PaddleTile, PaddleTile, PaddleTile }; | 	int chr[] = { PaddleTile, PaddleTile, PaddleTile, PaddleTile }; | ||||||
| 	int   x[] = { 0, 0,  0,  0 }; | 	int   x[] = { 0, 0,  0,  0 }; | ||||||
| 	int   y[] = { 0, 8, 16, 24 }; | 	int   y[] = { 0, 8, 16, 24 }; | ||||||
| 	msdata.chr = chr; |  | ||||||
| 	msdata.x = x; | 	paddleSpriteMap.chr = chr; | ||||||
| 	msdata.y = y; | 	paddleSpriteMap.x = x; | ||||||
|  | 	paddleSpriteMap.y = y; | ||||||
|  |  | ||||||
| 	windowConfig.width = 320; | 	windowConfig.width = 320; | ||||||
| 	windowConfig.height = 240; | 	windowConfig.height = 240; | ||||||
| @@ -287,6 +290,23 @@ int main( int argc, char *argv[] ) | |||||||
| 		return -1; | 		return -1; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	// divisorTileMap.chr = malloc(windowConfig.height/8 * sizeof(int*)); | ||||||
|  | 	// divisorTileMap.x = malloc(windowConfig.height/8 * sizeof(int*)); | ||||||
|  | 	// divisorTileMap.y = malloc(windowConfig.height/8 * sizeof(int*)); | ||||||
|  | 	// borderTileMap.chr = malloc(windowConfig.height/8 * sizeof(int*)); | ||||||
|  | 	// borderTileMap.x = malloc(windowConfig.height/8 * sizeof(int*)); | ||||||
|  | 	// borderTileMap.y = malloc(windowConfig.height/8 * sizeof(int*)); | ||||||
|  |  | ||||||
|  | 	for( i=0; i<windowConfig.height/8; i++ ) | ||||||
|  | 	{ | ||||||
|  | 		//divisorTileMap.chr[i] = DivisorTile; | ||||||
|  | 		// divisorTileMap.x[i] = windowConfig.width/2; | ||||||
|  | 		// divisorTileMap.y[i] = 0; | ||||||
|  | 		// borderTileMap.chr[i] = BorderTile; | ||||||
|  | 		// borderTileMap.x[i] = 0; | ||||||
|  | 		// borderTileMap.y[i] = 8; | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	DisplayBorders(); | 	DisplayBorders(); | ||||||
| 	ResetBall(); | 	ResetBall(); | ||||||
| 	paddleSxY = windowConfig.height/2 - PaddleHeightPx; | 	paddleSxY = windowConfig.height/2 - PaddleHeightPx; | ||||||
|   | |||||||
							
								
								
									
										223
									
								
								LibMultiSpacc/Examples/Switch.mk
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										223
									
								
								LibMultiSpacc/Examples/Switch.mk
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,223 @@ | |||||||
|  | # This Makefile is borrowed from switchbrew's switch-examples | ||||||
|  | # <https://github.com/switchbrew/switch-examples> | ||||||
|  |  | ||||||
|  | #--------------------------------------------------------------------------------- | ||||||
|  | .SUFFIXES: | ||||||
|  | #--------------------------------------------------------------------------------- | ||||||
|  |  | ||||||
|  | ifeq ($(strip $(DEVKITPRO)),) | ||||||
|  | $(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>/devkitpro") | ||||||
|  | endif | ||||||
|  |  | ||||||
|  | TOPDIR ?= $(CURDIR) | ||||||
|  | include $(DEVKITPRO)/libnx/switch_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 containing data to be added to RomFS, relative to the Makefile (Optional) | ||||||
|  | # | ||||||
|  | # NO_ICON: if set to anything, do not use icon. | ||||||
|  | # NO_NACP: if set to anything, no .nacp file is generated. | ||||||
|  | # APP_TITLE is the name of the app stored in the .nacp file (Optional) | ||||||
|  | # APP_AUTHOR is the author of the app stored in the .nacp file (Optional) | ||||||
|  | # APP_VERSION is the version of the app stored in the .nacp file (Optional) | ||||||
|  | # APP_TITLEID is the titleID of the app stored in the .nacp file (Optional) | ||||||
|  | # ICON is the filename of the icon (.jpg), relative to the project folder. | ||||||
|  | #   If not set, it attempts to use one of the following (in this order): | ||||||
|  | #     - <Project name>.jpg | ||||||
|  | #     - icon.jpg | ||||||
|  | #     - <libnx folder>/default_icon.jpg | ||||||
|  | # | ||||||
|  | # CONFIG_JSON is the filename of the NPDM config file (.json), relative to the project folder. | ||||||
|  | #   If not set, it attempts to use one of the following (in this order): | ||||||
|  | #     - <Project name>.json | ||||||
|  | #     - config.json | ||||||
|  | #   If a JSON file is provided or autodetected, an ExeFS PFS0 (.nsp) is built instead | ||||||
|  | #   of a homebrew executable (.nro). This is intended to be used for sysmodules. | ||||||
|  | #   NACP building is skipped as well. | ||||||
|  | #--------------------------------------------------------------------------------- | ||||||
|  | BUILD    := build | ||||||
|  | SOURCES  := source | ||||||
|  | DATA     := data | ||||||
|  | INCLUDES := include | ||||||
|  | ROMFS    := romfs | ||||||
|  |  | ||||||
|  | #--------------------------------------------------------------------------------- | ||||||
|  | # options for code generation | ||||||
|  | #--------------------------------------------------------------------------------- | ||||||
|  | ARCH	:=	-march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIE | ||||||
|  |  | ||||||
|  | CFLAGS	:=	-g -Wall -O2 -ffunction-sections $(ARCH) $(DEFINES) $(MultiSpacc_Defines) | ||||||
|  |  | ||||||
|  | CFLAGS	+=	-D__SWITCH__ $(INCLUDE) `sdl2-config --cflags` | ||||||
|  |  | ||||||
|  | CXXFLAGS	:= $(CFLAGS) -fno-rtti -fno-exceptions | ||||||
|  |  | ||||||
|  | ASFLAGS	:=	-g $(ARCH) | ||||||
|  | LDFLAGS	=	-specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) | ||||||
|  |  | ||||||
|  | LIBS	:=	`sdl2-config --libs` -lSDL2main -lSDL2 -lSDL2_image -lSDL2_mixer -lSDL2_ttf -lpng -ljpeg -lwebp -lm -lz -lminizip -lbz2 | ||||||
|  |  | ||||||
|  | #--------------------------------------------------------------------------------- | ||||||
|  | # list of directories containing libraries, this must be the top level containing | ||||||
|  | # include and lib | ||||||
|  | #--------------------------------------------------------------------------------- | ||||||
|  | LIBDIRS	:= $(PORTLIBS) $(LIBNX) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | #--------------------------------------------------------------------------------- | ||||||
|  | # no real need to edit anything past this point unless you need to add additional | ||||||
|  | # rules for different file extensions | ||||||
|  | #--------------------------------------------------------------------------------- | ||||||
|  | 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))) | ||||||
|  | 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_BIN	:=	$(addsuffix .o,$(BINFILES)) | ||||||
|  | export OFILES_SRC	:=	$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) | ||||||
|  | export OFILES 	:=	$(OFILES_BIN) $(OFILES_SRC) | ||||||
|  | export HFILES_BIN	:=	$(addsuffix .h,$(subst .,_,$(BINFILES))) | ||||||
|  |  | ||||||
|  | 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) | ||||||
|  |  | ||||||
|  | ifeq ($(strip $(CONFIG_JSON)),) | ||||||
|  | 	jsons := $(wildcard *.json) | ||||||
|  | 	ifneq (,$(findstring $(TARGET).json,$(jsons))) | ||||||
|  | 		export APP_JSON := $(TOPDIR)/$(TARGET).json | ||||||
|  | 	else | ||||||
|  | 		ifneq (,$(findstring config.json,$(jsons))) | ||||||
|  | 			export APP_JSON := $(TOPDIR)/config.json | ||||||
|  | 		endif | ||||||
|  | 	endif | ||||||
|  | else | ||||||
|  | 	export APP_JSON := $(TOPDIR)/$(CONFIG_JSON) | ||||||
|  | endif | ||||||
|  |  | ||||||
|  | ifeq ($(strip $(ICON)),) | ||||||
|  | 	icons := $(wildcard *.jpg) | ||||||
|  | 	ifneq (,$(findstring $(TARGET).jpg,$(icons))) | ||||||
|  | 		export APP_ICON := $(TOPDIR)/$(TARGET).jpg | ||||||
|  | 	else | ||||||
|  | 		ifneq (,$(findstring icon.jpg,$(icons))) | ||||||
|  | 			export APP_ICON := $(TOPDIR)/icon.jpg | ||||||
|  | 		endif | ||||||
|  | 	endif | ||||||
|  | else | ||||||
|  | 	export APP_ICON := $(TOPDIR)/$(ICON) | ||||||
|  | endif | ||||||
|  |  | ||||||
|  | ifeq ($(strip $(NO_ICON)),) | ||||||
|  | 	export NROFLAGS += --icon=$(APP_ICON) | ||||||
|  | endif | ||||||
|  |  | ||||||
|  | ifeq ($(strip $(NO_NACP)),) | ||||||
|  | 	export NROFLAGS += --nacp=$(CURDIR)/$(TARGET).nacp | ||||||
|  | endif | ||||||
|  |  | ||||||
|  | ifneq ($(APP_TITLEID),) | ||||||
|  | 	export NACPFLAGS += --titleid=$(APP_TITLEID) | ||||||
|  | endif | ||||||
|  |  | ||||||
|  | ifneq ($(ROMFS),) | ||||||
|  | 	export NROFLAGS += --romfsdir=$(CURDIR)/$(ROMFS) | ||||||
|  | endif | ||||||
|  |  | ||||||
|  | .PHONY: $(BUILD) clean all | ||||||
|  |  | ||||||
|  | #--------------------------------------------------------------------------------- | ||||||
|  | all: $(BUILD) | ||||||
|  |  | ||||||
|  | $(BUILD): | ||||||
|  | 	@[ -d $@ ] || mkdir -p $@ | ||||||
|  | 	@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile | ||||||
|  |  | ||||||
|  | #--------------------------------------------------------------------------------- | ||||||
|  | clean: | ||||||
|  | 	@echo clean ... | ||||||
|  | ifeq ($(strip $(APP_JSON)),) | ||||||
|  | 	@rm -fr $(BUILD) $(TARGET).nro $(TARGET).nacp $(TARGET).elf | ||||||
|  | else | ||||||
|  | 	@rm -fr $(BUILD) $(TARGET).nsp $(TARGET).nso $(TARGET).npdm $(TARGET).elf | ||||||
|  | endif | ||||||
|  |  | ||||||
|  |  | ||||||
|  | #--------------------------------------------------------------------------------- | ||||||
|  | else | ||||||
|  | .PHONY:	all | ||||||
|  |  | ||||||
|  | DEPENDS	:=	$(OFILES:.o=.d) | ||||||
|  |  | ||||||
|  | #--------------------------------------------------------------------------------- | ||||||
|  | # main targets | ||||||
|  | #--------------------------------------------------------------------------------- | ||||||
|  | ifeq ($(strip $(APP_JSON)),) | ||||||
|  |  | ||||||
|  | all	:	$(OUTPUT).nro | ||||||
|  |  | ||||||
|  | ifeq ($(strip $(NO_NACP)),) | ||||||
|  | $(OUTPUT).nro	:	$(OUTPUT).elf $(OUTPUT).nacp | ||||||
|  | else | ||||||
|  | $(OUTPUT).nro	:	$(OUTPUT).elf | ||||||
|  | endif | ||||||
|  |  | ||||||
|  | else | ||||||
|  |  | ||||||
|  | all	:	$(OUTPUT).nsp | ||||||
|  |  | ||||||
|  | $(OUTPUT).nsp	:	$(OUTPUT).nso $(OUTPUT).npdm | ||||||
|  |  | ||||||
|  | $(OUTPUT).nso	:	$(OUTPUT).elf | ||||||
|  |  | ||||||
|  | endif | ||||||
|  |  | ||||||
|  | $(OUTPUT).elf	:	$(OFILES) | ||||||
|  |  | ||||||
|  | $(OFILES_SRC)	: $(HFILES_BIN) | ||||||
|  |  | ||||||
|  | #--------------------------------------------------------------------------------- | ||||||
|  | # you need a rule like this for each extension you use as binary data | ||||||
|  | #--------------------------------------------------------------------------------- | ||||||
|  | %.bin.o	%_bin.h :	%.bin | ||||||
|  | #--------------------------------------------------------------------------------- | ||||||
|  | 	@echo $(notdir $<) | ||||||
|  | 	@$(bin2o) | ||||||
|  |  | ||||||
|  | -include $(DEPENDS) | ||||||
|  |  | ||||||
|  | #--------------------------------------------------------------------------------------- | ||||||
|  | endif | ||||||
|  | #--------------------------------------------------------------------------------------- | ||||||
| @@ -2,7 +2,7 @@ | |||||||
|  |  | ||||||
| bool MultiSpacc_CheckKey( int key, char pad ) | bool MultiSpacc_CheckKey( int key, char pad ) | ||||||
| { | { | ||||||
| 	#if defined(MultiSpacc_Target_SDLCom) | 	#if defined(MultiSpacc_Target_SDLCommon) | ||||||
| 		#if defined(MultiSpacc_Target_SDL12) | 		#if defined(MultiSpacc_Target_SDL12) | ||||||
| 			Uint8 *keys = SDL_GetKeyState(NULL); | 			Uint8 *keys = SDL_GetKeyState(NULL); | ||||||
| 		#elif defined(MultiSpacc_Target_SDL20) | 		#elif defined(MultiSpacc_Target_SDL20) | ||||||
| @@ -20,6 +20,11 @@ bool MultiSpacc_CheckKey( int key, char pad ) | |||||||
| 			// } | 			// } | ||||||
| 		// } | 		// } | ||||||
| 		// return false; | 		// return false; | ||||||
|  | 	#elif defined(MultiSpacc_Target_NDS) | ||||||
|  | 		int keys; | ||||||
|  | 		scanKeys(); | ||||||
|  | 		keys = keysDown(); | ||||||
|  | 		return ( keys & key ); | ||||||
| 	#elif defined(MultiSpacc_Target_NES) | 	#elif defined(MultiSpacc_Target_NES) | ||||||
| 		return ( pad_poll(pad) & key ); | 		return ( pad_poll(pad) & key ); | ||||||
| 	#endif | 	#endif | ||||||
|   | |||||||
| @@ -1,40 +1,58 @@ | |||||||
| #ifndef _MultiSpacc_Keys_h_ | #ifndef _MultiSpacc_Keys_h_ | ||||||
| #define _MultiSpacc_Keys_h_ | #define _MultiSpacc_Keys_h_ | ||||||
|  |  | ||||||
|  | #ifdef __cplusplus | ||||||
|  | extern "C" { | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | // Action1 | ||||||
| #if defined(MultiSpacc_Target_NES) | #if defined(MultiSpacc_Target_NES) | ||||||
| 	#define MultiSpacc_Key_Action1 PAD_A | 	#define MultiSpacc_Key_Action1 PAD_A | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | // Action2 | ||||||
| #if defined(MultiSpacc_Target_NES) | #if defined(MultiSpacc_Target_NES) | ||||||
| 	#define MultiSpacc_Key_Action2 PAD_B | 	#define MultiSpacc_Key_Action2 PAD_B | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | // Confirm | ||||||
| #if defined(MultiSpacc_Target_NES) | #if defined(MultiSpacc_Target_NES) | ||||||
| 	#define MultiSpacc_Key_Confirm PAD_A | 	#define MultiSpacc_Key_Confirm PAD_A | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | // Cancel | ||||||
| #if defined(MultiSpacc_Target_NES) | #if defined(MultiSpacc_Target_NES) | ||||||
| 	#define MultiSpacc_Key_Cancel PAD_B | 	#define MultiSpacc_Key_Cancel PAD_B | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | // Start | ||||||
| #if defined(MultiSpacc_Target_NES) | #if defined(MultiSpacc_Target_NES) | ||||||
| 	#define MultiSpacc_Key_Start PAD_START | 	#define MultiSpacc_Key_Start PAD_START | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | // Pause | ||||||
| #if defined(MultiSpacc_Target_SDLCommon) && (defined(MultiSpacc_Target_PC) || defined(MultiSpacc_Target_Web)) | #if defined(MultiSpacc_Target_SDLCommon) && (defined(MultiSpacc_Target_PC) || defined(MultiSpacc_Target_Web)) | ||||||
| 	// #define MultiSpacc_Key_Pause SDLK_ESCAPE | 	// #define MultiSpacc_Key_Pause SDLK_ESCAPE | ||||||
| 	#define MultiSpacc_Key_Pause SDL_SCANCODE_ESCAPE | 	#define MultiSpacc_Key_Pause SDL_SCANCODE_ESCAPE | ||||||
|  | #elif defined(MultiSpacc_Target_SDLCommon) && defined(MultiSpacc_Target_Switch) | ||||||
|  | 	#define MultiSpacc_Key_Pause 10 | ||||||
|  | #elif defined(MultiSpacc_Target_NDS) | ||||||
|  | 	#define MultiSpacc_Key_Pause KEY_START | ||||||
| #elif defined(MultiSpacc_Target_NES) | #elif defined(MultiSpacc_Target_NES) | ||||||
| 	#define MultiSpacc_Key_Pause PAD_START | 	#define MultiSpacc_Key_Pause PAD_START | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | // Select | ||||||
| #if defined(MultiSpacc_Target_SDLCommon) && (defined(MultiSpacc_Target_PC) || defined(MultiSpacc_Target_Web)) | #if defined(MultiSpacc_Target_SDLCommon) && (defined(MultiSpacc_Target_PC) || defined(MultiSpacc_Target_Web)) | ||||||
| 	// #define MultiSpacc_Key_Select SDLK_TAB | 	// #define MultiSpacc_Key_Select SDLK_TAB | ||||||
| 	#define MultiSpacc_Key_Select SDL_SCANCODE_TAB | 	#define MultiSpacc_Key_Select SDL_SCANCODE_TAB | ||||||
|  | #elif defined(MultiSpacc_Target_NDS) | ||||||
|  | 	#define MultiSpacc_Key_Select KEY_SELECT | ||||||
| #elif defined(MultiSpacc_Target_NES) | #elif defined(MultiSpacc_Target_NES) | ||||||
| 	#define MultiSpacc_Key_Select PAD_SELECT | 	#define MultiSpacc_Key_Select PAD_SELECT | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | // Directions | ||||||
| #if defined(MultiSpacc_Target_SDLCommon) && (defined(MultiSpacc_Target_PC) || defined(MultiSpacc_Target_Web)) | #if defined(MultiSpacc_Target_SDLCommon) && (defined(MultiSpacc_Target_PC) || defined(MultiSpacc_Target_Web)) | ||||||
| 	// #define MultiSpacc_Key_Up    SDLK_UP | 	// #define MultiSpacc_Key_Up    SDLK_UP | ||||||
| 	// #define MultiSpacc_Key_Down  SDLK_DOWN | 	// #define MultiSpacc_Key_Down  SDLK_DOWN | ||||||
| @@ -62,4 +80,8 @@ | |||||||
|  |  | ||||||
| bool MultiSpacc_CheckKey( int key, char pad ); | bool MultiSpacc_CheckKey( int key, char pad ); | ||||||
|  |  | ||||||
|  | #ifdef __cplusplus | ||||||
|  | } | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #endif // _MultiSpacc_Keys_h_ | #endif // _MultiSpacc_Keys_h_ | ||||||
|   | |||||||
| @@ -1,6 +1,10 @@ | |||||||
| #ifndef _MultiSpacc_MultiSpacc_h_ | #ifndef _MultiSpacc_MultiSpacc_h_ | ||||||
| #define _MultiSpacc_MultiSpacc_h_ | #define _MultiSpacc_MultiSpacc_h_ | ||||||
|  |  | ||||||
|  | #ifdef __cplusplus | ||||||
|  | extern "C" { | ||||||
|  | #endif | ||||||
|  |  | ||||||
| // Amount of times per second to call the FixedUpdate function, independent from video rate and hardcoded in some places due to consoles, don't change | // Amount of times per second to call the FixedUpdate function, independent from video rate and hardcoded in some places due to consoles, don't change | ||||||
| #define MultiSpacc_GameTick 50 | #define MultiSpacc_GameTick 50 | ||||||
|  |  | ||||||
| @@ -40,7 +44,7 @@ | |||||||
| 	} MultiSpacc_Event; | 	} MultiSpacc_Event; | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #ifdef MultiSpacc_Target_SDLCom | #ifdef MultiSpacc_Target_SDLCommon | ||||||
| 	#define MultiSpacc_Init SDL_Init | 	#define MultiSpacc_Init SDL_Init | ||||||
| 	#define MultiSpacc_Surface SDL_Surface | 	#define MultiSpacc_Surface SDL_Surface | ||||||
| 	#define MultiSpacc_GetTicks SDL_GetTicks | 	#define MultiSpacc_GetTicks SDL_GetTicks | ||||||
| @@ -50,6 +54,11 @@ | |||||||
| 	#include <emscripten.h> | 	#include <emscripten.h> | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | #ifdef MultiSpacc_Target_Switch | ||||||
|  | 	#include <switch.h> | ||||||
|  | 	#include <unistd.h> | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #ifdef MultiSpacc_Target_NDS | #ifdef MultiSpacc_Target_NDS | ||||||
| 	#include <nds.h> | 	#include <nds.h> | ||||||
| 	#define Uint32 int32 | 	#define Uint32 int32 | ||||||
| @@ -98,12 +107,12 @@ typedef struct MultiSpacc_SurfaceConfig { | |||||||
| 	Uint32 flags; | 	Uint32 flags; | ||||||
| } MultiSpacc_SurfaceConfig; | } MultiSpacc_SurfaceConfig; | ||||||
|  |  | ||||||
| typedef struct MultiSpacc_SpritesMap { | typedef struct { | ||||||
| 	int *chr; | 	int *chr; | ||||||
| 	int *x; | 	int *x; | ||||||
| 	int *y; | 	int *y; | ||||||
| 	int *flags;	 | 	int *flags;	 | ||||||
| } MultiSpacc_SpritesMap; | } MultiSpacc_SpritesMap, MultiSpacc_TilesMap; | ||||||
|  |  | ||||||
| typedef struct MultiSpacc_MainLoopHandlerArgs { | typedef struct MultiSpacc_MainLoopHandlerArgs { | ||||||
| 	bool (*functionFixedUpdate)( void *args ); | 	bool (*functionFixedUpdate)( void *args ); | ||||||
| @@ -144,4 +153,8 @@ bool MultiSpacc_UpdateDisplay( MultiSpacc_Window *window ); | |||||||
|  |  | ||||||
| #include "./Keys.h" | #include "./Keys.h" | ||||||
|  |  | ||||||
|  | #ifdef __cplusplus | ||||||
|  | } | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #endif // _MultiSpacc_MultiSpacc_h_ | #endif // _MultiSpacc_MultiSpacc_h_ | ||||||
|   | |||||||
| @@ -32,6 +32,7 @@ MultiSpacc_Window *MultiSpacc_SetWindow( MultiSpacc_SurfaceConfig *windowConfig | |||||||
| 		if( windowConfig->bits <= 0 ){ | 		if( windowConfig->bits <= 0 ){ | ||||||
| 			windowConfig->bits = 24; | 			windowConfig->bits = 24; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		#if defined(MultiSpacc_Target_SDL12) | 		#if defined(MultiSpacc_Target_SDL12) | ||||||
| 			return SDL_SetVideoMode( windowConfig->width, windowConfig->height, windowConfig->bits, windowConfig->flags ); | 			return SDL_SetVideoMode( windowConfig->width, windowConfig->height, windowConfig->bits, windowConfig->flags ); | ||||||
| 		#elif defined(MultiSpacc_Target_SDL20) | 		#elif defined(MultiSpacc_Target_SDL20) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user