Skip to content
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
46 changes: 46 additions & 0 deletions libretro/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ endif

# Unix
ifneq (,$(findstring unix,$(platform)))
CFLAGS += -flto
CXXFLAGS += -flto
LDFLAGS += -flto
TARGET := $(TARGET_NAME)_libretro.so
fpic := -fPIC
ifneq ($(findstring SunOS,$(shell uname -a)),)
Expand All @@ -72,6 +75,9 @@ ifneq (,$(findstring unix,$(platform)))

# OS X
else ifeq ($(platform), osx)
CFLAGS += -flto
CXXFLAGS += -flto
LDFLAGS += -flto
TARGET := $(TARGET_NAME)_libretro.dylib
fpic := -fPIC
SHARED := -dynamiclib
Expand All @@ -88,6 +94,9 @@ else ifeq ($(platform), osx)

# iOS
else ifneq (,$(findstring ios,$(platform)))
CFLAGS += -flto
CXXFLAGS += -flto
LDFLAGS += -flto
TARGET := $(TARGET_NAME)_libretro_ios.dylib
fpic := -fPIC
SHARED := -dynamiclib
Expand Down Expand Up @@ -117,6 +126,9 @@ else ifneq (,$(findstring ios,$(platform)))

# Theos
else ifeq ($(platform), theos_ios)
CFLAGS += -flto
CXXFLAGS += -flto
LDFLAGS += -flto
DEPLOYMENT_IOSVERSION = 5.0
TARGET = iphone:latest:$(DEPLOYMENT_IOSVERSION)
ARCHS = armv7 armv7s
Expand All @@ -139,6 +151,9 @@ else ifeq ($(platform), qnx)

# Vita
else ifeq ($(platform), vita)
CFLAGS += -flto
CXXFLAGS += -flto
LDFLAGS += -flto
TARGET := $(TARGET_NAME)_libretro_$(platform).so
fpic := -fPIC
CC = arm-vita-eabi-gcc$(EXE_EXT)
Expand All @@ -162,19 +177,28 @@ else ifneq (,$(filter $(platform), ps3 sncps3 psl1ght))

# PS3
else ifneq (,$(findstring ps3,$(platform)))
CFLAGS += -flto
CXXFLAGS += -flto
LDFLAGS += -flto
CC = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-gcc.exe
CXX = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-g++.exe
AR = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-ar.exe

# Lightweight PS3 Homebrew SDK
else ifneq (,$(findstring psl1ght,$(platform)))
CFLAGS += -flto
CXXFLAGS += -flto
LDFLAGS += -flto
CC = $(PS3DEV)/ppu/bin/ppu-gcc$(EXE_EXT)
CXX = $(PS3DEV)/ppu/bin/ppu-g++$(EXE_EXT)
AR = $(PS3DEV)/ppu/bin/ppu-ar$(EXE_EXT)
endif

# Xbox 360
else ifeq ($(platform), xenon)
CFLAGS += -flto
CXXFLAGS += -flto
LDFLAGS += -flto
TARGET := $(TARGET_NAME)_libretro_xenon360.a
CC = xenon-gcc$(EXE_EXT)
CXX = xenon-g++$(EXE_EXT)
Expand All @@ -184,6 +208,9 @@ else ifeq ($(platform), xenon)

# Nintendo Game Cube / Wii / WiiU
else ifneq (,$(filter $(platform), ngc wii wiiu))
CFLAGS += -flto
CXXFLAGS += -flto
LDFLAGS += -flto
TARGET := $(TARGET_NAME)_libretro_$(platform).a
CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
CXX = $(DEVKITPPC)/bin/powerpc-eabi-g++$(EXE_EXT)
Expand Down Expand Up @@ -212,6 +239,8 @@ else ifeq ($(platform), emscripten)

# Windows MSVC 2003 Xbox 1
else ifeq ($(platform), xbox1_msvc2003)
CFLAGS += -D__WIN32__
CXXFLAGS += -D__WIN32__
TARGET := $(TARGET_NAME)_libretro_xdk1.lib
MSVCBINDIRPREFIX = $(XDK)/xbox/bin/vc71
CC = "$(MSVCBINDIRPREFIX)/CL.exe"
Expand All @@ -227,6 +256,8 @@ STATIC_LINKING=1
HAS_GCC := 0
# Windows MSVC 2010 Xbox 360
else ifeq ($(platform), xbox360_msvc2010)
CFLAGS += -D__WIN32__
CXXFLAGS += -D__WIN32__
TARGET := $(TARGET_NAME)_libretro_xdk360.lib
MSVCBINDIRPREFIX = $(XEDK)/bin/win32
CC = "$(MSVCBINDIRPREFIX)/cl.exe"
Expand All @@ -243,6 +274,8 @@ HAS_GCC := 0

# Windows MSVC 2017 all architectures
else ifneq (,$(findstring windows_msvc2017,$(platform)))
CFLAGS += -D__WIN32__
CXXFLAGS += -D__WIN32__

PlatformSuffix = $(subst windows_msvc2017_,,$(platform))
ifneq (,$(findstring desktop,$(PlatformSuffix)))
Expand Down Expand Up @@ -335,6 +368,8 @@ else ifneq (,$(findstring windows_msvc2017,$(platform)))

# Windows MSVC 2010 x64
else ifeq ($(platform), windows_msvc2010_x64)
CFLAGS += -D__WIN32__
CXXFLAGS += -D__WIN32__
CC = cl.exe
CXX = cl.exe

Expand All @@ -359,6 +394,8 @@ LDFLAGS += -DLL
LIBS :=
# Windows MSVC 2010 x86
else ifeq ($(platform), windows_msvc2010_x86)
CFLAGS += -D__WIN32__
CXXFLAGS += -D__WIN32__
CC = cl.exe
CXX = cl.exe

Expand All @@ -384,6 +421,8 @@ LIBS :=

# Windows MSVC 2003 x86
else ifeq ($(platform), windows_msvc2003_x86)
CFLAGS += -D__WIN32__
CXXFLAGS += -D__WIN32__
CC = cl.exe
CXX = cl.exe

Expand All @@ -404,6 +443,8 @@ CFLAGS += -D_CRT_SECURE_NO_DEPRECATE

# Windows MSVC 2005 x86
else ifeq ($(platform), windows_msvc2005_x86)
CFLAGS += -D__WIN32__
CXXFLAGS += -D__WIN32__
CC = cl.exe
CXX = cl.exe

Expand All @@ -421,8 +462,12 @@ TARGET := $(TARGET_NAME)_libretro.dll
PSS_STYLE :=2
LDFLAGS += -DLL
CFLAGS += -D_CRT_SECURE_NO_DEPRECATE
CXXFLAGS += -D_CRT_SECURE_NO_DEPRECATE
# Windows
else
CFLAGS += -flto
CXXFLAGS += -flto
LDFLAGS += -flto
TARGET := $(TARGET_NAME)_libretro.dll
CC = gcc
CXX = g++
Expand Down Expand Up @@ -451,6 +496,7 @@ ifeq ($(DEBUG), 1)
else
CFLAGS += -O2 -DNDEBUG
CXXFLAGS += -O2 -DNDEBUG
LDFLAGS += -O2

ifneq (,$(findstring msvc,$(platform)))
ifeq ($(STATIC_LINKING),1)
Expand Down
4 changes: 4 additions & 0 deletions libretro/libretro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,7 @@ void retro_init(void)
Settings.CartBName[0] = 0;
Settings.AutoSaveDelay = 1;
Settings.DontSaveOopsSnapshot = TRUE;
Settings.LoadStateDoNotClearScreen = TRUE;

CPU.Flags = 0;

Expand Down Expand Up @@ -1250,6 +1251,9 @@ static void report_buttons()

void retro_run()
{
//sanity check to prevent infinite loop inside emulator
if (!rom_loaded) return;

static uint16 height = PPU.ScreenHeight;
bool updated = false;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated)
Expand Down
2 changes: 1 addition & 1 deletion port.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@
#include <sys/types.h>

#ifdef __WIN32__
#define NOMINMAX
#define NOMINMAX 1
#include <windows.h>
#endif

Expand Down
9 changes: 6 additions & 3 deletions snapshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1941,9 +1941,12 @@ int S9xUnfreezeFromStream (STREAM stream)
}
else
{
// couldn't load graphics, so black out the screen instead
for (uint32 y = 0; y < (uint32) (IMAGE_HEIGHT); y++)
memset(GFX.Screen + y * GFX.RealPPL, 0, GFX.RealPPL * 2);
if (!Settings.LoadStateDoNotClearScreen)
{
// couldn't load graphics, so black out the screen instead
for (uint32 y = 0; y < (uint32)(IMAGE_HEIGHT); y++)
memset(GFX.Screen + y * GFX.RealPPL, 0, GFX.RealPPL * 2);
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions snes9x.h
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,8 @@ struct SSettings
int OneSlowClockCycle;
int TwoClockCycles;
int MaxSpriteTilesPerLine;

bool LoadStateDoNotClearScreen;
};

struct SSNESGameFixes
Expand Down