]> Chaos Git - corbenik/ctrulib.git/commitdiff
Added example for launching apps/applets
authorprofi200 <fd3194@gmx.de>
Mon, 10 Nov 2014 16:34:11 +0000 (17:34 +0100)
committerprofi200 <fd3194@gmx.de>
Mon, 10 Nov 2014 16:34:11 +0000 (17:34 +0100)
examples/app_launch/Makefile [new file with mode: 0644]
examples/app_launch/source/main.c [new file with mode: 0644]
libctru/build.bat [new file with mode: 0644]

diff --git a/examples/app_launch/Makefile b/examples/app_launch/Makefile
new file mode 100644 (file)
index 0000000..c850c22
--- /dev/null
@@ -0,0 +1,139 @@
+#---------------------------------------------------------------------------------
+.SUFFIXES:
+#---------------------------------------------------------------------------------
+
+ifeq ($(strip $(DEVKITARM)),)
+$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
+endif
+
+ifeq ($(strip $(CTRULIB)),)
+# THIS IS TEMPORARY - in the future it should be at $(DEVKITPRO)/libctru
+$(error "Please set CTRULIB in your environment. export CTRULIB=<path to>libctru")
+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
+# SPECS is the directory containing the important build and link files
+#---------------------------------------------------------------------------------
+export TARGET          :=      $(shell basename $(CURDIR))
+BUILD          :=      build
+SOURCES                :=      source
+DATA           :=      data
+INCLUDES       :=      include
+
+
+#---------------------------------------------------------------------------------
+# options for code generation
+#---------------------------------------------------------------------------------
+ARCH   :=      -march=armv6k -mtune=mpcore
+
+CFLAGS :=      -g -Wall -O3 -mword-relocations -save-temps \
+                       -fomit-frame-pointer -ffast-math \
+                       $(ARCH)
+
+CFLAGS +=      $(INCLUDE) -DARM11 -D_3DS
+
+CXXFLAGS       := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
+
+ASFLAGS        :=      -g $(ARCH)
+LDFLAGS        =       -specs=3dsx.specs -g $(ARCH) \
+                       -Wl,-Map,$(TARGET).map
+
+LIBS   := -lctru -lm
+
+#---------------------------------------------------------------------------------
+# list of directories containing libraries, this must be the top level containing
+# include and lib
+#---------------------------------------------------------------------------------
+LIBDIRS        := $(CTRULIB)
+  
+#---------------------------------------------------------------------------------
+# 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  :=      $(addsuffix .o,$(BINFILES)) \
+                       $(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)
+
+.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 $(TARGET).elf
+#---------------------------------------------------------------------------------
+else
+DEPENDS        :=      $(OFILES:.o=.d)
+#---------------------------------------------------------------------------------
+# main targets
+#---------------------------------------------------------------------------------
+$(OUTPUT).3dsx :       $(OUTPUT).elf
+$(OUTPUT).elf  :       $(OFILES)
+
+#---------------------------------------------------------------------------------
+# you need a rule like this for each extension you use as binary data 
+#---------------------------------------------------------------------------------
+%.bin.o        :       %.bin
+#---------------------------------------------------------------------------------
+       @echo $(notdir $<)
+       $(bin2o)
+
+-include $(DEPENDS)
+#---------------------------------------------------------------------------------------
+endif
+#---------------------------------------------------------------------------------------
diff --git a/examples/app_launch/source/main.c b/examples/app_launch/source/main.c
new file mode 100644 (file)
index 0000000..1c4dcdc
--- /dev/null
@@ -0,0 +1,47 @@
+#include <stdio.h>
+#include <string.h>
+#include <3ds.h>
+
+
+
+int main()
+{
+       srvInit();      
+       aptInit();
+       gfxInit();
+       hidInit(NULL);
+
+
+       u8 buf0[0x300];
+       u8 buf1[0x20];
+
+
+       while(aptMainLoop())
+       {
+               hidScanInput();
+               svcSleepThread(100000000LL);
+
+               if(hidKeysDown() & KEY_A)
+               {
+                       memset(buf0, 0, 0x300);
+                       memset(buf1, 0, 0x20);
+
+                       aptOpenSession();
+                       APT_PrepareToDoAppJump(NULL, 0, 0x0004001000022400LL, 0); // *EUR* camera app
+                       APT_DoAppJump(NULL, 0x300, 0x20, buf0, buf1);
+                       aptCloseSession();
+               }
+
+               gfxFlushBuffers();
+               gfxSwapBuffers();
+               gspWaitForVBlank();
+       }
+
+
+       hidExit();
+       gfxExit();
+       aptExit();
+       srvExit();
+
+       return 0;
+}
diff --git a/libctru/build.bat b/libctru/build.bat
new file mode 100644 (file)
index 0000000..22cb06b
--- /dev/null
@@ -0,0 +1,12 @@
+Setlocal
+Pushd "%~dp0"
+@echo off
+
+echo.
+echo.
+make clean
+echo.
+echo.
+make
+echo.
+echo.