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
Show all changes
24 commits
Select commit Hold shift + click to select a range
9e1943d
Update README.md
44670 Nov 9, 2017
5447135
Update README.md
44670 Nov 9, 2017
bec1205
Update README.md
tommai78101 Nov 10, 2017
04d7ab7
Merge pull request #1 from tommai78101/readme
44670 Nov 10, 2017
fe1ae57
replace python build "system" with Makefile
WinterMute Nov 10, 2017
ce24534
Merge pull request #3 from WinterMute/fix-build
44670 Nov 11, 2017
3588aee
Added new make targets.
tommai78101 Nov 11, 2017
7252505
Warnings removal (Part 1)
tommai78101 Nov 11, 2017
b807ff6
Fixed warnings, and a bug in svc.h (Part 2)
tommai78101 Nov 11, 2017
9c63016
Fix warnings and corrected a return type for exit(). (Part 3)
tommai78101 Nov 12, 2017
e97a519
Attempting to set dsp/nightshift.c to use -O3, else use -Os.
tommai78101 Nov 12, 2017
64e2c67
fix build system
enler Nov 14, 2017
e020997
Merge pull request #7 from enler/master
44670 Nov 14, 2017
8f39670
Merge branch 'master' into makefile
tommai78101 Nov 15, 2017
7acd6ec
Fixed warnings and added back in missing function prototypes. Moved <…
tommai78101 Nov 15, 2017
8dac11a
Removed the remaining warnings.
tommai78101 Nov 16, 2017
5ebb78e
Removed all warnings (FINALLY!)
tommai78101 Nov 16, 2017
be6e899
Warnings all removed.
tommai78101 Nov 16, 2017
4fb33b7
Added back in missing Readme.md.
tommai78101 Nov 17, 2017
02a748e
Merge pull request #5 from tommai78101/goodbye_warnings
44670 Nov 17, 2017
58201bb
Removed HAS_DSP flag that was setting to null, out of fear.
tommai78101 Nov 17, 2017
6882423
Merge branch 'master' of https://github.com/tommai78101/NTR into make…
tommai78101 Nov 28, 2017
a15a0f5
Merge branch 'makefile' of https://github.com/tommai78101/NTR into ma…
tommai78101 Nov 28, 2017
28227d4
Added #pragma GCC call to nightshift.c, and made some adjustments in …
tommai78101 Nov 28, 2017
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
176 changes: 176 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------

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

TOPDIR ?= $(CURDIR)

containing = $(foreach v,$2,$(if $(findstring $1,$v),$v))
not-containing = $(foreach v,$2,$(if $(findstring $1,$v),,$v))

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 :=
BUILD := build
SOURCES := source source/dsp source/jpeg source/ns source/libctru
DATA :=
INCLUDES := include include/jpeg
OLD_3DS_TARGET := o3ds_ntr_payload
NEW_3DS_TARGET := n3ds_ntr_payload

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

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

ifeq ($(strip $(NEW_3DS)),1)
TARGET := $(NEW_3DS_TARGET)
CFLAGS_VAR := $(INCLUDE) -DHAS_JPEG=1 -O3
else
TARGET := $(OLD_3DS_TARGET)

ifeq ($(findstring nightshift,$(basename $%)),nightshift)
CFLAGS_VAR := $(INCLUDE) -O3
else
CFLAGS_VAR := $(INCLUDE) -Os
endif

endif

CFLAGS := $(CFLAGS_DEF) $(CFLAGS_VAR)

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 old_3ds new_3ds both

#---------------------------------------------------------------------------------
all: $(BUILD)

$(BUILD):
@[ -d $@ ] || mkdir -p $@
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile

#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(NEW_3DS_TARGET).bin $(NEW_3DS_TARGET).elf $(OLD_3DS_TARGET).bin $(OLD_3DS_TARGET).elf

old_3ds:
@echo making ntr_payload for old_3ds ...
@$(MAKE) NEW_3DS=0

new_3ds:
@echo making ntr_payload for new_3ds ...
@$(MAKE) NEW_3DS=1

pre_both: old_3ds
@rm -fr $(BUILD)

both: pre_both new_3ds



#---------------------------------------------------------------------------------
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"
2 changes: 2 additions & 0 deletions include/xprintf.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@


#if _USE_XFUNC_OUT
#include <stdarg.h>
#define xdev_out(func) xfunc_out = (void(*)(unsigned char))(func)
extern void (*xfunc_out)(unsigned char);
void xputc (char c);
Expand All @@ -21,6 +22,7 @@ void xfputs (void (*func)(unsigned char), const char* str);
void xprintf (const char* fmt, ...);
void xsprintf (char* buff, const char* fmt, ...);
void xfprintf (void (*func)(unsigned char), const char* fmt, ...);
void xvprintf(const char* fmt, va_list arp);
void put_dump (const void* buff, unsigned long addr, int len, int width);
#define DW_CHAR sizeof(char)
#define DW_SHORT sizeof(short)
Expand Down
Binary file removed libc.a
Binary file not shown.
Binary file removed libgcc.a
Binary file not shown.
Binary file removed libm.a
Binary file not shown.
Loading