mirror of https://github.com/snesrev/smw.git
Nintendo Switch Support (#8)
This commit is contained in:
parent
706eb7329a
commit
2510728a91
|
|
@ -0,0 +1,6 @@
|
|||
/bin
|
||||
/*.nacp
|
||||
/*.nro
|
||||
/*.elf
|
||||
/*.smc
|
||||
/*.sfc
|
||||
|
|
@ -0,0 +1,224 @@
|
|||
#---------------------------------------------------------------------------------
|
||||
.SUFFIXES:
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
ifeq ($(strip $(DEVKITPRO)),)
|
||||
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>/devkitpro")
|
||||
endif
|
||||
|
||||
TOPDIR ?= $(CURDIR)
|
||||
include $(DEVKITPRO)/libnx/switch_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
|
||||
# ROMFS is the directory containing data to be added to RomFS, relative to the Makefile (Optional)
|
||||
#
|
||||
# NO_ICON: if set to anything, do not use icon.
|
||||
# NO_NACP: if set to anything, no .nacp file is generated.
|
||||
# APP_TITLE is the name of the app stored in the .nacp file (Optional)
|
||||
# APP_AUTHOR is the author of the app stored in the .nacp file (Optional)
|
||||
# APP_VERSION is the version of the app stored in the .nacp file (Optional)
|
||||
# APP_TITLEID is the titleID of the app stored in the .nacp file (Optional)
|
||||
# ICON is the filename of the icon (.jpg), relative to the project folder.
|
||||
# If not set, it attempts to use one of the following (in this order):
|
||||
# - <Project name>.jpg
|
||||
# - icon.jpg
|
||||
# - <libnx folder>/default_icon.jpg
|
||||
#
|
||||
# CONFIG_JSON is the filename of the NPDM config file (.json), relative to the project folder.
|
||||
# If not set, it attempts to use one of the following (in this order):
|
||||
# - <Project name>.json
|
||||
# - config.json
|
||||
# If a JSON file is provided or autodetected, an ExeFS PFS0 (.nsp) is built instead
|
||||
# of a homebrew executable (.nro). This is intended to be used for sysmodules.
|
||||
# NACP building is skipped as well.
|
||||
#---------------------------------------------------------------------------------
|
||||
SRC_DIR := ../../
|
||||
TARGET := smw
|
||||
BUILD := bin
|
||||
SOURCES := $(SRC_DIR) $(SRC_DIR)/snes $(SRC_DIR)/platform/switch/src $(SRC_DIR)/../third_party/gl_core
|
||||
|
||||
CFILES := $(wildcard $(SRC_DIR)/*.c $(SRC_DIR)/snes/*.c $(SRC_DIR)/platform/switch/src/*.c) $(SRC_DIR)/../third_party/gl_core/gl_core_3_1.c
|
||||
|
||||
INCLUDES := include $(SRC_DIR)/../ ./src/
|
||||
APP_TITLE := Super Mario World
|
||||
APP_AUTHOR := snesrev & Lywx
|
||||
APP_VERSION := $(shell git rev-parse --short HEAD) $(shell git rev-parse --abbrev-ref HEAD)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
ARCH := -march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIE
|
||||
|
||||
CFLAGS := -Wall -O3 -ffast-math -ffunction-sections -Wno-parentheses \
|
||||
$(ARCH) $(DEFINES)
|
||||
|
||||
CFLAGS += -D__SWITCH__ $(INCLUDE) -DSTBI_NO_THREAD_LOCALS `sdl2-config --cflags`
|
||||
|
||||
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
|
||||
CFLAGS += -std=gnu11
|
||||
|
||||
ASFLAGS := -g $(ARCH)
|
||||
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
||||
|
||||
LIBS := `$(PREFIX)pkg-config --libs sdl2` -lnx -lm
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS := $(PORTLIBS) $(LIBNX)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# 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)))
|
||||
#CFILES := $(wildcard ../../*.c ../../snes/*.c) ../../third_party/gl_core/gl_core_3_1.c ../../third_party/opus-1.3.1-stripped/opus_decoder_amalgam.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
|
||||
#---------------------------------------------------------------------------------
|
||||
export LD := $(CXX)
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
export OFILES_BIN := $(addsuffix .o,$(BINFILES))
|
||||
export OFILES_SRC := $(CPPFILES:.cpp=.o) $(notdir $(CFILES:.c=.o)) $(SFILES:.s=.o)
|
||||
export OFILES := $(OFILES_BIN) $(OFILES_SRC)
|
||||
export HFILES_BIN := $(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)
|
||||
|
||||
$(info $(OFILES))
|
||||
|
||||
ifeq ($(strip $(CONFIG_JSON)),)
|
||||
jsons := $(wildcard *.json)
|
||||
ifneq (,$(findstring $(TARGET).json,$(jsons)))
|
||||
export APP_JSON := $(TOPDIR)/$(TARGET).json
|
||||
else
|
||||
ifneq (,$(findstring config.json,$(jsons)))
|
||||
export APP_JSON := $(TOPDIR)/config.json
|
||||
endif
|
||||
endif
|
||||
else
|
||||
export APP_JSON := $(TOPDIR)/$(CONFIG_JSON)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(ICON)),)
|
||||
icons := $(wildcard *.jpg)
|
||||
ifneq (,$(findstring $(TARGET).jpg,$(icons)))
|
||||
export APP_ICON := $(TOPDIR)/$(TARGET).jpg
|
||||
else
|
||||
ifneq (,$(findstring icon.jpg,$(icons)))
|
||||
export APP_ICON := $(TOPDIR)/icon.jpg
|
||||
endif
|
||||
endif
|
||||
else
|
||||
export APP_ICON := $(TOPDIR)/$(ICON)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(NO_ICON)),)
|
||||
export NROFLAGS += --icon=$(APP_ICON)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(NO_NACP)),)
|
||||
export NROFLAGS += --nacp=$(CURDIR)/$(TARGET).nacp
|
||||
endif
|
||||
|
||||
ifneq ($(APP_TITLEID),)
|
||||
export NACPFLAGS += --titleid=$(APP_TITLEID)
|
||||
endif
|
||||
|
||||
ifneq ($(ROMFS),)
|
||||
export NROFLAGS += --romfsdir=$(CURDIR)/$(ROMFS)
|
||||
endif
|
||||
|
||||
.PHONY: $(BUILD) clean all
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
all: $(BUILD)
|
||||
|
||||
$(BUILD):
|
||||
@echo $(CFILES) ...
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
@echo clean ...
|
||||
ifeq ($(strip $(APP_JSON)),)
|
||||
@rm -fr $(BUILD) $(TARGET).nro $(TARGET).nacp $(TARGET).elf
|
||||
else
|
||||
@rm -fr $(BUILD) $(TARGET).nsp $(TARGET).nso $(TARGET).npdm $(TARGET).elf
|
||||
endif
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
.PHONY: all
|
||||
|
||||
DEPENDS := $(OFILES:.o=.d)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# main targets
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(APP_JSON)),)
|
||||
|
||||
all : $(OUTPUT).nro
|
||||
|
||||
ifeq ($(strip $(NO_NACP)),)
|
||||
$(OUTPUT).nro : $(OUTPUT).elf $(OUTPUT).nacp
|
||||
else
|
||||
$(OUTPUT).nro : $(OUTPUT).elf
|
||||
endif
|
||||
|
||||
else
|
||||
|
||||
all : $(OUTPUT).nsp
|
||||
|
||||
$(OUTPUT).nsp : $(OUTPUT).nso $(OUTPUT).npdm
|
||||
|
||||
$(OUTPUT).nso : $(OUTPUT).elf
|
||||
|
||||
endif
|
||||
|
||||
$(OUTPUT).elf : $(OFILES)
|
||||
|
||||
$(OFILES_SRC) : $(HFILES_BIN)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# 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
|
||||
#---------------------------------------------------------------------------------------
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 34 KiB |
|
|
@ -0,0 +1,95 @@
|
|||
[General]
|
||||
# Automatically save state on quit and reload on start
|
||||
Autosave = 0
|
||||
|
||||
# Disable the SDL_Delay that happens each frame (Gives slightly better perf if your
|
||||
# display is set to exactly 60hz)
|
||||
DisableFrameDelay = 0
|
||||
|
||||
# Save a snapshot each time a level is completed
|
||||
SavePlaythrough = 0
|
||||
|
||||
|
||||
[Graphics]
|
||||
# Window size ( Auto or WidthxHeight )
|
||||
WindowSize = 1920x1080
|
||||
|
||||
# Fullscreen mode (0=windowed, 1=desktop fullscreen, 2=fullscreen w/mode change)
|
||||
Fullscreen = 0
|
||||
|
||||
# Window scale (1=100%, 2=200%, 3=300%, etc.)
|
||||
WindowScale = 1
|
||||
|
||||
# Use an optimized (but potentially more buggy) SNES PPU implementation
|
||||
NewRenderer = 1
|
||||
|
||||
# Don't keep the aspect ratio
|
||||
IgnoreAspectRatio = 1
|
||||
|
||||
# Enable this option to remove the sprite limits per scan line
|
||||
NoSpriteLimits = 1
|
||||
|
||||
# Use either SDL, SDL-Software, or OpenGL as the output method
|
||||
# SDL-Software rendering might give better performance on Raspberry pi.
|
||||
#OutputMethod = SDL
|
||||
|
||||
# Set to true to use linear filtering. Gives less crisp pixels. Works with SDL and OpenGL.
|
||||
#LinearFiltering = 0
|
||||
|
||||
# Set a glsl shader. Only supported with the OpenGL output method
|
||||
# This can be the path to a .glsl or .glslp file
|
||||
# Get them with: git clone https://github.com/snesrev/glsl-shaders
|
||||
#Shader = glsl-shaders/hqx/hq4x.glslp
|
||||
|
||||
[Sound]
|
||||
EnableAudio = 1
|
||||
|
||||
# DSP frequency in samples per second (e.g. 48000, 44100, 32000, 22050, 11025)
|
||||
AudioFreq = 44100
|
||||
|
||||
# number of separate sound channels (1=mono, 2=stereo)
|
||||
AudioChannels = 2
|
||||
|
||||
# Audio buffer size in samples (power of 2; e.g., 4096, 2048, 1024) [try 1024 if sound is crackly]. The higher the more lag before you hear sounds.
|
||||
AudioSamples = 1024
|
||||
|
||||
[KeyMap]
|
||||
# Change what keyboard keys map to the joypad
|
||||
# Order: Up, Down, Left, Right, Select, Start, A, B, X, Y, L, R
|
||||
|
||||
# This default is suitable for QWERTY keyboards.
|
||||
Controls = Up, Down, Left, Right, Right Shift, Return, x, z, s, a, c, v
|
||||
|
||||
# This default is suitable for QWERTZ keyboards.
|
||||
#Controls = Up, Down, Left, Right, Right Shift, Return, x, y, s, a, c, v
|
||||
|
||||
# This one is suitable for AZERTY keyboards.
|
||||
#Controls = Up, Down, Left, Right, Right Shift, Return, x, w, s, q, c, v
|
||||
|
||||
CheatLife = w
|
||||
CheatJump = Ctrl+q
|
||||
ClearKeyLog = k
|
||||
StopReplay = l
|
||||
Fullscreen = Alt+Return
|
||||
Reset = Ctrl+r
|
||||
Pause = Shift+p
|
||||
PauseDimmed = p
|
||||
Turbo = Tab
|
||||
ReplayTurbo = t
|
||||
WindowBigger = Ctrl+Up
|
||||
WindowSmaller = Ctrl+Down
|
||||
|
||||
VolumeUp = Shift+=
|
||||
VolumeDown = Shift+-
|
||||
|
||||
Load = F1, F2, F3, F4, F5, F6, F7, F8, F9, F10
|
||||
Save = Shift+F1,Shift+F2,Shift+F3,Shift+F4,Shift+F5,Shift+F6,Shift+F7,Shift+F8,Shift+F9,Shift+F10
|
||||
Replay= Ctrl+F1,Ctrl+F2,Ctrl+F3,Ctrl+F4,Ctrl+F5,Ctrl+F6,Ctrl+F7,Ctrl+F8,Ctrl+F9,Ctrl+F10
|
||||
|
||||
LoadRef = 1,2,3,4,5,6,7,8,9,0,-,=,Backspace
|
||||
ReplayRef = Ctrl+1,Ctrl+2,Ctrl+3,Ctrl+4,Ctrl+5,Ctrl+6,Ctrl+7,Ctrl+8,Ctrl+9,Ctrl+0,Ctrl+-,Ctrl+=,Ctrl+Backspace
|
||||
|
||||
[GamepadMap]
|
||||
# Any keys used in KeyMap can be used also in this section.
|
||||
# The shoulder button is called L1/Lb and L2, and the thumbstick button is called L3
|
||||
Controls = DpadUp, DpadDown, DpadLeft, DpadRight, Back, Start, B, A, Y, X, Lb, Rb
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
#include "switch_impl.h"
|
||||
|
||||
#include <switch.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
void SwitchImpl_Init() {
|
||||
appletInitializeGamePlayRecording();
|
||||
appletSetGamePlayRecordingState(true);
|
||||
appletSetFocusHandlingMode(AppletFocusHandlingMode_NoSuspend);
|
||||
socketInitializeDefault();
|
||||
#ifdef DEBUG
|
||||
nxlinkStdio();
|
||||
#endif
|
||||
}
|
||||
|
||||
void SwitchImpl_Exit() {
|
||||
appletSetGamePlayRecordingState(false);
|
||||
socketExit();
|
||||
}
|
||||
|
||||
void PrintErrorMessageToScreen(const char* str, ...) {
|
||||
consoleInit(NULL);
|
||||
|
||||
va_list args;
|
||||
va_start(args, str);
|
||||
vprintf(str, args);
|
||||
va_end(args);
|
||||
|
||||
while (appletMainLoop()) {
|
||||
consoleUpdate(NULL);
|
||||
}
|
||||
|
||||
consoleExit(NULL);
|
||||
}
|
||||
|
||||
// Error messages
|
||||
|
||||
void ThrowMissingROM() {
|
||||
PrintErrorMessageToScreen(
|
||||
"\x1b[2;2HYou've launched Super Mario World without the rom file."
|
||||
"\x1b[4;2HPlease relaunch making sure smw.sfc exists."
|
||||
"\x1b[44;2HMade with <3 by snesrev and Lywx"
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
void SwitchImpl_Init();
|
||||
void SwitchImpl_Exit();
|
||||
|
||||
// Error messages
|
||||
|
||||
void ThrowMissingROM();
|
||||
Loading…
Reference in New Issue