Skip to content
This repository has been archived by the owner on Jan 7, 2021. It is now read-only.

Commit

Permalink
start of the c++ rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
LiquidFenrir committed Aug 18, 2017
1 parent 8d1601c commit 75894ea
Show file tree
Hide file tree
Showing 63 changed files with 23,764 additions and 1 deletion.
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
*.smdh
*.bin
*.bnr
*.icn
*.icon
*.3dsx
*.elf
*.bat
*.lnk
*.cia
*.lst
*.map
build/*
out/*
239 changes: 239 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,239 @@
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------

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

TOPDIR ?= $(CURDIR)
include $(DEVKITARM)/3ds_rules

APP_TITLE := MultiUpdater
APP_DESCRIPTION := Updater for FIRM payloads, CIAs, and other files.
APP_AUTHOR := LiquidFenrir

TARGET := MultiUpdater
OUTDIR := out
BUILD := build
SOURCES := source
INCLUDES := include
RESOURCES := $(CURDIR)/resources

ICON := $(RESOURCES)/icon.png
ICON_FLAGS := visible,nosavebackups

BANNER_AUDIO := $(RESOURCES)/audio.wav
BANNER_IMAGE := $(RESOURCES)/banner.png

RSF_PATH := $(RESOURCES)/rominfo.rsf
PRODUCT_CODE := CTR-P-ULTI
UNIQUE_ID := 0xd5c49

LOGO := $(RESOURCES)/logo.bcma.lz

# VERSION := $(shell git describe --tags)
VERSION := 0.0.0

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

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

CFLAGS += $(INCLUDE) -DARM11 -D_3DS -D_GNU_SOURCE -DAPP_TITLE="\"$(APP_TITLE)\"" -DAPP_AUTHOR="\"$(APP_AUTHOR)\"" -DVERSION_STRING="\"$(VERSION)\""

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 -lz

#---------------------------------------------------------------------------------
# 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)/$(OUTDIR)/$(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)

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 := $(ICON)
endif

ifeq ($(strip $(NO_SMDH)),)
export _3DSXFLAGS += --smdh=$(OUTPUT).smdh
endif

ifneq ($(ROMFS),)
export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
endif

.PHONY: $(BUILD) clean all release

#---------------------------------------------------------------------------------
3dsx: $(BUILD)

cia : $(OUTPUT).cia

all: 3dsx cia

release: clean all $(OUTPUT)-$(VERSION).zip

$(BUILD):
@mkdir -p $(OUTDIR)
@[ -d "$@" ] || mkdir -p "$@"
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
@rm -f "$(OUTPUT).smdh"

#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr "$(BUILD)" "$(OUTDIR)"

#---------------------------------------------------------------------------------
%.zip:
@7z a -bso0 "$@" "$(OUTPUT).cia" "$(OUTPUT).3dsx"
@7z rn -bso0 "$@" "$(TARGET).3dsx" "3ds/$(TARGET)/$(TARGET).3dsx"

#---------------------------------------------------------------------------------

MAKEROM ?= makerom

%.cia: $(OUTPUT).elf $(BUILD)/banner.bnr $(BUILD)/icon.icn
$(MAKEROM) -f cia -o "$@" -elf "$(OUTPUT).elf" -rsf "$(RSF_PATH)" -logo "$(LOGO)" -target t -exefslogo -banner "$(BUILD)/banner.bnr" -icon "$(BUILD)/icon.icn" -DAPP_TITLE="$(APP_TITLE)" -DAPP_PRODUCT_CODE="$(PRODUCT_CODE)" -DAPP_UNIQUE_ID="$(UNIQUE_ID)"

# Banner

BANNERTOOL ?= bannertool

ifeq ($(suffix $(BANNER_IMAGE)),.cgfx)
BANNER_IMAGE_ARG := -ci
else
BANNER_IMAGE_ARG := -i
endif

ifeq ($(suffix $(BANNER_AUDIO)),.cwav)
BANNER_AUDIO_ARG := -ca
else
BANNER_AUDIO_ARG := -a
endif

$(BUILD)/banner.bnr : $(BANNER_IMAGE) $(BANNER_AUDIO)
$(BANNERTOOL) makebanner $(BANNER_IMAGE_ARG) "$(BANNER_IMAGE)" $(BANNER_AUDIO_ARG) "$(BANNER_AUDIO)" -o "$@"

$(BUILD)/icon.icn : $(ICON)
$(BANNERTOOL) makesmdh -s "$(APP_TITLE)" -l "$(APP_DESCRIPTION)" -p "$(APP_AUTHOR)" -i "$(ICON)" -f "$(ICON_FLAGS)" -o "$@"


#---------------------------------------------------------------------------------
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)

#---------------------------------------------------------------------------------
# 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
#---------------------------------------------------------------------------------------
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,23 @@
# MultiUpdater
or µpdtr for short, is an updater for 3ds applications/a9lh payloads written in C
MultiUpdater is an updater for FIRM payloads, CIA applications, and other files on the SD card.

# Configuration
The configuration file is named `config.json` and should be placed in `/3ds/MultiUpdater/`.
An example config can be found in the repo.

# Dependencies / Requirements
This project requires ctrulib, zlib, and jansson in your environment.
zlib and jansson can be installed with [3ds_portlibs](https://github.com/devkitPro/3ds_portlibs)

# Compilation
Just run `make` in terminal. Bannertool and makerom **must** be in your PATH or CIA compilation will fail.

# License
MultiUpdater is licensed under the MIT license, a copy of which can be found in the [LICENSE file](../blob/master/LICENSE).
The files located in `source/minizip` are part of [minizip](https://github.com/nmoinvaz/minizip) and are absolutely not created by me, but were slightly modified to remove compilation warnings. They are licensed under the zlib license, a copy of which can be found in the [minizip-LICENSE file](../blob/master/minizip-LICENSE).
The files located in `source/7z` are in the public domain, but I think it's better to add this. They were taken from [lumaupdate](https://github.com/Hamcha/lumaupdate)

# Credits
All of the ctrulib contributors, for ctrulib which this depends upon
Makefile and 7z support by Hamcha
\#Cakey on freenode for help
55 changes: 55 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"config": {
"self_updater": true,
"delete_archives": true,
"delete_cias": false,
"log_output": true
},
"entries": [
{
"name": "3DSident (GUI)",
"url": "https://github.com/joel16/3DSident",
"inrelease": "3DSident_GUI.cia",
"path": "/cias/3DSident_GUI.cia"
},
{
"name": "3DSident",
"url": "https://github.com/joel16/3DSident",
"inrelease": "3DSident.cia",
"path": "/cias/3DSident.cia"
},
{
"name": "GodMode9 (latest commit)",
"url": "https://d0k3.secretalgorithm.com/GodMode9TD/latest.zip",
"inarchive": "GodMode9.firm",
"path": "/luma/payloads/GodMode9.firm"
},
{
"name": "GodMode9 (latest release)",
"url": "https://github.com/d0k3/GodMode9",
"inrelease": "GodMode9-*-*.zip",
"inarchive": "GodMode9.firm",
"path": "/luma/payloads/GodMode9.firm"
},
{
"name": "Luma3DS (latest commit)",
"url": "https://astronautlevel2.github.io/Luma3DS/latest.zip",
"inarchive": "out/boot.firm",
"path": "/boot.firm"
},
{
"name": "Luma3DS (latest release)",
"url": "https://github.com/AuroraWright/Luma3DS",
"inrelease": "Luma3DSv*z",
"inarchive": "boot.firm",
"path": "/boot.firm"
},
{
"name": "CTRNAND Luma3DS (latest release)",
"url": "https://github.com/AuroraWright/Luma3DS",
"inrelease": "Luma3DSv*z",
"inarchive": "boot.firm",
"path": "ctrnand:/boot.firm"
}
]
}
17 changes: 17 additions & 0 deletions minizip-LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Condition of use and distribution are the same as zlib:

This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.

Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:

1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgement in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Binary file added resources/audio.wav
Binary file not shown.
Binary file added resources/banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/logo.bcma.lz
Binary file not shown.
Loading

0 comments on commit 75894ea

Please sign in to comment.