Add Nintendo Switch support (including gitlab-ci, gitlab-pages etc.)
This commit is contained in:
56
src/Makefile
56
src/Makefile
@@ -568,6 +568,27 @@ endif
|
||||
STRIP = mipsel-linux-strip
|
||||
JOYCOPT = -DUSE_JOYSTICK
|
||||
else
|
||||
ifdef SWITCH
|
||||
#cross compile an exec for the switch
|
||||
ifeq ($(strip $(DEVKITPRO)),)
|
||||
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>/devkitpro")
|
||||
endif
|
||||
include $(DEVKITPRO)/libnx/switch_rules
|
||||
PLATFORM = switch
|
||||
API = sdl2
|
||||
NOLUA = 1
|
||||
OBJDIR = ../obj/switch
|
||||
BIN = ../bin/grafx2
|
||||
CC = $(DEVKITPRO)/devkitA64/bin/aarch64-none-elf-gcc
|
||||
ARCH = -g -march=armv8-a -mtune=cortex-a57 -fPIE -std=c99 -ffast-math -mcpu=cortex-a57+crc+fp+simd
|
||||
COPT = `$(DEVKITPRO)/portlibs/switch/bin/sdl2-config --cflags` `$(DEVKITPRO)/portlibs/switch/bin/freetype-config --cflags`
|
||||
COPT += $(ARCH) -Wall -ffunction-sections -O$(OPTIM)
|
||||
COPT += -D__SWITCH__ -D_XOPEN_SOURCE=500 -DUSE_JOYSTICK -D__no_tifflib__
|
||||
LOPT = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(OBJDIR)/$*.map
|
||||
LOPT += -lSDL2_image `$(DEVKITPRO)/portlibs/switch/bin/sdl2-config --libs`
|
||||
LOPT += -lSDL2_ttf `$(DEVKITPRO)/portlibs/switch/bin/freetype-config --libs`
|
||||
LOPT += -ljpeg -lstdc++ -lnx
|
||||
else
|
||||
ifdef AROS32CROSS
|
||||
#cross compile an AROS 32 bit executable
|
||||
BIN = ../GrafX2
|
||||
@@ -673,6 +694,7 @@ endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
endif
|
||||
@@ -924,6 +946,13 @@ else
|
||||
ifeq ($(PLATFORM),FreeMiNT)
|
||||
$(STACK) -S 128k $(BIN)
|
||||
$(FIX_FLAGS) -S $(BIN)
|
||||
else
|
||||
ifeq ($(SWITCH), 1)
|
||||
@nacptool --create "grafX2" "grafX2 team / romain337 (nxbuild)" "$(VERSIONTAG)" $(BIN).nacp
|
||||
@echo built ... $(BIN).nacp
|
||||
@elf2nro $(BIN) $(BIN).nro $(BIN).nacp --icon=../misc/switch/icon.jpg --nacp=$(BIN).nacp
|
||||
@echo built ... $(BIN).nro
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
@@ -937,6 +966,13 @@ else
|
||||
ifeq ($(PLATFORM),FreeMiNT)
|
||||
$(STACK) -S 128k $(BIN)
|
||||
$(FIX_FLAGS) -S $(BIN)
|
||||
else
|
||||
ifeq ($(SWITCH), 1)
|
||||
@nacptool --create "grafX2" "grafX2 team / romain337 (nxbuild)" "$(VERSIONTAG)" $(BIN).nacp
|
||||
@echo built ... $(BIN).nacp
|
||||
@elf2nro $(BIN) $(BIN).nro $(BIN).nacp --icon=../misc/switch/icon.jpg --nacp=$(BIN).nacp
|
||||
@echo built ... $(BIN).nro
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
@@ -944,6 +980,12 @@ endif
|
||||
# Make release will strip the executable to make it smaller but non-debugable
|
||||
release : $(BIN)
|
||||
$(STRIP) $(BIN)
|
||||
ifeq ($(SWITCH), 1)
|
||||
@nacptool --create "grafX2" "grafX2 team / romain337 (nxbuild)" "$(VERSIONTAG)" $(BIN).nacp
|
||||
@echo built ... $(BIN).nacp
|
||||
@elf2nro $(BIN) $(BIN).nro $(BIN).nacp --icon=../misc/switch/icon.jpg --nacp=$(BIN).nacp
|
||||
@echo built ... $(BIN).nro
|
||||
endif
|
||||
|
||||
# .tgz archive with source only files
|
||||
SRCARCH = ../src-$(VERSIONTAG).tgz
|
||||
@@ -995,6 +1037,19 @@ ifdef ATARICROSS
|
||||
GRAFX2/gfx2def.ini GRAFX2/DOC/ GRAFX2/SCRIPTS/
|
||||
$(AT)$(RM) -r $(TMP)
|
||||
else
|
||||
ifdef SWITCH
|
||||
$(eval TMP := $(shell mktemp -d))
|
||||
$(AT)$(MKDIR) $(TMP)/switch/grafx2
|
||||
$(AT)$(CP) $(BIN).nro $(TMP)/switch/grafx2
|
||||
$(AT)$(CP) -R ../share/grafx2/fonts $(TMP)/switch/grafx2
|
||||
$(AT)$(CP) -R ../share/grafx2/skins $(TMP)/switch/grafx2
|
||||
$(AT)$(CP) ../misc/switch/gfx2def.ini $(TMP)/switch/grafx2
|
||||
cd .. && $(ZIP) $(ZIPOPT) "grafx2-$(API)-$(VERSIONTAG)$(TTFLABEL)-$(PLATFORM).$(ZIP)" \
|
||||
$(DOC_FILES:../%=%) $(DOC_FILESRTF:../%=%) $(SRCARCH:../%=%)
|
||||
cd $(TMP) && \
|
||||
$(ZIP) $(ZIPOPT) "$(CURDIR)/../grafx2-$(API)-$(VERSIONTAG)$(TTFLABEL)-$(PLATFORM).$(ZIP)" -r ./*
|
||||
$(AT)$(RM) -r $(TMP)
|
||||
else
|
||||
ifdef GP2XCROSS
|
||||
$(eval TMP := $(shell mktemp -d))
|
||||
$(AT)$(MKDIR) $(TMP)/data
|
||||
@@ -1026,6 +1081,7 @@ ifeq ($(PLATFORM),Darwin)
|
||||
$(DOC_FILES:../%=%) $(DOC_FILESRTF:../%=%) $(SRCARCH:../%=%)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
$(AT)$(TAR) czf "../grafx2-$(VERSIONTAG)-src.tgz" $(TARTRANSFORM) \
|
||||
../src/*.c ../src/*.cpp ../src/*.h ../src/Makefile \
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
#include "pxsimple.h"
|
||||
#include "oldies.h"
|
||||
|
||||
#if defined(__GP2X__) || defined(__WIZ__) || defined(__CAANOO__)
|
||||
#if defined(__GP2X__) || defined(__WIZ__) || defined(__CAANOO__) || defined(__SWITCH__)
|
||||
// We don't want to underline the keyboard shortcuts as there is no keyboard
|
||||
#define NO_KEYBOARD
|
||||
#endif
|
||||
|
||||
@@ -571,7 +571,7 @@ void Read_list_of_files(T_Fileselector *list, byte selected_format)
|
||||
// Now here's OS-specific code to determine if "parent directory" entry
|
||||
// should appear.
|
||||
|
||||
#if defined(__MORPHOS__) || defined(__AROS__) || defined (__amigaos4__) || defined(__amigaos__)
|
||||
#if defined(__MORPHOS__) || defined(__AROS__) || defined (__amigaos4__) || defined(__amigaos__) || defined(__SWITCH__)
|
||||
// Amiga systems: always
|
||||
Add_element_to_list(list, PARENT_DIR, Format_filename(PARENT_DIR,19,1), FSOBJECT_DIR, ICON_NONE);
|
||||
list->Nb_directories ++;
|
||||
|
||||
@@ -977,7 +977,9 @@ void Button_Stats(int btn)
|
||||
#else
|
||||
#define NODISKSPACESUPPORT
|
||||
// Free disk space is only for shows. Other platforms can display 0.
|
||||
#if !defined(__SWITCH__)
|
||||
#warning "Missing code for your platform !!! Check and correct please :)"
|
||||
#endif
|
||||
mem_size=0;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -156,6 +156,15 @@ byte Pan_shortcut_pressed;
|
||||
short Joybutton_left_click= JOY_BUTTON_A;
|
||||
short Joybutton_right_click=JOY_BUTTON_B;
|
||||
|
||||
#elif defined(__SWITCH__)
|
||||
|
||||
#define JOYSTICK_THRESHOLD (1024)
|
||||
short Joybutton_shift= JOY_BUTTON_L;
|
||||
short Joybutton_control= JOY_BUTTON_R;
|
||||
short Joybutton_alt= JOY_BUTTON_Y;
|
||||
short Joybutton_left_click= JOY_BUTTON_A;
|
||||
short Joybutton_right_click=JOY_BUTTON_B;
|
||||
|
||||
#else // Default : Any joystick on a computer platform
|
||||
///
|
||||
/// This is the sensitivity threshold for the directional
|
||||
|
||||
4
src/io.c
4
src/io.c
@@ -462,7 +462,7 @@ int Directory_exists(const char * directory)
|
||||
/// Check if a file or directory is hidden.
|
||||
int File_is_hidden(const char *fname, const char *full_name)
|
||||
{
|
||||
#if defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__) || defined(__MINT__)
|
||||
#if defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__) || defined(__MINT__)|| defined(__SWITCH__)
|
||||
// False (unable to determine, or irrelevent for platform)
|
||||
(void)fname;//unused
|
||||
(void)full_name;//unused
|
||||
@@ -772,6 +772,8 @@ byte Create_lock_file(const char *file_directory)
|
||||
{
|
||||
#if defined (__amigaos__)||(__AROS__)||(__ANDROID__)
|
||||
#warning "Missing code for your platform, please check and correct!"
|
||||
#elif defined(__SWITCH__)
|
||||
// The switch can only run one application at a time, so we don't do anything special here
|
||||
#else
|
||||
char lock_filename[MAX_PATH_CHARACTERS];
|
||||
|
||||
|
||||
@@ -570,6 +570,20 @@
|
||||
#define JOY_BUTTON_JOY (10)
|
||||
|
||||
#define KEY_ESC (KEY_JOYBUTTON+JOY_BUTTON_HOME)
|
||||
#elif defined (__SWITCH__)
|
||||
/// Button definitions for the Switch
|
||||
#define JOY_BUTTON_UP (13)
|
||||
#define JOY_BUTTON_DOWN (15)
|
||||
#define JOY_BUTTON_LEFT (12)
|
||||
#define JOY_BUTTON_RIGHT (14)
|
||||
#define JOY_BUTTON_A (0)
|
||||
#define JOY_BUTTON_X (2)
|
||||
#define JOY_BUTTON_B (1)
|
||||
#define JOY_BUTTON_Y (3)
|
||||
#define JOY_BUTTON_L (6)
|
||||
#define JOY_BUTTON_R (7)
|
||||
|
||||
#define KEY_ESC (KEY_JOYBUTTON+JOY_BUTTON_X)
|
||||
#else
|
||||
///
|
||||
/// This is the key identifier for ESC. When hard-coding keyboard shortcuts
|
||||
|
||||
@@ -92,6 +92,8 @@
|
||||
|
||||
#if defined(__macosx__)
|
||||
#include <machine/endian.h>
|
||||
#elif defined(__SWITCH__)
|
||||
#include <machine/endian.h>
|
||||
#elif defined(__FreeBSD__)
|
||||
#include <sys/endian.h>
|
||||
#elif !defined(WIN32)
|
||||
|
||||
@@ -717,7 +717,7 @@ void Zoom_a_line(byte* original_line, byte* zoomed_line,
|
||||
|
||||
#if defined(WIN32)
|
||||
#include <windows.h>
|
||||
#elif defined(__macosx__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
#elif defined(__macosx__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__SWITCH__)
|
||||
#if defined(__OpenBSD__)
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
@@ -785,7 +785,13 @@ unsigned long Memory_free(void)
|
||||
return info.freeram*info.mem_unit;
|
||||
#else
|
||||
// AvailMem is misleading on os4 (os4 caches stuff in memory that you can still allocate)
|
||||
#if defined(__SWITCH__)
|
||||
// There is some way to get memory information on switch (see include switch/kernel/svc.h svcGetInfo svcGetSystemInfo)
|
||||
// but the usage is a bit confusing for the first and the later need privilege to be used.
|
||||
// If you come here with a solution, you'r welcome. For now we just return the default value.
|
||||
#elif
|
||||
#warning "There is missing code there for your platform ! please check and correct :)"
|
||||
#endif
|
||||
return 10*1024*1024;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -43,6 +43,8 @@
|
||||
#include <sys/types.h>
|
||||
#elif defined(__SKYOS__)||defined(__ANDROID__)
|
||||
#warning "Your platform is missing some specific code here ! please check and fix :)"
|
||||
#elif defined(__SWITCH__)
|
||||
// Nothing much to do
|
||||
#else
|
||||
#define MOUNTED_GETMNTENT1
|
||||
#endif
|
||||
@@ -279,6 +281,10 @@ read_file_system_list (bool need_fs_type)
|
||||
struct mount_entry **mtail = &mount_list;
|
||||
(void)need_fs_type; // may be unused
|
||||
|
||||
#if defined(__SWITCH__)
|
||||
(void)me; // unused on switch
|
||||
#endif
|
||||
|
||||
#ifdef MOUNTED_LISTMNTENT
|
||||
{
|
||||
struct tabmntent *mntlist, *p;
|
||||
|
||||
@@ -74,7 +74,7 @@ const char * get_paste_board(void);
|
||||
#endif
|
||||
|
||||
// Virtual keyboard is ON by default on these platforms:
|
||||
#if defined(__GP2X__) || defined(__WIZ__) || defined(__CAANOO__) || defined(GCWZERO)
|
||||
#if defined(__GP2X__) || defined(__WIZ__) || defined(__CAANOO__) || defined(GCWZERO) || defined(__SWITCH__)
|
||||
#define VIRT_KEY_DEFAULT_ON 1
|
||||
#else
|
||||
#define VIRT_KEY_DEFAULT_ON 0
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <limits.h>
|
||||
#endif
|
||||
|
||||
#if defined(__AROS__) || defined(__BEOS__) || defined(__MORPHOS__) || defined(__GP2X__) || defined(__WIZ__) || defined(__CAANOO__) || defined(__amigaos__)
|
||||
#if defined(__AROS__) || defined(__BEOS__) || defined(__MORPHOS__) || defined(__GP2X__) || defined(__WIZ__) || defined(__CAANOO__) || defined(__amigaos__) || defined(__SWITCH__)
|
||||
// These platforms don't have realpath().
|
||||
// We use the following implementation, found in:
|
||||
// http://amiga.sourceforge.net/amigadevhelp/FUNCTIONS/GeekGadgets/realpath/ex02_realpath.c
|
||||
@@ -65,7 +65,7 @@
|
||||
|
||||
if (chdir(path)) {
|
||||
if (errno == ENOTDIR) {
|
||||
#if defined(WIN32) || defined(__MORPHOS__) || defined(__amigaos__)
|
||||
#if defined(WIN32) || defined(__MORPHOS__) || defined(__amigaos__) || defined(__SWITCH__)
|
||||
// No symbolic links and no readlink()
|
||||
l = -1;
|
||||
#else
|
||||
|
||||
@@ -60,6 +60,8 @@
|
||||
#define UPDATE_METHOD UPDATE_METHOD_FULL_PAGE
|
||||
#elif defined(__ANDROID__)
|
||||
#define UPDATE_METHOD UPDATE_METHOD_FULL_PAGE
|
||||
#elif defined(__SWITCH__)
|
||||
#define UPDATE_METHOD UPDATE_METHOD_CUMULATED
|
||||
#else
|
||||
#define UPDATE_METHOD UPDATE_METHOD_CUMULATED
|
||||
#endif
|
||||
|
||||
@@ -140,6 +140,9 @@ void Set_data_directory(const char * program_dir, char * data_dir)
|
||||
//on tos, the same directory is used for everything
|
||||
#elif defined (__MINT__)
|
||||
strcpy(data_dir, program_dir);
|
||||
//on switch, we store everything in the SD card in /switch/grafx2
|
||||
#elif defined(__SWITCH__)
|
||||
strcpy(data_dir,"/switch/grafx2/");
|
||||
// Haiku provides us with an API to find it.
|
||||
#elif defined(__HAIKU__)
|
||||
if (find_path(Set_data_directory, B_FIND_PATH_DATA_DIRECTORY, "grafx2/", data_dir, PATH_MAX) != B_OK)
|
||||
@@ -180,6 +183,9 @@ void Set_config_directory(const char * program_dir, char * config_dir)
|
||||
// For TOS we store everything in the program dir
|
||||
#elif defined(__MINT__)
|
||||
strcpy(config_dir,program_dir);
|
||||
//on switch, we store everything in the SD card in /switch/grafx2
|
||||
#elif defined(__SWITCH__)
|
||||
strcpy(config_dir,"/switch/grafx2/");
|
||||
// For all other platforms, there is some kind of settigns dir to store this.
|
||||
#else
|
||||
char filename[MAX_PATH_CHARACTERS];
|
||||
|
||||
Reference in New Issue
Block a user