Start making this suitable for MSVC and C89

This commit is contained in:
twinaphex 2017-08-11 17:43:00 +02:00
parent 1aecedc999
commit b9c74ceb13
25 changed files with 1385 additions and 1131 deletions

View File

@ -205,6 +205,27 @@ else ifeq ($(platform), gcw0)
LIBM :=
LOAD_FROM_MEMORY_TEST = 0
CFLAGS += -ffast-math -march=mips32 -mtune=mips32r2 -mhard-float
# Windows MSVC 2010 x86
else ifeq ($(platform), windows_msvc2010_x86)
CC = cl.exe
CXX = cl.exe
PATH := $(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../../VC/bin"):$(PATH)
PATH := $(PATH):$(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../IDE")
INCLUDE := $(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../../VC/include")
LIB := $(shell IFS=$$'\n'; cygpath -w "$(VS100COMNTOOLS)../../VC/lib")
BIN := $(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../../VC/bin")
WindowsSdkDir := $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A" -v "InstallationFolder" | grep -o '[A-Z]:\\.*')lib
WindowsSdkDir ?= $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1A" -v "InstallationFolder" | grep -o '[A-Z]:\\.*')lib
export INCLUDE := $(INCLUDE)
export LIB := $(LIB);$(WindowsSdkDir)
TARGET := $(TARGET_NAME)_libretro.dll
PSS_STYLE :=2
LDFLAGS += -DLL
OLD_GCC = 1
else
TARGET := $(TARGET_NAME)_libretro.dll
CC = gcc
@ -220,6 +241,32 @@ LIBRETRO_DIR := .
include Makefile.common
ifeq ($(OLD_GCC), 1)
WARNINGS := -Wall
else ifeq ($(NO_GCC), 1)
WARNINGS :=
else
WARNINGS := \
-Wall \
-Wno-sign-compare \
-Wno-unused-variable \
-Wno-unused-function \
-Wno-uninitialized \
-Wno-strict-aliasing \
-Wno-overflow \
-fno-strict-overflow
endif
ifeq ($(DEBUG),1)
FLAGS += -O0 -g
else
FLAGS += -O2 -DNDEBUG
endif
ifeq ($(PERF_TEST),1)
FLAGS += -DPERF_TEST
endif
ifeq ($(platform), psp1)
INCFLAGS += -I$(shell psp-config --pspsdk-path)/include
endif
@ -233,6 +280,16 @@ FLAGS += $(fpic)
CXXFLAGS += $(FLAGS)
CFLAGS += $(FLAGS)
ifneq (,$(findstring msvc,$(platform)))
OBJOUT = -Fo
LINKOUT = -out:
LD = link.exe
else
OBJOUT = -o
LINKOUT = -o
LD = $(CC)
endif
ifeq ($(platform), theos_ios)
COMMON_FLAGS := -DIOS $(COMMON_DEFINES) $(INCFLAGS) -I$(THEOS_INCLUDE_PATH) -Wno-error
$(LIBRARY_NAME)_CFLAGS += $(COMMON_FLAGS) $(CFLAGS)
@ -248,10 +305,10 @@ else
endif
%.o: %.cpp
$(CXX) -c -o $@ $< $(CXXFLAGS)
$(CXX) -c $(OBJOUT)$@ $< $(CXXFLAGS)
%.o: %.c
$(CC) -c -o $@ $< $(CFLAGS)
$(CC) -c $(OBJOUT)$@ $< $(CFLAGS)
clean:
rm -f $(TARGET) $(OBJECTS)

View File

@ -1,4 +1,6 @@
INCFLAGS := -I$(CORE_DIR) -I$(LIBRETRO_DIR)
LIBRETRO_COMM_DIR := $(LIBRETRO_DIR)/libretro-common
INCFLAGS := -I$(CORE_DIR) -I$(LIBRETRO_DIR) -I$(LIBRETRO_COMM_DIR)/include
ifeq ($(HAVE_GRIFFIN), 1)
SOURCES_C := $(CORE_DIR)/catsfc_griffin.c
@ -44,16 +46,6 @@ SOURCES_C := \
$(LIBRETRO_DIR)/libretro.c
endif
ifeq ($(DEBUG),1)
FLAGS += -O0 -g
else
FLAGS += -O3 -DNDEBUG
endif
ifeq ($(PERF_TEST),1)
FLAGS += -DPERF_TEST
endif
ifeq ($(USE_BLARGG_APU),1)
FLAGS += -DUSE_BLARGG_APU
endif
@ -62,20 +54,4 @@ ifeq ($(LOAD_FROM_MEMORY_TEST),1)
FLAGS += -DLOAD_FROM_MEMORY_TEST
endif
ifeq ($(OLD_GCC), 1)
WARNINGS := -Wall
else ifeq ($(NO_GCC), 1)
WARNINGS :=
else
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)

View File

@ -0,0 +1,39 @@
/* Copyright (C) 2010-2017 The RetroArch team
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (retro_inline.h).
* ---------------------------------------------------------------------------------------
*
* Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __LIBRETRO_SDK_INLINE_H
#define __LIBRETRO_SDK_INLINE_H
#ifndef INLINE
#if defined(_WIN32) || defined(__INTEL_COMPILER)
#define INLINE __inline
#elif defined(__STDC_VERSION__) && __STDC_VERSION__>=199901L
#define INLINE inline
#elif defined(__GNUC__)
#define INLINE __inline__
#else
#define INLINE
#endif
#endif
#endif

View File

@ -8,6 +8,8 @@
#include "port.h"
#include "spc700.h"
#include <retro_inline.h>
typedef struct
{
uint8_t* PC;
@ -47,14 +49,14 @@ typedef struct
SAPU APU;
SIAPU IAPU;
static inline void S9xAPUUnpackStatus(void)
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;
}
static inline void S9xAPUPackStatus(void)
static INLINE void S9xAPUPackStatus(void)
{
IAPU.Registers.P &= ~(Zero | Negative | Carry | Overflow);
if (IAPU._Carry)

View File

@ -55,14 +55,19 @@ const int16_t C4MulTable[256] =
int16_t C4_Sin(int16_t Angle)
{
int32_t S;
int16_t AngleS7;
if (Angle < 0)
{
if (Angle == -32768)
return 0;
return -C4_Sin(-Angle);
}
int16_t AngleS7 = Angle >> 7;
int32_t S = C4SinTable[AngleS7] + (C4MulTable[Angle & 0xff] * C4SinTable[0x80 + AngleS7] >> 15);
AngleS7 = Angle >> 7;
S = C4SinTable[AngleS7] + (C4MulTable[Angle & 0xff] * C4SinTable[0x80 + AngleS7] >> 15);
if (S > 32767)
S = 32767;
return (int16_t) S;
@ -70,14 +75,17 @@ int16_t C4_Sin(int16_t Angle)
int16_t C4_Cos(int16_t Angle)
{
int32_t S;
int16_t AngleS7;
if (Angle < 0)
{
if (Angle == -32768)
return -32768;
Angle = -Angle;
}
int16_t AngleS7 = Angle >> 7;
int32_t S = C4SinTable[0x80 + AngleS7] - (C4MulTable[Angle & 0xff] * C4SinTable[AngleS7] >> 15);
AngleS7 = Angle >> 7;
S = C4SinTable[0x80 + AngleS7] - (C4MulTable[Angle & 0xff] * C4SinTable[AngleS7] >> 15);
if (S < -32768)
S = -32767;
return (int16_t) S;
@ -104,11 +112,13 @@ const int16_t atantbl[256] = {
int16_t _atan2(int16_t x, int16_t y)
{
int32_t absAtan;
int32_t x1, y1;
if (x == 0)
return 0;
int32_t x1 = ABS(x), y1 = ABS(y);
int32_t absAtan;
x1 = ABS(x);
y1 = ABS(y);
if (x1 > y1)
absAtan = atantbl[(uint8_t)((y1 << 8) / x1)];

View File

@ -36,16 +36,15 @@ static uint8_t C4TestPattern [12 * 4] =
static void C4ConvOAM()
{
uint8_t* i;
uint8_t* OAMptr = Memory.C4RAM + (Memory.C4RAM[0x626] << 2);
for (i = Memory.C4RAM + 0x1fd; i > OAMptr; i -= 4)
*i = 0xe0; // Clear OAM-to-be
uint16_t globalX, globalY;
uint8_t* OAMptr2;
int16_t SprX, SprY;
uint8_t SprName, SprAttr;
uint8_t SprCount;
uint8_t* i;
uint8_t* OAMptr = Memory.C4RAM + (Memory.C4RAM[0x626] << 2);
for (i = Memory.C4RAM + 0x1fd; i > OAMptr; i -= 4)
*i = 0xe0; // Clear OAM-to-be
globalX = READ_WORD(Memory.C4RAM + 0x0621);
globalY = READ_WORD(Memory.C4RAM + 0x0623);
@ -53,14 +52,16 @@ static void C4ConvOAM()
if (Memory.C4RAM[0x0620] != 0)
{
uint8_t offset;
int32_t prio, i;
SprCount = 128 - Memory.C4RAM[0x626];
uint8_t offset = (Memory.C4RAM[0x626] & 3) * 2;
offset = (Memory.C4RAM[0x626] & 3) * 2;
for (prio = 0x30; prio >= 0; prio -= 0x10)
{
uint8_t* srcptr = Memory.C4RAM + 0x220;
for (i = Memory.C4RAM[0x0620]; i > 0 && SprCount > 0; i--, srcptr += 16)
{
uint8_t *sprptr;
if ((srcptr[4] & 0x30) != prio)
continue;
SprX = READ_WORD(srcptr) - globalX;
@ -68,7 +69,7 @@ static void C4ConvOAM()
SprName = srcptr[5];
SprAttr = srcptr[4] | srcptr[0x06]; // XXX: mask bits?
uint8_t* sprptr = S9xGetMemPointer(READ_3WORD(srcptr + 7));
sprptr = S9xGetMemPointer(READ_3WORD(srcptr + 7));
if (*sprptr != 0)
{
int32_t SprCnt;
@ -130,12 +131,21 @@ static void C4ConvOAM()
static void C4DoScaleRotate(int32_t row_padding)
{
int16_t A, B, C, D;
int32_t YScale;
uint8_t w, h;
int32_t Cx, Cy;
int32_t LineX, LineY;
uint32_t X, Y;
uint8_t byte;
int32_t outidx = 0;
int32_t x, y;
uint8_t bit = 0x80;
// Calculate matrix
int32_t XScale = READ_WORD(Memory.C4RAM + 0x1f8f);
if (XScale & 0x8000)
XScale = 0x7fff;
int32_t YScale = READ_WORD(Memory.C4RAM + 0x1f92);
YScale = READ_WORD(Memory.C4RAM + 0x1f92);
if (YScale & 0x8000)
YScale = 0x7fff;
@ -182,28 +192,23 @@ static void C4DoScaleRotate(int32_t row_padding)
}
// Calculate Pixel Resolution
uint8_t w = Memory.C4RAM[0x1f89] & ~7;
uint8_t h = Memory.C4RAM[0x1f8c] & ~7;
w = Memory.C4RAM[0x1f89] & ~7;
h = Memory.C4RAM[0x1f8c] & ~7;
// Clear the output RAM
memset(Memory.C4RAM, 0, (w + row_padding / 4)*h / 2);
int32_t Cx = (int16_t)READ_WORD(Memory.C4RAM + 0x1f83);
int32_t Cy = (int16_t)READ_WORD(Memory.C4RAM + 0x1f86);
Cx = (int16_t)READ_WORD(Memory.C4RAM + 0x1f83);
Cy = (int16_t)READ_WORD(Memory.C4RAM + 0x1f86);
// Calculate start position (i.e. (Ox, Oy) = (0, 0))
// The low 12 bits are fractional, so (Cx<<12) gives us the Cx we want in
// the function. We do Cx*A etc normally because the matrix parameters
// already have the fractional parts.
int32_t LineX = (Cx << 12) - Cx * A - Cx * B;
int32_t LineY = (Cy << 12) - Cy * C - Cy * D;
LineX = (Cx << 12) - Cx * A - Cx * B;
LineY = (Cy << 12) - Cy * C - Cy * D;
// Start loop
uint32_t X, Y;
uint8_t byte;
int32_t outidx = 0;
int32_t x, y;
uint8_t bit = 0x80;
for (y = 0; y < h; y++)
{
X = LineX;
@ -252,6 +257,8 @@ static void C4DoScaleRotate(int32_t row_padding)
static void C4DrawLine(int32_t X1, int32_t Y1, int16_t Z1, int32_t X2, int32_t Y2, int16_t Z2, uint8_t Color)
{
int32_t i;
// Transform coordinates
C4WFXVal = (int16_t)X1;
C4WFYVal = (int16_t)Y1;
@ -281,7 +288,6 @@ static void C4DrawLine(int32_t X1, int32_t Y1, int16_t Z1, int32_t X2, int32_t Y
Y2 = (int16_t)C4WFYVal;
// render line
int32_t i;
for (i = C4WFDist ? C4WFDist : 1; i > 0; i--)
{
//.loop
@ -336,15 +342,17 @@ static void C4DrawWireFrame()
static void C4TransformLines()
{
int32_t i;
uint8_t *ptr;
uint8_t* ptr2;
C4WFX2Val = Memory.C4RAM[0x1f83];
C4WFY2Val = Memory.C4RAM[0x1f86];
C4WFDist = Memory.C4RAM[0x1f89];
C4WFScale = Memory.C4RAM[0x1f8c];
int32_t i;
// transform vertices
uint8_t* ptr = Memory.C4RAM;
ptr = Memory.C4RAM;
{
for (i = READ_WORD(Memory.C4RAM + 0x1f80); i > 0; i--, ptr += 0x10)
{
@ -365,8 +373,8 @@ static void C4TransformLines()
WRITE_WORD(Memory.C4RAM + 0x602 + 8, 0x60);
WRITE_WORD(Memory.C4RAM + 0x605 + 8, 0x40);
ptr = Memory.C4RAM + 0xb02;
uint8_t* ptr2 = Memory.C4RAM;
ptr = Memory.C4RAM + 0xb02;
ptr2 = Memory.C4RAM;
for (i = READ_WORD(Memory.C4RAM + 0xb00); i > 0; i--, ptr += 2, ptr2 += 8)
{
@ -450,25 +458,18 @@ static void C4BitPlaneWave()
static void C4SprDisintegrate()
{
uint8_t width, height;
uint32_t StartX, StartY;
uint8_t* src;
int32_t scaleX, scaleY;
int32_t Cx, Cy;
width = Memory.C4RAM[0x1f89];
height = Memory.C4RAM[0x1f8c];
Cx = (int16_t)READ_WORD(Memory.C4RAM + 0x1f80);
Cy = (int16_t)READ_WORD(Memory.C4RAM + 0x1f83);
scaleX = (int16_t)READ_WORD(Memory.C4RAM + 0x1f86);
scaleY = (int16_t)READ_WORD(Memory.C4RAM + 0x1f8f);
StartX = -Cx * scaleX + (Cx << 8);
StartY = -Cy * scaleY + (Cy << 8);
src = Memory.C4RAM + 0x600;
uint32_t x, y, i, j;
uint8_t width = Memory.C4RAM[0x1f89];
uint8_t height = Memory.C4RAM[0x1f8c];
int32_t Cx = (int16_t)READ_WORD(Memory.C4RAM + 0x1f80);
int32_t Cy = (int16_t)READ_WORD(Memory.C4RAM + 0x1f83);
int32_t scaleX = (int16_t)READ_WORD(Memory.C4RAM + 0x1f86);
int32_t scaleY = (int16_t)READ_WORD(Memory.C4RAM + 0x1f8f);
uint32_t StartX = -Cx * scaleX + (Cx << 8);
uint32_t StartY = -Cy * scaleY + (Cy << 8);
uint8_t *src = Memory.C4RAM + 0x600;
memset(Memory.C4RAM, 0, width * height / 2);
uint32_t x, y, i, j;
for (y = StartY, i = 0; i < height; i++, y += scaleY)
{
for (x = StartX, j = 0; j < width; j++, x += scaleX)

View File

@ -33,6 +33,7 @@ const char* S9xProActionReplayToRaw(const char* code, uint32_t* address, uint8_t
const char* S9xGoldFingerToRaw(const char* code, uint32_t* address, bool* sram, uint8_t* num_bytes, uint8_t bytes[3])
{
int32_t i;
char tmp [15];
if (strlen(code) != 14)
return "Invalid Gold Finger code should be 14 hex digits in length.";
@ -42,12 +43,11 @@ const char* S9xGoldFingerToRaw(const char* code, uint32_t* address, bool* sram,
if (sscanf(tmp, "%x", address) != 1)
return "Invalid Gold Finger code.";
int32_t i;
for (i = 0; i < 3; i++)
{
int32_t byte;
strncpy(tmp, code + 5 + i * 2, 2);
tmp [2] = 0;
int32_t byte;
if (sscanf(tmp, "%x", &byte) != 1)
break;
bytes [i] = (uint8_t) byte;
@ -60,6 +60,10 @@ const char* S9xGoldFingerToRaw(const char* code, uint32_t* address, bool* sram,
const char* S9xGameGenieToRaw(const char* code, uint32_t* address, uint8_t* byte)
{
char new_code [12];
static char* real_hex = "0123456789ABCDEF";
static char* genie_hex = "DF4709156BC8A23E";
uint32_t data = 0;
int32_t i;
if (strlen(code) != 9 || *(code + 4) != '-' || !S9xAllHex(code, 4) || !S9xAllHex(code + 5, 4))
return "Invalid Game Genie(tm) code - should be 'xxxx-xxxx'.";
@ -68,15 +72,11 @@ const char* S9xGameGenieToRaw(const char* code, uint32_t* address, uint8_t* byte
strncpy(new_code + 2, code, 4);
strcpy(new_code + 6, code + 5);
static char* real_hex = "0123456789ABCDEF";
static char* genie_hex = "DF4709156BC8A23E";
int32_t i;
for (i = 2; i < 10; i++)
{
int32_t j;
if (islower(new_code [i]))
new_code [i] = toupper(new_code [i]);
int32_t j;
for (j = 0; j < 16; j++)
{
if (new_code [i] == genie_hex [j])
@ -88,7 +88,6 @@ const char* S9xGameGenieToRaw(const char* code, uint32_t* address, uint8_t* byte
if (j == 16)
return "Invalid hex-character in Game Genie(tm) code";
}
uint32_t data = 0;
sscanf(new_code, "%x", &data);
*byte = (uint8_t)(data >> 24);
*address = ((data & 0x003c00) << 10) +
@ -148,6 +147,7 @@ void S9xSearchForChange(SCheatData* d, S9xCheatComparisonType cmp,
S9xCheatDataSize size, bool is_signed, bool update)
{
int32_t l;
int32_t i;
switch (size)
{
@ -166,7 +166,6 @@ void S9xSearchForChange(SCheatData* d, S9xCheatComparisonType cmp,
break;
}
int32_t i;
if (is_signed)
{
for (i = 0; i < 0x20000 - l; i++)
@ -250,6 +249,7 @@ void S9xSearchForValue(SCheatData* d, S9xCheatComparisonType cmp,
bool is_signed, bool update)
{
int32_t l;
int32_t i;
switch (size)
{
@ -268,7 +268,6 @@ void S9xSearchForValue(SCheatData* d, S9xCheatComparisonType cmp,
break;
}
int32_t i;
if (is_signed)
{

View File

@ -9,7 +9,7 @@
extern SCheatData Cheat;
void S9xInitCheatData()
void S9xInitCheatData(void)
{
Cheat.RAM = Memory.RAM;
Cheat.SRAM = Memory.SRAM;
@ -47,7 +47,7 @@ void S9xDeleteCheat(uint32_t which1)
}
}
void S9xDeleteCheats()
void S9xDeleteCheats(void)
{
S9xRemoveCheats();
Cheat.num_cheats = 0;
@ -91,13 +91,15 @@ void S9xRemoveCheat(uint32_t which1)
void S9xApplyCheat(uint32_t which1)
{
int32_t block;
uint8_t *ptr;
uint32_t address = Cheat.c [which1].address;
if (!Cheat.c [which1].saved)
Cheat.c [which1].saved_byte = S9xGetByte(address);
int32_t block = (address >> MEMMAP_SHIFT) & MEMMAP_MASK;
uint8_t* ptr = Memory.Map [block];
block = (address >> MEMMAP_SHIFT) & MEMMAP_MASK;
ptr = Memory.Map [block];
if (ptr >= (uint8_t*) MAP_LAST)
*(ptr + (address & 0xffff)) = Cheat.c [which1].byte;
@ -106,7 +108,7 @@ void S9xApplyCheat(uint32_t which1)
Cheat.c [which1].saved = true;
}
void S9xApplyCheats()
void S9xApplyCheats(void)
{
uint32_t i;
if (Settings.ApplyCheats)
@ -117,7 +119,7 @@ void S9xApplyCheats()
}
}
void S9xRemoveCheats()
void S9xRemoveCheats(void)
{
uint32_t i;
for (i = 0; i < Cheat.num_cheats; i++)
@ -127,10 +129,12 @@ void S9xRemoveCheats()
bool S9xLoadCheatFile(const char* filename)
{
uint8_t data [8 + MAX_SFCCHEAT_NAME];
FILE* fs = NULL;
Cheat.num_cheats = 0;
FILE* fs = fopen(filename, "rb");
uint8_t data [8 + MAX_SFCCHEAT_NAME];
fs = fopen(filename, "rb");
if (!fs)
return (false);
@ -159,19 +163,21 @@ bool S9xLoadCheatFile(const char* filename)
bool S9xSaveCheatFile(const char* filename)
{
uint32_t i;
uint8_t data [8 + MAX_SFCCHEAT_NAME];
FILE* fs = NULL;
if (Cheat.num_cheats == 0)
{
(void) remove(filename);
return (true);
}
FILE* fs = fopen(filename, "wb");
uint8_t data [8 + MAX_SFCCHEAT_NAME];
fs = fopen(filename, "wb");
if (!fs)
return (false);
uint32_t i;
for (i = 0; i < Cheat.num_cheats; i++)
{
memset(data, 0, 8 + MAX_SFCCHEAT_NAME);

View File

@ -3,21 +3,23 @@
#ifndef _CPUADDR_H_
#define _CPUADDR_H_
#include <retro_inline.h>
extern int32_t OpAddress;
static inline void Immediate8()
static INLINE void Immediate8(void)
{
OpAddress = ICPU.ShiftedPB + CPU.PC - CPU.PCBase;
CPU.PC++;
}
static inline void Immediate16()
static INLINE void Immediate16()
{
OpAddress = ICPU.ShiftedPB + CPU.PC - CPU.PCBase;
CPU.PC += 2;
}
static inline void Relative()
static INLINE void Relative()
{
int8_t Int8 = *CPU.PC++;
#ifndef SA1_OPCODES
@ -26,7 +28,7 @@ static inline void Relative()
OpAddress = ((int32_t)(CPU.PC - CPU.PCBase) + Int8) & 0xffff;
}
static inline void RelativeLong()
static INLINE void RelativeLong()
{
#ifdef FAST_LSB_WORD_ACCESS
OpAddress = *(uint16_t*) CPU.PC;
@ -41,7 +43,7 @@ static inline void RelativeLong()
OpAddress &= 0xffff;
}
static inline void AbsoluteIndexedIndirect(bool read)
static INLINE void AbsoluteIndexedIndirect(bool read)
{
#ifdef FAST_LSB_WORD_ACCESS
OpAddress = (ICPU.Registers.X.W + * (uint16_t*) CPU.PC) & 0xffff;
@ -58,7 +60,7 @@ static inline void AbsoluteIndexedIndirect(bool read)
OpenBus = (uint8_t)(OpAddress >> 8);
}
static inline void AbsoluteIndirectLong(bool read)
static INLINE void AbsoluteIndirectLong(bool read)
{
#ifdef FAST_LSB_WORD_ACCESS
OpAddress = *(uint16_t*) CPU.PC;
@ -76,7 +78,7 @@ static inline void AbsoluteIndirectLong(bool read)
OpAddress = S9xGetWord(OpAddress) | (S9xGetByte(OpAddress + 2) << 16);
}
static inline void AbsoluteIndirect(bool read)
static INLINE void AbsoluteIndirect(bool read)
{
#ifdef FAST_LSB_WORD_ACCESS
OpAddress = *(uint16_t*) CPU.PC;
@ -94,7 +96,7 @@ static inline void AbsoluteIndirect(bool read)
OpAddress += ICPU.ShiftedPB;
}
static inline void Absolute(bool read)
static INLINE void Absolute(bool read)
{
#ifdef FAST_LSB_WORD_ACCESS
OpAddress = *(uint16_t*) CPU.PC + ICPU.ShiftedDB;
@ -109,7 +111,7 @@ static inline void Absolute(bool read)
#endif
}
static inline void AbsoluteLong(bool read)
static INLINE void AbsoluteLong(bool read)
{
#ifdef FAST_LSB_WORD_ACCESS
OpAddress = (*(uint32_t*) CPU.PC) & 0xffffff;
@ -129,7 +131,7 @@ static inline void AbsoluteLong(bool read)
#endif
}
static inline void Direct(bool read)
static INLINE void Direct(bool read)
{
if (read)
OpenBus = *CPU.PC;
@ -139,7 +141,7 @@ static inline void Direct(bool read)
#endif
}
static inline void DirectIndirectIndexed(bool read)
static INLINE void DirectIndirectIndexed(bool read)
{
OpenBus = *CPU.PC;
OpAddress = (*CPU.PC++ + ICPU.Registers.D.W) & 0xffff;
@ -155,7 +157,7 @@ static inline void DirectIndirectIndexed(bool read)
// XXX: else Add one cycle if crosses page boundary
}
static inline void DirectIndirectIndexedLong(bool read)
static INLINE void DirectIndirectIndexedLong(bool read)
{
OpenBus = *CPU.PC;
OpAddress = (*CPU.PC++ + ICPU.Registers.D.W) & 0xffff;
@ -168,7 +170,7 @@ static inline void DirectIndirectIndexedLong(bool read)
OpAddress = S9xGetWord(OpAddress) + (S9xGetByte(OpAddress + 2) << 16) + ICPU.Registers.Y.W;
}
static inline void DirectIndexedIndirect(bool read)
static INLINE void DirectIndexedIndirect(bool read)
{
OpenBus = *CPU.PC;
OpAddress = (*CPU.PC++ + ICPU.Registers.D.W + ICPU.Registers.X.W) & 0xffff;
@ -184,7 +186,7 @@ static inline void DirectIndexedIndirect(bool read)
#endif
}
static inline void DirectIndexedX(bool read)
static INLINE void DirectIndexedX(bool read)
{
if (read)
OpenBus = *CPU.PC;
@ -195,7 +197,7 @@ static inline void DirectIndexedX(bool read)
#endif
}
static inline void DirectIndexedY(bool read)
static INLINE void DirectIndexedY(bool read)
{
if (read)
OpenBus = *CPU.PC;
@ -206,7 +208,7 @@ static inline void DirectIndexedY(bool read)
#endif
}
static inline void AbsoluteIndexedX(bool read)
static INLINE void AbsoluteIndexedX(bool read)
{
#ifdef FAST_LSB_WORD_ACCESS
OpAddress = ICPU.ShiftedDB + *(uint16_t*) CPU.PC + ICPU.Registers.X.W;
@ -223,7 +225,7 @@ static inline void AbsoluteIndexedX(bool read)
// XXX: else is cross page boundary add one cycle
}
static inline void AbsoluteIndexedY(bool read)
static INLINE void AbsoluteIndexedY(bool read)
{
#ifdef FAST_LSB_WORD_ACCESS
OpAddress = ICPU.ShiftedDB + *(uint16_t*) CPU.PC + ICPU.Registers.Y.W;
@ -240,7 +242,7 @@ static inline void AbsoluteIndexedY(bool read)
// XXX: else is cross page boundary add one cycle
}
static inline void AbsoluteLongIndexedX(bool read)
static INLINE void AbsoluteLongIndexedX(bool read)
{
#ifdef FAST_LSB_WORD_ACCESS
OpAddress = (*(uint32_t*) CPU.PC + ICPU.Registers.X.W) & 0xffffff;
@ -260,7 +262,7 @@ static inline void AbsoluteLongIndexedX(bool read)
#endif
}
static inline void DirectIndirect(bool read)
static INLINE void DirectIndirect(bool read)
{
OpenBus = *CPU.PC;
OpAddress = (*CPU.PC++ + ICPU.Registers.D.W) & 0xffff;
@ -273,7 +275,7 @@ static inline void DirectIndirect(bool read)
OpAddress += ICPU.ShiftedDB;
}
static inline void DirectIndirectLong(bool read)
static INLINE void DirectIndirectLong(bool read)
{
OpenBus = *CPU.PC;
OpAddress = (*CPU.PC++ + ICPU.Registers.D.W) & 0xffff;
@ -286,7 +288,7 @@ static inline void DirectIndirectLong(bool read)
OpAddress = S9xGetWord(OpAddress) + (S9xGetByte(OpAddress + 2) << 16);
}
static inline void StackRelative(bool read)
static INLINE void StackRelative(bool read)
{
if (read)
OpenBus = *CPU.PC;
@ -296,7 +298,7 @@ static inline void StackRelative(bool read)
#endif
}
static inline void StackRelativeIndirectIndexed(bool read)
static INLINE void StackRelativeIndirectIndexed(bool read)
{
OpenBus = *CPU.PC;
OpAddress = (*CPU.PC++ + ICPU.Registers.S.W) & 0xffff;

View File

@ -366,9 +366,10 @@ void S9xDoHBlankProcessing_SFX()
if (!PPU.ForcedBlanking)
{
uint8_t tmp = 0;
PPU.OAMAddr = PPU.SavedOAMAddr;
uint8_t tmp = 0;
if (PPU.OAMPriorityRotation)
tmp = (PPU.OAMAddr & 0xFE) >> 1;
if ((PPU.OAMFlip & 1) || PPU.FirstSprite != tmp)
@ -499,9 +500,10 @@ void S9xDoHBlankProcessing_NoSFX()
if (!PPU.ForcedBlanking)
{
uint8_t tmp = 0;
PPU.OAMAddr = PPU.SavedOAMAddr;
uint8_t tmp = 0;
if (PPU.OAMPriorityRotation)
tmp = (PPU.OAMAddr & 0xFE) >> 1;
if ((PPU.OAMFlip & 1) || PPU.FirstSprite != tmp)

View File

@ -6,15 +6,16 @@
typedef struct
{
#ifdef __WIN32__
void (__cdecl* S9xOpcode)();
void (__cdecl* S9xOpcode)(void);
#else
void (*S9xOpcode)();
void (*S9xOpcode)(void);
#endif
} SOpcodes;
#include "ppu.h"
#include "memmap.h"
#include "65c816.h"
#include <retro_inline.h>
#define DO_HBLANK_CHECK_SFX() \
if (CPU.Cycles >= CPU.NextEvent) \
@ -57,7 +58,7 @@ extern SOpcodes S9xOpcodesM0X0 [256];
extern SICPU ICPU;
static inline void S9xUnpackStatus()
static INLINE void S9xUnpackStatus(void)
{
ICPU._Zero = (ICPU.Registers.PL & Zero) == 0;
ICPU._Negative = (ICPU.Registers.PL & Negative);
@ -65,20 +66,20 @@ static inline void S9xUnpackStatus()
ICPU._Overflow = (ICPU.Registers.PL & Overflow) >> 6;
}
static inline void S9xPackStatus()
static INLINE void S9xPackStatus(void)
{
ICPU.Registers.PL &= ~(Zero | Negative | Carry | Overflow);
ICPU.Registers.PL |= ICPU._Carry | ((ICPU._Zero == 0) << 1) | (ICPU._Negative & 0x80) | (ICPU._Overflow << 6);
}
static inline void CLEAR_IRQ_SOURCE(uint32_t M)
static INLINE void CLEAR_IRQ_SOURCE(uint32_t M)
{
CPU.IRQActive &= ~M;
if (!CPU.IRQActive)
CPU.Flags &= ~IRQ_PENDING_FLAG;
}
static inline void S9xFixCycles()
static INLINE void S9xFixCycles(void)
{
if (CheckEmulation())
ICPU.S9xOpcodes = S9xOpcodesE1;
@ -98,7 +99,7 @@ static inline void S9xFixCycles()
}
}
static inline void S9xReschedule()
static INLINE void S9xReschedule(void)
{
uint8_t which;
int32_t max;

View File

@ -3,26 +3,29 @@
#ifndef _CPUMACRO_H_
#define _CPUMACRO_H_
#include <retro_inline.h>
extern int32_t OpAddress;
static inline void SetZN16(uint16_t Work)
static INLINE void SetZN16(uint16_t Work)
{
ICPU._Zero = Work != 0;
ICPU._Negative = (uint8_t)(Work >> 8);
}
static inline void SetZN8(uint8_t Work)
static INLINE void SetZN8(uint8_t Work)
{
ICPU._Zero = Work;
ICPU._Negative = Work;
}
static inline void ADC8()
static INLINE void ADC8()
{
uint8_t Work8 = S9xGetByte(OpAddress);
if (CheckDecimal())
{
uint8_t Ans8;
uint8_t A1 = (ICPU.Registers.A.W) & 0x0f;
uint8_t A2 = (ICPU.Registers.A.W) & 0xf0;
uint8_t W1 = Work8 & 0x0f;
@ -44,7 +47,7 @@ static inline void ADC8()
else
ClearCarry();
uint8_t Ans8 = A2 | A1;
Ans8 = A2 | A1;
if (~(ICPU.Registers.AL ^ Work8) & (Work8 ^ Ans8) & 0x80)
SetOverflow();
else
@ -64,12 +67,13 @@ static inline void ADC8()
SetZN8(ICPU.Registers.AL);
}
static inline void ADC16()
static INLINE void ADC16()
{
uint16_t Work16 = S9xGetWord(OpAddress);
if (CheckDecimal())
{
uint16_t Ans16;
uint16_t A1 = ICPU.Registers.A.W & 0x000f;
uint16_t A2 = ICPU.Registers.A.W & 0x00f0;
uint16_t A3 = ICPU.Registers.A.W & 0x0f00;
@ -109,7 +113,7 @@ static inline void ADC16()
else
ClearCarry();
uint16_t Ans16 = A4 | A3 | A2 | A1;
Ans16 = A4 | A3 | A2 | A1;
if (~(ICPU.Registers.A.W ^ Work16) & (Work16 ^ Ans16) & 0x8000)
SetOverflow();
else
@ -130,19 +134,19 @@ static inline void ADC16()
SetZN16(ICPU.Registers.A.W);
}
static inline void AND16()
static INLINE void AND16()
{
ICPU.Registers.A.W &= S9xGetWord(OpAddress);
SetZN16(ICPU.Registers.A.W);
}
static inline void AND8()
static INLINE void AND8()
{
ICPU.Registers.AL &= S9xGetByte(OpAddress);
SetZN8(ICPU.Registers.AL);
}
static inline void A_ASL16()
static INLINE void A_ASL16()
{
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
@ -152,7 +156,7 @@ static inline void A_ASL16()
SetZN16(ICPU.Registers.A.W);
}
static inline void A_ASL8()
static INLINE void A_ASL8()
{
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
@ -162,12 +166,13 @@ static inline void A_ASL8()
SetZN8(ICPU.Registers.AL);
}
static inline void ASL16()
static INLINE void ASL16()
{
uint16_t Work16;
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#endif
uint16_t Work16 = S9xGetWord(OpAddress);
Work16 = S9xGetWord(OpAddress);
ICPU._Carry = (Work16 & 0x8000) != 0;
Work16 <<= 1;
S9xSetByte(Work16 >> 8, OpAddress + 1);
@ -175,19 +180,20 @@ static inline void ASL16()
SetZN16(Work16);
}
static inline void ASL8()
static INLINE void ASL8()
{
uint8_t Work8;
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#endif
uint8_t Work8 = S9xGetByte(OpAddress);
Work8 = S9xGetByte(OpAddress);
ICPU._Carry = (Work8 & 0x80) != 0;
Work8 <<= 1;
S9xSetByte(Work8, OpAddress);
SetZN8(Work8);
}
static inline void BIT16()
static INLINE void BIT16()
{
uint16_t Work16 = S9xGetWord(OpAddress);
ICPU._Overflow = (Work16 & 0x4000) != 0;
@ -195,7 +201,7 @@ static inline void BIT16()
ICPU._Zero = (Work16 & ICPU.Registers.A.W) != 0;
}
static inline void BIT8()
static INLINE void BIT8()
{
uint8_t Work8 = S9xGetByte(OpAddress);
ICPU._Overflow = (Work8 & 0x40) != 0;
@ -203,49 +209,49 @@ static inline void BIT8()
ICPU._Zero = Work8 & ICPU.Registers.AL;
}
static inline void CMP16()
static INLINE void CMP16()
{
int32_t Int32 = (int32_t) ICPU.Registers.A.W - (int32_t) S9xGetWord(OpAddress);
ICPU._Carry = Int32 >= 0;
SetZN16((uint16_t) Int32);
}
static inline void CMP8()
static INLINE void CMP8()
{
int16_t Int16 = (int16_t) ICPU.Registers.AL - (int16_t) S9xGetByte(OpAddress);
ICPU._Carry = Int16 >= 0;
SetZN8((uint8_t) Int16);
}
static inline void CMX16()
static INLINE void CMX16()
{
int32_t Int32 = (int32_t) ICPU.Registers.X.W - (int32_t) S9xGetWord(OpAddress);
ICPU._Carry = Int32 >= 0;
SetZN16((uint16_t) Int32);
}
static inline void CMX8()
static INLINE void CMX8()
{
int16_t Int16 = (int16_t) ICPU.Registers.XL - (int16_t) S9xGetByte(OpAddress);
ICPU._Carry = Int16 >= 0;
SetZN8((uint8_t) Int16);
}
static inline void CMY16()
static INLINE void CMY16()
{
int32_t Int32 = (int32_t) ICPU.Registers.Y.W - (int32_t) S9xGetWord(OpAddress);
ICPU._Carry = Int32 >= 0;
SetZN16((uint16_t) Int32);
}
static inline void CMY8()
static INLINE void CMY8()
{
int16_t Int16 = (int16_t) ICPU.Registers.YL - (int16_t) S9xGetByte(OpAddress);
ICPU._Carry = Int16 >= 0;
SetZN8((uint8_t) Int16);
}
static inline void A_DEC16()
static INLINE void A_DEC16()
{
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
@ -255,7 +261,7 @@ static inline void A_DEC16()
SetZN16(ICPU.Registers.A.W);
}
static inline void A_DEC8()
static INLINE void A_DEC8()
{
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
@ -265,42 +271,46 @@ static inline void A_DEC8()
SetZN8(ICPU.Registers.AL);
}
static inline void DEC16()
static INLINE void DEC16()
{
uint16_t Work16;
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#endif
CPU.WaitAddress = NULL;
uint16_t Work16 = S9xGetWord(OpAddress) - 1;
Work16 = S9xGetWord(OpAddress) - 1;
S9xSetByte(Work16 >> 8, OpAddress + 1);
S9xSetByte(Work16 & 0xFF, OpAddress);
SetZN16(Work16);
}
static inline void DEC8()
static INLINE void DEC8()
{
uint8_t Work8;
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#endif
CPU.WaitAddress = NULL;
uint8_t Work8 = S9xGetByte(OpAddress) - 1;
Work8 = S9xGetByte(OpAddress) - 1;
S9xSetByte(Work8, OpAddress);
SetZN8(Work8);
}
static inline void EOR16()
static INLINE void EOR16()
{
ICPU.Registers.A.W ^= S9xGetWord(OpAddress);
SetZN16(ICPU.Registers.A.W);
}
static inline void EOR8()
static INLINE void EOR8()
{
ICPU.Registers.AL ^= S9xGetByte(OpAddress);
SetZN8(ICPU.Registers.AL);
}
static inline void A_INC16()
static INLINE void A_INC16()
{
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
@ -310,7 +320,7 @@ static inline void A_INC16()
SetZN16(ICPU.Registers.A.W);
}
static inline void A_INC8()
static INLINE void A_INC8()
{
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
@ -320,66 +330,69 @@ static inline void A_INC8()
SetZN8(ICPU.Registers.AL);
}
static inline void INC16()
static INLINE void INC16()
{
uint16_t Work16;
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#endif
CPU.WaitAddress = NULL;
uint16_t Work16 = S9xGetWord(OpAddress) + 1;
Work16 = S9xGetWord(OpAddress) + 1;
S9xSetByte(Work16 >> 8, OpAddress + 1);
S9xSetByte(Work16 & 0xFF, OpAddress);
SetZN16(Work16);
}
static inline void INC8()
static INLINE void INC8()
{
uint8_t Work8;
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#endif
CPU.WaitAddress = NULL;
uint8_t Work8 = S9xGetByte(OpAddress) + 1;
Work8 = S9xGetByte(OpAddress) + 1;
S9xSetByte(Work8, OpAddress);
SetZN8(Work8);
}
static inline void LDA16()
static INLINE void LDA16()
{
ICPU.Registers.A.W = S9xGetWord(OpAddress);
SetZN16(ICPU.Registers.A.W);
}
static inline void LDA8()
static INLINE void LDA8()
{
ICPU.Registers.AL = S9xGetByte(OpAddress);
SetZN8(ICPU.Registers.AL);
}
static inline void LDX16()
static INLINE void LDX16()
{
ICPU.Registers.X.W = S9xGetWord(OpAddress);
SetZN16(ICPU.Registers.X.W);
}
static inline void LDX8()
static INLINE void LDX8()
{
ICPU.Registers.XL = S9xGetByte(OpAddress);
SetZN8(ICPU.Registers.XL);
}
static inline void LDY16()
static INLINE void LDY16()
{
ICPU.Registers.Y.W = S9xGetWord(OpAddress);
SetZN16(ICPU.Registers.Y.W);
}
static inline void LDY8()
static INLINE void LDY8()
{
ICPU.Registers.YL = S9xGetByte(OpAddress);
SetZN8(ICPU.Registers.YL);
}
static inline void A_LSR16()
static INLINE void A_LSR16()
{
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
@ -389,7 +402,7 @@ static inline void A_LSR16()
SetZN16(ICPU.Registers.A.W);
}
static inline void A_LSR8()
static INLINE void A_LSR8()
{
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
@ -399,12 +412,14 @@ static inline void A_LSR8()
SetZN8(ICPU.Registers.AL);
}
static inline void LSR16()
static INLINE void LSR16()
{
uint16_t Work16;
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#endif
uint16_t Work16 = S9xGetWord(OpAddress);
Work16 = S9xGetWord(OpAddress);
ICPU._Carry = Work16 & 1;
Work16 >>= 1;
S9xSetByte(Work16 >> 8, OpAddress + 1);
@ -412,47 +427,51 @@ static inline void LSR16()
SetZN16(Work16);
}
static inline void LSR8()
static INLINE void LSR8()
{
uint8_t Work8;
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#endif
uint8_t Work8 = S9xGetByte(OpAddress);
Work8 = S9xGetByte(OpAddress);
ICPU._Carry = Work8 & 1;
Work8 >>= 1;
S9xSetByte(Work8, OpAddress);
SetZN8(Work8);
}
static inline void ORA16()
static INLINE void ORA16()
{
ICPU.Registers.A.W |= S9xGetWord(OpAddress);
SetZN16(ICPU.Registers.A.W);
}
static inline void ORA8()
static INLINE void ORA8()
{
ICPU.Registers.AL |= S9xGetByte(OpAddress);
SetZN8(ICPU.Registers.AL);
}
static inline void A_ROL16()
static INLINE void A_ROL16()
{
uint32_t Work32;
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#endif
uint32_t Work32 = (ICPU.Registers.A.W << 1) | CheckCarry();
Work32 = (ICPU.Registers.A.W << 1) | CheckCarry();
ICPU._Carry = Work32 > 0xffff;
ICPU.Registers.A.W = (uint16_t) Work32;
SetZN16((uint16_t) Work32);
}
static inline void A_ROL8()
static INLINE void A_ROL8()
{
uint16_t Work16;
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#endif
uint16_t Work16 = ICPU.Registers.AL;
Work16 = ICPU.Registers.AL;
Work16 <<= 1;
Work16 |= CheckCarry();
ICPU._Carry = Work16 > 0xff;
@ -460,12 +479,14 @@ static inline void A_ROL8()
SetZN8((uint8_t) Work16);
}
static inline void ROL16()
static INLINE void ROL16()
{
uint32_t Work32;
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#endif
uint32_t Work32 = S9xGetWord(OpAddress);
Work32 = S9xGetWord(OpAddress);
Work32 <<= 1;
Work32 |= CheckCarry();
ICPU._Carry = Work32 > 0xffff;
@ -474,12 +495,13 @@ static inline void ROL16()
SetZN16((uint16_t) Work32);
}
static inline void ROL8()
static INLINE void ROL8()
{
uint16_t Work16;
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#endif
uint16_t Work16 = S9xGetByte(OpAddress);
Work16 = S9xGetByte(OpAddress);
Work16 <<= 1;
Work16 |= CheckCarry();
ICPU._Carry = Work16 > 0xff;
@ -487,12 +509,13 @@ static inline void ROL8()
SetZN8((uint8_t) Work16);
}
static inline void A_ROR16()
static INLINE void A_ROR16()
{
uint32_t Work32;
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#endif
uint32_t Work32 = ICPU.Registers.A.W;
Work32 = ICPU.Registers.A.W;
Work32 |= (int32_t) CheckCarry() << 16;
ICPU._Carry = (uint8_t)(Work32 & 1);
Work32 >>= 1;
@ -500,24 +523,27 @@ static inline void A_ROR16()
SetZN16((uint16_t) Work32);
}
static inline void A_ROR8()
static INLINE void A_ROR8()
{
uint16_t Work16;
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#endif
uint16_t Work16 = ICPU.Registers.AL | ((uint16_t) CheckCarry() << 8);
Work16 = ICPU.Registers.AL | ((uint16_t) CheckCarry() << 8);
ICPU._Carry = (uint8_t) Work16 & 1;
Work16 >>= 1;
ICPU.Registers.AL = (uint8_t) Work16;
SetZN8((uint8_t) Work16);
}
static inline void ROR16()
static INLINE void ROR16()
{
uint32_t Work32;
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#endif
uint32_t Work32 = S9xGetWord(OpAddress);
Work32 = S9xGetWord(OpAddress);
Work32 |= (int32_t) CheckCarry() << 16;
ICPU._Carry = (uint8_t)(Work32 & 1);
Work32 >>= 1;
@ -526,12 +552,13 @@ static inline void ROR16()
SetZN16((uint16_t) Work32);
}
static inline void ROR8()
static INLINE void ROR8()
{
uint16_t Work16;
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#endif
uint16_t Work16 = S9xGetByte(OpAddress);
Work16 = S9xGetByte(OpAddress);
Work16 |= (int32_t) CheckCarry() << 8;
ICPU._Carry = (uint8_t)(Work16 & 1);
Work16 >>= 1;
@ -539,12 +566,13 @@ static inline void ROR8()
SetZN8((uint8_t) Work16);
}
static inline void SBC16()
static INLINE void SBC16()
{
uint16_t Work16 = S9xGetWord(OpAddress);
if (CheckDecimal())
{
uint16_t Ans16;
uint16_t A1 = ICPU.Registers.A.W & 0x000f;
uint16_t A2 = ICPU.Registers.A.W & 0x00f0;
uint16_t A3 = ICPU.Registers.A.W & 0x0f00;
@ -585,7 +613,7 @@ static inline void SBC16()
else
SetCarry();
uint16_t Ans16 = A4 | A3 | A2 | A1;
Ans16 = A4 | A3 | A2 | A1;
if ((ICPU.Registers.A.W ^ Work16) & (ICPU.Registers.A.W ^ Ans16) & 0x8000)
SetOverflow();
else
@ -605,11 +633,12 @@ static inline void SBC16()
SetZN16(ICPU.Registers.A.W);
}
static inline void SBC8()
static INLINE void SBC8()
{
uint8_t Work8 = S9xGetByte(OpAddress);
if (CheckDecimal())
{
uint8_t Ans8;
uint8_t A1 = ICPU.Registers.A.W & 0x0f;
uint8_t A2 = ICPU.Registers.A.W & 0xf0;
uint8_t W1 = Work8 & 0x0f;
@ -632,7 +661,7 @@ static inline void SBC8()
else
SetCarry();
uint8_t Ans8 = A2 | A1;
Ans8 = A2 | A1;
if ((ICPU.Registers.AL ^ Work8) & (ICPU.Registers.AL ^ Ans8) & 0x80)
SetOverflow();
else
@ -652,87 +681,92 @@ static inline void SBC8()
SetZN8(ICPU.Registers.AL);
}
static inline void STA16()
static INLINE void STA16()
{
S9xSetWord(ICPU.Registers.A.W, OpAddress);
}
static inline void STA8()
static INLINE void STA8()
{
S9xSetByte(ICPU.Registers.AL, OpAddress);
}
static inline void STX16()
static INLINE void STX16()
{
S9xSetWord(ICPU.Registers.X.W, OpAddress);
}
static inline void STX8()
static INLINE void STX8()
{
S9xSetByte(ICPU.Registers.XL, OpAddress);
}
static inline void STY16()
static INLINE void STY16()
{
S9xSetWord(ICPU.Registers.Y.W, OpAddress);
}
static inline void STY8()
static INLINE void STY8()
{
S9xSetByte(ICPU.Registers.YL, OpAddress);
}
static inline void STZ16()
static INLINE void STZ16()
{
S9xSetWord(0, OpAddress);
}
static inline void STZ8()
static INLINE void STZ8()
{
S9xSetByte(0, OpAddress);
}
static inline void TSB16()
static INLINE void TSB16()
{
uint16_t Work16;
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#endif
uint16_t Work16 = S9xGetWord(OpAddress);
Work16 = S9xGetWord(OpAddress);
ICPU._Zero = (Work16 & ICPU.Registers.A.W) != 0;
Work16 |= ICPU.Registers.A.W;
S9xSetByte(Work16 >> 8, OpAddress + 1);
S9xSetByte(Work16 & 0xFF, OpAddress);
}
static inline void TSB8()
static INLINE void TSB8()
{
uint8_t Work8;
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#endif
uint8_t Work8 = S9xGetByte(OpAddress);
Work8 = S9xGetByte(OpAddress);
ICPU._Zero = Work8 & ICPU.Registers.AL;
Work8 |= ICPU.Registers.AL;
S9xSetByte(Work8, OpAddress);
}
static inline void TRB16()
static INLINE void TRB16()
{
uint16_t Work16;
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#endif
uint16_t Work16 = S9xGetWord(OpAddress);
Work16 = S9xGetWord(OpAddress);
ICPU._Zero = (Work16 & ICPU.Registers.A.W) != 0;
Work16 &= ~ICPU.Registers.A.W;
S9xSetByte(Work16 >> 8, OpAddress + 1);
S9xSetByte(Work16 & 0xFF, OpAddress);
}
static inline void TRB8()
static INLINE void TRB8()
{
uint8_t Work8;
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#endif
uint8_t Work8 = S9xGetByte(OpAddress);
Work8 = S9xGetByte(OpAddress);
ICPU._Zero = Work8 & ICPU.Registers.AL;
Work8 &= ~ICPU.Registers.AL;
S9xSetByte(Work8, OpAddress);

View File

@ -16,6 +16,8 @@
#include "cpumacro.h"
#include "apu.h"
#include <retro_inline.h>
int32_t OpAddress;
/* ADC *************************************************************************************** */
@ -2411,7 +2413,7 @@ static void Op0CM0(void)
#endif
#ifndef SA1_OPCODES
static inline void CPUShutdown(void)
static INLINE void CPUShutdown(void)
{
if (Settings.Shutdown && CPU.PC == CPU.WaitAddress)
{
@ -2444,7 +2446,7 @@ static inline void CPUShutdown(void)
}
}
#else
static inline void CPUShutdown(void)
static INLINE void CPUShutdown(void)
{
if (Settings.Shutdown && CPU.PC == CPU.WaitAddress)
{
@ -2460,7 +2462,7 @@ static inline void CPUShutdown(void)
#endif
// From the speed-hacks branch of CatSFC
static inline void ForceShutdown(void)
static INLINE void ForceShutdown(void)
{
#ifndef SA1_OPCODES
CPU.WaitAddress = NULL;
@ -3338,11 +3340,12 @@ static void OpBBX0(void)
/* XCE *************************************************************************************** */
static void OpFB(void)
{
uint8_t A1, A2;
#ifndef SA1_OPCODES
CPU.Cycles += ONE_CYCLE;
#endif
uint8_t A1 = ICPU._Carry;
uint8_t A2 = ICPU.Registers.PH;
A1 = ICPU._Carry;
A2 = ICPU.Registers.PH;
ICPU._Carry = A2 & 1;
ICPU.Registers.PH = A1;
@ -3890,11 +3893,12 @@ static void OpCB(void)
static void OpDB(void)
{
#ifndef NO_SPEEDHACKS
int8_t BranchOffset;
uint8_t NextByte = *CPU.PC++;
ForceShutdown();
int8_t BranchOffset = (NextByte & 0x7F) | ((NextByte & 0x40) << 1);
BranchOffset = (NextByte & 0x7F) | ((NextByte & 0x40) << 1);
// ^ -64 .. +63, sign extend bit 6 into 7 for unpacking
OpAddress = ((int32_t) (CPU.PC - CPU.PCBase) + BranchOffset) & 0xffff;
@ -3941,11 +3945,12 @@ static void OpDB(void)
static void Op42(void)
{
#ifndef NO_SPEEDHACKS
int8_t BranchOffset;
uint8_t NextByte = *CPU.PC++;
ForceShutdown();
int8_t BranchOffset = 0xF0 | (NextByte & 0xF); // always negative
BranchOffset = 0xF0 | (NextByte & 0xF); // always negative
OpAddress = ((int32_t) (CPU.PC - CPU.PCBase) + BranchOffset) & 0xffff;
switch (NextByte & 0xF0)

View File

@ -23,24 +23,27 @@ extern uint8_t* HDMABasePointers [8];
void S9xDoDMA(uint8_t Channel)
{
uint8_t Work;
int32_t count;
int32_t inc;
SDMA* d;
bool in_sa1_dma = false;
uint8_t* in_sdd1_dma = NULL;
uint8_t* spc7110_dma = NULL;
bool s7_wrap = false;
if (Channel > 7 || CPU.InDMA)
return;
CPU.InDMA = true;
bool in_sa1_dma = false;
uint8_t* in_sdd1_dma = NULL;
uint8_t* spc7110_dma = NULL;
bool s7_wrap = false;
SDMA* d = &DMA[Channel];
d = &DMA[Channel];
int32_t count = d->TransferBytes;
count = d->TransferBytes;
// Prepare for custom chip DMA
if (count == 0)
count = 0x10000;
int32_t inc = d->AAddressFixed ? 0 : (!d->AAddressDecrement ? 1 : -1);
inc = d->AAddressFixed ? 0 : (!d->AAddressDecrement ? 1 : -1);
if ((d->ABank == 0x7E || d->ABank == 0x7F) && d->BAddress == 0x80 && !d->TransferDirection)
{
@ -63,11 +66,13 @@ void S9xDoDMA(uint8_t Channel)
{
if (d->AAddressFixed && Memory.FillRAM [0x4801] > 0)
{
uint8_t *in_ptr;
// XXX: Should probably verify that we're DMAing from ROM?
// And somewhere we should make sure we're not running across a mapping boundary too.
inc = !d->AAddressDecrement ? 1 : -1;
uint8_t *in_ptr = GetBasePointer(((d->ABank << 16) | d->AAddress));
in_ptr = GetBasePointer(((d->ABank << 16) | d->AAddress));
if (in_ptr)
{
in_ptr += d->AAddress;
@ -81,6 +86,7 @@ void S9xDoDMA(uint8_t Channel)
if (Settings.SPC7110 && (d->AAddress == 0x4800 || d->ABank == 0x50))
{
uint32_t i;
int32_t icount;
i = (s7r.reg4805 | (s7r.reg4806 << 8));
i *= s7r.AlignBy;
i += s7r.bank50Internal;
@ -89,13 +95,16 @@ void S9xDoDMA(uint8_t Channel)
spc7110_dma = &s7r.bank50[i];
else
{
uint32_t j;
spc7110_dma = (uint8_t*)malloc(d->TransferBytes);
uint32_t j = DECOMP_BUFFER_SIZE - i;
j = DECOMP_BUFFER_SIZE - i;
memcpy(spc7110_dma, &s7r.bank50[i], j);
memcpy(&spc7110_dma[j], s7r.bank50, d->TransferBytes - j);
s7_wrap = true;
}
int32_t icount = s7r.reg4809 | (s7r.reg480A << 8);
icount = s7r.reg4809 | (s7r.reg480A << 8);
icount -= d->TransferBytes;
s7r.reg4809 = 0x00ff & icount;
s7r.reg480A = (0xff00 & icount) >> 8;
@ -107,6 +116,7 @@ void S9xDoDMA(uint8_t Channel)
}
if (d->BAddress == 0x18 && SA1.in_char_dma && (d->ABank & 0xf0) == 0x40)
{
int32_t i;
// Perform packed bitmap to PPU character format conversion on the
// data before transmitting it to V-RAM via-DMA.
int32_t num_chars = 1 << ((Memory.FillRAM [0x2231] >> 2) & 7);
@ -124,7 +134,6 @@ void S9xDoDMA(uint8_t Channel)
uint32_t char_count = inc / bytes_per_char;
in_sa1_dma = true;
int32_t i;
switch (depth)
{
@ -225,6 +234,9 @@ void S9xDoDMA(uint8_t Channel)
if (!d->TransferDirection)
{
uint8_t* base;
uint16_t p;
/* XXX: DMA is potentially broken here for cases where we DMA across
* XXX: memmap boundries. A possible solution would be to re-call
* XXX: GetBasePointer whenever we cross a boundry, and when
@ -240,8 +252,8 @@ void S9xDoDMA(uint8_t Channel)
//reflects extra cycle used by DMA
CPU.Cycles += SLOW_ONE_CYCLE * (count + 1);
uint8_t* base = GetBasePointer((d->ABank << 16) + d->AAddress);
uint16_t p = d->AAddress;
base = GetBasePointer((d->ABank << 16) + d->AAddress);
p = d->AAddress;
if (!base)
base = Memory.ROM;
@ -606,6 +618,8 @@ update_address:
void S9xStartHDMA()
{
uint8_t i;
if (Settings.DisableHDMA)
IPPU.HDMA = 0;
else
@ -615,7 +629,6 @@ void S9xStartHDMA()
if (IPPU.HDMA != 0)
CPU.Cycles += ONE_CYCLE * 3;
uint8_t i;
for (i = 0; i < 8; i++)
{
if (IPPU.HDMA & (1 << i))
@ -633,23 +646,26 @@ void S9xStartHDMA()
uint8_t S9xDoHDMA(uint8_t byte)
{
uint8_t mask;
SDMA* p = &DMA [0];
int32_t d = 0;
CPU.InDMA = true;
CPU.Cycles += ONE_CYCLE * 3;
uint8_t mask;
for (mask = 1; mask; mask <<= 1, p++, d++)
{
if (byte & mask)
{
if (!p->LineCount)
{
uint8_t line;
//remember, InDMA is set.
//Get/Set incur no charges!
CPU.Cycles += SLOW_ONE_CYCLE;
uint8_t line = S9xGetByte((p->ABank << 16) + p->Address);
line = S9xGetByte((p->ABank << 16) + p->Address);
if (line == 0x80)
{
p->Repeat = true;

View File

@ -624,6 +624,10 @@ uint8_t DSP1GetByte(uint16_t address)
void DSP2SetByte(uint8_t byte, uint16_t address)
{
#ifndef FAST_LSB_WORD_ACCESS
uint32_t temp;
#endif
if ((address & 0xf000) == 0x6000 ||
(address >= 0x8000 && address < 0xc000))
{
@ -715,7 +719,6 @@ void DSP2SetByte(uint8_t byte, uint16_t address)
#ifdef FAST_LSB_WORD_ACCESS
*(uint32_t*)DSP1.output = DSP2Op09Word1 * DSP2Op09Word2;
#else
uint32_t temp;
temp = DSP2Op09Word1 * DSP2Op09Word2;
DSP1.output[0] = temp & 0xFF;
DSP1.output[1] = (temp >> 8) & 0xFF;
@ -941,10 +944,11 @@ void DSP4SetByte(uint8_t byte, uint16_t address)
// internal memory management (06)
case 0x0005:
{
int32_t lcv;
// clear OAM tables
op06_index = 0;
op06_offset = 0;
int32_t lcv;
for (lcv = 0; lcv < 32; lcv++)
op06_OAM[lcv] = 0;
break;
@ -959,8 +963,9 @@ void DSP4SetByte(uint8_t byte, uint16_t address)
// sprite OAM post-table data
case 0x0006:
{
DSP4.out_count = 32;
int32_t lcv;
DSP4.out_count = 32;
for (lcv = 0; lcv < 32; lcv++)
DSP4.output[lcv] = op06_OAM[lcv];
}

View File

@ -301,24 +301,28 @@ const int16_t DSP1_SinTable[256] =
int16_t DSP1_Sin(int16_t Angle)
{
int32_t S;
if (Angle < 0)
{
if (Angle == -32768) return 0;
return -DSP1_Sin(-Angle);
}
int32_t S = DSP1_SinTable[Angle >> 8] + (DSP1_MulTable[Angle & 0xff] * DSP1_SinTable[0x40 + (Angle >> 8)] >> 15);
S = DSP1_SinTable[Angle >> 8] + (DSP1_MulTable[Angle & 0xff] * DSP1_SinTable[0x40 + (Angle >> 8)] >> 15);
if (S > 32767) S = 32767;
return (int16_t) S;
}
int16_t DSP1_Cos(int16_t Angle)
{
int32_t S;
if (Angle < 0)
{
if (Angle == -32768) return -32768;
Angle = -Angle;
}
int32_t S = DSP1_SinTable[0x40 + (Angle >> 8)] - (DSP1_MulTable[Angle & 0xff] * DSP1_SinTable[Angle >> 8] >> 15);
S = DSP1_SinTable[0x40 + (Angle >> 8)] - (DSP1_MulTable[Angle & 0xff] * DSP1_SinTable[Angle >> 8] >> 15);
if (S < -32768) S = -32767;
return (int16_t) S;
}

View File

@ -47,6 +47,11 @@ void DSP4_Op06(bool size, bool msb)
void DSP4_Op01()
{
int16_t plane;
int16_t index, lcv;
int16_t py_dy, px_dx;
int16_t y_out, x_out;
uint16_t command;
DSP4.waiting4command = false;
@ -123,11 +128,6 @@ DSP4_WAIT(1) resume1:
// process one iteration of projection
// inspect inputs
int16_t plane;
int16_t index, lcv;
int16_t py_dy, px_dx;
int16_t y_out, x_out;
resume2:
plane = DSP4_READ_WORD(0);
@ -241,6 +241,10 @@ resume2:
void DSP4_Op07()
{
uint16_t command;
int16_t plane;
int16_t index, lcv;
int16_t y_out, x_out;
int16_t py_dy, px_dx;
DSP4.waiting4command = false;
@ -309,11 +313,6 @@ DSP4_WAIT(1) resume1:
////////////////////////////////////////////////////
// process one loop of projection
int16_t plane;
int16_t index, lcv;
int16_t y_out, x_out;
int16_t py_dy, px_dx;
resume2:
px_dx = 0;
@ -404,6 +403,11 @@ resume2:
void DSP4_Op08()
{
uint16_t command;
// used in envelope shaping
int16_t x1_final;
int16_t x2_final;
int16_t plane, x_left, y_left, x_right, y_right;
int16_t envelope1, envelope2;
DSP4.waiting4command = false;
@ -494,20 +498,16 @@ DSP4_WAIT(2) resume2:
// debug
++block;
// used in envelope shaping
int16_t x1_final;
int16_t x2_final;
// look at guidelines
int16_t plane = DSP4_READ_WORD(0x00);
int16_t x_left = DSP4_READ_WORD(0x02);
int16_t y_left = DSP4_READ_WORD(0x04);
int16_t x_right = DSP4_READ_WORD(0x06);
int16_t y_right = DSP4_READ_WORD(0x08);
plane = DSP4_READ_WORD(0x00);
x_left = DSP4_READ_WORD(0x02);
y_left = DSP4_READ_WORD(0x04);
x_right = DSP4_READ_WORD(0x06);
y_right = DSP4_READ_WORD(0x08);
// envelope guidelines (one frame only)
int16_t envelope1 = DSP4_READ_WORD(0x0a);
int16_t envelope2 = DSP4_READ_WORD(0x0c);
envelope1 = DSP4_READ_WORD(0x0a);
envelope2 = DSP4_READ_WORD(0x0c);
// ignore invalid data
if ((uint16_t) plane == 0x8001) continue;
@ -730,6 +730,11 @@ DSP4_WAIT(2) resume2:
void DSP4_Op0D()
{
uint16_t command;
// inspect inputs
int16_t plane;
int16_t index, lcv;
int16_t py_dy, px_dx;
int16_t y_out, x_out;
DSP4.waiting4command = false;
@ -824,11 +829,6 @@ DSP4_WAIT(1) resume1:
////////////////////////////////////////////////////
// project section of the track
// inspect inputs
int16_t plane;
int16_t index, lcv;
int16_t py_dy, px_dx;
int16_t y_out, x_out;
resume2:
@ -940,6 +940,9 @@ resume2:
void DSP4_Op09()
{
uint16_t command;
bool clip;
int16_t sp_x, sp_y, sp_oam, sp_msb;
int16_t sp_dx, sp_dy;
DSP4.waiting4command = false;
@ -1055,6 +1058,7 @@ sprite_found:
int16_t plane;
int16_t car_left, car_right;
int16_t focal_back;
int32_t height;
// we already have 4 bytes we want
DSP4.in_count = 6 + 12;
@ -1096,7 +1100,6 @@ DSP4_WAIT(3) resume3:
DSP4_WAIT(4)
// store final values
int32_t height;
resume4:
height = DSP4_READ_WORD(0);
@ -1176,10 +1179,6 @@ DSP4_WAIT(6) resume6:
/////////////////////////////////////
// process tile data
bool clip;
int16_t sp_x, sp_y, sp_oam, sp_msb;
int16_t sp_dx, sp_dy;
resume7:
// sprite deltas

View File

@ -284,6 +284,8 @@ static void fx_writeRegisterSpaceAfterUse()
/* Reset the FxChip */
void FxReset(FxInit_s* psFxInfo)
{
int32_t i;
/* Clear all internal variables */
memset(&GSU, 0, sizeof(FxRegs_s));
@ -310,7 +312,6 @@ void FxReset(FxInit_s* psFxInfo)
GSU.pvRegisters[0x3b] = 0;
/* Make ROM bank table */
int32_t i;
for (i = 0; i < 256; i++)
{
uint32_t b = i & 0x7f;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -7,6 +7,8 @@
#include "ppu.h"
#include "snes9x.h"
#include <retro_inline.h>
void S9xStartScreenRefresh(void);
void S9xDrawScanLine(uint8_t Line);
void S9xEndScreenRefresh(void);
@ -145,7 +147,7 @@ extern uint8_t mul_brightness [16][32];
#define SUB_SCREEN_DEPTH 0
#define MAIN_SCREEN_DEPTH 32
static inline uint16_t COLOR_ADD(uint16_t C1, uint16_t C2)
static INLINE uint16_t COLOR_ADD(uint16_t C1, uint16_t C2)
{
if (C1 == 0)
return C2;

View File

@ -6,6 +6,7 @@
#include <limits.h>
#include <string.h>
#include <sys/types.h>
#include <retro_inline.h>
#ifdef PSP
#define PIXEL_FORMAT BGR555
@ -23,11 +24,25 @@
#define PATH_MAX 1024
#endif
#ifndef _MAX_DIR
#define _MAX_DIR PATH_MAX
#endif
#ifndef _MAX_DRIVE
#define _MAX_DRIVE 1
#endif
#ifndef _MAX_FNAME
#define _MAX_FNAME PATH_MAX
#endif
#ifndef _MAX_EXT
#define _MAX_EXT PATH_MAX
#endif
#ifndef _MAX_PATH
#define _MAX_PATH PATH_MAX
#endif
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);
@ -55,7 +70,7 @@ void _splitpath(const char* path, char* drive, char* dir, char* fname, char* ext
#define MAX(A,B) ((A) > (B) ? (A) : (B))
/* Integer square root by Halleck's method, with Legalize's speedup */
static inline int32_t _isqrt(int32_t val)
static INLINE int32_t _isqrt(int32_t val)
{
int32_t squaredbit, remainder, root;

View File

@ -1,8 +1,9 @@
#include "../copyright"
#ifndef _PPU_H_
#define _PPU_H_
#include "../copyright"
#include <retro_inline.h>
#define FIRST_VISIBLE_LINE 1
extern uint8_t GetBank;
@ -199,20 +200,20 @@ typedef struct
bool FirstLine;
} SDMA;
void S9xUpdateScreen();
void S9xResetPPU();
void S9xSoftResetPPU();
void S9xFixColourBrightness();
void S9xUpdateJoypads();
void S9xUpdateScreen(void);
void S9xResetPPU(void);
void S9xSoftResetPPU(void);
void S9xFixColourBrightness(void);
void S9xUpdateJoypads(void);
void S9xProcessMouse(int32_t which1);
void S9xSuperFXExec();
void S9xSuperFXExec(void);
void S9xSetPPU(uint8_t Byte, uint16_t Address);
uint8_t S9xGetPPU(uint16_t Address);
void S9xSetCPU(uint8_t Byte, uint16_t Address);
uint8_t S9xGetCPU(uint16_t Address);
void S9xInitC4();
void S9xInitC4(void);
void S9xSetC4(uint8_t Byte, uint16_t Address);
uint8_t S9xGetC4(uint16_t Address);
void S9xSetC4RAM(uint8_t Byte, uint16_t Address);
@ -241,27 +242,29 @@ extern SnesModel M2SNES;
//Platform specific input functions used by PPU.CPP
void JustifierButtons(uint32_t*);
bool JustifierOffscreen();
bool JustifierOffscreen(void);
static inline void FLUSH_REDRAW()
static INLINE void FLUSH_REDRAW(void)
{
if (IPPU.PreviousLine != IPPU.CurrentLine)
S9xUpdateScreen();
}
static inline void REGISTER_2104(uint8_t byte)
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])
{
SOBJ* pObj = NULL;
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 = &PPU.OBJ [(addr & 0x1f) * 4];
pObj->HPos = (pObj->HPos & 0xFF) | SignExtend[(byte >> 0) & 1];
pObj++->Size = byte & 2;
@ -296,12 +299,15 @@ static inline void REGISTER_2104(uint8_t byte)
}
else
{
int32_t addr;
uint8_t lowbyte, highbyte;
PPU.OAMWriteRegister &= 0x00ff;
uint8_t lowbyte = (uint8_t)(PPU.OAMWriteRegister);
uint8_t highbyte = byte;
lowbyte = (uint8_t)(PPU.OAMWriteRegister);
highbyte = byte;
PPU.OAMWriteRegister |= byte << 8;
int32_t addr = (PPU.OAMAddr << 1);
addr = (PPU.OAMAddr << 1);
if (lowbyte != PPU.OAMData [addr] ||
highbyte != PPU.OAMData [addr + 1])
@ -343,7 +349,7 @@ static inline void REGISTER_2104(uint8_t byte)
Memory.FillRAM [0x2104] = byte;
}
static inline void REGISTER_2118(uint8_t Byte)
static INLINE void REGISTER_2118(uint8_t Byte)
{
uint32_t address;
if (PPU.VMA.FullGraphicCount)
@ -363,7 +369,7 @@ static inline void REGISTER_2118(uint8_t Byte)
PPU.VMA.Address += PPU.VMA.Increment;
}
static inline void REGISTER_2118_tile(uint8_t Byte)
static INLINE void REGISTER_2118_tile(uint8_t Byte)
{
uint32_t address;
uint32_t rem = PPU.VMA.Address & PPU.VMA.Mask1;
@ -378,7 +384,7 @@ static inline void REGISTER_2118_tile(uint8_t Byte)
PPU.VMA.Address += PPU.VMA.Increment;
}
static inline void REGISTER_2118_linear(uint8_t Byte)
static INLINE void REGISTER_2118_linear(uint8_t Byte)
{
uint32_t address;
Memory.VRAM[address = (PPU.VMA.Address << 1) & 0xFFFF] = Byte;
@ -389,7 +395,7 @@ static inline void REGISTER_2118_linear(uint8_t Byte)
PPU.VMA.Address += PPU.VMA.Increment;
}
static inline void REGISTER_2119(uint8_t Byte)
static INLINE void REGISTER_2119(uint8_t Byte)
{
uint32_t address;
if (PPU.VMA.FullGraphicCount)
@ -409,7 +415,7 @@ static inline void REGISTER_2119(uint8_t Byte)
PPU.VMA.Address += PPU.VMA.Increment;
}
static inline void REGISTER_2119_tile(uint8_t Byte)
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) +
@ -423,7 +429,7 @@ static inline void REGISTER_2119_tile(uint8_t Byte)
PPU.VMA.Address += PPU.VMA.Increment;
}
static inline void REGISTER_2119_linear(uint8_t Byte)
static INLINE void REGISTER_2119_linear(uint8_t Byte)
{
uint32_t address;
Memory.VRAM[address = ((PPU.VMA.Address << 1) + 1) & 0xFFFF] = Byte;
@ -434,7 +440,7 @@ static inline void REGISTER_2119_linear(uint8_t Byte)
PPU.VMA.Address += PPU.VMA.Increment;
}
static inline void REGISTER_2122(uint8_t Byte)
static INLINE void REGISTER_2122(uint8_t Byte)
{
if (PPU.CGFLIP)
{
@ -465,14 +471,14 @@ static inline void REGISTER_2122(uint8_t Byte)
PPU.CGFLIP = !PPU.CGFLIP;
}
static inline void REGISTER_2180(uint8_t Byte)
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()
static INLINE uint8_t REGISTER_4212(void)
{
uint8_t GetBank = 0;
if (CPU.V_Counter >= PPU.ScreenHeight + FIRST_VISIBLE_LINE &&

View File

@ -5,6 +5,7 @@
#include "memmap.h"
#include "cpuexec.h"
#include <retro_inline.h>
typedef struct
{
@ -85,15 +86,15 @@ extern SOpcodes S9xSA1OpcodesM0X1 [256];
extern SOpcodes S9xSA1OpcodesM0X0 [256];
extern SSA1 SA1;
void S9xSA1MainLoop();
void S9xSA1Init();
void S9xFixSA1AfterSnapshotLoad();
void S9xSA1MainLoop(void);
void S9xSA1Init(void);
void S9xFixSA1AfterSnapshotLoad(void);
#define SNES_IRQ_SOURCE (1 << 7)
#define TIMER_IRQ_SOURCE (1 << 6)
#define DMA_IRQ_SOURCE (1 << 5)
static inline void S9xSA1UnpackStatus()
static INLINE void S9xSA1UnpackStatus(void)
{
SA1._Zero = (SA1.Registers.PL & Zero) == 0;
SA1._Negative = (SA1.Registers.PL & Negative);
@ -101,13 +102,13 @@ static inline void S9xSA1UnpackStatus()
SA1._Overflow = (SA1.Registers.PL & Overflow) >> 6;
}
static inline void S9xSA1PackStatus()
static INLINE void S9xSA1PackStatus(void)
{
SA1.Registers.PL &= ~(Zero | Negative | Carry | Overflow);
SA1.Registers.PL |= SA1._Carry | ((SA1._Zero == 0) << 1) | (SA1._Negative & 0x80) | (SA1._Overflow << 6);
}
static inline void S9xSA1FixCycles()
static INLINE void S9xSA1FixCycles(void)
{
if (SA1CheckEmulation())
SA1.S9xOpcodes = S9xSA1OpcodesE1;

View File

@ -4,6 +4,7 @@
#define _SAR_H_
#include <stdint.h>
#include <retro_inline.h>
#include "port.h"
@ -14,7 +15,7 @@
#define SAR64(b, n) ((b) >> (n))
#else
static inline int8_t SAR8(const int8_t b, const int32_t n)
static INLINE int8_t SAR8(const int8_t b, const int32_t n)
{
#ifndef RIGHTSHIFT_INT8_IS_SAR
if (b < 0)
@ -23,7 +24,7 @@ static inline int8_t SAR8(const int8_t b, const int32_t n)
return b >> n;
}
static inline int16_t SAR16(const int16_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)
@ -32,7 +33,7 @@ static inline int16_t SAR16(const int16_t b, const int32_t n)
return b >> n;
}
static inline int32_t SAR32(const int32_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)
@ -41,7 +42,7 @@ static inline int32_t SAR32(const int32_t b, const int32_t n)
return b >> n;
}
static inline int64_t SAR64(const int64_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)