summary refs log tree commit diff
path: root/misc/3ds
diff options
context:
space:
mode:
Diffstat (limited to 'misc/3ds')
-rw-r--r--misc/3ds/Makefile136
-rw-r--r--misc/3ds/audio.wavbin0 -> 63020 bytes
-rw-r--r--misc/3ds/banner.binbin0 -> 68576 bytes
-rw-r--r--misc/3ds/banner.pngbin0 -> 10600 bytes
-rw-r--r--misc/3ds/coloured.v.pica33
-rw-r--r--misc/3ds/icon.binbin0 -> 14016 bytes
-rw-r--r--misc/3ds/icon.pngbin0 -> 1415 bytes
-rw-r--r--misc/3ds/offset.v.pica38
-rw-r--r--misc/3ds/readme.md5
-rw-r--r--misc/3ds/spec.rsf204
-rw-r--r--misc/3ds/textured.v.pica37
11 files changed, 453 insertions, 0 deletions
diff --git a/misc/3ds/Makefile b/misc/3ds/Makefile
new file mode 100644
index 0000000..f3aaf3a
--- /dev/null
+++ b/misc/3ds/Makefile
@@ -0,0 +1,136 @@
+#---------------------------------------------------------------------------------
+.SUFFIXES:
+#---------------------------------------------------------------------------------
+
+ifeq ($(strip $(DEVKITARM)),)
+$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
+endif
+
+TOPDIR ?= $(CURDIR)
+include $(DEVKITARM)/3ds_rules
+
+#---------------------------------------------------------------------------------
+# configurable options
+#---------------------------------------------------------------------------------
+APP_ICON	:= $(TOPDIR)/misc/3ds/icon.png
+APP_TITLE 	:= ClassiCube
+APP_DESCRIPTION := Simple block building sandbox
+APP_AUTHOR 	:= UnknownShadow200
+TARGET 		:= ClassiCube-3ds
+
+#---------------------------------------------------------------------------------
+# 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
+# INCLUDES is a list of directories containing header files
+#---------------------------------------------------------------------------------
+BUILD		:=	build-3ds
+SOURCES		:= src misc/3ds third_party/bearssl/src
+INCLUDES	:=	third_party/bearssl/inc
+
+CIA_BANNER_BIN	:= $(TOPDIR)/misc/3ds/banner.bin
+CIA_ICON_BIN	:= $(TOPDIR)/misc/3ds/icon.bin
+CIA_SPEC_RSF	:= $(TOPDIR)/misc/3ds/spec.rsf
+
+#---------------------------------------------------------------------------------
+# options for code generation
+#---------------------------------------------------------------------------------
+ARCH	:=	-march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
+
+CFLAGS	:=	-g -Wall -O2 -mword-relocations \
+			-ffunction-sections \
+			$(ARCH)
+
+CFLAGS	+=	$(INCLUDE) -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
+
+
+#---------------------------------------------------------------------------------
+# 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)))
+SFILES		:=	$(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
+PICAFILES	:=	$(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
+
+export LD	:=	$(CC)
+
+export OFILES_SOURCES 	:=	$(CFILES:.c=.o) $(SFILES:.s=.o)
+
+export OFILES_BIN	:=	$(PICAFILES:.v.pica=.shbin.o)
+
+export OFILES := $(OFILES_BIN) $(OFILES_SOURCES)
+
+export INCLUDE	:=	$(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
+			$(foreach dir,$(CTRULIB),-I$(dir)/include) \
+			-I$(CURDIR)/$(BUILD)
+
+export LIBPATHS	:=	$(foreach dir,$(CTRULIB),-L$(dir)/lib)
+
+export _3DSXFLAGS = --smdh=$(CURDIR)/$(TARGET).smdh
+
+.PHONY: all clean
+
+#---------------------------------------------------------------------------------
+all: $(BUILD)
+	$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/misc/3ds/Makefile
+
+$(BUILD):
+	mkdir -p $@
+
+#---------------------------------------------------------------------------------
+clean:
+	echo clean ...
+	rm -fr $(BUILD) $(TARGET).cia $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf
+
+#---------------------------------------------------------------------------------
+else
+
+#---------------------------------------------------------------------------------
+# main targets
+#---------------------------------------------------------------------------------
+$(OUTPUT).cia	: $(OUTPUT).3dsx makerom
+	./makerom -f cia -o "$(OUTPUT).cia" -elf "$(OUTPUT).elf" -rsf "$(CIA_SPEC_RSF)" -icon "$(CIA_ICON_BIN)" -banner "$(CIA_BANNER_BIN)" -exefslogo -target t
+	
+makerom:
+	wget https://github.com/3DSGuy/Project_CTR/releases/download/makerom-v0.18.3/makerom-v0.18.3-ubuntu_x86_64.zip
+	unzip makerom-v0.18.3-ubuntu_x86_64.zip
+	chmod +x makerom
+
+$(OUTPUT).3dsx	:	$(OUTPUT).elf $(OUTPUT).smdh
+
+$(OUTPUT).elf	:	$(OFILES)
+
+#---------------------------------------------------------------------------------
+.PRECIOUS	:	%.shbin
+#---------------------------------------------------------------------------------
+
+%.shbin.o : %.v.pica
+	$(eval CUR_SRC	:= $<)
+	$(eval CUR_FILE := $(notdir $(CUR_SRC)))
+	$(eval CUR_BIN	:= $(CURDIR)/$(subst .v.pica,.shbin,$(CUR_FILE)))
+	picasso -o $(CUR_BIN) $(CUR_SRC)
+	bin2s $(CUR_BIN) | $(AS) -o $(CUR_BIN).o
+
+
+-include $(DEPSDIR)/*.d
+
+#---------------------------------------------------------------------------------------
+endif
+#---------------------------------------------------------------------------------------
diff --git a/misc/3ds/audio.wav b/misc/3ds/audio.wav
new file mode 100644
index 0000000..02f3d15
--- /dev/null
+++ b/misc/3ds/audio.wav
Binary files differdiff --git a/misc/3ds/banner.bin b/misc/3ds/banner.bin
new file mode 100644
index 0000000..d93f930
--- /dev/null
+++ b/misc/3ds/banner.bin
Binary files differdiff --git a/misc/3ds/banner.png b/misc/3ds/banner.png
new file mode 100644
index 0000000..8f9c566
--- /dev/null
+++ b/misc/3ds/banner.png
Binary files differdiff --git a/misc/3ds/coloured.v.pica b/misc/3ds/coloured.v.pica
new file mode 100644
index 0000000..7954ed9
--- /dev/null
+++ b/misc/3ds/coloured.v.pica
@@ -0,0 +1,33 @@
+; Vertex shader for rendering coloured vertices for PICA200 GPU on the Nintendo 3DS
+; ==================================================================================
+
+; Uniforms
+.fvec MVP[4];
+
+; Constants
+.constf ONE_DIV_255(0.003921568627, 0.003921568627, 0.003921568627, 0.003921568627)
+
+; Outputs
+.out out_pos position
+.out out_col color
+
+; Inputs (defined as aliases for convenience)
+.alias in_pos v0
+.alias in_col v1
+
+.proc main
+	; r0 = in_pos
+	mov r0, in_pos
+
+	; out_pos = MVP * r0
+	dp4 out_pos.x, MVP[0], r0
+	dp4 out_pos.y, MVP[1], r0
+	dp4 out_pos.z, MVP[2], r0
+	dp4 out_pos.w, MVP[3], r0
+
+	; out_col = in_col * ONE_DIV_255
+	mul out_col, ONE_DIV_255, in_col
+	
+	end
+.end
+
diff --git a/misc/3ds/icon.bin b/misc/3ds/icon.bin
new file mode 100644
index 0000000..09941bc
--- /dev/null
+++ b/misc/3ds/icon.bin
Binary files differdiff --git a/misc/3ds/icon.png b/misc/3ds/icon.png
new file mode 100644
index 0000000..7d7a53c
--- /dev/null
+++ b/misc/3ds/icon.png
Binary files differdiff --git a/misc/3ds/offset.v.pica b/misc/3ds/offset.v.pica
new file mode 100644
index 0000000..9a462db
--- /dev/null
+++ b/misc/3ds/offset.v.pica
@@ -0,0 +1,38 @@
+; Vertex shader for rendering textured vertices with an offset for PICA200 GPU on the Nintendo 3DS
+; ==================================================================================
+
+; Uniforms
+.fvec MVP[4];
+.fvec tex_offset;
+
+; Constants
+.constf ONE_DIV_255(0.003921568627, 0.003921568627, 0.003921568627, 0.003921568627)
+
+; Outputs
+.out out_pos position
+.out out_col color
+.out out_tex texcoord0
+
+; Inputs (defined as aliases for convenience)
+.alias in_pos v0
+.alias in_col v1
+.alias in_tex v2
+
+.proc main
+	; r0 = in_pos
+	mov r0, in_pos
+
+	; out_pos = MVP * r0
+	dp4 out_pos.x, MVP[0], r0
+	dp4 out_pos.y, MVP[1], r0
+	dp4 out_pos.z, MVP[2], r0
+	dp4 out_pos.w, MVP[3], r0
+
+	; out_col = in_col * ONE_DIV_255
+	mul out_col, ONE_DIV_255, in_col
+	; out_tex = in_tex + tex_offset
+	add out_tex, tex_offset, in_tex
+	
+	end
+.end
+
diff --git a/misc/3ds/readme.md b/misc/3ds/readme.md
new file mode 100644
index 0000000..8590a8d
--- /dev/null
+++ b/misc/3ds/readme.md
@@ -0,0 +1,5 @@
+Commands used to generate the .bin files:
+
+`bannertool makebanner -i banner.png -a audio.wav -o banner.bin`
+
+`bannertool makesmdh -s ClassiCube -l ClassiCube -p UnknownShadow200 -i icon.png -o icon.bin`
\ No newline at end of file
diff --git a/misc/3ds/spec.rsf b/misc/3ds/spec.rsf
new file mode 100644
index 0000000..9299a63
--- /dev/null
+++ b/misc/3ds/spec.rsf
@@ -0,0 +1,204 @@
+# https://github.com/msikma/3ds-tpl
+# https://gist.github.com/jakcron/9f9f02ffd94d98a72632
+
+BasicInfo:
+  Title                   : ClassiCube
+  CompanyCode             : "00"
+  ProductCode             : CCBE
+  ContentType             : Application
+  Logo                    : Nintendo
+
+TitleInfo:
+  UniqueId                : 0x00CCBE
+  Category                : Application
+  
+CardInfo:
+  MediaSize               : 128MB # 128MB / 256MB / 512MB / 1GB / 2GB / 4GB
+  MediaType               : Card1 # Card1 / Card2
+  CardDevice              : NorFlash # NorFlash(Pick this if you use savedata) / None
+  
+
+Option:
+  UseOnSD                 : true # true if App is to be installed to SD
+  FreeProductCode         : true # Removes limitations on ProductCode
+  MediaFootPadding        : false # If true CCI files are created with padding
+  EnableCrypt             : false # Enables encryption for NCCH and CIA
+  EnableCompress          : true # Compresses exefs code
+  
+AccessControlInfo:
+  #UseExtSaveData : true
+  #ExtSaveDataId: 0xff3ff
+  #UseExtendedSaveDataAccessControl: true
+  #AccessibleSaveDataIds: [0x101, 0x202, 0x303, 0x404, 0x505, 0x606]
+
+SystemControlInfo:
+  SaveDataSize: 128KB
+  RemasterVersion: 0
+  StackSize: 0x40000
+
+AccessControlInfo:
+  FileSystemAccess:
+   - Debug
+   - DirectSdmc
+   - DirectSdmcWrite
+   
+  IdealProcessor                : 0
+  AffinityMask                  : 1
+  
+  Priority                      : 16
+   
+  MaxCpu                        : 0x9E # Default
+  DisableDebug                  : false
+  EnableForceDebug              : false
+  CanWriteSharedPage            : false
+  CanUsePrivilegedPriority      : false
+  CanUseNonAlphabetAndNumber    : false
+  PermitMainFunctionArgument    : false
+  CanShareDeviceMemory          : false
+  RunnableOnSleep               : false
+  SpecialMemoryArrange          : false
+  CoreVersion                   : 2
+  DescVersion                   : 2
+  
+  ReleaseKernelMajor            : "02"
+  ReleaseKernelMinor            : "33" 
+  MemoryType                    : Application
+  HandleTableSize: 512
+  
+  # New3DS Exclusive Process Settings
+  SystemModeExt                 : 124MB  # Legacy(Default)/124MB/178MB  Legacy:Use Old3DS SystemMode
+  CpuSpeed                      : 804MHz # 268MHz(Default)/804MHz
+  EnableL2Cache                 : true   # false(default)/true
+  CanAccessCore2                : true 
+  
+  # Virtual Address Mappings
+  IORegisterMapping: 
+   - 1ff50000-1ff57fff   # DSP memory
+   - 1ff70000-1ff77fff
+  MemoryMapping: 
+   - 1f000000-1f5fffff:r # VRAM
+   
+  SystemCallAccess: 
+    ArbitrateAddress: 34
+    Break: 60
+    CancelTimer: 28
+    ClearEvent: 25
+    ClearTimer: 29
+    CloseHandle: 35
+    ConnectToPort: 45
+    ControlMemory: 1
+    CreateAddressArbiter: 33
+    CreateEvent: 23
+    CreateMemoryBlock: 30
+    CreateMutex: 19
+    CreateSemaphore: 21
+    CreateThread: 8
+    CreateTimer: 26
+    DuplicateHandle: 39
+    ExitProcess: 3
+    ExitThread: 9
+    GetCurrentProcessorNumber: 17
+    GetHandleInfo: 41
+    GetProcessId: 53
+    GetProcessIdOfThread: 54
+    GetProcessIdealProcessor: 6
+    GetProcessInfo: 43
+    GetResourceLimit: 56
+    GetResourceLimitCurrentValues: 58
+    GetResourceLimitLimitValues: 57
+    GetSystemInfo: 42
+    GetSystemTick: 40
+    GetThreadContext: 59
+    GetThreadId: 55
+    GetThreadIdealProcessor: 15
+    GetThreadInfo: 44
+    GetThreadPriority: 11
+    MapMemoryBlock: 31
+    OutputDebugString: 61
+    QueryMemory: 2
+    ReleaseMutex: 20
+    ReleaseSemaphore: 22
+    SendSyncRequest1: 46
+    SendSyncRequest2: 47
+    SendSyncRequest3: 48
+    SendSyncRequest4: 49
+    SendSyncRequest: 50
+    SetThreadPriority: 12
+    SetTimer: 27
+    SignalEvent: 24
+    SleepThread: 10
+    UnmapMemoryBlock: 32
+    WaitSynchronization1: 36
+    WaitSynchronizationN: 37
+  InterruptNumbers:
+  
+  # Service List
+  # Maximum 34 services (32 if firmware is prior to 9.3.0)
+  ServiceAccessControl: 
+   - APT:U
+   - $hioFIO
+   - $hostio0
+   - $hostio1
+   - ac:u
+   - boss:U
+   - cam:u
+   - cecd:u
+   - cfg:u
+   - dlp:FKCL
+   - dlp:SRVR
+   - dsp::DSP
+   - frd:u
+   - fs:USER
+   - gsp::Gpu
+   - hid:USER
+   - mic:u
+   - ndm:u
+   - news:s
+   - nwm::UDS
+   - ptm:u
+   - pxi:dev
+   - soc:U
+   - gsp::Lcd
+   - y2r:u
+   - ldr:ro
+   - ir:USER
+   - ir:u
+   - csnd:SND
+   - am:u
+   - ns:s
+   
+SystemControlInfo:
+  # Modules that run services listed above should be included below
+  # Maximum 48 dependencies
+  # If a module is listed that isn't present on the 3DS, the title will get stuck at the logo (3ds waves)
+  # So act, nfc and qtm are commented for 4.x support. Uncomment if you need these.
+  # <module name>:<module titleid>
+  Dependency: 
+    ac: 0x0004013000002402L
+    am: 0x0004013000001502L
+    boss: 0x0004013000003402L
+    camera: 0x0004013000001602L
+    cecd: 0x0004013000002602L
+    cfg: 0x0004013000001702L
+    codec: 0x0004013000001802L
+    csnd: 0x0004013000002702L
+    dlp: 0x0004013000002802L
+    dsp: 0x0004013000001a02L
+    friends: 0x0004013000003202L
+    gpio: 0x0004013000001b02L
+    gsp: 0x0004013000001c02L
+    hid: 0x0004013000001d02L
+    i2c: 0x0004013000001e02L
+    ir: 0x0004013000003302L
+    mcu: 0x0004013000001f02L
+    mic: 0x0004013000002002L
+    ndm: 0x0004013000002b02L
+    news: 0x0004013000003502L
+    nim: 0x0004013000002c02L
+    nwm: 0x0004013000002d02L
+    pdn: 0x0004013000002102L
+    ps: 0x0004013000003102L
+    ptm: 0x0004013000002202L
+    ro: 0x0004013000003702L
+    socket: 0x0004013000002e02L
+    spi: 0x0004013000002302L
\ No newline at end of file
diff --git a/misc/3ds/textured.v.pica b/misc/3ds/textured.v.pica
new file mode 100644
index 0000000..f97d88e
--- /dev/null
+++ b/misc/3ds/textured.v.pica
@@ -0,0 +1,37 @@
+; Vertex shader for rendering textured vertices for PICA200 GPU on the Nintendo 3DS
+; ==================================================================================
+
+; Uniforms
+.fvec MVP[4];
+
+; Constants
+.constf ONE_DIV_255(0.003921568627, 0.003921568627, 0.003921568627, 0.003921568627)
+
+; Outputs
+.out out_pos position
+.out out_col color
+.out out_tex texcoord0
+
+; Inputs (defined as aliases for convenience)
+.alias in_pos v0
+.alias in_col v1
+.alias in_tex v2
+
+.proc main
+	; r0 = in_pos
+	mov r0, in_pos
+
+	; out_pos = MVP * r0
+	dp4 out_pos.x, MVP[0], r0
+	dp4 out_pos.y, MVP[1], r0
+	dp4 out_pos.z, MVP[2], r0
+	dp4 out_pos.w, MVP[3], r0
+
+	; out_col = in_col * ONE_DIV_255
+	mul out_col, ONE_DIV_255, in_col
+	; out_tex = in_tex
+	mov out_tex, in_tex
+	
+	end
+.end
+