aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile266
-rw-r--r--Makefile.common49
-rw-r--r--jni/Android.mk5
-rw-r--r--libretro.c255
-rw-r--r--libretro.h1526
-rw-r--r--link.T2
-rw-r--r--source/65c816.h10
-rw-r--r--source/apu.c12
-rw-r--r--source/apu.h107
-rw-r--r--source/apu_blargg.c152
-rw-r--r--source/apu_blargg.h315
-rw-r--r--source/apumem.h17
-rw-r--r--source/blargg_endian.h8
-rw-r--r--source/c4.c4
-rw-r--r--source/c4emu.c7
-rw-r--r--source/cheats.c22
-rw-r--r--source/cheats.h64
-rw-r--r--source/cheats2.c12
-rw-r--r--source/clip.c40
-rw-r--r--source/cpu.c7
-rw-r--r--source/cpuaddr.h2
-rw-r--r--source/cpuexec.c88
-rw-r--r--source/cpuexec.h26
-rw-r--r--source/cpumacro.h17
-rw-r--r--source/cpuops.c1133
-rw-r--r--source/display.h8
-rw-r--r--source/dma.c94
-rw-r--r--source/dma.h4
-rw-r--r--source/dsp1.c41
-rw-r--r--source/dsp1.h5
-rw-r--r--source/font.h1
-rw-r--r--source/fxemu.c6
-rw-r--r--source/fxemu.h27
-rw-r--r--source/fxinst.c1202
-rw-r--r--source/fxinst.h112
-rw-r--r--source/getset.h46
-rw-r--r--source/gfx.c188
-rw-r--r--source/gfx.h197
-rw-r--r--source/globals.c35
-rw-r--r--source/memmap.c171
-rw-r--r--source/memmap.h33
-rw-r--r--source/port.h11
-rw-r--r--source/ppu.c406
-rw-r--r--source/ppu.h426
-rw-r--r--source/sa1.c31
-rw-r--r--source/sa1.h5
-rw-r--r--source/sa1cpu.c3
-rw-r--r--source/sar.h20
-rw-r--r--source/sdd1emu.c84
-rw-r--r--source/seta.h12
-rw-r--r--source/seta010.c6
-rw-r--r--source/snes9x.h142
-rw-r--r--source/soundux.c36
-rw-r--r--source/soundux.h44
-rw-r--r--source/spc700.c258
-rw-r--r--source/spc700.h28
-rw-r--r--source/spc7110.c6
-rw-r--r--source/spc7110.h4
-rw-r--r--source/srtc.h15
-rw-r--r--source/tile.c144
-rw-r--r--source/tile.h322
61 files changed, 3787 insertions, 4532 deletions
diff --git a/Makefile b/Makefile
index 7b1edbb..d53269e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,108 +1,102 @@
-DEBUG = 0
-PERF_TEST = 0
-HAVE_GRIFFIN = 0
+DEBUG = 0
+PERF_TEST = 0
+HAVE_GRIFFIN = 0
LOAD_FROM_MEMORY_TEST = 1
-USE_BLARGG_APU = 0
+USE_BLARGG_APU = 0
ifeq ($(platform),)
-platform = unix
+ platform = unix
ifeq ($(shell uname -a),)
- platform = win
+ platform = win
else ifneq ($(findstring Darwin,$(shell uname -a)),)
- platform = osx
+ platform = osx
arch = intel
ifeq ($(shell uname -p),powerpc)
arch = ppc
endif
else ifneq ($(findstring MINGW,$(shell uname -a)),)
- platform = win
+ platform = win
endif
endif
# system platform
system_platform = unix
ifeq ($(shell uname -a),)
-EXE_EXT = .exe
- system_platform = win
+ EXE_EXT = .exe
+ system_platform = win
else ifneq ($(findstring Darwin,$(shell uname -a)),)
- system_platform = osx
+ system_platform = osx
arch = intel
-ifeq ($(shell uname -p),powerpc)
- arch = ppc
-endif
+ ifeq ($(shell uname -p),powerpc)
+ arch = ppc
+ endif
else ifneq ($(findstring MINGW,$(shell uname -a)),)
- system_platform = win
+ system_platform = win
endif
ifeq ($(USE_BLARGG_APU), 1)
-TARGET_NAME := snes9x2005_plus
+ TARGET_NAME := snes9x2005_plus
else
-TARGET_NAME := snes9x2005
+ TARGET_NAME := snes9x2005
endif
GIT_VERSION := " $(shell git rev-parse --short HEAD || echo unknown)"
ifneq ($(GIT_VERSION)," unknown")
CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
endif
-DEFS :=
-LIBM := -lm
+DEFS :=
+LIBM := -lm
ifeq ($(platform), unix)
- TARGET := $(TARGET_NAME)_libretro.so
- fpic := -fPIC
- SHARED := -shared -Wl,--no-undefined -Wl,--version-script=link.T
-
- CFLAGS += -fno-builtin \
- -fno-exceptions -ffunction-sections
+ TARGET := $(TARGET_NAME)_libretro.so
+ fpic := -fPIC
+ SHARED := -shared -Wl,--no-undefined -Wl,--version-script=link.T
+ CFLAGS += -fno-builtin -fno-exceptions -ffunction-sections
else ifeq ($(platform), linux-portable)
- TARGET := $(TARGET_NAME)_libretro.so
- fpic := -fPIC -nostdlib
- SHARED := -shared -Wl,--version-script=link.T
- CFLAGS += -fno-builtin \
- -fno-exceptions -ffunction-sections
- LIBM :=
+ TARGET := $(TARGET_NAME)_libretro.so
+ fpic := -fPIC -nostdlib
+ SHARED := -shared -Wl,--version-script=link.T
+ CFLAGS += -fno-builtin -fno-exceptions -ffunction-sections
+ LIBM :=
else ifeq ($(platform), osx)
- TARGET := $(TARGET_NAME)_libretro.dylib
- fpic := -fPIC
- SHARED := -dynamiclib
+ TARGET := $(TARGET_NAME)_libretro.dylib
+ fpic := -fPIC
+ SHARED := -dynamiclib
ifeq ($(arch),ppc)
FLAGS += -DMSB_FIRST
OLD_GCC = 1
endif
- OSXVER = `sw_vers -productVersion | cut -d. -f 2`
- OSX_LT_MAVERICKS = `(( $(OSXVER) <= 9)) && echo "YES"`
- fpic += -mmacosx-version-min=10.1
+ OSXVER = `sw_vers -productVersion | cut -d. -f 2`
+ OSX_LT_MAVERICKS = `(( $(OSXVER) <= 9)) && echo "YES"`
+ fpic += -mmacosx-version-min=10.1
ifndef ($(NOUNIVERSAL))
- FLAGS += $(ARCHFLAGS)
- LDFLAGS += $(ARCHFLAGS)
+ FLAGS += $(ARCHFLAGS)
+ LDFLAGS += $(ARCHFLAGS)
endif
-
# iOS
else ifneq (,$(findstring ios,$(platform)))
-
-
- TARGET := $(TARGET_NAME)_libretro_ios.dylib
- fpic := -fPIC
- SHARED := -dynamiclib
+ TARGET := $(TARGET_NAME)_libretro_ios.dylib
+ fpic := -fPIC
+ SHARED := -dynamiclib
ifeq ($(IOSSDK),)
- IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path)
+ IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path)
endif
- CC = cc -arch armv7 -isysroot $(IOSSDK)
- CXX = c++ -arch armv7 -isysroot $(IOSSDK)
+ CC = cc -arch armv7 -isysroot $(IOSSDK)
+ CXX = c++ -arch armv7 -isysroot $(IOSSDK)
ifeq ($(platform),ios9)
- SHARED += -miphoneos-version-min=8.0
- CC += -miphoneos-version-min=8.0
- CXX += -miphoneos-version-min=8.0
+ SHARED += -miphoneos-version-min=8.0
+ CC += -miphoneos-version-min=8.0
+ CXX += -miphoneos-version-min=8.0
else
- SHARED += -miphoneos-version-min=5.0
- CC += -miphoneos-version-min=5.0
- CXX += -miphoneos-version-min=5.0
+ SHARED += -miphoneos-version-min=5.0
+ CC += -miphoneos-version-min=5.0
+ CXX += -miphoneos-version-min=5.0
endif
+# Theos iOS
else ifeq ($(platform), theos_ios)
- # Theos iOS
DEPLOYMENT_IOSVERSION = 5.0
TARGET = iphone:latest:$(DEPLOYMENT_IOSVERSION)
ARCHS = armv7 armv7s
@@ -113,132 +107,121 @@ include $(THEOS)/makefiles/common.mk
LIBRARY_NAME = $(TARGET_NAME)_libretro_ios
else ifeq ($(platform), qnx)
- TARGET := $(TARGET_NAME)_libretro_$(platform).so
- fpic := -fPIC
- SHARED := -shared -Wl,--no-undefined -Wl,--version-script=link.T
+ TARGET := $(TARGET_NAME)_libretro_$(platform).so
+ fpic := -fPIC
+ SHARED := -shared -Wl,--no-undefined -Wl,--version-script=link.T
CC = qcc -Vgcc_ntoarmv7le
CXX = QCC -Vgcc_ntoarmv7le_cpp
-
# PS3
else ifeq ($(platform), ps3)
- TARGET := $(TARGET_NAME)_libretro_$(platform).a
- 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
- STATIC_LINKING = 1
+ TARGET := $(TARGET_NAME)_libretro_$(platform).a
+ 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
+ STATIC_LINKING = 1
FLAGS += -DMSB_FIRST
OLD_GCC = 1
-
# PS3 (SNC)
else ifeq ($(platform), sncps3)
- TARGET := $(TARGET_NAME)_libretro_ps3.a
- CC = $(CELL_SDK)/host-win32/sn/bin/ps3ppusnc.exe
- CXX = $(CELL_SDK)/host-win32/sn/bin/ps3ppusnc.exe
- AR = $(CELL_SDK)/host-win32/sn/bin/ps3snarl.exe
- STATIC_LINKING = 1
+ TARGET := $(TARGET_NAME)_libretro_ps3.a
+ CC = $(CELL_SDK)/host-win32/sn/bin/ps3ppusnc.exe
+ CXX = $(CELL_SDK)/host-win32/sn/bin/ps3ppusnc.exe
+ AR = $(CELL_SDK)/host-win32/sn/bin/ps3snarl.exe
+ STATIC_LINKING = 1
FLAGS += -DMSB_FIRST
NO_GCC = 1
-
# PSP1
else ifeq ($(platform), psp1)
- TARGET := $(TARGET_NAME)_libretro_$(platform).a
+ TARGET := $(TARGET_NAME)_libretro_$(platform).a
CC = psp-gcc$(EXE_EXT)
CXX = psp-g++$(EXE_EXT)
AR = psp-ar$(EXE_EXT)
- STATIC_LINKING = 1
+ STATIC_LINKING = 1
LOAD_FROM_MEMORY_TEST = 0
- FLAGS += -G0
- CFLAGS += -march=allegrex -mno-abicalls -fno-pic -fno-builtin \
- -fno-exceptions -ffunction-sections
- DEFS += -DPSP -D_PSP_FW_VERSION=371
- STATIC_LINKING := 1
-
+ FLAGS += -G0
+ CFLAGS += \
+ -march=allegrex -mno-abicalls -fno-pic \
+ -fno-builtin -fno-exceptions -ffunction-sections
+ DEFS += -DPSP -D_PSP_FW_VERSION=371
+ STATIC_LINKING := 1
# Vita
else ifeq ($(platform), vita)
- TARGET := $(TARGET_NAME)_libretro_$(platform).a
+ TARGET := $(TARGET_NAME)_libretro_$(platform).a
CC = arm-vita-eabi-gcc$(EXE_EXT)
CXX = arm-vita-eabi-g++$(EXE_EXT)
AR = arm-vita-eabi-ar$(EXE_EXT)
- STATIC_LINKING = 1
+ STATIC_LINKING = 1
LOAD_FROM_MEMORY_TEST = 0
- DEFS += -DVITA
- STATIC_LINKING := 1
-
+ DEFS += -DVITA
+ STATIC_LINKING := 1
# CTR (3DS)
else ifeq ($(platform), ctr)
- TARGET := $(TARGET_NAME)_libretro_$(platform).a
- CC = $(DEVKITARM)/bin/arm-none-eabi-gcc$(EXE_EXT)
- CXX = $(DEVKITARM)/bin/arm-none-eabi-g++$(EXE_EXT)
- AR = $(DEVKITARM)/bin/arm-none-eabi-ar$(EXE_EXT)
- CFLAGS += -DARM11 -D_3DS
- CFLAGS += -march=armv6k -mtune=mpcore -mfloat-abi=hard
- CFLAGS += -Wall -mword-relocations
- CFLAGS += -fomit-frame-pointer -ffast-math
- CFLAGS += -D_3DS
- PLATFORM_DEFINES := -D_3DS
- STATIC_LINKING = 1
-
+ TARGET := $(TARGET_NAME)_libretro_$(platform).a
+ CC = $(DEVKITARM)/bin/arm-none-eabi-gcc$(EXE_EXT)
+ CXX = $(DEVKITARM)/bin/arm-none-eabi-g++$(EXE_EXT)
+ AR = $(DEVKITARM)/bin/arm-none-eabi-ar$(EXE_EXT)
+ CFLAGS += -DARM11 -D_3DS
+ CFLAGS += -march=armv6k -mtune=mpcore -mfloat-abi=hard
+ CFLAGS += -Wall -mword-relocations
+ CFLAGS += -fomit-frame-pointer -ffast-math
+ CFLAGS += -D_3DS
+ PLATFORM_DEFINES := -D_3DS
+ STATIC_LINKING = 1
# Nintendo Game Cube
else ifeq ($(platform), ngc)
TARGET := $(TARGET_NAME)_libretro_$(platform).a
- CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
- AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
- CFLAGS += -DGEKKO -DHW_DOL -mrvl -mcpu=750 -meabi -mhard-float -D__ppc__ -DMSB_FIRST
- CFLAGS += -U__INT32_TYPE__ -U __UINT32_TYPE__ -D__INT32_TYPE__=int
- STATIC_LINKING = 1
-
+ CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
+ AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
+ CFLAGS += -DGEKKO -DHW_DOL -mrvl -mcpu=750 -meabi -mhard-float -D__ppc__ -DMSB_FIRST
+ CFLAGS += -U__INT32_TYPE__ -U __UINT32_TYPE__ -D__INT32_TYPE__=int
+ STATIC_LINKING = 1
# Nintendo Wii
else ifeq ($(platform), wii)
- TARGET := $(TARGET_NAME)_libretro_$(platform).a
- CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
- AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
- CFLAGS += -DGEKKO -DHW_RVL -mrvl -mcpu=750 -meabi -mhard-float -D__ppc__ -DMSB_FIRST
- CFLAGS += -U__INT32_TYPE__ -U __UINT32_TYPE__ -D__INT32_TYPE__=int
- STATIC_LINKING = 1
-
+ TARGET := $(TARGET_NAME)_libretro_$(platform).a
+ CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
+ AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
+ CFLAGS += -DGEKKO -DHW_RVL -mrvl -mcpu=750 -meabi -mhard-float -D__ppc__ -DMSB_FIRST
+ CFLAGS += -U__INT32_TYPE__ -U __UINT32_TYPE__ -D__INT32_TYPE__=int
+ STATIC_LINKING = 1
# Nintendo WiiU
else ifeq ($(platform), wiiu)
- TARGET := $(TARGET_NAME)_libretro_$(platform).a
- CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
- AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
- CFLAGS += -DGEKKO -DWIIU -DHW_RVL -mwup -mcpu=750 -meabi -mhard-float -D__ppc__ -DMSB_FIRST
- CFLAGS += -U__INT32_TYPE__ -U __UINT32_TYPE__ -D__INT32_TYPE__=int
- STATIC_LINKING = 1
-
+ TARGET := $(TARGET_NAME)_libretro_$(platform).a
+ CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
+ AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
+ CFLAGS += -DGEKKO -DWIIU -DHW_RVL -mwup -mcpu=750 -meabi -mhard-float -D__ppc__ -DMSB_FIRST
+ CFLAGS += -U__INT32_TYPE__ -U __UINT32_TYPE__ -D__INT32_TYPE__=int
+ STATIC_LINKING = 1
else ifeq ($(platform), emscripten)
- TARGET := $(TARGET_NAME)_libretro_$(platform).bc
- STATIC_LINKING = 1
-
+ TARGET := $(TARGET_NAME)_libretro_$(platform).bc
+ STATIC_LINKING = 1
# GCW0
else ifeq ($(platform), gcw0)
- TARGET := $(TARGET_NAME)_libretro.so
- CC = /opt/gcw0-toolchain/usr/bin/mipsel-linux-gcc
- CXX = /opt/gcw0-toolchain/usr/bin/mipsel-linux-g++
- AR = /opt/gcw0-toolchain/usr/bin/mipsel-linux-ar
- fpic := -fPIC -nostdlib
- SHARED := -shared -Wl,--version-script=link.T
-
- LIBM :=
- LOAD_FROM_MEMORY_TEST = 0
- CFLAGS += -ffast-math -march=mips32 -mtune=mips32r2 -mhard-float
-
+ TARGET := $(TARGET_NAME)_libretro.so
+ CC = /opt/gcw0-toolchain/usr/bin/mipsel-linux-gcc
+ CXX = /opt/gcw0-toolchain/usr/bin/mipsel-linux-g++
+ AR = /opt/gcw0-toolchain/usr/bin/mipsel-linux-ar
+ fpic := -fPIC -nostdlib
+ SHARED := -shared -Wl,--version-script=link.T
+ LIBM :=
+ LOAD_FROM_MEMORY_TEST = 0
+ CFLAGS += -ffast-math -march=mips32 -mtune=mips32r2 -mhard-float
else
- TARGET := $(TARGET_NAME)_libretro.dll
- CC = gcc
- CXX = g++
- SHARED := -shared -Wl,--no-undefined -Wl,--version-script=link.T
- LDFLAGS += -static-libgcc -static-libstdc++ -lwinmm
+ TARGET := $(TARGET_NAME)_libretro.dll
+ CC = gcc
+ CXX = g++
+ SHARED := -shared -Wl,--no-undefined -Wl,--version-script=link.T
+ LDFLAGS += -static-libgcc -static-libstdc++ -lwinmm
endif
LDFLAGS += $(LIBM)
-CORE_DIR := ./source
+CORE_DIR := ./source
LIBRETRO_DIR := .
include Makefile.common
ifeq ($(platform), psp1)
- INCFLAGS += -I$(shell psp-config --pspsdk-path)/include
+ INCFLAGS += -I$(shell psp-config --pspsdk-path)/include
endif
OBJECTS := $(SOURCES_C:.c=.o)
@@ -247,15 +230,14 @@ LDFLAGS += $(fpic) $(SHARED)
FLAGS += $(fpic)
-
CXXFLAGS += $(FLAGS)
CFLAGS += $(FLAGS)
ifeq ($(platform), theos_ios)
-COMMON_FLAGS := -DIOS $(COMMON_DEFINES) $(INCFLAGS) -I$(THEOS_INCLUDE_PATH) -Wno-error
-$(LIBRARY_NAME)_CFLAGS += $(COMMON_FLAGS) $(CFLAGS)
-${LIBRARY_NAME}_FILES = $(SOURCES_C)
-include $(THEOS_MAKE_PATH)/library.mk
+ COMMON_FLAGS := -DIOS $(COMMON_DEFINES) $(INCFLAGS) -I$(THEOS_INCLUDE_PATH) -Wno-error
+ $(LIBRARY_NAME)_CFLAGS += $(COMMON_FLAGS) $(CFLAGS)
+ ${LIBRARY_NAME}_FILES = $(SOURCES_C)
+ include $(THEOS_MAKE_PATH)/library.mk
else
all: $(TARGET)
$(TARGET): $(OBJECTS)
diff --git a/Makefile.common b/Makefile.common
index 7159234..83a0fdc 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -2,9 +2,10 @@ INCFLAGS := -I$(CORE_DIR) -I$(LIBRETRO_DIR)
ifeq ($(HAVE_GRIFFIN), 1)
SOURCES_C := $(CORE_DIR)/catsfc_griffin.c
-SOURCES_C += $(CORE_DIR)/sa1.c \
- $(CORE_DIR)/sa1cpu.c \
- $(CORE_DIR)/apu_blargg.c
+SOURCES_C += \
+ $(CORE_DIR)/sa1.c \
+ $(CORE_DIR)/sa1cpu.c \
+ $(CORE_DIR)/apu_blargg.c
else
SOURCES_C := \
$(CORE_DIR)/apu.c \
@@ -39,48 +40,42 @@ SOURCES_C := \
$(CORE_DIR)/spc7110.c \
$(CORE_DIR)/srtc.c \
$(CORE_DIR)/tile.c \
- $(CORE_DIR)/apu_blargg.c
-
-SOURCES_C += $(LIBRETRO_DIR)/libretro.c
+ $(CORE_DIR)/apu_blargg.c \
+ $(LIBRETRO_DIR)/libretro.c
endif
ifeq ($(DEBUG),1)
-FLAGS += -O0 -g
+ FLAGS += -O0 -g
else
-FLAGS += -O3 -DNDEBUG
+ FLAGS += -O3 -DNDEBUG
endif
ifeq ($(PERF_TEST),1)
-FLAGS += -DPERF_TEST
+ FLAGS += -DPERF_TEST
endif
ifeq ($(USE_BLARGG_APU),1)
-FLAGS += -DUSE_BLARGG_APU
+ FLAGS += -DUSE_BLARGG_APU
endif
ifeq ($(LOAD_FROM_MEMORY_TEST),1)
-FLAGS += -DLOAD_FROM_MEMORY_TEST
+ FLAGS += -DLOAD_FROM_MEMORY_TEST
endif
-DEFS += -DSPC700_C -DEXECUTE_SUPERFX_PER_LINE -DSDD1_DECOMP \
- -DVAR_CYCLES -DCPU_SHUTDOWN -DSPC700_SHUTDOWN \
- -DNO_INLINE_SET_GET -DHAVE_MKSTEMP -DWANT_CHEATS
-
-DEFS += -D__LIBRETRO__
-
ifeq ($(OLD_GCC), 1)
-WARNINGS := -Wall
+ WARNINGS := -Wall
else ifeq ($(NO_GCC), 1)
-WARNINGS :=
+ WARNINGS :=
else
-WARNINGS := -Wall \
- -Wno-sign-compare \
- -Wno-unused-variable \
- -Wno-unused-function \
- -Wno-uninitialized \
- -Wno-strict-aliasing \
- -Wno-overflow \
- -fno-strict-overflow
+ WARNINGS := \
+ -Wall \
+ -Wno-sign-compare \
+ -Wno-unused-variable \
+ -Wno-unused-function \
+ -Wno-uninitialized \
+ -Wno-strict-aliasing \
+ -Wno-overflow \
+ -fno-strict-overflow
endif
FLAGS += $(DEFS) $(WARNINGS) $(INCFLAGS)
diff --git a/jni/Android.mk b/jni/Android.mk
index 579cb12..21da6bb 100644
--- a/jni/Android.mk
+++ b/jni/Android.mk
@@ -12,12 +12,10 @@ LIBRETRO_DIR := ..
DEBUG = 0
PERF_TEST = 0
-#HAVE_GRIFFIN = 1
HAVE_GRIFFIN = 0
LOAD_FROM_MEMORY_TEST = 1
USE_BLARGG_APU = 0
-
LOCAL_MODULE := retro
ifeq ($(TARGET_ARCH),arm)
@@ -33,10 +31,9 @@ ifeq ($(TARGET_ARCH),mips)
LOCAL_CFLAGS += -DANDROID_MIPS -D__mips__ -D__MIPSEL__
endif
-
include ../Makefile.common
LOCAL_SRC_FILES += $(SOURCES_C)
-LOCAL_CFLAGS += -std=gnu99 -ffast-math -DINLINE=inline $(FLAGS)
+LOCAL_CFLAGS += -std=gnu99 -ffast-math $(FLAGS)
include $(BUILD_SHARED_LIBRARY)
diff --git a/libretro.c b/libretro.c
index f2056b9..1cb7b30 100644
--- a/libretro.c
+++ b/libretro.c
@@ -38,9 +38,9 @@ char retro_save_directory[PATH_MAX];
char retro_base_name[PATH_MAX];
#ifdef _WIN32
-char slash = '\\';
+ char slash = '\\';
#else
-char slash = '/';
+ char slash = '/';
#endif
static int32_t samples_per_frame = 0;
@@ -48,15 +48,16 @@ static int32_t samplerate = (((SNES_CLOCK_SPEED * 6) / (32 * ONE_APU_CYCLE)));
#ifdef PERF_TEST
#define RETRO_PERFORMANCE_INIT(name) \
- retro_perf_tick_t current_ticks;\
- static struct retro_perf_counter name = {#name};\
- if (!name.registered) perf_cb.perf_register(&(name));\
- current_ticks = name.total
+ retro_perf_tick_t current_ticks; \
+ static struct retro_perf_counter name = {#name}; \
+ if (!name.registered) \
+ perf_cb.perf_register(&(name)); \
+ current_ticks = name.total
#define RETRO_PERFORMANCE_START(name) perf_cb.perf_start(&(name))
#define RETRO_PERFORMANCE_STOP(name) \
- perf_cb.perf_stop(&(name));\
- current_ticks = name.total - current_ticks;
+ perf_cb.perf_stop(&(name)); \
+ current_ticks = name.total - current_ticks;
#else
#define RETRO_PERFORMANCE_INIT(name)
#define RETRO_PERFORMANCE_START(name)
@@ -77,7 +78,6 @@ void retro_set_environment(retro_environment_t cb)
environ_cb(RETRO_ENVIRONMENT_GET_PERF_INTERFACE, &perf_cb);
}
-
void retro_set_video_refresh(retro_video_refresh_t cb)
{
video_cb = cb;
@@ -102,37 +102,33 @@ void retro_set_input_state(retro_input_state_t cb)
input_cb = cb;
}
-void retro_set_controller_port_device(unsigned port, unsigned device) {}
-
-unsigned retro_api_version()
+void retro_set_controller_port_device(unsigned in_port, unsigned device)
{
- return RETRO_API_VERSION;
}
-void S9xMessage(const char* message)
+unsigned retro_api_version()
{
- #define MAX_MESSAGE_LEN (36 * 3)
-
- static char buffer [MAX_MESSAGE_LEN + 1];
-
- printf("%s\n", message);
- strncpy(buffer, message, MAX_MESSAGE_LEN);
- buffer [MAX_MESSAGE_LEN] = 0;
- S9xSetInfoString(buffer);
+ return RETRO_API_VERSION;
}
void S9xDeinitDisplay(void)
{
#ifdef DS2_DMA
- if (GFX.Screen_buffer) AlignedFree(GFX.Screen, PtrAdj.GFXScreen);
+ if (GFX.Screen_buffer)
+ AlignedFree(GFX.Screen, PtrAdj.GFXScreen);
#elif defined(_3DS)
- if (GFX.Screen_buffer) linearFree(GFX.Screen_buffer);
+ if (GFX.Screen_buffer)
+ linearFree(GFX.Screen_buffer);
#else
- if (GFX.Screen_buffer) free(GFX.Screen_buffer);
+ if (GFX.Screen_buffer)
+ free(GFX.Screen_buffer);
#endif
- if (GFX.SubScreen_buffer) free(GFX.SubScreen_buffer);
- if (GFX.ZBuffer_buffer) free(GFX.ZBuffer_buffer);
- if (GFX.SubZBuffer_buffer) free(GFX.SubZBuffer_buffer);
+ if (GFX.SubScreen_buffer)
+ free(GFX.SubScreen_buffer);
+ if (GFX.ZBuffer_buffer)
+ free(GFX.ZBuffer_buffer);
+ if (GFX.SubZBuffer_buffer)
+ free(GFX.SubZBuffer_buffer);
GFX.Screen = NULL;
GFX.Screen_buffer = NULL;
@@ -174,9 +170,9 @@ bool S9xInitUpdate()
{
return (true);
}
+
#ifndef __WIN32__
-void _makepath(char* path, const char* drive, const char* dir,
- const char* fname, const char* ext)
+void _makepath(char* path, const char* drive, const char* dir, const char* fname, const char* ext)
{
if (dir && *dir)
{
@@ -196,48 +192,46 @@ void _makepath(char* path, const char* drive, const char* dir,
}
}
-void _splitpath(const char* path, char* drive, char* dir, char* fname,
- char* ext)
+void _splitpath (const char* path, char* drive, char* dir, char* fname, char* ext)
{
- *drive = 0;
-
- char* slash = strrchr((char*)path, '/');
+ const char* slash = strrchr(path, '/');
if (!slash)
slash = strrchr((char*)path, '\\');
- char* dot = strrchr((char*)path, '.');
+ const char* dot = strrchr(path, '.');
if (dot && slash && dot < slash)
dot = NULL;
if (!slash)
{
- strcpy(dir, "");
+ *dir = 0;
strcpy(fname, path);
if (dot)
{
- * (fname + (dot - path)) = 0;
+ fname[dot - path] = 0;
strcpy(ext, dot + 1);
}
else
- strcpy(ext, "");
+ *ext = 0;
}
else
{
strcpy(dir, path);
- * (dir + (slash - path)) = 0;
+ dir[slash - path] = 0;
strcpy(fname, slash + 1);
if (dot)
{
- * (fname + (dot - slash) - 1) = 0;
+ fname[dot - slash - 1] = 0;
strcpy(ext, dot + 1);
}
else
- strcpy(ext, "");
+ *ext = 0;
}
}
#endif
-const char* S9xGetFilename(const char* ex)
+
+const char* S9xGetFilename(const char* in)
{
static char filename [PATH_MAX + 1];
char drive [_MAX_DRIVE + 1];
@@ -245,9 +239,8 @@ const char* S9xGetFilename(const char* ex)
char fname [_MAX_FNAME + 1];
char ext [_MAX_EXT + 1];
_splitpath(Memory.ROMFilename, drive, dir, fname, ext);
- _makepath(filename, drive, dir, fname, ex);
-
- return (filename);
+ _makepath(filename, drive, dir, fname, in);
+ return filename;
}
void GetBaseName(const char* ex)
@@ -283,7 +276,6 @@ void init_sfc_setting(void)
Settings.ControllerOption = SNES_JOYPAD;
Settings.Transparency = true;
- Settings.SupportHiRes = true;
#ifdef USE_BLARGG_APU
Settings.SoundSync = false;
#endif
@@ -312,7 +304,7 @@ void retro_init(void)
struct retro_log_callback log;
enum retro_pixel_format rgb565;
static const struct retro_variable vars[] = {
- { "catsfc_VideoMode", "Video Mode; auto|NTSC|PAL" },
+ { "catsfc_VideoMode", "Video Mode; auto|NTSC|PAL" },
{ NULL, NULL },
};
@@ -321,6 +313,10 @@ void retro_init(void)
else
log_cb = NULL;
+ // State that the core supports achievements.
+ bool achievements = true;
+ environ_cb(RETRO_ENVIRONMENT_SET_SUPPORT_ACHIEVEMENTS, &achievements);
+
rgb565 = RETRO_PIXEL_FORMAT_RGB565;
if (environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &rgb565) && log_cb)
log_cb(RETRO_LOG_INFO,
@@ -338,6 +334,7 @@ void retro_init(void)
S9xInitSound();
#endif
environ_cb(RETRO_ENVIRONMENT_SET_VARIABLES, (void*)vars);
+ CPU.SaveStateVersion = 0;
}
void retro_deinit(void)
@@ -514,7 +511,6 @@ char* osd_GetPackDir()
_splitpath(Memory.ROMFilename, drive, dir, name, ext);
_makepath(filename, drive, dir, NULL, NULL);
-
if (!strncmp((char*)&Memory.ROM [0xffc0], "SUPER POWER LEAG 4 ", 21))
{
if (getenv("SPL4PACK"))
@@ -547,7 +543,7 @@ char* osd_GetPackDir()
return filename;
}
-unsigned retro_get_region(void)
+unsigned retro_get_region()
{
return Settings.PAL ? RETRO_REGION_PAL : RETRO_REGION_NTSC;
}
@@ -731,25 +727,20 @@ bool retro_unserialize(const void* data, size_t size)
void retro_cheat_reset(void)
{
-#ifdef WANT_CHEATS
S9xDeleteCheats();
S9xApplyCheats();
-#endif
}
-#ifdef WANT_CHEATS
extern SCheatData Cheat;
-#endif
void retro_cheat_set(unsigned index, bool enabled, const char* code)
{
-#ifdef WANT_CHEATS
uint32_t address;
uint8_t val;
-
+
bool sram;
- uint8_t bytes[3];//used only by GoldFinger, ignored for now
-
+ uint8_t bytes[3];//used only by GoldFinger, ignored for now
+
if (S9xGameGenieToRaw(code, &address, &val)!=NULL &&
S9xProActionReplayToRaw(code, &address, &val)!=NULL &&
S9xGoldFingerToRaw(code, &address, &sram, &val, bytes)!=NULL)
@@ -760,85 +751,84 @@ void retro_cheat_set(unsigned index, bool enabled, const char* code)
return; // cheat added in weird order, ignore
if (index == Cheat.num_cheats)
Cheat.num_cheats++;
-
+
Cheat.c[index].address = address;
Cheat.c[index].byte = val;
Cheat.c[index].enabled = enabled;
-
+
Cheat.c[index].saved = false; // it'll be saved next time cheats run anyways
-
+
Settings.ApplyCheats = true;
S9xApplyCheats();
-#endif
}
static void init_descriptors(void)
{
struct retro_input_descriptor desc[] = {
- { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "D-Pad Left" },
- { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "D-Pad Up" },
- { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "D-Pad Down" },
- { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "D-Pad Right" },
- { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "B" },
- { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "A" },
- { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X, "X" },
- { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y, "Y" },
- { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L, "L" },
- { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "R" },
- { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Select" },
- { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" },
-
- { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "D-Pad Left" },
- { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "D-Pad Up" },
- { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "D-Pad Down" },
- { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "D-Pad Right" },
- { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "B" },
- { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "A" },
- { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X, "X" },
- { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y, "Y" },
- { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L, "L" },
- { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "R" },
- { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Select" },
- { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" },
-
- { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "D-Pad Left" },
- { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "D-Pad Up" },
- { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "D-Pad Down" },
- { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "D-Pad Right" },
- { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "B" },
- { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "A" },
- { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X, "X" },
- { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y, "Y" },
- { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L, "L" },
- { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "R" },
- { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Select" },
- { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" },
-
- { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "D-Pad Left" },
- { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "D-Pad Up" },
- { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "D-Pad Down" },
- { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "D-Pad Right" },
- { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "B" },
- { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "A" },
- { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X, "X" },
- { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y, "Y" },
- { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L, "L" },
- { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "R" },
- { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Select" },
- { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" },
-
- { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "D-Pad Left" },
- { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "D-Pad Up" },
- { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "D-Pad Down" },
- { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "D-Pad Right" },
- { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "B" },
- { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "A" },
- { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X, "X" },
- { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y, "Y" },
- { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L, "L" },
- { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "R" },
- { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Select" },
- { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" },
+ { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "D-Pad Left" },
+ { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "D-Pad Up" },
+ { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "D-Pad Down" },
+ { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "D-Pad Right" },
+ { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "B" },
+ { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "A" },
+ { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X, "X" },
+ { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y, "Y" },
+ { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L, "L" },
+ { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "R" },
+ { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Select" },
+ { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" },
+
+ { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "D-Pad Left" },
+ { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "D-Pad Up" },
+ { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "D-Pad Down" },
+ { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "D-Pad Right" },
+ { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "B" },
+ { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "A" },
+ { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X, "X" },
+ { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y, "Y" },
+ { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L, "L" },
+ { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "R" },
+ { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Select" },
+ { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" },
+
+ { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "D-Pad Left" },
+ { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "D-Pad Up" },
+ { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "D-Pad Down" },
+ { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "D-Pad Right" },
+ { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "B" },
+ { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "A" },
+ { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X, "X" },
+ { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y, "Y" },
+ { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L, "L" },
+ { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "R" },
+ { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Select" },
+ { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" },
+
+ { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "D-Pad Left" },
+ { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "D-Pad Up" },
+ { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "D-Pad Down" },
+ { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "D-Pad Right" },
+ { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "B" },
+ { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "A" },
+ { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X, "X" },
+ { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y, "Y" },
+ { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L, "L" },
+ { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "R" },
+ { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Select" },
+ { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" },
+
+ { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "D-Pad Left" },
+ { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "D-Pad Up" },
+ { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "D-Pad Down" },
+ { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "D-Pad Right" },
+ { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "B" },
+ { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "A" },
+ { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X, "X" },
+ { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y, "Y" },
+ { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L, "L" },
+ { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "R" },
+ { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Select" },
+ { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" },
{ 0 },
};
@@ -859,12 +849,11 @@ bool retro_load_game(const struct retro_game_info* game)
#ifdef LOAD_FROM_MEMORY_TEST
if (!LoadROM(game))
#else
- if (!LoadROM(game->path))
+ if (!LoadROM(game->path))
#endif
- return false;
+ return false;
- Settings.FrameTime = (Settings.PAL ? Settings.FrameTimePAL :
- Settings.FrameTimeNTSC);
+ Settings.FrameTime = (Settings.PAL ? Settings.FrameTimePAL : Settings.FrameTimeNTSC);
retro_get_system_av_info(&av_info);
@@ -877,8 +866,7 @@ bool retro_load_game(const struct retro_game_info* game)
return true;
}
-bool retro_load_game_special(unsigned game_type,
- const struct retro_game_info* info, size_t num_info)
+bool retro_load_game_special(unsigned game_type, const struct retro_game_info* info, size_t num_info)
{
return false;
}
@@ -889,7 +877,7 @@ void retro_unload_game(void)
void* retro_get_memory_data(unsigned type)
{
- uint8_t* data = NULL;
+ uint8_t* data;
switch(type)
{
@@ -903,6 +891,7 @@ void* retro_get_memory_data(unsigned type)
data = Memory.VRAM;
break;
default:
+ data = NULL;
break;
}
diff --git a/libretro.h b/libretro.h
index dd76b0f..469b86a 100644
--- a/libretro.h
+++ b/libretro.h
@@ -23,7 +23,41 @@ extern "C" {
#endif
#endif
-/* Used for checking API/ABI mismatches that can break libretro
+#ifndef RETRO_CALLCONV
+# if defined(__GNUC__) && defined(__i386__) && !defined(__x86_64__)
+# define RETRO_CALLCONV __attribute__((cdecl))
+# elif defined(_MSC_VER) && defined(_M_X86) && !defined(_M_X64)
+# define RETRO_CALLCONV __cdecl
+# else
+# define RETRO_CALLCONV /* all other platforms only have one calling convention each */
+# endif
+#endif
+
+#ifndef RETRO_API
+# if defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
+# ifdef RETRO_IMPORT_SYMBOLS
+# ifdef __GNUC__
+# define RETRO_API RETRO_CALLCONV __attribute__((__dllimport__))
+# else
+# define RETRO_API RETRO_CALLCONV __declspec(dllimport)
+# endif
+# else
+# ifdef __GNUC__
+# define RETRO_API RETRO_CALLCONV __attribute__((__dllexport__))
+# else
+# define RETRO_API RETRO_CALLCONV __declspec(dllexport)
+# endif
+# endif
+# else
+# if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__CELLOS_LV2__)
+# define RETRO_API RETRO_CALLCONV __attribute__((__visibility__("default")))
+# else
+# define RETRO_API RETRO_CALLCONV
+# endif
+# endif
+#endif
+
+/* Used for checking API/ABI mismatches that can break libretro
* implementations.
* It is not incremented for compatible changes to the API.
*/
@@ -33,13 +67,13 @@ extern "C" {
* Libretro's fundamental device abstractions.
*
* Libretro's input system consists of some standardized device types,
- * such as a joypad (with/without analog), mouse, keyboard, lightgun
+ * such as a joypad (with/without analog), mouse, keyboard, lightgun
* and a pointer.
*
- * The functionality of these devices are fixed, and individual cores
+ * The functionality of these devices are fixed, and individual cores
* map their own concept of a controller to libretro's abstractions.
- * This makes it possible for frontends to map the abstract types to a
- * real input device, and not having to worry about binding input
+ * This makes it possible for frontends to map the abstract types to a
+ * real input device, and not having to worry about binding input
* correctly to arbitrary controller layouts.
*/
@@ -50,22 +84,22 @@ extern "C" {
/* Input disabled. */
#define RETRO_DEVICE_NONE 0
-/* The JOYPAD is called RetroPad. It is essentially a Super Nintendo
- * controller, but with additional L2/R2/L3/R3 buttons, similar to a
+/* The JOYPAD is called RetroPad. It is essentially a Super Nintendo
+ * controller, but with additional L2/R2/L3/R3 buttons, similar to a
* PS1 DualShock. */
#define RETRO_DEVICE_JOYPAD 1
/* The mouse is a simple mouse, similar to Super Nintendo's mouse.
* X and Y coordinates are reported relatively to last poll (poll callback).
- * It is up to the libretro implementation to keep track of where the mouse
+ * It is up to the libretro implementation to keep track of where the mouse
* pointer is supposed to be on the screen.
- * The frontend must make sure not to interfere with its own hardware
+ * The frontend must make sure not to interfere with its own hardware
* mouse pointer.
*/
#define RETRO_DEVICE_MOUSE 2
/* KEYBOARD device lets one poll for raw key pressed.
- * It is poll based, so input callback will return with the current
+ * It is poll based, so input callback will return with the current
* pressed state.
* For event/text based keyboard input, see
* RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK.
@@ -78,7 +112,7 @@ extern "C" {
/* The ANALOG device is an extension to JOYPAD (RetroPad).
* Similar to DualShock it adds two analog sticks.
- * This is treated as a separate device type as it returns values in the
+ * This is treated as a separate device type as it returns values in the
* full analog range of [-0x8000, 0x7fff]. Positive X axis is right.
* Positive Y axis is down.
* Only use ANALOG type when polling for analog values of the axes.
@@ -86,7 +120,7 @@ extern "C" {
#define RETRO_DEVICE_ANALOG 5
/* Abstracts the concept of a pointing mechanism, e.g. touch.
- * This allows libretro to query in absolute coordinates where on the
+ * This allows libretro to query in absolute coordinates where on the
* screen a mouse (or something similar) is being placed.
* For a touch centric device, coordinates reported are the coordinates
* of the press.
@@ -94,31 +128,31 @@ extern "C" {
* Coordinates in X and Y are reported as:
* [-0x7fff, 0x7fff]: -0x7fff corresponds to the far left/top of the screen,
* and 0x7fff corresponds to the far right/bottom of the screen.
- * The "screen" is here defined as area that is passed to the frontend and
+ * The "screen" is here defined as area that is passed to the frontend and
* later displayed on the monitor.
*
* The frontend is free to scale/resize this screen as it sees fit, however,
- * (X, Y) = (-0x7fff, -0x7fff) will correspond to the top-left pixel of the
+ * (X, Y) = (-0x7fff, -0x7fff) will correspond to the top-left pixel of the
* game image, etc.
*
- * To check if the pointer coordinates are valid (e.g. a touch display
+ * To check if the pointer coordinates are valid (e.g. a touch display
* actually being touched), PRESSED returns 1 or 0.
*
- * If using a mouse on a desktop, PRESSED will usually correspond to the
+ * If using a mouse on a desktop, PRESSED will usually correspond to the
* left mouse button, but this is a frontend decision.
* PRESSED will only return 1 if the pointer is inside the game screen.
*
- * For multi-touch, the index variable can be used to successively query
+ * For multi-touch, the index variable can be used to successively query
* more presses.
* If index = 0 returns true for _PRESSED, coordinates can be extracted
- * with _X, _Y for index = 0. One can then query _PRESSED, _X, _Y with
+ * with _X, _Y for index = 0. One can then query _PRESSED, _X, _Y with
* index = 1, and so on.
- * Eventually _PRESSED will return false for an index. No further presses
+ * Eventually _PRESSED will return false for an index. No further presses
* are registered at this point. */
#define RETRO_DEVICE_POINTER 6
/* Buttons for the RetroPad (JOYPAD).
- * The placement of these is equivalent to placements on the
+ * The placement of these is equivalent to placements on the
* Super Nintendo controller.
* L2/R2/L3/R3 buttons correspond to the PS1 DualShock. */
#define RETRO_DEVICE_ID_JOYPAD_B 0
@@ -145,13 +179,15 @@ extern "C" {
#define RETRO_DEVICE_ID_ANALOG_Y 1
/* Id values for MOUSE. */
-#define RETRO_DEVICE_ID_MOUSE_X 0
-#define RETRO_DEVICE_ID_MOUSE_Y 1
-#define RETRO_DEVICE_ID_MOUSE_LEFT 2
-#define RETRO_DEVICE_ID_MOUSE_RIGHT 3
-#define RETRO_DEVICE_ID_MOUSE_WHEELUP 4
-#define RETRO_DEVICE_ID_MOUSE_WHEELDOWN 5
-#define RETRO_DEVICE_ID_MOUSE_MIDDLE 6
+#define RETRO_DEVICE_ID_MOUSE_X 0
+#define RETRO_DEVICE_ID_MOUSE_Y 1
+#define RETRO_DEVICE_ID_MOUSE_LEFT 2
+#define RETRO_DEVICE_ID_MOUSE_RIGHT 3
+#define RETRO_DEVICE_ID_MOUSE_WHEELUP 4
+#define RETRO_DEVICE_ID_MOUSE_WHEELDOWN 5
+#define RETRO_DEVICE_ID_MOUSE_MIDDLE 6
+#define RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELUP 7
+#define RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELDOWN 8
/* Id values for LIGHTGUN types. */
#define RETRO_DEVICE_ID_LIGHTGUN_X 0
@@ -186,14 +222,16 @@ enum retro_language
RETRO_LANGUAGE_KOREAN = 9,
RETRO_LANGUAGE_CHINESE_TRADITIONAL = 10,
RETRO_LANGUAGE_CHINESE_SIMPLIFIED = 11,
+ RETRO_LANGUAGE_ESPERANTO = 12,
+ RETRO_LANGUAGE_POLISH = 13,
RETRO_LANGUAGE_LAST,
/* Ensure sizeof(enum) == sizeof(int) */
- RETRO_LANGUAGE_DUMMY = INT_MAX
+ RETRO_LANGUAGE_DUMMY = INT_MAX
};
/* Passed to retro_get_memory_data/size().
- * If the memory type doesn't apply to the
+ * If the memory type doesn't apply to the
* implementation NULL/0 can be returned.
*/
#define RETRO_MEMORY_MASK 0xff
@@ -383,7 +421,7 @@ enum retro_mod
RETROKMOD_DUMMY = INT_MAX /* Ensure sizeof(enum) == sizeof(int) */
};
-/* If set, this call is not part of the public libretro API yet. It can
+/* If set, this call is not part of the public libretro API yet. It can
* change or be removed at any time. */
#define RETRO_ENVIRONMENT_EXPERIMENTAL 0x10000
/* Environment callback to be used internally in frontend. */
@@ -393,11 +431,11 @@ enum retro_mod
#define RETRO_ENVIRONMENT_SET_ROTATION 1 /* const unsigned * --
* Sets screen rotation of graphics.
* Is only implemented if rotation can be accelerated by hardware.
- * Valid values are 0, 1, 2, 3, which rotates screen by 0, 90, 180,
+ * Valid values are 0, 1, 2, 3, which rotates screen by 0, 90, 180,
* 270 degrees counter-clockwise respectively.
*/
#define RETRO_ENVIRONMENT_GET_OVERSCAN 2 /* bool * --
- * Boolean value whether or not the implementation should use overscan,
+ * Boolean value whether or not the implementation should use overscan,
* or crop away overscan.
*/
#define RETRO_ENVIRONMENT_GET_CAN_DUPE 3 /* bool * --
@@ -405,15 +443,15 @@ enum retro_mod
* passing NULL to video frame callback.
*/
-/* Environ 4, 5 are no longer supported (GET_VARIABLE / SET_VARIABLES),
- * and reserved to avoid possible ABI clash.
- */
+ /* Environ 4, 5 are no longer supported (GET_VARIABLE / SET_VARIABLES),
+ * and reserved to avoid possible ABI clash.
+ */
#define RETRO_ENVIRONMENT_SET_MESSAGE 6 /* const struct retro_message * --
- * Sets a message to be displayed in implementation-specific manner
+ * Sets a message to be displayed in implementation-specific manner
* for a certain amount of 'frames'.
- * Should not be used for trivial messages, which should simply be
- * logged via RETRO_ENVIRONMENT_GET_LOG_INTERFACE (or as a
+ * Should not be used for trivial messages, which should simply be
+ * logged via RETRO_ENVIRONMENT_GET_LOG_INTERFACE (or as a
* fallback, stderr).
*/
#define RETRO_ENVIRONMENT_SHUTDOWN 7 /* N/A (NULL) --
@@ -422,415 +460,501 @@ enum retro_mod
* way to shutdown the game from a menu item or similar.
*/
#define RETRO_ENVIRONMENT_SET_PERFORMANCE_LEVEL 8
-/* const unsigned * --
- * Gives a hint to the frontend how demanding this implementation
- * is on a system. E.g. reporting a level of 2 means
- * this implementation should run decently on all frontends
- * of level 2 and up.
- *
- * It can be used by the frontend to potentially warn
- * about too demanding implementations.
- *
- * The levels are "floating".
- *
- * This function can be called on a per-game basis,
- * as certain games an implementation can play might be
- * particularly demanding.
- * If called, it should be called in retro_load_game().
- */
+ /* const unsigned * --
+ * Gives a hint to the frontend how demanding this implementation
+ * is on a system. E.g. reporting a level of 2 means
+ * this implementation should run decently on all frontends
+ * of level 2 and up.
+ *
+ * It can be used by the frontend to potentially warn
+ * about too demanding implementations.
+ *
+ * The levels are "floating".
+ *
+ * This function can be called on a per-game basis,
+ * as certain games an implementation can play might be
+ * particularly demanding.
+ * If called, it should be called in retro_load_game().
+ */
#define RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY 9
-/* const char ** --
- * Returns the "system" directory of the frontend.
- * This directory can be used to store system specific
- * content such as BIOSes, configuration data, etc.
- * The returned value can be NULL.
- * If so, no such directory is defined,
- * and it's up to the implementation to find a suitable directory.
- *
- * NOTE: Some cores used this folder also for "save" data such as
- * memory cards, etc, for lack of a better place to put it.
- * This is now discouraged, and if possible, cores should try to
- * use the new GET_SAVE_DIRECTORY.
- */
+ /* const char ** --
+ * Returns the "system" directory of the frontend.
+ * This directory can be used to store system specific
+ * content such as BIOSes, configuration data, etc.
+ * The returned value can be NULL.
+ * If so, no such directory is defined,
+ * and it's up to the implementation to find a suitable directory.
+ *
+ * NOTE: Some cores used this folder also for "save" data such as
+ * memory cards, etc, for lack of a better place to put it.
+ * This is now discouraged, and if possible, cores should try to
+ * use the new GET_SAVE_DIRECTORY.
+ */
#define RETRO_ENVIRONMENT_SET_PIXEL_FORMAT 10
-/* const enum retro_pixel_format * --
- * Sets the internal pixel format used by the implementation.
- * The default pixel format is RETRO_PIXEL_FORMAT_0RGB1555.
- * This pixel format however, is deprecated (see enum retro_pixel_format).
- * If the call returns false, the frontend does not support this pixel
- * format.
- *
- * This function should be called inside retro_load_game() or
- * retro_get_system_av_info().
- */
+ /* const enum retro_pixel_format * --
+ * Sets the internal pixel format used by the implementation.
+ * The default pixel format is RETRO_PIXEL_FORMAT_0RGB1555.
+ * This pixel format however, is deprecated (see enum retro_pixel_format).
+ * If the call returns false, the frontend does not support this pixel
+ * format.
+ *
+ * This function should be called inside retro_load_game() or
+ * retro_get_system_av_info().
+ */
#define RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS 11
-/* const struct retro_input_descriptor * --
- * Sets an array of retro_input_descriptors.
- * It is up to the frontend to present this in a usable way.
- * The array is terminated by retro_input_descriptor::description
- * being set to NULL.
- * This function can be called at any time, but it is recommended
- * to call it as early as possible.
- */
+ /* const struct retro_input_descriptor * --
+ * Sets an array of retro_input_descriptors.
+ * It is up to the frontend to present this in a usable way.
+ * The array is terminated by retro_input_descriptor::description
+ * being set to NULL.
+ * This function can be called at any time, but it is recommended
+ * to call it as early as possible.
+ */
#define RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK 12
-/* const struct retro_keyboard_callback * --
- * Sets a callback function used to notify core about keyboard events.
- */
+ /* const struct retro_keyboard_callback * --
+ * Sets a callback function used to notify core about keyboard events.
+ */
#define RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE 13
-/* const struct retro_disk_control_callback * --
- * Sets an interface which frontend can use to eject and insert
- * disk images.
- * This is used for games which consist of multiple images and
- * must be manually swapped out by the user (e.g. PSX).
- */
+ /* const struct retro_disk_control_callback * --
+ * Sets an interface which frontend can use to eject and insert
+ * disk images.
+ * This is used for games which consist of multiple images and
+ * must be manually swapped out by the user (e.g. PSX).
+ */
#define RETRO_ENVIRONMENT_SET_HW_RENDER 14
-/* struct retro_hw_render_callback * --
- * Sets an interface to let a libretro core render with
- * hardware acceleration.
- * Should be called in retro_load_game().
- * If successful, libretro cores will be able to render to a
- * frontend-provided framebuffer.
- * The size of this framebuffer will be at least as large as
- * max_width/max_height provided in get_av_info().
- * If HW rendering is used, pass only RETRO_HW_FRAME_BUFFER_VALID or
- * NULL to retro_video_refresh_t.
- */
+ /* struct retro_hw_render_callback * --
+ * Sets an interface to let a libretro core render with
+ * hardware acceleration.
+ * Should be called in retro_load_game().
+ * If successful, libretro cores will be able to render to a
+ * frontend-provided framebuffer.
+ * The size of this framebuffer will be at least as large as
+ * max_width/max_height provided in get_av_info().
+ * If HW rendering is used, pass only RETRO_HW_FRAME_BUFFER_VALID or
+ * NULL to retro_video_refresh_t.
+ */
#define RETRO_ENVIRONMENT_GET_VARIABLE 15
-/* struct retro_variable * --
- * Interface to acquire user-defined information from environment
- * that cannot feasibly be supported in a multi-system way.
- * 'key' should be set to a key which has already been set by
- * SET_VARIABLES.
- * 'data' will be set to a value or NULL.
- */
+ /* struct retro_variable * --
+ * Interface to acquire user-defined information from environment
+ * that cannot feasibly be supported in a multi-system way.
+ * 'key' should be set to a key which has already been set by
+ * SET_VARIABLES.
+ * 'data' will be set to a value or NULL.
+ */
#define RETRO_ENVIRONMENT_SET_VARIABLES 16
-/* const struct retro_variable * --
- * Allows an implementation to signal the environment
- * which variables it might want to check for later using
- * GET_VARIABLE.
- * This allows the frontend to present these variables to
- * a user dynamically.
- * This should be called as early as possible (ideally in
- * retro_set_environment).
- *
- * 'data' points to an array of retro_variable structs
- * terminated by a { NULL, NULL } element.
- * retro_variable::key should be namespaced to not collide
- * with other implementations' keys. E.g. A core called
- * 'foo' should use keys named as 'foo_option'.
- * retro_variable::value should contain a human readable
- * description of the key as well as a '|' delimited list
- * of expected values.
- *
- * The number of possible options should be very limited,
- * i.e. it should be feasible to cycle through options
- * without a keyboard.
- *
- * First entry should be treated as a default.
- *
- * Example entry:
- * { "foo_option", "Speed hack coprocessor X; false|true" }
- *
- * Text before first ';' is description. This ';' must be
- * followed by a space, and followed by a list of possible
- * values split up with '|'.
- *
- * Only strings are operated on. The possible values will
- * generally be displayed and stored as-is by the frontend.
- */
+ /* const struct retro_variable * --
+ * Allows an implementation to signal the environment
+ * which variables it might want to check for later using
+ * GET_VARIABLE.
+ * This allows the frontend to present these variables to
+ * a user dynamically.
+ * This should be called as early as possible (ideally in
+ * retro_set_environment).
+ *
+ * 'data' points to an array of retro_variable structs
+ * terminated by a { NULL, NULL } element.
+ * retro_variable::key should be namespaced to not collide
+ * with other implementations' keys. E.g. A core called
+ * 'foo' should use keys named as 'foo_option'.
+ * retro_variable::value should contain a human readable
+ * description of the key as well as a '|' delimited list
+ * of expected values.
+ *
+ * The number of possible options should be very limited,
+ * i.e. it should be feasible to cycle through options
+ * without a keyboard.
+ *
+ * First entry should be treated as a default.
+ *
+ * Example entry:
+ * { "foo_option", "Speed hack coprocessor X; false|true" }
+ *
+ * Text before first ';' is description. This ';' must be
+ * followed by a space, and followed by a list of possible
+ * values split up with '|'.
+ *
+ * Only strings are operated on. The possible values will
+ * generally be displayed and stored as-is by the frontend.
+ */
#define RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE 17
-/* bool * --
- * Result is set to true if some variables are updated by
- * frontend since last call to RETRO_ENVIRONMENT_GET_VARIABLE.
- * Variables should be queried with GET_VARIABLE.
- */
+ /* bool * --
+ * Result is set to true if some variables are updated by
+ * frontend since last call to RETRO_ENVIRONMENT_GET_VARIABLE.
+ * Variables should be queried with GET_VARIABLE.
+ */
#define RETRO_ENVIRONMENT_SET_SUPPORT_NO_GAME 18
-/* const bool * --
- * If true, the libretro implementation supports calls to
- * retro_load_game() with NULL as argument.
- * Used by cores which can run without particular game data.
- * This should be called within retro_set_environment() only.
- */
+ /* const bool * --
+ * If true, the libretro implementation supports calls to
+ * retro_load_game() with NULL as argument.
+ * Used by cores which can run without particular game data.
+ * This should be called within retro_set_environment() only.
+ */
#define RETRO_ENVIRONMENT_GET_LIBRETRO_PATH 19
-/* const char ** --
- * Retrieves the absolute path from where this libretro
- * implementation was loaded.
- * NULL is returned if the libretro was loaded statically
- * (i.e. linked statically to frontend), or if the path cannot be
- * determined.
- * Mostly useful in cooperation with SET_SUPPORT_NO_GAME as assets can
- * be loaded without ugly hacks.
- */
-
-/* Environment 20 was an obsolete version of SET_AUDIO_CALLBACK.
- * It was not used by any known core at the time,
- * and was removed from the API. */
+ /* const char ** --
+ * Retrieves the absolute path from where this libretro
+ * implementation was loaded.
+ * NULL is returned if the libretro was loaded statically
+ * (i.e. linked statically to frontend), or if the path cannot be
+ * determined.
+ * Mostly useful in cooperation with SET_SUPPORT_NO_GAME as assets can
+ * be loaded without ugly hacks.
+ */
+
+ /* Environment 20 was an obsolete version of SET_AUDIO_CALLBACK.
+ * It was not used by any known core at the time,
+ * and was removed from the API. */
#define RETRO_ENVIRONMENT_SET_AUDIO_CALLBACK 22
-/* const struct retro_audio_callback * --
- * Sets an interface which is used to notify a libretro core about audio
- * being available for writing.
- * The callback can be called from any thread, so a core using this must
- * have a thread safe audio implementation.
- * It is intended for games where audio and video are completely
- * asynchronous and audio can be generated on the fly.
- * This interface is not recommended for use with emulators which have
- * highly synchronous audio.
- *
- * The callback only notifies about writability; the libretro core still
- * has to call the normal audio callbacks
- * to write audio. The audio callbacks must be called from within the
- * notification callback.
- * The amount of audio data to write is up to the implementation.
- * Generally, the audio callback will be called continously in a loop.
- *
- * Due to thread safety guarantees and lack of sync between audio and
- * video, a frontend can selectively disallow this interface based on
- * internal configuration. A core using this interface must also
- * implement the "normal" audio interface.
- *
- * A libretro core using SET_AUDIO_CALLBACK should also make use of
- * SET_FRAME_TIME_CALLBACK.
- */
+ /* const struct retro_audio_callback * --
+ * Sets an interface which is used to notify a libretro core about audio
+ * being available for writing.
+ * The callback can be called from any thread, so a core using this must
+ * have a thread safe audio implementation.
+ * It is intended for games where audio and video are completely
+ * asynchronous and audio can be generated on the fly.
+ * This interface is not recommended for use with emulators which have
+ * highly synchronous audio.
+ *
+ * The callback only notifies about writability; the libretro core still
+ * has to call the normal audio callbacks
+ * to write audio. The audio callbacks must be called from within the
+ * notification callback.
+ * The amount of audio data to write is up to the implementation.
+ * Generally, the audio callback will be called continously in a loop.
+ *
+ * Due to thread safety guarantees and lack of sync between audio and
+ * video, a frontend can selectively disallow this interface based on
+ * internal configuration. A core using this interface must also
+ * implement the "normal" audio interface.
+ *
+ * A libretro core using SET_AUDIO_CALLBACK should also make use of
+ * SET_FRAME_TIME_CALLBACK.
+ */
#define RETRO_ENVIRONMENT_SET_FRAME_TIME_CALLBACK 21
-/* const struct retro_frame_time_callback * --
- * Lets the core know how much time has passed since last
- * invocation of retro_run().
- * The frontend can tamper with the timing to fake fast-forward,
- * slow-motion, frame stepping, etc.
- * In this case the delta time will use the reference value
- * in frame_time_callback..
- */
+ /* const struct retro_frame_time_callback * --
+ * Lets the core know how much time has passed since last
+ * invocation of retro_run().
+ * The frontend can tamper with the timing to fake fast-forward,
+ * slow-motion, frame stepping, etc.
+ * In this case the delta time will use the reference value
+ * in frame_time_callback..
+ */
#define RETRO_ENVIRONMENT_GET_RUMBLE_INTERFACE 23
-/* struct retro_rumble_interface * --
- * Gets an interface which is used by a libretro core to set
- * state of rumble motors in controllers.
- * A strong and weak motor is supported, and they can be
- * controlled indepedently.
- */
+ /* struct retro_rumble_interface * --
+ * Gets an interface which is used by a libretro core to set
+ * state of rumble motors in controllers.
+ * A strong and weak motor is supported, and they can be
+ * controlled indepedently.
+ */
#define RETRO_ENVIRONMENT_GET_INPUT_DEVICE_CAPABILITIES 24
-/* uint64_t * --
- * Gets a bitmask telling which device type are expected to be
- * handled properly in a call to retro_input_state_t.
- * Devices which are not handled or recognized always return
- * 0 in retro_input_state_t.
- * Example bitmask: caps = (1 << RETRO_DEVICE_JOYPAD) | (1 << RETRO_DEVICE_ANALOG).
- * Should only be called in retro_run().
- */
+ /* uint64_t * --
+ * Gets a bitmask telling which device type are expected to be
+ * handled properly in a call to retro_input_state_t.
+ * Devices which are not handled or recognized always return
+ * 0 in retro_input_state_t.
+ * Example bitmask: caps = (1 << RETRO_DEVICE_JOYPAD) | (1 << RETRO_DEVICE_ANALOG).
+ * Should only be called in retro_run().
+ */
#define RETRO_ENVIRONMENT_GET_SENSOR_INTERFACE (25 | RETRO_ENVIRONMENT_EXPERIMENTAL)
-/* struct retro_sensor_interface * --
- * Gets access to the sensor interface.
- * The purpose of this interface is to allow
- * setting state related to sensors such as polling rate,
- * enabling/disable it entirely, etc.
- * Reading sensor state is done via the normal
- * input_state_callback API.
- */
+ /* struct retro_sensor_interface * --
+ * Gets access to the sensor interface.
+ * The purpose of this interface is to allow
+ * setting state related to sensors such as polling rate,
+ * enabling/disable it entirely, etc.
+ * Reading sensor state is done via the normal
+ * input_state_callback API.
+ */
#define RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE (26 | RETRO_ENVIRONMENT_EXPERIMENTAL)
-/* struct retro_camera_callback * --
- * Gets an interface to a video camera driver.
- * A libretro core can use this interface to get access to a
- * video camera.
- * New video frames are delivered in a callback in same
- * thread as retro_run().
- *
- * GET_CAMERA_INTERFACE should be called in retro_load_game().
- *
- * Depending on the camera implementation used, camera frames
- * will be delivered as a raw framebuffer,
- * or as an OpenGL texture directly.
- *
- * The core has to tell the frontend here which types of
- * buffers can be handled properly.
- * An OpenGL texture can only be handled when using a
- * libretro GL core (SET_HW_RENDER).
- * It is recommended to use a libretro GL core when
- * using camera interface.
- *
- * The camera is not started automatically. The retrieved start/stop
- * functions must be used to explicitly
- * start and stop the camera driver.
- */
+ /* struct retro_camera_callback * --
+ * Gets an interface to a video camera driver.
+ * A libretro core can use this interface to get access to a
+ * video camera.
+ * New video frames are delivered in a callback in same
+ * thread as retro_run().
+ *
+ * GET_CAMERA_INTERFACE should be called in retro_load_game().
+ *
+ * Depending on the camera implementation used, camera frames
+ * will be delivered as a raw framebuffer,
+ * or as an OpenGL texture directly.
+ *
+ * The core has to tell the frontend here which types of
+ * buffers can be handled properly.
+ * An OpenGL texture can only be handled when using a
+ * libretro GL core (SET_HW_RENDER).
+ * It is recommended to use a libretro GL core when
+ * using camera interface.
+ *
+ * The camera is not started automatically. The retrieved start/stop
+ * functions must be used to explicitly
+ * start and stop the camera driver.
+ */
#define RETRO_ENVIRONMENT_GET_LOG_INTERFACE 27
-/* struct retro_log_callback * --
- * Gets an interface for logging. This is useful for
- * logging in a cross-platform way
- * as certain platforms cannot use use stderr for logging.
- * It also allows the frontend to
- * show logging information in a more suitable way.
- * If this interface is not used, libretro cores should
- * log to stderr as desired.
- */
+ /* struct retro_log_callback * --
+ * Gets an interface for logging. This is useful for
+ * logging in a cross-platform way
+ * as certain platforms cannot use use stderr for logging.
+ * It also allows the frontend to
+ * show logging information in a more suitable way.
+ * If this interface is not used, libretro cores should
+ * log to stderr as desired.
+ */
#define RETRO_ENVIRONMENT_GET_PERF_INTERFACE 28
-/* struct retro_perf_callback * --
- * Gets an interface for performance counters. This is useful
- * for performance logging in a cross-platform way and for detecting
- * architecture-specific features, such as SIMD support.
- */
+ /* struct retro_perf_callback * --
+ * Gets an interface for performance counters. This is useful
+ * for performance logging in a cross-platform way and for detecting
+ * architecture-specific features, such as SIMD support.
+ */
#define RETRO_ENVIRONMENT_GET_LOCATION_INTERFACE 29
-/* struct retro_location_callback * --
- * Gets access to the location interface.
- * The purpose of this interface is to be able to retrieve
- * location-based information from the host device,
- * such as current latitude / longitude.
- */
-#define RETRO_ENVIRONMENT_GET_CONTENT_DIRECTORY 30
-/* const char ** --
- * Returns the "content" directory of the frontend.
- * This directory can be used to store specific assets that the
- * core relies upon, such as art assets,
- * input data, etc etc.
- * The returned value can be NULL.
- * If so, no such directory is defined,
- * and it's up to the implementation to find a suitable directory.
- */
+ /* struct retro_location_callback * --
+ * Gets access to the location interface.
+ * The purpose of this interface is to be able to retrieve
+ * location-based information from the host device,
+ * such as current latitude / longitude.
+ */
+#define RETRO_ENVIRONMENT_GET_CONTENT_DIRECTORY 30 /* Old name, kept for compatibility. */
+#define RETRO_ENVIRONMENT_GET_CORE_ASSETS_DIRECTORY 30
+ /* const char ** --
+ * Returns the "core assets" directory of the frontend.
+ * This directory can be used to store specific assets that the
+ * core relies upon, such as art assets,
+ * input data, etc etc.
+ * The returned value can be NULL.
+ * If so, no such directory is defined,
+ * and it's up to the implementation to find a suitable directory.
+ */
#define RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY 31
-/* const char ** --
- * Returns the "save" directory of the frontend.
- * This directory can be used to store SRAM, memory cards,
- * high scores, etc, if the libretro core
- * cannot use the regular memory interface (retro_get_memory_data()).
- *
- * NOTE: libretro cores used to check GET_SYSTEM_DIRECTORY for
- * similar things before.
- * They should still check GET_SYSTEM_DIRECTORY if they want to
- * be backwards compatible.
- * The path here can be NULL. It should only be non-NULL if the
- * frontend user has set a specific save path.
- */
+ /* const char ** --
+ * Returns the "save" directory of the frontend.
+ * This directory can be used to store SRAM, memory cards,
+ * high scores, etc, if the libretro core
+ * cannot use the regular memory interface (retro_get_memory_data()).
+ *
+ * NOTE: libretro cores used to check GET_SYSTEM_DIRECTORY for
+ * similar things before.
+ * They should still check GET_SYSTEM_DIRECTORY if they want to
+ * be backwards compatible.
+ * The path here can be NULL. It should only be non-NULL if the
+ * frontend user has set a specific save path.
+ */
#define RETRO_ENVIRONMENT_SET_SYSTEM_AV_INFO 32
-/* const struct retro_system_av_info * --
- * Sets a new av_info structure. This can only be called from
- * within retro_run().
- * This should *only* be used if the core is completely altering the
- * internal resolutions, aspect ratios, timings, sampling rate, etc.
- * Calling this can require a full reinitialization of video/audio
- * drivers in the frontend,
- *
- * so it is important to call it very sparingly, and usually only with
- * the users explicit consent.
- * An eventual driver reinitialize will happen so that video and
- * audio callbacks
- * happening after this call within the same retro_run() call will
- * target the newly initialized driver.
- *
- * This callback makes it possible to support configurable resolutions
- * in games, which can be useful to
- * avoid setting the "worst case" in max_width/max_height.
- *
- * ***HIGHLY RECOMMENDED*** Do not call this callback every time
- * resolution changes in an emulator core if it's
- * expected to be a temporary change, for the reasons of possible
- * driver reinitialization.
- * This call is not a free pass for not trying to provide
- * correct values in retro_get_system_av_info(). If you need to change
- * things like aspect ratio or nominal width/height,
- * use RETRO_ENVIRONMENT_SET_GEOMETRY, which is a softer variant
- * of SET_SYSTEM_AV_INFO.
- *
- * If this returns false, the frontend does not acknowledge a
- * changed av_info struct.
- */
+ /* const struct retro_system_av_info * --
+ * Sets a new av_info structure. This can only be called from
+ * within retro_run().
+ * This should *only* be used if the core is completely altering the
+ * internal resolutions, aspect ratios, timings, sampling rate, etc.
+ * Calling this can require a full reinitialization of video/audio
+ * drivers in the frontend,
+ *
+ * so it is important to call it very sparingly, and usually only with
+ * the users explicit consent.
+ * An eventual driver reinitialize will happen so that video and
+ * audio callbacks
+ * happening after this call within the same retro_run() call will
+ * target the newly initialized driver.
+ *
+ * This callback makes it possible to support configurable resolutions
+ * in games, which can be useful to
+ * avoid setting the "worst case" in max_width/max_height.
+ *
+ * ***HIGHLY RECOMMENDED*** Do not call this callback every time
+ * resolution changes in an emulator core if it's
+ * expected to be a temporary change, for the reasons of possible
+ * driver reinitialization.
+ * This call is not a free pass for not trying to provide
+ * correct values in retro_get_system_av_info(). If you need to change
+ * things like aspect ratio or nominal width/height,
+ * use RETRO_ENVIRONMENT_SET_GEOMETRY, which is a softer variant
+ * of SET_SYSTEM_AV_INFO.
+ *
+ * If this returns false, the frontend does not acknowledge a
+ * changed av_info struct.
+ */
#define RETRO_ENVIRONMENT_SET_PROC_ADDRESS_CALLBACK 33
-/* const struct retro_get_proc_address_interface * --
- * Allows a libretro core to announce support for the
- * get_proc_address() interface.
- * This interface allows for a standard way to extend libretro where
- * use of environment calls are too indirect,
- * e.g. for cases where the frontend wants to call directly into the core.
- *
- * If a core wants to expose this interface, SET_PROC_ADDRESS_CALLBACK
- * **MUST** be called from within retro_set_environment().
- */
+ /* const struct retro_get_proc_address_interface * --
+ * Allows a libretro core to announce support for the
+ * get_proc_address() interface.
+ * This interface allows for a standard way to extend libretro where
+ * use of environment calls are too indirect,
+ * e.g. for cases where the frontend wants to call directly into the core.
+ *
+ * If a core wants to expose this interface, SET_PROC_ADDRESS_CALLBACK
+ * **MUST** be called from within retro_set_environment().
+ */
#define RETRO_ENVIRONMENT_SET_SUBSYSTEM_INFO 34
-/* const struct retro_subsystem_info * --
- * This environment call introduces the concept of libretro "subsystems".
- * A subsystem is a variant of a libretro core which supports
- * different kinds of games.
- * The purpose of this is to support e.g. emulators which might
- * have special needs, e.g. Super Nintendo's Super GameBoy, Sufami Turbo.
- * It can also be used to pick among subsystems in an explicit way
- * if the libretro implementation is a multi-system emulator itself.
- *
- * Loading a game via a subsystem is done with retro_load_game_special(),
- * and this environment call allows a libretro core to expose which
- * subsystems are supported for use with retro_load_game_special().
- * A core passes an array of retro_game_special_info which is terminated
- * with a zeroed out retro_game_special_info struct.
- *
- * If a core wants to use this functionality, SET_SUBSYSTEM_INFO
- * **MUST** be called from within retro_set_environment().
- */
+ /* const struct retro_subsystem_info * --
+ * This environment call introduces the concept of libretro "subsystems".
+ * A subsystem is a variant of a libretro core which supports
+ * different kinds of games.
+ * The purpose of this is to support e.g. emulators which might
+ * have special needs, e.g. Super Nintendo's Super GameBoy, Sufami Turbo.
+ * It can also be used to pick among subsystems in an explicit way
+ * if the libretro implementation is a multi-system emulator itself.
+ *
+ * Loading a game via a subsystem is done with retro_load_game_special(),
+ * and this environment call allows a libretro core to expose which
+ * subsystems are supported for use with retro_load_game_special().
+ * A core passes an array of retro_game_special_info which is terminated
+ * with a zeroed out retro_game_special_info struct.
+ *
+ * If a core wants to use this functionality, SET_SUBSYSTEM_INFO
+ * **MUST** be called from within retro_set_environment().
+ */
#define RETRO_ENVIRONMENT_SET_CONTROLLER_INFO 35
-/* const struct retro_controller_info * --
- * This environment call lets a libretro core tell the frontend
- * which controller types are recognized in calls to
- * retro_set_controller_port_device().
- *
- * Some emulators such as Super Nintendo
- * support multiple lightgun types which must be specifically
- * selected from.
- * It is therefore sometimes necessary for a frontend to be able
- * to tell the core about a special kind of input device which is
- * not covered by the libretro input API.
- *
- * In order for a frontend to understand the workings of an input device,
- * it must be a specialized type
- * of the generic device types already defined in the libretro API.
- *
- * Which devices are supported can vary per input port.
- * The core must pass an array of const struct retro_controller_info which
- * is terminated with a blanked out struct. Each element of the struct
- * corresponds to an ascending port index to
- * retro_set_controller_port_device().
- * Even if special device types are set in the libretro core,
- * libretro should only poll input based on the base input device types.
- */
+ /* const struct retro_controller_info * --
+ * This environment call lets a libretro core tell the frontend
+ * which controller types are recognized in calls to
+ * retro_set_controller_port_device().
+ *
+ * Some emulators such as Super Nintendo
+ * support multiple lightgun types which must be specifically
+ * selected from.
+ * It is therefore sometimes necessary for a frontend to be able
+ * to tell the core about a special kind of input device which is
+ * not covered by the libretro input API.
+ *
+ * In order for a frontend to understand the workings of an input device,
+ * it must be a specialized type
+ * of the generic device types already defined in the libretro API.
+ *
+ * Which devices are supported can vary per input port.
+ * The core must pass an array of const struct retro_controller_info which
+ * is terminated with a blanked out struct. Each element of the struct
+ * corresponds to an ascending port index to
+ * retro_set_controller_port_device().
+ * Even if special device types are set in the libretro core,
+ * libretro should only poll input based on the base input device types.
+ */
#define RETRO_ENVIRONMENT_SET_MEMORY_MAPS (36 | RETRO_ENVIRONMENT_EXPERIMENTAL)
-/* const struct retro_memory_map * --
- * This environment call lets a libretro core tell the frontend
- * about the memory maps this core emulates.
- * This can be used to implement, for example, cheats in a core-agnostic way.
- *
- * Should only be used by emulators; it doesn't make much sense for
- * anything else.
- * It is recommended to expose all relevant pointers through
- * retro_get_memory_* as well.
- *
- * Can be called from retro_init and retro_load_game.
- */
+ /* const struct retro_memory_map * --
+ * This environment call lets a libretro core tell the frontend
+ * about the memory maps this core emulates.
+ * This can be used to implement, for example, cheats in a core-agnostic way.
+ *
+ * Should only be used by emulators; it doesn't make much sense for
+ * anything else.
+ * It is recommended to expose all relevant pointers through
+ * retro_get_memory_* as well.
+ *
+ * Can be called from retro_init and retro_load_game.
+ */
#define RETRO_ENVIRONMENT_SET_GEOMETRY 37
-/* const struct retro_game_geometry * --
- * This environment call is similar to SET_SYSTEM_AV_INFO for changing
- * video parameters, but provides a guarantee that drivers will not be
- * reinitialized.
- * This can only be called from within retro_run().
- *
- * The purpose of this call is to allow a core to alter nominal
- * width/heights as well as aspect ratios on-the-fly, which can be
- * useful for some emulators to change in run-time.
- *
- * max_width/max_height arguments are ignored and cannot be changed
- * with this call as this could potentially require a reinitialization or a
- * non-constant time operation.
- * If max_width/max_height are to be changed, SET_SYSTEM_AV_INFO is required.
- *
- * A frontend must guarantee that this environment call completes in
- * constant time.
- */
-#define RETRO_ENVIRONMENT_GET_USERNAME 38
-/* const char **
- * Returns the specified username of the frontend, if specified by the user.
- * This username can be used as a nickname for a core that has online facilities
- * or any other mode where personalization of the user is desirable.
- * The returned value can be NULL.
- * If this environ callback is used by a core that requires a valid username,
- * a default username should be specified by the core.
- */
+ /* const struct retro_game_geometry * --
+ * This environment call is similar to SET_SYSTEM_AV_INFO for changing
+ * video parameters, but provides a guarantee that drivers will not be
+ * reinitialized.
+ * This can only be called from within retro_run().
+ *
+ * The purpose of this call is to allow a core to alter nominal
+ * width/heights as well as aspect ratios on-the-fly, which can be
+ * useful for some emulators to change in run-time.
+ *
+ * max_width/max_height arguments are ignored and cannot be changed
+ * with this call as this could potentially require a reinitialization or a
+ * non-constant time operation.
+ * If max_width/max_height are to be changed, SET_SYSTEM_AV_INFO is required.
+ *
+ * A frontend must guarantee that this environment call completes in
+ * constant time.
+ */
+#define RETRO_ENVIRONMENT_GET_USERNAME 38
+ /* const char **
+ * Returns the specified username of the frontend, if specified by the user.
+ * This username can be used as a nickname for a core that has online facilities
+ * or any other mode where personalization of the user is desirable.
+ * The returned value can be NULL.
+ * If this environ callback is used by a core that requires a valid username,
+ * a default username should be specified by the core.
+ */
#define RETRO_ENVIRONMENT_GET_LANGUAGE 39
-/* unsigned * --
- * Returns the specified language of the frontend, if specified by the user.
- * It can be used by the core for localization purposes.
- */
+ /* unsigned * --
+ * Returns the specified language of the frontend, if specified by the user.
+ * It can be used by the core for localization purposes.
+ */
+#define RETRO_ENVIRONMENT_GET_CURRENT_SOFTWARE_FRAMEBUFFER (40 | RETRO_ENVIRONMENT_EXPERIMENTAL)
+ /* struct retro_framebuffer * --
+ * Returns a preallocated framebuffer which the core can use for rendering
+ * the frame into when not using SET_HW_RENDER.
+ * The framebuffer returned from this call must not be used
+ * after the current call to retro_run() returns.
+ *
+ * The goal of this call is to allow zero-copy behavior where a core
+ * can render directly into video memory, avoiding extra bandwidth cost by copying
+ * memory from core to video memory.
+ *
+ * If this call succeeds and the core renders into it,
+ * the framebuffer pointer and pitch can be passed to retro_video_refresh_t.
+ * If the buffer from GET_CURRENT_SOFTWARE_FRAMEBUFFER is to be used,
+ * the core must pass the exact
+ * same pointer as returned by GET_CURRENT_SOFTWARE_FRAMEBUFFER;
+ * i.e. passing a pointer which is offset from the
+ * buffer is undefined. The width, height and pitch parameters
+ * must also match exactly to the values obtained from GET_CURRENT_SOFTWARE_FRAMEBUFFER.
+ *
+ * It is possible for a frontend to return a different pixel format
+ * than the one used in SET_PIXEL_FORMAT. This can happen if the frontend
+ * needs to perform conversion.
+ *
+ * It is still valid for a core to render to a different buffer
+ * even if GET_CURRENT_SOFTWARE_FRAMEBUFFER succeeds.
+ *
+ * A frontend must make sure that the pointer obtained from this function is
+ * writeable (and readable).
+ */
+
+enum retro_hw_render_interface_type
+{
+ RETRO_HW_RENDER_INTERFACE_VULKAN = 0,
+ RETRO_HW_RENDER_INTERFACE_DUMMY = INT_MAX
+};
+
+/* Base struct. All retro_hw_render_interface_* types
+ * contain at least these fields. */
+struct retro_hw_render_interface
+{
+ enum retro_hw_render_interface_type interface_type;
+ unsigned interface_version;
+};
+#define RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE (41 | RETRO_ENVIRONMENT_EXPERIMENTAL)
+ /* const struct retro_hw_render_interface ** --
+ * Returns an API specific rendering interface for accessing API specific data.
+ * Not all HW rendering APIs support or need this.
+ * The contents of the returned pointer is specific to the rendering API
+ * being used. See the various headers like libretro_vulkan.h, etc.
+ *
+ * GET_HW_RENDER_INTERFACE cannot be called before context_reset has been called.
+ * Similarly, after context_destroyed callback returns,
+ * the contents of the HW_RENDER_INTERFACE are invalidated.
+ */
+
+#define RETRO_ENVIRONMENT_SET_SUPPORT_ACHIEVEMENTS (42 | RETRO_ENVIRONMENT_EXPERIMENTAL)
+ /* const bool * --
+ * If true, the libretro implementation supports achievements
+ * either via memory descriptors set with RETRO_ENVIRONMENT_SET_MEMORY_MAPS
+ * or via retro_get_memory_data/retro_get_memory_size.
+ *
+ * This must be called before the first call to retro_run.
+ */
+
+enum retro_hw_render_context_negotiation_interface_type
+{
+ RETRO_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE_VULKAN = 0,
+ RETRO_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE_DUMMY = INT_MAX
+};
+
+/* Base struct. All retro_hw_render_context_negotiation_interface_* types
+ * contain at least these fields. */
+struct retro_hw_render_context_negotiation_interface
+{
+ enum retro_hw_render_context_negotiation_interface_type interface_type;
+ unsigned interface_version;
+};
+#define RETRO_ENVIRONMENT_SET_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE (43 | RETRO_ENVIRONMENT_EXPERIMENTAL)
+ /* const struct retro_hw_render_context_negotiation_interface * --
+ * Sets an interface which lets the libretro core negotiate with frontend how a context is created.
+ * The semantics of this interface depends on which API is used in SET_HW_RENDER earlier.
+ * This interface will be used when the frontend is trying to create a HW rendering context,
+ * so it will be used after SET_HW_RENDER, but before the context_reset callback.
+ */
#define RETRO_MEMDESC_CONST (1 << 0) /* The frontend will never change this memory area once retro_load_game has returned. */
#define RETRO_MEMDESC_BIGENDIAN (1 << 1) /* The memory area contains big endian data. Default is little endian. */
@@ -845,56 +969,56 @@ struct retro_memory_descriptor
uint64_t flags;
/* Pointer to the start of the relevant ROM or RAM chip.
- * It's strongly recommended to use 'offset' if possible, rather than
+ * It's strongly recommended to use 'offset' if possible, rather than
* doing math on the pointer.
*
- * If the same byte is mapped my multiple descriptors, their descriptors
+ * If the same byte is mapped my multiple descriptors, their descriptors
* must have the same pointer.
- * If 'start' does not point to the first byte in the pointer, put the
+ * If 'start' does not point to the first byte in the pointer, put the
* difference in 'offset' instead.
*
- * May be NULL if there's nothing usable here (e.g. hardware registers and
+ * May be NULL if there's nothing usable here (e.g. hardware registers and
* open bus). No flags should be set if the pointer is NULL.
* It's recommended to minimize the number of descriptors if possible,
* but not mandatory. */
- void* ptr;
+ void *ptr;
size_t offset;
- /* This is the location in the emulated address space
+ /* This is the location in the emulated address space
* where the mapping starts. */
size_t start;
/* Which bits must be same as in 'start' for this mapping to apply.
- * The first memory descriptor to claim a certain byte is the one
+ * The first memory descriptor to claim a certain byte is the one
* that applies.
* A bit which is set in 'start' must also be set in this.
- * Can be zero, in which case each byte is assumed mapped exactly once.
+ * Can be zero, in which case each byte is assumed mapped exactly once.
* In this case, 'len' must be a power of two. */
size_t select;
- /* If this is nonzero, the set bits are assumed not connected to the
+ /* If this is nonzero, the set bits are assumed not connected to the
* memory chip's address pins. */
size_t disconnect;
/* This one tells the size of the current memory area.
- * If, after start+disconnect are applied, the address is higher than
+ * If, after start+disconnect are applied, the address is higher than
* this, the highest bit of the address is cleared.
*
* If the address is still too high, the next highest bit is cleared.
- * Can be zero, in which case it's assumed to be infinite (as limited
+ * Can be zero, in which case it's assumed to be infinite (as limited
* by 'select' and 'disconnect'). */
size_t len;
- /* To go from emulated address to physical address, the following
+ /* To go from emulated address to physical address, the following
* order applies:
- * Subtract 'start', pick off 'disconnect', apply 'len', add 'offset'.
- *
- * The address space name must consist of only a-zA-Z0-9_-,
+ * Subtract 'start', pick off 'disconnect', apply 'len', add 'offset'. */
+
+ /* The address space name must consist of only a-zA-Z0-9_-,
* should be as short as feasible (maximum length is 8 plus the NUL),
- * and may not be any other address space plus one or more 0-9A-F
+ * and may not be any other address space plus one or more 0-9A-F
* at the end.
- * However, multiple memory descriptors for the same address space is
- * allowed, and the address space name can be empty. NULL is treated
+ * However, multiple memory descriptors for the same address space is
+ * allowed, and the address space name can be empty. NULL is treated
* as empty.
*
* Address space names are case sensitive, but avoid lowercase if possible.
@@ -908,27 +1032,58 @@ struct retro_memory_descriptor
* 'a'+blank - valid ('a' is not in 0-9A-F)
* 'a'+'A' - valid (neither is a prefix of each other)
* 'AR'+blank - valid ('R' is not in 0-9A-F)
- * 'ARB'+blank - valid (the B can't be part of the address either, because
- * there is no namespace 'AR')
- * blank+'B' - not valid, because it's ambigous which address space B1234
- * would refer to.
- * The length can't be used for that purpose; the frontend may want
+ * 'ARB'+blank - valid (the B can't be part of the address either, because
+ * there is no namespace 'AR')
+ * blank+'B' - not valid, because it's ambigous which address space B1234
+ * would refer to.
+ * The length can't be used for that purpose; the frontend may want
* to append arbitrary data to an address, without a separator. */
- const char* addrspace;
+ const char *addrspace;
+
+ /* TODO: When finalizing this one, add a description field, which should be
+ * "WRAM" or something roughly equally long. */
+
+ /* TODO: When finalizing this one, replace 'select' with 'limit', which tells
+ * which bits can vary and still refer to the same address (limit = ~select).
+ * TODO: limit? range? vary? something else? */
+
+ /* TODO: When finalizing this one, if 'len' is above what 'select' (or
+ * 'limit') allows, it's bankswitched. Bankswitched data must have both 'len'
+ * and 'select' != 0, and the mappings don't tell how the system switches the
+ * banks. */
+
+ /* TODO: When finalizing this one, fix the 'len' bit removal order.
+ * For len=0x1800, pointer 0x1C00 should go to 0x1400, not 0x0C00.
+ * Algorithm: Take bits highest to lowest, but if it goes above len, clear
+ * the most recent addition and continue on the next bit.
+ * TODO: Can the above be optimized? Is "remove the lowest bit set in both
+ * pointer and 'len'" equivalent? */
+
+ /* TODO: Some emulators (MAME?) emulate big endian systems by only accessing
+ * the emulated memory in 32-bit chunks, native endian. But that's nothing
+ * compared to Darek Mihocka <http://www.emulators.com/docs/nx07_vm101.htm>
+ * (section Emulation 103 - Nearly Free Byte Reversal) - he flips the ENTIRE
+ * RAM backwards! I'll want to represent both of those, via some flags.
+ *
+ * I suspect MAME either didn't think of that idea, or don't want the #ifdef.
+ * Not sure which, nor do I really care. */
+
+ /* TODO: Some of those flags are unused and/or don't really make sense. Clean
+ * them up. */
};
-/* The frontend may use the largest value of 'start'+'select' in a
+/* The frontend may use the largest value of 'start'+'select' in a
* certain namespace to infer the size of the address space.
*
- * If the address space is larger than that, a mapping with .ptr=NULL
- * should be at the end of the array, with .select set to all ones for
+ * If the address space is larger than that, a mapping with .ptr=NULL
+ * should be at the end of the array, with .select set to all ones for
* as long as the address space is big.
*
* Sample descriptors (minus .ptr, and RETRO_MEMFLAG_ on the flags):
* SNES WRAM:
* .start=0x7E0000, .len=0x20000
- * (Note that this must be mapped before the ROM in most cases; some of the
- * ROM mappers
+ * (Note that this must be mapped before the ROM in most cases; some of the
+ * ROM mappers
* try to claim $7E0000, or at least $7E8000.)
* SNES SPC700 RAM:
* .addrspace="S", .len=0x10000
@@ -937,7 +1092,7 @@ struct retro_memory_descriptor
* .flags=MIRROR, .start=0x800000, .select=0xC0E000, .len=0x2000
* SNES WRAM mirrors, alternate equivalent descriptor:
* .flags=MIRROR, .select=0x40E000, .disconnect=~0x1FFF
- * (Various similar constructions can be created by combining parts of
+ * (Various similar constructions can be created by combining parts of
* the above two.)
* SNES LoROM (512KB, mirrored a couple of times):
* .flags=CONST, .start=0x008000, .select=0x408000, .disconnect=0x8000, .len=512*1024
@@ -957,19 +1112,19 @@ struct retro_memory_descriptor
struct retro_memory_map
{
- const struct retro_memory_descriptor* descriptors;
+ const struct retro_memory_descriptor *descriptors;
unsigned num_descriptors;
};
struct retro_controller_description
{
- /* Human-readable description of the controller. Even if using a generic
- * input device type, this can be set to the particular device type the
+ /* Human-readable description of the controller. Even if using a generic
+ * input device type, this can be set to the particular device type the
* core uses. */
- const char* desc;
+ const char *desc;
- /* Device type passed to retro_set_controller_port_device(). If the device
- * type is a sub-class of a generic input device type, use the
+ /* Device type passed to retro_set_controller_port_device(). If the device
+ * type is a sub-class of a generic input device type, use the
* RETRO_DEVICE_SUBCLASS macro to create an ID.
*
* E.g. RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 1). */
@@ -978,17 +1133,17 @@ struct retro_controller_description
struct retro_controller_info
{
- const struct retro_controller_description* types;
+ const struct retro_controller_description *types;
unsigned num_types;
};
struct retro_subsystem_memory_info
{
/* The extension associated with a memory type, e.g. "psram". */
- const char* extension;
+ const char *extension;
- /* The memory type for retro_get_memory(). This should be at
- * least 0x100 to avoid conflict with standardized
+ /* The memory type for retro_get_memory(). This should be at
+ * least 0x100 to avoid conflict with standardized
* libretro memory types. */
unsigned type;
};
@@ -996,10 +1151,10 @@ struct retro_subsystem_memory_info
struct retro_subsystem_rom_info
{
/* Describes what the content is (SGB BIOS, GB ROM, etc). */
- const char* desc;
+ const char *desc;
/* Same definition as retro_get_system_info(). */
- const char* valid_extensions;
+ const char *valid_extensions;
/* Same definition as retro_get_system_info(). */
bool need_fullpath;
@@ -1007,60 +1162,60 @@ struct retro_subsystem_rom_info
/* Same definition as retro_get_system_info(). */
bool block_extract;
- /* This is set if the content is required to load a game.
+ /* This is set if the content is required to load a game.
* If this is set to false, a zeroed-out retro_game_info can be passed. */
bool required;
- /* Content can have multiple associated persistent
+ /* Content can have multiple associated persistent
* memory types (retro_get_memory()). */
- const struct retro_subsystem_memory_info* memory;
+ const struct retro_subsystem_memory_info *memory;
unsigned num_memory;
};
struct retro_subsystem_info
{
/* Human-readable string of the subsystem type, e.g. "Super GameBoy" */
- const char* desc;
+ const char *desc;
/* A computer friendly short string identifier for the subsystem type.
* This name must be [a-z].
* E.g. if desc is "Super GameBoy", this can be "sgb".
* This identifier can be used for command-line interfaces, etc.
*/
- const char* ident;
+ const char *ident;
- /* Infos for each content file. The first entry is assumed to be the
+ /* Infos for each content file. The first entry is assumed to be the
* "most significant" content for frontend purposes.
- * E.g. with Super GameBoy, the first content should be the GameBoy ROM,
+ * E.g. with Super GameBoy, the first content should be the GameBoy ROM,
* as it is the most "significant" content to a user.
- * If a frontend creates new file paths based on the content used
+ * If a frontend creates new file paths based on the content used
* (e.g. savestates), it should use the path for the first ROM to do so. */
- const struct retro_subsystem_rom_info* roms;
+ const struct retro_subsystem_rom_info *roms;
/* Number of content files associated with a subsystem. */
unsigned num_roms;
-
+
/* The type passed to retro_load_game_special(). */
unsigned id;
};
-typedef void (*retro_proc_address_t)(void);
+typedef void (RETRO_CALLCONV *retro_proc_address_t)(void);
/* libretro API extension functions:
* (None here so far).
*
* Get a symbol from a libretro core.
- * Cores should only return symbols which are actual
+ * Cores should only return symbols which are actual
* extensions to the libretro API.
*
- * Frontends should not use this to obtain symbols to standard
+ * Frontends should not use this to obtain symbols to standard
* libretro entry points (static linking or dlsym).
*
- * The symbol name must be equal to the function name,
+ * The symbol name must be equal to the function name,
* e.g. if void retro_foo(void); exists, the symbol must be called "retro_foo".
* The returned function pointer must be cast to the corresponding type.
*/
-typedef retro_proc_address_t (*retro_get_proc_address_t)(const char* sym);
+typedef retro_proc_address_t (RETRO_CALLCONV *retro_get_proc_address_t)(const char *sym);
struct retro_get_proc_address_interface
{
@@ -1078,8 +1233,8 @@ enum retro_log_level
};
/* Logging function. Takes log level argument as well. */
-typedef void (*retro_log_printf_t)(enum retro_log_level level,
- const char* fmt, ...);
+typedef void (RETRO_CALLCONV *retro_log_printf_t)(enum retro_log_level level,
+ const char *fmt, ...);
struct retro_log_callback
{
@@ -1105,13 +1260,17 @@ struct retro_log_callback
#define RETRO_SIMD_VFPU (1 << 13)
#define RETRO_SIMD_PS (1 << 14)
#define RETRO_SIMD_AES (1 << 15)
+#define RETRO_SIMD_VFPV3 (1 << 16)
+#define RETRO_SIMD_VFPV4 (1 << 17)
+#define RETRO_SIMD_POPCNT (1 << 18)
+#define RETRO_SIMD_MOVBE (1 << 19)
typedef uint64_t retro_perf_tick_t;
typedef int64_t retro_time_t;
struct retro_perf_counter
{
- const char* ident;
+ const char *ident;
retro_perf_tick_t start;
retro_perf_tick_t total;
retro_perf_tick_t call_cnt;
@@ -1122,34 +1281,34 @@ struct retro_perf_counter
/* Returns current time in microseconds.
* Tries to use the most accurate timer available.
*/
-typedef retro_time_t (*retro_perf_get_time_usec_t)(void);
+typedef retro_time_t (RETRO_CALLCONV *retro_perf_get_time_usec_t)(void);
/* A simple counter. Usually nanoseconds, but can also be CPU cycles.
- * Can be used directly if desired (when creating a more sophisticated
+ * Can be used directly if desired (when creating a more sophisticated
* performance counter system).
* */
-typedef retro_perf_tick_t (*retro_perf_get_counter_t)(void);
+typedef retro_perf_tick_t (RETRO_CALLCONV *retro_perf_get_counter_t)(void);
/* Returns a bit-mask of detected CPU features (RETRO_SIMD_*). */
-typedef uint64_t (*retro_get_cpu_features_t)(void);
+typedef uint64_t (RETRO_CALLCONV *retro_get_cpu_features_t)(void);
/* Asks frontend to log and/or display the state of performance counters.
* Performance counters can always be poked into manually as well.
*/
-typedef void (*retro_perf_log_t)(void);
+typedef void (RETRO_CALLCONV *retro_perf_log_t)(void);
/* Register a performance counter.
- * ident field must be set with a discrete value and other values in
+ * ident field must be set with a discrete value and other values in
* retro_perf_counter must be 0.
- * Registering can be called multiple times. To avoid calling to
+ * Registering can be called multiple times. To avoid calling to
* frontend redundantly, you can check registered field first. */
-typedef void (*retro_perf_register_t)(struct retro_perf_counter* counter);
+typedef void (RETRO_CALLCONV *retro_perf_register_t)(struct retro_perf_counter *counter);
/* Starts a registered counter. */
-typedef void (*retro_perf_start_t)(struct retro_perf_counter* counter);
+typedef void (RETRO_CALLCONV *retro_perf_start_t)(struct retro_perf_counter *counter);
/* Stops a registered counter. */
-typedef void (*retro_perf_stop_t)(struct retro_perf_counter* counter);
+typedef void (RETRO_CALLCONV *retro_perf_stop_t)(struct retro_perf_counter *counter);
/* For convenience it can be useful to wrap register, start and stop in macros.
* E.g.:
@@ -1212,10 +1371,10 @@ enum retro_sensor_action
#define RETRO_SENSOR_ACCELEROMETER_Y 1
#define RETRO_SENSOR_ACCELEROMETER_Z 2
-typedef bool (*retro_set_sensor_state_t)(unsigned port,
+typedef bool (RETRO_CALLCONV *retro_set_sensor_state_t)(unsigned port,
enum retro_sensor_action action, unsigned rate);
-typedef float(*retro_sensor_get_input_t)(unsigned port, unsigned id);
+typedef float (RETRO_CALLCONV *retro_sensor_get_input_t)(unsigned port, unsigned id);
struct retro_sensor_interface
{
@@ -1232,76 +1391,80 @@ enum retro_camera_buffer
};
/* Starts the camera driver. Can only be called in retro_run(). */
-typedef bool (*retro_camera_start_t)(void);
+typedef bool (RETRO_CALLCONV *retro_camera_start_t)(void);
/* Stops the camera driver. Can only be called in retro_run(). */
-typedef void (*retro_camera_stop_t)(void);
+typedef void (RETRO_CALLCONV *retro_camera_stop_t)(void);
-/* Callback which signals when the camera driver is initialized
+/* Callback which signals when the camera driver is initialized
* and/or deinitialized.
* retro_camera_start_t can be called in initialized callback.
*/
-typedef void (*retro_camera_lifetime_status_t)(void);
+typedef void (RETRO_CALLCONV *retro_camera_lifetime_status_t)(void);
/* A callback for raw framebuffer data. buffer points to an XRGB8888 buffer.
* Width, height and pitch are similar to retro_video_refresh_t.
* First pixel is top-left origin.
*/
-typedef void (*retro_camera_frame_raw_framebuffer_t)(const uint32_t* buffer,
+typedef void (RETRO_CALLCONV *retro_camera_frame_raw_framebuffer_t)(const uint32_t *buffer,
unsigned width, unsigned height, size_t pitch);
/* A callback for when OpenGL textures are used.
*
* texture_id is a texture owned by camera driver.
- * Its state or content should be considered immutable, except for things like
+ * Its state or content should be considered immutable, except for things like
* texture filtering and clamping.
*
* texture_target is the texture target for the GL texture.
- * These can include e.g. GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE, and possibly
+ * These can include e.g. GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE, and possibly
* more depending on extensions.
*
- * affine points to a packed 3x3 column-major matrix used to apply an affine
+ * affine points to a packed 3x3 column-major matrix used to apply an affine
* transform to texture coordinates. (affine_matrix * vec3(coord_x, coord_y, 1.0))
- * After transform, normalized texture coord (0, 0) should be bottom-left
+ * After transform, normalized texture coord (0, 0) should be bottom-left
* and (1, 1) should be top-right (or (width, height) for RECTANGLE).
*
- * GL-specific typedefs are avoided here to avoid relying on gl.h in
+ * GL-specific typedefs are avoided here to avoid relying on gl.h in
* the API definition.
*/
-typedef void (*retro_camera_frame_opengl_texture_t)(unsigned texture_id,
- unsigned texture_target, const float* affine);
+typedef void (RETRO_CALLCONV *retro_camera_frame_opengl_texture_t)(unsigned texture_id,
+ unsigned texture_target, const float *affine);
struct retro_camera_callback
{
- /* Set by libretro core.
+ /* Set by libretro core.
* Example bitmask: caps = (1 << RETRO_CAMERA_BUFFER_OPENGL_TEXTURE) | (1 << RETRO_CAMERA_BUFFER_RAW_FRAMEBUFFER).
*/
- uint64_t caps;
+ uint64_t caps;
- unsigned width; /* Desired resolution for camera. Is only used as a hint. */
+ /* Desired resolution for camera. Is only used as a hint. */
+ unsigned width;
unsigned height;
- retro_camera_start_t start; /* Set by frontend. */
- retro_camera_stop_t stop; /* Set by frontend. */
+
+ /* Set by frontend. */
+ retro_camera_start_t start;
+ retro_camera_stop_t stop;
/* Set by libretro core if raw framebuffer callbacks will be used. */
retro_camera_frame_raw_framebuffer_t frame_raw_framebuffer;
+
/* Set by libretro core if OpenGL texture callbacks will be used. */
- retro_camera_frame_opengl_texture_t frame_opengl_texture;
+ retro_camera_frame_opengl_texture_t frame_opengl_texture;
- /* Set by libretro core. Called after camera driver is initialized and
+ /* Set by libretro core. Called after camera driver is initialized and
* ready to be started.
* Can be NULL, in which this callback is not called.
*/
retro_camera_lifetime_status_t initialized;
- /* Set by libretro core. Called right before camera driver is
+ /* Set by libretro core. Called right before camera driver is
* deinitialized.
* Can be NULL, in which this callback is not called.
*/
retro_camera_lifetime_status_t deinitialized;
};
-/* Sets the interval of time and/or distance at which to update/poll
+/* Sets the interval of time and/or distance at which to update/poll
* location-based data.
*
* To ensure compatibility with all location-based implementations,
@@ -1310,28 +1473,28 @@ struct retro_camera_callback
* interval_ms is the interval expressed in milliseconds.
* interval_distance is the distance interval expressed in meters.
*/
-typedef void (*retro_location_set_interval_t)(unsigned interval_ms,
+typedef void (RETRO_CALLCONV *retro_location_set_interval_t)(unsigned interval_ms,
unsigned interval_distance);
/* Start location services. The device will start listening for changes to the
- * current location at regular intervals (which are defined with
+ * current location at regular intervals (which are defined with
* retro_location_set_interval_t). */
-typedef bool (*retro_location_start_t)(void);
+typedef bool (RETRO_CALLCONV *retro_location_start_t)(void);
-/* Stop location services. The device will stop listening for changes
+/* Stop location services. The device will stop listening for changes
* to the current location. */
-typedef void (*retro_location_stop_t)(void);
+typedef void (RETRO_CALLCONV *retro_location_stop_t)(void);
-/* Get the position of the current location. Will set parameters to
+/* Get the position of the current location. Will set parameters to
* 0 if no new location update has happened since the last time. */
-typedef bool (*retro_location_get_position_t)(double* lat, double* lon,
- double* horiz_accuracy, double* vert_accuracy);
+typedef bool (RETRO_CALLCONV *retro_location_get_position_t)(double *lat, double *lon,
+ double *horiz_accuracy, double *vert_accuracy);
-/* Callback which signals when the location driver is initialized
+/* Callback which signals when the location driver is initialized
* and/or deinitialized.
* retro_location_start_t can be called in initialized callback.
*/
-typedef void (*retro_location_lifetime_status_t)(void);
+typedef void (RETRO_CALLCONV *retro_location_lifetime_status_t)(void);
struct retro_location_callback
{
@@ -1352,14 +1515,14 @@ enum retro_rumble_effect
RETRO_RUMBLE_DUMMY = INT_MAX
};
-/* Sets rumble state for joypad plugged in port 'port'.
+/* Sets rumble state for joypad plugged in port 'port'.
* Rumble effects are controlled independently,
* and setting e.g. strong rumble does not override weak rumble.
* Strength has a range of [0, 0xffff].
*
- * Returns true if rumble state request was honored.
+ * Returns true if rumble state request was honored.
* Calling this before first retro_run() is likely to return false. */
-typedef bool (*retro_set_rumble_state_t)(unsigned port,
+typedef bool (RETRO_CALLCONV *retro_set_rumble_state_t)(unsigned port,
enum retro_rumble_effect effect, uint16_t strength);
struct retro_rumble_interface
@@ -1368,16 +1531,16 @@ struct retro_rumble_interface
};
/* Notifies libretro that audio data should be written. */
-typedef void (*retro_audio_callback_t)(void);
+typedef void (RETRO_CALLCONV *retro_audio_callback_t)(void);
-/* True: Audio driver in frontend is active, and callback is
+/* True: Audio driver in frontend is active, and callback is
* expected to be called regularily.
- * False: Audio driver in frontend is paused or inactive.
- * Audio callback will not be called until set_state has been
+ * False: Audio driver in frontend is paused or inactive.
+ * Audio callback will not be called until set_state has been
* called with true.
* Initial state is false (inactive).
*/
-typedef void (*retro_audio_set_state_callback_t)(bool enabled);
+typedef void (RETRO_CALLCONV *retro_audio_set_state_callback_t)(bool enabled);
struct retro_audio_callback
{
@@ -1385,21 +1548,21 @@ struct retro_audio_callback
retro_audio_set_state_callback_t set_state;
};
-/* Notifies a libretro core of time spent since last invocation
+/* Notifies a libretro core of time spent since last invocation
* of retro_run() in microseconds.
*
* It will be called right before retro_run() every frame.
- * The frontend can tamper with timing to support cases like
+ * The frontend can tamper with timing to support cases like
* fast-forward, slow-motion and framestepping.
*
* In those scenarios the reference frame time value will be used. */
typedef int64_t retro_usec_t;
-typedef void (*retro_frame_time_callback_t)(retro_usec_t usec);
+typedef void (RETRO_CALLCONV *retro_frame_time_callback_t)(retro_usec_t usec);
struct retro_frame_time_callback
{
retro_frame_time_callback_t callback;
- /* Represents the time of one frame. It is computed as
- * 1000000 / fps, but the implementation will resolve the
+ /* Represents the time of one frame. It is computed as
+ * 1000000 / fps, but the implementation will resolve the
* rounding to ensure that framestepping, etc is exact. */
retro_usec_t reference;
};
@@ -1415,24 +1578,24 @@ struct retro_frame_time_callback
* it should implement context_destroy callback.
* If called, all GPU resources must be reinitialized.
* Usually called when frontend reinits video driver.
- * Also called first time video driver is initialized,
+ * Also called first time video driver is initialized,
* allowing libretro core to initialize resources.
*/
-typedef void (*retro_hw_context_reset_t)(void);
+typedef void (RETRO_CALLCONV *retro_hw_context_reset_t)(void);
/* Gets current framebuffer which is to be rendered to.
* Could change every frame potentially.
*/
-typedef uintptr_t (*retro_hw_get_current_framebuffer_t)(void);
+typedef uintptr_t (RETRO_CALLCONV *retro_hw_get_current_framebuffer_t)(void);
/* Get a symbol from HW context. */
-typedef retro_proc_address_t (*retro_hw_get_proc_address_t)(const char* sym);
+typedef retro_proc_address_t (RETRO_CALLCONV *retro_hw_get_proc_address_t)(const char *sym);
enum retro_hw_context_type
{
RETRO_HW_CONTEXT_NONE = 0,
/* OpenGL 2.x. Driver can choose to use latest compatibility context. */
- RETRO_HW_CONTEXT_OPENGL = 1,
+ RETRO_HW_CONTEXT_OPENGL = 1,
/* OpenGL ES 2.0. */
RETRO_HW_CONTEXT_OPENGLES2 = 2,
/* Modern desktop core GL context. Use version_major/
@@ -1444,6 +1607,9 @@ enum retro_hw_context_type
* use the corresponding enums directly. */
RETRO_HW_CONTEXT_OPENGLES_VERSION = 5,
+ /* Vulkan, see RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE. */
+ RETRO_HW_CONTEXT_VULKAN = 6,
+
RETRO_HW_CONTEXT_DUMMY = INT_MAX
};
@@ -1455,10 +1621,10 @@ struct retro_hw_render_callback
/* Called when a context has been created or when it has been reset.
* An OpenGL context is only valid after context_reset() has been called.
*
- * When context_reset is called, OpenGL resources in the libretro
+ * When context_reset is called, OpenGL resources in the libretro
* implementation are guaranteed to be invalid.
*
- * It is possible that context_reset is called multiple times during an
+ * It is possible that context_reset is called multiple times during an
* application lifecycle.
* If context_reset is called without any notification (context_destroy),
* the OpenGL context was lost and resources should just be recreated
@@ -1466,58 +1632,64 @@ struct retro_hw_render_callback
*/
retro_hw_context_reset_t context_reset;
- /* Set by frontend. */
+ /* Set by frontend.
+ * TODO: This is rather obsolete. The frontend should not
+ * be providing preallocated framebuffers. */
retro_hw_get_current_framebuffer_t get_current_framebuffer;
/* Set by frontend. */
retro_hw_get_proc_address_t get_proc_address;
- /* Set if render buffers should have depth component attached. */
+ /* Set if render buffers should have depth component attached.
+ * TODO: Obsolete. */
bool depth;
- /* Set if stencil buffers should be attached. */
+ /* Set if stencil buffers should be attached.
+ * TODO: Obsolete. */
bool stencil;
- /* If depth and stencil are true, a packed 24/8 buffer will be added.
+ /* If depth and stencil are true, a packed 24/8 buffer will be added.
* Only attaching stencil is invalid and will be ignored. */
- /* Use conventional bottom-left origin convention. If false,
- * standard libretro top-left origin semantics are used. */
+ /* Use conventional bottom-left origin convention. If false,
+ * standard libretro top-left origin semantics are used.
+ * TODO: Move to GL specific interface. */
bool bottom_left_origin;
-
+
/* Major version number for core GL context or GLES 3.1+. */
unsigned version_major;
/* Minor version number for core GL context or GLES 3.1+. */
unsigned version_minor;
- /* If this is true, the frontend will go very far to avoid
+ /* If this is true, the frontend will go very far to avoid
* resetting context in scenarios like toggling fullscreen, etc.
+ * TODO: Obsolete? Maybe frontend should just always assume this ...
*/
bool cache_context;
- /* The reset callback might still be called in extreme situations
+ /* The reset callback might still be called in extreme situations
* such as if the context is lost beyond recovery.
*
- * For optimal stability, set this to false, and allow context to be
+ * For optimal stability, set this to false, and allow context to be
* reset at any time.
*/
-
- /* A callback to be called before the context is destroyed in a
+
+ /* A callback to be called before the context is destroyed in a
* controlled way by the frontend. */
retro_hw_context_reset_t context_destroy;
/* OpenGL resources can be deinitialized cleanly at this step.
- * context_destroy can be set to NULL, in which resources will
+ * context_destroy can be set to NULL, in which resources will
* just be destroyed without any notification.
*
- * Even when context_destroy is non-NULL, it is possible that
+ * Even when context_destroy is non-NULL, it is possible that
* context_reset is called without any destroy notification.
- * This happens if context is lost by external factors (such as
+ * This happens if context is lost by external factors (such as
* notified by GL_ARB_robustness).
*
* In this case, the context is assumed to be already dead,
- * and the libretro implementation must not try to free any OpenGL
+ * and the libretro implementation must not try to free any OpenGL
* resources in the subsequent context_reset.
*/
@@ -1525,7 +1697,7 @@ struct retro_hw_render_callback
bool debug_context;
};
-/* Callback type passed in RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK.
+/* Callback type passed in RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK.
* Called by the frontend in response to keyboard events.
* down is set if the key is being pressed, or false if it is being released.
* keycode is the RETROK value of the char.
@@ -1533,17 +1705,17 @@ struct retro_hw_render_callback
* key_modifiers is a set of RETROKMOD values or'ed together.
*
* The pressed/keycode state can be indepedent of the character.
- * It is also possible that multiple characters are generated from a
+ * It is also possible that multiple characters are generated from a
* single keypress.
* Keycode events should be treated separately from character events.
* However, when possible, the frontend should try to synchronize these.
* If only a character is posted, keycode should be RETROK_UNKNOWN.
*
- * Similarily if only a keycode event is generated with no corresponding
+ * Similarily if only a keycode event is generated with no corresponding
* character, character should be 0.
*/
-typedef void (*retro_keyboard_event_t)(bool down, unsigned keycode,
- uint32_t character, uint16_t key_modifiers);
+typedef void (RETRO_CALLCONV *retro_keyboard_event_t)(bool down, unsigned keycode,
+ uint32_t character, uint16_t key_modifiers);
struct retro_keyboard_callback
{
@@ -1551,39 +1723,39 @@ struct retro_keyboard_callback
};
/* Callbacks for RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE.
- * Should be set for implementations which can swap out multiple disk
+ * Should be set for implementations which can swap out multiple disk
* images in runtime.
*
* If the implementation can do this automatically, it should strive to do so.
* However, there are cases where the user must manually do so.
*
- * Overview: To swap a disk image, eject the disk image with
+ * Overview: To swap a disk image, eject the disk image with
* set_eject_state(true).
- * Set the disk index with set_image_index(index). Insert the disk again
+ * Set the disk index with set_image_index(index). Insert the disk again
* with set_eject_state(false).
*/
/* If ejected is true, "ejects" the virtual disk tray.
* When ejected, the disk image index can be set.
*/
-typedef bool (*retro_set_eject_state_t)(bool ejected);
+typedef bool (RETRO_CALLCONV *retro_set_eject_state_t)(bool ejected);
/* Gets current eject state. The initial state is 'not ejected'. */
-typedef bool (*retro_get_eject_state_t)(void);
+typedef bool (RETRO_CALLCONV *retro_get_eject_state_t)(void);
/* Gets current disk index. First disk is index 0.
* If return value is >= get_num_images(), no disk is currently inserted.
*/
-typedef unsigned(*retro_get_image_index_t)(void);
+typedef unsigned (RETRO_CALLCONV *retro_get_image_index_t)(void);
/* Sets image index. Can only be called when disk is ejected.
- * The implementation supports setting "no disk" by using an
+ * The implementation supports setting "no disk" by using an
* index >= get_num_images().
*/
-typedef bool (*retro_set_image_index_t)(unsigned index);
+typedef bool (RETRO_CALLCONV *retro_set_image_index_t)(unsigned index);
/* Gets total number of images which are available to use. */
-typedef unsigned(*retro_get_num_images_t)(void);
+typedef unsigned (RETRO_CALLCONV *retro_get_num_images_t)(void);
struct retro_game_info;
@@ -1591,22 +1763,22 @@ struct retro_game_info;
* Arguments to pass in info have same requirements as retro_load_game().
* Virtual disk tray must be ejected when calling this.
*
- * Replacing a disk image with info = NULL will remove the disk image
+ * Replacing a disk image with info = NULL will remove the disk image
* from the internal list.
* As a result, calls to get_image_index() can change.
*
- * E.g. replace_image_index(1, NULL), and previous get_image_index()
+ * E.g. replace_image_index(1, NULL), and previous get_image_index()
* returned 4 before.
* Index 1 will be removed, and the new index is 3.
*/
-typedef bool (*retro_replace_image_index_t)(unsigned index,
- const struct retro_game_info* info);
+typedef bool (RETRO_CALLCONV *retro_replace_image_index_t)(unsigned index,
+ const struct retro_game_info *info);
/* Adds a new valid index (get_num_images()) to the internal disk list.
* This will increment subsequent return values from get_num_images() by 1.
- * This image index cannot be used until a disk image has been set
+ * This image index cannot be used until a disk image has been set
* with replace_image_index. */
-typedef bool (*retro_add_image_index_t)(void);
+typedef bool (RETRO_CALLCONV *retro_add_image_index_t)(void);
struct retro_disk_control_callback
{
@@ -1635,7 +1807,7 @@ enum retro_pixel_format
/* RGB565, native endian.
* This pixel format is the recommended format to use if a 15/16-bit
- * format is desired as it is the pixel format that is typically
+ * format is desired as it is the pixel format that is typically
* available on a wide range of low-power devices.
*
* It is also natively supported in APIs like OpenGL ES. */
@@ -1647,7 +1819,7 @@ enum retro_pixel_format
struct retro_message
{
- const char* msg; /* Message to be displayed. */
+ const char *msg; /* Message to be displayed. */
unsigned frames; /* Duration in frames of message. */
};
@@ -1665,43 +1837,43 @@ struct retro_input_descriptor
/* Human readable description for parameters.
* The pointer must remain valid until
* retro_unload_game() is called. */
- const char* description;
+ const char *description;
};
struct retro_system_info
{
- /* All pointers are owned by libretro implementation, and pointers must
+ /* All pointers are owned by libretro implementation, and pointers must
* remain valid until retro_deinit() is called. */
- const char* library_name; /* Descriptive name of library. Should not
+ const char *library_name; /* Descriptive name of library. Should not
* contain any version numbers, etc. */
- const char* library_version; /* Descriptive version of core. */
+ const char *library_version; /* Descriptive version of core. */
- const char* valid_extensions; /* A string listing probably content
- * extensions the core will be able to
+ const char *valid_extensions; /* A string listing probably content
+ * extensions the core will be able to
* load, separated with pipe.
* I.e. "bin|rom|iso".
- * Typically used for a GUI to filter
+ * Typically used for a GUI to filter
* out extensions. */
- /* If true, retro_load_game() is guaranteed to provide a valid pathname
+ /* If true, retro_load_game() is guaranteed to provide a valid pathname
* in retro_game_info::path.
* ::data and ::size are both invalid.
*
- * If false, ::data and ::size are guaranteed to be valid, but ::path
+ * If false, ::data and ::size are guaranteed to be valid, but ::path
* might not be valid.
*
- * This is typically set to true for libretro implementations that must
+ * This is typically set to true for libretro implementations that must
* load from file.
- * Implementations should strive for setting this to false, as it allows
+ * Implementations should strive for setting this to false, as it allows
* the frontend to perform patching, etc. */
- bool need_fullpath;
+ bool need_fullpath;
- /* If true, the frontend is not allowed to extract any archives before
+ /* If true, the frontend is not allowed to extract any archives before
* loading the real content.
- * Necessary for certain libretro implementations that load games
+ * Necessary for certain libretro implementations that load games
* from zipped archives. */
- bool block_extract;
+ bool block_extract;
};
struct retro_game_geometry
@@ -1733,57 +1905,87 @@ struct retro_system_av_info
struct retro_variable
{
/* Variable to query in RETRO_ENVIRONMENT_GET_VARIABLE.
- * If NULL, obtains the complete environment string if more
+ * If NULL, obtains the complete environment string if more
* complex parsing is necessary.
- * The environment string is formatted as key-value pairs
+ * The environment string is formatted as key-value pairs
* delimited by semicolons as so:
* "key1=value1;key2=value2;..."
*/
- const char* key;
-
+ const char *key;
+
/* Value to be obtained. If key does not exist, it is set to NULL. */
- const char* value;
+ const char *value;
};
struct retro_game_info
{
- const char* path; /* Path to game, UTF-8 encoded.
+ const char *path; /* Path to game, UTF-8 encoded.
* Usually used as a reference.
* May be NULL if rom was loaded from stdin
- * or similar.
- * retro_system_info::need_fullpath guaranteed
+ * or similar.
+ * retro_system_info::need_fullpath guaranteed
* that this path is valid. */
- const void* data; /* Memory buffer of loaded game. Will be NULL
+ const void *data; /* Memory buffer of loaded game. Will be NULL
* if need_fullpath was set. */
size_t size; /* Size of memory buffer. */
- const char* meta; /* String of implementation specific meta-data. */
+ const char *meta; /* String of implementation specific meta-data. */
+};
+
+#define RETRO_MEMORY_ACCESS_WRITE (1 << 0)
+ /* The core will write to the buffer provided by retro_framebuffer::data. */
+#define RETRO_MEMORY_ACCESS_READ (1 << 1)
+ /* The core will read from retro_framebuffer::data. */
+#define RETRO_MEMORY_TYPE_CACHED (1 << 0)
+ /* The memory in data is cached.
+ * If not cached, random writes and/or reading from the buffer is expected to be very slow. */
+struct retro_framebuffer
+{
+ void *data; /* The framebuffer which the core can render into.
+ Set by frontend in GET_CURRENT_SOFTWARE_FRAMEBUFFER.
+ The initial contents of data are unspecified. */
+ unsigned width; /* The framebuffer width used by the core. Set by core. */
+ unsigned height; /* The framebuffer height used by the core. Set by core. */
+ size_t pitch; /* The number of bytes between the beginning of a scanline,
+ and beginning of the next scanline.
+ Set by frontend in GET_CURRENT_SOFTWARE_FRAMEBUFFER. */
+ enum retro_pixel_format format; /* The pixel format the core must use to render into data.
+ This format could differ from the format used in
+ SET_PIXEL_FORMAT.
+ Set by frontend in GET_CURRENT_SOFTWARE_FRAMEBUFFER. */
+
+ unsigned access_flags; /* How the core will access the memory in the framebuffer.
+ RETRO_MEMORY_ACCESS_* flags.
+ Set by core. */
+ unsigned memory_flags; /* Flags telling core how the memory has been mapped.
+ RETRO_MEMORY_TYPE_* flags.
+ Set by frontend in GET_CURRENT_SOFTWARE_FRAMEBUFFER. */
};
/* Callbacks */
-/* Environment callback. Gives implementations a way of performing
+/* Environment callback. Gives implementations a way of performing
* uncommon tasks. Extensible. */
-typedef bool (*retro_environment_t)(unsigned cmd, void* data);
+typedef bool (RETRO_CALLCONV *retro_environment_t)(unsigned cmd, void *data);
-/* Render a frame. Pixel format is 15-bit 0RGB1555 native endian
+/* Render a frame. Pixel format is 15-bit 0RGB1555 native endian
* unless changed (see RETRO_ENVIRONMENT_SET_PIXEL_FORMAT).
*
* Width and height specify dimensions of buffer.
* Pitch specifices length in bytes between two lines in buffer.
*
- * For performance reasons, it is highly recommended to have a frame
+ * For performance reasons, it is highly recommended to have a frame
* that is packed in memory, i.e. pitch == width * byte_per_pixel.
- * Certain graphic APIs, such as OpenGL ES, do not like textures
+ * Certain graphic APIs, such as OpenGL ES, do not like textures
* that are not packed in memory.
*/
-typedef void (*retro_video_refresh_t)(const void* data, unsigned width,
- unsigned height, size_t pitch);
+typedef void (RETRO_CALLCONV *retro_video_refresh_t)(const void *data, unsigned width,
+ unsigned height, size_t pitch);
-/* Renders a single audio frame. Should only be used if implementation
+/* Renders a single audio frame. Should only be used if implementation
* generates a single sample at a time.
* Format is signed 16-bit native endian.
*/
-typedef void (*retro_audio_sample_t)(int16_t left, int16_t right);
+typedef void (RETRO_CALLCONV *retro_audio_sample_t)(int16_t left, int16_t right);
/* Renders multiple audio frames in one go.
*
@@ -1791,113 +1993,113 @@ typedef void (*retro_audio_sample_t)(int16_t left, int16_t right);
* I.e. int16_t buf[4] = { l, r, l, r }; would be 2 frames.
* Only one of the audio callbacks must ever be used.
*/
-typedef size_t (*retro_audio_sample_batch_t)(const int16_t* data,
+typedef size_t (RETRO_CALLCONV *retro_audio_sample_batch_t)(const int16_t *data,
size_t frames);
/* Polls input. */
-typedef void (*retro_input_poll_t)(void);
+typedef void (RETRO_CALLCONV *retro_input_poll_t)(void);
-/* Queries for input for player 'port'. device will be masked with
+/* Queries for input for player 'port'. device will be masked with
* RETRO_DEVICE_MASK.
*
- * Specialization of devices such as RETRO_DEVICE_JOYPAD_MULTITAP that
+ * Specialization of devices such as RETRO_DEVICE_JOYPAD_MULTITAP that
* have been set with retro_set_controller_port_device()
* will still use the higher level RETRO_DEVICE_JOYPAD to request input.
*/
-typedef int16_t (*retro_input_state_t)(unsigned port, unsigned device,
- unsigned index, unsigned id);
+typedef int16_t (RETRO_CALLCONV *retro_input_state_t)(unsigned port, unsigned device,
+ unsigned index, unsigned id);
-/* Sets callbacks. retro_set_environment() is guaranteed to be called
+/* Sets callbacks. retro_set_environment() is guaranteed to be called
* before retro_init().
*
- * The rest of the set_* functions are guaranteed to have been called
+ * The rest of the set_* functions are guaranteed to have been called
* before the first call to retro_run() is made. */
-void retro_set_environment(retro_environment_t);
-void retro_set_video_refresh(retro_video_refresh_t);
-void retro_set_audio_sample(retro_audio_sample_t);
-void retro_set_audio_sample_batch(retro_audio_sample_batch_t);
-void retro_set_input_poll(retro_input_poll_t);
-void retro_set_input_state(retro_input_state_t);
+RETRO_API void retro_set_environment(retro_environment_t);
+RETRO_API void retro_set_video_refresh(retro_video_refresh_t);
+RETRO_API void retro_set_audio_sample(retro_audio_sample_t);
+RETRO_API void retro_set_audio_sample_batch(retro_audio_sample_batch_t);
+RETRO_API void retro_set_input_poll(retro_input_poll_t);
+RETRO_API void retro_set_input_state(retro_input_state_t);
/* Library global initialization/deinitialization. */
-void retro_init(void);
-void retro_deinit(void);
+RETRO_API void retro_init(void);
+RETRO_API void retro_deinit(void);
/* Must return RETRO_API_VERSION. Used to validate ABI compatibility
* when the API is revised. */
-unsigned retro_api_version(void);
+RETRO_API unsigned retro_api_version(void);
-/* Gets statically known system info. Pointers provided in *info
+/* Gets statically known system info. Pointers provided in *info
* must be statically allocated.
* Can be called at any time, even before retro_init(). */
-void retro_get_system_info(struct retro_system_info* info);
+RETRO_API void retro_get_system_info(struct retro_system_info *info);
/* Gets information about system audio/video timings and geometry.
* Can be called only after retro_load_game() has successfully completed.
- * NOTE: The implementation of this function might not initialize every
+ * NOTE: The implementation of this function might not initialize every
* variable if needed.
- * E.g. geom.aspect_ratio might not be initialized if core doesn't
+ * E.g. geom.aspect_ratio might not be initialized if core doesn't
* desire a particular aspect ratio. */
-void retro_get_system_av_info(struct retro_system_av_info* info);
+RETRO_API void retro_get_system_av_info(struct retro_system_av_info *info);
/* Sets device to be used for player 'port'.
- * By default, RETRO_DEVICE_JOYPAD is assumed to be plugged into all
+ * By default, RETRO_DEVICE_JOYPAD is assumed to be plugged into all
* available ports.
- * Setting a particular device type is not a guarantee that libretro cores
- * will only poll input based on that particular device type. It is only a
- * hint to the libretro core when a core cannot automatically detect the
- * appropriate input device type on its own. It is also relevant when a
+ * Setting a particular device type is not a guarantee that libretro cores
+ * will only poll input based on that particular device type. It is only a
+ * hint to the libretro core when a core cannot automatically detect the
+ * appropriate input device type on its own. It is also relevant when a
* core can change its behavior depending on device type. */
-void retro_set_controller_port_device(unsigned port, unsigned device);
+RETRO_API void retro_set_controller_port_device(unsigned port, unsigned device);
/* Resets the current game. */
-void retro_reset(void);
+RETRO_API void retro_reset(void);
/* Runs the game for one video frame.
* During retro_run(), input_poll callback must be called at least once.
- *
+ *
* If a frame is not rendered for reasons where a game "dropped" a frame,
- * this still counts as a frame, and retro_run() should explicitly dupe
+ * this still counts as a frame, and retro_run() should explicitly dupe
* a frame if GET_CAN_DUPE returns true.
* In this case, the video callback can take a NULL argument for data.
*/
-void retro_run(void);
+RETRO_API void retro_run(void);
-/* Returns the amount of data the implementation requires to serialize
+/* Returns the amount of data the implementation requires to serialize
* internal state (save states).
- * Between calls to retro_load_game() and retro_unload_game(), the
- * returned size is never allowed to be larger than a previous returned
+ * Between calls to retro_load_game() and retro_unload_game(), the
+ * returned size is never allowed to be larger than a previous returned
* value, to ensure that the frontend can allocate a save state buffer once.
*/
-size_t retro_serialize_size(void);
+RETRO_API size_t retro_serialize_size(void);
/* Serializes internal state. If failed, or size is lower than
* retro_serialize_size(), it should return false, true otherwise. */
-bool retro_serialize(void* data, size_t size);
-bool retro_unserialize(const void* data, size_t size);
+RETRO_API bool retro_serialize(void *data, size_t size);
+RETRO_API bool retro_unserialize(const void *data, size_t size);
-void retro_cheat_reset(void);
-void retro_cheat_set(unsigned index, bool enabled, const char* code);
+RETRO_API void retro_cheat_reset(void);
+RETRO_API void retro_cheat_set(unsigned index, bool enabled, const char *code);
/* Loads a game. */
-bool retro_load_game(const struct retro_game_info* game);
+RETRO_API bool retro_load_game(const struct retro_game_info *game);
/* Loads a "special" kind of game. Should not be used,
* except in extreme cases. */
-bool retro_load_game_special(
- unsigned game_type,
- const struct retro_game_info* info, size_t num_info
+RETRO_API bool retro_load_game_special(
+ unsigned game_type,
+ const struct retro_game_info *info, size_t num_info
);
/* Unloads a currently loaded game. */
-void retro_unload_game(void);
+RETRO_API void retro_unload_game(void);
/* Gets region of game. */
-unsigned retro_get_region(void);
+RETRO_API unsigned retro_get_region(void);
/* Gets region of memory. */
-void* retro_get_memory_data(unsigned id);
-size_t retro_get_memory_size(unsigned id);
+RETRO_API void *retro_get_memory_data(unsigned id);
+RETRO_API size_t retro_get_memory_size(unsigned id);
#ifdef __cplusplus
}
diff --git a/link.T b/link.T
index a90d3a8..9e82b5d 100644
--- a/link.T
+++ b/link.T
@@ -2,5 +2,3 @@
global: retro_*;
local: *;
};
-
-
diff --git a/source/65c816.h b/source/65c816.h
index 1d8eb60..91a165b 100644
--- a/source/65c816.h
+++ b/source/65c816.h
@@ -20,11 +20,11 @@
#define Zero 2
#define IRQ 4
#define Decimal 8
-#define IndexFlag 16
-#define MemoryFlag 32
-#define Overflow 64
-#define Negative 128
-#define Emulation 256
+#define IndexFlag 16
+#define MemoryFlag 32
+#define Overflow 64
+#define Negative 128
+#define Emulation 256
#define SetCarry() (ICPU._Carry = 1)
#define ClearCarry() (ICPU._Carry = 0)
diff --git a/source/apu.c b/source/apu.c
index 521d9b3..9d18242 100644
--- a/source/apu.c
+++ b/source/apu.c
@@ -8,7 +8,7 @@
#include "soundux.h"
#include "cpuexec.h"
-extern int32_t NoiseFreq [32];
+extern int32_t NoiseFreq[32];
bool S9xInitAPU()
{
@@ -17,10 +17,10 @@ bool S9xInitAPU()
if (!IAPU.RAM)
{
S9xDeinitAPU();
- return (false);
+ return false;
}
- return (true);
+ return true;
}
void S9xDeinitAPU()
@@ -66,11 +66,9 @@ void S9xResetAPU()
S9xAPUUnpackStatus();
IAPU.Registers.PC = 0;
IAPU.APUExecuting = Settings.APUEnabled;
-#ifdef SPC700_SHUTDOWN
IAPU.WaitAddress1 = NULL;
IAPU.WaitAddress2 = NULL;
IAPU.WaitCounter = 0;
-#endif
APU.ShowROM = true;
IAPU.RAM [0xf1] = 0x80;
@@ -246,7 +244,7 @@ void S9xSetAPUDSP(uint8_t byte)
case APU_P_LOW + 0x50:
case APU_P_LOW + 0x60:
case APU_P_LOW + 0x70:
- S9xSetSoundHertz(reg >> 4, ((byte + (APU.DSP [reg + 1] << 8)) & FREQUENCY_MASK) / 8);
+ S9xSetSoundHertz(reg >> 4, (((int16_t) byte + ((int16_t) APU.DSP [reg + 1] << 8)) & FREQUENCY_MASK) / 8);
break;
case APU_P_HIGH + 0x00:
case APU_P_HIGH + 0x10:
@@ -256,7 +254,7 @@ void S9xSetAPUDSP(uint8_t byte)
case APU_P_HIGH + 0x50:
case APU_P_HIGH + 0x60:
case APU_P_HIGH + 0x70:
- S9xSetSoundHertz(reg >> 4, (((byte << 8) + APU.DSP [reg - 1]) & FREQUENCY_MASK) * 8);
+ S9xSetSoundHertz(reg >> 4, ((((int16_t) byte << 8) + (int16_t) APU.DSP [reg - 1]) & FREQUENCY_MASK) * 8);
break;
case APU_ADSR1 + 0x00:
case APU_ADSR1 + 0x10:
diff --git a/source/apu.h b/source/apu.h
index 57ff79d..3e034c1 100644
--- a/source/apu.h
+++ b/source/apu.h
@@ -23,8 +23,8 @@ typedef struct
uint8_t _Carry;
uint8_t _Zero;
uint8_t _Overflow;
- uint32_t TimerErrorCounter;
- uint32_t Scanline;
+ uint32_t UNUSED1;
+ uint32_t UNUSED2;
int32_t OneCycle;
int32_t TwoCycles;
} SIAPU;
@@ -33,75 +33,80 @@ typedef struct
{
int32_t Cycles;
bool ShowROM;
- uint8_t Flags;
+ uint8_t UNUSED1;
uint8_t KeyedChannels;
- uint8_t OutPorts [4];
- uint8_t DSP [0x80];
- uint8_t ExtraRAM [64];
- uint16_t Timer [3];
- uint16_t TimerTarget [3];
+ uint8_t OutPorts [4];
+ uint8_t DSP [0x80];
+ uint8_t ExtraRAM [64];
+ uint16_t Timer [3];
+ uint16_t TimerTarget [3];
bool TimerEnabled [3];
- bool TimerValueWritten [3];
+ bool UNUSED2 [3];
} SAPU;
SAPU APU;
SIAPU IAPU;
-static inline void S9xAPUUnpackStatus()
+static inline void S9xAPUUnpackStatus(void)
{
- IAPU._Zero = ((IAPU.Registers.P & Zero) == 0) | (IAPU.Registers.P & Negative);
- IAPU._Carry = (IAPU.Registers.P & Carry);
- IAPU._Overflow = (IAPU.Registers.P & Overflow) >> 6;
+ IAPU._Zero = ((IAPU.Registers.P & Zero) == 0) | (IAPU.Registers.P & Negative);
+ IAPU._Carry = (IAPU.Registers.P & Carry);
+ IAPU._Overflow = IAPU.Registers.P & Overflow;
}
-static inline void S9xAPUPackStatus()
+static inline void S9xAPUPackStatus(void)
{
IAPU.Registers.P &= ~(Zero | Negative | Carry | Overflow);
- IAPU.Registers.P |= IAPU._Carry | ((IAPU._Zero == 0) << 1) |
- (IAPU._Zero & 0x80) | (IAPU._Overflow << 6);
+ if (IAPU._Carry)
+ IAPU.Registers.P |= Carry;
+ if (!IAPU._Zero)
+ IAPU.Registers.P |= Zero;
+ if (IAPU._Overflow)
+ IAPU.Registers.P |= Overflow;
+ if (IAPU._Zero & 0x80)
+ IAPU.Registers.P |= Negative;
}
-void S9xResetAPU();
-bool S9xInitAPU();
-void S9xDeinitAPU();
-void S9xDecacheSamples();
+void S9xResetAPU(void);
+bool S9xInitAPU(void);
+void S9xDeinitAPU(void);
+void S9xDecacheSamples(void);
void S9xSetAPUControl(uint8_t byte);
void S9xSetAPUDSP(uint8_t byte);
-uint8_t S9xGetAPUDSP();
-bool S9xInitSound();
-void S9xOpenCloseSoundTracingFile(bool);
-void S9xPrintAPUState();
+uint8_t S9xGetAPUDSP(void);
+bool S9xInitSound(void);
+void S9xPrintAPUState(void);
extern uint16_t S9xAPUCycles [256]; // Scaled cycle lengths
extern uint16_t S9xAPUCycleLengths [256]; // Raw data.
-extern void (*S9xApuOpcodes [256])();
+extern void (*S9xApuOpcodes [256])(void);
-#define APU_VOL_LEFT 0x00
+#define APU_VOL_LEFT 0x00
#define APU_VOL_RIGHT 0x01
-#define APU_P_LOW 0x02
-#define APU_P_HIGH 0x03
-#define APU_SRCN 0x04
-#define APU_ADSR1 0x05
-#define APU_ADSR2 0x06
-#define APU_GAIN 0x07
-#define APU_ENVX 0x08
-#define APU_OUTX 0x09
-
-#define APU_MVOL_LEFT 0x0c
+#define APU_P_LOW 0x02
+#define APU_P_HIGH 0x03
+#define APU_SRCN 0x04
+#define APU_ADSR1 0x05
+#define APU_ADSR2 0x06
+#define APU_GAIN 0x07
+#define APU_ENVX 0x08
+#define APU_OUTX 0x09
+
+#define APU_MVOL_LEFT 0x0c
#define APU_MVOL_RIGHT 0x1c
-#define APU_EVOL_LEFT 0x2c
+#define APU_EVOL_LEFT 0x2c
#define APU_EVOL_RIGHT 0x3c
-#define APU_KON 0x4c
-#define APU_KOFF 0x5c
-#define APU_FLG 0x6c
-#define APU_ENDX 0x7c
+#define APU_KON 0x4c
+#define APU_KOFF 0x5c
+#define APU_FLG 0x6c
+#define APU_ENDX 0x7c
-#define APU_EFB 0x0d
+#define APU_EFB 0x0d
#define APU_PMON 0x2d
-#define APU_NON 0x3d
-#define APU_EON 0x4d
-#define APU_DIR 0x5d
-#define APU_ESA 0x6d
-#define APU_EDL 0x7d
+#define APU_NON 0x3d
+#define APU_EON 0x4d
+#define APU_DIR 0x5d
+#define APU_ESA 0x6d
+#define APU_EDL 0x7d
#define APU_C0 0x0f
#define APU_C1 0x1f
@@ -112,8 +117,8 @@ extern void (*S9xApuOpcodes [256])();
#define APU_C6 0x6f
#define APU_C7 0x7f
-#define APU_SOFT_RESET 0x80
-#define APU_MUTE 0x40
+#define APU_SOFT_RESET 0x80
+#define APU_MUTE 0x40
#define APU_ECHO_DISABLED 0x20
#define FREQUENCY_MASK 0x3fff
@@ -122,7 +127,7 @@ extern void (*S9xApuOpcodes [256])();
#else
#include "apu_blargg.h"
#define ONE_APU_CYCLE 21
-#define APU_EXECUTE1() do{}while(0)
-#define APU_EXECUTE() do{}while(0)
+#define APU_EXECUTE1() do {} while(0)
+#define APU_EXECUTE() do {} while(0)
#endif
diff --git a/source/apu_blargg.c b/source/apu_blargg.c
index d0d5879..a89a905 100644
--- a/source/apu_blargg.c
+++ b/source/apu_blargg.c
@@ -8,12 +8,8 @@
#include <stdlib.h>
#include <limits.h>
-#ifndef INLINE
#ifdef PSP
-#define INLINE __attribute((force_inline))
-#else
-#define INLINE inline
-#endif
+#define inline __attribute((force_inline))
#endif
#include "blargg_endian.h"
@@ -40,32 +36,29 @@ details. You should have received a copy of the GNU Lesser General Public
License along with this module; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
-/* if ( io < -32768 ) io = -32768; */
-/* if ( io > 32767 ) io = 32767; */
-#define CLAMP16( io )\
-{\
- if ( (int16_t) io != io )\
- io = (io >> 31) ^ 0x7FFF;\
+#define CLAMP16(io) \
+{ \
+ if ((int16_t) io != io) \
+ io = (io >> 31) ^ 0x7FFF; \
}
/* Access global DSP register */
-#define REG(n) dsp_m.regs [R_##n]
+#define REG(n) dsp_m.regs [R_##n]
/* Access voice DSP register */
-#define VREG(r,n) r [V_##n]
+#define VREG(r,n) r [V_##n]
-#define WRITE_SAMPLES( l, r, out ) \
+#define WRITE_SAMPLES(l, r, out) \
{\
- out [0] = l;\
- out [1] = r;\
- out += 2;\
- if ( out >= dsp_m.out_end )\
- {\
- out = dsp_m.extra;\
- dsp_m.out_end = &dsp_m.extra [EXTRA_SIZE];\
- }\
-}\
-
+ out [0] = l; \
+ out [1] = r; \
+ out += 2; \
+ if ( out >= dsp_m.out_end ) \
+ { \
+ out = dsp_m.extra; \
+ dsp_m.out_end = &dsp_m.extra [EXTRA_SIZE]; \
+ } \
+}
/* Volume registers and efb are signed! Easy to forget int8_t cast. */
/* Prefixes are to avoid accidental use of locals with same names. */
@@ -74,31 +67,31 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
static int16_t gauss [512] =
{
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
- 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5,
- 6, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10,
- 11, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 15, 16, 16, 17, 17,
- 18, 19, 19, 20, 20, 21, 21, 22, 23, 23, 24, 24, 25, 26, 27, 27,
- 28, 29, 29, 30, 31, 32, 32, 33, 34, 35, 36, 36, 37, 38, 39, 40,
- 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
- 58, 59, 60, 61, 62, 64, 65, 66, 67, 69, 70, 71, 73, 74, 76, 77,
- 78, 80, 81, 83, 84, 86, 87, 89, 90, 92, 94, 95, 97, 99, 100, 102,
- 104, 106, 107, 109, 111, 113, 115, 117, 118, 120, 122, 124, 126, 128, 130, 132,
- 134, 137, 139, 141, 143, 145, 147, 150, 152, 154, 156, 159, 161, 163, 166, 168,
- 171, 173, 175, 178, 180, 183, 186, 188, 191, 193, 196, 199, 201, 204, 207, 210,
- 212, 215, 218, 221, 224, 227, 230, 233, 236, 239, 242, 245, 248, 251, 254, 257,
- 260, 263, 267, 270, 273, 276, 280, 283, 286, 290, 293, 297, 300, 304, 307, 311,
- 314, 318, 321, 325, 328, 332, 336, 339, 343, 347, 351, 354, 358, 362, 366, 370,
- 374, 378, 381, 385, 389, 393, 397, 401, 405, 410, 414, 418, 422, 426, 430, 434,
- 439, 443, 447, 451, 456, 460, 464, 469, 473, 477, 482, 486, 491, 495, 499, 504,
- 508, 513, 517, 522, 527, 531, 536, 540, 545, 550, 554, 559, 563, 568, 573, 577,
- 582, 587, 592, 596, 601, 606, 611, 615, 620, 625, 630, 635, 640, 644, 649, 654,
- 659, 664, 669, 674, 678, 683, 688, 693, 698, 703, 708, 713, 718, 723, 728, 732,
- 737, 742, 747, 752, 757, 762, 767, 772, 777, 782, 787, 792, 797, 802, 806, 811,
- 816, 821, 826, 831, 836, 841, 846, 851, 855, 860, 865, 870, 875, 880, 884, 889,
- 894, 899, 904, 908, 913, 918, 923, 927, 932, 937, 941, 946, 951, 955, 960, 965,
- 969, 974, 978, 983, 988, 992, 997,1001,1005,1010,1014,1019,1023,1027,1032,1036,
+0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
+2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5,
+6, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10,
+11, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 15, 16, 16, 17, 17,
+18, 19, 19, 20, 20, 21, 21, 22, 23, 23, 24, 24, 25, 26, 27, 27,
+28, 29, 29, 30, 31, 32, 32, 33, 34, 35, 36, 36, 37, 38, 39, 40,
+41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
+58, 59, 60, 61, 62, 64, 65, 66, 67, 69, 70, 71, 73, 74, 76, 77,
+78, 80, 81, 83, 84, 86, 87, 89, 90, 92, 94, 95, 97, 99, 100, 102,
+104, 106, 107, 109, 111, 113, 115, 117, 118, 120, 122, 124, 126, 128, 130, 132,
+134, 137, 139, 141, 143, 145, 147, 150, 152, 154, 156, 159, 161, 163, 166, 168,
+171, 173, 175, 178, 180, 183, 186, 188, 191, 193, 196, 199, 201, 204, 207, 210,
+212, 215, 218, 221, 224, 227, 230, 233, 236, 239, 242, 245, 248, 251, 254, 257,
+260, 263, 267, 270, 273, 276, 280, 283, 286, 290, 293, 297, 300, 304, 307, 311,
+314, 318, 321, 325, 328, 332, 336, 339, 343, 347, 351, 354, 358, 362, 366, 370,
+374, 378, 381, 385, 389, 393, 397, 401, 405, 410, 414, 418, 422, 426, 430, 434,
+439, 443, 447, 451, 456, 460, 464, 469, 473, 477, 482, 486, 491, 495, 499, 504,
+508, 513, 517, 522, 527, 531, 536, 540, 545, 550, 554, 559, 563, 568, 573, 577,
+582, 587, 592, 596, 601, 606, 611, 615, 620, 625, 630, 635, 640, 644, 649, 654,
+659, 664, 669, 674, 678, 683, 688, 693, 698, 703, 708, 713, 718, 723, 728, 732,
+737, 742, 747, 752, 757, 762, 767, 772, 777, 782, 787, 792, 797, 802, 806, 811,
+816, 821, 826, 831, 836, 841, 846, 851, 855, 860, 865, 870, 875, 880, 884, 889,
+894, 899, 904, 908, 913, 918, 923, 927, 932, 937, 941, 946, 951, 955, 960, 965,
+969, 974, 978, 983, 988, 992, 997, 1001,1005,1010,1014,1019,1023,1027,1032,1036,
1040,1045,1049,1053,1057,1061,1066,1070,1074,1078,1082,1086,1090,1094,1098,1102,
1106,1109,1113,1117,1121,1125,1128,1132,1136,1139,1143,1146,1150,1153,1157,1160,
1164,1167,1170,1174,1177,1180,1183,1186,1190,1193,1196,1199,1202,1205,1207,1210,
@@ -110,7 +103,7 @@ static int16_t gauss [512] =
/* Gaussian interpolation */
-static INLINE int32_t dsp_interpolate( dsp_voice_t *v )
+static inline int32_t dsp_interpolate( dsp_voice_t *v )
{
int32_t offset, out, *in;
int16_t *fwd, *rev;
@@ -140,7 +133,7 @@ static INLINE int32_t dsp_interpolate( dsp_voice_t *v )
static uint32_t const counter_rates [32] =
{
SIMPLE_COUNTER_RANGE + 1, /* never fires */
- 2048, 1536,
+ 2048, 1536,
1280, 1024, 768,
640, 512, 384,
320, 256, 192,
@@ -171,14 +164,14 @@ static uint32_t const counter_offsets [32] =
};
#define RUN_COUNTERS() \
- if ( --dsp_m.counter < 0 ) \
+ if (--dsp_m.counter < 0) \
dsp_m.counter = SIMPLE_COUNTER_RANGE - 1;
#define READ_COUNTER(rate) (((uint32_t) dsp_m.counter + counter_offsets [rate]) % counter_rates [rate])
/* Envelope */
-static INLINE void dsp_run_envelope( dsp_voice_t* const v )
+static inline void dsp_run_envelope( dsp_voice_t* const v )
{
int32_t env, rate, env_data;
@@ -252,7 +245,7 @@ static INLINE void dsp_run_envelope( dsp_voice_t* const v )
/* BRR Decoding */
-static INLINE void dsp_decode_brr( dsp_voice_t* v )
+static inline void dsp_decode_brr( dsp_voice_t* v )
{
int32_t nybbles, *pos, *end, header;
@@ -327,7 +320,7 @@ static INLINE void dsp_decode_brr( dsp_voice_t* v )
if ( (dsp_m.every_other_sample ^= 1) != 0 ) \
dsp_m.new_kon &= ~dsp_m.kon; /* clears KON 63 clocks after it was last read */
-static INLINE void dsp_misc_30()
+static inline void dsp_misc_30()
{
if ( dsp_m.every_other_sample )
{
@@ -347,13 +340,13 @@ static INLINE void dsp_misc_30()
/* Voices */
-static INLINE void dsp_voice_V1( dsp_voice_t* const v )
+static inline void dsp_voice_V1( dsp_voice_t* const v )
{
dsp_m.t_dir_addr = dsp_m.t_dir * 0x100 + dsp_m.t_srcn * 4;
dsp_m.t_srcn = v->regs[V_SRCN];
}
-static INLINE void dsp_voice_V2( dsp_voice_t* const v )
+static inline void dsp_voice_V2( dsp_voice_t* const v )
{
uint8_t *entry;
@@ -369,12 +362,12 @@ static INLINE void dsp_voice_V2( dsp_voice_t* const v )
dsp_m.t_pitch = v->regs [V_PITCHL];
}
-static INLINE void dsp_voice_V3a( dsp_voice_t* const v )
+static inline void dsp_voice_V3a( dsp_voice_t* const v )
{
dsp_m.t_pitch += (v->regs [V_PITCHH] & 0x3F) << 8;
}
-static INLINE void dsp_voice_V3b( dsp_voice_t* const v )
+static inline void dsp_voice_V3b( dsp_voice_t* const v )
{
dsp_m.t_brr_byte = dsp_m.ram [(v->brr_addr + v->brr_offset) & 0xffff];
dsp_m.t_brr_header = dsp_m.ram [v->brr_addr];
@@ -460,7 +453,7 @@ static void dsp_voice_V3c( dsp_voice_t* const v )
}
}
-static INLINE void dsp_voice_output( dsp_voice_t const* v, int32_t ch )
+static inline void dsp_voice_output( dsp_voice_t const* v, int32_t ch )
{
int32_t amp;
@@ -479,7 +472,7 @@ static INLINE void dsp_voice_output( dsp_voice_t const* v, int32_t ch )
}
}
-static INLINE void dsp_voice_V4( dsp_voice_t* const v )
+static inline void dsp_voice_V4( dsp_voice_t* const v )
{
/* Decode BRR */
dsp_m.t_looped = 0;
@@ -511,7 +504,7 @@ static INLINE void dsp_voice_V4( dsp_voice_t* const v )
dsp_voice_output( v, 0 );
}
-static INLINE void dsp_voice_V5( dsp_voice_t* const v )
+static inline void dsp_voice_V5( dsp_voice_t* const v )
{
int32_t endx_buf;
/* Output right */
@@ -526,13 +519,13 @@ static INLINE void dsp_voice_V5( dsp_voice_t* const v )
dsp_m.endx_buf = (uint8_t) endx_buf;
}
-static INLINE void dsp_voice_V6( dsp_voice_t* const v )
+static inline void dsp_voice_V6( dsp_voice_t* const v )
{
(void) v; /* avoid compiler warning about unused v */
dsp_m.outx_buf = (uint8_t) (dsp_m.t_output >> 8);
}
-static INLINE void dsp_voice_V7( dsp_voice_t* const v )
+static inline void dsp_voice_V7( dsp_voice_t* const v )
{
/* Update ENDX */
dsp_m.regs[R_ENDX] = dsp_m.endx_buf;
@@ -540,20 +533,20 @@ static INLINE void dsp_voice_V7( dsp_voice_t* const v )
dsp_m.envx_buf = v->t_envx_out;
}
-static INLINE void dsp_voice_V8( dsp_voice_t* const v )
+static inline void dsp_voice_V8( dsp_voice_t* const v )
{
/* Update OUTX */
v->regs [V_OUTX] = dsp_m.outx_buf;
}
-static INLINE void dsp_voice_V9( dsp_voice_t* const v )
+static inline void dsp_voice_V9( dsp_voice_t* const v )
{
v->regs [V_ENVX] = dsp_m.envx_buf;
}
/* Most voices do all these in one clock, so make a handy composite */
-static INLINE void dsp_voice_V3( dsp_voice_t* const v )
+static inline void dsp_voice_V3( dsp_voice_t* const v )
{
dsp_voice_V3a( v );
dsp_voice_V3b( v );
@@ -606,7 +599,7 @@ static void dsp_voice_V9_V6_V3( dsp_voice_t* const v )
ECHO_FIR( 0 ) [ch] = ECHO_FIR( 8 ) [ch] = s >> 1; \
}
-static INLINE void dsp_echo_22()
+static inline void dsp_echo_22()
{
int32_t l, r;
@@ -624,7 +617,7 @@ static INLINE void dsp_echo_22()
dsp_m.t_echo_in [1] = r;
}
-static INLINE void dsp_echo_23()
+static inline void dsp_echo_23()
{
int32_t l, r;
@@ -637,7 +630,7 @@ static INLINE void dsp_echo_23()
ECHO_READ(1);
}
-static INLINE void dsp_echo_24()
+static inline void dsp_echo_24()
{
int32_t l, r;
@@ -648,7 +641,7 @@ static INLINE void dsp_echo_24()
dsp_m.t_echo_in [1] += r;
}
-static INLINE void dsp_echo_25()
+static inline void dsp_echo_25()
{
int32_t l = dsp_m.t_echo_in [0] + (((dsp_m.echo_hist_pos [6 + 1]) [0] * (int8_t) dsp_m.regs [R_FIR + 6 * 0x10]) >> 6);
int32_t r = dsp_m.t_echo_in [1] + (((dsp_m.echo_hist_pos [6 + 1]) [1] * (int8_t) dsp_m.regs [R_FIR + 6 * 0x10]) >> 6);
@@ -674,7 +667,7 @@ static INLINE void dsp_echo_25()
CLAMP16( var ); \
}
-static INLINE void dsp_echo_26()
+static inline void dsp_echo_26()
{
int32_t l, r;
@@ -690,7 +683,7 @@ static INLINE void dsp_echo_26()
dsp_m.t_echo_out [1] = r & ~1;
}
-static INLINE void dsp_echo_27()
+static inline void dsp_echo_27()
{
int32_t l, r;
int16_t *out;
@@ -733,7 +726,7 @@ static INLINE void dsp_echo_27()
} \
dsp_m.t_echo_out [ch] = 0;
-static INLINE void dsp_echo_29()
+static inline void dsp_echo_29()
{
dsp_m.t_esa = dsp_m.regs [R_ESA];
@@ -1253,7 +1246,7 @@ void spc_enable_rom( int32_t enable )
dsp_run( clock_count ); \
}
-static INLINE void spc_dsp_write( int32_t data, int32_t time )
+static inline void spc_dsp_write( int32_t data, int32_t time )
{
int32_t addr;
@@ -2907,7 +2900,7 @@ static int32_t r_left[4], r_right[4];
#define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
#define SHORT_CLAMP(n) ((int16_t) CLAMP((n), -32768, 32767))
-static INLINE int32_t hermite (int32_t mu1, int32_t a, int32_t b, int32_t c, int32_t d)
+static inline int32_t hermite (int32_t mu1, int32_t a, int32_t b, int32_t c, int32_t d)
{
int32_t mu2, mu3, m0, m1, a0, a1, a2, a3;
@@ -3013,7 +3006,7 @@ static void resampler_new(int32_t num_samples)
resampler_clear();
}
-static INLINE bool resampler_push(int16_t *src, int32_t num_samples)
+static inline bool resampler_push(int16_t *src, int32_t num_samples)
{
int32_t bytes, end, first_write_size;
uint8_t *src_ring;
@@ -3037,7 +3030,7 @@ static INLINE bool resampler_push(int16_t *src, int32_t num_samples)
return true;
}
-static INLINE void resampler_resize (int32_t num_samples)
+static inline void resampler_resize (int32_t num_samples)
{
free(rb_buffer);
rb_buffer_size = rb_size;
@@ -3439,7 +3432,4 @@ void S9xAPULoadState (const uint8_t *block)
spc_remainder = GET_LE32(ptr);
}
-#undef INLINE
-#define INLINE static inline
-
#endif
diff --git a/source/apu_blargg.h b/source/apu_blargg.h
index 00d9428..3a07e2c 100644
--- a/source/apu_blargg.h
+++ b/source/apu_blargg.h
@@ -9,20 +9,20 @@
typedef void (*dsp_copy_func_t)( uint8_t ** io, void* state, size_t );
-#define ECHO_HIST_SIZE 8
-#define ECHO_HIST_SIZE_X2 16
+#define ECHO_HIST_SIZE 8
+#define ECHO_HIST_SIZE_X2 16
/* Sound control */
/* Mutes voices corresponding to non-zero bits in mask (issues repeated KOFF events).
Reduces emulation accuracy. */
-#define VOICE_COUNT 8
-#define EXTRA_SIZE 16
-#define EXTRA_SIZE_DIV_2 8
-#define BRR_BUF_SIZE 12
-#define BRR_BUF_SIZE_X2 24
-#define BRR_BLOCK_SIZE 9
+#define VOICE_COUNT 8
+#define EXTRA_SIZE 16
+#define EXTRA_SIZE_DIV_2 8
+#define BRR_BUF_SIZE 12
+#define BRR_BUF_SIZE_X2 24
+#define BRR_BLOCK_SIZE 9
/* DSP register addresses */
@@ -32,176 +32,170 @@ typedef void (*dsp_copy_func_t)( uint8_t ** io, void* state, size_t );
#define R_MVOLR 0x1C
#define R_EVOLL 0x2C
#define R_EVOLR 0x3C
-#define R_KON 0x4C
-#define R_KOFF 0x5C
-#define R_FLG 0x6C
-#define R_ENDX 0x7C
-#define R_EFB 0x0D
-#define R_EON 0x4D
-#define R_PMON 0x2D
-#define R_NON 0x3D
-#define R_DIR 0x5D
-#define R_ESA 0x6D
-#define R_EDL 0x7D
-#define R_FIR 0x0F /* 8 coefficients at 0x0F, 0x1F ... 0x7F */
+#define R_KON 0x4C
+#define R_KOFF 0x5C
+#define R_FLG 0x6C
+#define R_ENDX 0x7C
+#define R_EFB 0x0D
+#define R_EON 0x4D
+#define R_PMON 0x2D
+#define R_NON 0x3D
+#define R_DIR 0x5D
+#define R_ESA 0x6D
+#define R_EDL 0x7D
+#define R_FIR 0x0F /* 8 coefficients at 0x0F, 0x1F ... 0x7F */
/* Voice registers */
-#define V_VOLL 0x00
-#define V_VOLR 0x01
-#define V_PITCHL 0x02
-#define V_PITCHH 0x03
-#define V_SRCN 0x04
-#define V_ADSR0 0x05
-#define V_ADSR1 0x06
-#define V_GAIN 0x07
-#define V_ENVX 0x08
-#define V_OUTX 0x09
+#define V_VOLL 0x00
+#define V_VOLR 0x01
+#define V_PITCHL 0x02
+#define V_PITCHH 0x03
+#define V_SRCN 0x04
+#define V_ADSR0 0x05
+#define V_ADSR1 0x06
+#define V_GAIN 0x07
+#define V_ENVX 0x08
+#define V_OUTX 0x09
/* Status flag handling */
/* Hex value in name to clarify code and bit shifting.
Flag stored in indicated variable during emulation */
-#define N80 0x80 /* nz */
-#define V40 0x40 /* psw */
-#define P20 0x20 /* dp */
-#define B10 0x10 /* psw */
-#define H08 0x08 /* psw */
-#define I04 0x04 /* psw */
-#define Z02 0x02 /* nz */
-#define C01 0x01 /* c */
+#define N80 0x80 /* nz */
+#define V40 0x40 /* psw */
+#define P20 0x20 /* dp */
+#define B10 0x10 /* psw */
+#define H08 0x08 /* psw */
+#define I04 0x04 /* psw */
+#define Z02 0x02 /* nz */
+#define C01 0x01 /* c */
#define NZ_NEG_MASK 0x880 /* either bit set indicates N flag set */
#define REGISTER_COUNT 128
-#define ENV_RELEASE 0
-#define ENV_ATTACK 1
-#define ENV_DECAY 2
-#define ENV_SUSTAIN 3
+#define ENV_RELEASE 0
+#define ENV_ATTACK 1
+#define ENV_DECAY 2
+#define ENV_SUSTAIN 3
typedef struct
{
- int32_t buf [BRR_BUF_SIZE_X2]; // decoded samples (twice the size to simplify wrap handling)
- int32_t buf_pos; // place in buffer where next samples will be decoded
- int32_t interp_pos; // relative fractional position in sample (0x1000 = 1.0)
- int32_t brr_addr; // address of current BRR block
- int32_t brr_offset; // current decoding offset in BRR block
+ int32_t buf [BRR_BUF_SIZE_X2]; // decoded samples (twice the size to simplify wrap handling)
+ int32_t buf_pos; // place in buffer where next samples will be decoded
+ int32_t interp_pos; // relative fractional position in sample (0x1000 = 1.0)
+ int32_t brr_addr; // address of current BRR block
+ int32_t brr_offset; // current decoding offset in BRR block
uint8_t* regs; // pointer to voice's DSP registers
- int32_t vbit; // bitmask for voice: 0x01 for voice 0, 0x02 for voice 1, etc.
- int32_t kon_delay; // KON delay/current setup phase
- int32_t env_mode;
- int32_t env; // current envelope level
- int32_t hidden_env; // used by GAIN mode 7, very obscure quirk
+ int32_t vbit; // bitmask for voice: 0x01 for voice 0, 0x02 for voice 1, etc.
+ int32_t kon_delay; // KON delay/current setup phase
+ int32_t env_mode;
+ int32_t env; // current envelope level
+ int32_t hidden_env; // used by GAIN mode 7, very obscure quirk
uint8_t t_envx_out;
} dsp_voice_t;
typedef struct
{
- uint8_t regs [REGISTER_COUNT];
-
- /* Echo history keeps most recent 8 samples (twice the size to simplify wrap handling) */
-
- int32_t echo_hist [ECHO_HIST_SIZE_X2] [2];
-
- int32_t (*echo_hist_pos) [2]; /* &echo_hist [0 to 7] */
-
- int32_t every_other_sample; /* toggles every sample */
- int32_t kon; /* KON value when last checked */
- int32_t noise;
- int32_t counter;
- int32_t echo_offset; /* offset from ESA in echo buffer */
- int32_t echo_length; /* number of bytes that echo_offset will stop at */
- int32_t phase; /* next clock cycle to run (0-31) */
+ uint8_t regs [REGISTER_COUNT];
+ int32_t echo_hist [ECHO_HIST_SIZE_X2] [2]; /* Echo history keeps most recent 8 samples (twice the size to simplify wrap handling) */
+ int32_t (*echo_hist_pos) [2]; /* &echo_hist [0 to 7] */
+ int32_t every_other_sample; /* toggles every sample */
+ int32_t kon; /* KON value when last checked */
+ int32_t noise;
+ int32_t counter;
+ int32_t echo_offset; /* offset from ESA in echo buffer */
+ int32_t echo_length; /* number of bytes that echo_offset will stop at */
+ int32_t phase; /* next clock cycle to run (0-31) */
/* Hidden registers also written to when main register is written to */
- int32_t new_kon;
- uint8_t endx_buf;
- uint8_t envx_buf;
- uint8_t outx_buf;
-
- /* Temporary state between clocks */
+ int32_t new_kon;
+ uint8_t endx_buf;
+ uint8_t envx_buf;
+ uint8_t outx_buf;
/* read once per sample */
- int32_t t_pmon;
- int32_t t_non;
- int32_t t_eon;
- int32_t t_dir;
- int32_t t_koff;
+ int32_t t_pmon;
+ int32_t t_non;
+ int32_t t_eon;
+ int32_t t_dir;
+ int32_t t_koff;
/* read a few clocks ahead then used */
- int32_t t_brr_next_addr;
- int32_t t_adsr0;
- int32_t t_brr_header;
- int32_t t_brr_byte;
- int32_t t_srcn;
- int32_t t_esa;
- int32_t t_echo_enabled;
+ int32_t t_brr_next_addr;
+ int32_t t_adsr0;
+ int32_t t_brr_header;
+ int32_t t_brr_byte;
+ int32_t t_srcn;
+ int32_t t_esa;
+ int32_t t_echo_enabled;
/* internal state that is recalculated every sample */
- int32_t t_dir_addr;
- int32_t t_pitch;
- int32_t t_output;
- int32_t t_looped;
- int32_t t_echo_ptr;
+ int32_t t_dir_addr;
+ int32_t t_pitch;
+ int32_t t_output;
+ int32_t t_looped;
+ int32_t t_echo_ptr;
/* left/right sums */
- int32_t t_main_out [2];
- int32_t t_echo_out [2];
- int32_t t_echo_in [2];
+ int32_t t_main_out [2];
+ int32_t t_echo_out [2];
+ int32_t t_echo_in [2];
- dsp_voice_t voices [VOICE_COUNT];
+ dsp_voice_t voices [VOICE_COUNT];
/* non-emulation state */
- uint8_t* ram; /* 64K shared RAM between DSP and SMP */
- int16_t* out;
- int16_t* out_end;
- int16_t* out_begin;
- int16_t extra [EXTRA_SIZE];
-
- int32_t rom_enabled;
- uint8_t* rom;
- uint8_t* hi_ram;
+ uint8_t* ram; /* 64K shared RAM between DSP and SMP */
+ int16_t* out;
+ int16_t* out_end;
+ int16_t* out_begin;
+ int16_t extra [EXTRA_SIZE];
+
+ int32_t rom_enabled;
+ uint8_t* rom;
+ uint8_t* hi_ram;
} dsp_state_t;
#if !SPC_NO_COPY_STATE_FUNCS
-typedef struct {
+typedef struct
+{
dsp_copy_func_t func;
- uint8_t** buf;
+ uint8_t** buf;
} spc_state_copy_t;
#define SPC_COPY( type, state ) state = (type) spc_copier_copy_int(&copier, state, sizeof (type) );
#endif
-#define REG_COUNT 0x10
-#define PORT_COUNT 4
-#define TEMPO_UNIT 0x100
-#define STATE_SIZE 68 * 1024L /* maximum space needed when saving */
-#define TIMER_COUNT 3
-#define ROM_SIZE 0x40
-#define ROM_ADDR 0xFFC0
+#define REG_COUNT 0x10
+#define PORT_COUNT 4
+#define TEMPO_UNIT 0x100
+#define STATE_SIZE 68 * 1024L /* maximum space needed when saving */
+#define TIMER_COUNT 3
+#define ROM_SIZE 0x40
+#define ROM_ADDR 0xFFC0
/* 1024000 SPC clocks per second, sample pair every 32 clocks */
#define CLOCKS_PER_SAMPLE 32
-#define R_TEST 0x0
-#define R_CONTROL 0x1
-#define R_DSPADDR 0x2
-#define R_DSPDATA 0x3
-#define R_CPUIO0 0x4
-#define R_CPUIO1 0x5
-#define R_CPUIO2 0x6
-#define R_CPUIO3 0x7
-#define R_F8 0x8
-#define R_F9 0x9
-#define R_T0TARGET 0xA
-#define R_T1TARGET 0xB
-#define R_T2TARGET 0xC
-#define R_T0OUT 0xD
-#define R_T1OUT 0xE
-#define R_T2OUT 0xF
+#define R_TEST 0x0
+#define R_CONTROL 0x1
+#define R_DSPADDR 0x2
+#define R_DSPDATA 0x3
+#define R_CPUIO0 0x4
+#define R_CPUIO1 0x5
+#define R_CPUIO2 0x6
+#define R_CPUIO3 0x7
+#define R_F8 0x8
+#define R_F9 0x9
+#define R_T0TARGET 0xA
+#define R_T1TARGET 0xB
+#define R_T2TARGET 0xC
+#define R_T0OUT 0xD
+#define R_T1OUT 0xE
+#define R_T2OUT 0xF
/* Value that padding should be filled with */
#define CPU_PAD_FILL 0xFF
@@ -230,9 +224,8 @@ uint8_t* spc_apuram();
typedef struct
{
- Timer timers [TIMER_COUNT];
-
- uint8_t smp_regs [2] [REG_COUNT];
+ Timer timers [TIMER_COUNT];
+ uint8_t smp_regs [2] [REG_COUNT];
struct
{
@@ -244,27 +237,24 @@ typedef struct
int32_t sp;
} cpu_regs;
- int32_t dsp_time;
- int32_t spc_time;
-
- int32_t tempo;
-
+ int32_t dsp_time;
+ int32_t spc_time;
+ int32_t tempo;
int32_t extra_clocks;
int16_t* buf_begin;
- int16_t* buf_end;
+ int16_t* buf_end;
int16_t* extra_pos;
- int16_t extra_buf [EXTRA_SIZE];
-
- int32_t rom_enabled;
- uint8_t rom [ROM_SIZE];
- uint8_t hi_ram [ROM_SIZE];
-
- uint8_t cycle_table [256];
+ int16_t extra_buf [EXTRA_SIZE];
+ int32_t rom_enabled;
+ uint8_t rom [ROM_SIZE];
+ uint8_t hi_ram [ROM_SIZE];
+ uint8_t cycle_table [256];
struct
{
/* padding to neutralize address overflow */
- union {
+ union
+ {
uint8_t padding1 [0x100];
uint16_t align; /* makes compiler align data for 16-bit access */
} padding1 [1];
@@ -280,28 +270,27 @@ typedef void (*apu_callback)();
#define SPC_SAVE_STATE_BLOCK_SIZE (STATE_SIZE + 8)
-bool S9xInitAPU();
-void S9xDeinitAPU();
-void S9xResetAPU();
-void S9xSoftResetAPU();
+bool S9xInitAPU();
+void S9xDeinitAPU();
+void S9xResetAPU();
+void S9xSoftResetAPU();
uint8_t S9xAPUReadPort(int32_t port);
-void S9xAPUWritePort(int32_t port, uint8_t byte);
-void S9xAPUExecute();
-void S9xAPUSetReferenceTime(int32_t cpucycles);
-void S9xAPUTimingSetSpeedup(int32_t ticks);
-void S9xAPUAllowTimeOverflow(bool allow);
-void S9xAPULoadState(const uint8_t * block);
-void S9xAPUSaveState(uint8_t * block);
+void S9xAPUWritePort(int32_t port, uint8_t byte);
+void S9xAPUExecute();
+void S9xAPUSetReferenceTime(int32_t cpucycles);
+void S9xAPUTimingSetSpeedup(int32_t ticks);
+void S9xAPUAllowTimeOverflow(bool allow);
+void S9xAPULoadState(const uint8_t * block);
+void S9xAPUSaveState(uint8_t * block);
-bool S9xInitSound(int32_t buffer_ms, int32_t lag_ms);
+bool S9xInitSound(int32_t buffer_ms, int32_t lag_ms);
-bool S9xSyncSound();
+bool S9xSyncSound();
int32_t S9xGetSampleCount();
-void S9xFinalizeSamples();
-void S9xClearSamples();
-bool S9xMixSamples(int16_t * buffer, uint32_t sample_count);
-void S9xSetSamplesAvailableCallback(apu_callback);
+void S9xFinalizeSamples();
+void S9xClearSamples();
+bool S9xMixSamples(int16_t * buffer, uint32_t sample_count);
+void S9xSetSamplesAvailableCallback(apu_callback);
#endif // APU_BLARGG_H
-
#endif
diff --git a/source/apumem.h b/source/apumem.h
index 8a9f09a..c58b808 100644
--- a/source/apumem.h
+++ b/source/apumem.h
@@ -6,24 +6,20 @@
extern uint8_t W4;
extern uint8_t APUROM[64];
-INLINE uint8_t S9xAPUGetByteZ(uint8_t Address)
+static inline uint8_t S9xAPUGetByteZ(uint8_t Address)
{
if (Address >= 0xf0 && IAPU.DirectPage == IAPU.RAM)
{
if (Address >= 0xf4 && Address <= 0xf7)
{
-#ifdef SPC700_SHUTDOWN
IAPU.WaitAddress2 = IAPU.WaitAddress1;
IAPU.WaitAddress1 = IAPU.PC;
-#endif
return (IAPU.RAM [Address]);
}
if (Address >= 0xfd)
{
-#ifdef SPC700_SHUTDOWN
IAPU.WaitAddress2 = IAPU.WaitAddress1;
IAPU.WaitAddress1 = IAPU.PC;
-#endif
uint8_t t = IAPU.RAM [Address];
IAPU.RAM [Address] = 0;
return (t);
@@ -33,11 +29,10 @@ INLINE uint8_t S9xAPUGetByteZ(uint8_t Address)
return (IAPU.RAM [Address]);
}
- else
- return (IAPU.DirectPage [Address]);
+ return (IAPU.DirectPage [Address]);
}
-INLINE void S9xAPUSetByteZ(uint8_t byte, uint8_t Address)
+static inline void S9xAPUSetByteZ(uint8_t byte, uint8_t Address)
{
if (Address >= 0xf0 && IAPU.DirectPage == IAPU.RAM)
{
@@ -63,7 +58,7 @@ INLINE void S9xAPUSetByteZ(uint8_t byte, uint8_t Address)
IAPU.DirectPage [Address] = byte;
}
-INLINE uint8_t S9xAPUGetByte(uint32_t Address)
+static inline uint8_t S9xAPUGetByte(uint32_t Address)
{
Address &= 0xffff;
@@ -73,13 +68,11 @@ INLINE uint8_t S9xAPUGetByte(uint32_t Address)
bool zero = (Address >= 0xfd && Address <= 0xff);
uint8_t t = IAPU.RAM [Address];
-#ifdef SPC700_SHUTDOWN
if (zero || (Address >= 0xf4 && Address <= 0xf7))
{
IAPU.WaitAddress2 = IAPU.WaitAddress1;
IAPU.WaitAddress1 = IAPU.PC;
}
-#endif
if(zero)
IAPU.RAM [Address] = 0;
@@ -87,7 +80,7 @@ INLINE uint8_t S9xAPUGetByte(uint32_t Address)
return t;
}
-INLINE void S9xAPUSetByte(uint8_t byte, uint32_t Address)
+static inline void S9xAPUSetByte(uint8_t byte, uint32_t Address)
{
Address &= 0xffff;
diff --git a/source/blargg_endian.h b/source/blargg_endian.h
index 3fc7296..53e0e17 100644
--- a/source/blargg_endian.h
+++ b/source/blargg_endian.h
@@ -69,12 +69,12 @@
#define SET_LE32( addr, data ) (void) (*(uint32_t*) (addr) = (data))
#endif
#else
-static INLINE uint32_t get_le16( void const* p )
+static inline uint32_t get_le16( void const* p )
{
return (uint32_t) ((uint8_t const*) p) [1] << 8 | (uint32_t) ((uint8_t const*) p) [0];
}
-static INLINE uint32_t get_le32( void const* p )
+static inline uint32_t get_le32( void const* p )
{
return (uint32_t) ((uint8_t const*) p) [3] << 24 |
(uint32_t) ((uint8_t const*) p) [2] << 16 |
@@ -82,13 +82,13 @@ static INLINE uint32_t get_le32( void const* p )
(uint32_t) ((uint8_t const*) p) [0];
}
-static INLINE void set_le16( void* p, uint32_t n )
+static inline void set_le16( void* p, uint32_t n )
{
((uint8_t*) p) [1] = (uint8_t) (n >> 8);
((uint8_t*) p) [0] = (uint8_t) n;
}
-static INLINE void set_le32( void* p, uint32_t n )
+static inline void set_le32( void* p, uint32_t n )
{
((uint8_t*) p) [0] = (uint8_t) n;
((uint8_t*) p) [1] = (uint8_t) (n >> 8);
diff --git a/source/c4.c b/source/c4.c
index 9519cc3..251493c 100644
--- a/source/c4.c
+++ b/source/c4.c
@@ -111,9 +111,9 @@ int16_t _atan2(int16_t x, int16_t y)
int32_t absAtan;
if (x1 > y1)
- absAtan = atantbl[(unsigned char)((y1 << 8) / x1)];
+ absAtan = atantbl[(uint8_t)((y1 << 8) / x1)];
else
- absAtan = atantbl[(unsigned char)((x1 << 8) / y1)];
+ absAtan = atantbl[(uint8_t)((x1 << 8) / y1)];
if ((x >= 0) ^ (y >= 0))
return -absAtan;
diff --git a/source/c4emu.c b/source/c4emu.c
index 0cfb3aa..9736e3b 100644
--- a/source/c4emu.c
+++ b/source/c4emu.c
@@ -1,9 +1,5 @@
#include "../copyright"
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <math.h>
#include "snes9x.h"
#include "sar.h"
#include "memmap.h"
@@ -38,7 +34,6 @@ static uint8_t C4TestPattern [12 * 4] =
0x00, 0xff, 0xfe, 0x00
};
-
static void C4ConvOAM()
{
uint8_t* i;
@@ -320,7 +315,7 @@ static void C4DrawWireFrame()
if (line[0] == 0xff && line[1] == 0xff)
{
uint8_t* tmp = line - 5;
- while (line[2] == 0xff && line[3] == 0xff)
+ while (tmp[2] == 0xff && tmp[3] == 0xff)
tmp -= 5;
point1 = S9xGetMemPointer((Memory.C4RAM[0x1f82] << 16) | (tmp[2] << 8) | tmp[3]);
}
diff --git a/source/cheats.c b/source/cheats.c
index 7ddcbfb..2b03078 100644
--- a/source/cheats.c
+++ b/source/cheats.c
@@ -1,7 +1,5 @@
#include "../copyright"
-#ifdef WANT_CHEATS
-
#include <stdio.h>
#include <ctype.h>
#include <string.h>
@@ -16,9 +14,9 @@ static bool S9xAllHex(const char* code, int32_t len)
if ((code [i] < '0' || code [i] > '9') &&
(code [i] < 'a' || code [i] > 'f') &&
(code [i] < 'A' || code [i] > 'F'))
- return (false);
+ return false;
- return (true);
+ return true;
}
const char* S9xProActionReplayToRaw(const char* code, uint32_t* address, uint8_t* byte)
@@ -26,23 +24,23 @@ const char* S9xProActionReplayToRaw(const char* code, uint32_t* address, uint8_t
uint32_t data = 0;
if (strlen(code) != 8 || !S9xAllHex(code, 8) ||
sscanf(code, "%x", &data) != 1)
- return ("Invalid Pro Action Replay code - should be 8 hex digits in length.");
+ return "Invalid Pro Action Replay code - should be 8 hex digits in length.";
*address = data >> 8;
*byte = (uint8_t) data;
- return (NULL);
+ return NULL;
}
const char* S9xGoldFingerToRaw(const char* code, uint32_t* address, bool* sram, uint8_t* num_bytes, uint8_t bytes[3])
{
char tmp [15];
if (strlen(code) != 14)
- return ("Invalid Gold Finger code should be 14 hex digits in length.");
+ return "Invalid Gold Finger code should be 14 hex digits in length.";
strncpy(tmp, code, 5);
tmp [5] = 0;
if (sscanf(tmp, "%x", address) != 1)
- return ("Invalid Gold Finger code.");
+ return "Invalid Gold Finger code.";
int32_t i;
for (i = 0; i < 3; i++)
@@ -56,7 +54,7 @@ const char* S9xGoldFingerToRaw(const char* code, uint32_t* address, bool* sram,
}
*num_bytes = i;
*sram = code [13] == '1';
- return (NULL);
+ return NULL;
}
const char* S9xGameGenieToRaw(const char* code, uint32_t* address, uint8_t* byte)
@@ -64,7 +62,7 @@ const char* S9xGameGenieToRaw(const char* code, uint32_t* address, uint8_t* byte
char new_code [12];
if (strlen(code) != 9 || *(code + 4) != '-' || !S9xAllHex(code, 4) || !S9xAllHex(code + 5, 4))
- return ("Invalid Game Genie(tm) code - should be 'xxxx-xxxx'.");
+ return "Invalid Game Genie(tm) code - should be 'xxxx-xxxx'.";
strcpy(new_code, "0x");
strncpy(new_code + 2, code, 4);
@@ -88,7 +86,7 @@ const char* S9xGameGenieToRaw(const char* code, uint32_t* address, uint8_t* byte
}
}
if (j == 16)
- return ("Invalid hex-character in Game Genie(tm) code");
+ return "Invalid hex-character in Game Genie(tm) code";
}
uint32_t data = 0;
sscanf(new_code, "%x", &data);
@@ -371,5 +369,3 @@ void S9xOutputCheatSearchResults(SCheatData* d)
printf("IRAM: %05x: %02x\n", i, d->FillRAM [i + 0x3000]);
}
}
-
-#endif
diff --git a/source/cheats.h b/source/cheats.h
index 6c3c093..42e2b47 100644
--- a/source/cheats.h
+++ b/source/cheats.h
@@ -3,52 +3,50 @@
#ifndef _CHEATS_H_
#define _CHEATS_H_
-#ifdef WANT_CHEATS
-
#define MAX_SFCCHEAT_NAME 48
-#define MAX_CHEATS_T 800
+#define MAX_CHEATS 800
typedef struct
{
- uint32_t address;
- uint8_t byte;
- uint8_t saved_byte;
- bool enabled;
- bool saved;
- char name[MAX_SFCCHEAT_NAME];
+ uint32_t address;
+ uint8_t byte;
+ uint8_t saved_byte;
+ bool enabled;
+ bool saved;
+ char name[MAX_SFCCHEAT_NAME];
} SCheat;
typedef struct
{
- SCheat c [MAX_CHEATS_T];
- uint32_t num_cheats;
- uint8_t CWRAM [0x20000];
- uint8_t CSRAM [0x10000];
- uint8_t CIRAM [0x2000];
- uint8_t* RAM;
- uint8_t* FillRAM;
- uint8_t* SRAM;
- uint32_t WRAM_BITS [0x20000 >> 3];
- uint32_t SRAM_BITS [0x10000 >> 3];
- uint32_t IRAM_BITS [0x2000 >> 3];
+ SCheat c [MAX_CHEATS];
+ uint32_t num_cheats;
+ uint8_t CWRAM [0x20000];
+ uint8_t CSRAM [0x10000];
+ uint8_t CIRAM [0x2000];
+ uint8_t* RAM;
+ uint8_t* FillRAM;
+ uint8_t* SRAM;
+ uint32_t WRAM_BITS [0x20000 >> 3];
+ uint32_t SRAM_BITS [0x10000 >> 3];
+ uint32_t IRAM_BITS [0x2000 >> 3];
} SCheatData;
typedef enum
{
- S9X_LESS_THAN, S9X_GREATER_THAN, S9X_LESS_THAN_OR_EQUAL,
- S9X_GREATER_THAN_OR_EQUAL, S9X_EQUAL, S9X_NOT_EQUAL
+ S9X_LESS_THAN, S9X_GREATER_THAN, S9X_LESS_THAN_OR_EQUAL,
+ S9X_GREATER_THAN_OR_EQUAL, S9X_EQUAL, S9X_NOT_EQUAL
} S9xCheatComparisonType;
typedef enum
{
- S9X_8_BITS, S9X_16_BITS, S9X_24_BITS, S9X_32_BITS
+ S9X_8_BITS, S9X_16_BITS, S9X_24_BITS, S9X_32_BITS
} S9xCheatDataSize;
void S9xInitCheatData();
-const char *S9xGameGenieToRaw(const char *code, uint32_t *address, uint8_t *byte);
-const char *S9xProActionReplayToRaw(const char *code, uint32_t *address, uint8_t *byte);
-const char *S9xGoldFingerToRaw(const char *code, uint32_t *address, bool *sram, uint8_t *num_bytes, uint8_t bytes[3]);
+const char* S9xGameGenieToRaw(const char* code, uint32_t* address, uint8_t* byte);
+const char* S9xProActionReplayToRaw(const char* code, uint32_t* address, uint8_t* byte);
+const char* S9xGoldFingerToRaw(const char* code, uint32_t* address, bool* sram, uint8_t* num_bytes, uint8_t bytes[3]);
void S9xApplyCheats();
void S9xApplyCheat(uint32_t which1);
void S9xRemoveCheats();
@@ -59,14 +57,12 @@ void S9xDisableAllCheat();
void S9xAddCheat(bool enable, bool save_current_value, uint32_t address, uint8_t byte);
void S9xDeleteCheats();
void S9xDeleteCheat(uint32_t which1);
-bool S9xLoadCheatFile(const char *filename);
-bool S9xSaveCheatFile(const char *filename);
-
-void S9xStartCheatSearch(SCheatData *cheats);
-void S9xSearchForChange(SCheatData *cheats, S9xCheatComparisonType cmp, S9xCheatDataSize size, bool is_signed, bool update);
-void S9xSearchForValue(SCheatData *cheats, S9xCheatComparisonType cmp, S9xCheatDataSize size, uint32_t value, bool is_signed, bool update);
-void S9xOutputCheatSearchResults(SCheatData *cheats);
+bool S9xLoadCheatFile(const char* filename);
+bool S9xSaveCheatFile(const char* filename);
-#endif
+void S9xStartCheatSearch(SCheatData* cheats);
+void S9xSearchForChange(SCheatData* cheats, S9xCheatComparisonType cmp, S9xCheatDataSize size, bool is_signed, bool update);
+void S9xSearchForValue(SCheatData* cheats, S9xCheatComparisonType cmp, S9xCheatDataSize size, uint32_t value, bool is_signed, bool update);
+void S9xOutputCheatSearchResults(SCheatData* cheats);
#endif
diff --git a/source/cheats2.c b/source/cheats2.c
index dd4033f..977daf6 100644
--- a/source/cheats2.c
+++ b/source/cheats2.c
@@ -1,7 +1,5 @@
#include "../copyright"
-#ifdef WANT_CHEATS
-
#include <stdio.h>
#include <ctype.h>
#include <string.h>
@@ -18,8 +16,7 @@ void S9xInitCheatData()
Cheat.FillRAM = Memory.FillRAM;
}
-void S9xAddCheat(bool enable, bool save_current_value,
- uint32_t address, uint8_t byte)
+void S9xAddCheat(bool enable, bool save_current_value, uint32_t address, uint8_t byte)
{
if (Cheat.num_cheats < sizeof(Cheat.c) / sizeof(Cheat.c [0]))
{
@@ -45,9 +42,8 @@ void S9xDeleteCheat(uint32_t which1)
S9xRemoveCheat(which1);
// memmove required: Overlapping addresses [Neb]
- memmove(&Cheat.c [which1], &Cheat.c [which1 + 1],
- sizeof(Cheat.c [0]) * (Cheat.num_cheats - which1 - 1));
- Cheat.num_cheats--; //MK: This used to set it to 0??
+ memmove(&Cheat.c [which1], &Cheat.c [which1 + 1], sizeof(Cheat.c [0]) * (Cheat.num_cheats - which1 - 1));
+ Cheat.num_cheats--;
}
}
@@ -204,5 +200,3 @@ bool S9xSaveCheatFile(const char* filename)
fclose(fs);
return (true);
}
-
-#endif
diff --git a/source/clip.c b/source/clip.c
index 1a52bea..c579b77 100644
--- a/source/clip.c
+++ b/source/clip.c
@@ -6,11 +6,11 @@
#include "memmap.h"
#include "ppu.h"
-struct Band
+typedef struct
{
uint32_t Left;
uint32_t Right;
-};
+} Band;
#define BAND_EMPTY(B) (B.Left >= B.Right)
#define BANDS_INTERSECT(A,B) ((A.Left >= B.Left && A.Left < B.Right) || \
@@ -25,25 +25,17 @@ struct Band
static int32_t IntCompare(const void* d1, const void* d2)
{
- if (*(uint32_t*) d1 > *(uint32_t*) d2)
- return (1);
- else if (*(uint32_t*) d1 < * (uint32_t*) d2)
- return (-1);
- return (0);
+ return (*(uint32_t*) d1 - * (uint32_t*) d2);
}
static int32_t BandCompare(const void* d1, const void* d2)
{
- if (((struct Band*) d1)->Left > ((struct Band*) d2)->Left)
- return (1);
- else if (((struct Band*) d1)->Left < ((struct Band*) d2)->Left)
- return (-1);
- return (0);
+ return (((Band*) d1)->Left - ((Band*) d2)->Left);
}
void ComputeClipWindows()
{
- struct ClipData* pClip = &IPPU.Clip [0];
+ ClipData* pClip = &IPPU.Clip [0];
int32_t c, w, i;
// Loop around the main screen then the sub-screen.
@@ -98,16 +90,15 @@ void ComputeClipWindows()
if (w == 5 || pClip->Count [5] ||
(Memory.FillRAM [0x212c + c] & Memory.FillRAM [0x212e + c] & (1 << w)))
{
- struct Band Win1[3];
- struct Band Win2[3];
+ Band Win1[3];
+ Band Win2[3];
uint32_t Window1Enabled = 0;
uint32_t Window2Enabled = 0;
bool invert = (w == 5 &&
((c == 1 && (Memory.FillRAM [0x2130] & 0x30) == 0x10) ||
- (c == 0 && (Memory.FillRAM [0x2130] & 0xc0) == 0x40)));
+ (c == 0 && (Memory.FillRAM [0x2130] & 0xc0) == 0x40)));
- if (w == 5 ||
- (Memory.FillRAM [0x212c + c] & Memory.FillRAM [0x212e + c] & (1 << w)))
+ if (w == 5 || (Memory.FillRAM [0x212c + c] & Memory.FillRAM [0x212e + c] & (1 << w)))
{
if (PPU.ClipWindow1Enable [w])
{
@@ -188,7 +179,7 @@ void ComputeClipWindows()
// 1. <no range> (Left > Right. One band)
// 2. | ---------------- | (Left >= 0, Right <= 255, Left <= Right. One band)
// 3. |------------ ----------| (Left1 == 0, Right1 < Left2; Left2 > Right1, Right2 == 255. Two bands)
- struct Band Bands [6];
+ Band Bands [6];
int32_t B = 0;
switch (PPU.ClipWindowOverlapLogic [w] ^ 1)
{
@@ -630,16 +621,15 @@ void ComputeClipWindows()
{
// Intersect the colour window with the bg's
// own clip window.
- uint32_t i;
+ uint32_t i, j;
for (i = 0; i < pClip->Count [w]; i++)
{
- uint32_t j;
for (j = 0; j < pClip->Count [5]; j++)
{
- if ((pClip->Left[i][w] >= pClip->Left[j][5]
- && pClip->Left[i][w] < pClip->Right[j][5])
- || (pClip->Left[j][5] >= pClip->Left[i][w]
- && pClip->Left[j][5] < pClip->Right[i][w]))
+ if ((pClip->Left[i][w] >= pClip->Left[j][5] &&
+ pClip->Left[i][w] < pClip->Right[j][5]) ||
+ (pClip->Left[j][5] >= pClip->Left[i][w] &&
+ pClip->Left[j][5] < pClip->Right[i][w]))
{
// Found an intersection!
pClip->Left[i][w] = MAX(pClip->Left[i][w], pClip->Left[j][5]);
diff --git a/source/cpu.c b/source/cpu.c
index 15206c5..1724fd6 100644
--- a/source/cpu.c
+++ b/source/cpu.c
@@ -15,11 +15,10 @@
#include "spc7110.h"
#include "obc1.h"
-extern struct FxInit_s SuperFX;
+extern FxInit_s SuperFX;
void S9xResetSuperFX()
{
- SuperFX.vFlags = 0;
FxReset(&SuperFX);
}
@@ -57,9 +56,7 @@ void S9xResetCPU()
CPU.V_Counter = 0;
CPU.MemSpeed = SLOW_ONE_CYCLE;
CPU.MemSpeedx2 = SLOW_ONE_CYCLE * 2;
- CPU.AutoSaveTimer = 0;
CPU.SRAMModified = false;
- CPU.BRKTriggered = false;
CPU.NMICycleCount = 0;
CPU.IRQCycleCount = 0;
S9xSetPCBase(ICPU.Registers.PC);
@@ -94,9 +91,7 @@ static void CommonS9xReset()
if (Settings.C4)
S9xInitC4();
-#ifdef WANT_CHEATS
S9xInitCheatData();
-#endif
}
void S9xReset()
diff --git a/source/cpuaddr.h b/source/cpuaddr.h
index 1085921..94cb6f0 100644
--- a/source/cpuaddr.h
+++ b/source/cpuaddr.h
@@ -195,7 +195,7 @@ static inline void DirectIndexedX(bool read)
#endif
}
-static void DirectIndexedY(bool read)
+static inline void DirectIndexedY(bool read)
{
if (read)
OpenBus = *CPU.PC;
diff --git a/source/cpuexec.c b/source/cpuexec.c
index d7151be..98e321f 100644
--- a/source/cpuexec.c
+++ b/source/cpuexec.c
@@ -6,17 +6,16 @@
#include "ppu.h"
#include "cpuexec.h"
#include "gfx.h"
-#include "missing.h"
#include "apu.h"
#include "dma.h"
#include "fxemu.h"
#include "sa1.h"
#include "spc7110.h"
-void S9xMainLoop_SA1_SFX();
-void S9xMainLoop_SA1_NoSFX();
-void S9xMainLoop_NoSA1_SFX();
-void S9xMainLoop_NoSA1_NoSFX();
+void S9xMainLoop_SA1_SFX(void);
+void S9xMainLoop_SA1_NoSFX(void);
+void S9xMainLoop_NoSA1_SFX(void);
+void S9xMainLoop_NoSA1_NoSFX(void);
/*
* This is a CATSFC modification inspired by a Snes9x-Euphoria modification.
@@ -31,13 +30,17 @@ void S9xMainLoop()
{
if (Settings.SA1)
{
- if (Settings.SuperFX) S9xMainLoop_SA1_SFX();
- else S9xMainLoop_SA1_NoSFX();
+ if (Settings.SuperFX)
+ S9xMainLoop_SA1_SFX();
+ else
+ S9xMainLoop_SA1_NoSFX();
}
else
{
- if (Settings.SuperFX) S9xMainLoop_NoSA1_SFX();
- else S9xMainLoop_NoSA1_NoSFX();
+ if (Settings.SuperFX)
+ S9xMainLoop_NoSA1_SFX();
+ else
+ S9xMainLoop_NoSA1_NoSFX();
}
}
@@ -86,9 +89,7 @@ void S9xMainLoop_SA1_SFX()
break;
}
-#ifdef CPU_SHUTDOWN
CPU.PCAtOpcodeStart = CPU.PC;
-#endif
CPU.Cycles += CPU.MemSpeed;
(*ICPU.S9xOpcodes [*CPU.PC++].S9xOpcode)();
@@ -103,8 +104,7 @@ void S9xMainLoop_SA1_SFX()
IAPU.Registers.PC = IAPU.PC - IAPU.RAM;
S9xAPUPackStatus();
#endif
- if (CPU.Flags & SCAN_KEYS_FLAG)
- CPU.Flags &= ~SCAN_KEYS_FLAG;
+ CPU.Flags &= ~SCAN_KEYS_FLAG;
}
void S9xMainLoop_SA1_NoSFX()
@@ -152,9 +152,7 @@ void S9xMainLoop_SA1_NoSFX()
break;
}
-#ifdef CPU_SHUTDOWN
CPU.PCAtOpcodeStart = CPU.PC;
-#endif
CPU.Cycles += CPU.MemSpeed;
(*ICPU.S9xOpcodes [*CPU.PC++].S9xOpcode)();
@@ -169,8 +167,7 @@ void S9xMainLoop_SA1_NoSFX()
IAPU.Registers.PC = IAPU.PC - IAPU.RAM;
S9xAPUPackStatus();
#endif
- if (CPU.Flags & SCAN_KEYS_FLAG)
- CPU.Flags &= ~SCAN_KEYS_FLAG;
+ CPU.Flags &= ~SCAN_KEYS_FLAG;
}
void S9xMainLoop_NoSA1_SFX()
@@ -218,9 +215,7 @@ void S9xMainLoop_NoSA1_SFX()
break;
}
-#ifdef CPU_SHUTDOWN
CPU.PCAtOpcodeStart = CPU.PC;
-#endif
CPU.Cycles += CPU.MemSpeed;
(*ICPU.S9xOpcodes [*CPU.PC++].S9xOpcode)();
DO_HBLANK_CHECK_SFX();
@@ -232,8 +227,7 @@ void S9xMainLoop_NoSA1_SFX()
IAPU.Registers.PC = IAPU.PC - IAPU.RAM;
S9xAPUPackStatus();
#endif
- if (CPU.Flags & SCAN_KEYS_FLAG)
- CPU.Flags &= ~SCAN_KEYS_FLAG;
+ CPU.Flags &= ~SCAN_KEYS_FLAG;
}
void S9xMainLoop_NoSA1_NoSFX()
@@ -281,9 +275,7 @@ void S9xMainLoop_NoSA1_NoSFX()
break;
}
-#ifdef CPU_SHUTDOWN
CPU.PCAtOpcodeStart = CPU.PC;
-#endif
CPU.Cycles += CPU.MemSpeed;
(*ICPU.S9xOpcodes [*CPU.PC++].S9xOpcode)();
DO_HBLANK_CHECK_NoSFX();
@@ -295,8 +287,7 @@ void S9xMainLoop_NoSA1_NoSFX()
IAPU.Registers.PC = IAPU.PC - IAPU.RAM;
S9xAPUPackStatus();
#endif
- if (CPU.Flags & SCAN_KEYS_FLAG)
- CPU.Flags &= ~SCAN_KEYS_FLAG;
+ CPU.Flags &= ~SCAN_KEYS_FLAG;
}
void S9xSetIRQ(uint32_t source)
@@ -329,19 +320,15 @@ void S9xClearIRQ(uint32_t source)
*/
void S9xDoHBlankProcessing_SFX()
{
-#ifdef CPU_SHUTDOWN
CPU.WaitCounter++;
-#endif
switch (CPU.WhichEvent)
{
case HBLANK_START_EVENT:
if (IPPU.HDMA && CPU.V_Counter <= PPU.ScreenHeight)
IPPU.HDMA = S9xDoHDMA(IPPU.HDMA);
break;
-
case HBLANK_END_EVENT:
S9xSuperFXExec();
-
#ifndef USE_BLARGG_APU
CPU.Cycles -= Settings.H_Max;
if (IAPU.APUExecuting)
@@ -354,7 +341,6 @@ void S9xDoHBlankProcessing_SFX()
S9xAPUSetReferenceTime(CPU.Cycles);
#endif
CPU.NextEvent = -1;
- ICPU.Scanline++;
if (++CPU.V_Counter >= (Settings.PAL ? SNES_MAX_PAL_VCOUNTER : SNES_MAX_NTSC_VCOUNTER))
{
@@ -363,7 +349,6 @@ void S9xDoHBlankProcessing_SFX()
PPU.RangeTimeOver = 0;
CPU.NMIActive = false;
ICPU.Frame++;
- PPU.HVBeamCounterLatched = 0;
CPU.Flags |= SCAN_KEYS_FLAG;
S9xStartHDMA();
}
@@ -377,8 +362,6 @@ void S9xDoHBlankProcessing_SFX()
S9xEndScreenRefresh();
IPPU.HDMA = 0;
// Bits 7 and 6 of $4212 are computed when read in S9xGetPPU.
- missing.dma_this_frame = 0;
- IPPU.MaxBrightness = PPU.Brightness;
PPU.ForcedBlanking = (Memory.FillRAM [0x2100] >> 7) & 1;
if (!PPU.ForcedBlanking)
@@ -418,13 +401,7 @@ void S9xDoHBlankProcessing_SFX()
if (CPU.V_Counter >= FIRST_VISIBLE_LINE &&
CPU.V_Counter < PPU.ScreenHeight + FIRST_VISIBLE_LINE)
RenderLine(CPU.V_Counter - FIRST_VISIBLE_LINE);
-
#ifndef USE_BLARGG_APU
- // Use TimerErrorCounter to skip update of SPC700 timers once
- // every 128 updates. Needed because this section of code is called
- // once every emulated 63.5 microseconds, which coresponds to
- // 15.750KHz, but the SPC700 timers need to be updated at multiples
- // of 8KHz, hence the error correction.
{
if (APU.TimerEnabled [2])
{
@@ -433,10 +410,8 @@ void S9xDoHBlankProcessing_SFX()
{
IAPU.RAM [0xff] = (IAPU.RAM [0xff] + 1) & 0xf;
APU.Timer [2] -= APU.TimerTarget [2];
-#ifdef SPC700_SHUTDOWN
IAPU.WaitCounter++;
IAPU.APUExecuting = true;
-#endif
}
}
if (CPU.V_Counter & 1)
@@ -448,10 +423,8 @@ void S9xDoHBlankProcessing_SFX()
{
IAPU.RAM [0xfd] = (IAPU.RAM [0xfd] + 1) & 0xf;
APU.Timer [0] = 0;
-#ifdef SPC700_SHUTDOWN
IAPU.WaitCounter++;
IAPU.APUExecuting = true;
-#endif
}
}
if (APU.TimerEnabled [1])
@@ -461,41 +434,34 @@ void S9xDoHBlankProcessing_SFX()
{
IAPU.RAM [0xfe] = (IAPU.RAM [0xfe] + 1) & 0xf;
APU.Timer [1] = 0;
-#ifdef SPC700_SHUTDOWN
IAPU.WaitCounter++;
IAPU.APUExecuting = true;
-#endif
}
}
}
}
-#endif // #ifndef USE_BLARGG_APU
+#endif
break;
-
case HTIMER_BEFORE_EVENT:
case HTIMER_AFTER_EVENT:
- if (PPU.HTimerEnabled && (!PPU.VTimerEnabled
- || CPU.V_Counter == PPU.IRQVBeamPos))
+ if (PPU.HTimerEnabled && (!PPU.VTimerEnabled || CPU.V_Counter == PPU.IRQVBeamPos))
S9xSetIRQ(PPU_H_BEAM_IRQ_SOURCE);
break;
}
S9xReschedule();
}
+
void S9xDoHBlankProcessing_NoSFX()
{
-#ifdef CPU_SHUTDOWN
CPU.WaitCounter++;
-#endif
switch (CPU.WhichEvent)
{
case HBLANK_START_EVENT:
if (IPPU.HDMA && CPU.V_Counter <= PPU.ScreenHeight)
IPPU.HDMA = S9xDoHDMA(IPPU.HDMA);
break;
-
case HBLANK_END_EVENT:
-
#ifndef USE_BLARGG_APU
CPU.Cycles -= Settings.H_Max;
if (IAPU.APUExecuting)
@@ -507,9 +473,7 @@ void S9xDoHBlankProcessing_NoSFX()
CPU.Cycles -= Settings.H_Max;
S9xAPUSetReferenceTime(CPU.Cycles);
#endif
-
CPU.NextEvent = -1;
- ICPU.Scanline++;
if (++CPU.V_Counter >= (Settings.PAL ? SNES_MAX_PAL_VCOUNTER : SNES_MAX_NTSC_VCOUNTER))
{
@@ -518,7 +482,6 @@ void S9xDoHBlankProcessing_NoSFX()
PPU.RangeTimeOver = 0;
CPU.NMIActive = false;
ICPU.Frame++;
- PPU.HVBeamCounterLatched = 0;
CPU.Flags |= SCAN_KEYS_FLAG;
S9xStartHDMA();
}
@@ -532,8 +495,6 @@ void S9xDoHBlankProcessing_NoSFX()
S9xEndScreenRefresh();
IPPU.HDMA = 0;
// Bits 7 and 6 of $4212 are computed when read in S9xGetPPU.
- missing.dma_this_frame = 0;
- IPPU.MaxBrightness = PPU.Brightness;
PPU.ForcedBlanking = (Memory.FillRAM [0x2100] >> 7) & 1;
if (!PPU.ForcedBlanking)
@@ -573,11 +534,6 @@ void S9xDoHBlankProcessing_NoSFX()
if (CPU.V_Counter >= FIRST_VISIBLE_LINE &&
CPU.V_Counter < PPU.ScreenHeight + FIRST_VISIBLE_LINE)
RenderLine(CPU.V_Counter - FIRST_VISIBLE_LINE);
- // Use TimerErrorCounter to skip update of SPC700 timers once
- // every 128 updates. Needed because this section of code is called
- // once every emulated 63.5 microseconds, which coresponds to
- // 15.750KHz, but the SPC700 timers need to be updated at multiples
- // of 8KHz, hence the error correction.
#ifndef USE_BLARGG_APU
{
if (APU.TimerEnabled [2])
@@ -587,10 +543,8 @@ void S9xDoHBlankProcessing_NoSFX()
{
IAPU.RAM [0xff] = (IAPU.RAM [0xff] + 1) & 0xf;
APU.Timer [2] -= APU.TimerTarget [2];
-#ifdef SPC700_SHUTDOWN
IAPU.WaitCounter++;
IAPU.APUExecuting = true;
-#endif
}
}
if (CPU.V_Counter & 1)
@@ -602,10 +556,8 @@ void S9xDoHBlankProcessing_NoSFX()
{
IAPU.RAM [0xfd] = (IAPU.RAM [0xfd] + 1) & 0xf;
APU.Timer [0] = 0;
-#ifdef SPC700_SHUTDOWN
IAPU.WaitCounter++;
IAPU.APUExecuting = true;
-#endif
}
}
if (APU.TimerEnabled [1])
@@ -615,10 +567,8 @@ void S9xDoHBlankProcessing_NoSFX()
{
IAPU.RAM [0xfe] = (IAPU.RAM [0xfe] + 1) & 0xf;
APU.Timer [1] = 0;
-#ifdef SPC700_SHUTDOWN
IAPU.WaitCounter++;
IAPU.APUExecuting = true;
-#endif
}
}
}
diff --git a/source/cpuexec.h b/source/cpuexec.h
index d6a1db0..7d4008c 100644
--- a/source/cpuexec.h
+++ b/source/cpuexec.h
@@ -18,15 +18,15 @@ typedef struct
#define DO_HBLANK_CHECK_SFX() \
if (CPU.Cycles >= CPU.NextEvent) \
- S9xDoHBlankProcessing_SFX ();
+ S9xDoHBlankProcessing_SFX ();
#define DO_HBLANK_CHECK_NoSFX() \
if (CPU.Cycles >= CPU.NextEvent) \
- S9xDoHBlankProcessing_NoSFX ();
+ S9xDoHBlankProcessing_NoSFX ();
typedef struct
{
- uint8_t* Speed;
+ uint8_t* UNUSED1;
SOpcodes* S9xOpcodes;
SRegisters Registers;
uint8_t _Carry;
@@ -37,19 +37,19 @@ typedef struct
uint32_t ShiftedPB;
uint32_t ShiftedDB;
uint32_t Frame;
- uint32_t Scanline;
- uint32_t FrameAdvanceCount;
+ uint32_t UNUSED2;
+ uint32_t UNUSED3;
} SICPU;
-void S9xMainLoop();
-void S9xReset();
-void S9xSoftReset();
-void S9xDoHBlankProcessing_SFX();
-void S9xDoHBlankProcessing_NoSFX();
-void S9xClearIRQ(uint32_t);
-void S9xSetIRQ(uint32_t);
+void S9xMainLoop(void);
+void S9xReset(void);
+void S9xSoftReset(void);
+void S9xDoHBlankProcessing_SFX(void);
+void S9xDoHBlankProcessing_NoSFX(void);
+void S9xClearIRQ(uint32_t source);
+void S9xSetIRQ(uint32_t source);
-extern SOpcodes S9xOpcodesE1 [256];
+extern SOpcodes S9xOpcodesE1 [256];
extern SOpcodes S9xOpcodesM1X1 [256];
extern SOpcodes S9xOpcodesM1X0 [256];
extern SOpcodes S9xOpcodesM0X1 [256];
diff --git a/source/cpumacro.h b/source/cpumacro.h
index 5868fed..7712e49 100644
--- a/source/cpumacro.h
+++ b/source/cpumacro.h
@@ -119,7 +119,6 @@ static inline void ADC16()
else
{
uint32_t Ans32 = ICPU.Registers.A.W + Work16 + CheckCarry();
-
ICPU._Carry = Ans32 > 0xffff;
if (~(ICPU.Registers.A.W ^ Work16) & (Work16 ^ (uint16_t) Ans32) & 0x8000)
@@ -251,9 +250,7 @@ static inline void A_DEC16()
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#endif
-#ifdef CPU_SHUTDOWN
CPU.WaitAddress = NULL;
-#endif
ICPU.Registers.A.W--;
SetZN16(ICPU.Registers.A.W);
}
@@ -263,9 +260,7 @@ static inline void A_DEC8()
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#endif
-#ifdef CPU_SHUTDOWN
CPU.WaitAddress = NULL;
-#endif
ICPU.Registers.AL--;
SetZN8(ICPU.Registers.AL);
}
@@ -275,9 +270,7 @@ static inline void DEC16()
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#endif
-#ifdef CPU_SHUTDOWN
CPU.WaitAddress = NULL;
-#endif
uint16_t Work16 = S9xGetWord(OpAddress) - 1;
S9xSetByte(Work16 >> 8, OpAddress + 1);
S9xSetByte(Work16 & 0xFF, OpAddress);
@@ -289,9 +282,7 @@ static inline void DEC8()
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#endif
-#ifdef CPU_SHUTDOWN
CPU.WaitAddress = NULL;
-#endif
uint8_t Work8 = S9xGetByte(OpAddress) - 1;
S9xSetByte(Work8, OpAddress);
SetZN8(Work8);
@@ -314,9 +305,7 @@ static inline void A_INC16()
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#endif
-#ifdef CPU_SHUTDOWN
CPU.WaitAddress = NULL;
-#endif
ICPU.Registers.A.W++;
SetZN16(ICPU.Registers.A.W);
}
@@ -326,9 +315,7 @@ static inline void A_INC8()
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#endif
-#ifdef CPU_SHUTDOWN
CPU.WaitAddress = NULL;
-#endif
ICPU.Registers.AL++;
SetZN8(ICPU.Registers.AL);
}
@@ -338,9 +325,7 @@ static inline void INC16()
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#endif
-#ifdef CPU_SHUTDOWN
CPU.WaitAddress = NULL;
-#endif
uint16_t Work16 = S9xGetWord(OpAddress) + 1;
S9xSetByte(Work16 >> 8, OpAddress + 1);
S9xSetByte(Work16 & 0xFF, OpAddress);
@@ -352,9 +337,7 @@ static inline void INC8()
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#endif
-#ifdef CPU_SHUTDOWN
CPU.WaitAddress = NULL;
-#endif
uint8_t Work8 = S9xGetByte(OpAddress) + 1;
S9xSetByte(Work8, OpAddress);
SetZN8(Work8);
diff --git a/source/cpuops.c b/source/cpuops.c
index 0b92901..c86d9c1 100644
--- a/source/cpuops.c
+++ b/source/cpuops.c
@@ -7,11 +7,9 @@
#include "snes9x.h"
#include "memmap.h"
-#include "missing.h"
#include "apu.h"
#include "sa1.h"
#include "spc7110.h"
-
#include "cpuexec.h"
#include "cpuaddr.h"
#include "cpuops.h"
@@ -21,181 +19,181 @@
int32_t OpAddress;
/* ADC *************************************************************************************** */
-static void Op69M1()
+static void Op69M1(void)
{
Immediate8();
ADC8();
}
-static void Op69M0()
+static void Op69M0(void)
{
Immediate16();
ADC16();
}
-static void Op65M1()
+static void Op65M1(void)
{
Direct(true);
ADC8();
}
-static void Op65M0()
+static void Op65M0(void)
{
Direct(true);
ADC16();
}
-static void Op75M1()
+static void Op75M1(void)
{
DirectIndexedX(true);
ADC8();
}
-static void Op75M0()
+static void Op75M0(void)
{
DirectIndexedX(true);
ADC16();
}
-static void Op72M1()
+static void Op72M1(void)
{
DirectIndirect(true);
ADC8();
}
-static void Op72M0()
+static void Op72M0(void)
{
DirectIndirect(true);
ADC16();
}
-static void Op61M1()
+static void Op61M1(void)
{
DirectIndexedIndirect(true);
ADC8();
}
-static void Op61M0()
+static void Op61M0(void)
{
DirectIndexedIndirect(true);
ADC16();
}
-static void Op71M1()
+static void Op71M1(void)
{
DirectIndirectIndexed(true);
ADC8();
}
-static void Op71M0()
+static void Op71M0(void)
{
DirectIndirectIndexed(true);
ADC16();
}
-static void Op67M1()
+static void Op67M1(void)
{
DirectIndirectLong(true);
ADC8();
}
-static void Op67M0()
+static void Op67M0(void)
{
DirectIndirectLong(true);
ADC16();
}
-static void Op77M1()
+static void Op77M1(void)
{
DirectIndirectIndexedLong(true);
ADC8();
}
-static void Op77M0()
+static void Op77M0(void)
{
DirectIndirectIndexedLong(true);
ADC16();
}
-static void Op6DM1()
+static void Op6DM1(void)
{
Absolute(true);
ADC8();
}
-static void Op6DM0()
+static void Op6DM0(void)
{
Absolute(true);
ADC16();
}
-static void Op7DM1()
+static void Op7DM1(void)
{
AbsoluteIndexedX(true);
ADC8();
}
-static void Op7DM0()
+static void Op7DM0(void)
{
AbsoluteIndexedX(true);
ADC16();
}
-static void Op79M1()
+static void Op79M1(void)
{
AbsoluteIndexedY(true);
ADC8();
}
-static void Op79M0()
+static void Op79M0(void)
{
AbsoluteIndexedY(true);
ADC16();
}
-static void Op6FM1()
+static void Op6FM1(void)
{
AbsoluteLong(true);
ADC8();
}
-static void Op6FM0()
+static void Op6FM0(void)
{
AbsoluteLong(true);
ADC16();
}
-static void Op7FM1()
+static void Op7FM1(void)
{
AbsoluteLongIndexedX(true);
ADC8();
}
-static void Op7FM0()
+static void Op7FM0(void)
{
AbsoluteLongIndexedX(true);
ADC16();
}
-static void Op63M1()
+static void Op63M1(void)
{
StackRelative(true);
ADC8();
}
-static void Op63M0()
+static void Op63M0(void)
{
StackRelative(true);
ADC16();
}
-static void Op73M1()
+static void Op73M1(void)
{
StackRelativeIndirectIndexed(true);
ADC8();
}
-static void Op73M0()
+static void Op73M0(void)
{
StackRelativeIndirectIndexed(true);
ADC16();
@@ -204,7 +202,7 @@ static void Op73M0()
/**********************************************************************************************/
/* AND *************************************************************************************** */
-static void Op29M1()
+static void Op29M1(void)
{
ICPU.Registers.AL &= *CPU.PC++;
#ifndef SA1_OPCODES
@@ -213,7 +211,7 @@ static void Op29M1()
SetZN8(ICPU.Registers.AL);
}
-static void Op29M0()
+static void Op29M0(void)
{
#ifdef FAST_LSB_WORD_ACCESS
ICPU.Registers.A.W &= *(uint16_t*) CPU.PC;
@@ -227,169 +225,169 @@ static void Op29M0()
SetZN16(ICPU.Registers.A.W);
}
-static void Op25M1()
+static void Op25M1(void)
{
Direct(true);
AND8();
}
-static void Op25M0()
+static void Op25M0(void)
{
Direct(true);
AND16();
}
-static void Op35M1()
+static void Op35M1(void)
{
DirectIndexedX(true);
AND8();
}
-static void Op35M0()
+static void Op35M0(void)
{
DirectIndexedX(true);
AND16();
}
-static void Op32M1()
+static void Op32M1(void)
{
DirectIndirect(true);
AND8();
}
-static void Op32M0()
+static void Op32M0(void)
{
DirectIndirect(true);
AND16();
}
-static void Op21M1()
+static void Op21M1(void)
{
DirectIndexedIndirect(true);
AND8();
}
-static void Op21M0()
+static void Op21M0(void)
{
DirectIndexedIndirect(true);
AND16();
}
-static void Op31M1()
+static void Op31M1(void)
{
DirectIndirectIndexed(true);
AND8();
}
-static void Op31M0()
+static void Op31M0(void)
{
DirectIndirectIndexed(true);
AND16();
}
-static void Op27M1()
+static void Op27M1(void)
{
DirectIndirectLong(true);
AND8();
}
-static void Op27M0()
+static void Op27M0(void)
{
DirectIndirectLong(true);
AND16();
}
-static void Op37M1()
+static void Op37M1(void)
{
DirectIndirectIndexedLong(true);
AND8();
}
-static void Op37M0()
+static void Op37M0(void)
{
DirectIndirectIndexedLong(true);
AND16();
}
-static void Op2DM1()
+static void Op2DM1(void)
{
Absolute(true);
AND8();
}
-static void Op2DM0()
+static void Op2DM0(void)
{
Absolute(true);
AND16();
}
-static void Op3DM1()
+static void Op3DM1(void)
{
AbsoluteIndexedX(true);
AND8();
}
-static void Op3DM0()
+static void Op3DM0(void)
{
AbsoluteIndexedX(true);
AND16();
}
-static void Op39M1()
+static void Op39M1(void)
{
AbsoluteIndexedY(true);
AND8();
}
-static void Op39M0()
+static void Op39M0(void)
{
AbsoluteIndexedY(true);
AND16();
}
-static void Op2FM1()
+static void Op2FM1(void)
{
AbsoluteLong(true);
AND8();
}
-static void Op2FM0()
+static void Op2FM0(void)
{
AbsoluteLong(true);
AND16();
}
-static void Op3FM1()
+static void Op3FM1(void)
{
AbsoluteLongIndexedX(true);
AND8();
}
-static void Op3FM0()
+static void Op3FM0(void)
{
AbsoluteLongIndexedX(true);
AND16();
}
-static void Op23M1()
+static void Op23M1(void)
{
StackRelative(true);
AND8();
}
-static void Op23M0()
+static void Op23M0(void)
{
StackRelative(true);
AND16();
}
-static void Op33M1()
+static void Op33M1(void)
{
StackRelativeIndirectIndexed(true);
AND8();
}
-static void Op33M0()
+static void Op33M0(void)
{
StackRelativeIndirectIndexed(true);
AND16();
@@ -397,59 +395,59 @@ static void Op33M0()
/**********************************************************************************************/
/* ASL *************************************************************************************** */
-static void Op0AM1()
+static void Op0AM1(void)
{
A_ASL8();
}
-static void Op0AM0()
+static void Op0AM0(void)
{
A_ASL16();
}
-static void Op06M1()
+static void Op06M1(void)
{
Direct(false);
ASL8();
}
-static void Op06M0()
+static void Op06M0(void)
{
Direct(false);
ASL16();
}
-static void Op16M1()
+static void Op16M1(void)
{
DirectIndexedX(false);
ASL8();
}
-static void Op16M0()
+static void Op16M0(void)
{
DirectIndexedX(false);
ASL16();
}
-static void Op0EM1()
+static void Op0EM1(void)
{
Absolute(false);
ASL8();
}
-static void Op0EM0()
+static void Op0EM0(void)
{
Absolute(false);
ASL16();
}
-static void Op1EM1()
+static void Op1EM1(void)
{
AbsoluteIndexedX(false);
ASL8();
}
-static void Op1EM0()
+static void Op1EM0(void)
{
AbsoluteIndexedX(false);
ASL16();
@@ -457,7 +455,7 @@ static void Op1EM0()
/**********************************************************************************************/
/* BIT *************************************************************************************** */
-static void Op89M1()
+static void Op89M1(void)
{
ICPU._Zero = ICPU.Registers.AL & *CPU.PC++;
#ifndef SA1_OPCODES
@@ -465,7 +463,7 @@ static void Op89M1()
#endif
}
-static void Op89M0()
+static void Op89M0(void)
{
#ifdef FAST_LSB_WORD_ACCESS
ICPU._Zero = (ICPU.Registers.A.W & *(uint16_t*) CPU.PC) != 0;
@@ -478,49 +476,49 @@ static void Op89M0()
CPU.PC += 2;
}
-static void Op24M1()
+static void Op24M1(void)
{
Direct(true);
BIT8();
}
-static void Op24M0()
+static void Op24M0(void)
{
Direct(true);
BIT16();
}
-static void Op34M1()
+static void Op34M1(void)
{
DirectIndexedX(true);
BIT8();
}
-static void Op34M0()
+static void Op34M0(void)
{
DirectIndexedX(true);
BIT16();
}
-static void Op2CM1()
+static void Op2CM1(void)
{
Absolute(true);
BIT8();
}
-static void Op2CM0()
+static void Op2CM0(void)
{
Absolute(true);
BIT16();
}
-static void Op3CM1()
+static void Op3CM1(void)
{
AbsoluteIndexedX(true);
BIT8();
}
-static void Op3CM0()
+static void Op3CM0(void)
{
AbsoluteIndexedX(true);
BIT16();
@@ -528,7 +526,7 @@ static void Op3CM0()
/**********************************************************************************************/
/* CMP *************************************************************************************** */
-static void OpC9M1()
+static void OpC9M1(void)
{
int32_t Int32 = (int32_t) ICPU.Registers.AL - (int32_t) *CPU.PC++;
ICPU._Carry = Int32 >= 0;
@@ -538,7 +536,7 @@ static void OpC9M1()
#endif
}
-static void OpC9M0()
+static void OpC9M0(void)
{
#ifdef FAST_LSB_WORD_ACCESS
int32_t Int32 = (int32_t) ICPU.Registers.A.W - (int32_t) *(uint16_t*)CPU.PC;
@@ -553,169 +551,169 @@ static void OpC9M0()
#endif
}
-static void OpC5M1()
+static void OpC5M1(void)
{
Direct(true);
CMP8();
}
-static void OpC5M0()
+static void OpC5M0(void)
{
Direct(true);
CMP16();
}
-static void OpD5M1()
+static void OpD5M1(void)
{
DirectIndexedX(true);
CMP8();
}
-static void OpD5M0()
+static void OpD5M0(void)
{
DirectIndexedX(true);
CMP16();
}
-static void OpD2M1()
+static void OpD2M1(void)
{
DirectIndirect(true);
CMP8();
}
-static void OpD2M0()
+static void OpD2M0(void)
{
DirectIndirect(true);
CMP16();
}
-static void OpC1M1()
+static void OpC1M1(void)
{
DirectIndexedIndirect(true);
CMP8();
}
-static void OpC1M0()
+static void OpC1M0(void)
{
DirectIndexedIndirect(true);
CMP16();
}
-static void OpD1M1()
+static void OpD1M1(void)
{
DirectIndirectIndexed(true);
CMP8();
}
-static void OpD1M0()
+static void OpD1M0(void)
{
DirectIndirectIndexed(true);
CMP16();
}
-static void OpC7M1()
+static void OpC7M1(void)
{
DirectIndirectLong(true);
CMP8();
}
-static void OpC7M0()
+static void OpC7M0(void)
{
DirectIndirectLong(true);
CMP16();
}
-static void OpD7M1()
+static void OpD7M1(void)
{
DirectIndirectIndexedLong(true);
CMP8();
}
-static void OpD7M0()
+static void OpD7M0(void)
{
DirectIndirectIndexedLong(true);
CMP16();
}
-static void OpCDM1()
+static void OpCDM1(void)
{
Absolute(true);
CMP8();
}
-static void OpCDM0()
+static void OpCDM0(void)
{
Absolute(true);
CMP16();
}
-static void OpDDM1()
+static void OpDDM1(void)
{
AbsoluteIndexedX(true);
CMP8();
}
-static void OpDDM0()
+static void OpDDM0(void)
{
AbsoluteIndexedX(true);
CMP16();
}
-static void OpD9M1()
+static void OpD9M1(void)
{
AbsoluteIndexedY(true);
CMP8();
}
-static void OpD9M0()
+static void OpD9M0(void)
{
AbsoluteIndexedY(true);
CMP16();
}
-static void OpCFM1()
+static void OpCFM1(void)
{
AbsoluteLong(true);
CMP8();
}
-static void OpCFM0()
+static void OpCFM0(void)
{
AbsoluteLong(true);
CMP16();
}
-static void OpDFM1()
+static void OpDFM1(void)
{
AbsoluteLongIndexedX(true);
CMP8();
}
-static void OpDFM0()
+static void OpDFM0(void)
{
AbsoluteLongIndexedX(true);
CMP16();
}
-static void OpC3M1()
+static void OpC3M1(void)
{
StackRelative(true);
CMP8();
}
-static void OpC3M0()
+static void OpC3M0(void)
{
StackRelative(true);
CMP16();
}
-static void OpD3M1()
+static void OpD3M1(void)
{
StackRelativeIndirectIndexed(true);
CMP8();
}
-static void OpD3M0()
+static void OpD3M0(void)
{
StackRelativeIndirectIndexed(true);
CMP16();
@@ -724,7 +722,7 @@ static void OpD3M0()
/**********************************************************************************************/
/* CMX *************************************************************************************** */
-static void OpE0X1()
+static void OpE0X1(void)
{
int32_t Int32 = (int32_t) ICPU.Registers.XL - (int32_t) *CPU.PC++;
ICPU._Carry = Int32 >= 0;
@@ -734,7 +732,7 @@ static void OpE0X1()
#endif
}
-static void OpE0X0()
+static void OpE0X0(void)
{
#ifdef FAST_LSB_WORD_ACCESS
int32_t Int32 = (int32_t) ICPU.Registers.X.W - (int32_t) *(uint16_t*)CPU.PC;
@@ -749,25 +747,25 @@ static void OpE0X0()
#endif
}
-static void OpE4X1()
+static void OpE4X1(void)
{
Direct(true);
CMX8();
}
-static void OpE4X0()
+static void OpE4X0(void)
{
Direct(true);
CMX16();
}
-static void OpECX1()
+static void OpECX1(void)
{
Absolute(true);
CMX8();
}
-static void OpECX0()
+static void OpECX0(void)
{
Absolute(true);
CMX16();
@@ -776,7 +774,7 @@ static void OpECX0()
/**********************************************************************************************/
/* CMY *************************************************************************************** */
-static void OpC0X1()
+static void OpC0X1(void)
{
int32_t Int32 = (int32_t) ICPU.Registers.YL - (int32_t) *CPU.PC++;
ICPU._Carry = Int32 >= 0;
@@ -786,7 +784,7 @@ static void OpC0X1()
#endif
}
-static void OpC0X0()
+static void OpC0X0(void)
{
#ifdef FAST_LSB_WORD_ACCESS
int32_t Int32 = (int32_t) ICPU.Registers.Y.W - (int32_t) *(uint16_t*)CPU.PC;
@@ -801,25 +799,25 @@ static void OpC0X0()
#endif
}
-static void OpC4X1()
+static void OpC4X1(void)
{
Direct(true);
CMY8();
}
-static void OpC4X0()
+static void OpC4X0(void)
{
Direct(true);
CMY16();
}
-static void OpCCX1()
+static void OpCCX1(void)
{
Absolute(true);
CMY8();
}
-static void OpCCX0()
+static void OpCCX0(void)
{
Absolute(true);
CMY16();
@@ -828,59 +826,59 @@ static void OpCCX0()
/**********************************************************************************************/
/* DEC *************************************************************************************** */
-static void Op3AM1()
+static void Op3AM1(void)
{
A_DEC8();
}
-static void Op3AM0()
+static void Op3AM0(void)
{
A_DEC16();
}
-static void OpC6M1()
+static void OpC6M1(void)
{
Direct(false);
DEC8();
}
-static void OpC6M0()
+static void OpC6M0(void)
{
Direct(false);
DEC16();
}
-static void OpD6M1()
+static void OpD6M1(void)
{
DirectIndexedX(false);
DEC8();
}
-static void OpD6M0()
+static void OpD6M0(void)
{
DirectIndexedX(false);
DEC16();
}
-static void OpCEM1()
+static void OpCEM1(void)
{
Absolute(false);
DEC8();
}
-static void OpCEM0()
+static void OpCEM0(void)
{
Absolute(false);
DEC16();
}
-static void OpDEM1()
+static void OpDEM1(void)
{
AbsoluteIndexedX(false);
DEC8();
}
-static void OpDEM0()
+static void OpDEM0(void)
{
AbsoluteIndexedX(false);
DEC16();
@@ -889,7 +887,7 @@ static void OpDEM0()
/**********************************************************************************************/
/* EOR *************************************************************************************** */
-static void Op49M1()
+static void Op49M1(void)
{
ICPU.Registers.AL ^= *CPU.PC++;
#ifndef SA1_OPCODES
@@ -898,7 +896,7 @@ static void Op49M1()
SetZN8(ICPU.Registers.AL);
}
-static void Op49M0()
+static void Op49M0(void)
{
#ifdef FAST_LSB_WORD_ACCESS
ICPU.Registers.A.W ^= *(uint16_t*) CPU.PC;
@@ -912,169 +910,169 @@ static void Op49M0()
SetZN16(ICPU.Registers.A.W);
}
-static void Op45M1()
+static void Op45M1(void)
{
Direct(true);
EOR8();
}
-static void Op45M0()
+static void Op45M0(void)
{
Direct(true);
EOR16();
}
-static void Op55M1()
+static void Op55M1(void)
{
DirectIndexedX(true);
EOR8();
}
-static void Op55M0()
+static void Op55M0(void)
{
DirectIndexedX(true);
EOR16();
}
-static void Op52M1()
+static void Op52M1(void)
{
DirectIndirect(true);
EOR8();
}
-static void Op52M0()
+static void Op52M0(void)
{
DirectIndirect(true);
EOR16();
}
-static void Op41M1()
+static void Op41M1(void)
{
DirectIndexedIndirect(true);
EOR8();
}
-static void Op41M0()
+static void Op41M0(void)
{
DirectIndexedIndirect(true);
EOR16();
}
-static void Op51M1()
+static void Op51M1(void)
{
DirectIndirectIndexed(true);
EOR8();
}
-static void Op51M0()
+static void Op51M0(void)
{
DirectIndirectIndexed(true);
EOR16();
}
-static void Op47M1()
+static void Op47M1(void)
{
DirectIndirectLong(true);
EOR8();
}
-static void Op47M0()
+static void Op47M0(void)
{
DirectIndirectLong(true);
EOR16();
}
-static void Op57M1()
+static void Op57M1(void)
{
DirectIndirectIndexedLong(true);
EOR8();
}
-static void Op57M0()
+static void Op57M0(void)
{
DirectIndirectIndexedLong(true);
EOR16();
}
-static void Op4DM1()
+static void Op4DM1(void)
{
Absolute(true);
EOR8();
}
-static void Op4DM0()
+static void Op4DM0(void)
{
Absolute(true);
EOR16();
}
-static void Op5DM1()
+static void Op5DM1(void)
{
AbsoluteIndexedX(true);
EOR8();
}
-static void Op5DM0()
+static void Op5DM0(void)
{
AbsoluteIndexedX(true);
EOR16();
}
-static void Op59M1()
+static void Op59M1(void)
{
AbsoluteIndexedY(true);
EOR8();
}
-static void Op59M0()
+static void Op59M0(void)
{
AbsoluteIndexedY(true);
EOR16();
}
-static void Op4FM1()
+static void Op4FM1(void)
{
AbsoluteLong(true);
EOR8();
}
-static void Op4FM0()
+static void Op4FM0(void)
{
AbsoluteLong(true);
EOR16();
}
-static void Op5FM1()
+static void Op5FM1(void)
{
AbsoluteLongIndexedX(true);
EOR8();
}
-static void Op5FM0()
+static void Op5FM0(void)
{
AbsoluteLongIndexedX(true);
EOR16();
}
-static void Op43M1()
+static void Op43M1(void)
{
StackRelative(true);
EOR8();
}
-static void Op43M0()
+static void Op43M0(void)
{
StackRelative(true);
EOR16();
}
-static void Op53M1()
+static void Op53M1(void)
{
StackRelativeIndirectIndexed(true);
EOR8();
}
-static void Op53M0()
+static void Op53M0(void)
{
StackRelativeIndirectIndexed(true);
EOR16();
@@ -1083,59 +1081,59 @@ static void Op53M0()
/**********************************************************************************************/
/* INC *************************************************************************************** */
-static void Op1AM1()
+static void Op1AM1(void)
{
A_INC8();
}
-static void Op1AM0()
+static void Op1AM0(void)
{
A_INC16();
}
-static void OpE6M1()
+static void OpE6M1(void)
{
Direct(false);
INC8();
}
-static void OpE6M0()
+static void OpE6M0(void)
{
Direct(false);
INC16();
}
-static void OpF6M1()
+static void OpF6M1(void)
{
DirectIndexedX(false);
INC8();
}
-static void OpF6M0()
+static void OpF6M0(void)
{
DirectIndexedX(false);
INC16();
}
-static void OpEEM1()
+static void OpEEM1(void)
{
Absolute(false);
INC8();
}
-static void OpEEM0()
+static void OpEEM0(void)
{
Absolute(false);
INC16();
}
-static void OpFEM1()
+static void OpFEM1(void)
{
AbsoluteIndexedX(false);
INC8();
}
-static void OpFEM0()
+static void OpFEM0(void)
{
AbsoluteIndexedX(false);
INC16();
@@ -1143,7 +1141,7 @@ static void OpFEM0()
/**********************************************************************************************/
/* LDA *************************************************************************************** */
-static void OpA9M1()
+static void OpA9M1(void)
{
ICPU.Registers.AL = *CPU.PC++;
#ifndef SA1_OPCODES
@@ -1152,7 +1150,7 @@ static void OpA9M1()
SetZN8(ICPU.Registers.AL);
}
-static void OpA9M0()
+static void OpA9M0(void)
{
#ifdef FAST_LSB_WORD_ACCESS
ICPU.Registers.A.W = *(uint16_t*) CPU.PC;
@@ -1167,169 +1165,169 @@ static void OpA9M0()
SetZN16(ICPU.Registers.A.W);
}
-static void OpA5M1()
+static void OpA5M1(void)
{
Direct(true);
LDA8();
}
-static void OpA5M0()
+static void OpA5M0(void)
{
Direct(true);
LDA16();
}
-static void OpB5M1()
+static void OpB5M1(void)
{
DirectIndexedX(true);
LDA8();
}
-static void OpB5M0()
+static void OpB5M0(void)
{
DirectIndexedX(true);
LDA16();
}
-static void OpB2M1()
+static void OpB2M1(void)
{
DirectIndirect(true);
LDA8();
}
-static void OpB2M0()
+static void OpB2M0(void)
{
DirectIndirect(true);
LDA16();
}
-static void OpA1M1()
+static void OpA1M1(void)
{
DirectIndexedIndirect(true);
LDA8();
}
-static void OpA1M0()
+static void OpA1M0(void)
{
DirectIndexedIndirect(true);
LDA16();
}
-static void OpB1M1()
+static void OpB1M1(void)
{
DirectIndirectIndexed(true);
LDA8();
}
-static void OpB1M0()
+static void OpB1M0(void)
{
DirectIndirectIndexed(true);
LDA16();
}
-static void OpA7M1()
+static void OpA7M1(void)
{
DirectIndirectLong(true);
LDA8();
}
-static void OpA7M0()
+static void OpA7M0(void)
{
DirectIndirectLong(true);
LDA16();
}
-static void OpB7M1()
+static void OpB7M1(void)
{
DirectIndirectIndexedLong(true);
LDA8();
}
-static void OpB7M0()
+static void OpB7M0(void)
{
DirectIndirectIndexedLong(true);
LDA16();
}
-static void OpADM1()
+static void OpADM1(void)
{
Absolute(true);
LDA8();
}
-static void OpADM0()
+static void OpADM0(void)
{
Absolute(true);
LDA16();
}
-static void OpBDM1()
+static void OpBDM1(void)
{
AbsoluteIndexedX(true);
LDA8();
}
-static void OpBDM0()
+static void OpBDM0(void)
{
AbsoluteIndexedX(true);
LDA16();
}
-static void OpB9M1()
+static void OpB9M1(void)
{
AbsoluteIndexedY(true);
LDA8();
}
-static void OpB9M0()
+static void OpB9M0(void)
{
AbsoluteIndexedY(true);
LDA16();
}
-static void OpAFM1()
+static void OpAFM1(void)
{
AbsoluteLong(true);
LDA8();
}
-static void OpAFM0()
+static void OpAFM0(void)
{
AbsoluteLong(true);
LDA16();
}
-static void OpBFM1()
+static void OpBFM1(void)
{
AbsoluteLongIndexedX(true);
LDA8();
}
-static void OpBFM0()
+static void OpBFM0(void)
{
AbsoluteLongIndexedX(true);
LDA16();
}
-static void OpA3M1()
+static void OpA3M1(void)
{
StackRelative(true);
LDA8();
}
-static void OpA3M0()
+static void OpA3M0(void)
{
StackRelative(true);
LDA16();
}
-static void OpB3M1()
+static void OpB3M1(void)
{
StackRelativeIndirectIndexed(true);
LDA8();
}
-static void OpB3M0()
+static void OpB3M0(void)
{
StackRelativeIndirectIndexed(true);
LDA16();
@@ -1338,7 +1336,7 @@ static void OpB3M0()
/**********************************************************************************************/
/* LDX *************************************************************************************** */
-static void OpA2X1()
+static void OpA2X1(void)
{
ICPU.Registers.XL = *CPU.PC++;
#ifndef SA1_OPCODES
@@ -1347,7 +1345,7 @@ static void OpA2X1()
SetZN8(ICPU.Registers.XL);
}
-static void OpA2X0()
+static void OpA2X0(void)
{
#ifdef FAST_LSB_WORD_ACCESS
ICPU.Registers.X.W = *(uint16_t*) CPU.PC;
@@ -1361,49 +1359,49 @@ static void OpA2X0()
SetZN16(ICPU.Registers.X.W);
}
-static void OpA6X1()
+static void OpA6X1(void)
{
Direct(true);
LDX8();
}
-static void OpA6X0()
+static void OpA6X0(void)
{
Direct(true);
LDX16();
}
-static void OpB6X1()
+static void OpB6X1(void)
{
DirectIndexedY(true);
LDX8();
}
-static void OpB6X0()
+static void OpB6X0(void)
{
DirectIndexedY(true);
LDX16();
}
-static void OpAEX1()
+static void OpAEX1(void)
{
Absolute(true);
LDX8();
}
-static void OpAEX0()
+static void OpAEX0(void)
{
Absolute(true);
LDX16();
}
-static void OpBEX1()
+static void OpBEX1(void)
{
AbsoluteIndexedY(true);
LDX8();
}
-static void OpBEX0()
+static void OpBEX0(void)
{
AbsoluteIndexedY(true);
LDX16();
@@ -1411,7 +1409,7 @@ static void OpBEX0()
/**********************************************************************************************/
/* LDY *************************************************************************************** */
-static void OpA0X1()
+static void OpA0X1(void)
{
ICPU.Registers.YL = *CPU.PC++;
#ifndef SA1_OPCODES
@@ -1420,7 +1418,7 @@ static void OpA0X1()
SetZN8(ICPU.Registers.YL);
}
-static void OpA0X0()
+static void OpA0X0(void)
{
#ifdef FAST_LSB_WORD_ACCESS
ICPU.Registers.Y.W = *(uint16_t*) CPU.PC;
@@ -1435,49 +1433,49 @@ static void OpA0X0()
SetZN16(ICPU.Registers.Y.W);
}
-static void OpA4X1()
+static void OpA4X1(void)
{
Direct(true);
LDY8();
}
-static void OpA4X0()
+static void OpA4X0(void)
{
Direct(true);
LDY16();
}
-static void OpB4X1()
+static void OpB4X1(void)
{
DirectIndexedX(true);
LDY8();
}
-static void OpB4X0()
+static void OpB4X0(void)
{
DirectIndexedX(true);
LDY16();
}
-static void OpACX1()
+static void OpACX1(void)
{
Absolute(true);
LDY8();
}
-static void OpACX0()
+static void OpACX0(void)
{
Absolute(true);
LDY16();
}
-static void OpBCX1()
+static void OpBCX1(void)
{
AbsoluteIndexedX(true);
LDY8();
}
-static void OpBCX0()
+static void OpBCX0(void)
{
AbsoluteIndexedX(true);
LDY16();
@@ -1485,59 +1483,59 @@ static void OpBCX0()
/**********************************************************************************************/
/* LSR *************************************************************************************** */
-static void Op4AM1()
+static void Op4AM1(void)
{
A_LSR8();
}
-static void Op4AM0()
+static void Op4AM0(void)
{
A_LSR16();
}
-static void Op46M1()
+static void Op46M1(void)
{
Direct(false);
LSR8();
}
-static void Op46M0()
+static void Op46M0(void)
{
Direct(false);
LSR16();
}
-static void Op56M1()
+static void Op56M1(void)
{
DirectIndexedX(false);
LSR8();
}
-static void Op56M0()
+static void Op56M0(void)
{
DirectIndexedX(false);
LSR16();
}
-static void Op4EM1()
+static void Op4EM1(void)
{
Absolute(false);
LSR8();
}
-static void Op4EM0()
+static void Op4EM0(void)
{
Absolute(false);
LSR16();
}
-static void Op5EM1()
+static void Op5EM1(void)
{
AbsoluteIndexedX(false);
LSR8();
}
-static void Op5EM0()
+static void Op5EM0(void)
{
AbsoluteIndexedX(false);
LSR16();
@@ -1546,7 +1544,7 @@ static void Op5EM0()
/**********************************************************************************************/
/* ORA *************************************************************************************** */
-static void Op09M1()
+static void Op09M1(void)
{
ICPU.Registers.AL |= *CPU.PC++;
#ifndef SA1_OPCODES
@@ -1555,7 +1553,7 @@ static void Op09M1()
SetZN8(ICPU.Registers.AL);
}
-static void Op09M0()
+static void Op09M0(void)
{
#ifdef FAST_LSB_WORD_ACCESS
ICPU.Registers.A.W |= *(uint16_t*) CPU.PC;
@@ -1569,169 +1567,169 @@ static void Op09M0()
SetZN16(ICPU.Registers.A.W);
}
-static void Op05M1()
+static void Op05M1(void)
{
Direct(true);
ORA8();
}
-static void Op05M0()
+static void Op05M0(void)
{
Direct(true);
ORA16();
}
-static void Op15M1()
+static void Op15M1(void)
{
DirectIndexedX(true);
ORA8();
}
-static void Op15M0()
+static void Op15M0(void)
{
DirectIndexedX(true);
ORA16();
}
-static void Op12M1()
+static void Op12M1(void)
{
DirectIndirect(true);
ORA8();
}
-static void Op12M0()
+static void Op12M0(void)
{
DirectIndirect(true);
ORA16();
}
-static void Op01M1()
+static void Op01M1(void)
{
DirectIndexedIndirect(true);
ORA8();
}
-static void Op01M0()
+static void Op01M0(void)
{
DirectIndexedIndirect(true);
ORA16();
}
-static void Op11M1()
+static void Op11M1(void)
{
DirectIndirectIndexed(true);
ORA8();
}
-static void Op11M0()
+static void Op11M0(void)
{
DirectIndirectIndexed(true);
ORA16();
}
-static void Op07M1()
+static void Op07M1(void)
{
DirectIndirectLong(true);
ORA8();
}
-static void Op07M0()
+static void Op07M0(void)
{
DirectIndirectLong(true);
ORA16();
}
-static void Op17M1()
+static void Op17M1(void)
{
DirectIndirectIndexedLong(true);
ORA8();
}
-static void Op17M0()
+static void Op17M0(void)
{
DirectIndirectIndexedLong(true);
ORA16();
}
-static void Op0DM1()
+static void Op0DM1(void)
{
Absolute(true);
ORA8();
}
-static void Op0DM0()
+static void Op0DM0(void)
{
Absolute(true);
ORA16();
}
-static void Op1DM1()
+static void Op1DM1(void)
{
AbsoluteIndexedX(true);
ORA8();
}
-static void Op1DM0()
+static void Op1DM0(void)
{
AbsoluteIndexedX(true);
ORA16();
}
-static void Op19M1()
+static void Op19M1(void)
{
AbsoluteIndexedY(true);
ORA8();
}
-static void Op19M0()
+static void Op19M0(void)
{
AbsoluteIndexedY(true);
ORA16();
}
-static void Op0FM1()
+static void Op0FM1(void)
{
AbsoluteLong(true);
ORA8();
}
-static void Op0FM0()
+static void Op0FM0(void)
{
AbsoluteLong(true);
ORA16();
}
-static void Op1FM1()
+static void Op1FM1(void)
{
AbsoluteLongIndexedX(true);
ORA8();
}
-static void Op1FM0()
+static void Op1FM0(void)
{
AbsoluteLongIndexedX(true);
ORA16();
}
-static void Op03M1()
+static void Op03M1(void)
{
StackRelative(true);
ORA8();
}
-static void Op03M0()
+static void Op03M0(void)
{
StackRelative(true);
ORA16();
}
-static void Op13M1()
+static void Op13M1(void)
{
StackRelativeIndirectIndexed(true);
ORA8();
}
-static void Op13M0()
+static void Op13M0(void)
{
StackRelativeIndirectIndexed(true);
ORA16();
@@ -1740,59 +1738,59 @@ static void Op13M0()
/**********************************************************************************************/
/* ROL *************************************************************************************** */
-static void Op2AM1()
+static void Op2AM1(void)
{
A_ROL8();
}
-static void Op2AM0()
+static void Op2AM0(void)
{
A_ROL16();
}
-static void Op26M1()
+static void Op26M1(void)
{
Direct(false);
ROL8();
}
-static void Op26M0()
+static void Op26M0(void)
{
Direct(false);
ROL16();
}
-static void Op36M1()
+static void Op36M1(void)
{
DirectIndexedX(false);
ROL8();
}
-static void Op36M0()
+static void Op36M0(void)
{
DirectIndexedX(false);
ROL16();
}
-static void Op2EM1()
+static void Op2EM1(void)
{
Absolute(false);
ROL8();
}
-static void Op2EM0()
+static void Op2EM0(void)
{
Absolute(false);
ROL16();
}
-static void Op3EM1()
+static void Op3EM1(void)
{
AbsoluteIndexedX(false);
ROL8();
}
-static void Op3EM0()
+static void Op3EM0(void)
{
AbsoluteIndexedX(false);
ROL16();
@@ -1800,59 +1798,59 @@ static void Op3EM0()
/**********************************************************************************************/
/* ROR *************************************************************************************** */
-static void Op6AM1()
+static void Op6AM1(void)
{
A_ROR8();
}
-static void Op6AM0()
+static void Op6AM0(void)
{
A_ROR16();
}
-static void Op66M1()
+static void Op66M1(void)
{
Direct(false);
ROR8();
}
-static void Op66M0()
+static void Op66M0(void)
{
Direct(false);
ROR16();
}
-static void Op76M1()
+static void Op76M1(void)
{
DirectIndexedX(false);
ROR8();
}
-static void Op76M0()
+static void Op76M0(void)
{
DirectIndexedX(false);
ROR16();
}
-static void Op6EM1()
+static void Op6EM1(void)
{
Absolute(false);
ROR8();
}
-static void Op6EM0()
+static void Op6EM0(void)
{
Absolute(false);
ROR16();
}
-static void Op7EM1()
+static void Op7EM1(void)
{
AbsoluteIndexedX(false);
ROR8();
}
-static void Op7EM0()
+static void Op7EM0(void)
{
AbsoluteIndexedX(false);
ROR16();
@@ -1860,181 +1858,181 @@ static void Op7EM0()
/**********************************************************************************************/
/* SBC *************************************************************************************** */
-static void OpE9M1()
+static void OpE9M1(void)
{
Immediate8();
SBC8();
}
-static void OpE9M0()
+static void OpE9M0(void)
{
Immediate16();
SBC16();
}
-static void OpE5M1()
+static void OpE5M1(void)
{
Direct(true);
SBC8();
}
-static void OpE5M0()
+static void OpE5M0(void)
{
Direct(true);
SBC16();
}
-static void OpF5M1()
+static void OpF5M1(void)
{
DirectIndexedX(true);
SBC8();
}
-static void OpF5M0()
+static void OpF5M0(void)
{
DirectIndexedX(true);
SBC16();
}
-static void OpF2M1()
+static void OpF2M1(void)
{
DirectIndirect(true);
SBC8();
}
-static void OpF2M0()
+static void OpF2M0(void)
{
DirectIndirect(true);
SBC16();
}
-static void OpE1M1()
+static void OpE1M1(void)
{
DirectIndexedIndirect(true);
SBC8();
}
-static void OpE1M0()
+static void OpE1M0(void)
{
DirectIndexedIndirect(true);
SBC16();
}
-static void OpF1M1()
+static void OpF1M1(void)
{
DirectIndirectIndexed(true);
SBC8();
}
-static void OpF1M0()
+static void OpF1M0(void)
{
DirectIndirectIndexed(true);
SBC16();
}
-static void OpE7M1()
+static void OpE7M1(void)
{
DirectIndirectLong(true);
SBC8();
}
-static void OpE7M0()
+static void OpE7M0(void)
{
DirectIndirectLong(true);
SBC16();
}
-static void OpF7M1()
+static void OpF7M1(void)
{
DirectIndirectIndexedLong(true);
SBC8();
}
-static void OpF7M0()
+static void OpF7M0(void)
{
DirectIndirectIndexedLong(true);
SBC16();
}
-static void OpEDM1()
+static void OpEDM1(void)
{
Absolute(true);
SBC8();
}
-static void OpEDM0()
+static void OpEDM0(void)
{
Absolute(true);
SBC16();
}
-static void OpFDM1()
+static void OpFDM1(void)
{
AbsoluteIndexedX(true);
SBC8();
}
-static void OpFDM0()
+static void OpFDM0(void)
{
AbsoluteIndexedX(true);
SBC16();
}
-static void OpF9M1()
+static void OpF9M1(void)
{
AbsoluteIndexedY(true);
SBC8();
}
-static void OpF9M0()
+static void OpF9M0(void)
{
AbsoluteIndexedY(true);
SBC16();
}
-static void OpEFM1()
+static void OpEFM1(void)
{
AbsoluteLong(true);
SBC8();
}
-static void OpEFM0()
+static void OpEFM0(void)
{
AbsoluteLong(true);
SBC16();
}
-static void OpFFM1()
+static void OpFFM1(void)
{
AbsoluteLongIndexedX(true);
SBC8();
}
-static void OpFFM0()
+static void OpFFM0(void)
{
AbsoluteLongIndexedX(true);
SBC16();
}
-static void OpE3M1()
+static void OpE3M1(void)
{
StackRelative(true);
SBC8();
}
-static void OpE3M0()
+static void OpE3M0(void)
{
StackRelative(true);
SBC16();
}
-static void OpF3M1()
+static void OpF3M1(void)
{
StackRelativeIndirectIndexed(true);
SBC8();
}
-static void OpF3M0()
+static void OpF3M0(void)
{
StackRelativeIndirectIndexed(true);
SBC16();
@@ -2042,177 +2040,177 @@ static void OpF3M0()
/**********************************************************************************************/
/* STA *************************************************************************************** */
-static void Op85M1()
+static void Op85M1(void)
{
Direct(false);
STA8();
}
-static void Op85M0()
+static void Op85M0(void)
{
Direct(false);
STA16();
}
-static void Op95M1()
+static void Op95M1(void)
{
DirectIndexedX(false);
STA8();
}
-static void Op95M0()
+static void Op95M0(void)
{
DirectIndexedX(false);
STA16();
}
-static void Op92M1()
+static void Op92M1(void)
{
DirectIndirect(false);
STA8();
}
-static void Op92M0()
+static void Op92M0(void)
{
DirectIndirect(false);
STA16();
}
-static void Op81M1()
+static void Op81M1(void)
{
DirectIndexedIndirect(false);
STA8();
-#ifdef noVAR_CYCLES
+#ifndef SA1_OPCODES
if (CheckIndex())
CPU.Cycles += ONE_CYCLE;
#endif
}
-static void Op81M0()
+static void Op81M0(void)
{
DirectIndexedIndirect(false);
STA16();
-#ifdef noVAR_CYCLES
+#ifndef SA1_OPCODES
if (CheckIndex())
CPU.Cycles += ONE_CYCLE;
#endif
}
-static void Op91M1()
+static void Op91M1(void)
{
DirectIndirectIndexed(false);
STA8();
}
-static void Op91M0()
+static void Op91M0(void)
{
DirectIndirectIndexed(false);
STA16();
}
-static void Op87M1()
+static void Op87M1(void)
{
DirectIndirectLong(false);
STA8();
}
-static void Op87M0()
+static void Op87M0(void)
{
DirectIndirectLong(false);
STA16();
}
-static void Op97M1()
+static void Op97M1(void)
{
DirectIndirectIndexedLong(false);
STA8();
}
-static void Op97M0()
+static void Op97M0(void)
{
DirectIndirectIndexedLong(false);
STA16();
}
-static void Op8DM1()
+static void Op8DM1(void)
{
Absolute(false);
STA8();
}
-static void Op8DM0()
+static void Op8DM0(void)
{
Absolute(false);
STA16();
}
-static void Op9DM1()
+static void Op9DM1(void)
{
AbsoluteIndexedX(false);
STA8();
}
-static void Op9DM0()
+static void Op9DM0(void)
{
AbsoluteIndexedX(false);
STA16();
}
-static void Op99M1()
+static void Op99M1(void)
{
AbsoluteIndexedY(false);
STA8();
}
-static void Op99M0()
+static void Op99M0(void)
{
AbsoluteIndexedY(false);
STA16();
}
-static void Op8FM1()
+static void Op8FM1(void)
{
AbsoluteLong(false);
STA8();
}
-static void Op8FM0()
+static void Op8FM0(void)
{
AbsoluteLong(false);
STA16();
}
-static void Op9FM1()
+static void Op9FM1(void)
{
AbsoluteLongIndexedX(false);
STA8();
}
-static void Op9FM0()
+static void Op9FM0(void)
{
AbsoluteLongIndexedX(false);
STA16();
}
-static void Op83M1()
+static void Op83M1(void)
{
StackRelative(false);
STA8();
}
-static void Op83M0()
+static void Op83M0(void)
{
StackRelative(false);
STA16();
}
-static void Op93M1()
+static void Op93M1(void)
{
StackRelativeIndirectIndexed(false);
STA8();
}
-static void Op93M0()
+static void Op93M0(void)
{
StackRelativeIndirectIndexed(false);
STA16();
@@ -2220,37 +2218,37 @@ static void Op93M0()
/**********************************************************************************************/
/* STX *************************************************************************************** */
-static void Op86X1()
+static void Op86X1(void)
{
Direct(false);
STX8();
}
-static void Op86X0()
+static void Op86X0(void)
{
Direct(false);
STX16();
}
-static void Op96X1()
+static void Op96X1(void)
{
DirectIndexedY(false);
STX8();
}
-static void Op96X0()
+static void Op96X0(void)
{
DirectIndexedY(false);
STX16();
}
-static void Op8EX1()
+static void Op8EX1(void)
{
Absolute(false);
STX8();
}
-static void Op8EX0()
+static void Op8EX0(void)
{
Absolute(false);
STX16();
@@ -2258,37 +2256,37 @@ static void Op8EX0()
/**********************************************************************************************/
/* STY *************************************************************************************** */
-static void Op84X1()
+static void Op84X1(void)
{
Direct(false);
STY8();
}
-static void Op84X0()
+static void Op84X0(void)
{
Direct(false);
STY16();
}
-static void Op94X1()
+static void Op94X1(void)
{
DirectIndexedX(false);
STY8();
}
-static void Op94X0()
+static void Op94X0(void)
{
DirectIndexedX(false);
STY16();
}
-static void Op8CX1()
+static void Op8CX1(void)
{
Absolute(false);
STY8();
}
-static void Op8CX0()
+static void Op8CX0(void)
{
Absolute(false);
STY16();
@@ -2296,49 +2294,49 @@ static void Op8CX0()
/**********************************************************************************************/
/* STZ *************************************************************************************** */
-static void Op64M1()
+static void Op64M1(void)
{
Direct(false);
STZ8();
}
-static void Op64M0()
+static void Op64M0(void)
{
Direct(false);
STZ16();
}
-static void Op74M1()
+static void Op74M1(void)
{
DirectIndexedX(false);
STZ8();
}
-static void Op74M0()
+static void Op74M0(void)
{
DirectIndexedX(false);
STZ16();
}
-static void Op9CM1()
+static void Op9CM1(void)
{
Absolute(false);
STZ8();
}
-static void Op9CM0()
+static void Op9CM0(void)
{
Absolute(false);
STZ16();
}
-static void Op9EM1()
+static void Op9EM1(void)
{
AbsoluteIndexedX(false);
STZ8();
}
-static void Op9EM0()
+static void Op9EM0(void)
{
AbsoluteIndexedX(false);
STZ16();
@@ -2347,25 +2345,25 @@ static void Op9EM0()
/**********************************************************************************************/
/* TRB *************************************************************************************** */
-static void Op14M1()
+static void Op14M1(void)
{
Direct(false);
TRB8();
}
-static void Op14M0()
+static void Op14M0(void)
{
Direct(false);
TRB16();
}
-static void Op1CM1()
+static void Op1CM1(void)
{
Absolute(false);
TRB8();
}
-static void Op1CM0()
+static void Op1CM0(void)
{
Absolute(false);
TRB16();
@@ -2373,25 +2371,25 @@ static void Op1CM0()
/**********************************************************************************************/
/* TSB *************************************************************************************** */
-static void Op04M1()
+static void Op04M1(void)
{
Direct(false);
TSB8();
}
-static void Op04M0()
+static void Op04M0(void)
{
Direct(false);
TSB16();
}
-static void Op0CM1()
+static void Op0CM1(void)
{
Absolute(false);
TSB8();
}
-static void Op0CM0()
+static void Op0CM0(void)
{
Absolute(false);
TSB16();
@@ -2401,63 +2399,19 @@ static void Op0CM0()
/* Branch Instructions *********************************************************************** */
#ifndef SA1_OPCODES
-#define BranchCheck0()\
- if(CPU.BranchSkip)\
- {\
- CPU.BranchSkip = false;\
- if (!Settings.SoundSkipMethod)\
- if (CPU.PC - CPU.PCBase > OpAddress)\
- return;\
- }
-
-#define BranchCheck1()\
- if(CPU.BranchSkip)\
- {\
- CPU.BranchSkip = false;\
- if (!Settings.SoundSkipMethod)\
- {\
- if( CPU.PC - CPU.PCBase > OpAddress)\
- return;\
- }\
- else if (Settings.SoundSkipMethod == 1)\
- return;\
- if (Settings.SoundSkipMethod == 3)\
- {\
- if (CPU.PC - CPU.PCBase > OpAddress)\
- return;\
- else\
- CPU.PC = CPU.PCBase + OpAddress;\
- }\
- }
-
-#define BranchCheck2()\
- if(CPU.BranchSkip)\
- {\
- CPU.BranchSkip = false;\
- if (!Settings.SoundSkipMethod)\
- {\
- if( CPU.PC - CPU.PCBase > OpAddress)\
- return;\
- }\
- else if (Settings.SoundSkipMethod == 1)\
- CPU.PC = CPU.PCBase + OpAddress;\
- if (Settings.SoundSkipMethod == 3)\
- {\
- if (CPU.PC - CPU.PCBase > OpAddress)\
- return;\
- else\
- CPU.PC = CPU.PCBase + OpAddress;\
- }\
+#define BranchCheck() \
+ if(CPU.BranchSkip) \
+ { \
+ CPU.BranchSkip = false; \
+ if (CPU.PC - CPU.PCBase > OpAddress)\
+ return; \
}
#else
-#define BranchCheck0()
-#define BranchCheck1()
-#define BranchCheck2()
+#define BranchCheck()
#endif
-#ifdef CPU_SHUTDOWN
#ifndef SA1_OPCODES
-static inline void CPUShutdown()
+static inline void CPUShutdown(void)
{
if (Settings.Shutdown && CPU.PC == CPU.WaitAddress)
{
@@ -2490,7 +2444,7 @@ static inline void CPUShutdown()
}
}
#else
-static inline void CPUShutdown()
+static inline void CPUShutdown(void)
{
if (Settings.Shutdown && CPU.PC == CPU.WaitAddress)
{
@@ -2504,15 +2458,11 @@ static inline void CPUShutdown()
}
}
#endif
-#else
-#define CPUShutdown()
-#endif
// From the speed-hacks branch of CatSFC
-static inline void ForceShutdown()
+static inline void ForceShutdown(void)
{
-#ifdef CPU_SHUTDOWN
-#ifdef VAR_CYCLES
+#ifndef SA1_OPCODES
CPU.WaitAddress = NULL;
#ifndef USE_BLARGG_APU
CPU.Cycles = CPU.NextEvent;
@@ -2531,14 +2481,13 @@ static inline void ForceShutdown()
SA1.Executing = false;
SA1.CPUExecuting = false;
#endif
-#endif
}
/* BCC */
-static void Op90()
+static void Op90(void)
{
Relative();
- BranchCheck0();
+ BranchCheck();
if (!CheckCarry())
{
CPU.PC = CPU.PCBase + OpAddress;
@@ -2550,10 +2499,10 @@ static void Op90()
}
/* BCS */
-static void OpB0()
+static void OpB0(void)
{
Relative();
- BranchCheck0();
+ BranchCheck();
if (CheckCarry())
{
CPU.PC = CPU.PCBase + OpAddress;
@@ -2565,10 +2514,10 @@ static void OpB0()
}
/* BEQ */
-static void OpF0()
+static void OpF0(void)
{
Relative();
- BranchCheck2();
+ BranchCheck();
if (CheckZero())
{
CPU.PC = CPU.PCBase + OpAddress;
@@ -2580,10 +2529,10 @@ static void OpF0()
}
/* BMI */
-static void Op30()
+static void Op30(void)
{
Relative();
- BranchCheck1();
+ BranchCheck();
if (CheckNegative())
{
CPU.PC = CPU.PCBase + OpAddress;
@@ -2595,10 +2544,10 @@ static void Op30()
}
/* BNE */
-static void OpD0()
+static void OpD0(void)
{
Relative();
- BranchCheck1();
+ BranchCheck();
if (!CheckZero())
{
CPU.PC = CPU.PCBase + OpAddress;
@@ -2610,10 +2559,10 @@ static void OpD0()
}
/* BPL */
-static void Op10()
+static void Op10(void)
{
Relative();
- BranchCheck1();
+ BranchCheck();
if (!CheckNegative())
{
CPU.PC = CPU.PCBase + OpAddress;
@@ -2625,7 +2574,7 @@ static void Op10()
}
/* BRA */
-static void Op80()
+static void Op80(void)
{
Relative();
CPU.PC = CPU.PCBase + OpAddress;
@@ -2636,10 +2585,10 @@ static void Op80()
}
/* BVC */
-static void Op50()
+static void Op50(void)
{
Relative();
- BranchCheck0();
+ BranchCheck();
if (!CheckOverflow())
{
CPU.PC = CPU.PCBase + OpAddress;
@@ -2651,10 +2600,10 @@ static void Op50()
}
/* BVS */
-static void Op70()
+static void Op70(void)
{
Relative();
- BranchCheck0();
+ BranchCheck();
if (CheckOverflow())
{
CPU.PC = CPU.PCBase + OpAddress;
@@ -2668,7 +2617,7 @@ static void Op70()
/* ClearFlag Instructions ******************************************************************** */
/* CLC */
-static void Op18()
+static void Op18(void)
{
ClearCarry();
#ifndef SA1_OPCODES
@@ -2677,7 +2626,7 @@ static void Op18()
}
/* CLD */
-static void OpD8()
+static void OpD8(void)
{
ClearDecimal();
#ifndef SA1_OPCODES
@@ -2686,7 +2635,7 @@ static void OpD8()
}
/* CLI */
-static void Op58()
+static void Op58(void)
{
ClearIRQ();
#ifndef SA1_OPCODES
@@ -2696,7 +2645,7 @@ static void Op58()
}
/* CLV */
-static void OpB8()
+static void OpB8(void)
{
ClearOverflow();
#ifndef SA1_OPCODES
@@ -2706,100 +2655,84 @@ static void OpB8()
/**********************************************************************************************/
/* DEX/DEY *********************************************************************************** */
-static void OpCAX1()
+static void OpCAX1(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#endif
-#ifdef CPU_SHUTDOWN
CPU.WaitAddress = NULL;
-#endif
ICPU.Registers.XL--;
SetZN8(ICPU.Registers.XL);
}
-static void OpCAX0()
+static void OpCAX0(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#endif
-#ifdef CPU_SHUTDOWN
CPU.WaitAddress = NULL;
-#endif
ICPU.Registers.X.W--;
SetZN16(ICPU.Registers.X.W);
}
-static void Op88X1()
+static void Op88X1(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#endif
-#ifdef CPU_SHUTDOWN
CPU.WaitAddress = NULL;
-#endif
ICPU.Registers.YL--;
SetZN8(ICPU.Registers.YL);
}
-static void Op88X0()
+static void Op88X0(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#endif
-#ifdef CPU_SHUTDOWN
CPU.WaitAddress = NULL;
-#endif
ICPU.Registers.Y.W--;
SetZN16(ICPU.Registers.Y.W);
}
/**********************************************************************************************/
/* INX/INY *********************************************************************************** */
-static void OpE8X1()
+static void OpE8X1(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#endif
-#ifdef CPU_SHUTDOWN
CPU.WaitAddress = NULL;
-#endif
ICPU.Registers.XL++;
SetZN8(ICPU.Registers.XL);
}
-static void OpE8X0()
+static void OpE8X0(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#endif
-#ifdef CPU_SHUTDOWN
CPU.WaitAddress = NULL;
-#endif
ICPU.Registers.X.W++;
SetZN16(ICPU.Registers.X.W);
}
-static void OpC8X1()
+static void OpC8X1(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#endif
-#ifdef CPU_SHUTDOWN
CPU.WaitAddress = NULL;
-#endif
ICPU.Registers.YL++;
SetZN8(ICPU.Registers.YL);
}
-static void OpC8X0()
+static void OpC8X0(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#endif
-#ifdef CPU_SHUTDOWN
CPU.WaitAddress = NULL;
-#endif
ICPU.Registers.Y.W++;
SetZN16(ICPU.Registers.Y.W);
}
@@ -2807,7 +2740,7 @@ static void OpC8X0()
/**********************************************************************************************/
/* NOP *************************************************************************************** */
-static void OpEA()
+static void OpEA(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
@@ -2833,46 +2766,46 @@ static void OpEA()
ICPU.Registers.SH = 0x01;
//PEA NL
-static void OpF4E1()
+static void OpF4E1(void)
{
Absolute(false);
PushWE((uint16_t)OpAddress);
}
-static void OpF4()
+static void OpF4(void)
{
Absolute(false);
PushW((uint16_t)OpAddress);
}
//PEI NL
-static void OpD4E1()
+static void OpD4E1(void)
{
DirectIndirect(false);
PushWE((uint16_t)OpAddress);
}
-static void OpD4()
+static void OpD4(void)
{
DirectIndirect(false);
PushW((uint16_t)OpAddress);
}
//PER NL
-static void Op62E1()
+static void Op62E1(void)
{
RelativeLong(false);
PushWE((uint16_t)OpAddress);
}
-static void Op62()
+static void Op62(void)
{
RelativeLong(false);
PushW((uint16_t)OpAddress);
}
//PHA
-static void Op48E1()
+static void Op48E1(void)
{
PushBE(ICPU.Registers.AL);
#ifndef SA1_OPCODES
@@ -2880,7 +2813,7 @@ static void Op48E1()
#endif
}
-static void Op48M1()
+static void Op48M1(void)
{
PushB(ICPU.Registers.AL);
#ifndef SA1_OPCODES
@@ -2888,7 +2821,7 @@ static void Op48M1()
#endif
}
-static void Op48M0()
+static void Op48M0(void)
{
PushW(ICPU.Registers.A.W);
#ifndef SA1_OPCODES
@@ -2897,7 +2830,7 @@ static void Op48M0()
}
//PHB
-static void Op8BE1()
+static void Op8BE1(void)
{
PushBE(ICPU.Registers.DB);
#ifndef SA1_OPCODES
@@ -2905,7 +2838,7 @@ static void Op8BE1()
#endif
}
-static void Op8B()
+static void Op8B(void)
{
PushB(ICPU.Registers.DB);
#ifndef SA1_OPCODES
@@ -2914,7 +2847,7 @@ static void Op8B()
}
//PHD NL
-static void Op0BE1()
+static void Op0BE1(void)
{
PushWE(ICPU.Registers.D.W);
#ifndef SA1_OPCODES
@@ -2922,7 +2855,7 @@ static void Op0BE1()
#endif
}
-static void Op0B()
+static void Op0B(void)
{
PushW(ICPU.Registers.D.W);
#ifndef SA1_OPCODES
@@ -2931,7 +2864,7 @@ static void Op0B()
}
//PHK
-static void Op4BE1()
+static void Op4BE1(void)
{
PushBE(ICPU.Registers.PB);
#ifndef SA1_OPCODES
@@ -2939,7 +2872,7 @@ static void Op4BE1()
#endif
}
-static void Op4B()
+static void Op4B(void)
{
PushB(ICPU.Registers.PB);
#ifndef SA1_OPCODES
@@ -2948,7 +2881,7 @@ static void Op4B()
}
//PHP
-static void Op08E1()
+static void Op08E1(void)
{
S9xPackStatus();
PushBE(ICPU.Registers.PL);
@@ -2957,7 +2890,7 @@ static void Op08E1()
#endif
}
-static void Op08()
+static void Op08(void)
{
S9xPackStatus();
PushB(ICPU.Registers.PL);
@@ -2967,7 +2900,7 @@ static void Op08()
}
//PHX
-static void OpDAE1()
+static void OpDAE1(void)
{
PushBE(ICPU.Registers.XL);
#ifndef SA1_OPCODES
@@ -2975,7 +2908,7 @@ static void OpDAE1()
#endif
}
-static void OpDAX1()
+static void OpDAX1(void)
{
PushB(ICPU.Registers.XL);
#ifndef SA1_OPCODES
@@ -2983,7 +2916,7 @@ static void OpDAX1()
#endif
}
-static void OpDAX0()
+static void OpDAX0(void)
{
PushW(ICPU.Registers.X.W);
#ifndef SA1_OPCODES
@@ -2992,7 +2925,7 @@ static void OpDAX0()
}
//PHY
-static void Op5AE1()
+static void Op5AE1(void)
{
PushBE(ICPU.Registers.YL);
#ifndef SA1_OPCODES
@@ -3000,7 +2933,7 @@ static void Op5AE1()
#endif
}
-static void Op5AX1()
+static void Op5AX1(void)
{
PushB(ICPU.Registers.YL);
#ifndef SA1_OPCODES
@@ -3008,7 +2941,7 @@ static void Op5AX1()
#endif
}
-static void Op5AX0()
+static void Op5AX0(void)
{
PushW(ICPU.Registers.Y.W);
#ifndef SA1_OPCODES
@@ -3034,7 +2967,7 @@ static void Op5AX0()
ICPU.Registers.SH = 0x01;
//PLA
-static void Op68E1()
+static void Op68E1(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += TWO_CYCLES;
@@ -3043,7 +2976,7 @@ static void Op68E1()
SetZN8(ICPU.Registers.AL);
}
-static void Op68M1()
+static void Op68M1(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += TWO_CYCLES;
@@ -3052,7 +2985,7 @@ static void Op68M1()
SetZN8(ICPU.Registers.AL);
}
-static void Op68M0()
+static void Op68M0(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += TWO_CYCLES;
@@ -3062,7 +2995,7 @@ static void Op68M0()
}
//PLB
-static void OpABE1()
+static void OpABE1(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += TWO_CYCLES;
@@ -3072,7 +3005,7 @@ static void OpABE1()
ICPU.ShiftedDB = ICPU.Registers.DB << 16;
}
-static void OpAB()
+static void OpAB(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += TWO_CYCLES;
@@ -3084,7 +3017,7 @@ static void OpAB()
/* PHP */
//PLD NL
-static void Op2BE1()
+static void Op2BE1(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += TWO_CYCLES;
@@ -3093,7 +3026,7 @@ static void Op2BE1()
SetZN16(ICPU.Registers.D.W);
}
-static void Op2B()
+static void Op2B(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += TWO_CYCLES;
@@ -3103,7 +3036,7 @@ static void Op2B()
}
/* PLP */
-static void Op28E1()
+static void Op28E1(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += TWO_CYCLES;
@@ -3119,7 +3052,7 @@ static void Op28E1()
S9xFixCycles();
}
-static void Op28()
+static void Op28(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += TWO_CYCLES;
@@ -3136,7 +3069,7 @@ static void Op28()
}
//PLX
-static void OpFAE1()
+static void OpFAE1(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += TWO_CYCLES;
@@ -3145,7 +3078,7 @@ static void OpFAE1()
SetZN8(ICPU.Registers.XL);
}
-static void OpFAX1()
+static void OpFAX1(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += TWO_CYCLES;
@@ -3154,7 +3087,7 @@ static void OpFAX1()
SetZN8(ICPU.Registers.XL);
}
-static void OpFAX0()
+static void OpFAX0(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += TWO_CYCLES;
@@ -3164,7 +3097,7 @@ static void OpFAX0()
}
//PLY
-static void Op7AE1()
+static void Op7AE1(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += TWO_CYCLES;
@@ -3173,7 +3106,7 @@ static void Op7AE1()
SetZN8(ICPU.Registers.YL);
}
-static void Op7AX1()
+static void Op7AX1(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += TWO_CYCLES;
@@ -3182,7 +3115,7 @@ static void Op7AX1()
SetZN8(ICPU.Registers.YL);
}
-static void Op7AX0()
+static void Op7AX0(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += TWO_CYCLES;
@@ -3195,7 +3128,7 @@ static void Op7AX0()
/* SetFlag Instructions ********************************************************************** */
/* SEC */
-static void Op38()
+static void Op38(void)
{
SetCarry();
#ifndef SA1_OPCODES
@@ -3204,17 +3137,16 @@ static void Op38()
}
/* SED */
-static void OpF8()
+static void OpF8(void)
{
SetDecimal();
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#endif
- missing.decimal_mode = 1;
}
/* SEI */
-static void Op78()
+static void Op78(void)
{
SetIRQ();
#ifndef SA1_OPCODES
@@ -3225,7 +3157,7 @@ static void Op78()
/* Transfer Instructions ********************************************************************* */
/* TAX8 */
-static void OpAAX1()
+static void OpAAX1(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
@@ -3235,7 +3167,7 @@ static void OpAAX1()
}
/* TAX16 */
-static void OpAAX0()
+static void OpAAX0(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
@@ -3245,7 +3177,7 @@ static void OpAAX0()
}
/* TAY8 */
-static void OpA8X1()
+static void OpA8X1(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
@@ -3255,7 +3187,7 @@ static void OpA8X1()
}
/* TAY16 */
-static void OpA8X0()
+static void OpA8X0(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
@@ -3264,7 +3196,7 @@ static void OpA8X0()
SetZN16(ICPU.Registers.Y.W);
}
-static void Op5B()
+static void Op5B(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
@@ -3273,7 +3205,7 @@ static void Op5B()
SetZN16(ICPU.Registers.D.W);
}
-static void Op1B()
+static void Op1B(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
@@ -3283,7 +3215,7 @@ static void Op1B()
ICPU.Registers.SH = 1;
}
-static void Op7B()
+static void Op7B(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
@@ -3292,7 +3224,7 @@ static void Op7B()
SetZN16(ICPU.Registers.A.W);
}
-static void Op3B()
+static void Op3B(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
@@ -3301,7 +3233,7 @@ static void Op3B()
SetZN16(ICPU.Registers.A.W);
}
-static void OpBAX1()
+static void OpBAX1(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
@@ -3310,7 +3242,7 @@ static void OpBAX1()
SetZN8(ICPU.Registers.XL);
}
-static void OpBAX0()
+static void OpBAX0(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
@@ -3319,7 +3251,7 @@ static void OpBAX0()
SetZN16(ICPU.Registers.X.W);
}
-static void Op8AM1()
+static void Op8AM1(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
@@ -3328,7 +3260,7 @@ static void Op8AM1()
SetZN8(ICPU.Registers.AL);
}
-static void Op8AM0()
+static void Op8AM0(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
@@ -3337,7 +3269,7 @@ static void Op8AM0()
SetZN16(ICPU.Registers.A.W);
}
-static void Op9A()
+static void Op9A(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
@@ -3347,7 +3279,7 @@ static void Op9A()
ICPU.Registers.SH = 1;
}
-static void Op9BX1()
+static void Op9BX1(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
@@ -3356,7 +3288,7 @@ static void Op9BX1()
SetZN8(ICPU.Registers.YL);
}
-static void Op9BX0()
+static void Op9BX0(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
@@ -3365,7 +3297,7 @@ static void Op9BX0()
SetZN16(ICPU.Registers.Y.W);
}
-static void Op98M1()
+static void Op98M1(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
@@ -3374,7 +3306,7 @@ static void Op98M1()
SetZN8(ICPU.Registers.AL);
}
-static void Op98M0()
+static void Op98M0(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
@@ -3383,7 +3315,7 @@ static void Op98M0()
SetZN16(ICPU.Registers.A.W);
}
-static void OpBBX1()
+static void OpBBX1(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
@@ -3392,7 +3324,7 @@ static void OpBBX1()
SetZN8(ICPU.Registers.XL);
}
-static void OpBBX0()
+static void OpBBX0(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
@@ -3404,7 +3336,7 @@ static void OpBBX0()
/**********************************************************************************************/
/* XCE *************************************************************************************** */
-static void OpFB()
+static void OpFB(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
@@ -3418,7 +3350,6 @@ static void OpFB()
{
SetFlags(MemoryFlag | IndexFlag);
ICPU.Registers.SH = 1;
- missing.emulate6502 = 1;
}
if (CheckIndex())
{
@@ -3430,11 +3361,8 @@ static void OpFB()
/**********************************************************************************************/
/* BRK *************************************************************************************** */
-static void Op00()
+static void Op00(void)
{
-#ifndef SA1_OPCODES
- CPU.BRKTriggered = true;
-#endif
if (!CheckEmulation())
{
PushB(ICPU.Registers.PB);
@@ -3472,7 +3400,7 @@ static void Op00()
/**********************************************************************************************/
/* BRL ************************************************************************************** */
-static void Op82()
+static void Op82(void)
{
RelativeLong();
S9xSetPCBase(ICPU.ShiftedPB + OpAddress);
@@ -3480,7 +3408,7 @@ static void Op82()
/**********************************************************************************************/
/* IRQ *************************************************************************************** */
-void S9xOpcode_IRQ()
+void S9xOpcode_IRQ(void)
{
if (!CheckEmulation())
{
@@ -3538,7 +3466,7 @@ void S9xOpcode_IRQ()
/**********************************************************************************************/
/* NMI *************************************************************************************** */
-void S9xOpcode_NMI()
+void S9xOpcode_NMI(void)
{
if (!CheckEmulation())
{
@@ -3595,7 +3523,7 @@ void S9xOpcode_NMI()
/**********************************************************************************************/
/* COP *************************************************************************************** */
-static void Op02()
+static void Op02(void)
{
if (!CheckEmulation())
{
@@ -3634,7 +3562,7 @@ static void Op02()
/**********************************************************************************************/
/* JML *************************************************************************************** */
-static void OpDC()
+static void OpDC(void)
{
AbsoluteIndirectLong(false);
ICPU.Registers.PB = (uint8_t)(OpAddress >> 16);
@@ -3645,7 +3573,7 @@ static void OpDC()
#endif
}
-static void Op5C()
+static void Op5C(void)
{
AbsoluteLong(false);
ICPU.Registers.PB = (uint8_t)(OpAddress >> 16);
@@ -3655,22 +3583,22 @@ static void Op5C()
/**********************************************************************************************/
/* JMP *************************************************************************************** */
-static void Op4C()
+static void Op4C(void)
{
Absolute(false);
S9xSetPCBase(ICPU.ShiftedPB + (OpAddress & 0xffff));
-#if defined(CPU_SHUTDOWN) && defined(SA1_OPCODES)
+#ifdef SA1_OPCODES
CPUShutdown();
#endif
}
-static void Op6C()
+static void Op6C(void)
{
AbsoluteIndirect(false);
S9xSetPCBase(ICPU.ShiftedPB + (OpAddress & 0xffff));
}
-static void Op7C()
+static void Op7C(void)
{
AbsoluteIndexedIndirect(false);
S9xSetPCBase(ICPU.ShiftedPB + OpAddress);
@@ -3681,7 +3609,7 @@ static void Op7C()
/**********************************************************************************************/
/* JSL/RTL *********************************************************************************** */
-static void Op22E1()
+static void Op22E1(void)
{
AbsoluteLong(false);
PushB(ICPU.Registers.PB);
@@ -3691,7 +3619,7 @@ static void Op22E1()
S9xSetPCBase(OpAddress);
}
-static void Op22()
+static void Op22(void)
{
AbsoluteLong(false);
PushB(ICPU.Registers.PB);
@@ -3701,7 +3629,7 @@ static void Op22()
S9xSetPCBase(OpAddress);
}
-static void Op6BE1()
+static void Op6BE1(void)
{
PullWE(ICPU.Registers.PC);
PullB(ICPU.Registers.PB);
@@ -3712,7 +3640,7 @@ static void Op6BE1()
#endif
}
-static void Op6B()
+static void Op6B(void)
{
PullW(ICPU.Registers.PC);
PullB(ICPU.Registers.PB);
@@ -3725,7 +3653,7 @@ static void Op6B()
/**********************************************************************************************/
/* JSR/RTS *********************************************************************************** */
-static void Op20()
+static void Op20(void)
{
Absolute(false);
PushW(CPU.PC - CPU.PCBase - 1);
@@ -3736,7 +3664,7 @@ static void Op20()
}
//JSR a,x
-static void OpFCE1()
+static void OpFCE1(void)
{
AbsoluteIndexedIndirect(false);
PushWE(CPU.PC - CPU.PCBase - 1);
@@ -3746,7 +3674,7 @@ static void OpFCE1()
#endif
}
-static void OpFC()
+static void OpFC(void)
{
AbsoluteIndexedIndirect(false);
PushW(CPU.PC - CPU.PCBase - 1);
@@ -3756,7 +3684,7 @@ static void OpFC()
#endif
}
-static void Op60()
+static void Op60(void)
{
PullW(ICPU.Registers.PC);
S9xSetPCBase(ICPU.ShiftedPB + ((ICPU.Registers.PC + 1) & 0xffff));
@@ -3768,7 +3696,7 @@ static void Op60()
/**********************************************************************************************/
/* MVN/MVP *********************************************************************************** */
-static void Op54X1()
+static void Op54X1(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += CPU.MemSpeedx2 + TWO_CYCLES;
@@ -3787,7 +3715,7 @@ static void Op54X1()
CPU.PC -= 3;
}
-static void Op54X0()
+static void Op54X0(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += CPU.MemSpeedx2 + TWO_CYCLES;
@@ -3806,7 +3734,7 @@ static void Op54X0()
CPU.PC -= 3;
}
-static void Op44X1()
+static void Op44X1(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += CPU.MemSpeedx2 + TWO_CYCLES;
@@ -3823,7 +3751,7 @@ static void Op44X1()
CPU.PC -= 3;
}
-static void Op44X0()
+static void Op44X0(void)
{
#ifndef SA1_OPCODES
CPU.Cycles += CPU.MemSpeedx2 + TWO_CYCLES;
@@ -3843,7 +3771,7 @@ static void Op44X0()
/**********************************************************************************************/
/* REP/SEP *********************************************************************************** */
-static void OpC2()
+static void OpC2(void)
{
uint8_t Work8 = ~*CPU.PC++;
ICPU.Registers.PL &= Work8;
@@ -3856,10 +3784,7 @@ static void OpC2()
CPU.Cycles += CPU.MemSpeed + ONE_CYCLE;
#endif
if (CheckEmulation())
- {
SetFlags(MemoryFlag | IndexFlag);
- missing.emulate6502 = 1;
- }
if (CheckIndex())
{
ICPU.Registers.XH = 0;
@@ -3868,7 +3793,7 @@ static void OpC2()
S9xFixCycles();
}
-static void OpE2()
+static void OpE2(void)
{
uint8_t Work8 = *CPU.PC++;
ICPU.Registers.PL |= Work8;
@@ -3881,10 +3806,7 @@ static void OpE2()
CPU.Cycles += CPU.MemSpeed + ONE_CYCLE;
#endif
if (CheckEmulation())
- {
SetFlags(MemoryFlag | IndexFlag);
- missing.emulate6502 = 1;
- }
if (CheckIndex())
{
ICPU.Registers.XH = 0;
@@ -3895,7 +3817,7 @@ static void OpE2()
/**********************************************************************************************/
/* XBA *************************************************************************************** */
-static void OpEB()
+static void OpEB(void)
{
uint8_t Work8 = ICPU.Registers.AL;
ICPU.Registers.AL = ICPU.Registers.AH;
@@ -3908,7 +3830,7 @@ static void OpEB()
/**********************************************************************************************/
/* RTI *************************************************************************************** */
-static void Op40()
+static void Op40(void)
{
PullB(ICPU.Registers.PL);
S9xUnpackStatus();
@@ -3919,10 +3841,7 @@ static void Op40()
ICPU.ShiftedPB = ICPU.Registers.PB << 16;
}
else
- {
SetFlags(MemoryFlag | IndexFlag);
- missing.emulate6502 = 1;
- }
S9xSetPCBase(ICPU.ShiftedPB + ICPU.Registers.PC);
if (CheckIndex())
{
@@ -3939,7 +3858,7 @@ static void Op40()
/* STP/WAI/DB ******************************************************************************** */
// WAI
-static void OpCB()
+static void OpCB(void)
{
#ifdef SA1_OPCODES
SA1.WaitingForInterrupt = true;
@@ -3947,7 +3866,6 @@ static void OpCB()
#else // SA_OPCODES
CPU.WaitingForInterrupt = true;
CPU.PC--;
-#ifdef CPU_SHUTDOWN
if (Settings.Shutdown)
{
CPU.Cycles = CPU.NextEvent;
@@ -3965,14 +3883,13 @@ static void OpCB()
#endif
}
#endif
-#endif
}
// Usually an STP opcode
// SNESAdvance speed hack, not implemented in Snes9xTYL | Snes9x-Euphoria (from the speed-hacks branch of CatSFC)
-static void OpDB()
+static void OpDB(void)
{
-#if !defined NO_SPEEDHACKS && defined CPU_SHUTDOWN
+#ifndef NO_SPEEDHACKS
uint8_t NextByte = *CPU.PC++;
ForceShutdown();
@@ -3984,11 +3901,11 @@ static void OpDB()
switch (NextByte & 0x80)
{
case 0x00: // BNE
- BranchCheck1 ();
+ BranchCheck();
if (!CheckZero ())
{
CPU.PC = CPU.PCBase + OpAddress;
-#ifdef VAR_CYCLES
+#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#else
#ifndef SA1_OPCODES
@@ -3999,11 +3916,11 @@ static void OpDB()
}
return;
case 0x80: // BEQ
- BranchCheck2 ();
+ BranchCheck();
if (CheckZero ())
{
CPU.PC = CPU.PCBase + OpAddress;
-#ifdef VAR_CYCLES
+#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#else
#ifndef SA1_OPCODES
@@ -4021,9 +3938,9 @@ static void OpDB()
}
// SNESAdvance speed hack, as implemented in Snes9xTYL / Snes9x-Euphoria (from the speed-hacks branch of CatSFC)
-static void Op42()
+static void Op42(void)
{
-#if !defined NO_SPEEDHACKS && defined CPU_SHUTDOWN
+#ifndef NO_SPEEDHACKS
uint8_t NextByte = *CPU.PC++;
ForceShutdown();
@@ -4034,11 +3951,11 @@ static void Op42()
switch (NextByte & 0xF0)
{
case 0x10: // BPL
- BranchCheck1 ();
+ BranchCheck();
if (!CheckNegative ())
{
CPU.PC = CPU.PCBase + OpAddress;
-#ifdef VAR_CYCLES
+#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#else
#ifndef SA1_OPCODES
@@ -4049,11 +3966,11 @@ static void Op42()
}
return;
case 0x30: // BMI
- BranchCheck1 ();
+ BranchCheck();
if (CheckNegative ())
{
CPU.PC = CPU.PCBase + OpAddress;
-#ifdef VAR_CYCLES
+#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#else
#ifndef SA1_OPCODES
@@ -4064,11 +3981,11 @@ static void Op42()
}
return;
case 0x50: // BVC
- BranchCheck0 ();
+ BranchCheck();
if (!CheckOverflow ())
{
CPU.PC = CPU.PCBase + OpAddress;
-#ifdef VAR_CYCLES
+#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#else
#ifndef SA1_OPCODES
@@ -4079,11 +3996,11 @@ static void Op42()
}
return;
case 0x70: // BVS
- BranchCheck0 ();
+ BranchCheck();
if (CheckOverflow ())
{
CPU.PC = CPU.PCBase + OpAddress;
-#ifdef VAR_CYCLES
+#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#else
#ifndef SA1_OPCODES
@@ -4095,7 +4012,7 @@ static void Op42()
return;
case 0x80: // BRA
CPU.PC = CPU.PCBase + OpAddress;
-#ifdef VAR_CYCLES
+#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#else
#ifndef SA1_OPCODES
@@ -4105,11 +4022,11 @@ static void Op42()
CPUShutdown ();
return;
case 0x90: // BCC
- BranchCheck0 ();
+ BranchCheck();
if (!CheckCarry ())
{
CPU.PC = CPU.PCBase + OpAddress;
-#ifdef VAR_CYCLES
+#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#else
#ifndef SA1_OPCODES
@@ -4120,11 +4037,11 @@ static void Op42()
}
return;
case 0xB0: // BCS
- BranchCheck0 ();
+ BranchCheck();
if (CheckCarry ())
{
CPU.PC = CPU.PCBase + OpAddress;
-#ifdef VAR_CYCLES
+#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#else
#ifndef SA1_OPCODES
@@ -4135,11 +4052,11 @@ static void Op42()
}
return;
case 0xD0: // BNE
- BranchCheck1 ();
+ BranchCheck();
if (!CheckZero ())
{
CPU.PC = CPU.PCBase + OpAddress;
-#ifdef VAR_CYCLES
+#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#else
#ifndef SA1_OPCODES
@@ -4150,11 +4067,11 @@ static void Op42()
}
return;
case 0xF0: // BEQ
- BranchCheck2 ();
+ BranchCheck();
if (CheckZero ())
{
CPU.PC = CPU.PCBase + OpAddress;
-#ifdef VAR_CYCLES
+#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#else
#ifndef SA1_OPCODES
diff --git a/source/display.h b/source/display.h
index 44e0900..e7732bc 100644
--- a/source/display.h
+++ b/source/display.h
@@ -8,12 +8,10 @@ uint32_t S9xReadJoypad(int32_t port);
bool S9xReadMousePosition(int32_t which1_0_to_1, int32_t* x, int32_t* y, uint32_t* buttons);
bool S9xReadSuperScopePosition(int32_t* x, int32_t* y, uint32_t* buttons);
-void S9xInitDisplay();
-void S9xDeinitDisplay();
+void S9xInitDisplay(void);
+void S9xDeinitDisplay(void);
void S9xToggleSoundChannel(int32_t channel);
-void S9xSetInfoString(const char* string);
-void S9xNextController();
-bool S9xLoadROMImage(const char* string);
+void S9xNextController(void);
const char* S9xGetFilename(const char* extension);
diff --git a/source/dma.c b/source/dma.c
index e943975..399d956 100644
--- a/source/dma.c
+++ b/source/dma.c
@@ -1,41 +1,25 @@
#include "../copyright"
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
#include "snes9x.h"
-
#include "memmap.h"
#include "ppu.h"
#include "cpuexec.h"
-#include "missing.h"
#include "dma.h"
#include "apu.h"
#include "sa1.h"
#include "spc7110.h"
-
-#ifdef SDD1_DECOMP
#include "sdd1emu.h"
-#endif
-#ifdef SDD1_DECOMP
static uint8_t sdd1_decode_buffer[0x10000];
-#endif
extern int32_t HDMA_ModeByteCounts [8];
extern uint8_t* HDMAMemPointers [8];
extern uint8_t* HDMABasePointers [8];
-#ifdef SETA010_HDMA_FROM_CART
-uint32_t HDMARawPointers[8]; // Cart address space pointer
-#endif
-
/**********************************************************************************************/
/* S9xDoDMA() */
/* This function preforms the general dma transfer */
/**********************************************************************************************/
-
void S9xDoDMA(uint8_t Channel)
{
uint8_t Work;
@@ -50,7 +34,6 @@ void S9xDoDMA(uint8_t Channel)
bool s7_wrap = false;
SDMA* d = &DMA[Channel];
-
int32_t count = d->TransferBytes;
// Prepare for custom chip DMA
@@ -76,8 +59,6 @@ void S9xDoDMA(uint8_t Channel)
FLUSH_REDRAW();
break;
}
- // S-DD1
-#ifdef SDD1_DECOMP
if (Settings.SDD1)
{
if (d->AAddressFixed && Memory.FillRAM [0x4801] > 0)
@@ -97,7 +78,6 @@ void S9xDoDMA(uint8_t Channel)
Memory.FillRAM [0x4801] = 0;
}
-#endif
if (Settings.SPC7110 && (d->AAddress == 0x4800 || d->ABank == 0x50))
{
uint32_t i;
@@ -519,7 +499,6 @@ void S9xDoDMA(uint8_t Channel)
d->AAddress += inc;
--count;
break;
-
case 1:
case 5:
Work = S9xGetPPU(0x2100 + d->BAddress);
@@ -533,7 +512,6 @@ void S9xDoDMA(uint8_t Channel)
d->AAddress += inc;
count--;
break;
-
case 3:
case 7:
Work = S9xGetPPU(0x2100 + d->BAddress);
@@ -593,15 +571,13 @@ void S9xDoDMA(uint8_t Channel)
while (count);
}
#ifndef USE_BLARGG_APU
-#ifdef SPC700_C
IAPU.APUExecuting = Settings.APUEnabled;
APU_EXECUTE();
#endif
-#endif
if (Settings.SuperFX)
while (CPU.Cycles > CPU.NextEvent)
S9xDoHBlankProcessing_SFX();
- else /* if (!Settings.SuperFX) */
+ else
while (CPU.Cycles > CPU.NextEvent)
S9xDoHBlankProcessing_NoSFX();
@@ -633,20 +609,18 @@ void S9xStartHDMA()
if (Settings.DisableHDMA)
IPPU.HDMA = 0;
else
- missing.hdma_this_frame = IPPU.HDMA = Memory.FillRAM [0x420c];
+ IPPU.HDMA = Memory.FillRAM [0x420c];
//per anomie timing post
if (IPPU.HDMA != 0)
CPU.Cycles += ONE_CYCLE * 3;
- IPPU.HDMAStarted = true;
-
uint8_t i;
for (i = 0; i < 8; i++)
{
if (IPPU.HDMA & (1 << i))
{
- CPU.Cycles += SLOW_ONE_CYCLE ;
+ CPU.Cycles += SLOW_ONE_CYCLE;
DMA [i].LineCount = 0;
DMA [i].FirstLine = true;
DMA [i].Address = DMA [i].AAddress;
@@ -654,9 +628,6 @@ void S9xStartHDMA()
CPU.Cycles += (SLOW_ONE_CYCLE << 2);
}
HDMAMemPointers [i] = NULL;
-#ifdef SETA010_HDMA_FROM_CART
- HDMARawPointers [i] = 0;
-#endif
}
}
@@ -694,11 +665,7 @@ uint8_t S9xDoHDMA(uint8_t byte)
/* XXX: instead of p->BAddress == 0x18, make S9xSetPPU fail
* XXX: writes to $2118/9 when appropriate
*/
-#ifdef SETA010_HDMA_FROM_CART
- if (!p->LineCount)
-#else
if (!p->LineCount || p->BAddress == 0x18)
-#endif
{
byte &= ~mask;
p->IndirectAddress += HDMAMemPointers [d] - HDMABasePointers [d];
@@ -708,7 +675,7 @@ uint8_t S9xDoHDMA(uint8_t byte)
}
p->Address++;
- p->FirstLine = 1;
+ p->FirstLine = true;
if (p->HDMAIndirectAddressing)
{
p->IndirectBank = Memory.FillRAM [0x4307 + (d << 4)];
@@ -722,11 +689,7 @@ uint8_t S9xDoHDMA(uint8_t byte)
p->IndirectBank = p->ABank;
p->IndirectAddress = p->Address;
}
- HDMABasePointers [d] = HDMAMemPointers [d] =
- S9xGetMemPointer((p->IndirectBank << 16) + p->IndirectAddress);
-#ifdef SETA010_HDMA_FROM_CART
- HDMARawPointers [d] = (p->IndirectBank << 16) + p->IndirectAddress;
-#endif
+ HDMABasePointers [d] = HDMAMemPointers [d] = S9xGetMemPointer((p->IndirectBank << 16) + p->IndirectAddress);
}
else
CPU.Cycles += SLOW_ONE_CYCLE;
@@ -738,9 +701,7 @@ uint8_t S9xDoHDMA(uint8_t byte)
p->IndirectBank = p->ABank;
p->IndirectAddress = p->Address;
}
-#ifdef SETA010_HDMA_FROM_CART
- HDMARawPointers [d] = (p->IndirectBank << 16) + p->IndirectAddress;
-#endif
+
if (!(HDMABasePointers [d] = HDMAMemPointers [d] =
S9xGetMemPointer((p->IndirectBank << 16) + p->IndirectAddress)))
{
@@ -763,88 +724,49 @@ uint8_t S9xDoHDMA(uint8_t byte)
{
case 0:
CPU.Cycles += SLOW_ONE_CYCLE;
-#ifdef SETA010_HDMA_FROM_CART
- S9xSetPPU(S9xGetByte(HDMARawPointers [d]++), 0x2100 + p->BAddress);
- HDMAMemPointers [d]++;
-#else
S9xSetPPU(*HDMAMemPointers [d]++, 0x2100 + p->BAddress);
-#endif
break;
case 5:
CPU.Cycles += 2 * SLOW_ONE_CYCLE;
-#ifdef SETA010_HDMA_FROM_CART
- S9xSetPPU(S9xGetByte(HDMARawPointers [d]), 0x2100 + p->BAddress);
- S9xSetPPU(S9xGetByte(HDMARawPointers [d] + 1), 0x2101 + p->BAddress);
- HDMARawPointers [d] += 2;
-#else
S9xSetPPU(*(HDMAMemPointers [d] + 0), 0x2100 + p->BAddress);
S9xSetPPU(*(HDMAMemPointers [d] + 1), 0x2101 + p->BAddress);
-#endif
HDMAMemPointers [d] += 2;
/* fall through */
case 1:
CPU.Cycles += 2 * SLOW_ONE_CYCLE;
-#ifdef SETA010_HDMA_FROM_CART
- S9xSetPPU(S9xGetByte(HDMARawPointers [d]), 0x2100 + p->BAddress);
- S9xSetPPU(S9xGetByte(HDMARawPointers [d] + 1), 0x2101 + p->BAddress);
- HDMARawPointers [d] += 2;
-#else
S9xSetPPU(*(HDMAMemPointers [d] + 0), 0x2100 + p->BAddress);
S9xSetPPU(*(HDMAMemPointers [d] + 1), 0x2101 + p->BAddress);
-#endif
HDMAMemPointers [d] += 2;
break;
case 2:
case 6:
CPU.Cycles += 2 * SLOW_ONE_CYCLE;
-#ifdef SETA010_HDMA_FROM_CART
- S9xSetPPU(S9xGetByte(HDMARawPointers [d]), 0x2100 + p->BAddress);
- S9xSetPPU(S9xGetByte(HDMARawPointers [d] + 1), 0x2100 + p->BAddress);
- HDMARawPointers [d] += 2;
-#else
S9xSetPPU(*(HDMAMemPointers [d] + 0), 0x2100 + p->BAddress);
S9xSetPPU(*(HDMAMemPointers [d] + 1), 0x2100 + p->BAddress);
-#endif
HDMAMemPointers [d] += 2;
break;
case 3:
case 7:
CPU.Cycles += 4 * SLOW_ONE_CYCLE;
-#ifdef SETA010_HDMA_FROM_CART
- S9xSetPPU(S9xGetByte(HDMARawPointers [d]), 0x2100 + p->BAddress);
- S9xSetPPU(S9xGetByte(HDMARawPointers [d] + 1), 0x2100 + p->BAddress);
- S9xSetPPU(S9xGetByte(HDMARawPointers [d] + 2), 0x2101 + p->BAddress);
- S9xSetPPU(S9xGetByte(HDMARawPointers [d] + 3), 0x2101 + p->BAddress);
- HDMARawPointers [d] += 4;
-#else
S9xSetPPU(*(HDMAMemPointers [d] + 0), 0x2100 + p->BAddress);
S9xSetPPU(*(HDMAMemPointers [d] + 1), 0x2100 + p->BAddress);
S9xSetPPU(*(HDMAMemPointers [d] + 2), 0x2101 + p->BAddress);
S9xSetPPU(*(HDMAMemPointers [d] + 3), 0x2101 + p->BAddress);
-#endif
HDMAMemPointers [d] += 4;
break;
case 4:
CPU.Cycles += 4 * SLOW_ONE_CYCLE;
-#ifdef SETA010_HDMA_FROM_CART
- S9xSetPPU(S9xGetByte(HDMARawPointers [d]), 0x2100 + p->BAddress);
- S9xSetPPU(S9xGetByte(HDMARawPointers [d] + 1), 0x2101 + p->BAddress);
- S9xSetPPU(S9xGetByte(HDMARawPointers [d] + 2), 0x2102 + p->BAddress);
- S9xSetPPU(S9xGetByte(HDMARawPointers [d] + 3), 0x2103 + p->BAddress);
- HDMARawPointers [d] += 4;
-#else
S9xSetPPU(*(HDMAMemPointers [d] + 0), 0x2100 + p->BAddress);
S9xSetPPU(*(HDMAMemPointers [d] + 1), 0x2101 + p->BAddress);
S9xSetPPU(*(HDMAMemPointers [d] + 2), 0x2102 + p->BAddress);
S9xSetPPU(*(HDMAMemPointers [d] + 3), 0x2103 + p->BAddress);
-#endif
HDMAMemPointers [d] += 4;
break;
}
if (!p->HDMAIndirectAddressing)
p->Address += HDMA_ModeByteCounts [p->TransferMode];
p->IndirectAddress += HDMA_ModeByteCounts [p->TransferMode];
- /* XXX: Check for p->IndirectAddress crossing a mapping boundry,
+ /* XXX: Check for p->IndirectAddress crossing a mapping boundary,
* XXX: and invalidate HDMAMemPointers[d]
*/
p->FirstLine = false;
@@ -852,7 +774,7 @@ uint8_t S9xDoHDMA(uint8_t byte)
}
}
CPU.InDMA = false;
- return (byte);
+ return byte;
}
void S9xResetDMA()
diff --git a/source/dma.h b/source/dma.h
index 7782ee2..c2ab8d2 100644
--- a/source/dma.h
+++ b/source/dma.h
@@ -3,9 +3,9 @@
#ifndef _DMA_H_
#define _DMA_H_
-void S9xResetDMA();
+void S9xResetDMA(void);
uint8_t S9xDoHDMA(uint8_t);
-void S9xStartHDMA();
+void S9xStartHDMA(void);
void S9xDoDMA(uint8_t);
#endif
diff --git a/source/dsp1.c b/source/dsp1.c
index 9e7f05b..2166e87 100644
--- a/source/dsp1.c
+++ b/source/dsp1.c
@@ -2,10 +2,7 @@
#include "snes9x.h"
#include "dsp1.h"
-#include "missing.h"
#include "memmap.h"
-#include <math.h>
-
#include "dsp1emu.c"
#include "dsp2emu.c"
@@ -124,9 +121,9 @@ void DSP1SetByte(uint8_t byte, uint16_t address)
case 0x32:
DSP1.in_count = 7;
break;
- case 0x3a:
- case 0x2a:
case 0x1a:
+ case 0x2a:
+ case 0x3a:
DSP1.command = 0x1a;
DSP1.in_count = 1;
break;
@@ -786,7 +783,7 @@ typedef struct
uint32_t out_count;
uint32_t out_index;
uint8_t parameters [512];
- uint8_t output [512];
+ uint8_t output [512];
} SDSP4;
SDSP4 DSP4;
@@ -826,38 +823,36 @@ void DSP4SetByte(uint8_t byte, uint16_t address)
switch (DSP4.command)
{
- case 0x0000:
- DSP4.in_count = 4;
- break;
- case 0x0001:
- DSP4.in_count = 36;
- break;
case 0x0003:
case 0x0005:
case 0x0006:
+ case 0x000E:
DSP4.in_count = 0;
break;
- case 0x0007:
- DSP4.in_count = 22;
+ case 0x0000:
+ DSP4.in_count = 4;
break;
- case 0x0008:
- DSP4.in_count = 72;
+ case 0x000A:
+ case 0x000B:
+ DSP4.in_count = 6;
+ break;
+ case 0x0011:
+ DSP4.in_count = 8;
break;
case 0x0009:
DSP4.in_count = 14;
break;
- case 0x000A:
- case 0x000B:
- DSP4.in_count = 6;
+ case 0x0007:
+ DSP4.in_count = 22;
break;
case 0x000D:
DSP4.in_count = 34;
break;
- case 0x000E:
- DSP4.in_count = 0;
+ case 0x0001:
+ DSP4.in_count = 36;
break;
- case 0x0011:
- DSP4.in_count = 8;
+ case 0x0008:
+ DSP4.in_count = 72;
break;
default:
DSP4.waiting4command = true;
diff --git a/source/dsp1.h b/source/dsp1.h
index 7cd97c6..4cc2eca 100644
--- a/source/dsp1.h
+++ b/source/dsp1.h
@@ -28,11 +28,10 @@ typedef struct
uint32_t out_count;
uint32_t out_index;
uint8_t parameters [512];
- //output was 512 for DSP-2 work, updated to reflect current thinking on DSP-3
- uint8_t output [512];
+ uint8_t output [512];
} SDSP1;
-void S9xResetDSP1();
+void S9xResetDSP1(void);
uint8_t S9xGetDSP(uint16_t Address);
void S9xSetDSP(uint8_t Byte, uint16_t Address);
extern SDSP1 DSP1;
diff --git a/source/font.h b/source/font.h
index 01ed497..e5fb25c 100644
--- a/source/font.h
+++ b/source/font.h
@@ -60,4 +60,3 @@ static const char* font[] =
static int32_t font_width = 8;
static int32_t font_height = 9;
-
diff --git a/source/fxemu.c b/source/fxemu.c
index 3995a53..dcbf04d 100644
--- a/source/fxemu.c
+++ b/source/fxemu.c
@@ -7,7 +7,7 @@
#include <stdio.h>
/* The FxChip Emulator's internal variables */
-struct FxRegs_s GSU; // This will be initialized when loading a ROM
+FxRegs_s GSU; /* This will be initialized when loading a ROM */
void FxCacheWriteAccess(uint16_t vAddress)
{
@@ -282,10 +282,10 @@ static void fx_writeRegisterSpaceAfterUse()
}
/* Reset the FxChip */
-void FxReset(struct FxInit_s* psFxInfo)
+void FxReset(FxInit_s* psFxInfo)
{
/* Clear all internal variables */
- memset((uint8_t*) &GSU, 0, sizeof(struct FxRegs_s));
+ memset(&GSU, 0, sizeof(FxRegs_s));
/* Set default registers */
GSU.pvSreg = GSU.pvDreg = &R0;
diff --git a/source/fxemu.h b/source/fxemu.h
index 0012c33..3af330c 100644
--- a/source/fxemu.h
+++ b/source/fxemu.h
@@ -6,48 +6,47 @@
#include "snes9x.h"
/* The FxInfo_s structure, the link between the FxEmulator and the Snes Emulator */
-struct FxInit_s
+typedef struct
{
- uint32_t vFlags;
uint8_t* pvRegisters; /* 768 bytes located in the memory at address 0x3000 */
uint32_t nRamBanks; /* Number of 64kb-banks in GSU-RAM/BackupRAM (banks 0x70-0x73) */
uint8_t* pvRam; /* Pointer to GSU-RAM */
uint32_t nRomBanks; /* Number of 32kb-banks in Cart-ROM */
uint8_t* pvRom; /* Pointer to Cart-ROM */
-};
+} FxInit_s;
/* Reset the FxChip */
-extern void FxReset(struct FxInit_s* psFxInfo);
+extern void FxReset(FxInit_s* psFxInfo);
/* Execute until the next stop instruction */
extern int32_t FxEmulate(uint32_t nInstructions);
/* Write access to the cache */
extern void FxCacheWriteAccess(uint16_t vAddress);
-extern void FxFlushCache(); /* Callled when the G flag in SFR is set to zero */
+extern void FxFlushCache(void); /* Called when the G flag in SFR is set to zero */
/* Errors */
-extern int32_t FxGetErrorCode();
-extern int32_t FxGetIllegalAddress();
+extern int32_t FxGetErrorCode(void);
+extern int32_t FxGetIllegalAddress(void);
/* Access to internal registers */
-extern uint32_t FxGetColorRegister();
-extern uint32_t FxGetPlotOptionRegister();
-extern uint32_t FxGetSourceRegisterIndex();
-extern uint32_t FxGetDestinationRegisterIndex();
+extern uint32_t FxGetColorRegister(void);
+extern uint32_t FxGetPlotOptionRegister(void);
+extern uint32_t FxGetSourceRegisterIndex(void);
+extern uint32_t FxGetDestinationRegisterIndex(void);
/* Get the byte currently in the pipe */
-extern uint8_t FxPipe();
+extern uint8_t FxPipe(void);
/* SCBR write seen. We need to update our cached screen pointers */
-extern void fx_dirtySCBR();
+extern void fx_dirtySCBR(void);
/* Update RamBankReg and RAM Bank pointer */
extern void fx_updateRamBank(uint8_t Byte);
/* Option flags */
#define FX_FLAG_ADDRESS_CHECKING 0x01
-#define FX_FLAG_ROM_BUFFER 0x02
+#define FX_FLAG_ROM_BUFFER 0x02
/* Return codes from FxEmulate(), FxStepInto() or FxStepOver() */
#define FX_BREAKPOINT -1
diff --git a/source/fxinst.c b/source/fxinst.c
index 86ccd38..814825b 100644
--- a/source/fxinst.c
+++ b/source/fxinst.c
@@ -7,7 +7,7 @@
#include <string.h>
#include <stdio.h>
-extern struct FxRegs_s GSU;
+extern FxRegs_s GSU;
int32_t gsu_bank [512] = {0};
/* Codes used:
@@ -22,7 +22,7 @@ int32_t gsu_bank [512] = {0};
*/
/* 00 - stop - stop GSU execution (and maybe generate an IRQ) */
-static void fx_stop()
+static inline void fx_stop()
{
CF(G);
GSU.vCounter = 0;
@@ -39,7 +39,7 @@ static void fx_stop()
}
/* 01 - nop - no operation */
-static void fx_nop()
+static inline void fx_nop()
{
CLRFLAGS;
R15++;
@@ -48,7 +48,7 @@ static void fx_nop()
extern void fx_flushCache();
/* 02 - cache - reintialize GSU cache */
-static void fx_cache()
+static inline void fx_cache()
{
uint32_t c = R15 & 0xfff0;
if (GSU.vCacheBaseReg != c || !GSU.bCacheActive)
@@ -62,7 +62,7 @@ static void fx_cache()
}
/* 03 - lsr - logic shift right */
-static void fx_lsr()
+static inline void fx_lsr()
{
uint32_t v;
GSU.vCarry = SREG & 1;
@@ -76,7 +76,7 @@ static void fx_lsr()
}
/* 04 - rol - rotate left */
-static void fx_rol()
+static inline void fx_rol()
{
uint32_t v = USEX16((SREG << 1) + GSU.vCarry);
GSU.vCarry = (SREG >> 15) & 1;
@@ -89,7 +89,7 @@ static void fx_rol()
}
/* 05 - bra - branch always */
-static void fx_bra()
+static inline void fx_bra()
{
uint8_t v = PIPE;
R15++;
@@ -113,61 +113,61 @@ static void fx_bra()
#define TEST_CY (GSU.vCarry & 1)
/* 06 - blt - branch on less than */
-static void fx_blt()
+static inline void fx_blt()
{
BRA_COND((TEST_S != 0) != (TEST_OV != 0));
}
/* 07 - bge - branch on greater or equals */
-static void fx_bge()
+static inline void fx_bge()
{
BRA_COND((TEST_S != 0) == (TEST_OV != 0));
}
/* 08 - bne - branch on not equal */
-static void fx_bne()
+static inline void fx_bne()
{
BRA_COND(!TEST_Z);
}
/* 09 - beq - branch on equal */
-static void fx_beq()
+static inline void fx_beq()
{
BRA_COND(TEST_Z);
}
/* 0a - bpl - branch on plus */
-static void fx_bpl()
+static inline void fx_bpl()
{
BRA_COND(!TEST_S);
}
/* 0b - bmi - branch on minus */
-static void fx_bmi()
+static inline void fx_bmi()
{
BRA_COND(TEST_S);
}
/* 0c - bcc - branch on carry clear */
-static void fx_bcc()
+static inline void fx_bcc()
{
BRA_COND(!TEST_CY);
}
/* 0d - bcs - branch on carry set */
-static void fx_bcs()
+static inline void fx_bcs()
{
BRA_COND(TEST_CY);
}
/* 0e - bvc - branch on overflow clear */
-static void fx_bvc()
+static inline void fx_bvc()
{
BRA_COND(!TEST_OV);
}
/* 0f - bvs - branch on overflow set */
-static void fx_bvs()
+static inline void fx_bvs()
{
BRA_COND(TEST_OV);
}
@@ -207,67 +207,67 @@ static void fx_bvs()
R15++; \
}
-static void fx_to_r0()
+static inline void fx_to_r0()
{
FX_TO(0);
}
-static void fx_to_r1()
+static inline void fx_to_r1()
{
FX_TO(1);
}
-static void fx_to_r2()
+static inline void fx_to_r2()
{
FX_TO(2);
}
-static void fx_to_r3()
+static inline void fx_to_r3()
{
FX_TO(3);
}
-static void fx_to_r4()
+static inline void fx_to_r4()
{
FX_TO(4);
}
-static void fx_to_r5()
+static inline void fx_to_r5()
{
FX_TO(5);
}
-static void fx_to_r6()
+static inline void fx_to_r6()
{
FX_TO(6);
}
-static void fx_to_r7()
+static inline void fx_to_r7()
{
FX_TO(7);
}
-static void fx_to_r8()
+static inline void fx_to_r8()
{
FX_TO(8);
}
-static void fx_to_r9()
+static inline void fx_to_r9()
{
FX_TO(9);
}
-static void fx_to_r10()
+static inline void fx_to_r10()
{
FX_TO(10);
}
-static void fx_to_r11()
+static inline void fx_to_r11()
{
FX_TO(11);
}
-static void fx_to_r12()
+static inline void fx_to_r12()
{
FX_TO(12);
}
-static void fx_to_r13()
+static inline void fx_to_r13()
{
FX_TO(13);
}
-static void fx_to_r14()
+static inline void fx_to_r14()
{
FX_TO_R14(14);
}
-static void fx_to_r15()
+static inline void fx_to_r15()
{
FX_TO_R15(15);
}
@@ -278,67 +278,67 @@ static void fx_to_r15()
GSU.pvSreg = GSU.pvDreg = &GSU.avReg[reg]; \
R15++
-static void fx_with_r0()
+static inline void fx_with_r0()
{
FX_WITH(0);
}
-static void fx_with_r1()
+static inline void fx_with_r1()
{
FX_WITH(1);
}
-static void fx_with_r2()
+static inline void fx_with_r2()
{
FX_WITH(2);
}
-static void fx_with_r3()
+static inline void fx_with_r3()
{
FX_WITH(3);
}
-static void fx_with_r4()
+static inline void fx_with_r4()
{
FX_WITH(4);
}
-static void fx_with_r5()
+static inline void fx_with_r5()
{
FX_WITH(5);
}
-static void fx_with_r6()
+static inline void fx_with_r6()
{
FX_WITH(6);
}
-static void fx_with_r7()
+static inline void fx_with_r7()
{
FX_WITH(7);
}
-static void fx_with_r8()
+static inline void fx_with_r8()
{
FX_WITH(8);
}
-static void fx_with_r9()
+static inline void fx_with_r9()
{
FX_WITH(9);
}
-static void fx_with_r10()
+static inline void fx_with_r10()
{
FX_WITH(10);
}
-static void fx_with_r11()
+static inline void fx_with_r11()
{
FX_WITH(11);
}
-static void fx_with_r12()
+static inline void fx_with_r12()
{
FX_WITH(12);
}
-static void fx_with_r13()
+static inline void fx_with_r13()
{
FX_WITH(13);
}
-static void fx_with_r14()
+static inline void fx_with_r14()
{
FX_WITH(14);
}
-static void fx_with_r15()
+static inline void fx_with_r15()
{
FX_WITH(15);
}
@@ -351,51 +351,51 @@ static void fx_with_r15()
CLRFLAGS; \
R15++
-static void fx_stw_r0()
+static inline void fx_stw_r0()
{
FX_STW(0);
}
-static void fx_stw_r1()
+static inline void fx_stw_r1()
{
FX_STW(1);
}
-static void fx_stw_r2()
+static inline void fx_stw_r2()
{
FX_STW(2);
}
-static void fx_stw_r3()
+static inline void fx_stw_r3()
{
FX_STW(3);
}
-static void fx_stw_r4()
+static inline void fx_stw_r4()
{
FX_STW(4);
}
-static void fx_stw_r5()
+static inline void fx_stw_r5()
{
FX_STW(5);
}
-static void fx_stw_r6()
+static inline void fx_stw_r6()
{
FX_STW(6);
}
-static void fx_stw_r7()
+static inline void fx_stw_r7()
{
FX_STW(7);
}
-static void fx_stw_r8()
+static inline void fx_stw_r8()
{
FX_STW(8);
}
-static void fx_stw_r9()
+static inline void fx_stw_r9()
{
FX_STW(9);
}
-static void fx_stw_r10()
+static inline void fx_stw_r10()
{
FX_STW(10);
}
-static void fx_stw_r11()
+static inline void fx_stw_r11()
{
FX_STW(11);
}
@@ -407,57 +407,57 @@ static void fx_stw_r11()
CLRFLAGS; \
R15++
-static void fx_stb_r0()
+static inline void fx_stb_r0()
{
FX_STB(0);
}
-static void fx_stb_r1()
+static inline void fx_stb_r1()
{
FX_STB(1);
}
-static void fx_stb_r2()
+static inline void fx_stb_r2()
{
FX_STB(2);
}
-static void fx_stb_r3()
+static inline void fx_stb_r3()
{
FX_STB(3);
}
-static void fx_stb_r4()
+static inline void fx_stb_r4()
{
FX_STB(4);
}
-static void fx_stb_r5()
+static inline void fx_stb_r5()
{
FX_STB(5);
}
-static void fx_stb_r6()
+static inline void fx_stb_r6()
{
FX_STB(6);
}
-static void fx_stb_r7()
+static inline void fx_stb_r7()
{
FX_STB(7);
}
-static void fx_stb_r8()
+static inline void fx_stb_r8()
{
FX_STB(8);
}
-static void fx_stb_r9()
+static inline void fx_stb_r9()
{
FX_STB(9);
}
-static void fx_stb_r10()
+static inline void fx_stb_r10()
{
FX_STB(10);
}
-static void fx_stb_r11()
+static inline void fx_stb_r11()
{
FX_STB(11);
}
/* 3c - loop - decrement loop counter, and branch on not zero */
-static void fx_loop()
+static inline void fx_loop()
{
GSU.vSign = GSU.vZero = --R12;
if ((uint16_t) R12 != 0)
@@ -468,7 +468,7 @@ static void fx_loop()
}
/* 3d - alt1 - set alt1 mode */
-static void fx_alt1()
+static inline void fx_alt1()
{
SF(ALT1);
CF(B);
@@ -476,7 +476,7 @@ static void fx_alt1()
}
/* 3e - alt2 - set alt2 mode */
-static void fx_alt2()
+static inline void fx_alt2()
{
SF(ALT2);
CF(B);
@@ -484,7 +484,7 @@ static void fx_alt2()
}
/* 3f - alt3 - set alt3 mode */
-static void fx_alt3()
+static inline void fx_alt3()
{
SF(ALT1);
SF(ALT2);
@@ -503,51 +503,51 @@ static void fx_alt3()
TESTR14; \
CLRFLAGS
-static void fx_ldw_r0()
+static inline void fx_ldw_r0()
{
FX_LDW(0);
}
-static void fx_ldw_r1()
+static inline void fx_ldw_r1()
{
FX_LDW(1);
}
-static void fx_ldw_r2()
+static inline void fx_ldw_r2()
{
FX_LDW(2);
}
-static void fx_ldw_r3()
+static inline void fx_ldw_r3()
{
FX_LDW(3);
}
-static void fx_ldw_r4()
+static inline void fx_ldw_r4()
{
FX_LDW(4);
}
-static void fx_ldw_r5()
+static inline void fx_ldw_r5()
{
FX_LDW(5);
}
-static void fx_ldw_r6()
+static inline void fx_ldw_r6()
{
FX_LDW(6);
}
-static void fx_ldw_r7()
+static inline void fx_ldw_r7()
{
FX_LDW(7);
}
-static void fx_ldw_r8()
+static inline void fx_ldw_r8()
{
FX_LDW(8);
}
-static void fx_ldw_r9()
+static inline void fx_ldw_r9()
{
FX_LDW(9);
}
-static void fx_ldw_r10()
+static inline void fx_ldw_r10()
{
FX_LDW(10);
}
-static void fx_ldw_r11()
+static inline void fx_ldw_r11()
{
FX_LDW(11);
}
@@ -562,57 +562,57 @@ static void fx_ldw_r11()
TESTR14; \
CLRFLAGS
-static void fx_ldb_r0()
+static inline void fx_ldb_r0()
{
FX_LDB(0);
}
-static void fx_ldb_r1()
+static inline void fx_ldb_r1()
{
FX_LDB(1);
}
-static void fx_ldb_r2()
+static inline void fx_ldb_r2()
{
FX_LDB(2);
}
-static void fx_ldb_r3()
+static inline void fx_ldb_r3()
{
FX_LDB(3);
}
-static void fx_ldb_r4()
+static inline void fx_ldb_r4()
{
FX_LDB(4);
}
-static void fx_ldb_r5()
+static inline void fx_ldb_r5()
{
FX_LDB(5);
}
-static void fx_ldb_r6()
+static inline void fx_ldb_r6()
{
FX_LDB(6);
}
-static void fx_ldb_r7()
+static inline void fx_ldb_r7()
{
FX_LDB(7);
}
-static void fx_ldb_r8()
+static inline void fx_ldb_r8()
{
FX_LDB(8);
}
-static void fx_ldb_r9()
+static inline void fx_ldb_r9()
{
FX_LDB(9);
}
-static void fx_ldb_r10()
+static inline void fx_ldb_r10()
{
FX_LDB(10);
}
-static void fx_ldb_r11()
+static inline void fx_ldb_r11()
{
FX_LDB(11);
}
/* 4c - plot - plot pixel with R1,R2 as x,y and the color register as the color */
-static void fx_plot_2bit()
+static inline void fx_plot_2bit()
{
uint32_t x = USEX8(R1);
uint32_t y = USEX8(R2);
@@ -644,7 +644,7 @@ static void fx_plot_2bit()
}
/* 2c(ALT1) - rpix - read color of the pixel with R1,R2 as x,y */
-static void fx_rpix_2bit()
+static inline void fx_rpix_2bit()
{
uint32_t x = USEX8(R1);
uint32_t y = USEX8(R2);
@@ -664,7 +664,7 @@ static void fx_rpix_2bit()
}
/* 4c - plot - plot pixel with R1,R2 as x,y and the color register as the color */
-static void fx_plot_4bit()
+static inline void fx_plot_4bit()
{
uint32_t x = USEX8(R1);
uint32_t y = USEX8(R2);
@@ -704,7 +704,7 @@ static void fx_plot_4bit()
}
/* 4c(ALT1) - rpix - read color of the pixel with R1,R2 as x,y */
-static void fx_rpix_4bit()
+static inline void fx_rpix_4bit()
{
uint32_t x = USEX8(R1);
uint32_t y = USEX8(R2);
@@ -726,7 +726,7 @@ static void fx_rpix_4bit()
}
/* 8c - plot - plot pixel with R1,R2 as x,y and the color register as the color */
-static void fx_plot_8bit()
+static inline void fx_plot_8bit()
{
uint32_t x = USEX8(R1);
uint32_t y = USEX8(R2);
@@ -784,7 +784,7 @@ static void fx_plot_8bit()
}
/* 4c(ALT1) - rpix - read color of the pixel with R1,R2 as x,y */
-static void fx_rpix_8bit()
+static inline void fx_rpix_8bit()
{
uint32_t x = USEX8(R1);
uint32_t y = USEX8(R2);
@@ -812,12 +812,12 @@ static void fx_rpix_8bit()
/* 4o - plot - plot pixel with R1,R2 as x,y and the color register as the color */
/* 4c(ALT1) - rpix - read color of the pixel with R1,R2 as x,y */
-static void fx_obj_func()
+static inline void fx_obj_func()
{
}
/* 4d - swap - swap upper and lower byte of a register */
-static void fx_swap()
+static inline void fx_swap()
{
uint8_t c = (uint8_t)SREG;
uint8_t d = (uint8_t)(SREG >> 8);
@@ -831,7 +831,7 @@ static void fx_swap()
}
/* 4e - color - copy source register to color register */
-static void fx_color()
+static inline void fx_color()
{
uint8_t c = (uint8_t)SREG;
if (GSU.vPlotOptionReg & 0x04)
@@ -848,7 +848,7 @@ static void fx_color()
}
/* 4e(ALT1) - cmode - set plot option register */
-static void fx_cmode()
+static inline void fx_cmode()
{
GSU.vPlotOptionReg = SREG;
@@ -863,7 +863,7 @@ static void fx_cmode()
}
/* 4f - not - perform exclusive exor with 1 on all bits */
-static void fx_not()
+static inline void fx_not()
{
uint32_t v = ~SREG;
R15++;
@@ -886,67 +886,67 @@ static void fx_not()
TESTR14; \
CLRFLAGS
-static void fx_add_r0()
+static inline void fx_add_r0()
{
FX_ADD(0);
}
-static void fx_add_r1()
+static inline void fx_add_r1()
{
FX_ADD(1);
}
-static void fx_add_r2()
+static inline void fx_add_r2()
{
FX_ADD(2);
}
-static void fx_add_r3()
+static inline void fx_add_r3()
{
FX_ADD(3);
}
-static void fx_add_r4()
+static inline void fx_add_r4()
{
FX_ADD(4);
}
-static void fx_add_r5()
+static inline void fx_add_r5()
{
FX_ADD(5);
}
-static void fx_add_r6()
+static inline void fx_add_r6()
{
FX_ADD(6);
}
-static void fx_add_r7()
+static inline void fx_add_r7()
{
FX_ADD(7);
}
-static void fx_add_r8()
+static inline void fx_add_r8()
{
FX_ADD(8);
}
-static void fx_add_r9()
+static inline void fx_add_r9()
{
FX_ADD(9);
}
-static void fx_add_r10()
+static inline void fx_add_r10()
{
FX_ADD(10);
}
-static void fx_add_r11()
+static inline void fx_add_r11()
{
FX_ADD(11);
}
-static void fx_add_r12()
+static inline void fx_add_r12()
{
FX_ADD(12);
}
-static void fx_add_r13()
+static inline void fx_add_r13()
{
FX_ADD(13);
}
-static void fx_add_r14()
+static inline void fx_add_r14()
{
FX_ADD(14);
}
-static void fx_add_r15()
+static inline void fx_add_r15()
{
FX_ADD(15);
}
@@ -963,67 +963,67 @@ static void fx_add_r15()
TESTR14; \
CLRFLAGS
-static void fx_adc_r0()
+static inline void fx_adc_r0()
{
FX_ADC(0);
}
-static void fx_adc_r1()
+static inline void fx_adc_r1()
{
FX_ADC(1);
}
-static void fx_adc_r2()
+static inline void fx_adc_r2()
{
FX_ADC(2);
}
-static void fx_adc_r3()
+static inline void fx_adc_r3()
{
FX_ADC(3);
}
-static void fx_adc_r4()
+static inline void fx_adc_r4()
{
FX_ADC(4);
}
-static void fx_adc_r5()
+static inline void fx_adc_r5()
{
FX_ADC(5);
}
-static void fx_adc_r6()
+static inline void fx_adc_r6()
{
FX_ADC(6);
}
-static void fx_adc_r7()
+static inline void fx_adc_r7()
{
FX_ADC(7);
}
-static void fx_adc_r8()
+static inline void fx_adc_r8()
{
FX_ADC(8);
}
-static void fx_adc_r9()
+static inline void fx_adc_r9()
{
FX_ADC(9);
}
-static void fx_adc_r10()
+static inline void fx_adc_r10()
{
FX_ADC(10);
}
-static void fx_adc_r11()
+static inline void fx_adc_r11()
{
FX_ADC(11);
}
-static void fx_adc_r12()
+static inline void fx_adc_r12()
{
FX_ADC(12);
}
-static void fx_adc_r13()
+static inline void fx_adc_r13()
{
FX_ADC(13);
}
-static void fx_adc_r14()
+static inline void fx_adc_r14()
{
FX_ADC(14);
}
-static void fx_adc_r15()
+static inline void fx_adc_r15()
{
FX_ADC(15);
}
@@ -1040,67 +1040,67 @@ static void fx_adc_r15()
TESTR14; \
CLRFLAGS
-static void fx_add_i0()
+static inline void fx_add_i0()
{
FX_ADD_I(0);
}
-static void fx_add_i1()
+static inline void fx_add_i1()
{
FX_ADD_I(1);
}
-static void fx_add_i2()
+static inline void fx_add_i2()
{
FX_ADD_I(2);
}
-static void fx_add_i3()
+static inline void fx_add_i3()
{
FX_ADD_I(3);
}
-static void fx_add_i4()
+static inline void fx_add_i4()
{
FX_ADD_I(4);
}
-static void fx_add_i5()
+static inline void fx_add_i5()
{
FX_ADD_I(5);
}
-static void fx_add_i6()
+static inline void fx_add_i6()
{
FX_ADD_I(6);
}
-static void fx_add_i7()
+static inline void fx_add_i7()
{
FX_ADD_I(7);
}
-static void fx_add_i8()
+static inline void fx_add_i8()
{
FX_ADD_I(8);
}
-static void fx_add_i9()
+static inline void fx_add_i9()
{
FX_ADD_I(9);
}
-static void fx_add_i10()
+static inline void fx_add_i10()
{
FX_ADD_I(10);
}
-static void fx_add_i11()
+static inline void fx_add_i11()
{
FX_ADD_I(11);
}
-static void fx_add_i12()
+static inline void fx_add_i12()
{
FX_ADD_I(12);
}
-static void fx_add_i13()
+static inline void fx_add_i13()
{
FX_ADD_I(13);
}
-static void fx_add_i14()
+static inline void fx_add_i14()
{
FX_ADD_I(14);
}
-static void fx_add_i15()
+static inline void fx_add_i15()
{
FX_ADD_I(15);
}
@@ -1117,67 +1117,67 @@ static void fx_add_i15()
TESTR14; \
CLRFLAGS
-static void fx_adc_i0()
+static inline void fx_adc_i0()
{
FX_ADC_I(0);
}
-static void fx_adc_i1()
+static inline void fx_adc_i1()
{
FX_ADC_I(1);
}
-static void fx_adc_i2()
+static inline void fx_adc_i2()
{
FX_ADC_I(2);
}
-static void fx_adc_i3()
+static inline void fx_adc_i3()
{
FX_ADC_I(3);
}
-static void fx_adc_i4()
+static inline void fx_adc_i4()
{
FX_ADC_I(4);
}
-static void fx_adc_i5()
+static inline void fx_adc_i5()
{
FX_ADC_I(5);
}
-static void fx_adc_i6()
+static inline void fx_adc_i6()
{
FX_ADC_I(6);
}
-static void fx_adc_i7()
+static inline void fx_adc_i7()
{
FX_ADC_I(7);
}
-static void fx_adc_i8()
+static inline void fx_adc_i8()
{
FX_ADC_I(8);
}
-static void fx_adc_i9()
+static inline void fx_adc_i9()
{
FX_ADC_I(9);
}
-static void fx_adc_i10()
+static inline void fx_adc_i10()
{
FX_ADC_I(10);
}
-static void fx_adc_i11()
+static inline void fx_adc_i11()
{
FX_ADC_I(11);
}
-static void fx_adc_i12()
+static inline void fx_adc_i12()
{
FX_ADC_I(12);
}
-static void fx_adc_i13()
+static inline void fx_adc_i13()
{
FX_ADC_I(13);
}
-static void fx_adc_i14()
+static inline void fx_adc_i14()
{
FX_ADC_I(14);
}
-static void fx_adc_i15()
+static inline void fx_adc_i15()
{
FX_ADC_I(15);
}
@@ -1194,67 +1194,67 @@ static void fx_adc_i15()
TESTR14; \
CLRFLAGS
-static void fx_sub_r0()
+static inline void fx_sub_r0()
{
FX_SUB(0);
}
-static void fx_sub_r1()
+static inline void fx_sub_r1()
{
FX_SUB(1);
}
-static void fx_sub_r2()
+static inline void fx_sub_r2()
{
FX_SUB(2);
}
-static void fx_sub_r3()
+static inline void fx_sub_r3()
{
FX_SUB(3);
}
-static void fx_sub_r4()
+static inline void fx_sub_r4()
{
FX_SUB(4);
}
-static void fx_sub_r5()
+static inline void fx_sub_r5()
{
FX_SUB(5);
}
-static void fx_sub_r6()
+static inline void fx_sub_r6()
{
FX_SUB(6);
}
-static void fx_sub_r7()
+static inline void fx_sub_r7()
{
FX_SUB(7);
}
-static void fx_sub_r8()
+static inline void fx_sub_r8()
{
FX_SUB(8);
}
-static void fx_sub_r9()
+static inline void fx_sub_r9()
{
FX_SUB(9);
}
-static void fx_sub_r10()
+static inline void fx_sub_r10()
{
FX_SUB(10);
}
-static void fx_sub_r11()
+static inline void fx_sub_r11()
{
FX_SUB(11);
}
-static void fx_sub_r12()
+static inline void fx_sub_r12()
{
FX_SUB(12);
}
-static void fx_sub_r13()
+static inline void fx_sub_r13()
{
FX_SUB(13);
}
-static void fx_sub_r14()
+static inline void fx_sub_r14()
{
FX_SUB(14);
}
-static void fx_sub_r15()
+static inline void fx_sub_r15()
{
FX_SUB(15);
}
@@ -1271,67 +1271,67 @@ static void fx_sub_r15()
TESTR14; \
CLRFLAGS
-static void fx_sbc_r0()
+static inline void fx_sbc_r0()
{
FX_SBC(0);
}
-static void fx_sbc_r1()
+static inline void fx_sbc_r1()
{
FX_SBC(1);
}
-static void fx_sbc_r2()
+static inline void fx_sbc_r2()
{
FX_SBC(2);
}
-static void fx_sbc_r3()
+static inline void fx_sbc_r3()
{
FX_SBC(3);
}
-static void fx_sbc_r4()
+static inline void fx_sbc_r4()
{
FX_SBC(4);
}
-static void fx_sbc_r5()
+static inline void fx_sbc_r5()
{
FX_SBC(5);
}
-static void fx_sbc_r6()
+static inline void fx_sbc_r6()
{
FX_SBC(6);
}
-static void fx_sbc_r7()
+static inline void fx_sbc_r7()
{
FX_SBC(7);
}
-static void fx_sbc_r8()
+static inline void fx_sbc_r8()
{
FX_SBC(8);
}
-static void fx_sbc_r9()
+static inline void fx_sbc_r9()
{
FX_SBC(9);
}
-static void fx_sbc_r10()
+static inline void fx_sbc_r10()
{
FX_SBC(10);
}
-static void fx_sbc_r11()
+static inline void fx_sbc_r11()
{
FX_SBC(11);
}
-static void fx_sbc_r12()
+static inline void fx_sbc_r12()
{
FX_SBC(12);
}
-static void fx_sbc_r13()
+static inline void fx_sbc_r13()
{
FX_SBC(13);
}
-static void fx_sbc_r14()
+static inline void fx_sbc_r14()
{
FX_SBC(14);
}
-static void fx_sbc_r15()
+static inline void fx_sbc_r15()
{
FX_SBC(15);
}
@@ -1348,67 +1348,67 @@ static void fx_sbc_r15()
TESTR14; \
CLRFLAGS
-static void fx_sub_i0()
+static inline void fx_sub_i0()
{
FX_SUB_I(0);
}
-static void fx_sub_i1()
+static inline void fx_sub_i1()
{
FX_SUB_I(1);
}
-static void fx_sub_i2()
+static inline void fx_sub_i2()
{
FX_SUB_I(2);
}
-static void fx_sub_i3()
+static inline void fx_sub_i3()
{
FX_SUB_I(3);
}
-static void fx_sub_i4()
+static inline void fx_sub_i4()
{
FX_SUB_I(4);
}
-static void fx_sub_i5()
+static inline void fx_sub_i5()
{
FX_SUB_I(5);
}
-static void fx_sub_i6()
+static inline void fx_sub_i6()
{
FX_SUB_I(6);
}
-static void fx_sub_i7()
+static inline void fx_sub_i7()
{
FX_SUB_I(7);
}
-static void fx_sub_i8()
+static inline void fx_sub_i8()
{
FX_SUB_I(8);
}
-static void fx_sub_i9()
+static inline void fx_sub_i9()
{
FX_SUB_I(9);
}
-static void fx_sub_i10()
+static inline void fx_sub_i10()
{
FX_SUB_I(10);
}
-static void fx_sub_i11()
+static inline void fx_sub_i11()
{
FX_SUB_I(11);
}
-static void fx_sub_i12()
+static inline void fx_sub_i12()
{
FX_SUB_I(12);
}
-static void fx_sub_i13()
+static inline void fx_sub_i13()
{
FX_SUB_I(13);
}
-static void fx_sub_i14()
+static inline void fx_sub_i14()
{
FX_SUB_I(14);
}
-static void fx_sub_i15()
+static inline void fx_sub_i15()
{
FX_SUB_I(15);
}
@@ -1423,73 +1423,73 @@ static void fx_sub_i15()
R15++; \
CLRFLAGS
-static void fx_cmp_r0()
+static inline void fx_cmp_r0()
{
FX_CMP(0);
}
-static void fx_cmp_r1()
+static inline void fx_cmp_r1()
{
FX_CMP(1);
}
-static void fx_cmp_r2()
+static inline void fx_cmp_r2()
{
FX_CMP(2);
}
-static void fx_cmp_r3()
+static inline void fx_cmp_r3()
{
FX_CMP(3);
}
-static void fx_cmp_r4()
+static inline void fx_cmp_r4()
{
FX_CMP(4);
}
-static void fx_cmp_r5()
+static inline void fx_cmp_r5()
{
FX_CMP(5);
}
-static void fx_cmp_r6()
+static inline void fx_cmp_r6()
{
FX_CMP(6);
}
-static void fx_cmp_r7()
+static inline void fx_cmp_r7()
{
FX_CMP(7);
}
-static void fx_cmp_r8()
+static inline void fx_cmp_r8()
{
FX_CMP(8);
}
-static void fx_cmp_r9()
+static inline void fx_cmp_r9()
{
FX_CMP(9);
}
-static void fx_cmp_r10()
+static inline void fx_cmp_r10()
{
FX_CMP(10);
}
-static void fx_cmp_r11()
+static inline void fx_cmp_r11()
{
FX_CMP(11);
}
-static void fx_cmp_r12()
+static inline void fx_cmp_r12()
{
FX_CMP(12);
}
-static void fx_cmp_r13()
+static inline void fx_cmp_r13()
{
FX_CMP(13);
}
-static void fx_cmp_r14()
+static inline void fx_cmp_r14()
{
FX_CMP(14);
}
-static void fx_cmp_r15()
+static inline void fx_cmp_r15()
{
FX_CMP(15);
}
/* 70 - merge - R7 as upper byte, R8 as lower byte (used for texture-mapping) */
-static void fx_merge()
+static inline void fx_merge()
{
uint32_t v = (R7 & 0xff00) | ((R8 & 0xff00) >> 8);
R15++;
@@ -1512,63 +1512,63 @@ static void fx_merge()
TESTR14; \
CLRFLAGS
-static void fx_and_r1()
+static inline void fx_and_r1()
{
FX_AND(1);
}
-static void fx_and_r2()
+static inline void fx_and_r2()
{
FX_AND(2);
}
-static void fx_and_r3()
+static inline void fx_and_r3()
{
FX_AND(3);
}
-static void fx_and_r4()
+static inline void fx_and_r4()
{
FX_AND(4);
}
-static void fx_and_r5()
+static inline void fx_and_r5()
{
FX_AND(5);
}
-static void fx_and_r6()
+static inline void fx_and_r6()
{
FX_AND(6);
}
-static void fx_and_r7()
+static inline void fx_and_r7()
{
FX_AND(7);
}
-static void fx_and_r8()
+static inline void fx_and_r8()
{
FX_AND(8);
}
-static void fx_and_r9()
+static inline void fx_and_r9()
{
FX_AND(9);
}
-static void fx_and_r10()
+static inline void fx_and_r10()
{
FX_AND(10);
}
-static void fx_and_r11()
+static inline void fx_and_r11()
{
FX_AND(11);
}
-static void fx_and_r12()
+static inline void fx_and_r12()
{
FX_AND(12);
}
-static void fx_and_r13()
+static inline void fx_and_r13()
{
FX_AND(13);
}
-static void fx_and_r14()
+static inline void fx_and_r14()
{
FX_AND(14);
}
-static void fx_and_r15()
+static inline void fx_and_r15()
{
FX_AND(15);
}
@@ -1583,63 +1583,63 @@ static void fx_and_r15()
TESTR14; \
CLRFLAGS
-static void fx_bic_r1()
+static inline void fx_bic_r1()
{
FX_BIC(1);
}
-static void fx_bic_r2()
+static inline void fx_bic_r2()
{
FX_BIC(2);
}
-static void fx_bic_r3()
+static inline void fx_bic_r3()
{
FX_BIC(3);
}
-static void fx_bic_r4()
+static inline void fx_bic_r4()
{
FX_BIC(4);
}
-static void fx_bic_r5()
+static inline void fx_bic_r5()
{
FX_BIC(5);
}
-static void fx_bic_r6()
+static inline void fx_bic_r6()
{
FX_BIC(6);
}
-static void fx_bic_r7()
+static inline void fx_bic_r7()
{
FX_BIC(7);
}
-static void fx_bic_r8()
+static inline void fx_bic_r8()
{
FX_BIC(8);
}
-static void fx_bic_r9()
+static inline void fx_bic_r9()
{
FX_BIC(9);
}
-static void fx_bic_r10()
+static inline void fx_bic_r10()
{
FX_BIC(10);
}
-static void fx_bic_r11()
+static inline void fx_bic_r11()
{
FX_BIC(11);
}
-static void fx_bic_r12()
+static inline void fx_bic_r12()
{
FX_BIC(12);
}
-static void fx_bic_r13()
+static inline void fx_bic_r13()
{
FX_BIC(13);
}
-static void fx_bic_r14()
+static inline void fx_bic_r14()
{
FX_BIC(14);
}
-static void fx_bic_r15()
+static inline void fx_bic_r15()
{
FX_BIC(15);
}
@@ -1654,63 +1654,63 @@ static void fx_bic_r15()
TESTR14; \
CLRFLAGS
-static void fx_and_i1()
+static inline void fx_and_i1()
{
FX_AND_I(1);
}
-static void fx_and_i2()
+static inline void fx_and_i2()
{
FX_AND_I(2);
}
-static void fx_and_i3()
+static inline void fx_and_i3()
{
FX_AND_I(3);
}
-static void fx_and_i4()
+static inline void fx_and_i4()
{
FX_AND_I(4);
}
-static void fx_and_i5()
+static inline void fx_and_i5()
{
FX_AND_I(5);
}
-static void fx_and_i6()
+static inline void fx_and_i6()
{
FX_AND_I(6);
}
-static void fx_and_i7()
+static inline void fx_and_i7()
{
FX_AND_I(7);
}
-static void fx_and_i8()
+static inline void fx_and_i8()
{
FX_AND_I(8);
}
-static void fx_and_i9()
+static inline void fx_and_i9()
{
FX_AND_I(9);
}
-static void fx_and_i10()
+static inline void fx_and_i10()
{
FX_AND_I(10);
}
-static void fx_and_i11()
+static inline void fx_and_i11()
{
FX_AND_I(11);
}
-static void fx_and_i12()
+static inline void fx_and_i12()
{
FX_AND_I(12);
}
-static void fx_and_i13()
+static inline void fx_and_i13()
{
FX_AND_I(13);
}
-static void fx_and_i14()
+static inline void fx_and_i14()
{
FX_AND_I(14);
}
-static void fx_and_i15()
+static inline void fx_and_i15()
{
FX_AND_I(15);
}
@@ -1725,63 +1725,63 @@ static void fx_and_i15()
TESTR14; \
CLRFLAGS
-static void fx_bic_i1()
+static inline void fx_bic_i1()
{
FX_BIC_I(1);
}
-static void fx_bic_i2()
+static inline void fx_bic_i2()
{
FX_BIC_I(2);
}
-static void fx_bic_i3()
+static inline void fx_bic_i3()
{
FX_BIC_I(3);
}
-static void fx_bic_i4()
+static inline void fx_bic_i4()
{
FX_BIC_I(4);
}
-static void fx_bic_i5()
+static inline void fx_bic_i5()
{
FX_BIC_I(5);
}
-static void fx_bic_i6()
+static inline void fx_bic_i6()
{
FX_BIC_I(6);
}
-static void fx_bic_i7()
+static inline void fx_bic_i7()
{
FX_BIC_I(7);
}
-static void fx_bic_i8()
+static inline void fx_bic_i8()
{
FX_BIC_I(8);
}
-static void fx_bic_i9()
+static inline void fx_bic_i9()
{
FX_BIC_I(9);
}
-static void fx_bic_i10()
+static inline void fx_bic_i10()
{
FX_BIC_I(10);
}
-static void fx_bic_i11()
+static inline void fx_bic_i11()
{
FX_BIC_I(11);
}
-static void fx_bic_i12()
+static inline void fx_bic_i12()
{
FX_BIC_I(12);
}
-static void fx_bic_i13()
+static inline void fx_bic_i13()
{
FX_BIC_I(13);
}
-static void fx_bic_i14()
+static inline void fx_bic_i14()
{
FX_BIC_I(14);
}
-static void fx_bic_i15()
+static inline void fx_bic_i15()
{
FX_BIC_I(15);
}
@@ -1796,67 +1796,67 @@ static void fx_bic_i15()
TESTR14; \
CLRFLAGS
-static void fx_mult_r0()
+static inline void fx_mult_r0()
{
FX_MULT(0);
}
-static void fx_mult_r1()
+static inline void fx_mult_r1()
{
FX_MULT(1);
}
-static void fx_mult_r2()
+static inline void fx_mult_r2()
{
FX_MULT(2);
}
-static void fx_mult_r3()
+static inline void fx_mult_r3()
{
FX_MULT(3);
}
-static void fx_mult_r4()
+static inline void fx_mult_r4()
{
FX_MULT(4);
}
-static void fx_mult_r5()
+static inline void fx_mult_r5()
{
FX_MULT(5);
}
-static void fx_mult_r6()
+static inline void fx_mult_r6()
{
FX_MULT(6);
}
-static void fx_mult_r7()
+static inline void fx_mult_r7()
{
FX_MULT(7);
}
-static void fx_mult_r8()
+static inline void fx_mult_r8()
{
FX_MULT(8);
}
-static void fx_mult_r9()
+static inline void fx_mult_r9()
{
FX_MULT(9);
}
-static void fx_mult_r10()
+static inline void fx_mult_r10()
{
FX_MULT(10);
}
-static void fx_mult_r11()
+static inline void fx_mult_r11()
{
FX_MULT(11);
}
-static void fx_mult_r12()
+static inline void fx_mult_r12()
{
FX_MULT(12);
}
-static void fx_mult_r13()
+static inline void fx_mult_r13()
{
FX_MULT(13);
}
-static void fx_mult_r14()
+static inline void fx_mult_r14()
{
FX_MULT(14);
}
-static void fx_mult_r15()
+static inline void fx_mult_r15()
{
FX_MULT(15);
}
@@ -1871,67 +1871,67 @@ static void fx_mult_r15()
TESTR14; \
CLRFLAGS
-static void fx_umult_r0()
+static inline void fx_umult_r0()
{
FX_UMULT(0);
}
-static void fx_umult_r1()
+static inline void fx_umult_r1()
{
FX_UMULT(1);
}
-static void fx_umult_r2()
+static inline void fx_umult_r2()
{
FX_UMULT(2);
}
-static void fx_umult_r3()
+static inline void fx_umult_r3()
{
FX_UMULT(3);
}
-static void fx_umult_r4()
+static inline void fx_umult_r4()
{
FX_UMULT(4);
}
-static void fx_umult_r5()
+static inline void fx_umult_r5()
{
FX_UMULT(5);
}
-static void fx_umult_r6()
+static inline void fx_umult_r6()
{
FX_UMULT(6);
}
-static void fx_umult_r7()
+static inline void fx_umult_r7()
{
FX_UMULT(7);
}
-static void fx_umult_r8()
+static inline void fx_umult_r8()
{
FX_UMULT(8);
}
-static void fx_umult_r9()
+static inline void fx_umult_r9()
{
FX_UMULT(9);
}
-static void fx_umult_r10()
+static inline void fx_umult_r10()
{
FX_UMULT(10);
}
-static void fx_umult_r11()
+static inline void fx_umult_r11()
{
FX_UMULT(11);
}
-static void fx_umult_r12()
+static inline void fx_umult_r12()
{
FX_UMULT(12);
}
-static void fx_umult_r13()
+static inline void fx_umult_r13()
{
FX_UMULT(13);
}
-static void fx_umult_r14()
+static inline void fx_umult_r14()
{
FX_UMULT(14);
}
-static void fx_umult_r15()
+static inline void fx_umult_r15()
{
FX_UMULT(15);
}
@@ -1946,67 +1946,67 @@ static void fx_umult_r15()
TESTR14; \
CLRFLAGS
-static void fx_mult_i0()
+static inline void fx_mult_i0()
{
FX_MULT_I(0);
}
-static void fx_mult_i1()
+static inline void fx_mult_i1()
{
FX_MULT_I(1);
}
-static void fx_mult_i2()
+static inline void fx_mult_i2()
{
FX_MULT_I(2);
}
-static void fx_mult_i3()
+static inline void fx_mult_i3()
{
FX_MULT_I(3);
}
-static void fx_mult_i4()
+static inline void fx_mult_i4()
{
FX_MULT_I(4);
}
-static void fx_mult_i5()
+static inline void fx_mult_i5()
{
FX_MULT_I(5);
}
-static void fx_mult_i6()
+static inline void fx_mult_i6()
{
FX_MULT_I(6);
}
-static void fx_mult_i7()
+static inline void fx_mult_i7()
{
FX_MULT_I(7);
}
-static void fx_mult_i8()
+static inline void fx_mult_i8()
{
FX_MULT_I(8);
}
-static void fx_mult_i9()
+static inline void fx_mult_i9()
{
FX_MULT_I(9);
}
-static void fx_mult_i10()
+static inline void fx_mult_i10()
{
FX_MULT_I(10);
}
-static void fx_mult_i11()
+static inline void fx_mult_i11()
{
FX_MULT_I(11);
}
-static void fx_mult_i12()
+static inline void fx_mult_i12()
{
FX_MULT_I(12);
}
-static void fx_mult_i13()
+static inline void fx_mult_i13()
{
FX_MULT_I(13);
}
-static void fx_mult_i14()
+static inline void fx_mult_i14()
{
FX_MULT_I(14);
}
-static void fx_mult_i15()
+static inline void fx_mult_i15()
{
FX_MULT_I(15);
}
@@ -2021,73 +2021,73 @@ static void fx_mult_i15()
TESTR14; \
CLRFLAGS
-static void fx_umult_i0()
+static inline void fx_umult_i0()
{
FX_UMULT_I(0);
}
-static void fx_umult_i1()
+static inline void fx_umult_i1()
{
FX_UMULT_I(1);
}
-static void fx_umult_i2()
+static inline void fx_umult_i2()
{
FX_UMULT_I(2);
}
-static void fx_umult_i3()
+static inline void fx_umult_i3()
{
FX_UMULT_I(3);
}
-static void fx_umult_i4()
+static inline void fx_umult_i4()
{
FX_UMULT_I(4);
}
-static void fx_umult_i5()
+static inline void fx_umult_i5()
{
FX_UMULT_I(5);
}
-static void fx_umult_i6()
+static inline void fx_umult_i6()
{
FX_UMULT_I(6);
}
-static void fx_umult_i7()
+static inline void fx_umult_i7()
{
FX_UMULT_I(7);
}
-static void fx_umult_i8()
+static inline void fx_umult_i8()
{
FX_UMULT_I(8);
}
-static void fx_umult_i9()
+static inline void fx_umult_i9()
{
FX_UMULT_I(9);
}
-static void fx_umult_i10()
+static inline void fx_umult_i10()
{
FX_UMULT_I(10);
}
-static void fx_umult_i11()
+static inline void fx_umult_i11()
{
FX_UMULT_I(11);
}
-static void fx_umult_i12()
+static inline void fx_umult_i12()
{
FX_UMULT_I(12);
}
-static void fx_umult_i13()
+static inline void fx_umult_i13()
{
FX_UMULT_I(13);
}
-static void fx_umult_i14()
+static inline void fx_umult_i14()
{
FX_UMULT_I(14);
}
-static void fx_umult_i15()
+static inline void fx_umult_i15()
{
FX_UMULT_I(15);
}
/* 90 - sbk - store word to last accessed RAM address */
-static void fx_sbk()
+static inline void fx_sbk()
{
RAM(GSU.vLastRamAdr) = (uint8_t)SREG;
RAM(GSU.vLastRamAdr ^ 1) = (uint8_t)(SREG >> 8);
@@ -2101,25 +2101,25 @@ static void fx_sbk()
CLRFLAGS; \
R15++
-static void fx_link_i1()
+static inline void fx_link_i1()
{
FX_LINK_I(1);
}
-static void fx_link_i2()
+static inline void fx_link_i2()
{
FX_LINK_I(2);
}
-static void fx_link_i3()
+static inline void fx_link_i3()
{
FX_LINK_I(3);
}
-static void fx_link_i4()
+static inline void fx_link_i4()
{
FX_LINK_I(4);
}
/* 95 - sex - sign extend 8 bit to 16 bit */
-static void fx_sex()
+static inline void fx_sex()
{
uint32_t v = (uint32_t)SEX8(SREG);
R15++;
@@ -2131,7 +2131,7 @@ static void fx_sex()
}
/* 96 - asr - aritmetric shift right by one */
-static void fx_asr()
+static inline void fx_asr()
{
uint32_t v;
GSU.vCarry = SREG & 1;
@@ -2145,7 +2145,7 @@ static void fx_asr()
}
/* 96(ALT1) - div2 - aritmetric shift right by one */
-static void fx_div2()
+static inline void fx_div2()
{
uint32_t v;
int32_t s = SEX16(SREG);
@@ -2163,7 +2163,7 @@ static void fx_div2()
}
/* 97 - ror - rotate right by one */
-static void fx_ror()
+static inline void fx_ror()
{
uint32_t v = (USEX16(SREG) >> 1) | (GSU.vCarry << 15);
GSU.vCarry = SREG & 1;
@@ -2180,27 +2180,27 @@ static void fx_ror()
R15 = GSU.avReg[reg]; \
CLRFLAGS
-static void fx_jmp_r8()
+static inline void fx_jmp_r8()
{
FX_JMP(8);
}
-static void fx_jmp_r9()
+static inline void fx_jmp_r9()
{
FX_JMP(9);
}
-static void fx_jmp_r10()
+static inline void fx_jmp_r10()
{
FX_JMP(10);
}
-static void fx_jmp_r11()
+static inline void fx_jmp_r11()
{
FX_JMP(11);
}
-static void fx_jmp_r12()
+static inline void fx_jmp_r12()
{
FX_JMP(12);
}
-static void fx_jmp_r13()
+static inline void fx_jmp_r13()
{
FX_JMP(13);
}
@@ -2214,33 +2214,33 @@ static void fx_jmp_r13()
fx_cache(); \
R15--
-static void fx_ljmp_r8()
+static inline void fx_ljmp_r8()
{
FX_LJMP(8);
}
-static void fx_ljmp_r9()
+static inline void fx_ljmp_r9()
{
FX_LJMP(9);
}
-static void fx_ljmp_r10()
+static inline void fx_ljmp_r10()
{
FX_LJMP(10);
}
-static void fx_ljmp_r11()
+static inline void fx_ljmp_r11()
{
FX_LJMP(11);
}
-static void fx_ljmp_r12()
+static inline void fx_ljmp_r12()
{
FX_LJMP(12);
}
-static void fx_ljmp_r13()
+static inline void fx_ljmp_r13()
{
FX_LJMP(13);
}
/* 9e - lob - set upper byte to zero (keep low byte) */
-static void fx_lob()
+static inline void fx_lob()
{
uint32_t v = USEX8(SREG);
R15++;
@@ -2252,7 +2252,7 @@ static void fx_lob()
}
/* 9f - fmult - 16 bit to 32 bit signed multiplication, upper 16 bits only */
-static void fx_fmult()
+static inline void fx_fmult()
{
uint32_t v;
uint32_t c = (uint32_t)(SEX16(SREG) * SEX16(R6));
@@ -2267,7 +2267,7 @@ static void fx_fmult()
}
/* 9f(ALT1) - lmult - 16 bit to 32 bit signed multiplication */
-static void fx_lmult()
+static inline void fx_lmult()
{
uint32_t v;
uint32_t c = (uint32_t)(SEX16(SREG) * SEX16(R6));
@@ -2292,68 +2292,68 @@ static void fx_lmult()
GSU.avReg[reg] = SEX8(v); \
CLRFLAGS
-static void fx_ibt_r0()
+static inline void fx_ibt_r0()
{
FX_IBT(0);
}
-static void fx_ibt_r1()
+static inline void fx_ibt_r1()
{
FX_IBT(1);
}
-static void fx_ibt_r2()
+static inline void fx_ibt_r2()
{
FX_IBT(2);
}
-static void fx_ibt_r3()
+static inline void fx_ibt_r3()
{
FX_IBT(3);
}
-static void fx_ibt_r4()
+static inline void fx_ibt_r4()
{
FX_IBT(4);
}
-static void fx_ibt_r5()
+static inline void fx_ibt_r5()
{
FX_IBT(5);
}
-static void fx_ibt_r6()
+static inline void fx_ibt_r6()
{
FX_IBT(6);
}
-static void fx_ibt_r7()
+static inline void fx_ibt_r7()
{
FX_IBT(7);
}
-static void fx_ibt_r8()
+static inline void fx_ibt_r8()
{
FX_IBT(8);
}
-static void fx_ibt_r9()
+static inline void fx_ibt_r9()
{
FX_IBT(9);
}
-static void fx_ibt_r10()
+static inline void fx_ibt_r10()
{
FX_IBT(10);
}
-static void fx_ibt_r11()
+static inline void fx_ibt_r11()
{
FX_IBT(11);
}
-static void fx_ibt_r12()
+static inline void fx_ibt_r12()
{
FX_IBT(12);
}
-static void fx_ibt_r13()
+static inline void fx_ibt_r13()
{
FX_IBT(13);
}
-static void fx_ibt_r14()
+static inline void fx_ibt_r14()
{
FX_IBT(14);
READR14;
}
-static void fx_ibt_r15()
+static inline void fx_ibt_r15()
{
FX_IBT(15);
}
@@ -2368,68 +2368,68 @@ static void fx_ibt_r15()
GSU.avReg[reg] |= ((uint32_t) RAM(GSU.vLastRamAdr + 1)) << 8; \
CLRFLAGS
-static void fx_lms_r0()
+static inline void fx_lms_r0()
{
FX_LMS(0);
}
-static void fx_lms_r1()
+static inline void fx_lms_r1()
{
FX_LMS(1);
}
-static void fx_lms_r2()
+static inline void fx_lms_r2()
{
FX_LMS(2);
}
-static void fx_lms_r3()
+static inline void fx_lms_r3()
{
FX_LMS(3);
}
-static void fx_lms_r4()
+static inline void fx_lms_r4()
{
FX_LMS(4);
}
-static void fx_lms_r5()
+static inline void fx_lms_r5()
{
FX_LMS(5);
}
-static void fx_lms_r6()
+static inline void fx_lms_r6()
{
FX_LMS(6);
}
-static void fx_lms_r7()
+static inline void fx_lms_r7()
{
FX_LMS(7);
}
-static void fx_lms_r8()
+static inline void fx_lms_r8()
{
FX_LMS(8);
}
-static void fx_lms_r9()
+static inline void fx_lms_r9()
{
FX_LMS(9);
}
-static void fx_lms_r10()
+static inline void fx_lms_r10()
{
FX_LMS(10);
}
-static void fx_lms_r11()
+static inline void fx_lms_r11()
{
FX_LMS(11);
}
-static void fx_lms_r12()
+static inline void fx_lms_r12()
{
FX_LMS(12);
}
-static void fx_lms_r13()
+static inline void fx_lms_r13()
{
FX_LMS(13);
}
-static void fx_lms_r14()
+static inline void fx_lms_r14()
{
FX_LMS(14);
READR14;
}
-static void fx_lms_r15()
+static inline void fx_lms_r15()
{
FX_LMS(15);
}
@@ -2446,67 +2446,67 @@ static void fx_lms_r15()
CLRFLAGS; \
R15++
-static void fx_sms_r0()
+static inline void fx_sms_r0()
{
FX_SMS(0);
}
-static void fx_sms_r1()
+static inline void fx_sms_r1()
{
FX_SMS(1);
}
-static void fx_sms_r2()
+static inline void fx_sms_r2()
{
FX_SMS(2);
}
-static void fx_sms_r3()
+static inline void fx_sms_r3()
{
FX_SMS(3);
}
-static void fx_sms_r4()
+static inline void fx_sms_r4()
{
FX_SMS(4);
}
-static void fx_sms_r5()
+static inline void fx_sms_r5()
{
FX_SMS(5);
}
-static void fx_sms_r6()
+static inline void fx_sms_r6()
{
FX_SMS(6);
}
-static void fx_sms_r7()
+static inline void fx_sms_r7()
{
FX_SMS(7);
}
-static void fx_sms_r8()
+static inline void fx_sms_r8()
{
FX_SMS(8);
}
-static void fx_sms_r9()
+static inline void fx_sms_r9()
{
FX_SMS(9);
}
-static void fx_sms_r10()
+static inline void fx_sms_r10()
{
FX_SMS(10);
}
-static void fx_sms_r11()
+static inline void fx_sms_r11()
{
FX_SMS(11);
}
-static void fx_sms_r12()
+static inline void fx_sms_r12()
{
FX_SMS(12);
}
-static void fx_sms_r13()
+static inline void fx_sms_r13()
{
FX_SMS(13);
}
-static void fx_sms_r14()
+static inline void fx_sms_r14()
{
FX_SMS(14);
}
-static void fx_sms_r15()
+static inline void fx_sms_r15()
{
FX_SMS(15);
}
@@ -2531,73 +2531,73 @@ static void fx_sms_r15()
R15++; \
}
-static void fx_from_r0()
+static inline void fx_from_r0()
{
FX_FROM(0);
}
-static void fx_from_r1()
+static inline void fx_from_r1()
{
FX_FROM(1);
}
-static void fx_from_r2()
+static inline void fx_from_r2()
{
FX_FROM(2);
}
-static void fx_from_r3()
+static inline void fx_from_r3()
{
FX_FROM(3);
}
-static void fx_from_r4()
+static inline void fx_from_r4()
{
FX_FROM(4);
}
-static void fx_from_r5()
+static inline void fx_from_r5()
{
FX_FROM(5);
}
-static void fx_from_r6()
+static inline void fx_from_r6()
{
FX_FROM(6);
}
-static void fx_from_r7()
+static inline void fx_from_r7()
{
FX_FROM(7);
}
-static void fx_from_r8()
+static inline void fx_from_r8()
{
FX_FROM(8);
}
-static void fx_from_r9()
+static inline void fx_from_r9()
{
FX_FROM(9);
}
-static void fx_from_r10()
+static inline void fx_from_r10()
{
FX_FROM(10);
}
-static void fx_from_r11()
+static inline void fx_from_r11()
{
FX_FROM(11);
}
-static void fx_from_r12()
+static inline void fx_from_r12()
{
FX_FROM(12);
}
-static void fx_from_r13()
+static inline void fx_from_r13()
{
FX_FROM(13);
}
-static void fx_from_r14()
+static inline void fx_from_r14()
{
FX_FROM(14);
}
-static void fx_from_r15()
+static inline void fx_from_r15()
{
FX_FROM(15);
}
/* c0 - hib - move high-byte to low-byte */
-static void fx_hib()
+static inline void fx_hib()
{
uint32_t v = USEX8(SREG >> 8);
R15++;
@@ -2618,63 +2618,63 @@ static void fx_hib()
TESTR14; \
CLRFLAGS
-static void fx_or_r1()
+static inline void fx_or_r1()
{
FX_OR(1);
}
-static void fx_or_r2()
+static inline void fx_or_r2()
{
FX_OR(2);
}
-static void fx_or_r3()
+static inline void fx_or_r3()
{
FX_OR(3);
}
-static void fx_or_r4()
+static inline void fx_or_r4()
{
FX_OR(4);
}
-static void fx_or_r5()
+static inline void fx_or_r5()
{
FX_OR(5);
}
-static void fx_or_r6()
+static inline void fx_or_r6()
{
FX_OR(6);
}
-static void fx_or_r7()
+static inline void fx_or_r7()
{
FX_OR(7);
}
-static void fx_or_r8()
+static inline void fx_or_r8()
{
FX_OR(8);
}
-static void fx_or_r9()
+static inline void fx_or_r9()
{
FX_OR(9);
}
-static void fx_or_r10()
+static inline void fx_or_r10()
{
FX_OR(10);
}
-static void fx_or_r11()
+static inline void fx_or_r11()
{
FX_OR(11);
}
-static void fx_or_r12()
+static inline void fx_or_r12()
{
FX_OR(12);
}
-static void fx_or_r13()
+static inline void fx_or_r13()
{
FX_OR(13);
}
-static void fx_or_r14()
+static inline void fx_or_r14()
{
FX_OR(14);
}
-static void fx_or_r15()
+static inline void fx_or_r15()
{
FX_OR(15);
}
@@ -2689,63 +2689,63 @@ static void fx_or_r15()
TESTR14; \
CLRFLAGS
-static void fx_xor_r1()
+static inline void fx_xor_r1()
{
FX_XOR(1);
}
-static void fx_xor_r2()
+static inline void fx_xor_r2()
{
FX_XOR(2);
}
-static void fx_xor_r3()
+static inline void fx_xor_r3()
{
FX_XOR(3);
}
-static void fx_xor_r4()
+static inline void fx_xor_r4()
{
FX_XOR(4);
}
-static void fx_xor_r5()
+static inline void fx_xor_r5()
{
FX_XOR(5);
}
-static void fx_xor_r6()
+static inline void fx_xor_r6()
{
FX_XOR(6);
}
-static void fx_xor_r7()
+static inline void fx_xor_r7()
{
FX_XOR(7);
}
-static void fx_xor_r8()
+static inline void fx_xor_r8()
{
FX_XOR(8);
}
-static void fx_xor_r9()
+static inline void fx_xor_r9()
{
FX_XOR(9);
}
-static void fx_xor_r10()
+static inline void fx_xor_r10()
{
FX_XOR(10);
}
-static void fx_xor_r11()
+static inline void fx_xor_r11()
{
FX_XOR(11);
}
-static void fx_xor_r12()
+static inline void fx_xor_r12()
{
FX_XOR(12);
}
-static void fx_xor_r13()
+static inline void fx_xor_r13()
{
FX_XOR(13);
}
-static void fx_xor_r14()
+static inline void fx_xor_r14()
{
FX_XOR(14);
}
-static void fx_xor_r15()
+static inline void fx_xor_r15()
{
FX_XOR(15);
}
@@ -2760,63 +2760,63 @@ static void fx_xor_r15()
TESTR14; \
CLRFLAGS
-static void fx_or_i1()
+static inline void fx_or_i1()
{
FX_OR_I(1);
}
-static void fx_or_i2()
+static inline void fx_or_i2()
{
FX_OR_I(2);
}
-static void fx_or_i3()
+static inline void fx_or_i3()
{
FX_OR_I(3);
}
-static void fx_or_i4()
+static inline void fx_or_i4()
{
FX_OR_I(4);
}
-static void fx_or_i5()
+static inline void fx_or_i5()
{
FX_OR_I(5);
}
-static void fx_or_i6()
+static inline void fx_or_i6()
{
FX_OR_I(6);
}
-static void fx_or_i7()
+static inline void fx_or_i7()
{
FX_OR_I(7);
}
-static void fx_or_i8()
+static inline void fx_or_i8()
{
FX_OR_I(8);
}
-static void fx_or_i9()
+static inline void fx_or_i9()
{
FX_OR_I(9);
}
-static void fx_or_i10()
+static inline void fx_or_i10()
{
FX_OR_I(10);
}
-static void fx_or_i11()
+static inline void fx_or_i11()
{
FX_OR_I(11);
}
-static void fx_or_i12()
+static inline void fx_or_i12()
{
FX_OR_I(12);
}
-static void fx_or_i13()
+static inline void fx_or_i13()
{
FX_OR_I(13);
}
-static void fx_or_i14()
+static inline void fx_or_i14()
{
FX_OR_I(14);
}
-static void fx_or_i15()
+static inline void fx_or_i15()
{
FX_OR_I(15);
}
@@ -2831,63 +2831,63 @@ static void fx_or_i15()
TESTR14; \
CLRFLAGS
-static void fx_xor_i1()
+static inline void fx_xor_i1()
{
FX_XOR_I(1);
}
-static void fx_xor_i2()
+static inline void fx_xor_i2()
{
FX_XOR_I(2);
}
-static void fx_xor_i3()
+static inline void fx_xor_i3()
{
FX_XOR_I(3);
}
-static void fx_xor_i4()
+static inline void fx_xor_i4()
{
FX_XOR_I(4);
}
-static void fx_xor_i5()
+static inline void fx_xor_i5()
{
FX_XOR_I(5);
}
-static void fx_xor_i6()
+static inline void fx_xor_i6()
{
FX_XOR_I(6);
}
-static void fx_xor_i7()
+static inline void fx_xor_i7()
{
FX_XOR_I(7);
}
-static void fx_xor_i8()
+static inline void fx_xor_i8()
{
FX_XOR_I(8);
}
-static void fx_xor_i9()
+static inline void fx_xor_i9()
{
FX_XOR_I(9);
}
-static void fx_xor_i10()
+static inline void fx_xor_i10()
{
FX_XOR_I(10);
}
-static void fx_xor_i11()
+static inline void fx_xor_i11()
{
FX_XOR_I(11);
}
-static void fx_xor_i12()
+static inline void fx_xor_i12()
{
FX_XOR_I(12);
}
-static void fx_xor_i13()
+static inline void fx_xor_i13()
{
FX_XOR_I(13);
}
-static void fx_xor_i14()
+static inline void fx_xor_i14()
{
FX_XOR_I(14);
}
-static void fx_xor_i15()
+static inline void fx_xor_i15()
{
FX_XOR_I(15);
}
@@ -2900,70 +2900,70 @@ static void fx_xor_i15()
CLRFLAGS; \
R15++
-static void fx_inc_r0()
+static inline void fx_inc_r0()
{
FX_INC(0);
}
-static void fx_inc_r1()
+static inline void fx_inc_r1()
{
FX_INC(1);
}
-static void fx_inc_r2()
+static inline void fx_inc_r2()
{
FX_INC(2);
}
-static void fx_inc_r3()
+static inline void fx_inc_r3()
{
FX_INC(3);
}
-static void fx_inc_r4()
+static inline void fx_inc_r4()
{
FX_INC(4);
}
-static void fx_inc_r5()
+static inline void fx_inc_r5()
{
FX_INC(5);
}
-static void fx_inc_r6()
+static inline void fx_inc_r6()
{
FX_INC(6);
}
-static void fx_inc_r7()
+static inline void fx_inc_r7()
{
FX_INC(7);
}
-static void fx_inc_r8()
+static inline void fx_inc_r8()
{
FX_INC(8);
}
-static void fx_inc_r9()
+static inline void fx_inc_r9()
{
FX_INC(9);
}
-static void fx_inc_r10()
+static inline void fx_inc_r10()
{
FX_INC(10);
}
-static void fx_inc_r11()
+static inline void fx_inc_r11()
{
FX_INC(11);
}
-static void fx_inc_r12()
+static inline void fx_inc_r12()
{
FX_INC(12);
}
-static void fx_inc_r13()
+static inline void fx_inc_r13()
{
FX_INC(13);
}
-static void fx_inc_r14()
+static inline void fx_inc_r14()
{
FX_INC(14);
READR14;
}
/* df - getc - transfer ROM buffer to color register */
-static void fx_getc()
+static inline void fx_getc()
{
#ifndef FX_DO_ROMBUFFER
uint8_t c;
@@ -2985,7 +2985,7 @@ static void fx_getc()
}
/* df(ALT2) - ramb - set current RAM bank */
-static void fx_ramb()
+static inline void fx_ramb()
{
GSU.vRamBankReg = SREG & (FX_RAM_BANKS - 1);
GSU.pvRamBank = GSU.apvRamBank[GSU.vRamBankReg & 0x3];
@@ -2994,7 +2994,7 @@ static void fx_ramb()
}
/* df(ALT3) - romb - set current ROM bank */
-static void fx_romb()
+static inline void fx_romb()
{
GSU.vRomBankReg = USEX8(SREG) & 0x7f;
GSU.pvRomBank = GSU.apvRomBank[GSU.vRomBankReg];
@@ -3010,70 +3010,70 @@ static void fx_romb()
CLRFLAGS; \
R15++
-static void fx_dec_r0()
+static inline void fx_dec_r0()
{
FX_DEC(0);
}
-static void fx_dec_r1()
+static inline void fx_dec_r1()
{
FX_DEC(1);
}
-static void fx_dec_r2()
+static inline void fx_dec_r2()
{
FX_DEC(2);
}
-static void fx_dec_r3()
+static inline void fx_dec_r3()
{
FX_DEC(3);
}
-static void fx_dec_r4()
+static inline void fx_dec_r4()
{
FX_DEC(4);
}
-static void fx_dec_r5()
+static inline void fx_dec_r5()
{
FX_DEC(5);
}
-static void fx_dec_r6()
+static inline void fx_dec_r6()
{
FX_DEC(6);
}
-static void fx_dec_r7()
+static inline void fx_dec_r7()
{
FX_DEC(7);
}
-static void fx_dec_r8()
+static inline void fx_dec_r8()
{
FX_DEC(8);
}
-static void fx_dec_r9()
+static inline void fx_dec_r9()
{
FX_DEC(9);
}
-static void fx_dec_r10()
+static inline void fx_dec_r10()
{
FX_DEC(10);
}
-static void fx_dec_r11()
+static inline void fx_dec_r11()
{
FX_DEC(11);
}
-static void fx_dec_r12()
+static inline void fx_dec_r12()
{
FX_DEC(12);
}
-static void fx_dec_r13()
+static inline void fx_dec_r13()
{
FX_DEC(13);
}
-static void fx_dec_r14()
+static inline void fx_dec_r14()
{
FX_DEC(14);
READR14;
}
/* ef - getb - get byte from ROM at address R14 */
-static void fx_getb()
+static inline void fx_getb()
{
uint32_t v;
#ifndef FX_DO_ROMBUFFER
@@ -3088,7 +3088,7 @@ static void fx_getb()
}
/* ef(ALT1) - getbh - get high-byte from ROM at address R14 */
-static void fx_getbh()
+static inline void fx_getbh()
{
uint32_t v;
#ifndef FX_DO_ROMBUFFER
@@ -3105,7 +3105,7 @@ static void fx_getbh()
}
/* ef(ALT2) - getbl - get low-byte from ROM at address R14 */
-static void fx_getbl()
+static inline void fx_getbl()
{
uint32_t v;
#ifndef FX_DO_ROMBUFFER
@@ -3121,7 +3121,7 @@ static void fx_getbl()
}
/* ef(ALT3) - getbs - get sign extended byte from ROM at address R14 */
-static void fx_getbs()
+static inline void fx_getbs()
{
uint32_t v;
#ifndef FX_DO_ROMBUFFER
@@ -3149,68 +3149,68 @@ static void fx_getbs()
GSU.avReg[reg] = v; \
CLRFLAGS
-static void fx_iwt_r0()
+static inline void fx_iwt_r0()
{
FX_IWT(0);
}
-static void fx_iwt_r1()
+static inline void fx_iwt_r1()
{
FX_IWT(1);
}
-static void fx_iwt_r2()
+static inline void fx_iwt_r2()
{
FX_IWT(2);
}
-static void fx_iwt_r3()
+static inline void fx_iwt_r3()
{
FX_IWT(3);
}
-static void fx_iwt_r4()
+static inline void fx_iwt_r4()
{
FX_IWT(4);
}
-static void fx_iwt_r5()
+static inline void fx_iwt_r5()
{
FX_IWT(5);
}
-static void fx_iwt_r6()
+static inline void fx_iwt_r6()
{
FX_IWT(6);
}
-static void fx_iwt_r7()
+static inline void fx_iwt_r7()
{
FX_IWT(7);
}
-static void fx_iwt_r8()
+static inline void fx_iwt_r8()
{
FX_IWT(8);
}
-static void fx_iwt_r9()
+static inline void fx_iwt_r9()
{
FX_IWT(9);
}
-static void fx_iwt_r10()
+static inline void fx_iwt_r10()
{
FX_IWT(10);
}
-static void fx_iwt_r11()
+static inline void fx_iwt_r11()
{
FX_IWT(11);
}
-static void fx_iwt_r12()
+static inline void fx_iwt_r12()
{
FX_IWT(12);
}
-static void fx_iwt_r13()
+static inline void fx_iwt_r13()
{
FX_IWT(13);
}
-static void fx_iwt_r14()
+static inline void fx_iwt_r14()
{
FX_IWT(14);
READR14;
}
-static void fx_iwt_r15()
+static inline void fx_iwt_r15()
{
FX_IWT(15);
}
@@ -3228,68 +3228,68 @@ static void fx_iwt_r15()
GSU.avReg[reg] |= USEX8(RAM(GSU.vLastRamAdr ^ 1)) << 8; \
CLRFLAGS
-static void fx_lm_r0()
+static inline void fx_lm_r0()
{
FX_LM(0);
}
-static void fx_lm_r1()
+static inline void fx_lm_r1()
{
FX_LM(1);
}
-static void fx_lm_r2()
+static inline void fx_lm_r2()
{
FX_LM(2);
}
-static void fx_lm_r3()
+static inline void fx_lm_r3()
{
FX_LM(3);
}
-static void fx_lm_r4()
+static inline void fx_lm_r4()
{
FX_LM(4);
}
-static void fx_lm_r5()
+static inline void fx_lm_r5()
{
FX_LM(5);
}
-static void fx_lm_r6()
+static inline void fx_lm_r6()
{
FX_LM(6);
}
-static void fx_lm_r7()
+static inline void fx_lm_r7()
{
FX_LM(7);
}
-static void fx_lm_r8()
+static inline void fx_lm_r8()
{
FX_LM(8);
}
-static void fx_lm_r9()
+static inline void fx_lm_r9()
{
FX_LM(9);
}
-static void fx_lm_r10()
+static inline void fx_lm_r10()
{
FX_LM(10);
}
-static void fx_lm_r11()
+static inline void fx_lm_r11()
{
FX_LM(11);
}
-static void fx_lm_r12()
+static inline void fx_lm_r12()
{
FX_LM(12);
}
-static void fx_lm_r13()
+static inline void fx_lm_r13()
{
FX_LM(13);
}
-static void fx_lm_r14()
+static inline void fx_lm_r14()
{
FX_LM(14);
READR14;
}
-static void fx_lm_r15()
+static inline void fx_lm_r15()
{
FX_LM(15);
}
@@ -3309,67 +3309,67 @@ static void fx_lm_r15()
CLRFLAGS; \
R15++
-static void fx_sm_r0()
+static inline void fx_sm_r0()
{
FX_SM(0);
}
-static void fx_sm_r1()
+static inline void fx_sm_r1()
{
FX_SM(1);
}
-static void fx_sm_r2()
+static inline void fx_sm_r2()
{
FX_SM(2);
}
-static void fx_sm_r3()
+static inline void fx_sm_r3()
{
FX_SM(3);
}
-static void fx_sm_r4()
+static inline void fx_sm_r4()
{
FX_SM(4);
}
-static void fx_sm_r5()
+static inline void fx_sm_r5()
{
FX_SM(5);
}
-static void fx_sm_r6()
+static inline void fx_sm_r6()
{
FX_SM(6);
}
-static void fx_sm_r7()
+static inline void fx_sm_r7()
{
FX_SM(7);
}
-static void fx_sm_r8()
+static inline void fx_sm_r8()
{
FX_SM(8);
}
-static void fx_sm_r9()
+static inline void fx_sm_r9()
{
FX_SM(9);
}
-static void fx_sm_r10()
+static inline void fx_sm_r10()
{
FX_SM(10);
}
-static void fx_sm_r11()
+static inline void fx_sm_r11()
{
FX_SM(11);
}
-static void fx_sm_r12()
+static inline void fx_sm_r12()
{
FX_SM(12);
}
-static void fx_sm_r13()
+static inline void fx_sm_r13()
{
FX_SM(13);
}
-static void fx_sm_r14()
+static inline void fx_sm_r14()
{
FX_SM(14);
}
-static void fx_sm_r15()
+static inline void fx_sm_r15()
{
FX_SM(15);
}
@@ -3388,8 +3388,8 @@ uint32_t fx_run(uint32_t nInstructions)
/*** Special table for the different plot configurations ***/
void (*fx_apfPlotTable[])() =
{
- &fx_plot_2bit, &fx_plot_4bit, &fx_plot_4bit, &fx_plot_8bit, &fx_obj_func,
- &fx_rpix_2bit, &fx_rpix_4bit, &fx_rpix_4bit, &fx_rpix_8bit, &fx_obj_func,
+ &fx_plot_2bit, &fx_plot_4bit, &fx_plot_4bit, &fx_plot_8bit, &fx_obj_func,
+ &fx_rpix_2bit, &fx_rpix_4bit, &fx_rpix_4bit, &fx_rpix_8bit, &fx_obj_func,
};
/*** Opcode table ***/
diff --git a/source/fxinst.h b/source/fxinst.h
index 657d7d2..e63c68c 100644
--- a/source/fxinst.h
+++ b/source/fxinst.h
@@ -124,71 +124,65 @@
/* Number of banks in GSU RAM */
#define FX_RAM_BANKS 4
-struct FxRegs_s
+typedef struct
{
/* FxChip registers */
- uint32_t avReg[16]; /* 16 Generic registers */
- uint32_t vColorReg; /* Internal color register */
- uint32_t vPlotOptionReg; /* Plot option register */
- uint32_t vStatusReg; /* Status register */
- uint32_t vPrgBankReg; /* Program bank index register */
- uint32_t vRomBankReg; /* Rom bank index register */
- uint32_t vRamBankReg; /* Ram bank index register */
- uint32_t vCacheBaseReg; /* Cache base address register */
- uint32_t vCacheFlags; /* Saying what parts of the cache was written to */
- uint32_t vLastRamAdr; /* Last RAM address accessed */
- uint32_t* pvDreg; /* Pointer to current destination register */
- uint32_t* pvSreg; /* Pointer to current source register */
- uint8_t vRomBuffer; /* Current byte read by R14 */
- uint8_t vPipe; /* Instructionset pipe */
- uint32_t vPipeAdr; /* The address of where the pipe was read from */
+ uint32_t avReg[16]; /* 16 Generic registers */
+ uint32_t vColorReg; /* Internal color register */
+ uint32_t vPlotOptionReg; /* Plot option register */
+ uint32_t vStatusReg; /* Status register */
+ uint32_t vPrgBankReg; /* Program bank index register */
+ uint32_t vRomBankReg; /* Rom bank index register */
+ uint32_t vRamBankReg; /* Ram bank index register */
+ uint32_t vCacheBaseReg; /* Cache base address register */
+ uint32_t vCacheFlags; /* Saying what parts of the cache was written to */
+ uint32_t vLastRamAdr; /* Last RAM address accessed */
+ uint32_t* pvDreg; /* Pointer to current destination register */
+ uint32_t* pvSreg; /* Pointer to current source register */
+ uint8_t vRomBuffer; /* Current byte read by R14 */
+ uint8_t vPipe; /* Instructionset pipe */
+ uint32_t vPipeAdr; /* The address of where the pipe was read from */
/* status register optimization stuff */
- uint32_t vSign; /* v & 0x8000 */
- uint32_t vZero; /* v == 0 */
- uint32_t vCarry; /* a value of 1 or 0 */
- int32_t vOverflow; /* (v >= 0x8000 || v < -0x8000) */
+ uint32_t vSign; /* v & 0x8000 */
+ uint32_t vZero; /* v == 0 */
+ uint32_t vCarry; /* a value of 1 or 0 */
+ int32_t vOverflow; /* (v >= 0x8000 || v < -0x8000) */
/* Other emulator variables */
- int32_t vErrorCode;
- uint32_t vIllegalAddress;
-
- uint8_t bBreakPoint;
- uint32_t vBreakPoint;
- uint32_t vStepPoint;
-
- uint8_t* pvRegisters; /* 768 bytes located in the memory at address 0x3000 */
- uint32_t nRamBanks; /* Number of 64kb-banks in FxRam (Don't confuse it with SNES-Ram!!!) */
- uint8_t* pvRam; /* Pointer to FxRam */
- uint32_t nRomBanks; /* Number of 32kb-banks in Cart-ROM */
- uint8_t* pvRom; /* Pointer to Cart-ROM */
-
- uint32_t vMode; /* Color depth/mode */
- uint32_t vPrevMode; /* Previous depth */
- uint8_t* pvScreenBase;
- uint8_t* apvScreen[32]; /* Pointer to each of the 32 screen colums */
- int32_t x[32];
- uint32_t vScreenHeight; /* 128, 160, 192 or 256 (could be overriden by cmode) */
- uint32_t vScreenRealHeight; /* 128, 160, 192 or 256 */
- uint32_t vPrevScreenHeight;
- uint32_t vScreenSize;
- void (*pfPlot)();
- void (*pfRpix)();
-
- uint8_t* pvRamBank; /* Pointer to current RAM-bank */
- uint8_t* pvRomBank; /* Pointer to current ROM-bank */
- uint8_t* pvPrgBank; /* Pointer to current program ROM-bank */
-
- uint8_t* apvRamBank[FX_RAM_BANKS]; /* Ram bank table (max 256kb) */
- uint8_t* apvRomBank[256]; /* Rom bank table */
-
- uint8_t bCacheActive;
- uint8_t* pvCache; /* Pointer to the GSU cache */
- uint8_t avCacheBackup[512]; /* Backup of ROM when the cache has replaced it */
- uint32_t vCounter;
- uint32_t vInstCount;
- uint32_t vSCBRDirty; /* if SCBR is written, our cached screen pointers need updating */
-};
+ int32_t vErrorCode;
+ uint32_t vIllegalAddress;
+ uint8_t bBreakPoint;
+ uint32_t vBreakPoint;
+ uint32_t vStepPoint;
+ uint8_t* pvRegisters; /* 768 bytes located in the memory at address 0x3000 */
+ uint32_t nRamBanks; /* Number of 64kb-banks in FxRam (Don't confuse it with SNES-Ram!!!) */
+ uint8_t* pvRam; /* Pointer to FxRam */
+ uint32_t nRomBanks; /* Number of 32kb-banks in Cart-ROM */
+ uint8_t* pvRom; /* Pointer to Cart-ROM */
+ uint32_t vMode; /* Color depth/mode */
+ uint32_t vPrevMode; /* Previous depth */
+ uint8_t* pvScreenBase;
+ uint8_t* apvScreen[32]; /* Pointer to each of the 32 screen colums */
+ int32_t x[32];
+ uint32_t vScreenHeight; /* 128, 160, 192 or 256 (could be overriden by cmode) */
+ uint32_t vScreenRealHeight; /* 128, 160, 192 or 256 */
+ uint32_t vPrevScreenHeight;
+ uint32_t vScreenSize;
+ void (*pfPlot)();
+ void (*pfRpix)();
+ uint8_t* pvRamBank; /* Pointer to current RAM-bank */
+ uint8_t* pvRomBank; /* Pointer to current ROM-bank */
+ uint8_t* pvPrgBank; /* Pointer to current program ROM-bank */
+ uint8_t* apvRamBank[FX_RAM_BANKS]; /* Ram bank table (max 256kb) */
+ uint8_t* apvRomBank[256]; /* Rom bank table */
+ uint8_t bCacheActive;
+ uint8_t* pvCache; /* Pointer to the GSU cache */
+ uint8_t avCacheBackup[512]; /* Backup of ROM when the cache has replaced it */
+ uint32_t vCounter;
+ uint32_t vInstCount;
+ uint32_t vSCBRDirty; /* if SCBR is written, our cached screen pointers need updating */
+} FxRegs_s;
/* GSU registers */
#define GSU_R0 0x000
diff --git a/source/getset.h b/source/getset.h
index 7d28a04..ebf996f 100644
--- a/source/getset.h
+++ b/source/getset.h
@@ -13,20 +13,18 @@
extern uint8_t OpenBus;
-INLINE uint8_t S9xGetByte(uint32_t Address)
+inline uint8_t S9xGetByte(uint32_t Address)
{
int32_t block;
uint8_t* GetAddress = Memory.Map [block = (Address >> MEMMAP_SHIFT) & MEMMAP_MASK];
- if (!CPU.InDMA)
+ if ((intptr_t) GetAddress != MAP_CPU || !CPU.InDMA)
CPU.Cycles += Memory.MemorySpeed [block];
if (GetAddress >= (uint8_t*) MAP_LAST)
{
-#ifdef CPU_SHUTDOWN
if (Memory.BlockIsRAM [block])
CPU.WaitAddress = CPU.PCAtOpcodeStart;
-#endif
return (*(GetAddress + (Address & 0xffff)));
}
@@ -67,7 +65,7 @@ INLINE uint8_t S9xGetByte(uint32_t Address)
}
}
-INLINE uint16_t S9xGetWord(uint32_t Address)
+inline uint16_t S9xGetWord(uint32_t Address)
{
if ((Address & 0x0fff) == 0x0fff)
{
@@ -77,15 +75,13 @@ INLINE uint16_t S9xGetWord(uint32_t Address)
int32_t block;
uint8_t* GetAddress = Memory.Map [block = (Address >> MEMMAP_SHIFT) & MEMMAP_MASK];
- if (!CPU.InDMA)
+ if ((intptr_t) GetAddress != MAP_CPU || !CPU.InDMA)
CPU.Cycles += (Memory.MemorySpeed [block] << 1);
if (GetAddress >= (uint8_t*) MAP_LAST)
{
-#ifdef CPU_SHUTDOWN
if (Memory.BlockIsRAM [block])
CPU.WaitAddress = CPU.PCAtOpcodeStart;
-#endif
#ifdef FAST_LSB_WORD_ACCESS
return (*(uint16_t*)(GetAddress + (Address & 0xffff)));
#else
@@ -145,21 +141,17 @@ INLINE uint16_t S9xGetWord(uint32_t Address)
}
}
-INLINE void S9xSetByte(uint8_t Byte, uint32_t Address)
+inline void S9xSetByte(uint8_t Byte, uint32_t Address)
{
-#if defined(CPU_SHUTDOWN)
CPU.WaitAddress = NULL;
-#endif
int32_t block;
uint8_t* SetAddress = Memory.WriteMap [block = ((Address >> MEMMAP_SHIFT) & MEMMAP_MASK)];
- if (!CPU.InDMA)
+ if ((intptr_t) SetAddress != MAP_CPU || !CPU.InDMA)
CPU.Cycles += Memory.MemorySpeed [block];
-
if (SetAddress >= (uint8_t*) MAP_LAST)
{
-#ifdef CPU_SHUTDOWN
SetAddress += Address & 0xffff;
if (SetAddress == SA1.WaitByteAddress1 ||
SetAddress == SA1.WaitByteAddress2)
@@ -168,9 +160,6 @@ INLINE void S9xSetByte(uint8_t Byte, uint32_t Address)
SA1.WaitCounter = 0;
}
*SetAddress = Byte;
-#else
- *(SetAddress + (Address & 0xffff)) = Byte;
-#endif
return;
}
@@ -227,7 +216,7 @@ INLINE void S9xSetByte(uint8_t Byte, uint32_t Address)
}
}
-INLINE void S9xSetWord(uint16_t Word, uint32_t Address)
+inline void S9xSetWord(uint16_t Word, uint32_t Address)
{
if ((Address & 0x0FFF) == 0x0FFF)
{
@@ -236,19 +225,15 @@ INLINE void S9xSetWord(uint16_t Word, uint32_t Address)
return;
}
-#if defined(CPU_SHUTDOWN)
CPU.WaitAddress = NULL;
-#endif
int32_t block;
uint8_t* SetAddress = Memory.WriteMap [block = ((Address >> MEMMAP_SHIFT) & MEMMAP_MASK)];
- if (!CPU.InDMA)
+ if ((intptr_t) SetAddress != MAP_CPU || !CPU.InDMA)
CPU.Cycles += Memory.MemorySpeed [block] << 1;
-
if (SetAddress >= (uint8_t*) MAP_LAST)
{
-#ifdef CPU_SHUTDOWN
SetAddress += Address & 0xffff;
if (SetAddress == SA1.WaitByteAddress1 ||
SetAddress == SA1.WaitByteAddress2)
@@ -262,14 +247,6 @@ INLINE void S9xSetWord(uint16_t Word, uint32_t Address)
*SetAddress = (uint8_t) Word;
*(SetAddress + 1) = Word >> 8;
#endif
-#else
-#ifdef FAST_LSB_WORD_ACCESS
- *(uint16_t*)(SetAddress + (Address & 0xffff)) = Word;
-#else
- *(SetAddress + (Address & 0xffff)) = (uint8_t) Word;
- *(SetAddress + ((Address + 1) & 0xffff)) = Word >> 8;
-#endif
-#endif
return;
}
@@ -350,7 +327,7 @@ INLINE void S9xSetWord(uint16_t Word, uint32_t Address)
}
}
-INLINE uint8_t* GetBasePointer(uint32_t Address)
+inline uint8_t* GetBasePointer(uint32_t Address)
{
uint8_t* GetAddress = Memory.Map [(Address >> MEMMAP_SHIFT) & MEMMAP_MASK];
if (GetAddress >= (uint8_t*) MAP_LAST)
@@ -384,7 +361,7 @@ INLINE uint8_t* GetBasePointer(uint32_t Address)
}
}
-INLINE uint8_t* S9xGetMemPointer(uint32_t Address)
+inline uint8_t* S9xGetMemPointer(uint32_t Address)
{
uint8_t* GetAddress = Memory.Map [(Address >> MEMMAP_SHIFT) & MEMMAP_MASK];
if (GetAddress >= (uint8_t*) MAP_LAST)
@@ -421,7 +398,7 @@ INLINE uint8_t* S9xGetMemPointer(uint32_t Address)
}
}
-INLINE void S9xSetPCBase(uint32_t Address)
+inline void S9xSetPCBase(uint32_t Address)
{
int32_t block;
uint8_t* GetAddress = Memory.Map [block = (Address >> MEMMAP_SHIFT) & MEMMAP_MASK];
@@ -458,5 +435,4 @@ INLINE void S9xSetPCBase(uint32_t Address)
CPU.PC = CPU.PCBase + (Address & 0xffff);
}
-
#endif
diff --git a/source/gfx.c b/source/gfx.c
index 4b88295..5694be6 100644
--- a/source/gfx.c
+++ b/source/gfx.c
@@ -29,8 +29,8 @@ extern LargePixelRenderer DrawLargePixelPtr;
extern SBG BG;
-extern struct SLineData LineData[240];
-extern struct SLineMatrixData LineMatrixData [240];
+extern SLineData LineData[240];
+extern SLineMatrixData LineMatrixData [240];
extern uint8_t Mode7Depths [2];
@@ -38,8 +38,7 @@ extern uint8_t Mode7Depths [2];
((a) & ((1 << 10) - 1)) + (((((a) & (1 << 13)) ^ (1 << 13)) - (1 << 13)) >> 3)
#define ON_MAIN(N) \
-(GFX.r212c & (1 << (N)) && \
- !(PPU.BG_Forced & (1 << (N))))
+(GFX.r212c & (1 << (N)))
#define SUB_OR_ADD(N) \
(GFX.r2131 & (1 << (N)))
@@ -47,8 +46,7 @@ extern uint8_t Mode7Depths [2];
#define ON_SUB(N) \
((GFX.r2130 & 0x30) != 0x30 && \
(GFX.r2130 & 2) && \
- (GFX.r212d & (1 << N)) && \
- !(PPU.BG_Forced & (1 << (N))))
+ (GFX.r212d & (1 << N)))
#define ANYTHING_ON_SUB \
((GFX.r2130 & 0x30) != 0x30 && \
@@ -61,6 +59,7 @@ extern uint8_t Mode7Depths [2];
#define FIX_INTERLACE(SCREEN, DO_DEPTH, DEPTH) \
uint32_t y; \
if (IPPU.DoubleHeightPixels && ((PPU.BGMode != 5 && PPU.BGMode != 6) || !IPPU.Interlace)) \
+ { \
for (y = GFX.StartY; y <= GFX.EndY; y++) \
{ \
/* memmove converted: Same malloc, non-overlapping addresses [Neb] */ \
@@ -73,7 +72,8 @@ extern uint8_t Mode7Depths [2];
DEPTH + y * GFX.PPL, \
GFX.PPLx2>>1); \
} \
- }
+ } \
+ }
#define BLACK BUILD_PIXEL(0,0,0)
@@ -266,7 +266,6 @@ bool S9xInitGFX()
GFX.Delta = (GFX.SubScreen - GFX.Screen) >> 1;
GFX.DepthDelta = GFX.SubZBuffer - GFX.ZBuffer;
- PPU.BG_Forced = 0;
IPPU.OBJChanged = true;
IPPU.DirectColourMapsNeedRebuild = true;
@@ -274,16 +273,8 @@ bool S9xInitGFX()
DrawTilePtr = DrawTile16;
DrawClippedTilePtr = DrawClippedTile16;
DrawLargePixelPtr = DrawLargePixel16;
- if (Settings.SupportHiRes)
- {
- DrawHiResTilePtr = DrawTile16;
- DrawHiResClippedTilePtr = DrawClippedTile16;
- }
- else
- {
- DrawHiResTilePtr = DrawTile16HalfWidth;
- DrawHiResClippedTilePtr = DrawClippedTile16HalfWidth;
- }
+ DrawHiResTilePtr = DrawTile16;
+ DrawHiResClippedTilePtr = DrawClippedTile16;
GFX.PPL = GFX.Pitch >> 1;
GFX.PPLx2 = GFX.Pitch;
S9xFixColourBrightness();
@@ -437,9 +428,6 @@ void S9xBuildDirectColourMaps()
void S9xStartScreenRefresh()
{
- if (GFX.InfoStringTimeout > 0 && --GFX.InfoStringTimeout == 0)
- GFX.InfoString = NULL;
-
if (IPPU.RenderThisFrame)
{
if (!S9xInitUpdate())
@@ -448,14 +436,11 @@ void S9xStartScreenRefresh()
return;
}
- IPPU.RenderedFramesCount++;
IPPU.PreviousLine = IPPU.CurrentLine = 0;
- IPPU.MaxBrightness = PPU.Brightness;
- IPPU.LatchedBlanking = PPU.ForcedBlanking;
if (PPU.BGMode == 5 || PPU.BGMode == 6)
IPPU.Interlace = (Memory.FillRAM[0x2133] & 1);
- if (Settings.SupportHiRes && (PPU.BGMode == 5 || PPU.BGMode == 6 || IPPU.Interlace))
+ if (PPU.BGMode == 5 || PPU.BGMode == 6 || IPPU.Interlace)
{
IPPU.RenderedScreenWidth = 512;
IPPU.DoubleWidthPixels = true;
@@ -478,14 +463,6 @@ void S9xStartScreenRefresh()
GFX.PPLx2 = GFX.PPL << 1;
}
}
- else if (!Settings.SupportHiRes && (PPU.BGMode == 5 || PPU.BGMode == 6 || IPPU.Interlace))
- {
- IPPU.RenderedScreenWidth = 256;
- IPPU.DoubleWidthPixels = false;
- // Secret of Mana displays menus with mode 5.
- // Make them readable.
- IPPU.HalfWidthPixels = true;
- }
else
{
IPPU.RenderedScreenWidth = 256;
@@ -507,11 +484,7 @@ void S9xStartScreenRefresh()
}
if (++IPPU.FrameCount % Memory.ROMFramesPerSecond == 0)
- {
- IPPU.DisplayedRenderedFrameCount = IPPU.RenderedFramesCount;
- IPPU.RenderedFramesCount = 0;
IPPU.FrameCount = 0;
- }
}
void RenderLine(uint8_t C)
@@ -525,7 +498,7 @@ void RenderLine(uint8_t C)
if (PPU.BGMode == 7)
{
- struct SLineMatrixData* p = &LineMatrixData [C];
+ SLineMatrixData* p = &LineMatrixData [C];
p->MatrixA = PPU.MatrixA;
p->MatrixB = PPU.MatrixB;
p->MatrixC = PPU.MatrixC;
@@ -555,14 +528,14 @@ void RenderLine(uint8_t C)
{
/* if we're not rendering this frame, we still need to update this */
// XXX: Check ForceBlank? Or anything else?
- if (IPPU.OBJChanged) S9xSetupOBJ();
+ if (IPPU.OBJChanged)
+ S9xSetupOBJ();
PPU.RangeTimeOver |= GFX.OBJLines[C].RTOFlags;
}
}
void S9xEndScreenRefresh()
{
- IPPU.HDMAStarted = false;
if (IPPU.RenderThisFrame)
{
FLUSH_REDRAW();
@@ -577,20 +550,12 @@ void S9xEndScreenRefresh()
GFX.PPL = GFX.PPLx2 >> 1;
}
-#ifdef WANT_CHEATS
S9xApplyCheats();
-#endif
if (CPU.SRAMModified)
CPU.SRAMModified = false;
}
-void S9xSetInfoString(const char* string)
-{
- GFX.InfoString = string;
- GFX.InfoStringTimeout = 120;
-}
-
static inline void SelectTileRenderer(bool normal)
{
if (normal)
@@ -698,12 +663,6 @@ void S9xSetupOBJ()
LargeWidth = LargeHeight = 32;
break;
}
- if (IPPU.InterlaceSprites)
- {
- SmallHeight >>= 1;
- LargeHeight >>= 1;
- }
-
/* OK, we have three cases here. Either there's no priority, priority is
* normal FirstSprite, or priority is FirstSprite+Y. The first two are
* easy, the last is somewhat more ... interesting. So we split them up. */
@@ -892,7 +851,7 @@ static void DrawOBJS(bool OnMain, uint8_t D)
struct
{
uint16_t Pos;
- bool Value;
+ bool Value;
} Windows[7];
int32_t clipcount = GFX.pCurrentClip->Count [4];
@@ -938,46 +897,31 @@ static void DrawOBJS(bool OnMain, uint8_t D)
}
}
- if (Settings.SupportHiRes)
+ if (PPU.BGMode == 5 || PPU.BGMode == 6)
{
- if (PPU.BGMode == 5 || PPU.BGMode == 6)
+ // Bah, OnMain is never used except to determine if calling
+ // SelectTileRenderer is necessary. So let's hack it to false here
+ // to stop SelectTileRenderer from being called when it causes
+ // problems.
+ OnMain = false;
+ GFX.PixSize = 2;
+ if (IPPU.DoubleHeightPixels)
{
- // Bah, OnMain is never used except to determine if calling
- // SelectTileRenderer is necessary. So let's hack it to false here
- // to stop SelectTileRenderer from being called when it causes
- // problems.
- OnMain = false;
- GFX.PixSize = 2;
- if (IPPU.DoubleHeightPixels)
- {
- DrawTilePtr = DrawTile16x2x2;
- DrawClippedTilePtr = DrawClippedTile16x2x2;
- }
- else
- {
- DrawTilePtr = DrawTile16x2;
- DrawClippedTilePtr = DrawClippedTile16x2;
- }
+ DrawTilePtr = DrawTile16x2x2;
+ DrawClippedTilePtr = DrawClippedTile16x2x2;
}
else
{
- DrawTilePtr = DrawTile16;
- DrawClippedTilePtr = DrawClippedTile16;
+ DrawTilePtr = DrawTile16x2;
+ DrawClippedTilePtr = DrawClippedTile16x2;
}
}
- else // if (!Settings.SupportHiRes)
+ else
{
- if (PPU.BGMode == 5 || PPU.BGMode == 6)
- {
- // Bah, OnMain is never used except to determine if calling
- // SelectTileRenderer is necessary. So let's hack it to false here
- // to stop SelectTileRenderer from being called when it causes
- // problems.
- OnMain = false;
- }
DrawTilePtr = DrawTile16;
DrawClippedTilePtr = DrawClippedTile16;
}
+
GFX.Z1 = D + 2;
uint32_t Y, Offset;
@@ -1941,8 +1885,6 @@ static void DrawBackground(uint32_t BGMode, uint32_t bg, uint8_t Z1, uint8_t Z2)
case 5:
case 6: // XXX: is also offset per tile.
- if (!Settings.SupportHiRes)
- SelectTileRenderer(true /* normal */);
DrawBackgroundMode5(bg, Z1, Z2);
return;
}
@@ -2291,7 +2233,7 @@ static void DrawBackground(uint32_t BGMode, uint32_t bg, uint8_t Z1, uint8_t Z2)
\
Screen += GFX.StartY * GFX.Pitch; \
uint8_t *Depth = GFX.DB + GFX.StartY * GFX.PPL; \
- struct SLineMatrixData *l = &LineMatrixData [GFX.StartY]; \
+ SLineMatrixData *l = &LineMatrixData [GFX.StartY]; \
\
uint32_t Line; \
for (Line = GFX.StartY; Line <= GFX.EndY; Line++, Screen += GFX.Pitch, Depth += GFX.PPL, l++) \
@@ -2482,7 +2424,7 @@ static void DrawBGMode7Background16Sub1_2(uint8_t* Screen, int32_t bg)
\
Screen += GFX.StartY * GFX.Pitch; \
uint8_t *Depth = GFX.DB + GFX.StartY * GFX.PPL; \
- struct SLineMatrixData *l = &LineMatrixData [GFX.StartY]; \
+ SLineMatrixData *l = &LineMatrixData [GFX.StartY]; \
bool allowSimpleCase = false; \
if (!l->MatrixB && !l->MatrixC && (l->MatrixA == 0x0100) && (l->MatrixD == 0x0100) \
&& !LineMatrixData[GFX.EndY].MatrixB && !LineMatrixData[GFX.EndY].MatrixC \
@@ -3063,20 +3005,10 @@ void S9xUpdateScreen()
GFX.r212d = Memory.FillRAM [0x212d];
GFX.r2130 = Memory.FillRAM [0x2130];
-#ifdef JP_FIX
-
- GFX.Pseudo = (Memory.FillRAM [0x2133] & 8) != 0 &&
- (GFX.r212c & 15) != (GFX.r212d & 15) &&
- (GFX.r2131 == 0x3f);
-
-#else
-
GFX.Pseudo = (Memory.FillRAM [0x2133] & 8) != 0 &&
(GFX.r212c & 15) != (GFX.r212d & 15) &&
(GFX.r2131 & 0x3f) == 0;
-#endif
-
if (IPPU.OBJChanged)
S9xSetupOBJ();
@@ -3096,9 +3028,7 @@ void S9xUpdateScreen()
uint32_t starty = GFX.StartY;
uint32_t endy = GFX.EndY;
- if (Settings.SupportHiRes &&
- (PPU.BGMode == 5 || PPU.BGMode == 6 || IPPU.Interlace
- || IPPU.DoubleHeightPixels))
+ if (PPU.BGMode == 5 || PPU.BGMode == 6 || IPPU.Interlace || IPPU.DoubleHeightPixels)
{
if (PPU.BGMode == 5 || PPU.BGMode == 6 || IPPU.Interlace)
{
@@ -3158,27 +3088,6 @@ void S9xUpdateScreen()
}
}
}
- else if (!Settings.SupportHiRes)
- {
- if (PPU.BGMode == 5 || PPU.BGMode == 6 || IPPU.Interlace)
- {
- if (!IPPU.HalfWidthPixels)
- {
- // The game has switched from lo-res to hi-res mode part way down
- // the screen. Hi-res pixels must now be drawn at half width.
- IPPU.HalfWidthPixels = true;
- }
- }
- else
- {
- if (IPPU.HalfWidthPixels)
- {
- // The game has switched from hi-res to lo-res mode part way down
- // the screen. Lo-res pixels must now be drawn at FULL width.
- IPPU.HalfWidthPixels = false;
- }
- }
- }
uint32_t black = BLACK | (BLACK << 16);
@@ -3196,7 +3105,7 @@ void S9xUpdateScreen()
(GFX.r2130 & 0x30) != 0x30 &&
!((GFX.r2130 & 0x30) == 0x10 && IPPU.Clip[1].Count[5] == 0))
{
- struct ClipData* pClip;
+ ClipData* pClip;
GFX.FixedColour = BUILD_PIXEL(IPPU.XB [PPU.FixedColourRed],
IPPU.XB [PPU.FixedColourGreen],
@@ -3264,7 +3173,6 @@ void S9xUpdateScreen()
// because there is a colour window in effect clipping
// the main screen that will allow the sub-screen
// 'underneath' to show through.
-
uint32_t b = GFX.FixedColour | (GFX.FixedColour << 16);
uint32_t* p = (uint32_t*)(GFX.SubScreen + y * GFX.Pitch2);
uint32_t* q = (uint32_t*)((uint16_t*) p + IPPU.RenderedScreenWidth);
@@ -3593,30 +3501,24 @@ void S9xUpdateScreen()
}
}
}
- else
- {
- }
- if (Settings.SupportHiRes)
+ if (PPU.BGMode != 5 && PPU.BGMode != 6 && IPPU.DoubleWidthPixels)
{
- if (PPU.BGMode != 5 && PPU.BGMode != 6 && IPPU.DoubleWidthPixels)
+ // Mixture of background modes used on screen - scale width
+ // of all non-mode 5 and 6 pixels.
+ uint32_t y;
+ for (y = starty; y <= endy; y++)
{
- // Mixture of background modes used on screen - scale width
- // of all non-mode 5 and 6 pixels.
- uint32_t y;
- for (y = starty; y <= endy; y++)
- {
- int32_t x;
- uint16_t* p = (uint16_t*)(GFX.Screen + y * GFX.Pitch2) + 255;
- uint16_t* q = (uint16_t*)(GFX.Screen + y * GFX.Pitch2) + 510;
- for (x = 255; x >= 0; x--, p--, q -= 2)
- * q = *(q + 1) = *p;
- }
+ int32_t x;
+ uint16_t* p = (uint16_t*)(GFX.Screen + y * GFX.Pitch2) + 255;
+ uint16_t* q = (uint16_t*)(GFX.Screen + y * GFX.Pitch2) + 510;
+ for (x = 255; x >= 0; x--, p--, q -= 2)
+ * q = *(q + 1) = *p;
}
-
- // Double the height of the pixels just drawn
- FIX_INTERLACE(GFX.Screen, false, GFX.ZBuffer);
}
+ // Double the height of the pixels just drawn
+ FIX_INTERLACE(GFX.Screen, false, GFX.ZBuffer);
+
IPPU.PreviousLine = IPPU.CurrentLine;
}
diff --git a/source/gfx.h b/source/gfx.h
index 230d692..c6b01cc 100644
--- a/source/gfx.h
+++ b/source/gfx.h
@@ -4,66 +4,56 @@
#define _GFX_H_
#include "port.h"
+#include "ppu.h"
#include "snes9x.h"
-void S9xStartScreenRefresh();
+void S9xStartScreenRefresh(void);
void S9xDrawScanLine(uint8_t Line);
-void S9xEndScreenRefresh();
-void S9xSetupOBJ();
-void S9xUpdateScreen();
+void S9xEndScreenRefresh(void);
+void S9xSetupOBJ(void);
+void S9xUpdateScreen(void);
void RenderLine(uint8_t line);
-void S9xBuildDirectColourMaps();
+void S9xBuildDirectColourMaps(void);
-// External port interface which must be implemented or initialised for each port.
-extern struct SGFX GFX;
-
-bool S9xInitGFX();
-void S9xDeinitGFX();
-bool S9xInitUpdate();
+bool S9xInitGFX(void);
+void S9xDeinitGFX(void);
+bool S9xInitUpdate(void);
-struct SGFX
+typedef struct
{
- // Initialize these variables
- uint8_t* Screen_buffer;
- uint8_t* SubScreen_buffer;
- uint8_t* ZBuffer_buffer;
- uint8_t* SubZBuffer_buffer;
-
- uint8_t* Screen;
- uint8_t* SubScreen;
- uint8_t* ZBuffer;
- uint8_t* SubZBuffer;
- uint32_t Pitch;
-
- // Setup in call to S9xInitGFX()
- int32_t Delta;
- uint16_t* X2;
- uint16_t* ZERO_OR_X2;
- uint16_t* ZERO;
- uint32_t RealPitch; // True pitch of Screen buffer.
- uint32_t Pitch2; // Same as RealPitch except while using speed up hack for Glide.
- uint32_t ZPitch; // Pitch of ZBuffer
- uint32_t PPL; // Number of pixels on each of Screen buffer
- uint32_t PPLx2;
- uint32_t PixSize;
- uint8_t S_safety_margin[8];
- uint8_t* S;
- uint8_t DB_safety_margin[8];
- uint8_t* DB;
- ptrdiff_t DepthDelta;
- uint8_t Z1; // Depth for comparison
- uint8_t Z2; // Depth to save
- uint8_t ZSprite; // Used to ensure only 1st sprite is drawn per pixel
- uint32_t FixedColour;
- const char* InfoString;
- uint32_t InfoStringTimeout;
- uint32_t StartY;
- uint32_t EndY;
- struct ClipData* pCurrentClip;
- uint32_t Mode7Mask;
- uint32_t Mode7PriorityMask;
- uint8_t OBJWidths[128];
- uint8_t OBJVisibleTiles[128];
+ uint8_t* Screen_buffer;
+ uint8_t* SubScreen_buffer;
+ uint8_t* ZBuffer_buffer;
+ uint8_t* SubZBuffer_buffer;
+ uint8_t* Screen;
+ uint8_t* SubScreen;
+ uint8_t* ZBuffer;
+ uint8_t* SubZBuffer;
+ uint32_t Pitch;
+
+ int32_t Delta;
+ uint16_t* X2;
+ uint16_t* ZERO_OR_X2;
+ uint16_t* ZERO;
+ uint32_t RealPitch; // True pitch of Screen buffer.
+ uint32_t Pitch2; // Same as RealPitch except while using speed up hack for Glide.
+ uint32_t ZPitch; // Pitch of ZBuffer
+ uint32_t PPL; // Number of pixels on each of Screen buffer
+ uint32_t PPLx2;
+ uint32_t PixSize;
+ uint8_t* S;
+ uint8_t* DB;
+ ptrdiff_t DepthDelta;
+ uint8_t Z1; // Depth for comparison
+ uint8_t Z2; // Depth to save
+ uint32_t FixedColour;
+ uint32_t StartY;
+ uint32_t EndY;
+ ClipData* pCurrentClip;
+ uint32_t Mode7Mask;
+ uint32_t Mode7PriorityMask;
+ uint8_t OBJWidths[128];
+ uint8_t OBJVisibleTiles[128];
struct
{
@@ -72,26 +62,29 @@ struct SGFX
struct
{
- int8_t Sprite;
+ int8_t Sprite;
uint8_t Line;
} OBJ[32];
} OBJLines [SNES_HEIGHT_EXTENDED];
- uint8_t r212c;
- uint8_t r212d;
- uint8_t r2130;
- uint8_t r2131;
- bool Pseudo;
-};
+ uint8_t r212c;
+ uint8_t r212d;
+ uint8_t r2130;
+ uint8_t r2131;
+ bool Pseudo;
+} SGFX;
-struct SLineData
+// External port interface which must be implemented or initialised for each port.
+extern SGFX GFX;
+
+typedef struct
{
struct
{
uint16_t VOffset;
uint16_t HOffset;
} BG [4];
-};
+} SLineData;
#define H_FLIP 0x4000
#define V_FLIP 0x8000
@@ -105,17 +98,15 @@ typedef struct
uint32_t TileAddress;
uint32_t NameSelect;
uint32_t SCBase;
-
uint32_t StartPalette;
uint32_t PaletteShift;
uint32_t PaletteMask;
-
uint8_t* Buffer;
uint8_t* Buffered;
bool DirectColourMode;
} SBG;
-struct SLineMatrixData
+typedef struct
{
int16_t MatrixA;
int16_t MatrixB;
@@ -123,41 +114,37 @@ struct SLineMatrixData
int16_t MatrixD;
int16_t CentreX;
int16_t CentreY;
-};
+} SLineMatrixData;
-extern uint32_t odd_high [4][16];
-extern uint32_t odd_low [4][16];
extern uint32_t even_high [4][16];
-extern uint32_t even_low [4][16];
+extern uint32_t even_low [4][16];
+extern uint32_t odd_high [4][16];
+extern uint32_t odd_low [4][16];
extern SBG BG;
extern uint16_t DirectColourMaps [8][256];
extern uint8_t mul_brightness [16][32];
// Could use BSWAP instruction on Intel port...
-#define SWAP_DWORD(dw) dw = ((dw & 0xff) << 24) | ((dw & 0xff00) << 8) | \
- ((dw & 0xff0000) >> 8) | ((dw & 0xff000000) >> 24)
+#define SWAP_DWORD(dword) dword = ((((dword) & 0x000000ff) << 24) \
+ | (((dword) & 0x0000ff00) << 8) \
+ | (((dword) & 0x00ff0000) >> 8) \
+ | (((dword) & 0xff000000) >> 24))
#ifdef FAST_LSB_WORD_ACCESS
-#define READ_2BYTES(s) (*(uint16_t *) (s))
-#define WRITE_2BYTES(s, d) *(uint16_t *) (s) = (d)
+#define READ_2BYTES(s) (*(uint16_t *) (s))
+#define WRITE_2BYTES(s, d) *(uint16_t *) (s) = (d)
+#elif defined(MSB_FIRST)
+#define READ_2BYTES(s) (*(uint8_t *) (s) | (*((uint8_t *) (s) + 1) << 8))
+#define WRITE_2BYTES(s, d) *(uint8_t *) (s) = (d), *((uint8_t *) (s) + 1) = (d) >> 8
#else
-#define READ_2BYTES(s) (*(uint8_t *) (s) | (*((uint8_t *) (s) + 1) << 8))
-#define WRITE_2BYTES(s, d) *(uint8_t *) (s) = (d), \
- *((uint8_t *) (s) + 1) = (d) >> 8
-#endif // i386
+#define READ_2BYTES(s) (*(uint16_t *) (s))
+#define WRITE_2BYTES(s, d) *(uint16_t *) (s) = (d)
+#endif
#define SUB_SCREEN_DEPTH 0
#define MAIN_SCREEN_DEPTH 32
-#if defined(OLD_COLOUR_BLENDING)
-#define COLOR_ADD(C1, C2) \
-GFX.X2 [((((C1) & RGB_REMOVE_LOW_BITS_MASK) + \
- ((C2) & RGB_REMOVE_LOW_BITS_MASK)) >> 1) + \
- ((C1) & (C2) & RGB_LOW_BITS_MASK)]
-#else
-static inline uint16_t COLOR_ADD(uint16_t, uint16_t);
-
static inline uint16_t COLOR_ADD(uint16_t C1, uint16_t C2)
{
if (C1 == 0)
@@ -165,52 +152,26 @@ static inline uint16_t COLOR_ADD(uint16_t C1, uint16_t C2)
else if (C2 == 0)
return C1;
else
- return GFX.X2 [(((C1 & RGB_REMOVE_LOW_BITS_MASK) + (C2 &
- RGB_REMOVE_LOW_BITS_MASK)) >> 1) + (C1 & C2 & RGB_LOW_BITS_MASK)] | ((
- C1 ^ C2) & RGB_LOW_BITS_MASK);
+ return GFX.X2 [(((C1 & RGB_REMOVE_LOW_BITS_MASK) +
+ (C2 & RGB_REMOVE_LOW_BITS_MASK)) >> 1) +
+ (C1 & C2 & RGB_LOW_BITS_MASK)] |
+ ((C1 ^ C2) & RGB_LOW_BITS_MASK);
}
-#endif
#define COLOR_ADD1_2(C1, C2) \
(((((C1) & RGB_REMOVE_LOW_BITS_MASK) + \
((C2) & RGB_REMOVE_LOW_BITS_MASK)) >> 1) + \
(((C1) & (C2) & RGB_LOW_BITS_MASK) | ALPHA_BITS_MASK))
-#if defined(OLD_COLOUR_BLENDING)
-#define COLOR_SUB(C1, C2) \
-GFX.ZERO_OR_X2 [(((C1) | RGB_HI_BITS_MASKx2) - \
- ((C2) & RGB_REMOVE_LOW_BITS_MASK)) >> 1]
-#elif !defined(NEW_COLOUR_BLENDING)
#define COLOR_SUB(C1, C2) \
(GFX.ZERO_OR_X2 [(((C1) | RGB_HI_BITS_MASKx2) - \
((C2) & RGB_REMOVE_LOW_BITS_MASK)) >> 1] + \
-((C1) & RGB_LOW_BITS_MASK) - ((C2) & RGB_LOW_BITS_MASK))
-#else
-inline uint16_t COLOR_SUB(uint16_t, uint16_t);
-
-inline uint16_t COLOR_SUB(uint16_t C1, uint16_t C2)
-{
- uint16_t mC1, mC2, v = 0;
-
- mC1 = C1 & FIRST_COLOR_MASK;
- mC2 = C2 & FIRST_COLOR_MASK;
- if (mC1 > mC2) v += (mC1 - mC2);
-
- mC1 = C1 & SECOND_COLOR_MASK;
- mC2 = C2 & SECOND_COLOR_MASK;
- if (mC1 > mC2) v += (mC1 - mC2);
-
- mC1 = C1 & THIRD_COLOR_MASK;
- mC2 = C2 & THIRD_COLOR_MASK;
- if (mC1 > mC2) v += (mC1 - mC2);
-
- return v;
-}
-#endif
+ ((C1) & RGB_LOW_BITS_MASK) - \
+ ((C2) & RGB_LOW_BITS_MASK))
#define COLOR_SUB1_2(C1, C2) \
GFX.ZERO [(((C1) | RGB_HI_BITS_MASKx2) - \
- ((C2) & RGB_REMOVE_LOW_BITS_MASK)) >> 1]
+ ((C2) & RGB_REMOVE_LOW_BITS_MASK)) >> 1]
typedef void (*NormalTileRenderer)(uint32_t Tile, int32_t Offset,
uint32_t StartLine, uint32_t LineCount);
diff --git a/source/globals.c b/source/globals.c
index b99e488..830c6ab 100644
--- a/source/globals.c
+++ b/source/globals.c
@@ -4,7 +4,6 @@
#include "memmap.h"
#include "ppu.h"
#include "dsp1.h"
-#include "missing.h"
#include "cpuexec.h"
#include "apu.h"
#include "dma.h"
@@ -17,8 +16,6 @@
char String[513];
-struct Missing missing;
-
SICPU ICPU;
SCPUState CPU;
@@ -39,8 +36,6 @@ SnesModel M1SNES = {1, 3, 2};
SnesModel M2SNES = {2, 4, 3};
SnesModel* Model = &M1SNES;
-uint8_t* C4RAM = NULL;
-
int32_t OpAddress = 0;
CMemory Memory;
@@ -49,7 +44,7 @@ SSNESGameFixes SNESGameFixes;
uint8_t OpenBus = 0;
-struct FxInit_s SuperFX;
+FxInit_s SuperFX;
SPPU PPU;
InternalPPU IPPU;
@@ -61,9 +56,9 @@ uint8_t* HDMABasePointers [8];
SBG BG;
-struct SGFX GFX;
-struct SLineData LineData[240];
-struct SLineMatrixData LineMatrixData [240];
+SGFX GFX;
+SLineData LineData[240];
+SLineMatrixData LineMatrixData [240];
uint8_t Mode7Depths [2];
NormalTileRenderer DrawTilePtr = NULL;
@@ -77,9 +72,7 @@ uint32_t odd_low[4][16];
uint32_t even_high[4][16];
uint32_t even_low[4][16];
-#ifdef WANT_CHEATS
SCheatData Cheat;
-#endif
#ifndef USE_BLARGG_APU
SoundStatus so;
@@ -150,12 +143,12 @@ uint8_t Depths[8][4] =
{
{TILE_2BIT, TILE_2BIT, TILE_2BIT, TILE_2BIT}, // 0
{TILE_4BIT, TILE_4BIT, TILE_2BIT, 0}, // 1
- {TILE_4BIT, TILE_4BIT, 0, 0}, // 2
- {TILE_8BIT, TILE_4BIT, 0, 0}, // 3
- {TILE_8BIT, TILE_2BIT, 0, 0}, // 4
- {TILE_4BIT, TILE_2BIT, 0, 0}, // 5
- {TILE_4BIT, 0, 0, 0}, // 6
- {0, 0, 0, 0} // 7
+ {TILE_4BIT, TILE_4BIT, 0, 0}, // 2
+ {TILE_8BIT, TILE_4BIT, 0, 0}, // 3
+ {TILE_8BIT, TILE_2BIT, 0, 0}, // 4
+ {TILE_4BIT, TILE_2BIT, 0, 0}, // 5
+ {TILE_4BIT, 0, 0, 0}, // 6
+ {0, 0, 0, 0} // 7
};
uint8_t BGSizes [2] =
{
@@ -165,8 +158,8 @@ uint16_t DirectColourMaps [8][256];
int32_t FilterValues[4][2] =
{
- {0, 0},
- {240, 0},
+ {0, 0},
+ {240, 0},
{488, -240},
{460, -208}
};
@@ -208,7 +201,7 @@ uint8_t APUROM [64] =
// Raw SPC700 instruction cycle lengths
uint16_t S9xAPUCycleLengths [256] =
{
- /* 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f, */
+ /* 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f, */
/* 00 */ 2, 8, 4, 5, 3, 4, 3, 6, 2, 6, 5, 4, 5, 4, 6, 8,
/* 10 */ 2, 8, 4, 5, 4, 5, 5, 6, 5, 5, 6, 5, 2, 2, 4, 6,
/* 20 */ 2, 8, 4, 5, 3, 4, 3, 6, 2, 6, 5, 4, 5, 4, 5, 4,
@@ -231,7 +224,7 @@ uint16_t S9xAPUCycleLengths [256] =
// to be relative to the 65c816 instruction lengths.
uint16_t S9xAPUCycles [256] =
{
- /* 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f, */
+ /* 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f, */
/* 00 */ 2, 8, 4, 5, 3, 4, 3, 6, 2, 6, 5, 4, 5, 4, 6, 8,
/* 10 */ 2, 8, 4, 5, 4, 5, 5, 6, 5, 5, 6, 5, 2, 2, 4, 6,
/* 20 */ 2, 8, 4, 5, 3, 4, 3, 6, 2, 6, 5, 4, 5, 4, 5, 4,
diff --git a/source/memmap.c b/source/memmap.c
index 72b5d17..31b46e6 100644
--- a/source/memmap.c
+++ b/source/memmap.c
@@ -29,7 +29,7 @@
#define MAP_RONLY_SRAM_OR_NONE (Memory.SRAMSize == 0 ? (uint8_t*) MAP_NONE : (uint8_t*) MAP_RONLY_SRAM)
#include "fxemu.h"
-extern struct FxInit_s SuperFX;
+extern FxInit_s SuperFX;
static int32_t retry_count = 0;
static uint8_t bytes0x2000 [0x2000];
@@ -107,11 +107,9 @@ static bool AllASCII(uint8_t* b, int32_t size)
{
int32_t i;
for (i = 0; i < size; i++)
- {
if (b[i] < 32 || b[i] > 126)
- return (false);
- }
- return (true);
+ return false;
+ return true;
}
static int32_t ScoreHiROM(bool skip_header, int32_t romoff)
@@ -156,7 +154,7 @@ static int32_t ScoreHiROM(bool skip_header, int32_t romoff)
if (!AllASCII(&Memory.ROM [o + 0xc0], ROM_NAME_LEN - 1))
score -= 1;
- return (score);
+ return score;
}
static int32_t ScoreLoROM(bool skip_header, int32_t romoff)
@@ -198,7 +196,7 @@ static int32_t ScoreLoROM(bool skip_header, int32_t romoff)
if (!AllASCII(&Memory.ROM [o + 0xc0], ROM_NAME_LEN - 1))
score -= 1;
- return (score);
+ return score;
}
static char* Safe(const char* s)
@@ -232,7 +230,7 @@ static char* Safe(const char* s)
safe [i] = '?';
}
safe [len] = 0;
- return (safe);
+ return safe;
}
/**********************************************************************************************/
@@ -269,7 +267,7 @@ bool S9xInitMemory()
!IPPU.TileCached [TILE_4BIT] || !IPPU.TileCached [TILE_8BIT])
{
S9xDeinitMemory();
- return (false);
+ return false;
}
// FillRAM uses first 32K of ROM image area, otherwise space just
@@ -287,10 +285,7 @@ bool S9xInitMemory()
SuperFX.nRomBanks = (2 * 1024 * 1024) / (32 * 1024);
SuperFX.pvRom = (uint8_t*) Memory.ROM;
- Memory.SDD1Data = NULL;
- Memory.SDD1Index = NULL;
-
- return (true);
+ return true;
}
void S9xDeinitMemory()
@@ -341,21 +336,6 @@ void S9xDeinitMemory()
IPPU.TileCached[t] = NULL;
}
}
- FreeSDD1Data();
-}
-
-void FreeSDD1Data()
-{
- if (Memory.SDD1Index)
- {
- free(Memory.SDD1Index);
- Memory.SDD1Index = NULL;
- }
- if (Memory.SDD1Data)
- {
- free(Memory.SDD1Data);
- Memory.SDD1Data = NULL;
- }
}
#ifndef LOAD_FROM_MEMORY_TEST
@@ -371,7 +351,7 @@ static int32_t ReadInt(FILE* f, uint32_t nbytes)
return -1;
v = (v << 8) | (c & 0xFF);
}
- return (v);
+ return v;
}
#define IPS_EOF 0x00454F46l
@@ -393,8 +373,7 @@ static void CheckForIPSPatch(const char* rom_filename, bool header, int32_t* rom
if (!(patch_file = fopen(S9xGetFilename("ips"), "rb")))
return;
- if (fread(fname, 1, 5, patch_file) != 5 ||
- strncmp(fname, "PATCH", 5) != 0)
+ if (fread(fname, 1, 5, patch_file) != 5 || strncmp(fname, "PATCH", 5) != 0)
{
fclose(patch_file);
return;
@@ -496,7 +475,7 @@ static uint32_t FileLoader(uint8_t* buffer, const char* filename, int32_t maxsiz
#endif
if ((ROMFile = fopen(fname, "rb")) == NULL)
- return (0);
+ return 0;
strcpy(Memory.ROMFilename, fname);
@@ -635,7 +614,7 @@ again:
TotalFileSize = FileLoader(Memory.ROM, filename, MAX_ROM_SIZE);
if (!TotalFileSize)
- return false; // it ends here
+ return false; // it ends here
else if (!Settings.NoPatch)
CheckForIPSPatch(filename, Memory.HeaderCount != 0, &TotalFileSize);
#endif
@@ -945,17 +924,12 @@ again:
if (Memory.ExtendedFormat == SMALLFIRST)
Tales = true;
- FreeSDD1Data();
InitROM(Tales);
-#ifdef WANT_CHEATS
S9xLoadCheatFile(S9xGetFilename("cht"));
S9xInitCheatData();
S9xApplyCheats();
-#endif
-
S9xReset();
-
- return (true);
+ return true;
}
/* compatibility wrapper */
@@ -1162,9 +1136,7 @@ void InitROM(bool Interleaved)
Settings.SPC7110RTC = true;
}
- if (Settings.BS)
- BSLoROMMap();
- else if (Settings.SPC7110)
+ if (Settings.SPC7110)
SPC7110HiROMMap();
else if ((Memory.ROMSpeed & ~0x10) == 0x25)
TalesROMMap(Interleaved);
@@ -1291,8 +1263,6 @@ void InitROM(bool Interleaved)
Memory.SRAMSize = 3;
LoROMMap();
}
- else if (Settings.BS)
- BSLoROMMap();
else
LoROMMap();
}
@@ -1392,8 +1362,8 @@ void InitROM(bool Interleaved)
sprintf(Memory.ROMId, "%s", Safe(Memory.ROMId));
sprintf(Memory.CompanyId, "%s", Safe(Memory.CompanyId));
- sprintf(String,
- "\"%s\" [%s] %s, %s, Type: %s, Mode: %s, TV: %s, S-RAM: %s, ROMId: %s Company: %2.2s",
+ fprintf(stderr,
+ "\"%s\" [%s] %s, %s, Type: %s, Mode: %s, TV: %s, S-RAM: %s, ROMId: %s Company: %2.2s\n",
Memory.ROMName,
(Memory.ROMChecksum + Memory.ROMComplementChecksum != 0xffff ||
Memory.ROMChecksum != Memory.CalculatedChecksum) ? "bad checksum" : "checksum ok",
@@ -1406,7 +1376,6 @@ void InitROM(bool Interleaved)
Memory.ROMId,
Memory.CompanyId);
- S9xMessage(String);
Settings.ForceHeader = Settings.ForceHiROM = Settings.ForceLoROM =
Settings.ForceInterleaved = Settings.ForceNoHeader =
Settings.ForceNotInterleaved =
@@ -1740,83 +1709,6 @@ void SetaDSPMap()
WriteProtectROM();
}
-void BSLoROMMap()
-{
- int32_t c;
- int32_t i;
-
- if (Settings.BS)
- Memory.SRAMSize = 5;
-
- // Banks 00->3f and 80->bf
- for (c = 0; c < 0x400; c += 16)
- {
- Memory.Map [c + 0] = Memory.Map [c + 0x800] = Memory.RAM;
- Memory.Map [c + 1] = Memory.Map [c + 0x801] = Memory.RAM;
- Memory.BlockIsRAM [c + 0] = Memory.BlockIsRAM [c + 0x800] = true;
- Memory.BlockIsRAM [c + 1] = Memory.BlockIsRAM [c + 0x801] = true;
-
- Memory.Map [c + 2] = Memory.Map [c + 0x802] = (uint8_t*) MAP_PPU;
- Memory.Map [c + 3] = Memory.Map [c + 0x803] = (uint8_t*) MAP_PPU;
- Memory.Map [c + 4] = Memory.Map [c + 0x804] = (uint8_t*) MAP_CPU;
- Memory.Map [c + 5] = Memory.Map [c + 0x805] = (uint8_t*) Memory.RAM;
- Memory.BlockIsRAM [c + 5] = Memory.BlockIsRAM [c + 0x805] = true;
-
- Memory.Map [c + 6] = Memory.Map [c + 0x806] = (uint8_t*) Memory.RAM;
- Memory.BlockIsRAM [c + 6] = Memory.BlockIsRAM [c + 0x806] = true;
- Memory.Map [c + 7] = Memory.Map [c + 0x807] = (uint8_t*) Memory.RAM;
- Memory.BlockIsRAM [c + 7] = Memory.BlockIsRAM [c + 0x807] = true;
- for (i = c + 8; i < c + 16; i++)
- {
- Memory.Map [i] = Memory.Map [i + 0x800] = &Memory.ROM [(c << 11) % Memory.CalculatedSize] - 0x8000;
- Memory.BlockIsROM [i] = Memory.BlockIsROM [i + 0x800] = true;
- }
- }
-
- for (c = 0; c < 8; c++)
- {
- Memory.Map[(c << 4) + 0x105] = MAP_LOROM_SRAM_OR_NONE;
- Memory.BlockIsROM [(c << 4) + 0x105] = false;
- Memory.BlockIsRAM [(c << 4) + 0x105] = true;
- }
-
- for (c = 1; c <= 4; c++)
- {
- for (i = 0; i < 16; i++)
- {
- Memory.Map[0x400 + i + (c << 4)] = MAP_LOROM_SRAM_OR_NONE;
- Memory.BlockIsRAM[0x400 + i + (c << 4)] = true;
- Memory.BlockIsROM[0x400 + i + (c << 4)] = false;
- }
- }
-
- for (i = 0; i < 0x80; i++)
- {
- Memory.Map[0x700 + i] = &Memory.BSRAM[0x10000 * (i / 16)];
- Memory.BlockIsRAM[0x700 + i] = true;
- Memory.BlockIsROM[0x700 + i] = false;
- }
- for (i = 0; i < 8; i++)
- {
- Memory.Map[0x205 + (i << 4)] = Memory.Map[0x285 + (i << 4)] = Memory.Map[0x305
- + (i << 4)] = Memory.Map[0x385 + (i << 4)] = Memory.Map[0x705 + (i << 4)];
- Memory.BlockIsRAM[0x205 + (i << 4)] = Memory.BlockIsRAM[0x285 +
- (i << 4)] = Memory.BlockIsRAM[0x305 + (i << 4)] = Memory.BlockIsRAM[0x385 +
- (i << 4)] = true;
- Memory.BlockIsROM[0x205 + (i << 4)] = Memory.BlockIsROM[0x285 +
- (i << 4)] = Memory.BlockIsROM[0x305 + (i << 4)] = Memory.BlockIsROM[0x385 +
- (i << 4)] = false;
- }
- for (c = 0; c < 8; c++)
- {
- Memory.Map[(c << 4) + 0x005] = Memory.BSRAM - 0x5000;
- Memory.BlockIsROM [(c << 4) + 0x005] = false;
- Memory.BlockIsRAM [(c << 4) + 0x005] = true;
- }
- MapRAM();
- WriteProtectROM();
-}
-
void HiROMMap()
{
int32_t i;
@@ -1920,8 +1812,7 @@ void TalesROMMap(bool Interleaved)
}
for (i = c + 8; i < c + 16; i++)
{
- Memory.Map [i] = &Memory.ROM [((c << 12) % (Memory.CalculatedSize - 0x400000)) +
- OFFSET0];
+ Memory.Map [i] = &Memory.ROM [((c << 12) % (Memory.CalculatedSize - 0x400000)) + OFFSET0];
Memory.Map [i + 0x800] = &Memory.ROM [((c << 12) % 0x400000) + OFFSET2];
Memory.BlockIsROM [i] = true;
Memory.BlockIsROM [i + 0x800] = true;
@@ -2616,17 +2507,17 @@ void SPC7110Sram(uint8_t newstate)
const char* TVStandard()
{
- return (Settings.PAL ? "PAL" : "NTSC");
+ return Settings.PAL ? "PAL" : "NTSC";
}
const char* Speed()
{
- return (Memory.ROMSpeed & 0x10 ? "120ns" : "200ns");
+ return Memory.ROMSpeed & 0x10 ? "120ns" : "200ns";
}
const char* MapType()
{
- return (Memory.HiROM ? "HiROM" : "LoROM");
+ return Memory.HiROM ? "HiROM" : "LoROM";
}
const char* StaticRAMSize()
@@ -2634,9 +2525,9 @@ const char* StaticRAMSize()
static char tmp [20];
if (Memory.SRAMSize > 16)
- return ("Corrupt");
+ return "Corrupt";
sprintf(tmp, "%dKB", (Memory.SRAMMask + 1) / 1024);
- return (tmp);
+ return tmp;
}
const char* Size()
@@ -2644,9 +2535,9 @@ const char* Size()
static char tmp [20];
if (Memory.ROMSize < 7 || Memory.ROMSize - 7 > 23)
- return ("Corrupt");
+ return "Corrupt";
sprintf(tmp, "%dMbits", 1 << (Memory.ROMSize - 7));
- return (tmp);
+ return tmp;
}
const char* KartContents()
@@ -2663,7 +2554,7 @@ const char* KartContents()
"ROM", "ROM+RAM", "ROM+RAM+BAT"
};
if (Memory.ROMType == 0 && !Settings.BS)
- return ("ROM only");
+ return "ROM only";
sprintf(tmp, "%s", Contents [(Memory.ROMType & 0xf) % 3]);
@@ -2698,29 +2589,29 @@ const char* KartContents()
sprintf(tmp, "%s+DSP%d", tmp, Settings.DSP == 0 ? 1 : Settings.DSP);
}
- return (tmp);
+ return tmp;
}
const char* MapMode()
{
static char tmp [4];
sprintf(tmp, "%02x", Memory.ROMSpeed & ~0x10);
- return (tmp);
+ return tmp;
}
const char* ROMID()
{
- return (Memory.ROMId);
+ return Memory.ROMId;
}
bool match_na(const char* str)
{
- return (strcmp(Memory.ROMName, str) == 0);
+ return strcmp(Memory.ROMName, str) == 0;
}
bool match_id(const char* str)
{
- return (strncmp(Memory.ROMId, str, strlen(str)) == 0);
+ return strncmp(Memory.ROMId, str, strlen(str)) == 0;
}
void ApplyROMFixes()
@@ -3232,6 +3123,4 @@ void ParseSNESHeader(uint8_t* RomHeader)
sprintf(Memory.CompanyId, "%02X", RomHeader[0x2A]);
}
-#undef INLINE
-#define INLINE
#include "getset.h"
diff --git a/source/memmap.h b/source/memmap.h
index 3675357..0d24aae 100644
--- a/source/memmap.h
+++ b/source/memmap.h
@@ -10,11 +10,8 @@
#define READ_DWORD(s) (*(uint32_t *) (s))
#define WRITE_WORD(s, d) (*(uint16_t *) (s)) = (d)
#define WRITE_DWORD(s, d) (*(uint32_t *) (s)) = (d)
-
-#define READ_3WORD(s) (0x00ffffff & *(uint32_t *) (s))
+#define READ_3WORD(s) ((*(uint32_t *) (s)) & 0x00ffffff)
#define WRITE_3WORD(s, d) *(uint16_t *) (s) = (uint16_t)(d), *((uint8_t *) (s) + 2) = (uint8_t) ((d) >> 16)
-
-
#else
#define READ_WORD(s) (*(uint8_t *) (s) | (*((uint8_t *) (s) + 1) << 8))
#define READ_DWORD(s) (*(uint8_t *) (s) | (*((uint8_t *) (s) + 1) << 8) | (*((uint8_t *) (s) + 2) << 16) | (*((uint8_t *) (s) + 3) << 24))
@@ -113,16 +110,16 @@ typedef struct
uint8_t* C4RAM;
bool HiROM;
bool LoROM;
- uint32_t SRAMMask;
+ uint16_t SRAMMask;
uint8_t SRAMSize;
- uint8_t* Map [MEMMAP_NUM_BLOCKS];
- uint8_t* WriteMap [MEMMAP_NUM_BLOCKS];
+ uint8_t* Map [MEMMAP_NUM_BLOCKS];
+ uint8_t* WriteMap [MEMMAP_NUM_BLOCKS];
uint8_t MemorySpeed [MEMMAP_NUM_BLOCKS];
- uint8_t BlockIsRAM [MEMMAP_NUM_BLOCKS];
- uint8_t BlockIsROM [MEMMAP_NUM_BLOCKS];
- char ROMName [ROM_NAME_LEN];
- char ROMId [5];
- char CompanyId [3];
+ uint8_t BlockIsRAM [MEMMAP_NUM_BLOCKS];
+ uint8_t BlockIsROM [MEMMAP_NUM_BLOCKS];
+ char ROMName [ROM_NAME_LEN];
+ char ROMId [5];
+ char CompanyId [3];
uint8_t ROMSpeed;
uint8_t ROMType;
uint8_t ROMSize;
@@ -132,12 +129,8 @@ typedef struct
uint32_t CalculatedChecksum;
uint32_t ROMChecksum;
uint32_t ROMComplementChecksum;
- uint8_t* SDD1Index;
- uint8_t* SDD1Data;
- uint32_t SDD1Entries;
char ROMFilename [_MAX_PATH];
uint8_t ROMRegion;
- uint32_t ROMCRC32;
uint8_t ExtendedFormat;
uint8_t* BSRAM;
} CMemory;
@@ -147,7 +140,6 @@ void ResetSpeedMap();
extern CMemory Memory;
void S9xDeinterleaveMode2();
-#ifdef NO_INLINE_SET_GET
uint8_t S9xGetByte(uint32_t Address);
uint16_t S9xGetWord(uint32_t Address);
void S9xSetByte(uint8_t Byte, uint32_t Address);
@@ -158,11 +150,4 @@ uint8_t* GetBasePointer(uint32_t Address);
extern uint8_t OpenBus;
-#else
-#ifndef INLINE
-#define INLINE static inline
-#endif
-#include "getset.h"
-#endif // NO_INLINE_SET_GET
-
#endif // _memmap_h_
diff --git a/source/port.h b/source/port.h
index 622027f..12d210c 100644
--- a/source/port.h
+++ b/source/port.h
@@ -4,7 +4,6 @@
#define _PORT_H_
#include <limits.h>
-
#include <string.h>
#include <sys/types.h>
@@ -24,23 +23,23 @@
#define PATH_MAX 1024
#endif
-#define _MAX_DIR PATH_MAX
+#define _MAX_DIR PATH_MAX
#define _MAX_DRIVE 1
#define _MAX_FNAME PATH_MAX
-#define _MAX_EXT PATH_MAX
-#define _MAX_PATH PATH_MAX
+#define _MAX_EXT PATH_MAX
+#define _MAX_PATH PATH_MAX
void _makepath(char* path, const char* drive, const char* dir, const char* fname, const char* ext);
void _splitpath(const char* path, char* drive, char* dir, char* fname, char* ext);
#else /* __WIN32__ */
-#define strcasecmp stricmp
+#define strcasecmp stricmp
#define strncasecmp strnicmp
#endif
#define SLASH_STR "/"
#define SLASH_CHAR '/'
-#if defined(__i386__) || defined(__i486__) || defined(__i586__) || \
+#if defined(__i386__) || defined(__i486__) || defined(__i586__) || \
defined(__WIN32__) || defined(__alpha__)
#define FAST_LSB_WORD_ACCESS
#elif defined(__MIPSEL__)
diff --git a/source/ppu.c b/source/ppu.c
index f48800d..167610d 100644
--- a/source/ppu.c
+++ b/source/ppu.c
@@ -4,7 +4,6 @@
#include "memmap.h"
#include "ppu.h"
#include "cpuexec.h"
-#include "missing.h"
#include "apu.h"
#include "dma.h"
#include "display.h"
@@ -12,10 +11,10 @@
#include "sdd1.h"
#include "srtc.h"
#include "spc7110.h"
-
#include "fxemu.h"
#include "fxinst.h"
-extern struct FxInit_s SuperFX;
+
+extern FxInit_s SuperFX;
extern uint8_t mul_brightness [16][32];
uint32_t justifiers = 0xffff00aa;
@@ -28,7 +27,6 @@ void S9xLatchCounters(bool force)
if (!force && !(Memory.FillRAM[0x4213] & 0x80))
return;
- PPU.HVBeamCounterLatched = 1;
PPU.VBeamPosLatched = (uint16_t) CPU.V_Counter;
PPU.HBeamPosLatched = (uint16_t)((CPU.Cycles * SNES_HCOUNTER_MAX) / Settings.H_Max);
@@ -111,7 +109,7 @@ static void S9xSetSuperFX(uint8_t Byte, uint16_t Address)
return;
old_fill_ram = Memory.FillRAM[Address];
- Memory.FillRAM[Address] = Byte;
+ Memory.FillRAM[Address] = Byte;
switch (Address)
{
@@ -176,8 +174,6 @@ void S9xSetPPU(uint8_t Byte, uint16_t Address)
IPPU.DirectColourMapsNeedRebuild = true;
PPU.Brightness = Byte & 0xF;
S9xFixColourBrightness();
- if (PPU.Brightness > IPPU.MaxBrightness)
- IPPU.MaxBrightness = PPU.Brightness;
}
if ((Memory.FillRAM[0x2100] & 0x80) != (Byte & 0x80))
{
@@ -201,7 +197,6 @@ void S9xSetPPU(uint8_t Byte, uint16_t Address)
// Sprite write address (low)
PPU.OAMAddr = ((Memory.FillRAM[0x2103] & 1) << 8) | Byte;
PPU.OAMFlip = 2;
- PPU.OAMReadFlip = 0;
PPU.SavedOAMAddr = PPU.OAMAddr;
if (PPU.OAMPriorityRotation && PPU.FirstSprite != (PPU.OAMAddr >> 1))
{
@@ -232,7 +227,6 @@ void S9xSetPPU(uint8_t Byte, uint16_t Address)
}
}
PPU.OAMFlip = 0;
- PPU.OAMReadFlip = 0;
PPU.SavedOAMAddr = PPU.OAMAddr;
break;
case 0x2104:
@@ -295,8 +289,6 @@ void S9xSetPPU(uint8_t Byte, uint16_t Address)
PPU.BG[3].NameBase = ((Byte >> 4) & 7) << 12;
}
break;
- //This is the Theme Park fix - it appears all these registers
- //share a previous byte value for setting them.
case 0x210D:
PPU.BG[0].HOffset = (Byte << 8) | PPU.BGnxOFSbyte;
PPU.BGnxOFSbyte = Byte;
@@ -329,7 +321,6 @@ void S9xSetPPU(uint8_t Byte, uint16_t Address)
PPU.BG[3].VOffset = (Byte << 8) | PPU.BGnxOFSbyte;
PPU.BGnxOFSbyte = Byte;
break;
- //end Theme Park
case 0x2115:
// VRAM byte/word access flag and increment
PPU.VMA.High = (bool) (Byte & 0x80);
@@ -395,12 +386,12 @@ void S9xSetPPU(uint8_t Byte, uint16_t Address)
case 0x211b:
// Mode 7 matrix A (low & high)
PPU.MatrixA = ((PPU.MatrixA >> 8) & 0xff) | (Byte << 8);
- PPU.Need16x8Mulitply = true;
+ PPU.Need16x8Multiply = true;
break;
case 0x211c:
// Mode 7 matrix B (low & high)
PPU.MatrixB = ((PPU.MatrixB >> 8) & 0xff) | (Byte << 8);
- PPU.Need16x8Mulitply = true;
+ PPU.Need16x8Multiply = true;
break;
case 0x211d:
// Mode 7 matrix C (low & high)
@@ -605,7 +596,6 @@ void S9xSetPPU(uint8_t Byte, uint16_t Address)
IPPU.OBJChanged = true;
if (PPU.BGMode == 5 || PPU.BGMode == 6)
IPPU.Interlace = (bool) (Byte & 1);
- IPPU.InterlaceSprites = false;
}
}
break;
@@ -702,16 +692,10 @@ void S9xSetPPU(uint8_t Byte, uint16_t Address)
case 0x217e:
case 0x217f:
#ifndef USE_BLARGG_APU
-#ifdef SPCTOOL
- _SPCInPB(Address & 3, Byte);
-#else
Memory.FillRAM [Address] = Byte;
IAPU.RAM [(Address & 3) + 0xf4] = Byte;
-#ifdef SPC700_SHUTDOWN
IAPU.APUExecuting = Settings.APUEnabled;
IAPU.WaitCounter++;
-#endif
-#endif // SPCTOOL
#else
S9xAPUWritePort(Address & 3, Byte);
#endif // #ifndef USE_BLARGG_APU
@@ -742,7 +726,6 @@ void S9xSetPPU(uint8_t Byte, uint16_t Address)
S9xSetSA1(Byte, Address);
else
Memory.FillRAM [Address] = Byte;
-
return;
}
else
@@ -794,13 +777,13 @@ uint8_t S9xGetPPU(uint16_t Address)
case 0x2135:
case 0x2136:
// 16bit x 8bit multiply read result.
- if (PPU.Need16x8Mulitply)
+ if (PPU.Need16x8Multiply)
{
int32_t r = (int32_t) PPU.MatrixA * (int32_t)(PPU.MatrixB >> 8);
Memory.FillRAM[0x2134] = (uint8_t) r;
Memory.FillRAM[0x2135] = (uint8_t)(r >> 8);
Memory.FillRAM[0x2136] = (uint8_t)(r >> 16);
- PPU.Need16x8Mulitply = false;
+ PPU.Need16x8Multiply = false;
}
return (PPU.OpenBus1 = Memory.FillRAM[Address]);
case 0x2137:
@@ -984,13 +967,9 @@ uint8_t S9xGetPPU(uint16_t Address)
case 0x217e:
case 0x217f:
#ifndef USE_BLARGG_APU
-#ifdef SPCTOOL
- return ((uint8_t) _SPCOutP [Address & 3]);
-#else
-#ifdef SPC700_SHUTDOWN
IAPU.APUExecuting = Settings.APUEnabled;
IAPU.WaitCounter++;
-#endif
+
if (Settings.APUEnabled)
{
if (SNESGameFixes.APU_OutPorts_ReturnValueFix &&
@@ -999,17 +978,9 @@ uint8_t S9xGetPPU(uint16_t Address)
return (APU.OutPorts [Address & 3]);
}
-#endif
- switch (Settings.SoundSkipMethod)
- {
- case 0:
- case 1:
- case 3:
- CPU.BranchSkip = true;
- break;
- case 2:
- break;
- }
+
+ CPU.BranchSkip = true;
+
if ((Address & 3) < 2)
{
int32_t r = rand();
@@ -1028,7 +999,7 @@ uint8_t S9xGetPPU(uint16_t Address)
return ((r >> 3) & 0xff);
}
return (Memory.FillRAM[Address]);
-#else // SPCTOOL
+#else
return (S9xAPUReadPort(Address & 3));
#endif //#ifndef USE_BLARGG_APU
case 0x2180:
@@ -1069,16 +1040,13 @@ uint8_t S9xGetPPU(uint16_t Address)
byte = Memory.FillRAM [Address];
-#ifdef CPU_SHUTDOWN
if (Address == 0x3030)
CPU.WaitAddress = CPU.PCAtOpcodeStart;
- else
-#endif
- if (Address == 0x3031)
- {
- CLEAR_IRQ_SOURCE(GSU_IRQ_SOURCE);
- Memory.FillRAM [0x3031] = byte & 0x7f;
- }
+ else if (Address == 0x3031)
+ {
+ CLEAR_IRQ_SOURCE(GSU_IRQ_SOURCE);
+ Memory.FillRAM [0x3031] = byte & 0x7f;
+ }
return byte;
}
return byte;
@@ -1306,20 +1274,12 @@ void S9xSetCPU(uint8_t byte, uint16_t Address)
// IRQ ocurred flag (reset on read or write)
CLEAR_IRQ_SOURCE(PPU_V_BEAM_IRQ_SOURCE | PPU_H_BEAM_IRQ_SOURCE);
break;
- case 0x4212:
- // v-blank, h-blank and joypad being scanned flags (read-only)
- /* fall through */
- case 0x4213:
- // I/O Port (read-only)
- /* fall through */
+ case 0x4212: // v-blank, h-blank and joypad being scanned flags (read-only)
+ case 0x4213: // I/O Port (read-only)
case 0x4214:
- case 0x4215:
- // Quotent of divide (read-only)
- /* fall through */
+ case 0x4215: // Quotent of divide (read-only)
case 0x4216:
- case 0x4217:
- // Multiply product (read-only)
- /* fall through */
+ case 0x4217: // Multiply product (read-only)
case 0x4218:
case 0x4219:
case 0x421a:
@@ -1327,8 +1287,7 @@ void S9xSetCPU(uint8_t byte, uint16_t Address)
case 0x421c:
case 0x421d:
case 0x421e:
- case 0x421f:
- // Joypad values (read-only)
+ case 0x421f: // Joypad values (read-only)
return;
case 0x4300:
case 0x4310:
@@ -1547,11 +1506,7 @@ void S9xSetCPU(uint8_t byte, uint16_t Address)
case 0x4841:
case 0x4842:
if (Settings.SPC7110)
- {
S9xSetSPC7110(byte, Address);
- break;
- }
- default:
break;
}
Memory.FillRAM [Address] = byte;
@@ -1586,13 +1541,8 @@ uint8_t S9xGetCPU(uint16_t Address)
if (Memory.FillRAM [0x4016] & 1)
{
// MultiPlayer5 adaptor is only allowed to be plugged into port 2
- switch (IPPU.Controller)
- {
- case SNES_MULTIPLAYER5:
- return (2);
- case SNES_MOUSE:
- break;
- }
+ if (IPPU.Controller == SNES_MULTIPLAYER5)
+ return 2;
return 0;
}
@@ -1653,24 +1603,18 @@ uint8_t S9xGetCPU(uint16_t Address)
case 0x420f:
return OpenBus;
case 0x4210:
-#ifdef CPU_SHUTDOWN
CPU.WaitAddress = CPU.PCAtOpcodeStart;
-#endif
byte = Memory.FillRAM[0x4210];
- Memory.FillRAM[0x4210] = Model->_5A22;
- //SNEeSe returns 2 for 5A22 version.
+ Memory.FillRAM[0x4210] = Model->_5A22; //SNEeSe returns 2 for 5A22 version.
return ((byte & 0x80) | (OpenBus & 0x70) | Model->_5A22);
case 0x4211:
byte = (CPU.IRQActive & (PPU_V_BEAM_IRQ_SOURCE | PPU_H_BEAM_IRQ_SOURCE)) ? 0x80 : 0;
CLEAR_IRQ_SOURCE(PPU_V_BEAM_IRQ_SOURCE | PPU_H_BEAM_IRQ_SOURCE);
byte |= OpenBus & 0x7f;
-
return (byte);
case 0x4212:
// V-blank, h-blank and joypads being read flags (read-only)
-#ifdef CPU_SHUTDOWN
CPU.WaitAddress = CPU.PCAtOpcodeStart;
-#endif
return (REGISTER_4212() | (OpenBus & 0x3E));
case 0x4213:
// I/O port input - returns 0 wherever $4201 is 0, and 1 elsewhere
@@ -1840,7 +1784,7 @@ static void CommonPPUReset()
PPU.VMA.Shift = 0;
uint8_t B;
- for (B = 0; B != 4; B++)
+ for (B = 0; B < 4; B++)
{
PPU.BG[B].SCBase = 0;
PPU.BG[B].VOffset = 0;
@@ -1849,7 +1793,6 @@ static void CommonPPUReset()
PPU.BG[B].NameBase = 0;
PPU.BG[B].SCSize = 0;
- PPU.ClipCounts[B] = 0;
PPU.ClipWindowOverlapLogic [B] = CLIP_OR;
PPU.ClipWindow1Enable[B] = false;
PPU.ClipWindow2Enable[B] = false;
@@ -1857,8 +1800,6 @@ static void CommonPPUReset()
PPU.ClipWindow2Inside[B] = true;
}
- PPU.ClipCounts[4] = 0;
- PPU.ClipCounts[5] = 0;
PPU.ClipWindowOverlapLogic[4] = PPU.ClipWindowOverlapLogic[5] = CLIP_OR;
PPU.ClipWindow1Enable[4] = PPU.ClipWindow1Enable[5] = false;
PPU.ClipWindow2Enable[4] = PPU.ClipWindow2Enable[5] = false;
@@ -1876,7 +1817,6 @@ static void CommonPPUReset()
}
PPU.FirstSprite = 0;
- PPU.LastSprite = 127;
int32_t Sprite;
for (Sprite = 0; Sprite < 128; Sprite++)
{
@@ -1896,7 +1836,6 @@ static void CommonPPUReset()
PPU.OpenBus2 = 0;
PPU.OAMFlip = 0;
- PPU.OAMTileAddress = 0;
PPU.OAMAddr = 0;
PPU.IRQVBeamPos = 0;
PPU.IRQHBeamPos = 0;
@@ -1905,7 +1844,6 @@ static void CommonPPUReset()
PPU.HBeamFlip = 0;
PPU.VBeamFlip = 0;
- PPU.HVBeamCounterLatched = 0;
PPU.MatrixA = PPU.MatrixB = PPU.MatrixC = PPU.MatrixD = 0;
PPU.CentreX = PPU.CentreY = 0;
@@ -1914,12 +1852,10 @@ static void CommonPPUReset()
PPU.SavedOAMAddr = 0;
PPU.ScreenHeight = SNES_HEIGHT;
PPU.WRAM = 0;
- PPU.BG_Forced = 0;
PPU.ForcedBlanking = true;
PPU.OBJSizeSelect = 0;
PPU.OBJNameSelect = 0;
PPU.OBJNameBase = 0;
- PPU.OAMReadFlip = 0;
PPU.BGnxOFSbyte = 0;
memset(PPU.OAMData, 0, 512 + 32);
@@ -1938,28 +1874,19 @@ static void CommonPPUReset()
PPU.Window2Right = 0;
PPU.RecomputeClipWindows = true;
PPU.CGFLIPRead = false;
- PPU.Need16x8Mulitply = false;
- PPU.MouseSpeed[0] = PPU.MouseSpeed[1] = 0;
+ PPU.Need16x8Multiply = false;
IPPU.ColorsChanged = true;
IPPU.HDMA = 0;
- IPPU.HDMAStarted = false;
- IPPU.MaxBrightness = 0;
- IPPU.LatchedBlanking = false;
IPPU.OBJChanged = true;
IPPU.RenderThisFrame = true;
IPPU.DirectColourMapsNeedRebuild = true;
IPPU.FrameCount = 0;
- IPPU.RenderedFramesCount = 0;
- IPPU.DisplayedRenderedFrameCount = 0;
- IPPU.SkippedFrames = 0;
- IPPU.FrameSkip = 0;
memset(IPPU.TileCached [TILE_2BIT], 0, MAX_2BIT_TILES);
memset(IPPU.TileCached [TILE_4BIT], 0, MAX_4BIT_TILES);
memset(IPPU.TileCached [TILE_8BIT], 0, MAX_8BIT_TILES);
IPPU.FirstVRAMRead = false;
IPPU.Interlace = false;
- IPPU.InterlaceSprites = false;
IPPU.DoubleWidthPixels = false;
IPPU.HalfWidthPixels = false;
IPPU.DoubleHeightPixels = false;
@@ -1978,7 +1905,7 @@ static void CommonPPUReset()
S9xNextController();
for (c = 0; c < 2; c++)
- memset(&IPPU.Clip [c], 0, sizeof(struct ClipData));
+ memset(&IPPU.Clip [c], 0, sizeof(ClipData));
if (Settings.MouseMaster)
{
@@ -2050,9 +1977,7 @@ void S9xProcessMouse(int32_t which1)
{
int32_t delta_x, delta_y;
#define MOUSE_SIGNATURE 0x1
- IPPU.Mouse [which1] = MOUSE_SIGNATURE |
- (PPU.MouseSpeed [which1] << 4) |
- ((buttons & 1) << 6) | ((buttons & 2) << 6);
+ IPPU.Mouse [which1] = MOUSE_SIGNATURE | ((buttons & 1) << 6) | ((buttons & 2) << 6);
delta_x = x - IPPU.PrevMouseX[which1];
delta_y = y - IPPU.PrevMouseY[which1];
@@ -2131,7 +2056,6 @@ void ProcessSuperScope()
PPU.VBeamPosLatched = (uint16_t)(y + 1);
PPU.HBeamPosLatched = (uint16_t) x;
- PPU.HVBeamCounterLatched = true;
Memory.FillRAM [0x213F] |= 0x40 | Model->_5C78;
}
IPPU.Joypads [1] = scope;
@@ -2215,8 +2139,6 @@ void S9xUpdateJustifiers()
if (last_p1)
{
-
- PPU.HVBeamCounterLatched = false;
Memory.FillRAM [0x213F] = Model->_5C78;
//process latch as Justifier 2
@@ -2226,10 +2148,8 @@ void S9xUpdateJustifiers()
{
if (!offscreen)
{
-
PPU.VBeamPosLatched = (uint16_t)(y + 1);
PPU.HBeamPosLatched = (uint16_t) x;
- PPU.HVBeamCounterLatched = true;
Memory.FillRAM [0x213F] |= 0x40 | Model->_5C78;
}
}
@@ -2237,8 +2157,6 @@ void S9xUpdateJustifiers()
}
else
{
-
- PPU.HVBeamCounterLatched = false;
Memory.FillRAM [0x213F] = Model->_5C78;
//emulate player 1.
@@ -2248,7 +2166,6 @@ void S9xUpdateJustifiers()
{
PPU.VBeamPosLatched = (uint16_t)(y + 1);
PPU.HBeamPosLatched = (uint16_t) x;
- PPU.HVBeamCounterLatched = true;
Memory.FillRAM [0x213F] |= 0x40 | Model->_5C78;
}
}
@@ -2257,27 +2174,18 @@ void S9xUpdateJustifiers()
//needs restructure
if (!offscreen)
{
-
if ((!last_p1 && IPPU.Controller == SNES_JUSTIFIER) || (last_p1
&& IPPU.Controller == SNES_JUSTIFIER_2))
{
PPU.VBeamPosLatched = (uint16_t)(y + 1);
PPU.HBeamPosLatched = (uint16_t) x;
- PPU.HVBeamCounterLatched = true;
Memory.FillRAM [0x213F] |= 0x40 | Model->_5C78;
}
else
- {
- PPU.HVBeamCounterLatched = false;
Memory.FillRAM [0x213F] = Model->_5C78;
-
- }
}
else
- {
- PPU.HVBeamCounterLatched = false;
Memory.FillRAM [0x213F] = Model->_5C78;
- }
}
}
@@ -2289,11 +2197,9 @@ void S9xUpdateJoypads()
{
IPPU.Joypads [i] = S9xReadJoypad(i);
- if ((IPPU.Joypads [i] & (SNES_LEFT_MASK | SNES_RIGHT_MASK)) ==
- (SNES_LEFT_MASK | SNES_RIGHT_MASK))
+ if (IPPU.Joypads [i] & SNES_LEFT_MASK)
IPPU.Joypads [i] &= ~SNES_RIGHT_MASK;
- if ((IPPU.Joypads [i] & (SNES_UP_MASK | SNES_DOWN_MASK)) ==
- (SNES_UP_MASK | SNES_DOWN_MASK))
+ if (IPPU.Joypads [i] & SNES_UP_MASK)
IPPU.Joypads [i] &= ~SNES_DOWN_MASK;
}
@@ -2357,7 +2263,6 @@ void S9xUpdateJoypads()
}
}
-
void S9xSuperFXExec()
{
if (Settings.SuperFX)
@@ -2374,252 +2279,3 @@ void S9xSuperFXExec()
}
}
}
-
-// Register reads and writes...
-
-uint8_t REGISTER_4212()
-{
- uint8_t GetBank = 0;
- if (CPU.V_Counter >= PPU.ScreenHeight + FIRST_VISIBLE_LINE &&
- CPU.V_Counter < PPU.ScreenHeight + FIRST_VISIBLE_LINE + 3)
- GetBank = 1;
-
- GetBank |= CPU.Cycles >= Settings.HBlankStart ? 0x40 : 0;
- if (CPU.V_Counter >= PPU.ScreenHeight + FIRST_VISIBLE_LINE)
- GetBank |= 0x80; /* XXX: 0x80 or 0xc0 ? */
-
- return (GetBank);
-}
-
-void FLUSH_REDRAW()
-{
- if (IPPU.PreviousLine != IPPU.CurrentLine)
- S9xUpdateScreen();
-}
-
-void REGISTER_2104(uint8_t byte)
-{
- if (PPU.OAMAddr & 0x100)
- {
- int32_t addr = ((PPU.OAMAddr & 0x10f) << 1) + (PPU.OAMFlip & 1);
- if (byte != PPU.OAMData [addr])
- {
- FLUSH_REDRAW();
- PPU.OAMData [addr] = byte;
- IPPU.OBJChanged = true;
-
- // X position high bit, and sprite size (x4)
- struct SOBJ* pObj = &PPU.OBJ [(addr & 0x1f) * 4];
-
- pObj->HPos = (pObj->HPos & 0xFF) | SignExtend[(byte >> 0) & 1];
- pObj++->Size = byte & 2;
- pObj->HPos = (pObj->HPos & 0xFF) | SignExtend[(byte >> 2) & 1];
- pObj++->Size = byte & 8;
- pObj->HPos = (pObj->HPos & 0xFF) | SignExtend[(byte >> 4) & 1];
- pObj++->Size = byte & 32;
- pObj->HPos = (pObj->HPos & 0xFF) | SignExtend[(byte >> 6) & 1];
- pObj->Size = byte & 128;
- }
- PPU.OAMFlip ^= 1;
- if (!(PPU.OAMFlip & 1))
- {
- ++PPU.OAMAddr;
- PPU.OAMAddr &= 0x1ff;
- if (PPU.OAMPriorityRotation && PPU.FirstSprite != (PPU.OAMAddr >> 1))
- {
- PPU.FirstSprite = (PPU.OAMAddr & 0xFE) >> 1;
- IPPU.OBJChanged = true;
- }
- }
- else if (PPU.OAMPriorityRotation && (PPU.OAMAddr & 1))
- IPPU.OBJChanged = true;
- }
- else if (!(PPU.OAMFlip & 1))
- {
- PPU.OAMWriteRegister &= 0xff00;
- PPU.OAMWriteRegister |= byte;
- PPU.OAMFlip |= 1;
- if (PPU.OAMPriorityRotation && (PPU.OAMAddr & 1))
- IPPU.OBJChanged = true;
- }
- else
- {
- PPU.OAMWriteRegister &= 0x00ff;
- uint8_t lowbyte = (uint8_t)(PPU.OAMWriteRegister);
- uint8_t highbyte = byte;
- PPU.OAMWriteRegister |= byte << 8;
-
- int32_t addr = (PPU.OAMAddr << 1);
-
- if (lowbyte != PPU.OAMData [addr] ||
- highbyte != PPU.OAMData [addr + 1])
- {
- FLUSH_REDRAW();
- PPU.OAMData [addr] = lowbyte;
- PPU.OAMData [addr + 1] = highbyte;
- IPPU.OBJChanged = true;
- if (addr & 2)
- {
- // Tile
- PPU.OBJ[addr = PPU.OAMAddr >> 1].Name = PPU.OAMWriteRegister & 0x1ff;
-
- // priority, h and v flip.
- PPU.OBJ[addr].Palette = (highbyte >> 1) & 7;
- PPU.OBJ[addr].Priority = (highbyte >> 4) & 3;
- PPU.OBJ[addr].HFlip = (highbyte >> 6) & 1;
- PPU.OBJ[addr].VFlip = (highbyte >> 7) & 1;
- }
- else
- {
- // X position (low)
- PPU.OBJ[addr = PPU.OAMAddr >> 1].HPos &= 0xFF00;
- PPU.OBJ[addr].HPos |= lowbyte;
-
- // Sprite Y position
- PPU.OBJ[addr].VPos = highbyte;
- }
- }
- PPU.OAMFlip &= ~1;
- ++PPU.OAMAddr;
- if (PPU.OAMPriorityRotation && PPU.FirstSprite != (PPU.OAMAddr >> 1))
- {
- PPU.FirstSprite = (PPU.OAMAddr & 0xFE) >> 1;
- IPPU.OBJChanged = true;
- }
- }
-
- Memory.FillRAM [0x2104] = byte;
-}
-
-void REGISTER_2118(uint8_t Byte)
-{
- uint32_t address;
- if (PPU.VMA.FullGraphicCount)
- {
- uint32_t rem = PPU.VMA.Address & PPU.VMA.Mask1;
- address = (((PPU.VMA.Address & ~PPU.VMA.Mask1) +
- (rem >> PPU.VMA.Shift) +
- ((rem & (PPU.VMA.FullGraphicCount - 1)) << 3)) << 1) & 0xffff;
- Memory.VRAM [address] = Byte;
- }
- else
- Memory.VRAM[address = (PPU.VMA.Address << 1) & 0xFFFF] = Byte;
- IPPU.TileCached [TILE_2BIT][address >> 4] = false;
- IPPU.TileCached [TILE_4BIT][address >> 5] = false;
- IPPU.TileCached [TILE_8BIT][address >> 6] = false;
- if (!PPU.VMA.High)
- PPU.VMA.Address += PPU.VMA.Increment;
-}
-
-void REGISTER_2118_tile(uint8_t Byte)
-{
- uint32_t address;
- uint32_t rem = PPU.VMA.Address & PPU.VMA.Mask1;
- address = (((PPU.VMA.Address & ~PPU.VMA.Mask1) +
- (rem >> PPU.VMA.Shift) +
- ((rem & (PPU.VMA.FullGraphicCount - 1)) << 3)) << 1) & 0xffff;
- Memory.VRAM [address] = Byte;
- IPPU.TileCached [TILE_2BIT][address >> 4] = false;
- IPPU.TileCached [TILE_4BIT][address >> 5] = false;
- IPPU.TileCached [TILE_8BIT][address >> 6] = false;
- if (!PPU.VMA.High)
- PPU.VMA.Address += PPU.VMA.Increment;
-}
-
-void REGISTER_2118_linear(uint8_t Byte)
-{
- uint32_t address;
- Memory.VRAM[address = (PPU.VMA.Address << 1) & 0xFFFF] = Byte;
- IPPU.TileCached [TILE_2BIT][address >> 4] = false;
- IPPU.TileCached [TILE_4BIT][address >> 5] = false;
- IPPU.TileCached [TILE_8BIT][address >> 6] = false;
- if (!PPU.VMA.High)
- PPU.VMA.Address += PPU.VMA.Increment;
-}
-
-void REGISTER_2119(uint8_t Byte)
-{
- uint32_t address;
- if (PPU.VMA.FullGraphicCount)
- {
- uint32_t rem = PPU.VMA.Address & PPU.VMA.Mask1;
- address = ((((PPU.VMA.Address & ~PPU.VMA.Mask1) +
- (rem >> PPU.VMA.Shift) +
- ((rem & (PPU.VMA.FullGraphicCount - 1)) << 3)) << 1) + 1) & 0xFFFF;
- Memory.VRAM [address] = Byte;
- }
- else
- Memory.VRAM[address = ((PPU.VMA.Address << 1) + 1) & 0xFFFF] = Byte;
- IPPU.TileCached [TILE_2BIT][address >> 4] = false;
- IPPU.TileCached [TILE_4BIT][address >> 5] = false;
- IPPU.TileCached [TILE_8BIT][address >> 6] = false;
- if (PPU.VMA.High)
- PPU.VMA.Address += PPU.VMA.Increment;
-}
-
-void REGISTER_2119_tile(uint8_t Byte)
-{
- uint32_t rem = PPU.VMA.Address & PPU.VMA.Mask1;
- uint32_t address = ((((PPU.VMA.Address & ~PPU.VMA.Mask1) +
- (rem >> PPU.VMA.Shift) +
- ((rem & (PPU.VMA.FullGraphicCount - 1)) << 3)) << 1) + 1) & 0xFFFF;
- Memory.VRAM [address] = Byte;
- IPPU.TileCached [TILE_2BIT][address >> 4] = false;
- IPPU.TileCached [TILE_4BIT][address >> 5] = false;
- IPPU.TileCached [TILE_8BIT][address >> 6] = false;
- if (PPU.VMA.High)
- PPU.VMA.Address += PPU.VMA.Increment;
-}
-
-void REGISTER_2119_linear(uint8_t Byte)
-{
- uint32_t address;
- Memory.VRAM[address = ((PPU.VMA.Address << 1) + 1) & 0xFFFF] = Byte;
- IPPU.TileCached [TILE_2BIT][address >> 4] = false;
- IPPU.TileCached [TILE_4BIT][address >> 5] = false;
- IPPU.TileCached [TILE_8BIT][address >> 6] = false;
- if (PPU.VMA.High)
- PPU.VMA.Address += PPU.VMA.Increment;
-}
-
-void REGISTER_2122(uint8_t Byte)
-{
- // CG-RAM (palette) write
-
- if (PPU.CGFLIP)
- {
- if ((Byte & 0x7f) != (PPU.CGDATA[PPU.CGADD] >> 8))
- {
- FLUSH_REDRAW();
- PPU.CGDATA[PPU.CGADD] &= 0x00FF;
- PPU.CGDATA[PPU.CGADD] |= (Byte & 0x7f) << 8;
- IPPU.ColorsChanged = true;
- IPPU.Blue [PPU.CGADD] = IPPU.XB [(Byte >> 2) & 0x1f];
- IPPU.Green [PPU.CGADD] = IPPU.XB [(PPU.CGDATA[PPU.CGADD] >> 5) & 0x1f];
- IPPU.ScreenColors [PPU.CGADD] = (uint16_t) BUILD_PIXEL(IPPU.Red [PPU.CGADD],
- IPPU.Green [PPU.CGADD],
- IPPU.Blue [PPU.CGADD]);
- }
- PPU.CGADD++;
- }
- else if (Byte != (uint8_t)(PPU.CGDATA[PPU.CGADD] & 0xff))
- {
- FLUSH_REDRAW();
- PPU.CGDATA[PPU.CGADD] &= 0x7F00;
- PPU.CGDATA[PPU.CGADD] |= Byte;
- IPPU.ColorsChanged = true;
- IPPU.Red [PPU.CGADD] = IPPU.XB [Byte & 0x1f];
- IPPU.Green [PPU.CGADD] = IPPU.XB [(PPU.CGDATA[PPU.CGADD] >> 5) & 0x1f];
- IPPU.ScreenColors [PPU.CGADD] = (uint16_t) BUILD_PIXEL(IPPU.Red [PPU.CGADD],
- IPPU.Green [PPU.CGADD],
- IPPU.Blue [PPU.CGADD]);
- }
- PPU.CGFLIP = !PPU.CGFLIP;
-}
-
-void REGISTER_2180(uint8_t Byte)
-{
- Memory.RAM[PPU.WRAM++] = Byte;
- PPU.WRAM &= 0x1FFFF;
- Memory.FillRAM [0x2180] = Byte;
-}
diff --git a/source/ppu.h b/source/ppu.h
index 5101f02..d700497 100644
--- a/source/ppu.h
+++ b/source/ppu.h
@@ -5,7 +5,7 @@
#define FIRST_VISIBLE_LINE 1
-extern uint8_t GetBank;
+extern uint8_t GetBank;
extern uint16_t SignExtend [2];
#define TILE_2BIT 0
@@ -22,55 +22,47 @@ extern uint16_t SignExtend [2];
#define SA1_DMA_IRQ_SOURCE (1 << 5)
#define SA1_IRQ_SOURCE (1 << 7)
-struct ClipData
+typedef struct
{
- uint32_t Count [6];
- uint32_t Left [6][6];
- uint32_t Right [6][6];
-};
+ uint32_t Count [6];
+ uint32_t Left [6][6];
+ uint32_t Right [6][6];
+} ClipData;
typedef struct
{
- bool ColorsChanged;
- uint8_t HDMA;
- bool HDMAStarted;
- uint8_t MaxBrightness;
- bool LatchedBlanking;
- bool OBJChanged;
- bool RenderThisFrame;
- bool DirectColourMapsNeedRebuild;
- uint32_t FrameCount;
- uint32_t RenderedFramesCount;
- uint32_t DisplayedRenderedFrameCount;
- uint32_t SkippedFrames;
- uint32_t FrameSkip;
- uint8_t* TileCache [3];
- uint8_t* TileCached [3];
- bool FirstVRAMRead;
- bool DoubleHeightPixels;
- bool Interlace;
- bool InterlaceSprites;
- bool DoubleWidthPixels;
- bool HalfWidthPixels;
- int32_t RenderedScreenHeight;
- int32_t RenderedScreenWidth;
- uint32_t Red [256];
- uint32_t Green [256];
- uint32_t Blue [256];
- uint8_t* XB;
- uint16_t ScreenColors [256];
- int32_t PreviousLine;
- int32_t CurrentLine;
- int32_t Controller;
- uint32_t Joypads[5];
- uint32_t SuperScope;
- uint32_t Mouse[2];
- int32_t PrevMouseX[2];
- int32_t PrevMouseY[2];
- struct ClipData Clip [2];
+ bool ColorsChanged;
+ uint8_t HDMA;
+ bool OBJChanged;
+ bool RenderThisFrame;
+ bool DirectColourMapsNeedRebuild;
+ uint32_t FrameCount;
+ uint8_t* TileCache [3];
+ uint8_t* TileCached [3];
+ bool FirstVRAMRead;
+ bool DoubleHeightPixels;
+ bool Interlace;
+ bool DoubleWidthPixels;
+ bool HalfWidthPixels;
+ int32_t RenderedScreenHeight;
+ int32_t RenderedScreenWidth;
+ uint32_t Red [256];
+ uint32_t Green [256];
+ uint32_t Blue [256];
+ uint8_t* XB;
+ uint16_t ScreenColors [256];
+ int32_t PreviousLine;
+ int32_t CurrentLine;
+ int32_t Controller;
+ uint32_t Joypads [5];
+ uint32_t SuperScope;
+ uint32_t Mouse [2];
+ int32_t PrevMouseX[2];
+ int32_t PrevMouseY[2];
+ ClipData Clip [2];
} InternalPPU;
-struct SOBJ
+typedef struct
{
int16_t HPos;
uint16_t VPos;
@@ -80,7 +72,7 @@ struct SOBJ
uint8_t Priority;
uint8_t Palette;
uint8_t Size;
-};
+} SOBJ;
typedef struct
{
@@ -108,35 +100,31 @@ typedef struct
uint16_t SCSize;
} BG [4];
- bool CGFLIP;
- uint16_t CGDATA [256];
- uint8_t FirstSprite;
- uint8_t LastSprite;
- struct SOBJ OBJ [128];
- uint8_t OAMPriorityRotation;
- uint16_t OAMAddr;
- uint8_t RangeTimeOver;
-
+ bool CGFLIP;
+ uint16_t CGDATA [256];
+ uint8_t FirstSprite;
+ uint8_t UNUSED1;
+ SOBJ OBJ [128];
+ uint8_t OAMPriorityRotation;
+ uint16_t OAMAddr;
+ uint8_t RangeTimeOver;
uint8_t OAMFlip;
- uint16_t OAMTileAddress;
+ uint16_t UNUSED2;
uint16_t IRQVBeamPos;
uint16_t IRQHBeamPos;
uint16_t VBeamPosLatched;
uint16_t HBeamPosLatched;
-
- uint8_t HBeamFlip;
- uint8_t VBeamFlip;
- uint8_t HVBeamCounterLatched;
-
- int16_t MatrixA;
- int16_t MatrixB;
- int16_t MatrixC;
- int16_t MatrixD;
- int16_t CentreX;
- int16_t CentreY;
- uint8_t Joypad1ButtonReadPos;
- uint8_t Joypad2ButtonReadPos;
-
+ uint8_t HBeamFlip;
+ uint8_t VBeamFlip;
+ uint8_t UNUSED3;
+ int16_t MatrixA;
+ int16_t MatrixB;
+ int16_t MatrixC;
+ int16_t MatrixD;
+ int16_t CentreX;
+ int16_t CentreY;
+ uint8_t Joypad1ButtonReadPos;
+ uint8_t Joypad2ButtonReadPos;
uint8_t CGADD;
uint8_t FixedColourRed;
uint8_t FixedColourGreen;
@@ -144,20 +132,20 @@ typedef struct
uint16_t SavedOAMAddr;
uint16_t ScreenHeight;
uint32_t WRAM;
- uint8_t BG_Forced;
+ uint8_t UNUSED4;
bool ForcedBlanking;
- bool OBJThroughMain;
- bool OBJThroughSub;
+ bool UNUSED5;
+ bool UNUSED6;
uint8_t OBJSizeSelect;
uint16_t OBJNameBase;
- bool OBJAddition;
- uint8_t OAMReadFlip;
- uint8_t OAMData [512 + 32];
+ bool UNUSED7;
+ uint8_t UNUSED8;
+ uint8_t OAMData [512 + 32];
bool VTimerEnabled;
bool HTimerEnabled;
int16_t HTimerPosition;
uint8_t Mosaic;
- bool BGMosaic [4];
+ bool BGMosaic [4];
bool Mode7HFlip;
bool Mode7VFlip;
uint8_t Mode7Repeat;
@@ -165,20 +153,18 @@ typedef struct
uint8_t Window1Right;
uint8_t Window2Left;
uint8_t Window2Right;
- uint8_t ClipCounts [6];
+ uint8_t UNUSED9 [6];
uint8_t ClipWindowOverlapLogic [6];
- uint8_t ClipWindow1Enable [6];
- uint8_t ClipWindow2Enable [6];
- bool ClipWindow1Inside [6];
- bool ClipWindow2Inside [6];
+ uint8_t ClipWindow1Enable [6];
+ uint8_t ClipWindow2Enable [6];
+ bool ClipWindow1Inside [6];
+ bool ClipWindow2Inside [6];
bool RecomputeClipWindows;
bool CGFLIPRead;
uint16_t OBJNameSelect;
- bool Need16x8Mulitply;
+ bool Need16x8Multiply;
uint8_t Joypad3ButtonReadPos;
- uint8_t MouseSpeed[2];
-
- // XXX Do these need to be added to snapshot.cpp?
+ uint8_t UNUSED10 [2];
uint16_t OAMWriteRegister;
uint8_t BGnxOFSbyte;
uint8_t OpenBus1;
@@ -192,11 +178,10 @@ typedef struct
typedef struct
{
- bool TransferDirection;
- bool AAddressFixed;
- bool AAddressDecrement;
- uint8_t TransferMode;
-
+ bool TransferDirection;
+ bool AAddressFixed;
+ bool AAddressDecrement;
+ uint8_t TransferMode;
uint8_t ABank;
uint16_t AAddress;
uint16_t Address;
@@ -209,9 +194,9 @@ typedef struct
bool HDMAIndirectAddressing;
uint16_t IndirectAddress;
uint8_t IndirectBank;
- uint8_t Repeat;
+ bool Repeat;
uint8_t LineCount;
- uint8_t FirstLine;
+ bool FirstLine;
} SDMA;
void S9xUpdateScreen();
@@ -251,23 +236,254 @@ extern SnesModel M1SNES;
extern SnesModel M2SNES;
#define MAX_5C77_VERSION 0x01
-#define MAX_5C78_VERSION 0x03
#define MAX_5A22_VERSION 0x02
-
-extern uint8_t REGISTER_4212();
-extern void FLUSH_REDRAW();
-extern void REGISTER_2104(uint8_t byte);
-extern void REGISTER_2118(uint8_t Byte);
-extern void REGISTER_2118_tile(uint8_t Byte);
-extern void REGISTER_2118_linear(uint8_t Byte);
-extern void REGISTER_2119(uint8_t Byte);
-extern void REGISTER_2119_tile(uint8_t Byte);
-extern void REGISTER_2119_linear(uint8_t Byte);
-extern void REGISTER_2122(uint8_t Byte);
-extern void REGISTER_2180(uint8_t Byte);
+#define MAX_5C78_VERSION 0x03
//Platform specific input functions used by PPU.CPP
void JustifierButtons(uint32_t*);
bool JustifierOffscreen();
+static inline void FLUSH_REDRAW()
+{
+ if (IPPU.PreviousLine != IPPU.CurrentLine)
+ S9xUpdateScreen();
+}
+
+static inline void REGISTER_2104(uint8_t byte)
+{
+ if (PPU.OAMAddr & 0x100)
+ {
+ int32_t addr = ((PPU.OAMAddr & 0x10f) << 1) + (PPU.OAMFlip & 1);
+ if (byte != PPU.OAMData [addr])
+ {
+ FLUSH_REDRAW();
+ PPU.OAMData [addr] = byte;
+ IPPU.OBJChanged = true;
+
+ // X position high bit, and sprite size (x4)
+ SOBJ* pObj = &PPU.OBJ [(addr & 0x1f) * 4];
+
+ pObj->HPos = (pObj->HPos & 0xFF) | SignExtend[(byte >> 0) & 1];
+ pObj++->Size = byte & 2;
+ pObj->HPos = (pObj->HPos & 0xFF) | SignExtend[(byte >> 2) & 1];
+ pObj++->Size = byte & 8;
+ pObj->HPos = (pObj->HPos & 0xFF) | SignExtend[(byte >> 4) & 1];
+ pObj++->Size = byte & 32;
+ pObj->HPos = (pObj->HPos & 0xFF) | SignExtend[(byte >> 6) & 1];
+ pObj->Size = byte & 128;
+ }
+ PPU.OAMFlip ^= 1;
+ if (!(PPU.OAMFlip & 1))
+ {
+ ++PPU.OAMAddr;
+ PPU.OAMAddr &= 0x1ff;
+ if (PPU.OAMPriorityRotation && PPU.FirstSprite != (PPU.OAMAddr >> 1))
+ {
+ PPU.FirstSprite = (PPU.OAMAddr & 0xFE) >> 1;
+ IPPU.OBJChanged = true;
+ }
+ }
+ else if (PPU.OAMPriorityRotation && (PPU.OAMAddr & 1))
+ IPPU.OBJChanged = true;
+ }
+ else if (!(PPU.OAMFlip & 1))
+ {
+ PPU.OAMWriteRegister &= 0xff00;
+ PPU.OAMWriteRegister |= byte;
+ PPU.OAMFlip |= 1;
+ if (PPU.OAMPriorityRotation && (PPU.OAMAddr & 1))
+ IPPU.OBJChanged = true;
+ }
+ else
+ {
+ PPU.OAMWriteRegister &= 0x00ff;
+ uint8_t lowbyte = (uint8_t)(PPU.OAMWriteRegister);
+ uint8_t highbyte = byte;
+ PPU.OAMWriteRegister |= byte << 8;
+
+ int32_t addr = (PPU.OAMAddr << 1);
+
+ if (lowbyte != PPU.OAMData [addr] ||
+ highbyte != PPU.OAMData [addr + 1])
+ {
+ FLUSH_REDRAW();
+ PPU.OAMData [addr] = lowbyte;
+ PPU.OAMData [addr + 1] = highbyte;
+ IPPU.OBJChanged = true;
+ if (addr & 2)
+ {
+ // Tile
+ PPU.OBJ[addr = PPU.OAMAddr >> 1].Name = PPU.OAMWriteRegister & 0x1ff;
+
+ // priority, h and v flip.
+ PPU.OBJ[addr].Palette = (highbyte >> 1) & 7;
+ PPU.OBJ[addr].Priority = (highbyte >> 4) & 3;
+ PPU.OBJ[addr].HFlip = (highbyte >> 6) & 1;
+ PPU.OBJ[addr].VFlip = (highbyte >> 7) & 1;
+ }
+ else
+ {
+ // X position (low)
+ PPU.OBJ[addr = PPU.OAMAddr >> 1].HPos &= 0xFF00;
+ PPU.OBJ[addr].HPos |= lowbyte;
+
+ // Sprite Y position
+ PPU.OBJ[addr].VPos = highbyte;
+ }
+ }
+ PPU.OAMFlip &= ~1;
+ ++PPU.OAMAddr;
+ if (PPU.OAMPriorityRotation && PPU.FirstSprite != (PPU.OAMAddr >> 1))
+ {
+ PPU.FirstSprite = (PPU.OAMAddr & 0xFE) >> 1;
+ IPPU.OBJChanged = true;
+ }
+ }
+
+ Memory.FillRAM [0x2104] = byte;
+}
+
+static inline void REGISTER_2118(uint8_t Byte)
+{
+ uint32_t address;
+ if (PPU.VMA.FullGraphicCount)
+ {
+ uint32_t rem = PPU.VMA.Address & PPU.VMA.Mask1;
+ address = (((PPU.VMA.Address & ~PPU.VMA.Mask1) +
+ (rem >> PPU.VMA.Shift) +
+ ((rem & (PPU.VMA.FullGraphicCount - 1)) << 3)) << 1) & 0xffff;
+ Memory.VRAM [address] = Byte;
+ }
+ else
+ Memory.VRAM[address = (PPU.VMA.Address << 1) & 0xFFFF] = Byte;
+ IPPU.TileCached [TILE_2BIT][address >> 4] = false;
+ IPPU.TileCached [TILE_4BIT][address >> 5] = false;
+ IPPU.TileCached [TILE_8BIT][address >> 6] = false;
+ if (!PPU.VMA.High)
+ PPU.VMA.Address += PPU.VMA.Increment;
+}
+
+static inline void REGISTER_2118_tile(uint8_t Byte)
+{
+ uint32_t address;
+ uint32_t rem = PPU.VMA.Address & PPU.VMA.Mask1;
+ address = (((PPU.VMA.Address & ~PPU.VMA.Mask1) +
+ (rem >> PPU.VMA.Shift) +
+ ((rem & (PPU.VMA.FullGraphicCount - 1)) << 3)) << 1) & 0xffff;
+ Memory.VRAM [address] = Byte;
+ IPPU.TileCached [TILE_2BIT][address >> 4] = false;
+ IPPU.TileCached [TILE_4BIT][address >> 5] = false;
+ IPPU.TileCached [TILE_8BIT][address >> 6] = false;
+ if (!PPU.VMA.High)
+ PPU.VMA.Address += PPU.VMA.Increment;
+}
+
+static inline void REGISTER_2118_linear(uint8_t Byte)
+{
+ uint32_t address;
+ Memory.VRAM[address = (PPU.VMA.Address << 1) & 0xFFFF] = Byte;
+ IPPU.TileCached [TILE_2BIT][address >> 4] = false;
+ IPPU.TileCached [TILE_4BIT][address >> 5] = false;
+ IPPU.TileCached [TILE_8BIT][address >> 6] = false;
+ if (!PPU.VMA.High)
+ PPU.VMA.Address += PPU.VMA.Increment;
+}
+
+static inline void REGISTER_2119(uint8_t Byte)
+{
+ uint32_t address;
+ if (PPU.VMA.FullGraphicCount)
+ {
+ uint32_t rem = PPU.VMA.Address & PPU.VMA.Mask1;
+ address = ((((PPU.VMA.Address & ~PPU.VMA.Mask1) +
+ (rem >> PPU.VMA.Shift) +
+ ((rem & (PPU.VMA.FullGraphicCount - 1)) << 3)) << 1) + 1) & 0xFFFF;
+ Memory.VRAM [address] = Byte;
+ }
+ else
+ Memory.VRAM[address = ((PPU.VMA.Address << 1) + 1) & 0xFFFF] = Byte;
+ IPPU.TileCached [TILE_2BIT][address >> 4] = false;
+ IPPU.TileCached [TILE_4BIT][address >> 5] = false;
+ IPPU.TileCached [TILE_8BIT][address >> 6] = false;
+ if (PPU.VMA.High)
+ PPU.VMA.Address += PPU.VMA.Increment;
+}
+
+static inline void REGISTER_2119_tile(uint8_t Byte)
+{
+ uint32_t rem = PPU.VMA.Address & PPU.VMA.Mask1;
+ uint32_t address = ((((PPU.VMA.Address & ~PPU.VMA.Mask1) +
+ (rem >> PPU.VMA.Shift) +
+ ((rem & (PPU.VMA.FullGraphicCount - 1)) << 3)) << 1) + 1) & 0xFFFF;
+ Memory.VRAM [address] = Byte;
+ IPPU.TileCached [TILE_2BIT][address >> 4] = false;
+ IPPU.TileCached [TILE_4BIT][address >> 5] = false;
+ IPPU.TileCached [TILE_8BIT][address >> 6] = false;
+ if (PPU.VMA.High)
+ PPU.VMA.Address += PPU.VMA.Increment;
+}
+
+static inline void REGISTER_2119_linear(uint8_t Byte)
+{
+ uint32_t address;
+ Memory.VRAM[address = ((PPU.VMA.Address << 1) + 1) & 0xFFFF] = Byte;
+ IPPU.TileCached [TILE_2BIT][address >> 4] = false;
+ IPPU.TileCached [TILE_4BIT][address >> 5] = false;
+ IPPU.TileCached [TILE_8BIT][address >> 6] = false;
+ if (PPU.VMA.High)
+ PPU.VMA.Address += PPU.VMA.Increment;
+}
+
+static inline void REGISTER_2122(uint8_t Byte)
+{
+ if (PPU.CGFLIP)
+ {
+ if ((Byte & 0x7f) != (PPU.CGDATA[PPU.CGADD] >> 8))
+ {
+ FLUSH_REDRAW();
+ PPU.CGDATA[PPU.CGADD] &= 0x00FF;
+ PPU.CGDATA[PPU.CGADD] |= (Byte & 0x7f) << 8;
+ IPPU.ColorsChanged = true;
+ IPPU.Blue [PPU.CGADD] = IPPU.XB [(Byte >> 2) & 0x1f];
+ IPPU.Green [PPU.CGADD] = IPPU.XB [(PPU.CGDATA[PPU.CGADD] >> 5) & 0x1f];
+ IPPU.ScreenColors [PPU.CGADD] = (uint16_t) BUILD_PIXEL(IPPU.Red [PPU.CGADD],
+ IPPU.Green [PPU.CGADD],
+ IPPU.Blue [PPU.CGADD]);
+ }
+ PPU.CGADD++;
+ }
+ else if (Byte != (uint8_t)(PPU.CGDATA[PPU.CGADD] & 0xff))
+ {
+ FLUSH_REDRAW();
+ PPU.CGDATA[PPU.CGADD] &= 0x7F00;
+ PPU.CGDATA[PPU.CGADD] |= Byte;
+ IPPU.ColorsChanged = true;
+ IPPU.Red [PPU.CGADD] = IPPU.XB [Byte & 0x1f];
+ IPPU.Green [PPU.CGADD] = IPPU.XB [(PPU.CGDATA[PPU.CGADD] >> 5) & 0x1f];
+ IPPU.ScreenColors [PPU.CGADD] = (uint16_t) BUILD_PIXEL(IPPU.Red [PPU.CGADD], IPPU.Green [PPU.CGADD], IPPU.Blue [PPU.CGADD]);
+ }
+ PPU.CGFLIP = !PPU.CGFLIP;
+}
+
+static inline void REGISTER_2180(uint8_t Byte)
+{
+ Memory.RAM[PPU.WRAM++] = Byte;
+ PPU.WRAM &= 0x1FFFF;
+ Memory.FillRAM [0x2180] = Byte;
+}
+
+static inline uint8_t REGISTER_4212()
+{
+ uint8_t GetBank = 0;
+ if (CPU.V_Counter >= PPU.ScreenHeight + FIRST_VISIBLE_LINE &&
+ CPU.V_Counter < PPU.ScreenHeight + FIRST_VISIBLE_LINE + 3)
+ GetBank = 1;
+
+ GetBank |= CPU.Cycles >= Settings.HBlankStart ? 0x40 : 0;
+ if (CPU.V_Counter >= PPU.ScreenHeight + FIRST_VISIBLE_LINE)
+ GetBank |= 0x80; /* XXX: 0x80 or 0xc0 ? */
+
+ return GetBank;
+}
+
#endif
diff --git a/source/sa1.c b/source/sa1.c
index 54ed836..b19ba11 100644
--- a/source/sa1.c
+++ b/source/sa1.c
@@ -6,8 +6,8 @@
#include "sa1.h"
-static void S9xSA1CharConv2();
-static void S9xSA1DMA();
+static void S9xSA1CharConv2(void);
+static void S9xSA1DMA(void);
static void S9xSA1ReadVariableLengthData(bool inc, bool no_shift);
void S9xSA1Init()
@@ -196,8 +196,6 @@ void S9xSA1SetByte(uint8_t byte, uint32_t address)
*ptr &= ~(15 << ((address & 1) << 2));
*ptr |= (byte & 15) << ((address & 1) << 2);
}
- default:
- return;
}
}
@@ -252,20 +250,25 @@ void S9xSetSA1MemMap(uint32_t which1, uint8_t map)
int32_t i;
int32_t start = which1 * 0x100 + 0xc00;
int32_t start2 = which1 * 0x200;
+ uint8_t* block;
if (which1 >= 2)
start2 += 0x400;
for (c = 0; c < 0x100; c += 16)
{
- uint8_t* block = &Memory.ROM [(map & 7) * 0x100000 + (c << 12)];
+ block = &Memory.ROM [(map & 7) * 0x100000 + (c << 12)];
for (i = c; i < c + 16; i++)
Memory.Map [start + i] = SA1.Map [start + i] = block;
}
for (c = 0; c < 0x200; c += 16)
{
- uint8_t* block = &Memory.ROM [(map & 7) * 0x100000 + (c << 11) - 0x8000];
+ /*Code from Snes9x 1.54.1 - *
+ * This allows Super Mario World VLDC 9 hack to load *
+ * conversion to int is needed here - map is promoted but which1 is not */
+ int32_t offset = (((map & 0x80) ? map : which1) & 7) * 0x100000 + (c << 11) - 0x8000;
+ block = &Memory.ROM [offset];
for (i = c + 8; i < c + 16; i++)
Memory.Map [start2 + i] = SA1.Map [start2 + i] = block;
}
@@ -292,13 +295,13 @@ uint8_t S9xGetSA1(uint32_t address)
case 0x230a:
return ((uint8_t)(SA1.sum >> 32));
case 0x230d:
- {
- uint8_t byte = Memory.FillRAM [0x230d];
+ {
+ uint8_t byte = Memory.FillRAM [0x230d];
- if (Memory.FillRAM [0x2258] & 0x80)
- S9xSA1ReadVariableLengthData(true, false);
- return (byte);
- }
+ if (Memory.FillRAM [0x2258] & 0x80)
+ S9xSA1ReadVariableLengthData(true, false);
+ return (byte);
+ }
}
return (Memory.FillRAM [address]);
@@ -418,9 +421,7 @@ void S9xSetSA1(uint8_t byte, uint32_t address)
case 0x2236:
Memory.FillRAM [address] = byte;
if ((Memory.FillRAM [0x2230] & 0xa4) == 0x80)
- {
S9xSA1DMA(); // Normal DMA to I-RAM
- }
else if ((Memory.FillRAM [0x2230] & 0xb0) == 0xb0)
{
Memory.FillRAM [0x2300] |= 0x20;
@@ -500,7 +501,7 @@ void S9xSetSA1(uint8_t byte, uint32_t address)
S9xSA1ReadVariableLengthData(false, true);
return;
}
-
+
Memory.FillRAM [address] = byte;
}
diff --git a/source/sa1.h b/source/sa1.h
index 6eb9935..7bd02cb 100644
--- a/source/sa1.h
+++ b/source/sa1.h
@@ -43,7 +43,7 @@ typedef struct
uint32_t WaitCounter;
uint8_t* WaitByteAddress1;
uint8_t* WaitByteAddress2;
- uint8_t* Map [MEMMAP_NUM_BLOCKS];
+ uint8_t* Map [MEMMAP_NUM_BLOCKS];
uint8_t* WriteMap [MEMMAP_NUM_BLOCKS];
int16_t op1;
int16_t op2;
@@ -104,8 +104,7 @@ static inline void S9xSA1UnpackStatus()
static inline void S9xSA1PackStatus()
{
SA1.Registers.PL &= ~(Zero | Negative | Carry | Overflow);
- SA1.Registers.PL |= SA1._Carry | ((SA1._Zero == 0) << 1) |
- (SA1._Negative & 0x80) | (SA1._Overflow << 6);
+ SA1.Registers.PL |= SA1._Carry | ((SA1._Zero == 0) << 1) | (SA1._Negative & 0x80) | (SA1._Overflow << 6);
}
static inline void S9xSA1FixCycles()
diff --git a/source/sa1cpu.c b/source/sa1cpu.c
index 272eb52..28f0c59 100644
--- a/source/sa1cpu.c
+++ b/source/sa1cpu.c
@@ -47,7 +47,6 @@
#define StackRelative SA1StackRelative
#define StackRelativeIndirectIndexed SA1StackRelativeIndirectIndexed
-#undef VAR_CYCLES
#define SA1_OPCODES
#include "cpuops.c"
@@ -74,9 +73,7 @@ void S9xSA1MainLoop()
for (i = 0; i < 3 && SA1.Executing; i++)
{
-#ifdef CPU_SHUTDOWN
SA1.PCAtOpcodeStart = SA1.PC;
-#endif
(*SA1.S9xOpcodes [*SA1.PC++].S9xOpcode)();
}
}
diff --git a/source/sar.h b/source/sar.h
index 9d0861e..635477a 100644
--- a/source/sar.h
+++ b/source/sar.h
@@ -8,16 +8,17 @@
#include "port.h"
#ifdef RIGHTSHIFT_IS_SAR
-#define SAR8(b, n) ((b)>>(n))
-#define SAR16(b, n) ((b)>>(n))
-#define SAR32(b, n) ((b)>>(n))
-#define SAR64(b, n) ((b)>>(n))
+#define SAR8(b, n) ((b) >> (n))
+#define SAR16(b, n) ((b) >> (n))
+#define SAR32(b, n) ((b) >> (n))
+#define SAR64(b, n) ((b) >> (n))
#else
static inline int8_t SAR8(const int8_t b, const int32_t n)
{
#ifndef RIGHTSHIFT_INT8_IS_SAR
- if (b < 0) return (b >> n) | (-1 << (8 - n));
+ if (b < 0)
+ return (b >> n) | (~0u << (8 - n));
#endif
return b >> n;
}
@@ -25,7 +26,8 @@ static inline int8_t SAR8(const int8_t b, const int32_t n)
static inline int16_t SAR16(const int16_t b, const int32_t n)
{
#ifndef RIGHTSHIFT_INT16_IS_SAR
- if (b < 0) return (b >> n) | (-1 << (16 - n));
+ if (b < 0)
+ return (b >> n) | (~0u << (16 - n));
#endif
return b >> n;
}
@@ -33,7 +35,8 @@ static inline int16_t SAR16(const int16_t b, const int32_t n)
static inline int32_t SAR32(const int32_t b, const int32_t n)
{
#ifndef RIGHTSHIFT_INT32_IS_SAR
- if (b < 0) return (b >> n) | (-1 << (32 - n));
+ if (b < 0)
+ return (b >> n) | (~0u << (32 - n));
#endif
return b >> n;
}
@@ -41,7 +44,8 @@ static inline int32_t SAR32(const int32_t b, const int32_t n)
static inline int64_t SAR64(const int64_t b, const int32_t n)
{
#ifndef RIGHTSHIFT_INT64_IS_SAR
- if (b < 0) return (b >> n) | (-1 << (64 - n));
+ if (b < 0)
+ return (b >> n) | (~0u << (64 - n));
#endif
return b >> n;
}
diff --git a/source/sdd1emu.c b/source/sdd1emu.c
index 5634960..fc2e809 100644
--- a/source/sdd1emu.c
+++ b/source/sdd1emu.c
@@ -36,52 +36,52 @@ static struct
uint8_t LPS_next;
} evolution_table[] =
{
- /* 0 */ { 0, 25, 25},
- /* 1 */ { 0, 2, 1},
- /* 2 */ { 0, 3, 1},
- /* 3 */ { 0, 4, 2},
- /* 4 */ { 0, 5, 3},
- /* 5 */ { 1, 6, 4},
- /* 6 */ { 1, 7, 5},
- /* 7 */ { 1, 8, 6},
- /* 8 */ { 1, 9, 7},
- /* 9 */ { 2, 10, 8},
- /* 10 */ { 2, 11, 9},
- /* 11 */ { 2, 12, 10},
- /* 12 */ { 2, 13, 11},
- /* 13 */ { 3, 14, 12},
- /* 14 */ { 3, 15, 13},
- /* 15 */ { 3, 16, 14},
- /* 16 */ { 3, 17, 15},
- /* 17 */ { 4, 18, 16},
- /* 18 */ { 4, 19, 17},
- /* 19 */ { 5, 20, 18},
- /* 20 */ { 5, 21, 19},
- /* 21 */ { 6, 22, 20},
- /* 22 */ { 6, 23, 21},
- /* 23 */ { 7, 24, 22},
- /* 24 */ { 7, 24, 23},
- /* 25 */ { 0, 26, 1},
- /* 26 */ { 1, 27, 2},
- /* 27 */ { 2, 28, 4},
- /* 28 */ { 3, 29, 8},
- /* 29 */ { 4, 30, 12},
- /* 30 */ { 5, 31, 16},
- /* 31 */ { 6, 32, 18},
- /* 32 */ { 7, 24, 22}
+ /* 0 */ { 0, 25, 25 },
+ /* 1 */ { 0, 2, 1 },
+ /* 2 */ { 0, 3, 1 },
+ /* 3 */ { 0, 4, 2 },
+ /* 4 */ { 0, 5, 3 },
+ /* 5 */ { 1, 6, 4 },
+ /* 6 */ { 1, 7, 5 },
+ /* 7 */ { 1, 8, 6 },
+ /* 8 */ { 1, 9, 7 },
+ /* 9 */ { 2, 10, 8 },
+ /* 10 */ { 2, 11, 9 },
+ /* 11 */ { 2, 12, 10 },
+ /* 12 */ { 2, 13, 11 },
+ /* 13 */ { 3, 14, 12 },
+ /* 14 */ { 3, 15, 13 },
+ /* 15 */ { 3, 16, 14 },
+ /* 16 */ { 3, 17, 15 },
+ /* 17 */ { 4, 18, 16 },
+ /* 18 */ { 4, 19, 17 },
+ /* 19 */ { 5, 20, 18 },
+ /* 20 */ { 5, 21, 19 },
+ /* 21 */ { 6, 22, 20 },
+ /* 22 */ { 6, 23, 21 },
+ /* 23 */ { 7, 24, 22 },
+ /* 24 */ { 7, 24, 23 },
+ /* 25 */ { 0, 26, 1 },
+ /* 26 */ { 1, 27, 2 },
+ /* 27 */ { 2, 28, 4 },
+ /* 28 */ { 3, 29, 8 },
+ /* 29 */ { 4, 30, 12 },
+ /* 30 */ { 5, 31, 16 },
+ /* 31 */ { 6, 32, 18 },
+ /* 32 */ { 7, 24, 22 }
};
static uint8_t run_table[128] =
{
- 128, 64, 96, 32, 112, 48, 80, 16, 120, 56, 88, 24, 104, 40, 72,
- 8, 124, 60, 92, 28, 108, 44, 76, 12, 116, 52, 84, 20, 100, 36,
- 68, 4, 126, 62, 94, 30, 110, 46, 78, 14, 118, 54, 86, 22, 102,
- 38, 70, 6, 122, 58, 90, 26, 106, 42, 74, 10, 114, 50, 82, 18,
- 98, 34, 66, 2, 127, 63, 95, 31, 111, 47, 79, 15, 119, 55, 87,
- 23, 103, 39, 71, 7, 123, 59, 91, 27, 107, 43, 75, 11, 115, 51,
- 83, 19, 99, 35, 67, 3, 125, 61, 93, 29, 109, 45, 77, 13, 117,
- 53, 85, 21, 101, 37, 69, 5, 121, 57, 89, 25, 105, 41, 73, 9,
- 113, 49, 81, 17, 97, 33, 65, 1
+ 128, 64, 96, 32, 112, 48, 80, 16, 120, 56, 88, 24, 104, 40, 72,
+ 8, 124, 60, 92, 28, 108, 44, 76, 12, 116, 52, 84, 20, 100, 36,
+ 68, 4, 126, 62, 94, 30, 110, 46, 78, 14, 118, 54, 86, 22, 102,
+ 38, 70, 6, 122, 58, 90, 26, 106, 42, 74, 10, 114, 50, 82, 18,
+ 98, 34, 66, 2, 127, 63, 95, 31, 111, 47, 79, 15, 119, 55, 87,
+ 23, 103, 39, 71, 7, 123, 59, 91, 27, 107, 43, 75, 11, 115, 51,
+ 83, 19, 99, 35, 67, 3, 125, 61, 93, 29, 109, 45, 77, 13, 117,
+ 53, 85, 21, 101, 37, 69, 5, 121, 57, 89, 25, 105, 41, 73, 9,
+ 113, 49, 81, 17, 97, 33, 65, 1
};
static inline uint8_t GetCodeword(int32_t bits)
diff --git a/source/seta.h b/source/seta.h
index 9c3e78b..339ba05 100644
--- a/source/seta.h
+++ b/source/seta.h
@@ -23,16 +23,16 @@ void S9xSetST011(uint32_t Address, uint8_t Byte);
extern void (*SetSETA)(uint32_t, uint8_t);
extern uint8_t(*GetSETA)(uint32_t);
-typedef struct SETA_ST010_STRUCT
+typedef struct
{
- uint8_t input_params[16];
+ uint8_t input_params [16];
uint8_t output_params[16];
uint8_t op_reg;
uint8_t execute;
bool control_enable;
} ST010_Regs;
-typedef struct SETA_ST011_STRUCT
+typedef struct
{
bool waiting4command;
uint8_t status;
@@ -42,10 +42,10 @@ typedef struct SETA_ST011_STRUCT
uint32_t out_count;
uint32_t out_index;
uint8_t parameters [512];
- uint8_t output [512];
+ uint8_t output [512];
} ST011_Regs;
-typedef struct SETA_ST018_STRUCT
+typedef struct
{
bool waiting4command;
uint8_t status;
@@ -57,7 +57,7 @@ typedef struct SETA_ST018_STRUCT
uint32_t out_count;
uint32_t out_index;
uint8_t parameters [512];
- uint8_t output [512];
+ uint8_t output [512];
} ST018_Regs;
#endif
diff --git a/source/seta010.c b/source/seta010.c
index 89ae4f8..4e1a293 100644
--- a/source/seta010.c
+++ b/source/seta010.c
@@ -577,10 +577,8 @@ void S9xSetST010(uint32_t Address, uint8_t Byte)
int16_t xpos_max = ST010_WORD(0x00C2);
// current coordinates and direction
- int32_t ypos = Memory.SRAM[0xC4] | (Memory.SRAM[0xC5] << 8) |
- (Memory.SRAM[0xC6] << 16) | (Memory.SRAM[0xC7] << 24);
- int32_t xpos = Memory.SRAM[0xC8] | (Memory.SRAM[0xC9] << 8) |
- (Memory.SRAM[0xCA] << 16) | (Memory.SRAM[0xCB] << 24);
+ int32_t ypos = Memory.SRAM[0xC4] | (Memory.SRAM[0xC5] << 8) | (Memory.SRAM[0xC6] << 16) | (Memory.SRAM[0xC7] << 24);
+ int32_t xpos = Memory.SRAM[0xC8] | (Memory.SRAM[0xC9] << 8) | (Memory.SRAM[0xCA] << 16) | (Memory.SRAM[0xCB] << 24);
uint16_t rot = Memory.SRAM[0xCC] | (Memory.SRAM[0xCD] << 8);
// physics
diff --git a/source/snes9x.h b/source/snes9x.h
index 9ae1c1c..3107494 100644
--- a/source/snes9x.h
+++ b/source/snes9x.h
@@ -14,22 +14,12 @@
#define ROM_NAME_LEN 23
-#define STREAM FILE*
-#define READ_STREAM(p,l,s) fread(p,1,l,s)
-#define WRITE_STREAM(p,l,s) fwrite(p,1,l,s)
-#define OPEN_STREAM(f,m) fopen(f,m)
-#define REOPEN_STREAM(f,m) fdopen(f,m)
-#define FIND_STREAM(f) ftell(f)
-#define REVERT_STREAM(f,o,s) fseek(f,o,s)
-#define CLOSE_STREAM(s) fclose(s)
-
-
/* SNES screen width and height */
#define SNES_WIDTH 256
#define SNES_HEIGHT 224
#define SNES_HEIGHT_EXTENDED 239
-#define IMAGE_WIDTH (Settings.SupportHiRes ? SNES_WIDTH * 2 : SNES_WIDTH)
-#define IMAGE_HEIGHT (Settings.SupportHiRes ? SNES_HEIGHT_EXTENDED * 2 : SNES_HEIGHT_EXTENDED)
+#define IMAGE_WIDTH SNES_WIDTH * 2
+#define IMAGE_HEIGHT SNES_HEIGHT_EXTENDED * 2
#define SNES_MAX_NTSC_VCOUNTER 262
#define SNES_MAX_PAL_VCOUNTER 312
@@ -60,7 +50,6 @@
#define SLOW_ONE_CYCLE 8u
#define TWO_CYCLES 12u
-
#define SNES_TR_MASK (1u << 4)
#define SNES_TL_MASK (1u << 5)
#define SNES_X_MASK (1u << 6)
@@ -118,10 +107,10 @@ typedef struct
long MemSpeed; // For savestate compatibility can't change to int32_t
long MemSpeedx2; // For savestate compatibility can't change to int32_t
long FastROMSpeed; // For savestate compatibility can't change to int32_t
- uint32_t AutoSaveTimer;
+ uint32_t SaveStateVersion;
bool SRAMModified;
uint32_t NMITriggerPoint;
- bool BRKTriggered;
+ bool UNUSED2;
bool TriedInterleavedMode2;
uint32_t NMICycleCount;
uint32_t IRQCycleCount;
@@ -136,27 +125,25 @@ typedef struct
typedef struct
{
/* CPU options */
- bool APUEnabled;
- bool Shutdown;
- uint8_t SoundSkipMethod;
- int32_t H_Max;
- int32_t HBlankStart;
- int32_t CyclesPercentage;
- bool DisableIRQ;
- bool Paused;
- bool ForcedPause;
- bool StopEmulation;
- bool FrameAdvance;
+ bool APUEnabled;
+ bool Shutdown;
+ int32_t H_Max;
+ int32_t HBlankStart;
+ int32_t CyclesPercentage;
+ bool DisableIRQ;
+ bool Paused;
+ bool ForcedPause;
+ bool StopEmulation;
/* Tracing options */
- bool TraceDMA;
- bool TraceHDMA;
- bool TraceVRAM;
- bool TraceUnknownRegisters;
- bool TraceDSP;
+ bool TraceDMA;
+ bool TraceHDMA;
+ bool TraceVRAM;
+ bool TraceUnknownRegisters;
+ bool TraceDSP;
/* Joystick options */
- bool JoystickEnabled;
+ bool JoystickEnabled;
/* ROM timing options (see also H_Max above) */
bool ForcePAL;
@@ -168,15 +155,15 @@ typedef struct
uint32_t SkipFrames;
/* ROM image options */
- bool ForceLoROM;
- bool ForceHiROM;
- bool ForceHeader;
- bool ForceNoHeader;
- bool ForceInterleaved;
- bool ForceInterleaved2;
- bool ForceNotInterleaved;
-
- /* Peripherial options */
+ bool ForceLoROM;
+ bool ForceHiROM;
+ bool ForceHeader;
+ bool ForceNoHeader;
+ bool ForceInterleaved;
+ bool ForceInterleaved2;
+ bool ForceNotInterleaved;
+
+ /* Peripheral options */
bool ForceSuperFX;
bool ForceNoSuperFX;
bool ForceDSP1;
@@ -192,54 +179,53 @@ typedef struct
bool SuperScope;
bool SRTC;
uint32_t ControllerOption;
+ bool ShutdownMaster;
+ bool MultiPlayer5Master;
+ bool SuperScopeMaster;
+ bool MouseMaster;
+
+ bool SuperFX;
+ bool DSP1Master;
+ bool SA1;
+ bool C4;
+ bool SDD1;
+ bool SPC7110;
+ bool SPC7110RTC;
+ bool OBC1;
+ uint8_t DSP;
- bool ShutdownMaster;
- bool MultiPlayer5Master;
- bool SuperScopeMaster;
- bool MouseMaster;
- bool SuperFX;
- bool DSP1Master;
- bool SA1;
- bool C4;
- bool SDD1;
- bool SPC7110;
- bool SPC7110RTC;
- bool OBC1;
- uint8_t DSP;
/* Sound options */
uint32_t SoundPlaybackRate;
#ifdef USE_BLARGG_APU
uint32_t SoundInputRate;
#endif
- bool TraceSoundDSP;
- bool EightBitConsoleSound; // due to caching, this needs S9xSetEightBitConsoleSound()
- int32_t SoundBufferSize;
- int32_t SoundMixInterval;
- bool SoundEnvelopeHeightReading;
- bool DisableSoundEcho;
- bool DisableMasterVolume;
- bool SoundSync;
- bool InterpolatedSound;
- bool ThreadSound;
- bool Mute;
- bool NextAPUEnabled;
+ bool TraceSoundDSP;
+ bool EightBitConsoleSound; // due to caching, this needs S9xSetEightBitConsoleSound()
+ int32_t SoundBufferSize;
+ int32_t SoundMixInterval;
+ bool SoundEnvelopeHeightReading;
+ bool DisableSoundEcho;
+ bool DisableMasterVolume;
+ bool SoundSync;
+ bool InterpolatedSound;
+ bool ThreadSound;
+ bool Mute;
+ bool NextAPUEnabled;
/* Graphics options */
- bool Transparency;
- bool SupportHiRes;
- bool Mode7Interpolate;
+ bool Transparency;
+ bool Mode7Interpolate;
/* SNES graphics options */
- bool BGLayering;
- bool DisableGraphicWindows;
- bool ForceTransparency;
- bool ForceNoTransparency;
- bool DisableHDMA;
- bool DisplayFrameRate;
- bool DisableRangeTimeOver; /* XXX: unused */
+ bool BGLayering;
+ bool DisableGraphicWindows;
+ bool ForceTransparency;
+ bool ForceNoTransparency;
+ bool DisableHDMA;
+ bool DisplayFrameRate;
/* Others */
- bool ApplyCheats;
+ bool ApplyCheats;
/* Fixes for individual games */
bool StarfoxHack;
@@ -273,8 +259,6 @@ extern SCPUState CPU;
extern SSNESGameFixes SNESGameFixes;
extern char String [513];
-void S9xMessage(const char* message);
-
void S9xSetPause(uint32_t mask);
void S9xClearPause(uint32_t mask);
diff --git a/source/soundux.c b/source/soundux.c
index 9a2839e..86db199 100644
--- a/source/soundux.c
+++ b/source/soundux.c
@@ -74,8 +74,6 @@ uint32_t IncreaseERate [32][10];
uint32_t DecreaseERateExp[32][10];
uint32_t KeyOffERate [10];
-static int32_t noise_gen;
-
#define FIXED_POINT 0x10000UL
#define FIXED_POINT_REMAINDER 0xffffUL
#define FIXED_POINT_SHIFT 16
@@ -113,7 +111,7 @@ void S9xAPUSetEndX(int32_t ch)
APU.DSP [APU_ENDX] |= 1 << ch;
}
-void S9xSetEnvRate(Channel* ch, uint32_t rate, int32_t direction, int32_t target, uint32_t mode)
+void S9xSetEnvRate(Channel* ch, uint32_t rate, int32_t direction, int32_t target, uint32_t mode)
{
ch->envx_target = target;
@@ -186,7 +184,6 @@ void S9xSetEchoVolume(int16_t volume_left, int16_t volume_right)
void S9xSetEchoEnable(uint8_t byte)
{
- SoundData.echo_channel_enable = byte;
if (!SoundData.echo_write_enabled || Settings.DisableSoundEcho)
byte = 0;
if (byte && !SoundData.echo_enable)
@@ -214,8 +211,7 @@ void S9xSetEchoFeedback(int32_t feedback)
void S9xSetEchoDelay(int32_t delay)
{
- SoundData.echo_buffer_size = (512 * delay * so.playback_rate) >> 15;
- SoundData.echo_buffer_size <<= 1;
+ SoundData.echo_buffer_size = (delay * so.playback_rate) >> 5;
if (SoundData.echo_buffer_size)
SoundData.echo_ptr %= SoundData.echo_buffer_size;
else
@@ -249,7 +245,6 @@ void S9xSetSoundKeyOff(int32_t channel)
void S9xFixSoundAfterSnapshotLoad()
{
SoundData.echo_write_enabled = !(APU.DSP [APU_FLG] & 0x20);
- SoundData.echo_channel_enable = APU.DSP [APU_EON];
S9xSetEchoDelay(APU.DSP [APU_EDL] & 0xf);
S9xSetEchoFeedback((int8_t) APU.DSP [APU_EFB]);
@@ -306,8 +301,7 @@ void S9xSetSoundADSR(int32_t channel, int32_t attack_ind, int32_t decay_ind, int
S9xSetEnvRate(ch, attack_rate, 1, 127, 0);
break;
case SOUND_DECAY:
- S9xSetEnvRate(ch, decay_rate, -1,
- (MAX_ENVELOPE_HEIGHT * (sustain_level + 1)) >> 3, 1 << 28);
+ S9xSetEnvRate(ch, decay_rate, -1, (MAX_ENVELOPE_HEIGHT * (sustain_level + 1)) >> 3, 1 << 28);
break;
case SOUND_SUSTAIN:
S9xSetEnvRate(ch, sustain_rate, -1, 0, 2 << 28);
@@ -335,14 +329,12 @@ int32_t S9xGetEnvelopeHeight(int32_t channel)
SNESGameFixes.SoundEnvelopeHeightReading2) &&
SoundData.channels[channel].state != SOUND_SILENT &&
SoundData.channels[channel].state != SOUND_GAIN)
- return (SoundData.channels[channel].envx);
+ return SoundData.channels[channel].envx;
- //siren fix from XPP
- if (SNESGameFixes.SoundEnvelopeHeightReading2 &&
- SoundData.channels[channel].state != SOUND_SILENT)
- return (SoundData.channels[channel].envx);
+ if (SNESGameFixes.SoundEnvelopeHeightReading2 && SoundData.channels[channel].state != SOUND_SILENT)
+ return SoundData.channels[channel].envx;
- return (0);
+ return 0;
}
void S9xSetSoundFrequency(int32_t channel, int32_t hertz) // hertz [0~64K<<1]
@@ -710,9 +702,9 @@ static inline void MixStereo(int32_t sample_count)
else
{
// Snes9x 1.53's SPC_DSP.cpp, by blargg
- int32_t feedback = (noise_gen << 13) ^ (noise_gen << 14);
- noise_gen = (feedback & 0x4000) ^ (noise_gen >> 1);
- ch->sample = (noise_gen << 17) >> 17;
+ int32_t feedback = (so.noise_gen << 13) ^ (so.noise_gen << 14);
+ so.noise_gen = (feedback & 0x4000) ^ (so.noise_gen >> 1);
+ ch->sample = (so.noise_gen << 17) >> 17;
ch->interpolate = 0;
}
@@ -740,12 +732,11 @@ static inline void MixStereo(int32_t sample_count)
if (!ch->echo_buf_ptr)
continue;
-
+
ch->echo_buf_ptr [I ] += VL;
ch->echo_buf_ptr [I + 1] += VR;
}
-stereo_exit:
- ;
+stereo_exit:;
}
}
@@ -862,13 +853,12 @@ void S9xResetSound(bool full)
FilterTaps [6] = 0;
FilterTaps [7] = 0;
FilterTapDefinitionBitfield = 0;
- noise_gen = 1;
+ so.noise_gen = 1;
if (full)
{
SoundData.echo_enable = 0;
SoundData.echo_write_enabled = 0;
- SoundData.echo_channel_enable = 0;
SoundData.pitch_mod = 0;
SoundData.master_volume[0] = 0;
SoundData.master_volume[1] = 0;
diff --git a/source/soundux.h b/source/soundux.h
index 72f00df..acf4664 100644
--- a/source/soundux.h
+++ b/source/soundux.h
@@ -5,17 +5,28 @@
#ifndef _SOUND_H_
#define _SOUND_H_
-enum { SOUND_SAMPLE = 0, SOUND_NOISE, SOUND_EXTRA_NOISE, SOUND_MUTE };
-enum { SOUND_SILENT, SOUND_ATTACK, SOUND_DECAY, SOUND_SUSTAIN,
- SOUND_RELEASE, SOUND_GAIN, SOUND_INCREASE_LINEAR,
- SOUND_INCREASE_BENT_LINE, SOUND_DECREASE_LINEAR,
- SOUND_DECREASE_EXPONENTIAL
- };
+enum
+{
+ SOUND_SAMPLE = 0,
+ SOUND_NOISE,
+ SOUND_EXTRA_NOISE,
+ SOUND_MUTE
+};
-enum { MODE_NONE = SOUND_SILENT, MODE_ADSR, MODE_RELEASE = SOUND_RELEASE,
- MODE_GAIN, MODE_INCREASE_LINEAR, MODE_INCREASE_BENT_LINE,
- MODE_DECREASE_LINEAR, MODE_DECREASE_EXPONENTIAL
- };
+enum
+{
+ SOUND_SILENT, SOUND_ATTACK, SOUND_DECAY, SOUND_SUSTAIN,
+ SOUND_RELEASE, SOUND_GAIN, SOUND_INCREASE_LINEAR,
+ SOUND_INCREASE_BENT_LINE, SOUND_DECREASE_LINEAR,
+ SOUND_DECREASE_EXPONENTIAL
+};
+
+enum
+{
+ MODE_NONE = SOUND_SILENT, MODE_ADSR, MODE_RELEASE = SOUND_RELEASE,
+ MODE_GAIN, MODE_INCREASE_LINEAR, MODE_INCREASE_BENT_LINE,
+ MODE_DECREASE_LINEAR, MODE_DECREASE_EXPONENTIAL
+};
#define MAX_ENVELOPE_HEIGHT 127
#define ENVELOPE_SHIFT 7
@@ -32,7 +43,7 @@ enum { MODE_NONE = SOUND_SILENT, MODE_ADSR, MODE_RELEASE = SOUND_RELEASE,
typedef struct
{
int32_t playback_rate;
- int32_t buffer_size;
+ int32_t noise_gen;
uint32_t freqbase; // notaz
bool mute_sound;
} SoundStatus;
@@ -63,7 +74,6 @@ typedef struct
uint32_t sustain_level;
int16_t sample;
int16_t decoded [16];
- int16_t previous16 [2];
int16_t* block;
uint16_t sample_number;
bool last_block;
@@ -76,12 +86,9 @@ typedef struct
int16_t next_sample;
int32_t interpolate;
int32_t previous [2];
- // notaz
uint8_t env_ind_attack;
uint8_t env_ind_decay;
uint8_t env_ind_sustain;
- // Just incase they are needed in the future, for snapshot compatibility.
- uint8_t dummy [29];
} Channel;
typedef struct
@@ -91,13 +98,10 @@ typedef struct
int32_t echo_ptr;
int32_t echo_buffer_size;
int32_t echo_write_enabled;
- int32_t echo_channel_enable;
int32_t pitch_mod;
- // Just incase they are needed in the future, for snapshot compatibility.
- uint32_t dummy [3];
Channel channels [NUM_CHANNELS];
int16_t master_volume [2]; /* range is -128 .. 127 */
- int16_t echo_volume [2]; /* range is -128 .. 127 */
+ int16_t echo_volume [2]; /* range is -128 .. 127 */
int32_t noise_hertz;
} SSoundData;
@@ -131,8 +135,6 @@ void S9xFixEnvelope(int32_t channel, uint8_t gain, uint8_t adsr1, uint8_t adsr2)
void S9xStartSample(int32_t channel);
void S9xMixSamples(int16_t* buffer, int32_t sample_count);
-bool S9xOpenSoundDevice(int32_t, bool, int32_t);
void S9xSetPlaybackRate(uint32_t rate);
#endif
-
#endif
diff --git a/source/spc700.c b/source/spc700.c
index 517f606..53bbb1b 100644
--- a/source/spc700.c
+++ b/source/spc700.c
@@ -8,20 +8,7 @@
#include "display.h"
#include "cpuexec.h"
#include "apu.h"
-
-// SPC700/Sound DSP chips have a 24.57MHz crystal on their PCB.
-
-#ifdef NO_INLINE_SET_GET
-uint8_t S9xAPUGetByteZ(uint8_t address);
-uint8_t S9xAPUGetByte(uint32_t address);
-void S9xAPUSetByteZ(uint8_t, uint8_t address);
-void S9xAPUSetByte(uint8_t, uint32_t address);
-
-#else
-#undef INLINE
-#define INLINE static inline
#include "apumem.h"
-#endif
int8_t Int8 = 0;
int16_t Int16 = 0;
@@ -35,120 +22,115 @@ uint32_t Work32 = 0;
#define OP1 (*(IAPU.PC + 1))
#define OP2 (*(IAPU.PC + 2))
-#ifdef SPC700_SHUTDOWN
#define APUShutdown() \
if (Settings.Shutdown && (IAPU.PC == IAPU.WaitAddress1 || IAPU.PC == IAPU.WaitAddress2)) \
{ \
- if (IAPU.WaitCounter == 0) \
- { \
- if (!ICPU.CPUExecuting) \
- APU.Cycles = CPU.Cycles = CPU.NextEvent; \
+ if (IAPU.WaitCounter == 0) \
+ { \
+ if (!ICPU.CPUExecuting) \
+ APU.Cycles = CPU.Cycles = CPU.NextEvent; \
+ else \
+ IAPU.APUExecuting = false; \
+ } \
+ else if (IAPU.WaitCounter >= 2) \
+ IAPU.WaitCounter = 1; \
else \
- IAPU.APUExecuting = false; \
- } \
- else \
- if (IAPU.WaitCounter >= 2) \
- IAPU.WaitCounter = 1; \
- else \
- IAPU.WaitCounter--; \
+ IAPU.WaitCounter--; \
}
-#else
-#define APUShutdown()
-#endif
-#define APUSetZN8(b)\
+#define APUSetZN8(b) \
IAPU._Zero = (b);
-#define APUSetZN16(w)\
+#define APUSetZN16(w) \
IAPU._Zero = ((w) != 0) | ((w) >> 8);
-#define TCALL(n)\
+#define TCALL(n) \
{\
SPC700_PushW (IAPU.PC - IAPU.RAM + 1); \
IAPU.PC = IAPU.RAM + S9xAPUGetByte(0xffc0 + ((15 - n) << 1)) + \
- (S9xAPUGetByte(0xffc1 + ((15 - n) << 1)) << 8); \
+ (S9xAPUGetByte(0xffc1 + ((15 - n) << 1)) << 8); \
}
-#define SBC(a,b)\
-Int16 = (int16_t) (a) - (int16_t) (b) + (int16_t) (APUCheckCarry ()) - 1;\
-IAPU._Carry = Int16 >= 0;\
-if ((((a) ^ (b)) & 0x80) && (((a) ^ (uint8_t) Int16) & 0x80))\
- APUSetOverflow ();\
-else \
- APUClearOverflow (); \
-APUSetHalfCarry ();\
-if(((a) ^ (b) ^ (uint8_t) Int16) & 0x10)\
- APUClearHalfCarry ();\
-(a) = (uint8_t) Int16;\
-APUSetZN8 ((uint8_t) Int16);
-
-#define ADC(a,b)\
-Work16 = (a) + (b) + APUCheckCarry();\
-IAPU._Carry = Work16 >= 0x100; \
-if (~((a) ^ (b)) & ((b) ^ (uint8_t) Work16) & 0x80)\
- APUSetOverflow ();\
-else \
- APUClearOverflow (); \
-APUClearHalfCarry ();\
-if(((a) ^ (b) ^ (uint8_t) Work16) & 0x10)\
- APUSetHalfCarry ();\
-(a) = (uint8_t) Work16;\
-APUSetZN8 ((uint8_t) Work16);
-
-#define CMP(a,b)\
-Int16 = (int16_t) (a) - (int16_t) (b);\
-IAPU._Carry = Int16 >= 0;\
-APUSetZN8 ((uint8_t) Int16);
-
-#define ASL(b)\
+#define SBC(a,b) \
+ Int16 = (int16_t) (a) - (int16_t) (b) + (int16_t) (APUCheckCarry ()) - 1; \
+ IAPU._Carry = Int16 >= 0; \
+ if ((((a) ^ (b)) & 0x80) && (((a) ^ (uint8_t) Int16) & 0x80)) \
+ APUSetOverflow (); \
+ else \
+ APUClearOverflow (); \
+ APUSetHalfCarry (); \
+ if(((a) ^ (b) ^ (uint8_t) Int16) & 0x10) \
+ APUClearHalfCarry (); \
+ (a) = (uint8_t) Int16; \
+ APUSetZN8 ((uint8_t) Int16)
+
+#define ADC(a,b) \
+ Work16 = (a) + (b) + APUCheckCarry(); \
+ IAPU._Carry = Work16 >= 0x100; \
+ if (~((a) ^ (b)) & ((b) ^ (uint8_t) Work16) & 0x80) \
+ APUSetOverflow (); \
+ else \
+ APUClearOverflow (); \
+ APUClearHalfCarry (); \
+ if(((a) ^ (b) ^ (uint8_t) Work16) & 0x10) \
+ APUSetHalfCarry (); \
+ (a) = (uint8_t) Work16; \
+ APUSetZN8 ((uint8_t) Work16)
+
+#define CMP(a,b) \
+ Int16 = (int16_t) (a) - (int16_t) (b); \
+ IAPU._Carry = Int16 >= 0; \
+ APUSetZN8((uint8_t) Int16);
+
+#define ASL(b) \
IAPU._Carry = ((b) & 0x80) != 0; \
- (b) <<= 1;\
+ (b) <<= 1; \
APUSetZN8 (b);
-#define LSR(b)\
- IAPU._Carry = (b) & 1;\
- (b) >>= 1;\
+#define LSR(b) \
+ IAPU._Carry = (b) & 1; \
+ (b) >>= 1; \
APUSetZN8 (b);
-#define ROL(b)\
+#define ROL(b) \
Work16 = ((b) << 1) | APUCheckCarry (); \
IAPU._Carry = Work16 >= 0x100; \
(b) = (uint8_t) Work16; \
APUSetZN8 (b);
-#define ROR(b)\
+#define ROR(b) \
Work16 = (b) | ((uint16_t) APUCheckCarry () << 8); \
IAPU._Carry = (uint8_t) Work16 & 1; \
Work16 >>= 1; \
(b) = (uint8_t) Work16; \
APUSetZN8 (b);
-#define Push(b)\
- *(IAPU.RAM + 0x100 + IAPU.Registers.S) = b;\
+#define Push(b) \
+ *(IAPU.RAM + 0x100 + IAPU.Registers.S) = b; \
IAPU.Registers.S--;
-#define Pop(b)\
- IAPU.Registers.S++;\
+#define Pop(b) \
+ IAPU.Registers.S++; \
(b) = *(IAPU.RAM + 0x100 + IAPU.Registers.S);
#ifdef FAST_LSB_WORD_ACCESS
-#define SPC700_PushW(w)\
+#define SPC700_PushW(w) \
if (IAPU.Registers.S == 0) {\
- *(IAPU.RAM + 0x1ff) = (w);\
- *(IAPU.RAM + 0x100) = ((w) >> 8);\
+ *(IAPU.RAM + 0x1ff) = (w); \
+ *(IAPU.RAM + 0x100) = ((w) >> 8); \
} else { \
- *(uint16_t *) (IAPU.RAM + 0xff + IAPU.Registers.S) = w;\
+ *(uint16_t *) (IAPU.RAM + 0xff + IAPU.Registers.S) = w; \
}\
IAPU.Registers.S -= 2;
-#define PopW(w)\
- IAPU.Registers.S += 2;\
- if (IAPU.Registers.S == 0)\
- (w) = *(IAPU.RAM + 0x1ff) | (*(IAPU.RAM + 0x100) << 8);\
+#define PopW(w) \
+ IAPU.Registers.S += 2; \
+ if (IAPU.Registers.S == 0) \
+ (w) = *(IAPU.RAM + 0x1ff) | (*(IAPU.RAM + 0x100) << 8); \
else \
(w) = *(uint16_t *) (IAPU.RAM + 0xff + IAPU.Registers.S);
#else
-#define SPC700_PushW(w)\
- *(IAPU.RAM + 0xff + IAPU.Registers.S) = w;\
- *(IAPU.RAM + 0x100 + IAPU.Registers.S) = ((w) >> 8);\
+#define SPC700_PushW(w) \
+ *(IAPU.RAM + 0xff + IAPU.Registers.S) = w; \
+ *(IAPU.RAM + 0x100 + IAPU.Registers.S) = ((w) >> 8); \
IAPU.Registers.S -= 2;
-#define PopW(w)\
+#define PopW(w) \
IAPU.Registers.S += 2; \
if(IAPU.Registers.S == 0) \
(w) = *(IAPU.RAM + 0x1ff) | (*(IAPU.RAM + 0x100) << 8); \
@@ -156,56 +138,56 @@ APUSetZN8 ((uint8_t) Int16);
(w) = *(IAPU.RAM + 0xff + IAPU.Registers.S) + (*(IAPU.RAM + 0x100 + IAPU.Registers.S) << 8);
#endif
-#define Relative()\
- Int8 = OP1;\
+#define Relative() \
+ Int8 = OP1; \
Int16 = (int16_t) (IAPU.PC + 2 - IAPU.RAM) + Int8;
-#define Relative2()\
- Int8 = OP2;\
+#define Relative2() \
+ Int8 = OP2; \
Int16 = (int16_t) (IAPU.PC + 3 - IAPU.RAM) + Int8;
#ifdef FAST_LSB_WORD_ACCESS
-#define IndexedXIndirect()\
+#define IndexedXIndirect() \
IAPU.Address = *(uint16_t *) (IAPU.DirectPage + ((OP1 + IAPU.Registers.X) & 0xff));
-#define Absolute()\
+#define Absolute() \
IAPU.Address = *(uint16_t *) (IAPU.PC + 1);
-#define AbsoluteX()\
+#define AbsoluteX() \
IAPU.Address = *(uint16_t *) (IAPU.PC + 1) + IAPU.Registers.X;
-#define AbsoluteY()\
+#define AbsoluteY() \
IAPU.Address = *(uint16_t *) (IAPU.PC + 1) + IAPU.Registers.YA.B.Y;
-#define MemBit()\
- IAPU.Address = *(uint16_t *) (IAPU.PC + 1);\
- IAPU.Bit = (uint8_t)(IAPU.Address >> 13);\
+#define MemBit() \
+ IAPU.Address = *(uint16_t *) (IAPU.PC + 1); \
+ IAPU.Bit = (uint8_t)(IAPU.Address >> 13); \
IAPU.Address &= 0x1fff;
-#define IndirectIndexedY()\
+#define IndirectIndexedY() \
IAPU.Address = *(uint16_t *) (IAPU.DirectPage + OP1) + IAPU.Registers.YA.B.Y;
#else
-#define IndexedXIndirect()\
+#define IndexedXIndirect() \
IAPU.Address = *(IAPU.DirectPage + ((OP1 + IAPU.Registers.X) & 0xff)) + \
- (*(IAPU.DirectPage + ((OP1 + IAPU.Registers.X + 1) & 0xff)) << 8);
-#define Absolute()\
+ (*(IAPU.DirectPage + ((OP1 + IAPU.Registers.X + 1) & 0xff)) << 8);
+#define Absolute() \
IAPU.Address = OP1 + (OP2 << 8);
-#define AbsoluteX()\
+#define AbsoluteX() \
IAPU.Address = OP1 + (OP2 << 8) + IAPU.Registers.X;
-#define AbsoluteY()\
+#define AbsoluteY() \
IAPU.Address = OP1 + (OP2 << 8) + IAPU.Registers.YA.B.Y;
-#define MemBit()\
- IAPU.Address = OP1 + (OP2 << 8);\
- IAPU.Bit = (int8_t) (IAPU.Address >> 13);\
+#define MemBit() \
+ IAPU.Address = OP1 + (OP2 << 8); \
+ IAPU.Bit = (int8_t) (IAPU.Address >> 13); \
IAPU.Address &= 0x1fff;
-#define IndirectIndexedY()\
+#define IndirectIndexedY() \
IAPU.Address = *(IAPU.DirectPage + OP1) + \
- (*(IAPU.DirectPage + OP1 + 1) << 8) + \
- IAPU.Registers.YA.B.Y;
+ (*(IAPU.DirectPage + OP1 + 1) << 8) + \
+ IAPU.Registers.YA.B.Y;
#endif
void Apu00()
@@ -819,7 +801,6 @@ void Apu4E()
void Apu0F()
{
// BRK
-
SPC700_PushW(IAPU.PC + 1 - IAPU.RAM);
S9xAPUPackStatus();
Push(IAPU.Registers.P);
@@ -1436,11 +1417,7 @@ void Apu3D()
// INC X
IAPU.Registers.X++;
APUSetZN8(IAPU.Registers.X);
-
-#ifdef SPC700_SHUTDOWN
IAPU.WaitCounter++;
-#endif
-
IAPU.PC++;
}
@@ -1449,11 +1426,7 @@ void ApuFC()
// INC Y
IAPU.Registers.YA.B.Y++;
APUSetZN8(IAPU.Registers.YA.B.Y);
-
-#ifdef SPC700_SHUTDOWN
IAPU.WaitCounter++;
-#endif
-
IAPU.PC++;
}
@@ -1462,11 +1435,7 @@ void Apu1D()
// DEC X
IAPU.Registers.X--;
APUSetZN8(IAPU.Registers.X);
-
-#ifdef SPC700_SHUTDOWN
IAPU.WaitCounter++;
-#endif
-
IAPU.PC++;
}
@@ -1475,11 +1444,7 @@ void ApuDC()
// DEC Y
IAPU.Registers.YA.B.Y--;
APUSetZN8(IAPU.Registers.YA.B.Y);
-
-#ifdef SPC700_SHUTDOWN
IAPU.WaitCounter++;
-#endif
-
IAPU.PC++;
}
@@ -1489,11 +1454,7 @@ void ApuAB()
Work8 = S9xAPUGetByteZ(OP1) + 1;
S9xAPUSetByteZ(Work8, OP1);
APUSetZN8(Work8);
-
-#ifdef SPC700_SHUTDOWN
IAPU.WaitCounter++;
-#endif
-
IAPU.PC += 2;
}
@@ -1504,11 +1465,7 @@ void ApuAC()
Work8 = S9xAPUGetByte(IAPU.Address) + 1;
S9xAPUSetByte(Work8, IAPU.Address);
APUSetZN8(Work8);
-
-#ifdef SPC700_SHUTDOWN
IAPU.WaitCounter++;
-#endif
-
IAPU.PC += 3;
}
@@ -1518,11 +1475,7 @@ void ApuBB()
Work8 = S9xAPUGetByteZ(OP1 + IAPU.Registers.X) + 1;
S9xAPUSetByteZ(Work8, OP1 + IAPU.Registers.X);
APUSetZN8(Work8);
-
-#ifdef SPC700_SHUTDOWN
IAPU.WaitCounter++;
-#endif
-
IAPU.PC += 2;
}
@@ -1531,11 +1484,7 @@ void ApuBC()
// INC A
IAPU.Registers.YA.B.A++;
APUSetZN8(IAPU.Registers.YA.B.A);
-
-#ifdef SPC700_SHUTDOWN
IAPU.WaitCounter++;
-#endif
-
IAPU.PC++;
}
@@ -1545,11 +1494,7 @@ void Apu8B()
Work8 = S9xAPUGetByteZ(OP1) - 1;
S9xAPUSetByteZ(Work8, OP1);
APUSetZN8(Work8);
-
-#ifdef SPC700_SHUTDOWN
IAPU.WaitCounter++;
-#endif
-
IAPU.PC += 2;
}
@@ -1560,11 +1505,7 @@ void Apu8C()
Work8 = S9xAPUGetByte(IAPU.Address) - 1;
S9xAPUSetByte(Work8, IAPU.Address);
APUSetZN8(Work8);
-
-#ifdef SPC700_SHUTDOWN
IAPU.WaitCounter++;
-#endif
-
IAPU.PC += 3;
}
@@ -1574,11 +1515,7 @@ void Apu9B()
Work8 = S9xAPUGetByteZ(OP1 + IAPU.Registers.X) - 1;
S9xAPUSetByteZ(Work8, OP1 + IAPU.Registers.X);
APUSetZN8(Work8);
-
-#ifdef SPC700_SHUTDOWN
IAPU.WaitCounter++;
-#endif
-
IAPU.PC += 2;
}
@@ -1587,11 +1524,7 @@ void Apu9C()
// DEC A
IAPU.Registers.YA.B.A--;
APUSetZN8(IAPU.Registers.YA.B.A);
-
-#ifdef SPC700_SHUTDOWN
IAPU.WaitCounter++;
-#endif
-
IAPU.PC++;
}
@@ -2008,7 +1941,7 @@ void Apu9E()
if (yva >= x)
yva ^= 1;
-
+
if (yva & 1)
yva = (yva - x) & 0x1ffff;
}
@@ -2459,12 +2392,6 @@ void ApuFB()
IAPU.PC += 2;
}
-#ifdef NO_INLINE_SET_GET
-#undef INLINE
-#define INLINE
-#include "apumem.h"
-#endif
-
void (*S9xApuOpcodes[256])() =
{
Apu00, Apu01, Apu02, Apu03, Apu04, Apu05, Apu06, Apu07,
@@ -2500,5 +2427,4 @@ void (*S9xApuOpcodes[256])() =
ApuF0, ApuF1, ApuF2, ApuF3, ApuF4, ApuF5, ApuF6, ApuF7,
ApuF8, ApuF9, ApuFA, ApuFB, ApuFC, ApuFD, ApuFE, ApuFF
};
-
#endif
diff --git a/source/spc700.h b/source/spc700.h
index cbe6637..53bc1b6 100644
--- a/source/spc700.h
+++ b/source/spc700.h
@@ -5,13 +5,6 @@
#ifndef _SPC700_H_
#define _SPC700_H_
-#ifdef SPCTOOL
-#define NO_CHANNEL_STRUCT
-#include "spctool/dsp.h"
-#include "spctool/spc700.h"
-#include "spctool/soundmod.h"
-#endif
-
#define Carry 1
#define Zero 2
#define Interrupt 4
@@ -43,10 +36,6 @@
#define APUCheckOverflow() (IAPU._Overflow)
#define APUCheckNegative() (IAPU._Zero & 0x80)
-#define APUClearFlags(f) (IAPU.Registers.P &= ~(f))
-#define APUSetFlags(f) (IAPU.Registers.P |= (f))
-#define APUCheckFlag(f) (IAPU.Registers.P & (f))
-
typedef union
{
struct
@@ -73,21 +62,6 @@ typedef struct
// Needed by ILLUSION OF GAIA
#define ONE_APU_CYCLE 21
-#ifdef SPCTOOL
-int32_t ESPC(int32_t);
-
-#define APU_EXECUTE() \
-{ \
- int32_t l = (CPU.Cycles - APU.Cycles) / 14; \
- if (l > 0) \
- { \
- l -= _EmuSPC(l); \
- APU.Cycles += l * 14; \
- } \
-}
-
-#else
-
#define APU_EXECUTE1() \
{ \
APU.Cycles += S9xAPUCycles [*IAPU.PC]; \
@@ -100,8 +74,6 @@ if (IAPU.APUExecuting) \
while (APU.Cycles <= CPU.Cycles) \
APU_EXECUTE1(); \
}
-#endif
#endif
-
#endif
diff --git a/source/spc7110.c b/source/spc7110.c
index ffaf35f..fb8f280 100644
--- a/source/spc7110.c
+++ b/source/spc7110.c
@@ -46,7 +46,7 @@ void (*Copy7110)() = NULL;
//size and offset of the pack data
//offset and size of reads from pack
-typedef struct SPC7110DecompressionLocationStruct
+typedef struct
{
uint32_t offset;
uint32_t size;
@@ -55,7 +55,7 @@ typedef struct SPC7110DecompressionLocationStruct
} Data7110;
//this maps an index.bin table to the decompression pack
-typedef struct SPC7110DecompressionIndexStruct
+typedef struct
{
int32_t table;
bool is_file;
@@ -63,7 +63,7 @@ typedef struct SPC7110DecompressionIndexStruct
} Index7110;
//this contains all the data for the decompression pack.
-typedef struct SPC7110DecompressionPackStructure
+typedef struct
{
uint8_t* binfiles[MAX_TABLES];
Index7110 tableEnts[MAX_TABLES];
diff --git a/source/spc7110.h b/source/spc7110.h
index 351f29d..8557071 100644
--- a/source/spc7110.h
+++ b/source/spc7110.h
@@ -32,7 +32,7 @@ void SPC7110Load(char*);
void SPC7110Open(char*);
void SPC7110Grab(char*);
-typedef struct SPC7110RTC
+typedef struct
{
uint8_t reg[16];
int16_t index;
@@ -41,7 +41,7 @@ typedef struct SPC7110RTC
time_t last_used;
} S7RTC;
-typedef struct SPC7110EmuVars
+typedef struct
{
uint8_t reg4800;
uint8_t reg4801;
diff --git a/source/srtc.h b/source/srtc.h
index 592a391..0688a54 100644
--- a/source/srtc.h
+++ b/source/srtc.h
@@ -15,32 +15,22 @@
#define COMMAND_LOAD_RTC 0
#define COMMAND_CLEAR_RTC 4
-
/*** The format of the rtc_data structure is:
-
Index Description Range (nibble)
----- -------------- ---------------------------------------
-
0 Seconds low 0-9
1 Seconds high 0-5
-
2 Minutes low 0-9
3 Minutes high 0-5
-
4 Hour low 0-9
5 Hour high 0-2
-
6 Day low 0-9
7 Day high 0-3
-
8 Month 1-C (0xC is December, 12th month)
-
9 Year ones 0-9
A Year tens 0-9
B Year High 9-B (9=19xx, A=20xx, B=21xx)
-
C Day of week 0-6 (0=Sunday, 1=Monday,...,6=Saturday)
-
***/
typedef struct
@@ -51,10 +41,9 @@ typedef struct
int8_t index;
uint8_t mode;
time_t system_timestamp; // Of latest RTC load time
- uint32_t pad;
} SRTC_DATA;
-extern SRTC_DATA rtc;
+extern SRTC_DATA rtc;
void S9xUpdateSrtcTime();
void S9xSetSRTC(uint8_t data, uint16_t Address);
@@ -66,4 +55,4 @@ void S9xHardResetSRTC();
#define SRTC_SRAM_PAD (4 + 8 + 1 + MAX_RTC_INDEX)
-#endif // _srtc_h
+#endif // _srtc_h
diff --git a/source/tile.c b/source/tile.c
index 43bcecb..7b78c27 100644
--- a/source/tile.c
+++ b/source/tile.c
@@ -125,8 +125,8 @@ static uint8_t ConvertTile(uint8_t* pCache, uint32_t TileAddr)
}
return (non_zero ? true : BLANK_TILE);
}
-#define PLOT_PIXEL(screen, pixel) (pixel)
+#define PLOT_PIXEL(screen, pixel) (pixel)
static void WRITE_4PIXELS16(int32_t Offset, uint8_t* Pixels, uint16_t* ScreenColors)
{
@@ -144,8 +144,7 @@ static void WRITE_4PIXELS16(int32_t Offset, uint8_t* Pixels, uint16_t* ScreenCol
}
}
-static void WRITE_4PIXELS16_FLIPPED(int32_t Offset, uint8_t* Pixels,
- uint16_t* ScreenColors)
+static void WRITE_4PIXELS16_FLIPPED(int32_t Offset, uint8_t* Pixels, uint16_t* ScreenColors)
{
uint8_t Pixel, N;
uint16_t* Screen = (uint16_t*) GFX.S + Offset;
@@ -161,8 +160,7 @@ static void WRITE_4PIXELS16_FLIPPED(int32_t Offset, uint8_t* Pixels,
}
}
-static void WRITE_4PIXELS16_HALFWIDTH(int32_t Offset, uint8_t* Pixels,
- uint16_t* ScreenColors)
+static void WRITE_4PIXELS16_HALFWIDTH(int32_t Offset, uint8_t* Pixels, uint16_t* ScreenColors)
{
uint8_t Pixel, N;
uint16_t* Screen = (uint16_t*) GFX.S + Offset;
@@ -178,8 +176,7 @@ static void WRITE_4PIXELS16_HALFWIDTH(int32_t Offset, uint8_t* Pixels,
}
}
-static void WRITE_4PIXELS16_FLIPPED_HALFWIDTH(int32_t Offset, uint8_t* Pixels,
- uint16_t* ScreenColors)
+static void WRITE_4PIXELS16_FLIPPED_HALFWIDTH(int32_t Offset, uint8_t* Pixels, uint16_t* ScreenColors)
{
uint8_t Pixel, N;
uint16_t* Screen = (uint16_t*) GFX.S + Offset;
@@ -203,7 +200,7 @@ static void WRITE_4PIXELS16x2(int32_t Offset, uint8_t* Pixels, uint16_t* ScreenC
for (N = 0; N < 4; N++)
{
- if (GFX.Z1 > Depth [N] && (Pixel = Pixels[N]))
+ if (GFX.Z1 > Depth [N * 2] && (Pixel = Pixels[N]))
{
Screen [N * 2] = Screen [N * 2 + 1] = ScreenColors [Pixel];
Depth [N * 2] = Depth [N * 2 + 1] = GFX.Z2;
@@ -211,8 +208,7 @@ static void WRITE_4PIXELS16x2(int32_t Offset, uint8_t* Pixels, uint16_t* ScreenC
}
}
-static void WRITE_4PIXELS16_FLIPPEDx2(int32_t Offset, uint8_t* Pixels,
- uint16_t* ScreenColors)
+static void WRITE_4PIXELS16_FLIPPEDx2(int32_t Offset, uint8_t* Pixels, uint16_t* ScreenColors)
{
uint8_t Pixel, N;
uint16_t* Screen = (uint16_t*) GFX.S + Offset;
@@ -220,7 +216,7 @@ static void WRITE_4PIXELS16_FLIPPEDx2(int32_t Offset, uint8_t* Pixels,
for (N = 0; N < 4; N++)
{
- if (GFX.Z1 > Depth [N] && (Pixel = Pixels[3 - N]))
+ if (GFX.Z1 > Depth [N * 2] && (Pixel = Pixels[3 - N]))
{
Screen [N * 2] = Screen [N * 2 + 1] = ScreenColors [Pixel];
Depth [N * 2] = Depth [N * 2 + 1] = GFX.Z2;
@@ -228,8 +224,7 @@ static void WRITE_4PIXELS16_FLIPPEDx2(int32_t Offset, uint8_t* Pixels,
}
}
-static void WRITE_4PIXELS16x2x2(int32_t Offset, uint8_t* Pixels,
- uint16_t* ScreenColors)
+static void WRITE_4PIXELS16x2x2(int32_t Offset, uint8_t* Pixels, uint16_t* ScreenColors)
{
uint8_t Pixel, N;
uint16_t* Screen = (uint16_t*) GFX.S + Offset;
@@ -237,18 +232,17 @@ static void WRITE_4PIXELS16x2x2(int32_t Offset, uint8_t* Pixels,
for (N = 0; N < 4; N++)
{
- if (GFX.Z1 > Depth [N] && (Pixel = Pixels[N]))
+ if (GFX.Z1 > Depth [N * 2] && (Pixel = Pixels[N]))
{
Screen [N * 2] = Screen [N * 2 + 1] = Screen [(GFX.RealPitch >> 1) + N * 2] =
Screen [(GFX.RealPitch >> 1) + N * 2 + 1] = ScreenColors [Pixel];
Depth [N * 2] = Depth [N * 2 + 1] = Depth [(GFX.RealPitch >> 1) + N * 2] =
- Depth [(GFX.RealPitch >> 1) + N * 2 + 1] = GFX.Z2;
+ Depth [(GFX.RealPitch >> 1) + N * 2 + 1] = GFX.Z2;
}
}
}
-static void WRITE_4PIXELS16_FLIPPEDx2x2(int32_t Offset, uint8_t* Pixels,
- uint16_t* ScreenColors)
+static void WRITE_4PIXELS16_FLIPPEDx2x2(int32_t Offset, uint8_t* Pixels, uint16_t* ScreenColors)
{
uint8_t Pixel, N;
uint16_t* Screen = (uint16_t*) GFX.S + Offset;
@@ -256,7 +250,7 @@ static void WRITE_4PIXELS16_FLIPPEDx2x2(int32_t Offset, uint8_t* Pixels,
for (N = 0; N < 4; N++)
{
- if (GFX.Z1 > Depth [N] && (Pixel = Pixels[3 - N]))
+ if (GFX.Z1 > Depth [N * 2] && (Pixel = Pixels[3 - N]))
{
Screen [N * 2] = Screen [N * 2 + 1] = Screen [(GFX.RealPitch >> 1) + N * 2] =
Screen [(GFX.RealPitch >> 1) + N * 2 + 1] = ScreenColors [Pixel];
@@ -266,8 +260,7 @@ static void WRITE_4PIXELS16_FLIPPEDx2x2(int32_t Offset, uint8_t* Pixels,
}
}
-void DrawTile16(uint32_t Tile, int32_t Offset, uint32_t StartLine,
- uint32_t LineCount)
+void DrawTile16(uint32_t Tile, int32_t Offset, uint32_t StartLine, uint32_t LineCount)
{
TILE_PREAMBLE
uint8_t* bp;
@@ -275,9 +268,7 @@ void DrawTile16(uint32_t Tile, int32_t Offset, uint32_t StartLine,
RENDER_TILE(WRITE_4PIXELS16, WRITE_4PIXELS16_FLIPPED, 4)
}
-void DrawClippedTile16(uint32_t Tile, int32_t Offset,
- uint32_t StartPixel, uint32_t Width,
- uint32_t StartLine, uint32_t LineCount)
+void DrawClippedTile16(uint32_t Tile, int32_t Offset, uint32_t StartPixel, uint32_t Width, uint32_t StartLine, uint32_t LineCount)
{
TILE_PREAMBLE
uint8_t* bp;
@@ -286,8 +277,7 @@ void DrawClippedTile16(uint32_t Tile, int32_t Offset,
RENDER_CLIPPED_TILE(WRITE_4PIXELS16, WRITE_4PIXELS16_FLIPPED, 4)
}
-void DrawTile16HalfWidth(uint32_t Tile, int32_t Offset, uint32_t StartLine,
- uint32_t LineCount)
+void DrawTile16HalfWidth(uint32_t Tile, int32_t Offset, uint32_t StartLine, uint32_t LineCount)
{
TILE_PREAMBLE
uint8_t* bp;
@@ -295,20 +285,16 @@ void DrawTile16HalfWidth(uint32_t Tile, int32_t Offset, uint32_t StartLine,
RENDER_TILE(WRITE_4PIXELS16_HALFWIDTH, WRITE_4PIXELS16_FLIPPED_HALFWIDTH, 2)
}
-void DrawClippedTile16HalfWidth(uint32_t Tile, int32_t Offset,
- uint32_t StartPixel, uint32_t Width,
- uint32_t StartLine, uint32_t LineCount)
+void DrawClippedTile16HalfWidth(uint32_t Tile, int32_t Offset, uint32_t StartPixel, uint32_t Width, uint32_t StartLine, uint32_t LineCount)
{
TILE_PREAMBLE
uint8_t* bp;
TILE_CLIP_PREAMBLE
- RENDER_CLIPPED_TILE(WRITE_4PIXELS16_HALFWIDTH,
- WRITE_4PIXELS16_FLIPPED_HALFWIDTH, 2)
+ RENDER_CLIPPED_TILE(WRITE_4PIXELS16_HALFWIDTH, WRITE_4PIXELS16_FLIPPED_HALFWIDTH, 2)
}
-void DrawTile16x2(uint32_t Tile, int32_t Offset, uint32_t StartLine,
- uint32_t LineCount)
+void DrawTile16x2(uint32_t Tile, int32_t Offset, uint32_t StartLine, uint32_t LineCount)
{
TILE_PREAMBLE
uint8_t* bp;
@@ -316,9 +302,7 @@ void DrawTile16x2(uint32_t Tile, int32_t Offset, uint32_t StartLine,
RENDER_TILE(WRITE_4PIXELS16x2, WRITE_4PIXELS16_FLIPPEDx2, 8)
}
-void DrawClippedTile16x2(uint32_t Tile, int32_t Offset,
- uint32_t StartPixel, uint32_t Width,
- uint32_t StartLine, uint32_t LineCount)
+void DrawClippedTile16x2(uint32_t Tile, int32_t Offset, uint32_t StartPixel, uint32_t Width, uint32_t StartLine, uint32_t LineCount)
{
TILE_PREAMBLE
uint8_t* bp;
@@ -360,9 +344,7 @@ void DrawLargePixel16(uint32_t Tile, int32_t Offset,
RENDER_TILE_LARGE(ScreenColors [pixel], PLOT_PIXEL)
}
-void DrawLargePixel16HalfWidth(uint32_t Tile, int32_t Offset,
- uint32_t StartPixel, uint32_t Pixels,
- uint32_t StartLine, uint32_t LineCount)
+void DrawLargePixel16HalfWidth(uint32_t Tile, int32_t Offset, uint32_t StartPixel, uint32_t Pixels, uint32_t StartLine, uint32_t LineCount)
{
TILE_PREAMBLE
@@ -373,8 +355,7 @@ void DrawLargePixel16HalfWidth(uint32_t Tile, int32_t Offset,
RENDER_TILE_LARGE_HALFWIDTH(ScreenColors [pixel], PLOT_PIXEL)
}
-static void WRITE_4PIXELS16_ADD(int32_t Offset, uint8_t* Pixels,
- uint16_t* ScreenColors)
+static void WRITE_4PIXELS16_ADD(int32_t Offset, uint8_t* Pixels, uint16_t* ScreenColors)
{
uint8_t Pixel, N;
@@ -403,8 +384,7 @@ static void WRITE_4PIXELS16_ADD(int32_t Offset, uint8_t* Pixels,
}
}
-static void WRITE_4PIXELS16_FLIPPED_ADD(int32_t Offset, uint8_t* Pixels,
- uint16_t* ScreenColors)
+static void WRITE_4PIXELS16_FLIPPED_ADD(int32_t Offset, uint8_t* Pixels, uint16_t* ScreenColors)
{
uint8_t Pixel, N;
@@ -433,8 +413,7 @@ static void WRITE_4PIXELS16_FLIPPED_ADD(int32_t Offset, uint8_t* Pixels,
}
}
-static void WRITE_4PIXELS16_ADD1_2(int32_t Offset, uint8_t* Pixels,
- uint16_t* ScreenColors)
+static void WRITE_4PIXELS16_ADD1_2(int32_t Offset, uint8_t* Pixels, uint16_t* ScreenColors)
{
uint8_t Pixel, N;
uint16_t* Screen = (uint16_t*) GFX.S + Offset;
@@ -463,8 +442,7 @@ static void WRITE_4PIXELS16_ADD1_2(int32_t Offset, uint8_t* Pixels,
}
}
-static void WRITE_4PIXELS16_FLIPPED_ADD1_2(int32_t Offset, uint8_t* Pixels,
- uint16_t* ScreenColors)
+static void WRITE_4PIXELS16_FLIPPED_ADD1_2(int32_t Offset, uint8_t* Pixels, uint16_t* ScreenColors)
{
uint8_t Pixel, N;
uint16_t* Screen = (uint16_t*) GFX.S + Offset;
@@ -493,8 +471,7 @@ static void WRITE_4PIXELS16_FLIPPED_ADD1_2(int32_t Offset, uint8_t* Pixels,
}
}
-static void WRITE_4PIXELS16_SUB(int32_t Offset, uint8_t* Pixels,
- uint16_t* ScreenColors)
+static void WRITE_4PIXELS16_SUB(int32_t Offset, uint8_t* Pixels, uint16_t* ScreenColors)
{
uint8_t Pixel, N;
uint16_t* Screen = (uint16_t*) GFX.S + Offset;
@@ -522,8 +499,7 @@ static void WRITE_4PIXELS16_SUB(int32_t Offset, uint8_t* Pixels,
}
}
-static void WRITE_4PIXELS16_FLIPPED_SUB(int32_t Offset, uint8_t* Pixels,
- uint16_t* ScreenColors)
+static void WRITE_4PIXELS16_FLIPPED_SUB(int32_t Offset, uint8_t* Pixels, uint16_t* ScreenColors)
{
uint8_t Pixel, N;
uint16_t* Screen = (uint16_t*) GFX.S + Offset;
@@ -551,8 +527,7 @@ static void WRITE_4PIXELS16_FLIPPED_SUB(int32_t Offset, uint8_t* Pixels,
}
}
-static void WRITE_4PIXELS16_SUB1_2(int32_t Offset, uint8_t* Pixels,
- uint16_t* ScreenColors)
+static void WRITE_4PIXELS16_SUB1_2(int32_t Offset, uint8_t* Pixels, uint16_t* ScreenColors)
{
uint8_t Pixel, N;
uint16_t* Screen = (uint16_t*) GFX.S + Offset;
@@ -572,8 +547,7 @@ static void WRITE_4PIXELS16_SUB1_2(int32_t Offset, uint8_t* Pixels,
Screen [N] = (uint16_t) COLOR_SUB(ScreenColors [Pixel], GFX.FixedColour);
break;
default:
- Screen [N] = (uint16_t) COLOR_SUB1_2(ScreenColors [Pixel],
- Screen [GFX.Delta + N]);
+ Screen [N] = (uint16_t) COLOR_SUB1_2(ScreenColors [Pixel], Screen [GFX.Delta + N]);
break;
}
Depth [N] = GFX.Z2;
@@ -581,8 +555,7 @@ static void WRITE_4PIXELS16_SUB1_2(int32_t Offset, uint8_t* Pixels,
}
}
-static void WRITE_4PIXELS16_FLIPPED_SUB1_2(int32_t Offset, uint8_t* Pixels,
- uint16_t* ScreenColors)
+static void WRITE_4PIXELS16_FLIPPED_SUB1_2(int32_t Offset, uint8_t* Pixels, uint16_t* ScreenColors)
{
uint8_t Pixel, N;
uint16_t* Screen = (uint16_t*) GFX.S + Offset;
@@ -612,8 +585,7 @@ static void WRITE_4PIXELS16_FLIPPED_SUB1_2(int32_t Offset, uint8_t* Pixels,
}
-void DrawTile16Add(uint32_t Tile, int32_t Offset, uint32_t StartLine,
- uint32_t LineCount)
+void DrawTile16Add(uint32_t Tile, int32_t Offset, uint32_t StartLine, uint32_t LineCount)
{
TILE_PREAMBLE
uint8_t* bp;
@@ -737,9 +709,7 @@ void DrawTile16Add(uint32_t Tile, int32_t Offset, uint32_t StartLine,
}
}
-void DrawClippedTile16Add(uint32_t Tile, int32_t Offset,
- uint32_t StartPixel, uint32_t Width,
- uint32_t StartLine, uint32_t LineCount)
+void DrawClippedTile16Add(uint32_t Tile, int32_t Offset, uint32_t StartPixel, uint32_t Width, uint32_t StartLine, uint32_t LineCount)
{
TILE_PREAMBLE
uint8_t* bp;
@@ -748,8 +718,7 @@ void DrawClippedTile16Add(uint32_t Tile, int32_t Offset,
RENDER_CLIPPED_TILE(WRITE_4PIXELS16_ADD, WRITE_4PIXELS16_FLIPPED_ADD, 4)
}
-void DrawTile16Add1_2(uint32_t Tile, int32_t Offset, uint32_t StartLine,
- uint32_t LineCount)
+void DrawTile16Add1_2(uint32_t Tile, int32_t Offset, uint32_t StartLine, uint32_t LineCount)
{
TILE_PREAMBLE
uint8_t* bp;
@@ -757,9 +726,7 @@ void DrawTile16Add1_2(uint32_t Tile, int32_t Offset, uint32_t StartLine,
RENDER_TILE(WRITE_4PIXELS16_ADD1_2, WRITE_4PIXELS16_FLIPPED_ADD1_2, 4)
}
-void DrawClippedTile16Add1_2(uint32_t Tile, int32_t Offset,
- uint32_t StartPixel, uint32_t Width,
- uint32_t StartLine, uint32_t LineCount)
+void DrawClippedTile16Add1_2(uint32_t Tile, int32_t Offset, uint32_t StartPixel, uint32_t Width, uint32_t StartLine, uint32_t LineCount)
{
TILE_PREAMBLE
uint8_t* bp;
@@ -768,8 +735,7 @@ void DrawClippedTile16Add1_2(uint32_t Tile, int32_t Offset,
RENDER_CLIPPED_TILE(WRITE_4PIXELS16_ADD1_2, WRITE_4PIXELS16_FLIPPED_ADD1_2, 4)
}
-void DrawTile16Sub(uint32_t Tile, int32_t Offset, uint32_t StartLine,
- uint32_t LineCount)
+void DrawTile16Sub(uint32_t Tile, int32_t Offset, uint32_t StartLine, uint32_t LineCount)
{
TILE_PREAMBLE
uint8_t* bp;
@@ -808,8 +774,7 @@ void DrawClippedTile16Sub1_2(uint32_t Tile, int32_t Offset,
RENDER_CLIPPED_TILE(WRITE_4PIXELS16_SUB1_2, WRITE_4PIXELS16_FLIPPED_SUB1_2, 4)
}
-static void WRITE_4PIXELS16_ADDF1_2(int32_t Offset, uint8_t* Pixels,
- uint16_t* ScreenColors)
+static void WRITE_4PIXELS16_ADDF1_2(int32_t Offset, uint8_t* Pixels, uint16_t* ScreenColors)
{
uint8_t Pixel, N;
uint16_t* Screen = (uint16_t*) GFX.S + Offset;
@@ -828,8 +793,7 @@ static void WRITE_4PIXELS16_ADDF1_2(int32_t Offset, uint8_t* Pixels,
}
}
-static void WRITE_4PIXELS16_FLIPPED_ADDF1_2(int32_t Offset, uint8_t* Pixels,
- uint16_t* ScreenColors)
+static void WRITE_4PIXELS16_FLIPPED_ADDF1_2(int32_t Offset, uint8_t* Pixels, uint16_t* ScreenColors)
{
uint8_t Pixel, N;
uint16_t* Screen = (uint16_t*) GFX.S + Offset;
@@ -848,8 +812,7 @@ static void WRITE_4PIXELS16_FLIPPED_ADDF1_2(int32_t Offset, uint8_t* Pixels,
}
}
-static void WRITE_4PIXELS16_SUBF1_2(int32_t Offset, uint8_t* Pixels,
- uint16_t* ScreenColors)
+static void WRITE_4PIXELS16_SUBF1_2(int32_t Offset, uint8_t* Pixels, uint16_t* ScreenColors)
{
uint8_t Pixel, N;
uint16_t* Screen = (uint16_t*) GFX.S + Offset;
@@ -868,8 +831,7 @@ static void WRITE_4PIXELS16_SUBF1_2(int32_t Offset, uint8_t* Pixels,
}
}
-static void WRITE_4PIXELS16_FLIPPED_SUBF1_2(int32_t Offset, uint8_t* Pixels,
- uint16_t* ScreenColors)
+static void WRITE_4PIXELS16_FLIPPED_SUBF1_2(int32_t Offset, uint8_t* Pixels, uint16_t* ScreenColors)
{
uint8_t Pixel, N;
uint16_t* Screen = (uint16_t*) GFX.S + Offset;
@@ -888,8 +850,7 @@ static void WRITE_4PIXELS16_FLIPPED_SUBF1_2(int32_t Offset, uint8_t* Pixels,
}
}
-void DrawTile16FixedAdd1_2(uint32_t Tile, int32_t Offset, uint32_t StartLine,
- uint32_t LineCount)
+void DrawTile16FixedAdd1_2(uint32_t Tile, int32_t Offset, uint32_t StartLine, uint32_t LineCount)
{
TILE_PREAMBLE
uint8_t* bp;
@@ -897,9 +858,7 @@ void DrawTile16FixedAdd1_2(uint32_t Tile, int32_t Offset, uint32_t StartLine,
RENDER_TILE(WRITE_4PIXELS16_ADDF1_2, WRITE_4PIXELS16_FLIPPED_ADDF1_2, 4)
}
-void DrawClippedTile16FixedAdd1_2(uint32_t Tile, int32_t Offset,
- uint32_t StartPixel, uint32_t Width,
- uint32_t StartLine, uint32_t LineCount)
+void DrawClippedTile16FixedAdd1_2(uint32_t Tile, int32_t Offset, uint32_t StartPixel, uint32_t Width, uint32_t StartLine, uint32_t LineCount)
{
TILE_PREAMBLE
uint8_t* bp;
@@ -909,8 +868,7 @@ void DrawClippedTile16FixedAdd1_2(uint32_t Tile, int32_t Offset,
WRITE_4PIXELS16_FLIPPED_ADDF1_2, 4)
}
-void DrawTile16FixedSub1_2(uint32_t Tile, int32_t Offset, uint32_t StartLine,
- uint32_t LineCount)
+void DrawTile16FixedSub1_2(uint32_t Tile, int32_t Offset, uint32_t StartLine, uint32_t LineCount)
{
TILE_PREAMBLE
uint8_t* bp;
@@ -918,9 +876,7 @@ void DrawTile16FixedSub1_2(uint32_t Tile, int32_t Offset, uint32_t StartLine,
RENDER_TILE(WRITE_4PIXELS16_SUBF1_2, WRITE_4PIXELS16_FLIPPED_SUBF1_2, 4)
}
-void DrawClippedTile16FixedSub1_2(uint32_t Tile, int32_t Offset,
- uint32_t StartPixel, uint32_t Width,
- uint32_t StartLine, uint32_t LineCount)
+void DrawClippedTile16FixedSub1_2(uint32_t Tile, int32_t Offset, uint32_t StartPixel, uint32_t Width, uint32_t StartLine, uint32_t LineCount)
{
TILE_PREAMBLE
uint8_t* bp;
@@ -930,9 +886,7 @@ void DrawClippedTile16FixedSub1_2(uint32_t Tile, int32_t Offset,
WRITE_4PIXELS16_FLIPPED_SUBF1_2, 4)
}
-void DrawLargePixel16Add(uint32_t Tile, int32_t Offset,
- uint32_t StartPixel, uint32_t Pixels,
- uint32_t StartLine, uint32_t LineCount)
+void DrawLargePixel16Add(uint32_t Tile, int32_t Offset, uint32_t StartPixel, uint32_t Pixels, uint32_t StartLine, uint32_t LineCount)
{
TILE_PREAMBLE
@@ -949,9 +903,7 @@ void DrawLargePixel16Add(uint32_t Tile, int32_t Offset,
RENDER_TILE_LARGE(ScreenColors [pixel], LARGE_ADD_PIXEL)
}
-void DrawLargePixel16Add1_2(uint32_t Tile, int32_t Offset,
- uint32_t StartPixel, uint32_t Pixels,
- uint32_t StartLine, uint32_t LineCount)
+void DrawLargePixel16Add1_2(uint32_t Tile, int32_t Offset, uint32_t StartPixel, uint32_t Pixels, uint32_t StartLine, uint32_t LineCount)
{
TILE_PREAMBLE
@@ -968,9 +920,7 @@ void DrawLargePixel16Add1_2(uint32_t Tile, int32_t Offset,
RENDER_TILE_LARGE(ScreenColors [pixel], LARGE_ADD_PIXEL1_2)
}
-void DrawLargePixel16Sub(uint32_t Tile, int32_t Offset,
- uint32_t StartPixel, uint32_t Pixels,
- uint32_t StartLine, uint32_t LineCount)
+void DrawLargePixel16Sub(uint32_t Tile, int32_t Offset, uint32_t StartPixel, uint32_t Pixels, uint32_t StartLine, uint32_t LineCount)
{
TILE_PREAMBLE
@@ -987,9 +937,7 @@ void DrawLargePixel16Sub(uint32_t Tile, int32_t Offset,
RENDER_TILE_LARGE(ScreenColors [pixel], LARGE_SUB_PIXEL)
}
-void DrawLargePixel16Sub1_2(uint32_t Tile, int32_t Offset,
- uint32_t StartPixel, uint32_t Pixels,
- uint32_t StartLine, uint32_t LineCount)
+void DrawLargePixel16Sub1_2(uint32_t Tile, int32_t Offset, uint32_t StartPixel, uint32_t Pixels, uint32_t StartLine, uint32_t LineCount)
{
TILE_PREAMBLE
diff --git a/source/tile.h b/source/tile.h
index 6bc4e23..2a273f6 100644
--- a/source/tile.h
+++ b/source/tile.h
@@ -8,7 +8,7 @@
\
uint32_t TileAddr = BG.TileAddress + ((Tile & 0x3ff) << BG.TileShift); \
if ((Tile & 0x1ff) >= 256) \
- TileAddr += BG.NameSelect; \
+ TileAddr += BG.NameSelect; \
\
TileAddr &= 0xffff; \
\
@@ -16,67 +16,67 @@
pCache = &BG.Buffer[(TileNumber = (TileAddr >> BG.TileShift)) << 6]; \
\
if (!BG.Buffered [TileNumber]) \
- BG.Buffered[TileNumber] = ConvertTile (pCache, TileAddr); \
+ BG.Buffered[TileNumber] = ConvertTile (pCache, TileAddr); \
\
if (BG.Buffered [TileNumber] == BLANK_TILE) \
- return; \
+ return; \
\
uint32_t l; \
uint16_t *ScreenColors; \
if (BG.DirectColourMode) \
{ \
- if (IPPU.DirectColourMapsNeedRebuild) \
- S9xBuildDirectColourMaps (); \
- ScreenColors = DirectColourMaps [(Tile >> 10) & BG.PaletteMask]; \
+ if (IPPU.DirectColourMapsNeedRebuild) \
+ S9xBuildDirectColourMaps (); \
+ ScreenColors = DirectColourMaps [(Tile >> 10) & BG.PaletteMask]; \
} \
else \
- ScreenColors = &IPPU.ScreenColors [(((Tile >> 10) & BG.PaletteMask) << BG.PaletteShift) + BG.StartPalette];
+ ScreenColors = &IPPU.ScreenColors [(((Tile >> 10) & BG.PaletteMask) << BG.PaletteShift) + BG.StartPalette];
#define RENDER_TILE(NORMAL, FLIPPED, N) \
switch (Tile & (V_FLIP | H_FLIP)) \
{ \
case 0: \
- bp = pCache + StartLine; \
- for (l = LineCount; l != 0; l--, bp += 8, Offset += GFX.PPL) \
- { \
- if (*(uint32_t *) bp) \
- NORMAL (Offset, bp, ScreenColors); \
- if (*(uint32_t *) (bp + 4)) \
- NORMAL (Offset + N, bp + 4, ScreenColors); \
- } \
- break; \
+ bp = pCache + StartLine; \
+ for (l = LineCount; l != 0; l--, bp += 8, Offset += GFX.PPL) \
+ { \
+ if (*(uint32_t *) bp) \
+ NORMAL (Offset, bp, ScreenColors); \
+ if (*(uint32_t *) (bp + 4)) \
+ NORMAL (Offset + N, bp + 4, ScreenColors); \
+ } \
+ break; \
case H_FLIP: \
- bp = pCache + StartLine; \
- for (l = LineCount; l != 0; l--, bp += 8, Offset += GFX.PPL) \
- { \
- if (*(uint32_t *) (bp + 4)) \
- FLIPPED (Offset, bp + 4, ScreenColors); \
- if (*(uint32_t *) bp) \
- FLIPPED (Offset + N, bp, ScreenColors); \
- } \
- break; \
+ bp = pCache + StartLine; \
+ for (l = LineCount; l != 0; l--, bp += 8, Offset += GFX.PPL) \
+ { \
+ if (*(uint32_t *) (bp + 4)) \
+ FLIPPED (Offset, bp + 4, ScreenColors); \
+ if (*(uint32_t *) bp) \
+ FLIPPED (Offset + N, bp, ScreenColors); \
+ } \
+ break; \
case H_FLIP | V_FLIP: \
- bp = pCache + 56 - StartLine; \
- for (l = LineCount; l != 0; l--, bp -= 8, Offset += GFX.PPL) \
- { \
- if (*(uint32_t *) (bp + 4)) \
- FLIPPED (Offset, bp + 4, ScreenColors); \
- if (*(uint32_t *) bp) \
- FLIPPED (Offset + N, bp, ScreenColors); \
- } \
- break; \
+ bp = pCache + 56 - StartLine; \
+ for (l = LineCount; l != 0; l--, bp -= 8, Offset += GFX.PPL) \
+ { \
+ if (*(uint32_t *) (bp + 4)) \
+ FLIPPED (Offset, bp + 4, ScreenColors); \
+ if (*(uint32_t *) bp) \
+ FLIPPED (Offset + N, bp, ScreenColors); \
+ } \
+ break; \
case V_FLIP: \
- bp = pCache + 56 - StartLine; \
- for (l = LineCount; l != 0; l--, bp -= 8, Offset += GFX.PPL) \
- { \
- if (*(uint32_t *) bp) \
- NORMAL (Offset, bp, ScreenColors); \
- if (*(uint32_t *) (bp + 4)) \
- NORMAL (Offset + N, bp + 4, ScreenColors); \
- } \
- break; \
+ bp = pCache + 56 - StartLine; \
+ for (l = LineCount; l != 0; l--, bp -= 8, Offset += GFX.PPL) \
+ { \
+ if (*(uint32_t *) bp) \
+ NORMAL (Offset, bp, ScreenColors); \
+ if (*(uint32_t *) (bp + 4)) \
+ NORMAL (Offset + N, bp + 4, ScreenColors); \
+ } \
+ break; \
default: \
- break; \
+ break; \
}
#define TILE_CLIP_PREAMBLE \
@@ -85,168 +85,176 @@
\
if (StartPixel < 4) \
{ \
- d1 = HeadMask [StartPixel]; \
- if (StartPixel + Width < 4) \
- d1 &= TailMask [StartPixel + Width]; \
+ d1 = HeadMask [StartPixel]; \
+ if (StartPixel + Width < 4) \
+ d1 &= TailMask [StartPixel + Width]; \
} \
else \
- d1 = 0; \
+ d1 = 0; \
\
if (StartPixel + Width > 4) \
{ \
- if (StartPixel > 4) \
- d2 = HeadMask [StartPixel - 4]; \
- else \
- d2 = 0xffffffff; \
+ if (StartPixel > 4) \
+ d2 = HeadMask [StartPixel - 4]; \
+ else \
+ d2 = 0xffffffff; \
\
- d2 &= TailMask [(StartPixel + Width - 4)]; \
+ d2 &= TailMask [(StartPixel + Width - 4)]; \
} \
else \
- d2 = 0;
+ d2 = 0;
#define RENDER_CLIPPED_TILE(NORMAL, FLIPPED, N) \
uint32_t dd; \
switch (Tile & (V_FLIP | H_FLIP)) \
{ \
case 0: \
- bp = pCache + StartLine; \
- for (l = LineCount; l != 0; l--, bp += 8, Offset += GFX.PPL) \
- { \
- /* This is perfectly OK, regardless of endian. The tiles are \
- * cached in leftmost-endian order (when not horiz flipped) by \
- * the ConvertTile function. \
- */ \
- if ((dd = (*(uint32_t *) bp) & d1)) \
- NORMAL (Offset, (uint8_t *) &dd, ScreenColors); \
- if ((dd = (*(uint32_t *) (bp + 4)) & d2)) \
- NORMAL (Offset + N, (uint8_t *) &dd, ScreenColors); \
- } \
- break; \
+ bp = pCache + StartLine; \
+ for (l = LineCount; l != 0; l--, bp += 8, Offset += GFX.PPL) \
+ { \
+ /* This is perfectly OK, regardless of endianness. The tiles are \
+ * cached in leftmost-endian order (when not horiz flipped) by \
+ * the ConvertTile function. \
+ */ \
+ if ((dd = (*(uint32_t *) bp) & d1)) \
+ NORMAL (Offset, (uint8_t *) &dd, ScreenColors); \
+ if ((dd = (*(uint32_t *) (bp + 4)) & d2)) \
+ NORMAL (Offset + N, (uint8_t *) &dd, ScreenColors); \
+ } \
+ break; \
case H_FLIP: \
- bp = pCache + StartLine; \
- SWAP_DWORD (d1); \
- SWAP_DWORD (d2); \
- for (l = LineCount; l != 0; l--, bp += 8, Offset += GFX.PPL) \
- { \
- if ((dd = *(uint32_t *) (bp + 4) & d1)) \
- FLIPPED (Offset, (uint8_t *) &dd, ScreenColors); \
- if ((dd = *(uint32_t *) bp & d2)) \
- FLIPPED (Offset + N, (uint8_t *) &dd, ScreenColors); \
- } \
- break; \
+ bp = pCache + StartLine; \
+ SWAP_DWORD (d1); \
+ SWAP_DWORD (d2); \
+ for (l = LineCount; l != 0; l--, bp += 8, Offset += GFX.PPL) \
+ { \
+ if ((dd = *(uint32_t *) (bp + 4) & d1)) \
+ FLIPPED (Offset, (uint8_t *) &dd, ScreenColors); \
+ if ((dd = *(uint32_t *) bp & d2)) \
+ FLIPPED (Offset + N, (uint8_t *) &dd, ScreenColors); \
+ } \
+ break; \
case H_FLIP | V_FLIP: \
- bp = pCache + 56 - StartLine; \
- SWAP_DWORD (d1); \
- SWAP_DWORD (d2); \
- for (l = LineCount; l != 0; l--, bp -= 8, Offset += GFX.PPL) \
- { \
- if ((dd = *(uint32_t *) (bp + 4) & d1)) \
- FLIPPED (Offset, (uint8_t *) &dd, ScreenColors); \
- if ((dd = *(uint32_t *) bp & d2)) \
- FLIPPED (Offset + N, (uint8_t *) &dd, ScreenColors); \
- } \
- break; \
+ bp = pCache + 56 - StartLine; \
+ SWAP_DWORD (d1); \
+ SWAP_DWORD (d2); \
+ for (l = LineCount; l != 0; l--, bp -= 8, Offset += GFX.PPL) \
+ { \
+ if ((dd = *(uint32_t *) (bp + 4) & d1)) \
+ FLIPPED (Offset, (uint8_t *) &dd, ScreenColors); \
+ if ((dd = *(uint32_t *) bp & d2)) \
+ FLIPPED (Offset + N, (uint8_t *) &dd, ScreenColors); \
+ } \
+ break; \
case V_FLIP: \
- bp = pCache + 56 - StartLine; \
- for (l = LineCount; l != 0; l--, bp -= 8, Offset += GFX.PPL) \
- { \
- if ((dd = (*(uint32_t *) bp) & d1)) \
- NORMAL (Offset, (uint8_t *) &dd, ScreenColors); \
- if ((dd = (*(uint32_t *) (bp + 4)) & d2)) \
- NORMAL (Offset + N, (uint8_t *) &dd, ScreenColors); \
- } \
- break; \
+ bp = pCache + 56 - StartLine; \
+ for (l = LineCount; l != 0; l--, bp -= 8, Offset += GFX.PPL) \
+ { \
+ if ((dd = (*(uint32_t *) bp) & d1)) \
+ NORMAL (Offset, (uint8_t *) &dd, ScreenColors); \
+ if ((dd = (*(uint32_t *) (bp + 4)) & d2)) \
+ NORMAL (Offset + N, (uint8_t *) &dd, ScreenColors); \
+ } \
+ break; \
default: \
- break; \
+ break; \
}
#define RENDER_TILE_LARGE(PIXEL, FUNCTION) \
switch (Tile & (V_FLIP | H_FLIP)) \
{ \
case H_FLIP: \
- StartPixel = 7 - StartPixel; \
- /* fallthrough for no-flip case - above was a horizontal flip */ \
+ StartPixel = 7 - StartPixel; \
+ /* fallthrough for no-flip case - above was a horizontal flip */ \
case 0: \
- if ((pixel = *(pCache + StartLine + StartPixel))) \
- { \
- pixel = PIXEL; \
- for (l = LineCount; l != 0; l--, sp += GFX.PPL, Depth += GFX.PPL) \
+ if ((pixel = *(pCache + StartLine + StartPixel))) \
{ \
- int32_t z; \
- for (z = Pixels - 1; z >= 0; z--) \
- if (GFX.Z1 > Depth [z]) \
+ pixel = PIXEL; \
+ for (l = LineCount; l != 0; l--, sp += GFX.PPL, Depth += GFX.PPL) \
{ \
- sp [z] = FUNCTION(sp + z, pixel); \
- Depth [z] = GFX.Z2; \
- }\
+ int32_t z; \
+ for (z = Pixels - 1; z >= 0; z--) \
+ { \
+ if (GFX.Z1 > Depth [z]) \
+ { \
+ sp [z] = FUNCTION(sp + z, pixel); \
+ Depth [z] = GFX.Z2; \
+ }\
+ } \
+ } \
} \
- } \
- break; \
+ break; \
case H_FLIP | V_FLIP: \
- StartPixel = 7 - StartPixel; \
- /* fallthrough for V_FLIP-only case - above was a horizontal flip */ \
+ StartPixel = 7 - StartPixel; \
+ /* fallthrough for V_FLIP-only case - above was a horizontal flip */ \
case V_FLIP: \
- if ((pixel = *(pCache + 56 - StartLine + StartPixel))) \
- { \
- pixel = PIXEL; \
- for (l = LineCount; l != 0; l--, sp += GFX.PPL, Depth += GFX.PPL) \
+ if ((pixel = *(pCache + 56 - StartLine + StartPixel))) \
{ \
- int32_t z; \
- for (z = Pixels - 1; z >= 0; z--) \
- if (GFX.Z1 > Depth [z]) \
+ pixel = PIXEL; \
+ for (l = LineCount; l != 0; l--, sp += GFX.PPL, Depth += GFX.PPL) \
{ \
- sp [z] = FUNCTION(sp + z, pixel); \
- Depth [z] = GFX.Z2; \
- }\
+ int32_t z; \
+ for (z = Pixels - 1; z >= 0; z--) \
+ { \
+ if (GFX.Z1 > Depth [z]) \
+ { \
+ sp [z] = FUNCTION(sp + z, pixel); \
+ Depth [z] = GFX.Z2; \
+ }\
+ } \
+ } \
} \
- } \
- break; \
+ break; \
default: \
- break; \
+ break; \
}
#define RENDER_TILE_LARGE_HALFWIDTH(PIXEL, FUNCTION) \
switch (Tile & (V_FLIP | H_FLIP)) \
{ \
case H_FLIP: \
- StartPixel = 7 - StartPixel; \
- /* fallthrough for no-flip case - above was a horizontal flip */ \
+ StartPixel = 7 - StartPixel; \
+ /* fallthrough for no-flip case - above was a horizontal flip */ \
case 0: \
- if ((pixel = *(pCache + StartLine + StartPixel))) \
- { \
- pixel = PIXEL; \
- for (l = LineCount; l != 0; l--, sp += GFX.PPL, Depth += GFX.PPL) \
+ if ((pixel = *(pCache + StartLine + StartPixel))) \
{ \
- int32_t z; \
- for (z = Pixels - 2; z >= 0; z -= 2) \
- if (GFX.Z1 > Depth [z]) \
+ pixel = PIXEL; \
+ for (l = LineCount; l != 0; l--, sp += GFX.PPL, Depth += GFX.PPL) \
{ \
- sp [z >> 1] = FUNCTION(sp + z, pixel); \
- Depth [z >> 1] = GFX.Z2; \
- }\
+ int32_t z; \
+ for (z = Pixels - 2; z >= 0; z -= 2) \
+ { \
+ if (GFX.Z1 > Depth [z]) \
+ { \
+ sp [z >> 1] = FUNCTION(sp + z, pixel); \
+ Depth [z >> 1] = GFX.Z2; \
+ } \
+ } \
+ } \
} \
- } \
- break; \
+ break; \
case H_FLIP | V_FLIP: \
- StartPixel = 7 - StartPixel; \
- /* fallthrough for V_FLIP-only case - above was a horizontal flip */ \
+ StartPixel = 7 - StartPixel; \
+ /* fallthrough for V_FLIP-only case - above was a horizontal flip */ \
case V_FLIP: \
- if ((pixel = *(pCache + 56 - StartLine + StartPixel))) \
- { \
- pixel = PIXEL; \
- for (l = LineCount; l != 0; l--, sp += GFX.PPL, Depth += GFX.PPL) \
+ if ((pixel = *(pCache + 56 - StartLine + StartPixel))) \
{ \
- int32_t z; \
- for (z = Pixels - 2; z >= 0; z -= 2) \
- if (GFX.Z1 > Depth [z]) \
+ pixel = PIXEL; \
+ for (l = LineCount; l != 0; l--, sp += GFX.PPL, Depth += GFX.PPL) \
{ \
- sp [z >> 1] = FUNCTION(sp + z, pixel); \
- Depth [z >> 1] = GFX.Z2; \
- }\
+ int32_t z; \
+ for (z = Pixels - 2; z >= 0; z -= 2) \
+ { \
+ if (GFX.Z1 > Depth [z]) \
+ { \
+ sp [z >> 1] = FUNCTION(sp + z, pixel); \
+ Depth [z >> 1] = GFX.Z2; \
+ } \
+ } \
+ } \
} \
- } \
- break; \
+ break; \
default: \
- break; \
+ break; \
}
#endif