Added nintendo switch support (#16)
This PR adds support for building sm on the nintendo switch, the installation instructions are pretty much the same, with the difference that you need a switch with atmosphere installed and the devkitpro development environment, to install on the switch just copy the .ini, the nro and the smc file. --------- Co-authored-by: snesrev <111028570+snesrev@users.noreply.github.com>
This commit is contained in:
28
src/main.c
28
src/main.c
@@ -22,6 +22,10 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "spc_player.h"
|
#include "spc_player.h"
|
||||||
|
|
||||||
|
#ifdef __SWITCH__
|
||||||
|
#include "switch_impl.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
static void playAudio(Snes *snes, SDL_AudioDeviceID device, int16_t *audioBuffer);
|
static void playAudio(Snes *snes, SDL_AudioDeviceID device, int16_t *audioBuffer);
|
||||||
static void renderScreen(Snes *snes, SDL_Renderer *renderer, SDL_Texture *texture);
|
static void renderScreen(Snes *snes, SDL_Renderer *renderer, SDL_Texture *texture);
|
||||||
static void SDLCALL AudioCallback(void *userdata, Uint8 *stream, int len);
|
static void SDLCALL AudioCallback(void *userdata, Uint8 *stream, int len);
|
||||||
@@ -309,6 +313,9 @@ static const struct RendererFuncs kSdlRendererFuncs = {
|
|||||||
|
|
||||||
#undef main
|
#undef main
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
|
#ifdef __SWITCH__
|
||||||
|
SwitchImpl_Init();
|
||||||
|
#endif
|
||||||
argc--, argv++;
|
argc--, argv++;
|
||||||
const char *config_file = NULL;
|
const char *config_file = NULL;
|
||||||
if (argc >= 2 && strcmp(argv[0], "--config") == 0) {
|
if (argc >= 2 && strcmp(argv[0], "--config") == 0) {
|
||||||
@@ -367,6 +374,20 @@ int main(int argc, char** argv) {
|
|||||||
g_renderer_funcs = kSdlRendererFuncs;
|
g_renderer_funcs = kSdlRendererFuncs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// init snes, load rom
|
||||||
|
const char* filename = argv[0] ? argv[0] : "sm.smc";
|
||||||
|
Snes *snes = SnesInit(filename);
|
||||||
|
|
||||||
|
if(snes == NULL) {
|
||||||
|
#ifdef __SWITCH__
|
||||||
|
ThrowMissingROM();
|
||||||
|
#else
|
||||||
|
char buf[256];
|
||||||
|
snprintf(buf, sizeof(buf), "unable to load rom: %s", filename);
|
||||||
|
Die(buf);
|
||||||
|
#endif
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
SDL_Window *window = SDL_CreateWindow(kWindowTitle, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, window_width, window_height, g_win_flags);
|
SDL_Window *window = SDL_CreateWindow(kWindowTitle, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, window_width, window_height, g_win_flags);
|
||||||
if(window == NULL) {
|
if(window == NULL) {
|
||||||
@@ -403,9 +424,6 @@ int main(int argc, char** argv) {
|
|||||||
g_audiobuffer = (uint8 *)malloc(g_frames_per_block * have.channels * sizeof(int16));
|
g_audiobuffer = (uint8 *)malloc(g_frames_per_block * have.channels * sizeof(int16));
|
||||||
}
|
}
|
||||||
|
|
||||||
// init snes, load rom
|
|
||||||
Snes *snes = SnesInit(argv[0] ? argv[0] : "sm.smc");
|
|
||||||
|
|
||||||
PpuBeginDrawing(snes->snes_ppu, g_pixels, 256 * 4, 0);
|
PpuBeginDrawing(snes->snes_ppu, g_pixels, 256 * 4, 0);
|
||||||
PpuBeginDrawing(snes->my_ppu, g_my_pixels, 256 * 4, 0);
|
PpuBeginDrawing(snes->my_ppu, g_my_pixels, 256 * 4, 0);
|
||||||
|
|
||||||
@@ -539,6 +557,10 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
g_renderer_funcs.Destroy();
|
g_renderer_funcs.Destroy();
|
||||||
|
|
||||||
|
#ifdef __SWITCH__
|
||||||
|
SwitchImpl_Exit();
|
||||||
|
#endif
|
||||||
|
|
||||||
SDL_DestroyWindow(window);
|
SDL_DestroyWindow(window);
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
5
src/platform/switch/.gitignore
vendored
Normal file
5
src/platform/switch/.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
/bin
|
||||||
|
/*.nacp
|
||||||
|
/*.nro
|
||||||
|
/*.elf
|
||||||
|
/*.smc
|
||||||
224
src/platform/switch/Makefile
Normal file
224
src/platform/switch/Makefile
Normal file
@@ -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 := sm
|
||||||
|
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 Metroid
|
||||||
|
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 := -g -Wall -O2 -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
|
||||||
|
#---------------------------------------------------------------------------------------
|
||||||
BIN
src/platform/switch/icon.jpg
Normal file
BIN
src/platform/switch/icon.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 48 KiB |
92
src/platform/switch/sm.ini
Normal file
92
src/platform/switch/sm.ini
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
[General]
|
||||||
|
|
||||||
|
# Disable the SDL_Delay that happens each frame (Gives slightly better perf if your
|
||||||
|
# display is set to exactly 60hz)
|
||||||
|
DisableFrameDelay = 1
|
||||||
|
|
||||||
|
[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
|
||||||
|
|
||||||
|
# Display the world map with higher resolution
|
||||||
|
EnhancedMode7 = 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
|
||||||
45
src/platform/switch/src/switch_impl.c
Normal file
45
src/platform/switch/src/switch_impl.c
Normal file
@@ -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 Metroid without the rom file."
|
||||||
|
"\x1b[4;2HPlease relaunch making sure sm.smc exists."
|
||||||
|
"\x1b[44;2HMade with <3 by snesrev and Lywx"
|
||||||
|
);
|
||||||
|
}
|
||||||
8
src/platform/switch/src/switch_impl.h
Normal file
8
src/platform/switch/src/switch_impl.h
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
void SwitchImpl_Init();
|
||||||
|
void SwitchImpl_Exit();
|
||||||
|
|
||||||
|
// Error messages
|
||||||
|
|
||||||
|
void ThrowMissingROM();
|
||||||
@@ -389,7 +389,6 @@ static void VerifySnapshotsEq(Snapshot *b, Snapshot *a, Snapshot *prev) {
|
|||||||
memcpy(&a->ram[0x77e], &b->ram[0x77e], 5); // my counter
|
memcpy(&a->ram[0x77e], &b->ram[0x77e], 5); // my counter
|
||||||
memcpy(&a->ram[0xe20], &b->ram[0xe20], 2); // enemy_population_ptr
|
memcpy(&a->ram[0xe20], &b->ram[0xe20], 2); // enemy_population_ptr
|
||||||
|
|
||||||
|
|
||||||
if (memcmp(b->ram, a->ram, 0x20000)) {
|
if (memcmp(b->ram, a->ram, 0x20000)) {
|
||||||
fprintf(stderr, "@%d: Memory compare failed (mine != theirs, prev):\n", snes_frame_counter);
|
fprintf(stderr, "@%d: Memory compare failed (mine != theirs, prev):\n", snes_frame_counter);
|
||||||
int j = 0;
|
int j = 0;
|
||||||
@@ -577,9 +576,7 @@ Snes *SnesInit(const char *filename) {
|
|||||||
|
|
||||||
bool loaded = loadRom(filename, g_snes);
|
bool loaded = loadRom(filename, g_snes);
|
||||||
if (!loaded) {
|
if (!loaded) {
|
||||||
char buf[256];
|
return NULL;
|
||||||
snprintf(buf, sizeof(buf), "unable to load rom: %s", filename);
|
|
||||||
Die(buf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g_sram = g_snes->cart->ram;
|
g_sram = g_snes->cart->ram;
|
||||||
|
|||||||
Reference in New Issue
Block a user