Skip to content
This repository was archived by the owner on Jan 11, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,4 @@ modules.order
Module.symvers
Mkfile.old
dkms.conf
build
1 change: 1 addition & 0 deletions 3ds.ld
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ SECTIONS
. = ALIGN(4);
.bss : {
*(.__bss_start)
*(.bss.*)
*(.bss COMMON)
*(.__bss_end)
}
Expand Down
142 changes: 142 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
#---------------------------------------------------------------------------------
.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
#---------------------------------------------------------------------------------
TARGET := ntr_payload
BUILD := build
SOURCES := source source/dsp source/jpeg source/ns source/libctru
DATA :=
INCLUDES := include include/jpeg

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

CFLAGS := -Wall \
-fomit-frame-pointer -ffunction-sections -fdata-sections \
$(ARCH)

CFLAGS += $(INCLUDE) -DHAS_JPEG=1

CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11

ASFLAGS := -g $(ARCH)
LDFLAGS = -pie -nostartfiles -T$(TOPDIR)/3ds.ld -g $(ARCH) -Wl,--gc-sections -Wl,-Map,$(notdir $*.map)

LIBS := -lm

#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS :=


#---------------------------------------------------------------------------------
# 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_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)

export OFILES_BIN := $(addsuffix .o,$(BINFILES))

export OFILES := $(OFILES_BIN) $(OFILES_SOURCES)

export HFILES := $(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)

.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).bin $(TARGET).elf


#---------------------------------------------------------------------------------
else

DEPENDS := $(OFILES:.o=.d)

#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT).bin: $(OUTPUT).elf
@echo "creating $(notdir $@)"
@$(OBJCOPY) -O binary $< $@ -S

$(OUTPUT).elf : $(OFILES)

$(OFILES_SOURCES) : $(HFILES)


#---------------------------------------------------------------------------------
# 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
#---------------------------------------------------------------------------------------
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
# NTR
# NTR


# TODO LIST

0. Fix the build system first.
1. The printf impl. (xprintf.c) is not thread-safe, it should be replaced with a thread-safe one.

# LICENSE

GPLv2
42 changes: 0 additions & 42 deletions build-jpeg.py

This file was deleted.

43 changes: 0 additions & 43 deletions build.py

This file was deleted.

14 changes: 9 additions & 5 deletions include/2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,20 @@

void paint_pixel(u32 x, u32 y, char r, char g, char b, int screen);
void paint_word(char* word, int x,int y, char r, char g, char b, int screen);
void paint_word_vert(char* word, int x,int y, char r, char g, char b, int screen);
void paint_buffer(u8* file, point f_dim, point offset, int screen);
void paint_byte_pixel(unsigned char byte, int x, int y, int screen);
void paint_sprite(unsigned char* sheet, point f_dim, point offset, int screen, int height, int width, int xstart, int ystart);
void paint_square(int x, int y, char r, char g, char b, int h, int w, int screen);
void paint_letter(u8 letter, int x, int y, char r, char g, char b, int screen);

//Unused paint functions.
//void paint_word_vert(char* word, int x,int y, char r, char g, char b, int screen);
//void paint_buffer(u8* file, point f_dim, point offset, int screen);
//void paint_byte_pixel(unsigned char byte, int x, int y, int screen);
//void paint_sprite(unsigned char* sheet, point f_dim, point offset, int screen, int height, int width, int xstart, int ystart);

//DLH
void blank(int x, int y, int xs, int ys);
void square(int x, int y, int xs, int ys);

//Unused function for DLH.
//void square(int x, int y, int xs, int ys);

extern u32 bottomFrameBuffer;
#endif
2 changes: 1 addition & 1 deletion include/ctr/srv.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define SRV_H

Result initSrv();
Result exitSrv();
void exitSrv();
Result srv_RegisterClient(Handle* handleptr);
Result srv_getServiceHandle(Handle* handleptr, Handle* out, char* server);

Expand Down
15 changes: 8 additions & 7 deletions include/ctr/svc.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ typedef enum{
Result svc_createThread(Handle* thread, ThreadFunc entrypoint, u32 arg, u32* stacktop, s32 threadpriority, s32 processorid);
void svc_exitThread();
void svc_sleepThread(s64 ns);
Result svc_openThread(Handle* thread, Handle process, u32 threadId);
Result svc_createMutex(Handle* mutex, bool initialLocked);
Result svc_releaseMutex(Handle handle);
Result svc_releaseSemaphore(s32* count, Handle semaphore, s32 releaseCount);
Expand All @@ -60,12 +61,12 @@ typedef enum{
Result svc_restartDma(Handle h, void * dst, void const* src, unsigned int size, signed char flag);
Result svc_kernelSetState(unsigned int Type, unsigned int Param0, unsigned int Param1, unsigned int Param2);

/**
* @brief Maps a block of process memory.
* @param process Handle of the process.
* @param destAddress Address of the mapped block in the current process.
* @param srcAddress Address of the mapped block in the source process.
* @param size Size of the block of the memory to map (truncated to a multiple of 0x1000 bytes).
*/
/**
* @brief Maps a block of process memory.
* @param process Handle of the process.
* @param destAddress Address of the mapped block in the current process.
* @param srcAddress Address of the mapped block in the source process.
* @param size Size of the block of the memory to map (truncated to a multiple of 0x1000 bytes).
*/
Result svcMapProcessMemoryEx(Handle process, u32 destAddr, u32 srcAddr, u32 size);
#endif
Empty file removed include/gen.h
Empty file.
6 changes: 3 additions & 3 deletions include/global.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#define IS_PLUGIN 0

#define NTR_CFW_VERSION "NTR 3.6"
#define NTR_CFW_VERSION ((u8*)"NTR 3.6")
#include "main.h"

#include "memory.h"
Expand All @@ -25,5 +25,5 @@

#include "func.h"
#include "sharedfunc.h"
#include <ns/ns.h>
#include <sys/socket.h>
#include "ns/ns.h"
#include "sys/socket.h"
Loading