upgrade core to 1.52

This commit is contained in:
dborth 2010-01-27 22:08:56 +00:00
parent 6b870179cf
commit dfb91c5f7c
112 changed files with 42329 additions and 47384 deletions

View File

@ -19,19 +19,16 @@ TARGET := snes9xgx-gc
TARGETDIR := executables
BUILD := build_gc
SOURCES := source/ngc/images source/ngc/sounds source/ngc/fonts source/ngc/lang \
source/ngc/gui source/ngc source/snes9x source/sz
source/ngc/gui source/ngc source/snes9x source/snes9x/apu \
source/sz
INCLUDES := source/snes9x source/ngc
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
CFLAGS = -g -O3 -Wall $(MACHDEP) $(INCLUDE) \
-DNGC -DNO_SOUND \
-DNO_ASM -DRIGHTSHIFT_IS_SAR \
-DCPU_SHUTDOWN -DSPC700_SHUTDOWN \
-DSPC700_C -DSDD1_DECOMP \
-DCORRECT_VRAM_READS -DNEW_COLOUR_BLENDING \
CFLAGS = -g -O3 -Wall $(MACHDEP) $(INCLUDE) -DNO_SOUND \
-DZLIB -DRIGHTSHIFT_IS_SAR -DCPU_SHUTDOWN -DCORRECT_VRAM_READS \
-D_SZ_ONE_DIRECTORY -D_LZMA_IN_CB -D_LZMA_OUT_READ \
-fomit-frame-pointer \
-Wno-unused-parameter -Wno-strict-aliasing \

View File

@ -19,7 +19,8 @@ TARGET := snes9xgx-wii
TARGETDIR := executables
BUILD := build_wii
SOURCES := source/ngc/images source/ngc/sounds source/ngc/fonts source/ngc/lang \
source/ngc/gui source/ngc source/snes9x source/sz source/unzip
source/ngc/gui source/ngc source/snes9x source/snes9x/apu \
source/sz source/unzip
INCLUDES := source/snes9x source/ngc source/unzip
#---------------------------------------------------------------------------------
@ -27,11 +28,7 @@ INCLUDES := source/snes9x source/ngc source/unzip
#---------------------------------------------------------------------------------
CFLAGS = -g -O3 -Wall $(MACHDEP) $(INCLUDE) \
-DNGC \
-DNO_ASM -DRIGHTSHIFT_IS_SAR \
-DCPU_SHUTDOWN -DSPC700_SHUTDOWN \
-DSPC700_C -DSDD1_DECOMP \
-DCORRECT_VRAM_READS -DNEW_COLOUR_BLENDING \
-DZLIB -DRIGHTSHIFT_IS_SAR -DCPU_SHUTDOWN -DCORRECT_VRAM_READS \
-D_SZ_ONE_DIRECTORY -D_LZMA_IN_CB -D_LZMA_OUT_READ \
-fomit-frame-pointer \
-Wno-unused-parameter -Wno-strict-aliasing \

View File

@ -18,14 +18,11 @@
#include "snes9x.h"
#include "memmap.h"
#include "s9xdebug.h"
#include "cpuexec.h"
#include "ppu.h"
#include "apu.h"
#include "apu/apu.h"
#include "display.h"
#include "gfx.h"
#include "soundux.h"
#include "spc700.h"
#include "spc7110.h"
#include "controls.h"
@ -42,6 +39,7 @@ static int whichab = 0; /*** Audio buffer flip switch ***/
static lwpq_t audioqueue;
static lwp_t athread;
static uint8 astack[AUDIOSTACK];
static mutex_t audiomutex = LWP_MUTEX_NULL;
/****************************************************************************
* Audio Threading
@ -58,8 +56,9 @@ AudioThread (void *arg)
memset (soundbuffer[whichab], 0, AUDIOBUFFER);
else
{
so.samples_mixed_so_far = so.play_position = 0;
LWP_MutexLock(audiomutex);
S9xMixSamples (soundbuffer[whichab], AUDIOBUFFER >> 1);
LWP_MutexUnlock(audiomutex);
}
LWP_ThreadSleep (audioqueue);
}
@ -85,6 +84,13 @@ GCMixSamples ()
}
}
static void FinalizeSamplesCallback (void *data)
{
LWP_MutexLock(audiomutex);
S9xFinalizeSamples();
LWP_MutexUnlock(audiomutex);
}
/****************************************************************************
* InitAudio
***************************************************************************/
@ -98,6 +104,7 @@ InitAudio ()
#else
ASND_Init();
#endif
LWP_MutexInit(&audiomutex, false);
LWP_CreateThread (&athread, AudioThread, NULL, astack, AUDIOSTACK, 70);
}
@ -117,9 +124,11 @@ SwitchAudioMode(int mode)
AUDIO_SetDSPSampleRate(AI_SAMPLERATE_32KHZ);
AUDIO_RegisterDMACallback(GCMixSamples);
#endif
S9xSetSamplesAvailableCallback(FinalizeSamplesCallback, NULL);
}
else // menu
{
S9xSetSamplesAvailableCallback(NULL, NULL);
#ifndef NO_SOUND
ASND_Init();
ASND_Pause(0);

View File

@ -453,6 +453,39 @@ int BrowserLoadSz()
return szfiles;
}
int WiiFileLoader()
{
int size;
char filepath[1024];
memset(Memory.NSRTHeader, 0, sizeof(Memory.NSRTHeader));
Memory.HeaderCount = 0;
if(!inSz)
{
if(!MakeFilePath(filepath, FILE_ROM))
return 0;
size = LoadFile ((char *)Memory.ROM, filepath, browserList[browser.selIndex].length, NOTSILENT);
}
else
{
size = LoadSzFile(szpath, (unsigned char *)Memory.ROM);
if(size <= 0)
{
browser.selIndex = 0;
BrowserChangeFolder();
}
}
if(size <= 0)
return 0;
SNESROMSize = Memory.HeaderRemove(size, Memory.HeaderCount, Memory.ROM);
return SNESROMSize;
}
/****************************************************************************
* BrowserLoadFile
*
@ -460,11 +493,9 @@ int BrowserLoadSz()
***************************************************************************/
int BrowserLoadFile()
{
char filepath[1024];
int loaded = 0;
int device;
if(!FindDevice(browser.dir, &device))
return 0;
@ -472,31 +503,12 @@ int BrowserLoadFile()
if(!IsValidROM())
goto done;
strcpy(loadedFile, browserList[browser.selIndex].filename);
// store the filename (w/o ext) - used for sram/freeze naming
StripExt(Memory.ROMFilename, browserList[browser.selIndex].filename);
SNESROMSize = 0;
S9xDeleteCheats();
if(!inSz)
{
if(!MakeFilePath(filepath, FILE_ROM))
goto done;
SNESROMSize = LoadFile ((char *)Memory.ROM, filepath, browserList[browser.selIndex].length, NOTSILENT);
}
else
{
SNESROMSize = LoadSzFile(szpath, (unsigned char *)Memory.ROM);
if(SNESROMSize <= 0)
{
browser.selIndex = 0;
BrowserChangeFolder();
}
}
Memory.LoadROM("ROM");
if (SNESROMSize <= 0)
{
@ -504,21 +516,12 @@ int BrowserLoadFile()
}
else
{
// load UPS/IPS/PPF patch
WiiLoadPatch();
Memory.LoadROM ("BLANK.SMC");
Memory.LoadSRAM ("BLANK");
// load SRAM or snapshot
if (GCSettings.AutoLoad == 1)
LoadSRAMAuto(SILENT);
else if (GCSettings.AutoLoad == 2)
LoadSnapshotAuto(SILENT);
// setup cheats
WiiSetupCheats();
ResetBrowser();
loaded = 1;
}

View File

@ -7,121 +7,42 @@
* Tantric 2008-2009
*
* freeze.cpp
*
* Snapshots Memory File System
*
* This is a single global memory file controller.
* Don't even think of opening two at the same time!
***************************************************************************/
#include <malloc.h>
#include <gccore.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fat.h>
#include <zlib.h>
#include "snes9x.h"
#include "port.h"
#include "memmap.h"
#include "soundux.h"
#include "snapshot.h"
#include "srtc.h"
#include "language.h"
#include "snes9xGX.h"
#include "freeze.h"
#include "fileop.h"
#include "filebrowser.h"
#include "menu.h"
#include "video.h"
#include "pngu.h"
extern void S9xSRTCPreSaveState ();
extern void NGCFreezeStruct ();
extern bool8 S9xUnfreezeGame (const char *filename);
static int bufoffset;
/****************************************************************************
* GetMem
*
* Return x bytes from memory buffer
***************************************************************************/
int
GetMem (char *buffer, int len)
bool8 S9xOpenSnapshotFile(const char *filepath, bool8 readonly, STREAM *file)
{
memcpy (buffer, savebuffer + bufoffset, len);
bufoffset += len;
return len;
return FALSE;
}
/****************************************************************************
* PutMem
*
* Put some values in memory buffer
***************************************************************************/
static void
PutMem (char *buffer, int len)
void S9xCloseSnapshotFile(STREAM s)
{
memcpy (savebuffer + bufoffset, buffer, len);
bufoffset += len;
}
void
NGCFreezeBlock (char *name, uint8 * block, int size)
{
char buffer[512];
sprintf (buffer, "%s:%06d:", name, size);
PutMem (buffer, strlen (buffer));
PutMem ((char *) block, size);
}
/****************************************************************************
* NGCFreezeMembuffer
*
* Copies a snapshot of Snes9x state into memory
***************************************************************************/
static int
NGCFreezeMemBuffer ()
{
int i;
char buffer[1024];
bufoffset = 0;
S9xUpdateRTC ();
S9xSRTCPreSaveState ();
for (i = 0; i < 8; i++)
{
SoundData.channels[i].previous16[0] =
(int16) SoundData.channels[i].previous[0];
SoundData.channels[i].previous16[1] =
(int16) SoundData.channels[i].previous[1];
}
sprintf (buffer, "%s:%04d\n", SNAPSHOT_MAGIC, SNAPSHOT_VERSION);
PutMem (buffer, strlen (buffer));
sprintf (buffer, "NAM:%06d:%s%c", (int) strlen (Memory.ROMFilename) + 1,
Memory.ROMFilename, 0);
PutMem (buffer, strlen (buffer) + 1);
NGCFreezeStruct ();
return 0;
}
/****************************************************************************
* SaveSnapshot
***************************************************************************/
int
SaveSnapshot (char * filepath, bool silent)
{
int offset = 0; // bytes written (actual)
int woffset = 0; // bytes written (expected)
int imgSize = 0; // image screenshot bytes written
int device;
@ -153,28 +74,21 @@ SaveSnapshot (char * filepath, bool silent)
FreeSaveBuffer ();
}
S9xSetSoundMute (TRUE);
S9xPrepareSoundForSnapshotSave (FALSE);
AllocSaveBuffer ();
// copy freeze mem into savebuffer - bufoffset contains # bytes written
NGCFreezeMemBuffer ();
woffset = bufoffset;
S9xPrepareSoundForSnapshotSave (TRUE);
S9xSetSoundMute (FALSE);
offset = SaveFile(filepath, woffset, silent);
FreeSaveBuffer ();
if(offset > 0) // save successful!
STREAM fp = OPEN_STREAM(filepath, "wb");
if(!fp)
{
if(!silent)
InfoPrompt("Save successful");
return 1;
ErrorPrompt("Save failed!");
return 0;
}
return 0;
S9xFreezeToStream(fp);
CLOSE_STREAM(fp);
if(!silent)
InfoPrompt("Save successful");
return 1;
}
int
@ -188,76 +102,47 @@ SaveSnapshotAuto (bool silent)
return SaveSnapshot(filepath, silent);
}
/****************************************************************************
* NGCUnFreezeBlock
***************************************************************************/
int
NGCUnFreezeBlock (char *name, uint8 * block, int size)
{
char buffer[20], *e;
int len = 0;
int rem = 0;
GetMem (buffer, 11);
if (strncmp (buffer, name, 3) != 0 || buffer[3] != ':' ||
buffer[10] != ':' || (len = strtol (&buffer[4], &e, 10)) == 0 ||
e != buffer + 10)
{
bufoffset -= 11; // go back to where we started
return WRONG_FORMAT;
}
if (len > size)
{
rem = len - size;
len = size;
}
ZeroMemory (block, size);
GetMem ((char *) block, len);
if (rem)
{
bufoffset += rem;
}
return SUCCESS;
}
/****************************************************************************
* LoadSnapshot
***************************************************************************/
int
LoadSnapshot (char * filepath, bool silent)
{
int offset = 0;
int result = 0;
bufoffset = 0;
int device;
if(!FindDevice(filepath, &device))
return 0;
AllocSaveBuffer();
offset = LoadFile(filepath, silent);
STREAM fp = OPEN_STREAM(filepath, "rb");
if(offset > 0)
{
if (S9xUnfreezeGame ("AGAME") == SUCCESS)
result = 1;
else
ErrorPrompt("Error thawing");
}
else
if(!fp)
{
if(!silent)
ErrorPrompt("Freeze file not found");
ErrorPrompt("Unable to open snapshot!");
return 0;
}
FreeSaveBuffer();
return result;
int result = S9xUnfreezeFromStream(fp);
CLOSE_STREAM(fp);
if (result == SUCCESS)
return 1;
switch (result)
{
case WRONG_FORMAT:
ErrorPrompt(SAVE_ERR_WRONG_FORMAT);
break;
case WRONG_VERSION:
ErrorPrompt(SAVE_ERR_WRONG_VERSION);
break;
case SNAPSHOT_INCONSISTENT:
ErrorPrompt(MOVIE_ERR_SNAPSHOT_INCONSISTENT);
break;
}
return 0;
}
int

View File

@ -7,27 +7,11 @@
* Tantric August 2008
*
* freeze.h
*
* Snapshots Memory File System
*
* This is a single global memory file controller.
* Don't even think of opening two at the same time!
***************************************************************************/
#ifndef _FREEZE_H_
#define _FREEZE_H_
typedef struct
{
char filename[512]; /*** Way over size - but who cares -;) ***/
int filehandle;
int currpos;
int length;
int mode;
char *buffer; /*** Memspace for read / write ***/
}
MEMFILE;
int SaveSnapshot (char * filepath, bool silent);
int SaveSnapshotAuto (bool silent);
int LoadSnapshot (char * filepath, bool silent);

View File

@ -760,7 +760,7 @@ void SetDefaultButtonMap ()
S9xMapPointer(maxcode++, S9xGetCommandT("Pointer Justifier2"), false);
maxcode = 0x90;
ASSIGN_BUTTON_FALSE (maxcode++, "Screenshot");
//ASSIGN_BUTTON_FALSE (maxcode++, "Screenshot");
SetControllers();
}

View File

@ -430,28 +430,19 @@ DefaultSettings ()
// General
Settings.MouseMaster = false;
Settings.SuperScopeMaster = false;
Settings.MultiPlayer5Master = false;
Settings.JustifierMaster = false;
Settings.ShutdownMaster = true; // needs to be on for ActRaiser 2
Settings.ApplyCheats = true;
Settings.MouseMaster = true;
Settings.SuperScopeMaster = true;
Settings.JustifierMaster = true;
Settings.MultiPlayer5Master = true;
Settings.BlockInvalidVRAMAccess = false;
Settings.HDMATimingHack = 100;
// Sound defaults. On GC this is 32Khz/16bit/Stereo/InterpolatedSound
Settings.APUEnabled = true;
Settings.NextAPUEnabled = true;
Settings.SoundPlaybackRate = 32000;
Settings.Stereo = true;
// Sound defaults. On Wii this is 32Khz/16bit/Stereo
Settings.SixteenBitSound = true;
Settings.SoundEnvelopeHeightReading = true;
Settings.SoundSync = true;
Settings.FixFrequency = false;
Settings.DisableSampleCaching = true;
Settings.InterpolatedSound = true;
Settings.ReverseStereo = true;
Settings.Stereo = true;
Settings.SoundPlaybackRate = 32000;
Settings.SoundInputRate = 31950;
// Graphics
Settings.Transparency = true;
@ -465,25 +456,6 @@ DefaultSettings ()
// Frame timings in 50hz and 60hz cpu mode
Settings.FrameTimePAL = 20000;
Settings.FrameTimeNTSC = 16667;
// SDD1 - Star Ocean Returns
Settings.SDD1Pack = true;
Settings.ForceNTSC = 0;
Settings.ForcePAL = 0;
Settings.ForceHiROM = 0;
Settings.ForceLoROM = 0;
Settings.ForceHeader = 0;
Settings.ForceNoHeader = 0;
Settings.ForceTransparency = 0;
Settings.ForceInterleaved = 0;
Settings.ForceInterleaved2 = 0;
Settings.ForceInterleaveGD24 = 0;
Settings.ForceNotInterleaved = 0;
Settings.ForceNoSuperFX = 0;
Settings.ForceSuperFX = 0;
Settings.ForceDSP1 = 0;
Settings.ForceNoDSP1 = 0;
}
/****************************************************************************

View File

@ -21,21 +21,16 @@
#include "snes9x.h"
#include "memmap.h"
#include "s9xdebug.h"
#include "cpuexec.h"
#include "ppu.h"
#include "apu.h"
#include "display.h"
#include "gfx.h"
#include "soundux.h"
#include "spc700.h"
#include "spc7110.h"
#include "apu/apu.h"
#include "controls.h"
#include "snes9xGX.h"
#include "video.h"
#include "audio.h"
#define MAX_MESSAGE_LEN (36 * 3)
static long long prev;
static long long now;
@ -47,8 +42,6 @@ void S9xExit()
void S9xMessage(int /*type */, int /*number */, const char *message)
{
#define MAX_MESSAGE_LEN (36 * 3)
static char buffer[MAX_MESSAGE_LEN + 1];
strncpy(buffer, message, MAX_MESSAGE_LEN);
buffer[MAX_MESSAGE_LEN] = 0;
@ -63,11 +56,14 @@ void S9xAutoSaveSRAM()
/*** Sound based functions ***/
void S9xToggleSoundChannel(int c)
{
if (c == 8)
so.sound_switch = 255;
else
so.sound_switch ^= 1 << c;
S9xSetSoundControl(so.sound_switch);
static int sound_switch = 255;
if (c == 8)
sound_switch = 255;
else
sound_switch ^= 1 << c;
S9xSetSoundControl (sound_switch);
}
/****************************************************************************
@ -75,25 +71,12 @@ void S9xToggleSoundChannel(int c)
*
* Main initialisation for Wii sound system
***************************************************************************/
bool8 S9xOpenSoundDevice(int mode, bool8 stereo, int buffer_size)
bool8 S9xOpenSoundDevice(void)
{
so.stereo = TRUE;
so.playback_rate = 32000;
so.sixteen_bit = TRUE;
so.encoded = 0;
so.buffer_size = 4096;
so.sound_switch = 255;
S9xSetPlaybackRate(so.playback_rate);
InitAudio();
return TRUE;
}
/*** Deprecated function. NGC uses threaded sound ***/
void S9xGenerateSound()
{
}
/* eke-eke */
void S9xInitSync()
{
@ -105,6 +88,9 @@ void S9xInitSync()
void S9xSyncSpeed ()
{
while (!S9xSyncSound())
usleep(10);
uint32 skipFrms = Settings.SkipFrames;
if (Settings.TurboMode)
@ -213,21 +199,6 @@ bool S9xPollPointer(uint32 id, int16 * x, int16 * y)
return 0;
}
void S9xLoadSDD1Data()
{
Memory.FreeSDD1Data();
Settings.SDD1Pack = FALSE;
if (strncmp(Memory.ROMName, "Star Ocean", 10) == 0)
Settings.SDD1Pack = TRUE;
if (strncmp(Memory.ROMName, "STREET FIGHTER ALPHA2", 21) == 0)
Settings.SDD1Pack = TRUE;
return;
}
/****************************************************************************
* Note that these are DUMMY functions, and only allow Snes9x to
* compile. Where possible, they will return an error signal.
@ -235,39 +206,65 @@ void S9xLoadSDD1Data()
const char *S9xChooseFilename(bool8 read_only)
{
ExitApp();
return NULL;
}
const char * S9xChooseMovieFilename(bool8 read_only)
{
ExitApp();
return NULL;
}
const char * S9xGetDirectory(enum s9x_getdirtype dirtype)
{
ExitApp();
return NULL;
}
const char * S9xGetFilename(const char *ex, enum s9x_getdirtype dirtype)
{
ExitApp();
return NULL;
}
const char * S9xGetFilenameInc(const char *e, enum s9x_getdirtype dirtype)
{
ExitApp();
return NULL;
}
char * S9xBasename(char *name)
const char * S9xBasename(const char *name)
{
ExitApp();
return name;
}
const char * S9xStringInput (const char * s)
{
ExitApp();
return s;
}
void _splitpath(char const *buf, char *drive, char *dir, char *fname, char *ext)
{
ExitApp();
}
void _makepath(char *filename, const char *drive, const char *dir,
const char *fname, const char *ext)
{
ExitApp();
}
int dup(int fildes)
{
ExitApp();
return 1;
}
int access(const char *pathname, int mode)
{
ExitApp();
return 1;
}

View File

@ -31,15 +31,7 @@
#include "snes9x.h"
#include "memmap.h"
#include "s9xdebug.h"
#include "cpuexec.h"
#include "ppu.h"
#include "apu.h"
#include "display.h"
#include "gfx.h"
#include "soundux.h"
#include "spc700.h"
#include "spc7110.h"
#include "apu/apu.h"
#include "controls.h"
#include "snes9xGX.h"
@ -397,15 +389,14 @@ main(int argc, char *argv[])
// Set Pixel Renderer to match 565
S9xSetRenderPixelFormat (RGB565);
// Initialise Snes Sound System
S9xInitSound (5, TRUE, 1024);
// Initialise Sound System
S9xInitSound (64, 0);
// Initialise Graphics
setGFX ();
if (!S9xGraphicsInit ())
ExitApp();
S9xSetSoundMute (TRUE);
S9xInitSync(); // initialize frame sync
// Initialize font system

View File

@ -116,7 +116,4 @@ extern char appPath[];
extern char loadedFile[];
extern FreeTypeGX *fontSystem[];
void WiiSetupCheats();
void WiiLoadPatch();
#endif

View File

@ -54,6 +54,14 @@ LoadSRAM (char * filepath, bool silent)
if (len - size == 512)
memmove(Memory.SRAM, Memory.SRAM + 512, size);
if (Settings.SRTC || Settings.SPC7110RTC)
{
int pathlen = strlen(filepath);
filepath[pathlen-3] = 'r';
filepath[pathlen-2] = 't';
filepath[pathlen-1] = 'c';
LoadFile((char *)RTCData.reg, filepath, 20, silent);
}
result = true;
}
else if(!silent)
@ -117,6 +125,15 @@ SaveSRAM (char * filepath, bool silent)
{
offset = SaveFile((char *)Memory.SRAM, filepath, size, silent);
if (Settings.SRTC || Settings.SPC7110RTC)
{
int pathlen = strlen(filepath);
filepath[pathlen-3] = 'r';
filepath[pathlen-2] = 't';
filepath[pathlen-1] = 'c';
SaveFile((char *)RTCData.reg, filepath, 20, silent);
}
if (offset > 0)
{
if (!silent)
@ -155,4 +172,3 @@ SaveSRAMAuto (bool silent)
return SaveSRAM(filepath, silent);
}

View File

@ -31,8 +31,8 @@
#include "input.h"
/*** Snes9x GFX Buffer ***/
#define SNES9XGFX_SIZE EXT_PITCH*EXT_HEIGHT
#define FILTERMEM_SIZE 512*MAX_SNES_HEIGHT*4
#define SNES9XGFX_SIZE (EXT_PITCH*EXT_HEIGHT)
#define FILTERMEM_SIZE (512*MAX_SNES_HEIGHT*4)
static unsigned char * snes9xgfx = NULL;
unsigned char * filtermem = NULL; // only want ((512*2) X (239*2))

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,107 +172,105 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#ifndef _65C816_H_
#define _65C816_H_
#define Carry 1
#define Zero 2
#define IRQ 4
#define Decimal 8
#define IndexFlag 16
#define MemoryFlag 32
#define Overflow 64
#define Negative 128
#define Emulation 256
#ifndef _65c816_h_
#define _65c816_h_
#define SetCarry() (ICPU._Carry = 1)
#define ClearCarry() (ICPU._Carry = 0)
#define SetZero() (ICPU._Zero = 0)
#define ClearZero() (ICPU._Zero = 1)
#define SetIRQ() (Registers.PL |= IRQ)
#define ClearIRQ() (Registers.PL &= ~IRQ)
#define SetDecimal() (Registers.PL |= Decimal)
#define ClearDecimal() (Registers.PL &= ~Decimal)
#define SetIndex() (Registers.PL |= IndexFlag)
#define ClearIndex() (Registers.PL &= ~IndexFlag)
#define SetMemory() (Registers.PL |= MemoryFlag)
#define ClearMemory() (Registers.PL &= ~MemoryFlag)
#define SetOverflow() (ICPU._Overflow = 1)
#define ClearOverflow() (ICPU._Overflow = 0)
#define SetNegative() (ICPU._Negative = 0x80)
#define ClearNegative() (ICPU._Negative = 0)
#define AL A.B.l
#define AH A.B.h
#define XL X.B.l
#define XH X.B.h
#define YL Y.B.l
#define YH Y.B.h
#define SL S.B.l
#define SH S.B.h
#define DL D.B.l
#define DH D.B.h
#define PL P.B.l
#define PH P.B.h
#define CheckCarry() (ICPU._Carry)
#define CheckZero() (ICPU._Zero == 0)
#define CheckIRQ() (Registers.PL & IRQ)
#define CheckDecimal() (Registers.PL & Decimal)
#define CheckIndex() (Registers.PL & IndexFlag)
#define CheckMemory() (Registers.PL & MemoryFlag)
#define CheckOverflow() (ICPU._Overflow)
#define CheckNegative() (ICPU._Negative & 0x80)
#define CheckEmulation() (Registers.P.W & Emulation)
#define Carry 1
#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 ClearCarry() (ICPU._Carry = 0)
#define SetCarry() (ICPU._Carry = 1)
#define SetZero() (ICPU._Zero = 0)
#define ClearZero() (ICPU._Zero = 1)
#define SetIRQ() (Registers.PL |= IRQ)
#define ClearIRQ() (Registers.PL &= ~IRQ)
#define SetDecimal() (Registers.PL |= Decimal)
#define ClearDecimal() (Registers.PL &= ~Decimal)
#define SetIndex() (Registers.PL |= IndexFlag)
#define ClearIndex() (Registers.PL &= ~IndexFlag)
#define SetMemory() (Registers.PL |= MemoryFlag)
#define ClearMemory() (Registers.PL &= ~MemoryFlag)
#define SetOverflow() (ICPU._Overflow = 1)
#define ClearOverflow() (ICPU._Overflow = 0)
#define SetNegative() (ICPU._Negative = 0x80)
#define ClearNegative() (ICPU._Negative = 0)
#define CheckZero() (ICPU._Zero == 0)
#define CheckCarry() (ICPU._Carry)
#define CheckIRQ() (Registers.PL & IRQ)
#define CheckDecimal() (Registers.PL & Decimal)
#define CheckIndex() (Registers.PL & IndexFlag)
#define CheckMemory() (Registers.PL & MemoryFlag)
#define CheckOverflow() (ICPU._Overflow)
#define CheckNegative() (ICPU._Negative & 0x80)
#define CheckEmulation() (Registers.P.W & Emulation)
#define ClearFlags(f) (Registers.P.W &= ~(f))
#define SetFlags(f) (Registers.P.W |= (f))
#define CheckFlag(f) (Registers.PL & (f))
#define SetFlags(f) (Registers.P.W |= (f))
#define ClearFlags(f) (Registers.P.W &= ~(f))
#define CheckFlag(f) (Registers.PL & (f))
typedef union
{
#ifdef LSB_FIRST
struct { uint8 l,h; } B;
struct { uint8 l, h; } B;
#else
struct { uint8 h,l; } B;
struct { uint8 h, l; } B;
#endif
uint16 W;
} pair;
uint16 W;
} pair;
typedef union {
typedef union
{
#ifdef LSB_FIRST
struct { uint8 xPCl, xPCh, xPB, z; } B;
struct { uint16 xPC, d; } W;
struct { uint8 xPCl, xPCh, xPB, z; } B;
struct { uint16 xPC, d; } W;
#else
struct { uint8 z, xPB, xPCh, xPCl; } B;
struct { uint16 d, xPC; } W;
struct { uint8 z, xPB, xPCh, xPCl; } B;
struct { uint16 d, xPC; } W;
#endif
uint32 xPBPC;
} PC_t;
uint32 xPBPC;
} PC_t;
struct SRegisters{
uint8 DB;
pair P;
pair A;
pair D;
pair S;
pair X;
pair Y;
PC_t PC;
struct SRegisters
{
uint8 DB;
pair P;
pair A;
pair D;
pair S;
pair X;
pair Y;
PC_t PC;
};
#define PBPC PC.xPBPC
#define PCw PC.W.xPC
#define PCh PC.B.xPCh
#define PCl PC.B.xPCl
#define PB PC.B.xPB
#define AL A.B.l
#define AH A.B.h
#define XL X.B.l
#define XH X.B.h
#define YL Y.B.l
#define YH Y.B.h
#define SL S.B.l
#define SH S.B.h
#define DL D.B.l
#define DH D.B.h
#define PL P.B.l
#define PH P.B.h
#define PBPC PC.xPBPC
#define PCw PC.W.xPC
#define PCh PC.B.xPCh
#define PCl PC.B.xPCl
#define PB PC.B.xPB
EXTERN_C struct SRegisters Registers;
extern struct SRegisters Registers;
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,297 +0,0 @@
/**********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
Jerremy Koot (jkoot@snes9x.com)
(c) Copyright 2002 - 2004 Matthew Kendora
(c) Copyright 2002 - 2005 Peter Bortas (peter@bortas.org)
(c) Copyright 2004 - 2005 Joel Yliluoma (http://iki.fi/bisqwit/)
(c) Copyright 2001 - 2006 John Weidman (jweidman@slip.net)
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
zones
C4 x86 assembler and some C emulation code
(c) Copyright 2000 - 2003 _Demo_ (_demo_@zsnes.com),
Nach,
zsKnight (zsknight@zsnes.com)
C4 C++ code
(c) Copyright 2003 - 2006 Brad Jorsch,
Nach
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
Kris Bleakley,
Matthew Kendora,
Nach,
neviksti (neviksti@hotmail.com)
DSP-2 emulator code
(c) Copyright 2003 John Weidman,
Kris Bleakley,
Lord Nightmare (lord_nightmare@users.sourceforge.net),
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
Lancer,
z80 gaiden
DSP-4 emulator code
(c) Copyright 2004 - 2006 Dreamer Nom,
John Weidman,
Kris Bleakley,
Nach,
z80 gaiden
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
John Weidman
ST010 C++ emulator code
(c) Copyright 2003 Feather,
John Weidman,
Kris Bleakley,
Matthew Kendora
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
2xSaI filter
(c) Copyright 1999 - 2001 Derek Liauw Kie Fa
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
fee, providing that this license information and copyright notice appear
with all copies and any derived work.
This software is provided 'as-is', without any express or implied
warranty. In no event shall the authors be held liable for any damages
arising from the use of this software or it's derivatives.
Snes9x is freeware for PERSONAL USE only. Commercial users should
seek permission of the copyright holders first. Commercial use includes,
but is not limited to, charging money for Snes9x or software derived from
Snes9x, including Snes9x or derivatives in commercial game bundles, and/or
using Snes9x as a promotion for your commercial product.
The copyright holders request that bug fixes and improvements to the code
should be forwarded to them so everyone can benefit from the modifications
in future versions.
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
#ifndef _apu_h_
#define _apu_h_
#include "spc700.h"
struct SIAPU
{
uint8 *PC;
uint8 *RAM;
uint8 *DirectPage;
bool8 APUExecuting;
uint8 Bit;
uint32 Address;
uint8 *WaitAddress1;
uint8 *WaitAddress2;
uint32 WaitCounter;
uint8 *ShadowRAM; // unused
uint8 *CachedSamples; // unused
uint8 _Carry;
uint8 _Zero;
uint8 _Overflow;
uint32 TimerErrorCounter;
uint32 Scanline;
int32 OneCycle;
int32 TwoCycles;
bool8 KONNotifier;
bool8 KOFFNotifier;
bool8 OUTXNotifier;
bool8 ENVXNotifier;
bool8 ENDXNotifier;
};
struct SAPU
{
int32 OldCycles; // unused
bool8 ShowROM;
uint32 Flags;
uint8 KeyedChannels;
uint8 OutPorts [4];
uint8 DSP [0x80];
uint8 ExtraRAM [64];
uint16 Timer [3];
uint16 TimerTarget [3];
bool8 TimerEnabled [3];
bool8 TimerValueWritten [3];
int32 Cycles;
int32 NextAPUTimerPos;
int32 APUTimerCounter;
};
EXTERN_C struct SAPU APU;
EXTERN_C struct SIAPU IAPU;
extern int spc_is_dumping;
extern int spc_is_dumping_temp;
extern uint8 spc_dump_dsp[0x100];
STATIC inline void S9xAPUUnpackStatus()
{
IAPU._Zero = ((APURegisters.P & Zero) == 0) | (APURegisters.P & Negative);
IAPU._Carry = (APURegisters.P & Carry);
IAPU._Overflow = (APURegisters.P & Overflow) >> 6;
}
STATIC inline void S9xAPUPackStatus()
{
APURegisters.P &= ~(Zero | Negative | Carry | Overflow);
APURegisters.P |= IAPU._Carry | ((IAPU._Zero == 0) << 1) |
(IAPU._Zero & 0x80) | (IAPU._Overflow << 6);
}
START_EXTERN_C
void S9xResetAPU (void);
bool8 S9xInitAPU ();
void S9xDeinitAPU ();
void S9xDecacheSamples ();
int S9xTraceAPU ();
int S9xAPUOPrint (char *buffer, uint16 Address);
void S9xSetAPUControl (uint8 byte);
void S9xSetAPUDSP (uint8 byte);
uint8 S9xGetAPUDSP ();
void S9xSetAPUTimer (uint16 Address, uint8 byte);
void S9xAPUExecute (void);
bool8 S9xInitSound (int quality, bool8 stereo, int buffer_size);
void S9xOpenCloseSoundTracingFile (bool8);
void S9xPrintAPUState ();
extern int32 S9xAPUCycles [256]; // Scaled cycle lengths
extern int32 S9xAPUCycleLengths [256]; // Raw data.
extern void (*S9xApuOpcodes [256]) (void);
END_EXTERN_C
#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_MVOL_RIGHT 0x1c
#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_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_C0 0x0f
#define APU_C1 0x1f
#define APU_C2 0x2f
#define APU_C3 0x3f
#define APU_C4 0x4f
#define APU_C5 0x5f
#define APU_C6 0x6f
#define APU_C7 0x7f
#define APU_SOFT_RESET 0x80
#define APU_MUTE 0x40
#define APU_ECHO_DISABLED 0x20
#define FREQUENCY_MASK 0x3fff
#endif

View File

@ -1,509 +0,0 @@
/**********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
Jerremy Koot (jkoot@snes9x.com)
(c) Copyright 2002 - 2004 Matthew Kendora
(c) Copyright 2002 - 2005 Peter Bortas (peter@bortas.org)
(c) Copyright 2004 - 2005 Joel Yliluoma (http://iki.fi/bisqwit/)
(c) Copyright 2001 - 2006 John Weidman (jweidman@slip.net)
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
zones
C4 x86 assembler and some C emulation code
(c) Copyright 2000 - 2003 _Demo_ (_demo_@zsnes.com),
Nach,
zsKnight (zsknight@zsnes.com)
C4 C++ code
(c) Copyright 2003 - 2006 Brad Jorsch,
Nach
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
Kris Bleakley,
Matthew Kendora,
Nach,
neviksti (neviksti@hotmail.com)
DSP-2 emulator code
(c) Copyright 2003 John Weidman,
Kris Bleakley,
Lord Nightmare (lord_nightmare@users.sourceforge.net),
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
Lancer,
z80 gaiden
DSP-4 emulator code
(c) Copyright 2004 - 2006 Dreamer Nom,
John Weidman,
Kris Bleakley,
Nach,
z80 gaiden
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
John Weidman
ST010 C++ emulator code
(c) Copyright 2003 Feather,
John Weidman,
Kris Bleakley,
Matthew Kendora
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
2xSaI filter
(c) Copyright 1999 - 2001 Derek Liauw Kie Fa
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
fee, providing that this license information and copyright notice appear
with all copies and any derived work.
This software is provided 'as-is', without any express or implied
warranty. In no event shall the authors be held liable for any damages
arising from the use of this software or it's derivatives.
Snes9x is freeware for PERSONAL USE only. Commercial users should
seek permission of the copyright holders first. Commercial use includes,
but is not limited to, charging money for Snes9x or software derived from
Snes9x, including Snes9x or derivatives in commercial game bundles, and/or
using Snes9x as a promotion for your commercial product.
The copyright holders request that bug fixes and improvements to the code
should be forwarded to them so everyone can benefit from the modifications
in future versions.
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
#include "snes9x.h"
#include "spc700.h"
#include "apu.h"
#include "soundux.h"
#include "cpuexec.h"
#ifdef DEBUGGER
extern int32 env_counter_table[32];
FILE *apu_trace = NULL;
static char *S9xMnemonics [256] = {
"NOP", "TCALL 0", "SET1 $%02X.0", "BBS $%02X.0,$%04X",
"OR A,$%02X", "OR A,!$%04X", "OR A,(X)", "OR A,[$%02X+X]",
"OR A,#$%02X", "OR $%02X,$%02X", "OR1 C,$%04X.%d", "ASL $%02X",
"MOV !$%04X,Y", "PUSH PSW", "TSET1 !$%04X", "BRK",
"BPL $%04X", "TCALL 1", "CLR1 $%02X.0", "BBC $%02X.0,$%04X",
"OR A,$%02X+X", "OR A,!$%04X+X", "OR A,!$%04X+Y", "OR A,[$%02X]+Y",
"OR $%02X,#$%02X", "OR (X),(Y)", "DECW $%02X", "ASL $%02X+X",
"ASL A", "DEC X", "CMP X,!$%04X", "JMP [!$%04X+X]",
"CLRP", "TCALL 2", "SET1 $%02X.1", "BBS $%02X.1,$%04X",
"AND A,$%02X", "AND A,!$%04X", "AND A,(X)", "AND A,[$%02X+X]",
"AND A,#$%02X", "AND $%02X,$%02X", "OR1 C,/$%04X.%d", "ROL $%02X",
"ROL !$%04X", "PUSH A", "CBNE $%02X,$%04X", "BRA $%04X",
"BMI $%04X", "TCALL 3", "CLR1 $%02X.1", "BBC $%02X.1,$%04X",
"AND A,$%02X+X", "AND A,!$%04X+X", "AND A,!$%04X+Y", "AND A,[$%02X]+Y",
"AND $%02X,#$%02X", "AND (X),(Y)", "INCW $%02X", "ROL $%02X+X",
"ROL A", "INC X", "CMP X,$%02X", "CALL !$%04X",
"SETP", "TCALL 4", "SET1 $%02X.2", "BBS $%02X.2,$%04X",
"EOR A,$%02X", "EOR A,!$%04X", "EOR A,(X)", "EOR A,[$%02X+X]",
"EOR A,#$%02X", "EOR $%02X,$%02X", "AND1 C,$%04X.%d", "LSR $%02X",
"LSR !$%04X", "PUSH X", "TCLR1 !$%04X", "PCALL $%02X",
"BVC $%04X", "TCALL 5", "CLR1 $%02X.2", "BBC $%02X.2,$%04X",
"EOR A,$%02X+X", "EOR A,!$%04X+X", "EOR A,!$%04X+Y", "EOR A,[$%02X]+Y",
"EOR $%02X,#$%02X", "EOR (X),(Y)", "CMPW YA,$%02X", "LSR $%02X+X",
"LSR A", "MOV X,A", "CMP Y,!$%04X", "JMP !$%04X",
"CLRC", "TCALL 6", "SET1 $%02X.3", "BBS $%02X.3,$%04X",
"CMP A,$%02X", "CMP A,!$%04X", "CMP A,(X)", "CMP A,[$%02X+X]",
"CMP A,#$%02X", "CMP $%02X,$%02X", "AND1 C,/$%04X.%d", "ROR $%02X",
"ROR !$%04X", "PUSH Y", "DBNZ $%02X,$%04X", "RET",
"BVS $%04X", "TCALL 7", "CLR1 $%02X.3", "BBC $%02X.3,$%04X",
"CMP A,$%02X+X", "CMP A,!$%04X+X", "CMP A,!$%04X+Y", "CMP A,[$%02X]+Y",
"CMP $%02X,#$%02X", "CMP (X),(Y)", "ADDW YA,$%02X", "ROR $%02X+X",
"ROR A", "MOV A,X", "CMP Y,$%02X", "RET1",
"SETC", "TCALL 8", "SET1 $%02X.4", "BBS $%02X.4,$%04X",
"ADC A,$%02X", "ADC A,!$%04X", "ADC A,(X)", "ADC A,[$%02X+X]",
"ADC A,#$%02X", "ADC $%02X,$%02X", "EOR1 C,$%04X.%d", "DEC $%02X",
"DEC !$%04X", "MOV Y,#$%02X", "POP PSW", "MOV $%02X,#$%02X",
"BCC $%04X", "TCALL 9", "CLR1 $%02X.4", "BBC $%02X.4,$%04X",
"ADC A,$%02X+X", "ADC A,!$%04X+X", "ADC A,!$%04X+Y", "ADC A,[$%02X]+Y",
"ADC $%02X,#$%02X", "ADC (X),(Y)", "SUBW YA,$%02X", "DEC $%02X+X",
"DEC A", "MOV X,SP", "DIV YA,X", "XCN A",
"EI", "TCALL 10", "SET1 $%02X.5", "BBS $%02X.5,$%04X",
"SBC A,$%02X", "SBC A,!$%04X", "SBC A,(X)", "SBC A,[$%02X+X]",
"SBC A,#$%02X", "SBC $%02X,$%02X", "MOV1 C,$%04X.%d", "INC $%02X",
"INC !$%04X", "CMP Y,#$%02X", "POP A", "MOV (X)+,A",
"BCS $%04X", "TCALL 11", "CLR1 $%02X.5", "BBC $%02X.5,$%04X",
"SBC A,$%02X+X", "SBC A,!$%04X+X", "SBC A,!$%04X+Y", "SBC A,[$%02X]+Y",
"SBC $%02X,#$%02X", "SBC (X),(Y)", "MOVW YA,$%02X", "INC $%02X+X",
"INC A", "MOV SP,X", "DAS A", "MOV A,(X)+",
"DI", "TCALL 12", "SET1 $%02X.6", "BBS $%02X.6,$%04X",
"MOV $%02X,A", "MOV !$%04X,A", "MOV (X),A", "MOV [$%02X+X],A",
"CMP X,#$%02X", "MOV !$%04X,X", "MOV1 $%04X.%d,C", "MOV $%02X,Y",
"ASL !$%04X", "MOV X,#$%02X", "POP X", "MUL YA",
"BNE $%04X", "TCALL 13", "CLR1 $%02X.6", "BBC $%02X.6,$%04X",
"MOV $%02X+X,A", "MOV !$%04X+X,A", "MOV !$%04X+Y,A", "MOV [$%02X]+Y,A",
"MOV $%02X,X", "MOV $%02X+Y,X", "MOVW $%02X,YA", "MOV $%02X+X,Y",
"DEC Y", "MOV A,Y", "CBNE $%02X+X,$%04X", "DAA A",
"CLRV", "TCALL 14", "SET1 $%02X.7", "BBS $%02X.7,$%04X",
"MOV A,$%02X", "MOV A,!$%04X", "MOV A,(X)", "MOV A,[$%02X+X]",
"MOV A,#$%02X", "MOV X,!$%04X", "NOT1 $%04X.%d", "MOV Y,$%02X",
"MOV Y,!$%04X", "NOTC", "POP Y", "SLEEP",
"BEQ $%04X", "TCALL 15", "CLR1 $%02X.7", "BBC $%02X.7,$%04X",
"MOV A,$%02X+X", "MOV A,!$%04X+X", "MOV A,!$%04X+Y", "MOV A,[$%02X]+Y",
"MOV X,$%02X", "MOV X,$%02X+Y", "MOV $%02X,$%02X", "MOV Y,$%02X+X",
"INC Y", "MOV Y,A", "DBNZ Y,$%04X", "STOP"
};
#undef ABS
#define DP 0
#define ABS 1
#define IM 2
#define DP2DP 3
#define DPIM 4
#define DPREL 5
#define ABSBIT 6
#define REL 7
static uint8 Modes [256] = {
IM, IM, DP, DPREL,
DP, ABS, IM, DP,
DP, DP2DP, ABSBIT, DP,
ABS, IM, ABS, IM,
REL, IM, DP, DPREL,
DP, ABS, ABS, DP,
DPIM, IM, DP, DP,
IM, IM, ABS, ABS,
IM, IM, DP, DPREL,
DP, ABS, IM, DP,
DP, DP2DP, ABSBIT, DP,
ABS, IM, DPREL, REL,
REL, IM, DP, DPREL,
DP, ABS, ABS, DP,
DPIM, IM, DP, DP,
IM, IM, DP, ABS,
IM, IM, DP, DPREL,
DP, ABS, IM, DP,
DP, DP2DP, ABSBIT, DP,
ABS, IM, ABS, DP,
REL, IM, DP, DPREL,
DP, ABS, ABS, DP,
DPIM, IM, DP, DP,
IM, IM, ABS, ABS,
IM, IM, DP, DPREL,
DP, ABS, IM, DP,
DP, DP2DP, ABSBIT, DP,
ABS, IM, DPREL, IM,
REL, IM, DP, DPREL,
DP, ABS, ABS, DP,
DPIM, IM, DP, DP,
IM, IM, DP, IM,
IM, IM, DP, DPREL,
DP, ABS, IM, DP,
DP, DP2DP, ABSBIT, DP,
ABS, DP, IM, DPIM,
REL, IM, DP, DPREL,
DP, ABS, ABS, DP,
DPIM, IM, DP, DP,
IM, IM, IM, IM,
IM, IM, DP, DPREL,
DP, ABS, IM, DP,
DP, DP2DP, ABSBIT, DP,
ABS, DP, IM, IM,
REL, IM, DP, DPREL,
DP, ABS, ABS, DP,
DPIM, IM, DP, DP,
IM, IM, IM, IM,
IM, IM, DP, DPREL,
DP, ABS, IM, DP,
DP, ABS, ABSBIT, DP,
ABS, DP, IM, IM,
REL, IM, DP, DPREL,
DP, ABS, ABS, DP,
DP, DP, DP, DP,
IM, IM, DPREL, IM,
IM, IM, DP, DPREL,
DP, ABS, IM, DP,
DP, ABS, ABSBIT, DP,
ABS, IM, IM, IM,
REL, IM, DP, DPREL,
DP, ABS, ABS, DP,
DP, DP, DP2DP, DP,
IM, IM, REL, IM
};
static uint8 ModesToBytes [] = {
2, 3, 1, 3, 3, 3, 3, 2
};
static FILE *SoundTracing = NULL;
void S9xOpenCloseSoundTracingFile (bool8 open)
{
if (open && !SoundTracing)
{
SoundTracing = fopen ("sound_trace.log", "w");
}
else
if (!open && SoundTracing)
{
fclose (SoundTracing);
SoundTracing = NULL;
}
}
void S9xTraceSoundDSP (const char *s, int i1 = 0, int i2 = 0, int i3 = 0,
int i4 = 0, int i5 = 0, int i6 = 0, int i7 = 0)
{
fprintf (SoundTracing, s, i1, i2, i3, i4, i5, i6, i7);
}
int S9xTraceAPU ()
{
char buffer [200];
uint8 b = S9xAPUOPrint (buffer, IAPU.PC - IAPU.RAM);
if (apu_trace == NULL)
apu_trace = fopen ("apu_trace.log", "wb");
fprintf (apu_trace, "%s\n", buffer);
return (b);
}
int S9xAPUOPrint (char *buffer, uint16 Address)
{
char mnem [100];
uint8 *p = IAPU.RAM + Address;
int mode = Modes [*p];
int bytes = ModesToBytes [mode];
switch (bytes)
{
case 1:
sprintf (buffer, "%04X %02X ", p - IAPU.RAM, *p);
break;
case 2:
sprintf (buffer, "%04X %02X %02X ", p - IAPU.RAM, *p,
*(p + 1));
break;
case 3:
sprintf (buffer, "%04X %02X %02X %02X ", p - IAPU.RAM, *p,
*(p + 1), *(p + 2));
break;
}
switch (mode)
{
case DP:
sprintf (mnem, S9xMnemonics [*p], *(p + 1));
break;
case ABS:
sprintf (mnem, S9xMnemonics [*p], *(p + 1) + (*(p + 2) << 8));
break;
case IM:
sprintf (mnem, S9xMnemonics [*p]);
break;
case DP2DP:
sprintf (mnem, S9xMnemonics [*p], *(p + 2), *(p + 1));;
break;
case DPIM:
sprintf (mnem, S9xMnemonics [*p], *(p + 2), *(p + 1));;
break;
case DPREL:
sprintf (mnem, S9xMnemonics [*p], *(p + 1),
(int) (p + 3 - IAPU.RAM) + (signed char) *(p + 2));
break;
case ABSBIT:
sprintf (mnem, S9xMnemonics [*p], (*(p + 1) + (*(p + 2) << 8)) & 0x1fff,
*(p + 2) >> 5);
break;
case REL:
sprintf (mnem, S9xMnemonics [*p],
(int) (p + 2 - IAPU.RAM) + (signed char) *(p + 1));
break;
}
sprintf (buffer, "%s %-20s A:%02X X:%02X Y:%02X S:%02X P:%c%c%c%c%c%c%c%c %03ld %04ld %04d",
buffer, mnem,
APURegisters.YA.B.A, APURegisters.X, APURegisters.YA.B.Y,
APURegisters.S,
APUCheckNegative () ? 'N' : 'n',
APUCheckOverflow () ? 'V' : 'v',
APUCheckDirectPage () ? 'P' : 'p',
APUCheckBreak () ? 'B' : 'b',
APUCheckHalfCarry () ? 'H' : 'h',
APUCheckInterrupt () ? 'I' : 'i',
APUCheckZero () ? 'Z' : 'z',
APUCheckCarry () ? 'C' : 'c',
CPU.V_Counter,
CPU.Cycles,
APU.Cycles >> SNES_APU_ACCURACY);
return (bytes);
}
const char *as_binary (uint8 data)
{
static char buf [9];
for (int i = 7; i >= 0; i--)
buf [7 - i] = ((data & (1 << i)) != 0) + '0';
buf [8] = 0;
return (buf);
}
void S9xPrintAPUState ()
{
printf ("Master volume left: %d, right: %d\n",
SoundData.master_volume_left, SoundData.master_volume_right);
printf ("Echo: %s %s, Delay: %d Feedback: %d Left: %d Right: %d\n",
SoundData.echo_write_enabled ? "on" : "off",
as_binary (SoundData.echo_enable),
SoundData.echo_buffer_size >> 9,
SoundData.echo_feedback, SoundData.echo_volume_left,
SoundData.echo_volume_right);
printf ("Noise: %s, Frequency: %d, Pitch mod: %s\n", as_binary (APU.DSP [APU_NON]),
env_counter_table [APU.DSP [APU_FLG] & 0x1f],
as_binary (SoundData.pitch_mod));
extern int FilterTaps [8];
printf ("Filter: ");
for (int i = 0; i < 8; i++)
printf ("%03d, ", FilterTaps [i]);
printf ("\n");
for (int J = 0; J < 8; J++)
{
register Channel *ch = &SoundData.channels[J];
printf ("%d: ", J);
if (ch->state == SOUND_SILENT)
{
printf ("off\n");
}
else
if (!(so.sound_switch & (1 << J)))
printf ("muted by user using channel on/off toggle\n");
else
{
int freq = ch->hertz;
if (APU.DSP [APU_NON] & (1 << J)) //ch->type == SOUND_NOISE)
{
freq = env_counter_table [APU.DSP [APU_FLG] & 0x1f];
printf ("noise, ");
}
else
printf ("sample %d, ", APU.DSP [APU_SRCN + J * 0x10]);
printf ("freq: %d", freq);
if (J > 0 && (SoundData.pitch_mod & (1 << J)) &&
ch->type != SOUND_NOISE)
{
printf ("(mod), ");
}
else
printf (", ");
printf ("left: %d, right: %d, ",
ch->volume_left, ch->volume_right);
static char* envelope [] =
{
"silent", "attack", "decay", "sustain", "release", "gain",
"inc_lin", "inc_bent", "dec_lin", "dec_exp"
};
printf ("%s envx: %d, target: %d, %ld", ch->state > 9 ? "???" : envelope [ch->state],
ch->envx, ch->envx_target, ch->erate);
printf ("\n");
}
}
}
#endif

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,51 +172,49 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
// Anonymous wrote:
// Dreamer Nom wrote:
// Large thanks to John Weidman for all his initial research
// Thanks to Seph3 for his modem notes
#include <time.h>
#include "snes9x.h"
#include "memmap.h"
#include "display.h"
#include "bsx.h"
//#define BSX_DEBUG
//#define BSX_DEBUG
#define BIOS_SIZE 0x100000
#define FLASH_SIZE 0x200000
#define PSRAM_SIZE 0x80000
#define BIOS_SIZE 0x100000
#define FLASH_SIZE 0x200000
#define PSRAM_SIZE 0x80000
#define Map Memory.Map
#define BlockIsRAM Memory.BlockIsRAM
#define BlockIsROM Memory.BlockIsROM
#define RAM Memory.RAM
#define SRAM Memory.SRAM
#define PSRAM Memory.BSRAM
#define BIOSROM Memory.BIOSROM
#define MAP_BSX Memory.MAP_BSX
#define MAP_CPU Memory.MAP_CPU
#define MAP_PPU Memory.MAP_PPU
#define MAP_NONE Memory.MAP_NONE
#define Map Memory.Map
#define BlockIsRAM Memory.BlockIsRAM
#define BlockIsROM Memory.BlockIsROM
#define RAM Memory.RAM
#define SRAM Memory.SRAM
#define PSRAM Memory.BSRAM
#define BIOSROM Memory.BIOSROM
#define MAP_BSX Memory.MAP_BSX
#define MAP_CPU Memory.MAP_CPU
#define MAP_PPU Memory.MAP_PPU
#define MAP_NONE Memory.MAP_NONE
#define BSXPPUBASE 0x2180
struct SBSX_RTC
{
int hours;
int minutes;
int seconds;
int ticks;
int hours;
int minutes;
int seconds;
int ticks;
};
struct SBSX_RTC BSX_RTC;
static struct SBSX_RTC BSX_RTC;
// flash card vendor information
const uint8 flashcard[20] =
static const uint8 flashcard[20] =
{
0x4D, 0x00, 0x50, 0x00, // vendor id
0x00, 0x00, // ?
@ -209,7 +223,7 @@ const uint8 flashcard[20] =
0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
const uint8 init2192[32] = // FIXME
static const uint8 init2192[32] = // FIXME
{
00, 00, 00, 00, 00, // unknown
01, 01, 00, 00, 00,
@ -221,29 +235,29 @@ const uint8 init2192[32] = // FIXME
00, 00, 00, 00, 00, 00, 00, 00, 00
};
bool8 FlashMode;
uint32 FlashSize;
uint8 *MapROM, *FlashROM;
static bool8 FlashMode;
static uint32 FlashSize;
static uint8 *MapROM, *FlashROM;
static void BSX_Map_SNES(void);
static void BSX_Map_LoROM(void);
static void BSX_Map_HiROM(void);
static void BSX_Map_MMC(void);
static void BSX_Map_FlashIO(void);
static void BSX_Map_SRAM(void);
static void BSX_Map_PSRAM(void);
static void BSX_Map_BIOS(void);
static void BSX_Map_RAM(void);
static void BSX_Map_Dirty(void);
static void BSX_Map(void);
static void BSX_Set_Bypass_FlashIO(uint16, uint8);
static uint8 BSX_Get_Bypass_FlashIO(uint16);
static bool8 BSX_LoadBIOS(void);
static void map_psram_mirror_sub(uint32);
static int is_bsx(unsigned char *);
static void BSX_Map_SNES (void);
static void BSX_Map_LoROM (void);
static void BSX_Map_HiROM (void);
static void BSX_Map_MMC (void);
static void BSX_Map_FlashIO (void);
static void BSX_Map_SRAM (void);
static void BSX_Map_PSRAM (void);
static void BSX_Map_BIOS (void);
static void BSX_Map_RAM (void);
static void BSX_Map_Dirty (void);
static void BSX_Map (void);
static void BSX_Set_Bypass_FlashIO (uint16, uint8);
static uint8 BSX_Get_Bypass_FlashIO (uint16);
static bool8 BSX_LoadBIOS (void);
static void map_psram_mirror_sub (uint32);
static int is_bsx (unsigned char *);
static void BSX_Map_SNES(void)
static void BSX_Map_SNES (void)
{
// These maps will be partially overwritten
@ -266,7 +280,7 @@ static void BSX_Map_SNES(void)
}
}
static void BSX_Map_LoROM(void)
static void BSX_Map_LoROM (void)
{
// These maps will be partially overwritten
@ -300,7 +314,7 @@ static void BSX_Map_LoROM(void)
}
}
static void BSX_Map_HiROM(void)
static void BSX_Map_HiROM (void)
{
// These maps will be partially overwritten
@ -329,7 +343,7 @@ static void BSX_Map_HiROM(void)
}
}
static void BSX_Map_MMC(void)
static void BSX_Map_MMC (void)
{
int c;
@ -341,7 +355,7 @@ static void BSX_Map_MMC(void)
}
}
static void BSX_Map_FlashIO(void)
static void BSX_Map_FlashIO (void)
{
int c;
@ -357,7 +371,7 @@ static void BSX_Map_FlashIO(void)
}
}
static void BSX_Map_SRAM(void)
static void BSX_Map_SRAM (void)
{
int c;
@ -370,7 +384,7 @@ static void BSX_Map_SRAM(void)
}
}
static void map_psram_mirror_sub(uint32 bank)
static void map_psram_mirror_sub (uint32 bank)
{
int i, c;
@ -407,7 +421,7 @@ static void map_psram_mirror_sub(uint32 bank)
}
}
static void BSX_Map_PSRAM(void)
static void BSX_Map_PSRAM (void)
{
int c;
@ -445,7 +459,7 @@ static void BSX_Map_PSRAM(void)
map_psram_mirror_sub(0x60);
}
static void BSX_Map_BIOS(void)
static void BSX_Map_BIOS (void)
{
int i,c;
@ -478,7 +492,7 @@ static void BSX_Map_BIOS(void)
}
}
static void BSX_Map_RAM(void)
static void BSX_Map_RAM (void)
{
int c;
@ -494,7 +508,7 @@ static void BSX_Map_RAM(void)
}
}
static void BSX_Map_Dirty(void)
static void BSX_Map_Dirty (void)
{
// for the quick bank change
@ -527,7 +541,7 @@ static void BSX_Map_Dirty(void)
}
}
static void BSX_Map(void)
static void BSX_Map (void)
{
#ifdef BSX_DEBUG
printf("BS: Remapping\n");
@ -582,20 +596,20 @@ static void BSX_Map(void)
Memory.map_WriteProtectROM();
}
static uint8 BSX_Get_Bypass_FlashIO(uint16 offset)
static uint8 BSX_Get_Bypass_FlashIO (uint16 offset)
{
if (BSX.MMC[0x02])
return MapROM[offset];
return (MapROM[offset]);
else
{
if (offset < 0x8000)
return MapROM[offset];
return (MapROM[offset]);
else
return MapROM[offset - 0x8000];
return (MapROM[offset - 0x8000]);
}
}
static void BSX_Set_Bypass_FlashIO(uint16 offset, uint8 byte)
static void BSX_Set_Bypass_FlashIO (uint16 offset, uint8 byte)
{
if (BSX.MMC[0x02])
MapROM[offset] = byte;
@ -608,7 +622,7 @@ static void BSX_Set_Bypass_FlashIO(uint16 offset, uint8 byte)
}
}
uint8 S9xGetBSX(uint32 address)
uint8 S9xGetBSX (uint32 address)
{
uint8 bank = (address >> 16) & 0xFF;
uint16 offset = address & 0xFFFF;
@ -616,7 +630,7 @@ uint8 S9xGetBSX(uint32 address)
// MMC
if ((bank >= 0x01 && bank <= 0x0E) && (offset == 0x5000))
return BSX.MMC[bank];
return (BSX.MMC[bank]);
// Flash IO
if (bank == 0xC0)
@ -654,10 +668,10 @@ uint8 S9xGetBSX(uint32 address)
}
}
return t;
return (t);
}
void S9xSetBSX(uint8 byte, uint32 address)
void S9xSetBSX (uint8 byte, uint32 address)
{
uint8 bank = (address >> 16) & 0xFF;
uint16 offset = address & 0xFFFF;
@ -776,210 +790,207 @@ void S9xSetBSX(uint8 byte, uint32 address)
}
}
uint8 S9xGetBSXPPU(uint16 address)
uint8 S9xGetBSXPPU (uint16 address)
{
uint8 t = 0;
uint8 t;
if (address >= 0x2188 && address <= 0x219F)
// known read registers
switch (address)
{
// known read registers
switch(address)
{
// Test register low? (r/w)
case 0x2188:
t = BSX.PPU[0x2188];
break;
// Test register low? (r/w)
case 0x2188:
t = BSX.PPU[0x2188 - BSXPPUBASE];
break;
// Test register high? (r/w)
case 0x2189:
t = BSX.PPU[0x2189];
break;
// Test register high? (r/w)
case 0x2189:
t = BSX.PPU[0x2189 - BSXPPUBASE];
break;
case 0x218A:
t = BSX.PPU[0x218A];
break;
case 0x218A:
t = BSX.PPU[0x218A - BSXPPUBASE];
break;
case 0x218C:
t = BSX.PPU[0x218C];
break;
case 0x218C:
t = BSX.PPU[0x218C - BSXPPUBASE];
break;
// Transmission number low? (r/w)
case 0x218E:
t = BSX.PPU[0x218E];
break;
// Transmission number low? (r/w)
case 0x218E:
t = BSX.PPU[0x218E - BSXPPUBASE];
break;
// Transmission number high? (r/w)
case 0x218F:
t = BSX.PPU[0x218F];
break;
// Transmission number high? (r/w)
case 0x218F:
t = BSX.PPU[0x218F - BSXPPUBASE];
break;
// Status register? (r)
case 0x2190:
t = BSX.PPU[0x2190];
break;
// Status register? (r)
case 0x2190:
t = BSX.PPU[0x2190 - BSXPPUBASE];
break;
// Data register? (r/w)
case 0x2192:
t = BSX.PPU[0x2192];
// Data register? (r/w)
case 0x2192:
t = BSX.PPU[0x2192 - BSXPPUBASE];
// test
t = BSX.test2192[BSX.out_index++];
if (BSX.out_index == 32)
BSX.out_index = 0;
BSX_RTC.ticks++;
if (BSX_RTC.ticks >= 1000)
{
BSX_RTC.ticks = 0;
BSX_RTC.seconds++;
}
if (BSX_RTC.seconds >= 60)
{
BSX_RTC.seconds = 0;
BSX_RTC.minutes++;
}
if (BSX_RTC.minutes >= 60)
{
BSX_RTC.minutes = 0;
BSX_RTC.hours++;
}
if (BSX_RTC.hours >= 24)
BSX_RTC.hours = 0;
BSX.test2192[10] = BSX_RTC.seconds;
BSX.test2192[11] = BSX_RTC.minutes;
BSX.test2192[12] = BSX_RTC.hours;
break;
// Transmission status? (r/w)
case 0x2193:
// Data ready when bits 2/3 clear?
t = BSX.PPU[0x2193] & ~0x0C;
break;
// Reset? (r/w)
case 0x2194:
t = BSX.PPU[0x2194];
break;
// Unknown (r)
case 0x2196:
t = BSX.PPU[0x2196];
break;
// Unknown (r/w)
case 0x2197:
t = BSX.PPU[0x2197];
break;
// Modem protocol? (r/w)
case 0x2199:
t = BSX.PPU[0x2199];
break;
default:
t = OpenBus;
break;
}
}
return t;
}
void S9xSetBSXPPU(uint8 byte, uint16 address)
{
if (address >= 0x2188 && address <= 0x219F)
{
// known write registers
switch(address)
{
// Test register low? (r/w)
case 0x2188:
BSX.PPU[0x2188] = byte;
break;
// Test register high? (r/w)
case 0x2189:
BSX.PPU[0x2189] = byte;
break;
case 0x218A:
BSX.PPU[0x218A] = byte;
break;
case 0x218B:
BSX.PPU[0x218B] = byte;
break;
case 0x218C:
BSX.PPU[0x218C] = byte;
break;
// Transmission number low? (r/w)
case 0x218E:
BSX.PPU[0x218E] = byte;
break;
// Transmission number high? (r/w)
case 0x218F:
BSX.PPU[0x218F] = byte;
// ?
BSX.PPU[0x218E] >>= 1;
BSX.PPU[0x218E] = BSX.PPU[0x218F] - BSX.PPU[0x218E];
BSX.PPU[0x218F] >>= 1;
BSX.PPU[0x2190] = 0x80; // ?
break;
// Strobe assert? (w)
case 0x2191:
BSX.PPU[0x2191] = byte;
// test
t = BSX.test2192[BSX.out_index++];
if (BSX.out_index == 32)
BSX.out_index = 0;
break;
// Data register? (r/w)
case 0x2192:
BSX.PPU[0x2192] = 0x01; // ?
BSX.PPU[0x2190] = 0x80; // ?
break;
BSX_RTC.ticks++;
if (BSX_RTC.ticks >= 1000)
{
BSX_RTC.ticks = 0;
BSX_RTC.seconds++;
}
if (BSX_RTC.seconds >= 60)
{
BSX_RTC.seconds = 0;
BSX_RTC.minutes++;
}
if (BSX_RTC.minutes >= 60)
{
BSX_RTC.minutes = 0;
BSX_RTC.hours++;
}
if (BSX_RTC.hours >= 24)
BSX_RTC.hours = 0;
// Transmission status? (r/w)
case 0x2193:
BSX.PPU[0x2193] = byte;
break;
BSX.test2192[10] = BSX_RTC.seconds;
BSX.test2192[11] = BSX_RTC.minutes;
BSX.test2192[12] = BSX_RTC.hours;
// Reset? (r/w)
case 0x2194:
BSX.PPU[0x2194] = byte;
break;
break;
// Unknown (r/w)
case 0x2197:
BSX.PPU[0x2197] = byte;
break;
// Transmission status? (r/w)
case 0x2193:
// Data ready when bits 2/3 clear?
t = BSX.PPU[0x2193 - BSXPPUBASE] & ~0x0C;
break;
// Modem protocol? (r/w)
case 0x2199:
// Lots of modem strings written here when
// connection is lost or no uplink established
BSX.PPU[0x2199] = byte;
break;
}
// Reset? (r/w)
case 0x2194:
t = BSX.PPU[0x2194 - BSXPPUBASE];
break;
// Unknown (r)
case 0x2196:
t = BSX.PPU[0x2196 - BSXPPUBASE];
break;
// Unknown (r/w)
case 0x2197:
t = BSX.PPU[0x2197 - BSXPPUBASE];
break;
// Modem protocol? (r/w)
case 0x2199:
t = BSX.PPU[0x2199 - BSXPPUBASE];
break;
default:
t = OpenBus;
break;
}
return (t);
}
void S9xSetBSXPPU (uint8 byte, uint16 address)
{
// known write registers
switch (address)
{
// Test register low? (r/w)
case 0x2188:
BSX.PPU[0x2188 - BSXPPUBASE] = byte;
break;
// Test register high? (r/w)
case 0x2189:
BSX.PPU[0x2189 - BSXPPUBASE] = byte;
break;
case 0x218A:
BSX.PPU[0x218A - BSXPPUBASE] = byte;
break;
case 0x218B:
BSX.PPU[0x218B - BSXPPUBASE] = byte;
break;
case 0x218C:
BSX.PPU[0x218C - BSXPPUBASE] = byte;
break;
// Transmission number low? (r/w)
case 0x218E:
BSX.PPU[0x218E - BSXPPUBASE] = byte;
break;
// Transmission number high? (r/w)
case 0x218F:
BSX.PPU[0x218F - BSXPPUBASE] = byte;
// ?
BSX.PPU[0x218E - BSXPPUBASE] >>= 1;
BSX.PPU[0x218E - BSXPPUBASE] = BSX.PPU[0x218F - BSXPPUBASE] - BSX.PPU[0x218E - BSXPPUBASE];
BSX.PPU[0x218F - BSXPPUBASE] >>= 1;
BSX.PPU[0x2190 - BSXPPUBASE] = 0x80; // ?
break;
// Strobe assert? (w)
case 0x2191:
BSX.PPU[0x2191 - BSXPPUBASE] = byte;
BSX.out_index = 0;
break;
// Data register? (r/w)
case 0x2192:
BSX.PPU[0x2192 - BSXPPUBASE] = 0x01; // ?
BSX.PPU[0x2190 - BSXPPUBASE] = 0x80; // ?
break;
// Transmission status? (r/w)
case 0x2193:
BSX.PPU[0x2193 - BSXPPUBASE] = byte;
break;
// Reset? (r/w)
case 0x2194:
BSX.PPU[0x2194 - BSXPPUBASE] = byte;
break;
// Unknown (r/w)
case 0x2197:
BSX.PPU[0x2197 - BSXPPUBASE] = byte;
break;
// Modem protocol? (r/w)
case 0x2199:
// Lots of modem strings written here when
// connection is lost or no uplink established
BSX.PPU[0x2199 - BSXPPUBASE] = byte;
break;
}
}
uint8 * S9xGetBasePointerBSX(uint32 address)
uint8 * S9xGetBasePointerBSX (uint32 address)
{
return MapROM;
return (MapROM);
}
static bool8 BSX_LoadBIOS(void)
static bool8 BSX_LoadBIOS (void)
{
#ifdef GEKKO
return FALSE; // We're not loading the BIOS!
#endif
FILE *fp;
char path[_MAX_PATH + 1], name[_MAX_PATH + 1];
char path[PATH_MAX + 1], name[PATH_MAX + 1];
bool8 r = FALSE;
strcpy(path, S9xGetDirectory(BIOS_DIR));
@ -1012,10 +1023,10 @@ static bool8 BSX_LoadBIOS(void)
printf("BS: BIOS not found!\n");
#endif
return r;
return (r);
}
void S9xInitBSX(void)
void S9xInitBSX (void)
{
Settings.BS = FALSE;
@ -1097,7 +1108,7 @@ void S9xInitBSX(void)
}
}
void S9xResetBSX(void)
void S9xResetBSX (void)
{
if (Settings.BSXItself)
memset(Memory.ROM, 0, FLASH_SIZE);
@ -1149,7 +1160,7 @@ void S9xResetBSX(void)
BSX_Map();
}
void S9xFixBSXAfterSnapshotLoad(void)
void S9xBSXPostLoadState (void)
{
uint8 temp[16];
bool8 pd1, pd2;
@ -1166,34 +1177,30 @@ void S9xFixBSXAfterSnapshotLoad(void)
BSX.dirty2 = pd2;
}
static bool valid_normal_bank(unsigned char bankbyte)
static bool valid_normal_bank (unsigned char bankbyte)
{
switch (bankbyte)
{
case 32: case 33: case 48: case 49:
return(true);
break;
}
return(false);
switch (bankbyte)
{
case 32: case 33: case 48: case 49:
return (true);
break;
}
return (false);
}
static int is_bsx(unsigned char *p)
static int is_bsx (unsigned char *p)
{
if ((p[26] == 0x33 || p[26] == 0xFF) &&
(!p[21] || (p[21] & 131) == 128) &&
valid_normal_bank(p[24]))
{
unsigned char m = p[22];
if (!m && !p[23])
{
return(2);
}
if ((m == 0xFF && p[23] == 0xFF) ||
(!(m & 0xF) && ((m >> 4) - 1 < 12)))
{
return(1);
}
}
return(0);
}
if ((p[26] == 0x33 || p[26] == 0xFF) && (!p[21] || (p[21] & 131) == 128) && valid_normal_bank(p[24]))
{
unsigned char m = p[22];
if (!m && !p[23])
return (2);
if ((m == 0xFF && p[23] == 0xFF) || (!(m & 0xF) && ((m >> 4) - 1 < 12)))
return (1);
}
return (0);
}

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,9 +172,7 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#ifndef _BSX_H_
@ -183,17 +197,15 @@ struct SBSX
uint8 test2192[32];
};
START_EXTERN_C
extern struct SBSX BSX;
uint8 S9xGetBSX(uint32);
void S9xSetBSX(uint8, uint32);
uint8 S9xGetBSXPPU(uint16);
void S9xSetBSXPPU(uint8, uint16);
uint8 * S9xGetBasePointerBSX(uint32);
void S9xInitBSX(void);
void S9xResetBSX(void);
void S9xFixBSXAfterSnapshotLoad(void);
END_EXTERN_C
uint8 S9xGetBSX (uint32);
void S9xSetBSX (uint8, uint32);
uint8 S9xGetBSXPPU (uint16);
void S9xSetBSXPPU (uint8, uint16);
uint8 * S9xGetBasePointerBSX (uint32);
void S9xInitBSX (void);
void S9xResetBSX (void);
void S9xBSXPostLoadState (void);
#endif

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,158 +172,149 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#include <math.h>
#include <stdlib.h>
#include "c4.h"
#include "snes9x.h"
#include "memmap.h"
extern "C" {
short C4WFXVal;
short C4WFYVal;
short C4WFZVal;
short C4WFX2Val;
short C4WFY2Val;
short C4WFDist;
short C4WFScale;
#define C4_PI 3.14159265
static double tanval;
static double c4x, c4y, c4z;
static double c4x2, c4y2, c4z2;
int16 C4WFXVal;
int16 C4WFYVal;
int16 C4WFZVal;
int16 C4WFX2Val;
int16 C4WFY2Val;
int16 C4WFDist;
int16 C4WFScale;
int16 C41FXVal;
int16 C41FYVal;
int16 C41FAngleRes;
int16 C41FDist;
int16 C41FDistVal;
void C4TransfWireFrame ()
static double tanval;
static double c4x, c4y, c4z;
static double c4x2, c4y2, c4z2;
void C4TransfWireFrame (void)
{
c4x = (double) C4WFXVal;
c4y = (double) C4WFYVal;
c4z = (double) C4WFZVal - 0x95;
c4x = (double) C4WFXVal;
c4y = (double) C4WFYVal;
c4z = (double) C4WFZVal - 0x95;
// Rotate X
tanval = -(double) C4WFX2Val * 3.14159265 * 2 / 128;
c4y2 = c4y * cos (tanval) - c4z * sin (tanval);
c4z2 = c4y * sin (tanval) + c4z * cos (tanval);
// Rotate X
tanval = -(double) C4WFX2Val * C4_PI * 2 / 128;
c4y2 = c4y * cos(tanval) - c4z * sin(tanval);
c4z2 = c4y * sin(tanval) + c4z * cos(tanval);
// Rotate Y
tanval = -(double)C4WFY2Val*3.14159265*2/128;
c4x2 = c4x * cos (tanval) + c4z2 * sin (tanval);
c4z = c4x * - sin (tanval) + c4z2 * cos (tanval);
// Rotate Y
tanval = -(double) C4WFY2Val * C4_PI * 2 / 128;
c4x2 = c4x * cos(tanval) + c4z2 * sin(tanval);
c4z = c4x * -sin(tanval) + c4z2 * cos(tanval);
// Rotate Z
tanval = -(double) C4WFDist * 3.14159265*2 / 128;
c4x = c4x2 * cos (tanval) - c4y2 * sin (tanval);
c4y = c4x2 * sin (tanval) + c4y2 * cos (tanval);
// Rotate Z
tanval = -(double) C4WFDist * C4_PI * 2 / 128;
c4x = c4x2 * cos(tanval) - c4y2 * sin(tanval);
c4y = c4x2 * sin(tanval) + c4y2 * cos(tanval);
// Scale
C4WFXVal = (short) (c4x*(double)C4WFScale/(0x90*(c4z+0x95))*0x95);
C4WFYVal = (short) (c4y*(double)C4WFScale/(0x90*(c4z+0x95))*0x95);
// Scale
C4WFXVal = (int16) (c4x * (double) C4WFScale / (0x90 * (c4z + 0x95)) * 0x95);
C4WFYVal = (int16) (c4y * (double) C4WFScale / (0x90 * (c4z + 0x95)) * 0x95);
}
void C4TransfWireFrame2 ()
void C4TransfWireFrame2 (void)
{
c4x = (double)C4WFXVal;
c4y = (double)C4WFYVal;
c4z = (double)C4WFZVal;
c4x = (double) C4WFXVal;
c4y = (double) C4WFYVal;
c4z = (double) C4WFZVal;
// Rotate X
tanval = -(double) C4WFX2Val * 3.14159265 * 2 / 128;
c4y2 = c4y * cos (tanval) - c4z * sin (tanval);
c4z2 = c4y * sin (tanval) + c4z * cos (tanval);
// Rotate X
tanval = -(double) C4WFX2Val * C4_PI * 2 / 128;
c4y2 = c4y * cos(tanval) - c4z * sin(tanval);
c4z2 = c4y * sin(tanval) + c4z * cos(tanval);
// Rotate Y
tanval = -(double) C4WFY2Val * 3.14159265 * 2 / 128;
c4x2 = c4x * cos (tanval) + c4z2 * sin (tanval);
c4z = c4x * -sin (tanval) + c4z2 * cos (tanval);
// Rotate Y
tanval = -(double) C4WFY2Val * C4_PI * 2 / 128;
c4x2 = c4x * cos(tanval) + c4z2 * sin(tanval);
c4z = c4x * -sin(tanval) + c4z2 * cos(tanval);
// Rotate Z
tanval = -(double)C4WFDist * 3.14159265 * 2 / 128;
c4x = c4x2 * cos (tanval) - c4y2 * sin (tanval);
c4y = c4x2 * sin (tanval) + c4y2 * cos (tanval);
// Rotate Z
tanval = -(double) C4WFDist * C4_PI * 2 / 128;
c4x = c4x2 * cos(tanval) - c4y2 * sin(tanval);
c4y = c4x2 * sin(tanval) + c4y2 * cos(tanval);
// Scale
C4WFXVal =(short)(c4x * (double)C4WFScale / 0x100);
C4WFYVal =(short)(c4y * (double)C4WFScale / 0x100);
// Scale
C4WFXVal = (int16) (c4x * (double) C4WFScale / 0x100);
C4WFYVal = (int16) (c4y * (double) C4WFScale / 0x100);
}
void C4CalcWireFrame ()
void C4CalcWireFrame (void)
{
C4WFXVal = C4WFX2Val - C4WFXVal;
C4WFYVal = C4WFY2Val - C4WFYVal;
if (abs (C4WFXVal) > abs (C4WFYVal))
{
C4WFDist = abs (C4WFXVal) + 1;
C4WFYVal = (short) (256 * (double) C4WFYVal / abs (C4WFXVal));
if (C4WFXVal < 0)
C4WFXVal = -256;
else
C4WFXVal = 256;
}
else
{
if (C4WFYVal != 0)
{
C4WFDist = abs(C4WFYVal)+1;
C4WFXVal = (short) (256 * (double)C4WFXVal / abs (C4WFYVal));
if (C4WFYVal < 0)
C4WFYVal = -256;
else
C4WFYVal = 256;
}
else
C4WFDist = 0;
}
C4WFXVal = C4WFX2Val - C4WFXVal;
C4WFYVal = C4WFY2Val - C4WFYVal;
if (abs(C4WFXVal) > abs(C4WFYVal))
{
C4WFDist = abs(C4WFXVal) + 1;
C4WFYVal = (int16) (256 * (double) C4WFYVal / abs(C4WFXVal));
if (C4WFXVal < 0)
C4WFXVal = -256;
else
C4WFXVal = 256;
}
else
{
if (C4WFYVal != 0)
{
C4WFDist = abs(C4WFYVal) + 1;
C4WFXVal = (int16) (256 * (double) C4WFXVal / abs(C4WFYVal));
if (C4WFYVal < 0)
C4WFYVal = -256;
else
C4WFYVal = 256;
}
else
C4WFDist = 0;
}
}
short C41FXVal;
short C41FYVal;
short C41FAngleRes;
short C41FDist;
short C41FDistVal;
void C4Op1F ()
void C4Op1F (void)
{
if (C41FXVal == 0)
{
if (C41FYVal > 0)
C41FAngleRes = 0x80;
else
C41FAngleRes = 0x180;
}
else
{
tanval = (double) C41FYVal / C41FXVal;
C41FAngleRes = (short) (atan (tanval) / (3.141592675 * 2) * 512);
C41FAngleRes = C41FAngleRes;
if (C41FXVal< 0)
C41FAngleRes += 0x100;
C41FAngleRes &= 0x1FF;
}
if (C41FXVal == 0)
{
if (C41FYVal > 0)
C41FAngleRes = 0x80;
else
C41FAngleRes = 0x180;
}
else
{
tanval = (double) C41FYVal / C41FXVal;
C41FAngleRes = (int16) (atan(tanval) / (C4_PI * 2) * 512);
C41FAngleRes = C41FAngleRes;
if (C41FXVal< 0)
C41FAngleRes += 0x100;
C41FAngleRes &= 0x1FF;
}
}
void C4Op15()
void C4Op15 (void)
{
tanval = sqrt ((double) C41FYVal * C41FYVal + (double) C41FXVal * C41FXVal);
C41FDist = (short) tanval;
tanval = sqrt((double) C41FYVal * C41FYVal + (double) C41FXVal * C41FXVal);
C41FDist = (int16) tanval;
}
void C4Op0D()
void C4Op0D (void)
{
tanval = sqrt ((double) C41FYVal * C41FYVal + (double) C41FXVal * C41FXVal);
tanval = C41FDistVal / tanval;
C41FYVal = (short) (C41FYVal * tanval * 0.99);
C41FXVal = (short) (C41FXVal * tanval * 0.98);
tanval = sqrt((double) C41FYVal * C41FYVal + (double) C41FXVal * C41FXVal);
tanval = C41FDistVal / tanval;
C41FYVal = (int16) (C41FYVal * tanval * 0.99);
C41FXVal = (int16) (C41FXVal * tanval * 0.98);
}
#ifdef ZSNES_C4
EXTERN_C void C4LoaDMem(char *C4RAM)
{
memmove(C4RAM+(READ_WORD(C4RAM+0x1f45)&0x1fff),
C4GetMemPointer(READ_3WORD(C4RAM+0x1f40)),
READ_WORD(C4RAM+0x1f43));
}
#endif
uint8 * S9xGetBasePointerC4 (uint16 Address)
{
if (Address >= 0x7f40 && Address <= 0x7f5e)
@ -322,4 +329,13 @@ uint8 * S9xGetMemPointerC4 (uint16 Address)
return (Memory.C4RAM - 0x6000 + (Address & 0xffff));
}
}//end extern C
#ifdef ZSNES_C4
START_EXTERN_C
void C4LoaDMem (char *C4RAM)
{
memmove(C4RAM + (READ_WORD(C4RAM + 0x1f45) & 0x1fff), C4GetMemPointer(READ_3WORD(C4RAM + 0x1f40)), READ_WORD(C4RAM + 0x1f43));
}
END_EXTERN_C
#endif

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,48 +172,53 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#ifndef _C4_H_
#define _C4_H_
#include "port.h"
#include "memmap.h"
#ifdef ZSNES_C4
START_EXTERN_C
#endif
extern "C" {
extern int16 C4WFXVal;
extern int16 C4WFYVal;
extern int16 C4WFZVal;
extern int16 C4WFX2Val;
extern int16 C4WFY2Val;
extern int16 C4WFDist;
extern int16 C4WFScale;
extern int16 C41FXVal;
extern int16 C41FYVal;
extern int16 C41FAngleRes;
extern int16 C41FDist;
extern int16 C41FDistVal;
extern int16 C4WFXVal;
extern int16 C4WFYVal;
extern int16 C4WFZVal;
extern int16 C4WFX2Val;
extern int16 C4WFY2Val;
extern int16 C4WFDist;
extern int16 C4WFScale;
#ifdef ZSNES_C4
extern uint8 *C4Ram;
#endif
void C4TransfWireFrame();
void C4TransfWireFrame2();
void C4CalcWireFrame();
void C4TransfWireFrame (void);
void C4TransfWireFrame2 (void);
void C4CalcWireFrame (void);
void C4Op0D (void);
void C4Op15 (void);
void C4Op1F (void);
void S9xInitC4 (void);
void S9xSetC4 (uint8, uint16);
uint8 S9xGetC4 (uint16);
extern int16 C41FXVal;
extern int16 C41FYVal;
extern int16 C41FAngleRes;
extern int16 C41FDist;
extern int16 C41FDistVal;
#ifdef ZSNES_C4
END_EXTERN_C
#endif
void C4Op1F();
void C4Op15();
void C4Op0D();
uint8 * S9xGetBasePointerC4 (uint16);
uint8 * S9xGetMemPointerC4 (uint16);
extern int16 C4CosTable[];
extern int16 C4SinTable[];
}
static inline uint8 *C4GetMemPointer(uint32 Address){
return (Memory.ROM + ((Address&0xff0000)>>1) + (Address&0x7fff));
static inline uint8 * C4GetMemPointer (uint32 Address)
{
return (Memory.ROM + ((Address & 0xff0000) >> 1) + (Address & 0x7fff));
}
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,429 +172,407 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include "snes9x.h"
#include "cheats.h"
#include "memmap.h"
#include "cheats.h"
#define WRAM_BITS ALL_BITS
#define SRAM_BITS ALL_BITS + (0x20000 >> 5)
#define IRAM_BITS ALL_BITS + (0x30000 >> 5)
#define BIT_CLEAR(a, v) (a)[(v) >> 5] &= ~(1 << ((v) & 31))
#define TEST_BIT(a, v) ((a)[(v) >> 5] & (1 << ((v) & 31)))
#define _S9XCHTC(c, a, b) \
((c) == S9X_LESS_THAN ? (a) < (b) : \
(c) == S9X_GREATER_THAN ? (a) > (b) : \
(c) == S9X_LESS_THAN_OR_EQUAL ? (a) <= (b) : \
(c) == S9X_GREATER_THAN_OR_EQUAL ? (a) >= (b) : \
(c) == S9X_EQUAL ? (a) == (b) : \
(a) != (b))
#define _S9XCHTD(s, m, o) \
((s) == S9X_8_BITS ? ((uint8) (*((m) + (o)))) : \
(s) == S9X_16_BITS ? ((uint16) (*((m) + (o)) + (*((m) + (o) + 1) << 8))) : \
(s) == S9X_24_BITS ? ((uint32) (*((m) + (o)) + (*((m) + (o) + 1) << 8) + (*((m) + (o) + 2) << 16))) : \
((uint32) (*((m) + (o)) + (*((m) + (o) + 1) << 8) + (*((m) + (o) + 2) << 16) + (*((m) + (o) + 3) << 24))))
#define _S9XCHTDS(s, m, o) \
((s) == S9X_8_BITS ? ((int8) (*((m) + (o)))) : \
(s) == S9X_16_BITS ? ((int16) (*((m) + (o)) + (*((m) + (o) + 1) << 8))) : \
(s) == S9X_24_BITS ? (((int32) ((*((m) + (o)) + (*((m) + (o) + 1) << 8) + (*((m) + (o) + 2) << 16)) << 8)) >> 8): \
((int32) (*((m) + (o)) + (*((m) + (o) + 1) << 8) + (*((m) + (o) + 2) << 16) + (*((m) + (o) + 3) << 24))))
static bool8 S9xAllHex (const char *, int);
static bool8 S9xAllHex (const char *code, int len)
{
for (int i = 0; i < len; i++)
if ((code [i] < '0' || code [i] > '9') &&
(code [i] < 'a' || code [i] > 'f') &&
(code [i] < 'A' || code [i] > 'F'))
return (FALSE);
for (int i = 0; i < len; i++)
if ((code[i] < '0' || code[i] > '9') && (code[i] < 'a' || code[i] > 'f') && (code[i] < 'A' || code[i] > 'F'))
return (FALSE);
return (TRUE);
return (TRUE);
}
const char *S9xProActionReplayToRaw (const char *code, uint32 &address, uint8 &byte)
const char * S9xProActionReplayToRaw (const char *code, uint32 &address, uint8 &byte)
{
uint32 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.");
uint32 data = 0;
address = data >> 8;
byte = (uint8) data;
return (NULL);
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.");
address = data >> 8;
byte = (uint8) data;
return (NULL);
}
const char *S9xGoldFingerToRaw (const char *code, uint32 &address, bool8 &sram,
uint8 &num_bytes, uint8 bytes[3])
const char * S9xGoldFingerToRaw (const char *code, uint32 &address, bool8 &sram, uint8 &num_bytes, uint8 bytes[3])
{
char tmp [15];
if (strlen (code) != 14)
return ("Invalid Gold Finger code should be 14 hex digits in length.");
char tmp[15];
int i;
strncpy (tmp, code, 5);
tmp [5] = 0;
if (sscanf (tmp, "%x", &address) != 1)
return ("Invalid Gold Finger code.");
if (strlen(code) != 14)
return ("Invalid Gold Finger code - should be 14 hex digits in length.");
int i;
for (i = 0; i < 3; i++)
{
strncpy (tmp, code + 5 + i * 2, 2);
tmp [2] = 0;
unsigned int byte;
if (sscanf (tmp, "%x", &byte) != 1)
break;
bytes [i] = (uint8) byte;
}
num_bytes = i;
sram = code [13] == '1';
return (NULL);
}
strncpy(tmp, code, 5);
tmp[5] = 0;
if (sscanf(tmp, "%x", &address) != 1)
return ("Invalid Gold Finger code.");
const char *S9xGameGenieToRaw (const char *code, uint32 &address, uint8 &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'.");
strcpy (new_code, "0x");
strncpy (new_code + 2, code, 4);
strcpy (new_code + 6, code + 5);
static char *real_hex = "0123456789ABCDEF";
static char *genie_hex = "DF4709156BC8A23E";
for (int i = 2; i < 10; i++)
{
if (islower (new_code [i]))
new_code [i] = toupper (new_code [i]);
int j;
for (j = 0; j < 16; j++)
for (i = 0; i < 3; i++)
{
if (new_code [i] == genie_hex [j])
{
new_code [i] = real_hex [j];
break;
}
}
if (j == 16)
return ("Invalid hex-character in Game Genie(tm) code");
}
uint32 data = 0;
sscanf (new_code, "%x", &data);
byte = (uint8)(data >> 24);
address = data & 0xffffff;
address = ((address & 0x003c00) << 10) +
((address & 0x00003c) << 14) +
((address & 0xf00000) >> 8) +
((address & 0x000003) << 10) +
((address & 0x00c000) >> 6) +
((address & 0x0f0000) >> 12) +
((address & 0x0003c0) >> 6);
unsigned int byte;
return (NULL);
strncpy(tmp, code + 5 + i * 2, 2);
tmp[2] = 0;
if (sscanf(tmp, "%x", &byte) != 1)
break;
bytes[i] = (uint8) byte;
}
num_bytes = i;
sram = code[13] == '1';
return (NULL);
}
const char * S9xGameGenieToRaw (const char *code, uint32 &address, uint8 &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'.");
strcpy(new_code, "0x");
strncpy(new_code + 2, code, 4);
strcpy(new_code + 6, code + 5);
static const char *real_hex = "0123456789ABCDEF";
static const char *genie_hex = "DF4709156BC8A23E";
for (int i = 2; i < 10; i++)
{
if (islower(new_code[i]))
new_code[i] = toupper(new_code[i]);
int j;
for (j = 0; j < 16; j++)
{
if (new_code[i] == genie_hex[j])
{
new_code[i] = real_hex[j];
break;
}
}
if (j == 16)
return ("Invalid hex-character in Game Genie(tm) code.");
}
uint32 data = 0;
sscanf(new_code, "%x", &data);
byte = (uint8) (data >> 24);
address = data & 0xffffff;
address = ((address & 0x003c00) << 10) +
((address & 0x00003c) << 14) +
((address & 0xf00000) >> 8) +
((address & 0x000003) << 10) +
((address & 0x00c000) >> 6) +
((address & 0x0f0000) >> 12) +
((address & 0x0003c0) >> 6);
return (NULL);
}
void S9xStartCheatSearch (SCheatData *d)
{
memmove (d->CWRAM, d->RAM, 0x20000);
memmove (d->CSRAM, d->SRAM, 0x10000);
memmove (d->CIRAM, &d->FillRAM [0x3000], 0x2000);
memset ((char *) d->ALL_BITS, 0xff, 0x32000 >> 3);
memmove(d->CWRAM, d->RAM, 0x20000);
memmove(d->CSRAM, d->SRAM, 0x10000);
memmove(d->CIRAM, &d->FillRAM[0x3000], 0x2000);
memset((char *) d->ALL_BITS, 0xff, 0x32000 >> 3);
}
#define BIT_CLEAR(a,v) \
(a)[(v) >> 5] &= ~(1 << ((v) & 31))
#define BIT_SET(a,v) \
(a)[(v) >> 5] |= 1 << ((v) & 31)
#define TEST_BIT(a,v) \
((a)[(v) >> 5] & (1 << ((v) & 31)))
#ifdef NGC
#undef _C /*** Stops powerpc-gekko-g++ complaining -;) ***/
#endif
#define _C(c,a,b) \
((c) == S9X_LESS_THAN ? (a) < (b) : \
(c) == S9X_GREATER_THAN ? (a) > (b) : \
(c) == S9X_LESS_THAN_OR_EQUAL ? (a) <= (b) : \
(c) == S9X_GREATER_THAN_OR_EQUAL ? (a) >= (b) : \
(c) == S9X_EQUAL ? (a) == (b) : \
(a) != (b))
#define _D(s,m,o) \
((s) == S9X_8_BITS ? (uint8) (*((m) + (o))) : \
(s) == S9X_16_BITS ? ((uint16) (*((m) + (o)) + (*((m) + (o) + 1) << 8))) : \
(s) == S9X_24_BITS ? ((uint32) (*((m) + (o)) + (*((m) + (o) + 1) << 8) + (*((m) + (o) + 2) << 16))) : \
((uint32) (*((m) + (o)) + (*((m) + (o) + 1) << 8) + (*((m) + (o) + 2) << 16) + (*((m) + (o) + 3) << 24))))
#define _DS(s,m,o) \
((s) == S9X_8_BITS ? ((int8) *((m) + (o))) : \
(s) == S9X_16_BITS ? ((int16) (*((m) + (o)) + (*((m) + (o) + 1) << 8))) : \
(s) == S9X_24_BITS ? (((int32) ((*((m) + (o)) + (*((m) + (o) + 1) << 8) + (*((m) + (o) + 2) << 16)) << 8)) >> 8): \
((int32) (*((m) + (o)) + (*((m) + (o) + 1) << 8) + (*((m) + (o) + 2) << 16) + (*((m) + (o) + 3) << 24))))
void S9xSearchForChange (SCheatData *d, S9xCheatComparisonType cmp,
S9xCheatDataSize size, bool8 is_signed, bool8 update)
void S9xSearchForChange (SCheatData *d, S9xCheatComparisonType cmp, S9xCheatDataSize size, bool8 is_signed, bool8 update)
{
int l;
int l, i;
switch (size)
{
case S9X_8_BITS: l = 0; break;
case S9X_16_BITS: l = 1; break;
case S9X_24_BITS: l = 2; break;
default:
case S9X_32_BITS: l = 3; break;
}
switch (size)
{
case S9X_8_BITS: l = 0; break;
case S9X_16_BITS: l = 1; break;
case S9X_24_BITS: l = 2; break;
default:
case S9X_32_BITS: l = 3; break;
}
int i;
if (is_signed)
{
for (i = 0; i < 0x20000 - l; i++)
{
if (TEST_BIT (d->WRAM_BITS, i) &&
_C(cmp, _DS(size, d->RAM, i), _DS(size, d->CWRAM, i)))
{
if (update)
d->CWRAM [i] = d->RAM [i];
}
else
BIT_CLEAR (d->WRAM_BITS, i);
}
if (is_signed)
{
for (i = 0; i < 0x20000 - l; i++)
{
if (TEST_BIT(d->WRAM_BITS, i) && _S9XCHTC(cmp, _S9XCHTDS(size, d->RAM, i), _S9XCHTDS(size, d->CWRAM, i)))
{
if (update)
d->CWRAM[i] = d->RAM[i];
}
else
BIT_CLEAR(d->WRAM_BITS, i);
}
for (i = 0; i < 0x10000 - l; i++)
{
if (TEST_BIT (d->SRAM_BITS, i) &&
_C(cmp, _DS(size, d->SRAM, i), _DS(size, d->CSRAM, i)))
{
if (update)
d->CSRAM [i] = d->SRAM [i];
}
else
BIT_CLEAR (d->SRAM_BITS, i);
}
for (i = 0; i < 0x10000 - l; i++)
{
if (TEST_BIT(d->SRAM_BITS, i) && _S9XCHTC(cmp, _S9XCHTDS(size, d->SRAM, i), _S9XCHTDS(size, d->CSRAM, i)))
{
if (update)
d->CSRAM[i] = d->SRAM[i];
}
else
BIT_CLEAR(d->SRAM_BITS, i);
}
for (i = 0; i < 0x2000 - l; i++)
{
if (TEST_BIT (d->IRAM_BITS, i) &&
_C(cmp, _DS(size, d->FillRAM + 0x3000, i), _DS(size, d->CIRAM, i)))
{
if (update)
d->CIRAM [i] = d->FillRAM [i + 0x3000];
}
else
BIT_CLEAR (d->IRAM_BITS, i);
}
}
else
{
for (i = 0; i < 0x20000 - l; i++)
{
if (TEST_BIT (d->WRAM_BITS, i) &&
_C(cmp, _D(size, d->RAM, i), _D(size, d->CWRAM, i)))
{
if (update)
d->CWRAM [i] = d->RAM [i];
}
else
BIT_CLEAR (d->WRAM_BITS, i);
}
for (i = 0; i < 0x2000 - l; i++)
{
if (TEST_BIT(d->IRAM_BITS, i) && _S9XCHTC(cmp, _S9XCHTDS(size, d->FillRAM + 0x3000, i), _S9XCHTDS(size, d->CIRAM, i)))
{
if (update)
d->CIRAM[i] = d->FillRAM[i + 0x3000];
}
else
BIT_CLEAR(d->IRAM_BITS, i);
}
}
else
{
for (i = 0; i < 0x20000 - l; i++)
{
if (TEST_BIT(d->WRAM_BITS, i) && _S9XCHTC(cmp, _S9XCHTD(size, d->RAM, i), _S9XCHTD(size, d->CWRAM, i)))
{
if (update)
d->CWRAM[i] = d->RAM[i];
}
else
BIT_CLEAR(d->WRAM_BITS, i);
}
for (i = 0; i < 0x10000 - l; i++)
{
if (TEST_BIT (d->SRAM_BITS, i) &&
_C(cmp, _D(size, d->SRAM, i), _D(size, d->CSRAM, i)))
{
if (update)
d->CSRAM [i] = d->SRAM [i];
}
else
BIT_CLEAR (d->SRAM_BITS, i);
}
for (i = 0; i < 0x10000 - l; i++)
{
if (TEST_BIT(d->SRAM_BITS, i) && _S9XCHTC(cmp, _S9XCHTD(size, d->SRAM, i), _S9XCHTD(size, d->CSRAM, i)))
{
if (update)
d->CSRAM[i] = d->SRAM[i];
}
else
BIT_CLEAR(d->SRAM_BITS, i);
}
for (i = 0; i < 0x2000 - l; i++)
{
if (TEST_BIT (d->IRAM_BITS, i) &&
_C(cmp, _D(size, d->FillRAM + 0x3000, i), _D(size, d->CIRAM, i)))
{
if (update)
d->CIRAM [i] = d->FillRAM [i + 0x3000];
}
else
BIT_CLEAR (d->IRAM_BITS, i);
}
}
for (i = 0x20000 - l; i < 0x20000; i++)
BIT_CLEAR (d->WRAM_BITS, i);
for (i = 0x10000 - l; i < 0x10000; i++)
BIT_CLEAR (d->SRAM_BITS, i);
for (i = 0; i < 0x2000 - l; i++)
{
if (TEST_BIT(d->IRAM_BITS, i) && _S9XCHTC(cmp, _S9XCHTD(size, d->FillRAM + 0x3000, i), _S9XCHTD(size, d->CIRAM, i)))
{
if (update)
d->CIRAM[i] = d->FillRAM[i + 0x3000];
}
else
BIT_CLEAR(d->IRAM_BITS, i);
}
}
for (i = 0x20000 - l; i < 0x20000; i++)
BIT_CLEAR(d->WRAM_BITS, i);
for (i = 0x10000 - l; i < 0x10000; i++)
BIT_CLEAR(d->SRAM_BITS, i);
}
void S9xSearchForValue (SCheatData *d, S9xCheatComparisonType cmp,
S9xCheatDataSize size, uint32 value,
bool8 is_signed, bool8 update)
void S9xSearchForValue (SCheatData *d, S9xCheatComparisonType cmp, S9xCheatDataSize size, uint32 value, bool8 is_signed, bool8 update)
{
int l;
int l, i;
switch (size)
{
case S9X_8_BITS: l = 0; break;
case S9X_16_BITS: l = 1; break;
case S9X_24_BITS: l = 2; break;
default:
case S9X_32_BITS: l = 3; break;
}
switch (size)
{
case S9X_8_BITS: l = 0; break;
case S9X_16_BITS: l = 1; break;
case S9X_24_BITS: l = 2; break;
default:
case S9X_32_BITS: l = 3; break;
}
int i;
if (is_signed)
{
for (i = 0; i < 0x20000 - l; i++)
{
if (TEST_BIT(d->WRAM_BITS, i) && _S9XCHTC(cmp, _S9XCHTDS(size, d->RAM, i), (int32) value))
{
if (update)
d->CWRAM[i] = d->RAM[i];
}
else
BIT_CLEAR(d->WRAM_BITS, i);
}
if (is_signed)
{
for (i = 0; i < 0x20000 - l; i++)
{
if (TEST_BIT (d->WRAM_BITS, i) &&
_C(cmp, _DS(size, d->RAM, i), (int32) value))
{
if (update)
d->CWRAM [i] = d->RAM [i];
}
else
BIT_CLEAR (d->WRAM_BITS, i);
}
for (i = 0; i < 0x10000 - l; i++)
{
if (TEST_BIT(d->SRAM_BITS, i) && _S9XCHTC(cmp, _S9XCHTDS(size, d->SRAM, i), (int32) value))
{
if (update)
d->CSRAM[i] = d->SRAM[i];
}
else
BIT_CLEAR(d->SRAM_BITS, i);
}
for (i = 0; i < 0x10000 - l; i++)
{
if (TEST_BIT (d->SRAM_BITS, i) &&
_C(cmp, _DS(size, d->SRAM, i), (int32) value))
{
if (update)
d->CSRAM [i] = d->SRAM [i];
}
else
BIT_CLEAR (d->SRAM_BITS, i);
}
for (i = 0; i < 0x2000 - l; i++)
{
if (TEST_BIT(d->IRAM_BITS, i) && _S9XCHTC(cmp, _S9XCHTDS(size, d->FillRAM + 0x3000, i), (int32) value))
{
if (update)
d->CIRAM[i] = d->FillRAM[i + 0x3000];
}
else
BIT_CLEAR(d->IRAM_BITS, i);
}
}
else
{
for (i = 0; i < 0x20000 - l; i++)
{
if (TEST_BIT(d->WRAM_BITS, i) && _S9XCHTC(cmp, _S9XCHTD(size, d->RAM, i), value))
{
if (update)
d->CWRAM[i] = d->RAM[i];
}
else
BIT_CLEAR(d->WRAM_BITS, i);
}
for (i = 0; i < 0x2000 - l; i++)
{
if (TEST_BIT (d->IRAM_BITS, i) &&
_C(cmp, _DS(size, d->FillRAM + 0x3000, i), (int32) value))
{
if (update)
d->CIRAM [i] = d->FillRAM [i + 0x3000];
}
else
BIT_CLEAR (d->IRAM_BITS, i);
}
}
else
{
for (i = 0; i < 0x20000 - l; i++)
{
if (TEST_BIT (d->WRAM_BITS, i) &&
_C(cmp, _D(size, d->RAM, i), value))
{
if (update)
d->CWRAM [i] = d->RAM [i];
}
else
BIT_CLEAR (d->WRAM_BITS, i);
}
for (i = 0; i < 0x10000 - l; i++)
{
if (TEST_BIT(d->SRAM_BITS, i) && _S9XCHTC(cmp, _S9XCHTD(size, d->SRAM, i), value))
{
if (update)
d->CSRAM[i] = d->SRAM[i];
}
else
BIT_CLEAR(d->SRAM_BITS, i);
}
for (i = 0; i < 0x10000 - l; i++)
{
if (TEST_BIT (d->SRAM_BITS, i) &&
_C(cmp, _D(size, d->SRAM, i), value))
{
if (update)
d->CSRAM [i] = d->SRAM [i];
}
else
BIT_CLEAR (d->SRAM_BITS, i);
}
for (i = 0; i < 0x2000 - l; i++)
{
if (TEST_BIT(d->IRAM_BITS, i) && _S9XCHTC(cmp, _S9XCHTD(size, d->FillRAM + 0x3000, i), value))
{
if (update)
d->CIRAM[i] = d->FillRAM[i + 0x3000];
}
else
BIT_CLEAR(d->IRAM_BITS, i);
}
}
for (i = 0; i < 0x2000 - l; i++)
{
if (TEST_BIT (d->IRAM_BITS, i) &&
_C(cmp, _D(size, d->FillRAM + 0x3000, i), value))
{
if (update)
d->CIRAM [i] = d->FillRAM [i + 0x3000];
}
else
BIT_CLEAR (d->IRAM_BITS, i);
}
}
for (i = 0x20000 - l; i < 0x20000; i++)
BIT_CLEAR (d->WRAM_BITS, i);
for (i = 0x10000 - l; i < 0x10000; i++)
BIT_CLEAR (d->SRAM_BITS, i);
for (i = 0x20000 - l; i < 0x20000; i++)
BIT_CLEAR(d->WRAM_BITS, i);
for (i = 0x10000 - l; i < 0x10000; i++)
BIT_CLEAR(d->SRAM_BITS, i);
}
void S9xSearchForAddress (SCheatData *d, S9xCheatComparisonType cmp,
S9xCheatDataSize size, uint32 value, bool8 update)
void S9xSearchForAddress (SCheatData *d, S9xCheatComparisonType cmp, S9xCheatDataSize size, uint32 value, bool8 update)
{
int l;
int l, i;
switch (size)
{
case S9X_8_BITS: l = 0; break;
case S9X_16_BITS: l = 1; break;
case S9X_24_BITS: l = 2; break;
default:
case S9X_32_BITS: l = 3; break;
}
switch (size)
{
case S9X_8_BITS: l = 0; break;
case S9X_16_BITS: l = 1; break;
case S9X_24_BITS: l = 2; break;
default:
case S9X_32_BITS: l = 3; break;
}
int i;
for (i = 0; i < 0x20000 - l; i++)
{
if (TEST_BIT(d->WRAM_BITS, i) && _S9XCHTC(cmp, i, (int32) value))
{
if (update)
d->CWRAM[i] = d->RAM[i];
}
else
BIT_CLEAR(d->WRAM_BITS, i);
}
{
for (i = 0; i < 0x10000 - l; i++)
{
if (TEST_BIT(d->SRAM_BITS, i) && _S9XCHTC(cmp, i + 0x20000, (int32) value))
{
if (update)
d->CSRAM[i] = d->SRAM[i];
}
else
BIT_CLEAR(d->SRAM_BITS, i);
}
for (i = 0; i < 0x20000 - l; i++)
{
if (TEST_BIT (d->WRAM_BITS, i) &&
_C(cmp, i, (int)value))
{
if (update)
d->CWRAM [i] = d->RAM [i];
}
else
BIT_CLEAR (d->WRAM_BITS, i);
}
for (i = 0; i < 0x2000 - l; i++)
{
if (TEST_BIT(d->IRAM_BITS, i) && _S9XCHTC(cmp, i + 0x30000, (int32) value))
{
if (update)
d->CIRAM[i] = d->FillRAM[i + 0x3000];
}
else
BIT_CLEAR(d->IRAM_BITS, i);
}
for (i = 0; i < 0x10000 - l; i++)
{
if (TEST_BIT (d->SRAM_BITS, i) &&
_C(cmp, i+0x20000, (int)value))
{
if (update)
d->CSRAM [i] = d->SRAM [i];
}
else
BIT_CLEAR (d->SRAM_BITS, i);
}
for (i = 0x20000 - l; i < 0x20000; i++)
BIT_CLEAR(d->WRAM_BITS, i);
for (i = 0; i < 0x2000 - l; i++)
{
if (TEST_BIT (d->IRAM_BITS, i) &&
_C(cmp, i+0x30000, (int)value))
{
if (update)
d->CIRAM [i] = d->FillRAM [i + 0x3000];
}
else
BIT_CLEAR (d->IRAM_BITS, i);
}
}
for (i = 0x20000 - l; i < 0x20000; i++)
BIT_CLEAR (d->WRAM_BITS, i);
for (i = 0x10000 - l; i < 0x10000; i++)
BIT_CLEAR (d->SRAM_BITS, i);
for (i = 0x10000 - l; i < 0x10000; i++)
BIT_CLEAR(d->SRAM_BITS, i);
}
void S9xOutputCheatSearchResults (SCheatData *d)
{
int i;
for (i = 0; i < 0x20000; i++)
{
if (TEST_BIT (d->WRAM_BITS, i))
printf ("WRAM: %05x: %02x\n", i, d->RAM [i]);
}
int i;
for (i = 0; i < 0x10000; i++)
{
if (TEST_BIT (d->SRAM_BITS, i))
printf ("SRAM: %04x: %02x\n", i, d->SRAM [i]);
}
for (i = 0; i < 0x20000; i++)
{
if (TEST_BIT(d->WRAM_BITS, i))
printf("WRAM: %05x: %02x\n", i, d->RAM[i]);
}
for (i = 0; i < 0x2000; i++)
{
if (TEST_BIT (d->IRAM_BITS, i))
printf ("IRAM: %05x: %02x\n", i, d->FillRAM [i + 0x3000]);
}
for (i = 0; i < 0x10000; i++)
{
if (TEST_BIT(d->SRAM_BITS, i))
printf("SRAM: %04x: %02x\n", i, d->SRAM[i]);
}
for (i = 0; i < 0x2000; i++)
{
if (TEST_BIT(d->IRAM_BITS, i))
printf("IRAM: %05x: %02x\n", i, d->FillRAM[i + 0x3000]);
}
}

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,92 +172,91 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#ifndef _CHEATS_H_
#define _CHEATS_H_
#define MAX_CHEATS 150
struct SCheat
{
uint32 address;
uint8 byte;
uint8 saved_byte;
bool8 enabled;
bool8 saved;
char name [22];
uint32 address;
uint8 byte;
uint8 saved_byte;
bool8 enabled;
bool8 saved;
char name[22];
};
#define MAX_CHEATS 150
struct SCheatData
{
struct SCheat c [MAX_CHEATS];
uint32 num_cheats;
uint8 CWRAM [0x20000];
uint8 CSRAM [0x10000];
uint8 CIRAM [0x2000];
uint8 *RAM;
uint8 *FillRAM;
uint8 *SRAM;
uint32 ALL_BITS [(0x32000 >> 5)];
#define WRAM_BITS ALL_BITS
#define SRAM_BITS ALL_BITS + (0x20000 >> 5)
#define IRAM_BITS ALL_BITS + (0x30000 >> 5)
uint8 CWatchRAM [0x32000];
struct SCheat c[MAX_CHEATS];
uint32 num_cheats;
uint8 CWRAM[0x20000];
uint8 CSRAM[0x10000];
uint8 CIRAM[0x2000];
uint8 *RAM;
uint8 *FillRAM;
uint8 *SRAM;
uint32 ALL_BITS[0x32000 >> 5];
uint8 CWatchRAM[0x32000];
};
struct Watch {
bool on;
int size;
int format;
uint32 address;
char buf[12];
char desc[32];
struct Watch
{
bool on;
int size;
int format;
uint32 address;
char buf[12];
char desc[32];
};
extern Watch watches [16];
typedef enum
{
S9X_LESS_THAN, S9X_GREATER_THAN, S9X_LESS_THAN_OR_EQUAL,
S9X_GREATER_THAN_OR_EQUAL, S9X_EQUAL, S9X_NOT_EQUAL
} S9xCheatComparisonType;
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
} S9xCheatDataSize;
S9X_8_BITS,
S9X_16_BITS,
S9X_24_BITS,
S9X_32_BITS
} S9xCheatDataSize;
void S9xInitCheatData ();
extern SCheatData Cheat;
extern Watch watches[16];
const char *S9xGameGenieToRaw (const char *code, uint32 &address, uint8 &byte);
const char *S9xProActionReplayToRaw (const char *code, uint32 &address, uint8 &byte);
const char *S9xGoldFingerToRaw (const char *code, uint32 &address, bool8 &sram,
uint8 &num_bytes, uint8 bytes[3]);
void S9xApplyCheats ();
void S9xApplyCheat (uint32 which1);
void S9xRemoveCheats ();
void S9xRemoveCheat (uint32 which1);
void S9xEnableCheat (uint32 which1);
void S9xDisableCheat (uint32 which1);
void S9xAddCheat (bool8 enable, bool8 save_current_value, uint32 address,
uint8 byte);
void S9xDeleteCheats ();
void S9xDeleteCheat (uint32 which1);
bool8 S9xLoadCheatFile (const char *filename);
bool8 S9xSaveCheatFile (const char *filename);
void S9xApplyCheat (uint32);
void S9xApplyCheats (void);
void S9xRemoveCheat (uint32);
void S9xRemoveCheats (void);
void S9xDeleteCheat (uint32);
void S9xDeleteCheats (void);
void S9xEnableCheat (uint32);
void S9xDisableCheat (uint32);
void S9xAddCheat (bool8, bool8, uint32, uint8);
void S9xInitCheatData (void);
void S9xInitWatchedAddress (void);
bool8 S9xLoadCheatFile (const char *);
bool8 S9xSaveCheatFile (const char *);
void S9xStartCheatSearch (SCheatData *);
void S9xSearchForChange (SCheatData *, S9xCheatComparisonType cmp,
S9xCheatDataSize size, bool8 is_signed, bool8 update);
void S9xSearchForValue (SCheatData *, S9xCheatComparisonType cmp,
S9xCheatDataSize size, uint32 value,
bool8 is_signed, bool8 update);
void S9xSearchForAddress (SCheatData *, S9xCheatComparisonType cmp,
S9xCheatDataSize size, uint32 address, bool8 update);
void S9xSearchForChange (SCheatData *, S9xCheatComparisonType, S9xCheatDataSize, bool8, bool8);
void S9xSearchForValue (SCheatData *, S9xCheatComparisonType, S9xCheatDataSize, uint32, bool8, bool8);
void S9xSearchForAddress (SCheatData *, S9xCheatComparisonType, S9xCheatDataSize, uint32, bool8);
void S9xOutputCheatSearchResults (SCheatData *);
#endif
const char * S9xGameGenieToRaw (const char *, uint32 &, uint8 &);
const char * S9xProActionReplayToRaw (const char *, uint32 &, uint8 &);
const char * S9xGoldFingerToRaw (const char *, uint32 &, bool8 &, uint8 &, uint8 bytes[3]);
#endif

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,226 +172,235 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include "snes9x.h"
#include "cheats.h"
#include "memmap.h"
#include "cheats.h"
#ifndef INLINE
#define INLINE inline
#endif
static uint8 S9xGetByteFree (uint32);
static void S9xSetByteFree (uint8, uint32);
extern SCheatData Cheat;
Watch watches [16];
// read a byte without altering CPU
INLINE uint8 S9xGetByteFree (uint32 Address)
static uint8 S9xGetByteFree (uint32 address)
{
uint32 Cycles = CPU.Cycles;
uint32 WaitAddress = CPU.WaitAddress;
uint8 rv = S9xGetByte (Address);
uint32 Cycles = CPU.Cycles;
uint32 WaitAddress = CPU.WaitAddress;
uint8 byte;
byte = S9xGetByte(address);
CPU.WaitAddress = WaitAddress;
CPU.Cycles = Cycles;
return rv;
return (byte);
}
INLINE void S9xSetByteFree (uint8 Byte, uint32 Address)
static void S9xSetByteFree (uint8 byte, uint32 address)
{
uint32 Cycles = CPU.Cycles;
uint32 WaitAddress = CPU.WaitAddress;
S9xSetByte (Byte, Address);
uint32 Cycles = CPU.Cycles;
uint32 WaitAddress = CPU.WaitAddress;
S9xSetByte(byte, address);
CPU.WaitAddress = WaitAddress;
CPU.Cycles = Cycles;
}
void S9xInitCheatData ()
void S9xInitWatchedAddress (void)
{
Cheat.RAM = Memory.RAM;
Cheat.SRAM = Memory.SRAM;
Cheat.FillRAM = Memory.FillRAM;
for (unsigned int i = 0; i < sizeof(watches) / sizeof(watches[0]); i++)
watches[i].on = false;
}
void S9xAddCheat (bool8 enable, bool8 save_current_value,
uint32 address, uint8 byte)
void S9xInitCheatData (void)
{
if (Cheat.num_cheats < sizeof (Cheat.c) / sizeof (Cheat. c [0]))
{
Cheat.c [Cheat.num_cheats].address = address;
Cheat.c [Cheat.num_cheats].byte = byte;
#ifdef __MACOSX__
Cheat.c [Cheat.num_cheats].enabled = enable;
#else
Cheat.c [Cheat.num_cheats].enabled = TRUE;
#endif
if (save_current_value)
Cheat.RAM = Memory.RAM;
Cheat.SRAM = Memory.SRAM;
Cheat.FillRAM = Memory.FillRAM;
}
void S9xAddCheat (bool8 enable, bool8 save_current_value, uint32 address, uint8 byte)
{
if (Cheat.num_cheats < sizeof(Cheat.c) / sizeof(Cheat.c[0]))
{
Cheat.c [Cheat.num_cheats].saved_byte = S9xGetByteFree (address);
Cheat.c [Cheat.num_cheats].saved = TRUE;
Cheat.c[Cheat.num_cheats].address = address;
Cheat.c[Cheat.num_cheats].byte = byte;
Cheat.c[Cheat.num_cheats].enabled = enable;
if (save_current_value)
{
Cheat.c[Cheat.num_cheats].saved_byte = S9xGetByteFree(address);
Cheat.c[Cheat.num_cheats].saved = TRUE;
}
Cheat.num_cheats++;
}
Cheat.num_cheats++;
}
}
void S9xDeleteCheat (uint32 which1)
{
if (which1 < Cheat.num_cheats)
{
if (Cheat.c [which1].enabled)
S9xRemoveCheat (which1);
if (which1 < Cheat.num_cheats)
{
if (Cheat.c[which1].enabled)
S9xRemoveCheat(which1);
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--;
}
}
void S9xDeleteCheats ()
void S9xDeleteCheats (void)
{
S9xRemoveCheats ();
Cheat.num_cheats = 0;
}
void S9xEnableCheat (uint32 which1)
{
if (which1 < Cheat.num_cheats && !Cheat.c [which1].enabled)
{
Cheat.c [which1].enabled = TRUE;
S9xApplyCheat (which1);
}
}
void S9xDisableCheat (uint32 which1)
{
if (which1 < Cheat.num_cheats && Cheat.c [which1].enabled)
{
S9xRemoveCheat (which1);
Cheat.c [which1].enabled = FALSE;
}
S9xRemoveCheats();
Cheat.num_cheats = 0;
}
void S9xRemoveCheat (uint32 which1)
{
if (Cheat.c [which1].saved)
{
uint32 address = Cheat.c [which1].address;
if (Cheat.c[which1].saved)
{
uint32 address = Cheat.c[which1].address;
int block = ((address&0xffffff) >> MEMMAP_SHIFT);
uint8 *ptr = Memory.Map [block];
int block = (address & 0xffffff) >> MEMMAP_SHIFT;
uint8 *ptr = Memory.Map[block];
if (ptr >= (uint8 *) CMemory::MAP_LAST)
*(ptr + (address & 0xffff)) = Cheat.c [which1].saved_byte;
else
S9xSetByte (Cheat.c [which1].saved_byte, address);
}
if (ptr >= (uint8 *) CMemory::MAP_LAST)
*(ptr + (address & 0xffff)) = Cheat.c[which1].saved_byte;
else
S9xSetByteFree(Cheat.c[which1].saved_byte, address);
}
}
void S9xRemoveCheats (void)
{
for (uint32 i = 0; i < Cheat.num_cheats; i++)
if (Cheat.c[i].enabled)
S9xRemoveCheat(i);
}
void S9xEnableCheat (uint32 which1)
{
if (which1 < Cheat.num_cheats && !Cheat.c[which1].enabled)
{
Cheat.c[which1].enabled = TRUE;
S9xApplyCheat(which1);
}
}
void S9xDisableCheat (uint32 which1)
{
if (which1 < Cheat.num_cheats && Cheat.c[which1].enabled)
{
S9xRemoveCheat(which1);
Cheat.c[which1].enabled = FALSE;
}
}
void S9xApplyCheat (uint32 which1)
{
uint32 address = Cheat.c [which1].address;
uint32 address = Cheat.c[which1].address;
if (!Cheat.c [which1].saved)
Cheat.c [which1].saved_byte = S9xGetByteFree (address);
if (!Cheat.c[which1].saved)
{
Cheat.c[which1].saved_byte = S9xGetByteFree(address);
Cheat.c[which1].saved = TRUE;
}
int block = ((address&0xffffff) >> MEMMAP_SHIFT);
uint8 *ptr = Memory.Map [block];
int block = (address & 0xffffff) >> MEMMAP_SHIFT;
uint8 *ptr = Memory.Map[block];
if (ptr >= (uint8 *) CMemory::MAP_LAST)
*(ptr + (address & 0xffff)) = Cheat.c [which1].byte;
else
S9xSetByte (Cheat.c [which1].byte, address);
Cheat.c [which1].saved = TRUE;
if (ptr >= (uint8 *) CMemory::MAP_LAST)
*(ptr + (address & 0xffff)) = Cheat.c[which1].byte;
else
S9xSetByteFree(Cheat.c[which1].byte, address);
}
void S9xApplyCheats ()
void S9xApplyCheats (void)
{
if (Settings.ApplyCheats)
{
for (uint32 i = 0; i < Cheat.num_cheats; i++)
if (Cheat.c [i].enabled)
S9xApplyCheat (i);
}
}
void S9xRemoveCheats ()
{
for (uint32 i = 0; i < Cheat.num_cheats; i++)
if (Cheat.c [i].enabled)
S9xRemoveCheat (i);
if (Settings.ApplyCheats)
{
for (uint32 i = 0; i < Cheat.num_cheats; i++)
if (Cheat.c[i].enabled)
S9xApplyCheat(i);
}
}
bool8 S9xLoadCheatFile (const char *filename)
{
Cheat.num_cheats = 0;
FILE *fs;
uint8 data[28];
FILE *fs = fopen (filename, "rb");
uint8 data [28];
Cheat.num_cheats = 0;
if (!fs)
return (FALSE);
fs = fopen(filename, "rb");
if (!fs)
return (FALSE);
while (fread ((void *) data, 1, 28, fs) == 28)
{
Cheat.c [Cheat.num_cheats].enabled = (data [0] & 4) == 0;
Cheat.c [Cheat.num_cheats].byte = data [1];
Cheat.c [Cheat.num_cheats].address = data [2] | (data [3] << 8) | (data [4] << 16);
Cheat.c [Cheat.num_cheats].saved_byte = data [5];
Cheat.c [Cheat.num_cheats].saved = (data [0] & 8) != 0;
memmove (Cheat.c [Cheat.num_cheats].name, &data [8], 20);
Cheat.c [Cheat.num_cheats++].name [20] = 0;
}
fclose (fs);
while (fread((void *) data, 1, 28, fs) == 28)
{
Cheat.c[Cheat.num_cheats].enabled = (data[0] & 4) == 0;
Cheat.c[Cheat.num_cheats].byte = data[1];
Cheat.c[Cheat.num_cheats].address = data[2] | (data[3] << 8) | (data[4] << 16);
Cheat.c[Cheat.num_cheats].saved_byte = data[5];
Cheat.c[Cheat.num_cheats].saved = (data[0] & 8) != 0;
memmove(Cheat.c[Cheat.num_cheats].name, &data[8], 20);
Cheat.c[Cheat.num_cheats++].name[20] = 0;
}
return (TRUE);
fclose(fs);
return (TRUE);
}
bool8 S9xSaveCheatFile (const char *filename)
{
if (Cheat.num_cheats == 0)
{
(void) remove (filename);
return (TRUE);
}
FILE *fs = fopen (filename, "wb");
uint8 data [28];
if (!fs)
return (FALSE);
uint32 i;
for (i = 0; i < Cheat.num_cheats; i++)
{
memset (data, 0, 28);
if (i == 0)
if (Cheat.num_cheats == 0)
{
data [6] = 254;
data [7] = 252;
remove(filename);
return (TRUE);
}
if (!Cheat.c [i].enabled)
data [0] |= 4;
if (Cheat.c [i].saved)
data [0] |= 8;
FILE *fs;
uint8 data[28];
data [1] = Cheat.c [i].byte;
data [2] = (uint8) Cheat.c [i].address;
data [3] = (uint8) (Cheat.c [i].address >> 8);
data [4] = (uint8) (Cheat.c [i].address >> 16);
data [5] = Cheat.c [i].saved_byte;
fs = fopen(filename, "wb");
if (!fs)
return (FALSE);
memmove (&data [8], Cheat.c [i].name, 19);
if (fwrite (data, 28, 1, fs) != 1)
for (uint32 i = 0; i < Cheat.num_cheats; i++)
{
fclose (fs);
return (FALSE);
ZeroMemory(data, 28);
if (i == 0)
{
data[6] = 254;
data[7] = 252;
}
if (!Cheat.c[i].enabled)
data[0] |= 4;
if (Cheat.c[i].saved)
data[0] |= 8;
data[1] = Cheat.c[i].byte;
data[2] = (uint8) (Cheat.c[i].address >> 0);
data[3] = (uint8) (Cheat.c[i].address >> 8);
data[4] = (uint8) (Cheat.c[i].address >> 16);
data[5] = Cheat.c[i].saved_byte;
memmove(&data[8], Cheat.c[i].name, 19);
if (fwrite(data, 28, 1, fs) != 1)
{
fclose(fs);
return (FALSE);
}
}
}
return (fclose (fs) == 0);
return (fclose(fs) == 0);
}

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,192 +172,234 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#include "snes9x.h"
#include "memmap.h"
#include "ppu.h"
static uint8 region_map[6][6]={
{0, 0x01, 0x03, 0x07, 0x0f, 0x1f },
{0, 0, 0x02, 0x06, 0x0e, 0x1e },
{0, 0, 0, 0x04, 0x0c, 0x1c },
{0, 0, 0, 0, 0x08, 0x18 },
{0, 0, 0, 0, 0, 0x10 }
static uint8 region_map[6][6] =
{
{ 0, 0x01, 0x03, 0x07, 0x0f, 0x1f },
{ 0, 0, 0x02, 0x06, 0x0e, 0x1e },
{ 0, 0, 0, 0x04, 0x0c, 0x1c },
{ 0, 0, 0, 0, 0x08, 0x18 },
{ 0, 0, 0, 0, 0, 0x10 }
};
static inline uint8 CalcWindowMask(int i, uint8 W1, uint8 W2){
if(!PPU.ClipWindow1Enable[i]){
if(!PPU.ClipWindow2Enable[i]){
return 0;
} else {
if(!PPU.ClipWindow2Inside[i]) return ~W2;
return W2;
}
} else {
if(!PPU.ClipWindow2Enable[i]){
if(!PPU.ClipWindow1Inside[i]) return ~W1;
return W1;
} else {
if(!PPU.ClipWindow1Inside[i]) W1=~W1;
if(!PPU.ClipWindow2Inside[i]) W2=~W2;
switch(PPU.ClipWindowOverlapLogic[i]){
case 0: // OR
return W1|W2;
case 1: // AND
return W1&W2;
case 2: // XOR
return W1^W2;
case 3: // XNOR
return ~(W1^W2);
}
}
}
static inline uint8 CalcWindowMask (int, uint8, uint8);
static inline void StoreWindowRegions (uint8, struct ClipData *, int, int16 *, uint8 *, bool8, bool8 s = FALSE);
// Never get here
return 0;
static inline uint8 CalcWindowMask (int i, uint8 W1, uint8 W2)
{
if (!PPU.ClipWindow1Enable[i])
{
if (!PPU.ClipWindow2Enable[i])
return (0);
else
{
if (!PPU.ClipWindow2Inside[i])
return (~W2);
return (W2);
}
}
else
{
if (!PPU.ClipWindow2Enable[i])
{
if (!PPU.ClipWindow1Inside[i])
return (~W1);
return (W1);
}
else
{
if (!PPU.ClipWindow1Inside[i])
W1 = ~W1;
if (!PPU.ClipWindow2Inside[i])
W2 = ~W2;
switch (PPU.ClipWindowOverlapLogic[i])
{
case 0: // OR
return (W1 | W2);
case 1: // AND
return (W1 & W2);
case 2: // XOR
return (W1 ^ W2);
case 3: // XNOR
return (~(W1 ^ W2));
}
}
}
// Never get here
return (0);
}
static inline void StoreWindowRegions(uint8 Mask, struct ClipData *Clip, int n_regions, int16 *windows, uint8 *drawing_modes, bool8 sub, bool8 StoreMode0=FALSE){
int ct=0;
for(int j=0; j<n_regions; j++){
int DrawMode=drawing_modes[j];
if(sub) DrawMode|=1;
if((Mask&(1<<j))) DrawMode=0;
if(!StoreMode0 && !DrawMode) continue;
if(ct>0 && Clip->Right[ct-1]==windows[j] && Clip->DrawMode[ct-1]==DrawMode){
// This region borders with and has the same drawing mode as the
// previous region: merge them.
Clip->Right[ct-1]=windows[j+1];
} else {
// Add a new region to the BG
Clip->Left[ct]=windows[j];
Clip->Right[ct]=windows[j+1];
Clip->DrawMode[ct]=DrawMode;
ct++;
}
}
Clip->Count=ct;
static inline void StoreWindowRegions (uint8 Mask, struct ClipData *Clip, int n_regions, int16 *windows, uint8 *drawing_modes, bool8 sub, bool8 StoreMode0)
{
int ct = 0;
for (int j = 0; j < n_regions; j++)
{
int DrawMode = drawing_modes[j];
if (sub)
DrawMode |= 1;
if (Mask & (1 << j))
DrawMode = 0;
if (!StoreMode0 && !DrawMode)
continue;
if (ct > 0 && Clip->Right[ct - 1] == windows[j] && Clip->DrawMode[ct - 1] == DrawMode)
Clip->Right[ct - 1] = windows[j + 1]; // This region borders with and has the same drawing mode as the previous region: merge them.
else
{
// Add a new region to the BG
Clip->Left[ct] = windows[j];
Clip->Right[ct] = windows[j + 1];
Clip->DrawMode[ct] = DrawMode;
ct++;
}
}
Clip->Count = ct;
}
void ComputeClipWindows () {
int16 windows[6]={0,256,256,256,256,256};
uint8 drawing_modes[5]={0,0,0,0,0};
int n_regions=1;
int i, j;
void S9xComputeClipWindows (void)
{
int16 windows[6] = { 0, 256, 256, 256, 256, 256 };
uint8 drawing_modes[5] = { 0, 0, 0, 0, 0 };
int n_regions = 1;
int i, j;
// Calculate window regions. We have at most 5 regions, because we have 6
// control points (screen edges, window 1 left & right, and window 2 left &
// right).
if(PPU.Window1Left<=PPU.Window1Right){
if(PPU.Window1Left>0){
windows[2]=256;
windows[1]=PPU.Window1Left;
n_regions=2;
}
if(PPU.Window1Right<255){
windows[n_regions+1]=256;
windows[n_regions]=PPU.Window1Right+1;
n_regions++;
}
}
if(PPU.Window2Left<=PPU.Window2Right){
for(i=0; i<=n_regions; i++){
if(PPU.Window2Left==windows[i]) break;
if(PPU.Window2Left<windows[i]){
for(j=n_regions; j>=i; j--){
windows[j+1]=windows[j];
}
windows[i]=PPU.Window2Left;
n_regions++;
break;
}
}
for(; i<=n_regions; i++){
if(PPU.Window2Right+1==windows[i]) break;
if(PPU.Window2Right+1<windows[i]){
for(j=n_regions; j>=i; j--){
windows[j+1]=windows[j];
}
windows[i]=PPU.Window2Right+1;
n_regions++;
break;
}
}
}
// Calculate window regions. We have at most 5 regions, because we have 6 control points
// (screen edges, window 1 left & right, and window 2 left & right).
// Get a bitmap of which regions correspond to each window.
uint8 W1, W2;
if (PPU.Window1Left <= PPU.Window1Right)
{
if (PPU.Window1Left > 0)
{
windows[2] = 256;
windows[1] = PPU.Window1Left;
n_regions = 2;
}
if(PPU.Window1Left<=PPU.Window1Right){
for(i=0; windows[i]!=PPU.Window1Left; i++);
for(j=i; windows[j]!=PPU.Window1Right+1; j++);
W1=region_map[i][j];
} else {
W1=0;
}
if(PPU.Window2Left<=PPU.Window2Right){
for(i=0; windows[i]!=PPU.Window2Left; i++);
for(j=i; windows[j]!=PPU.Window2Right+1; j++);
W2=region_map[i][j];
} else {
W2=0;
}
if (PPU.Window1Right < 255)
{
windows[n_regions + 1] = 256;
windows[n_regions] = PPU.Window1Right + 1;
n_regions++;
}
}
// Color Window affects the drawing mode for each region. Modes are: 3=Draw
// as normal, 2=clip color (math only), 1=no math (draw only), 0=nothing.
uint8 CW_color=0, CW_math=0;
uint8 CW=CalcWindowMask(5,W1,W2);
if (PPU.Window2Left <= PPU.Window2Right)
{
for (i = 0; i <= n_regions; i++)
{
if (PPU.Window2Left == windows[i])
break;
switch(Memory.FillRAM[0x2130]&0xc0){
case 0x00:
CW_color=0;
break;
case 0x40:
CW_color=~CW;
break;
case 0x80:
CW_color=CW;
break;
case 0xc0:
CW_color=0xff;
break;
}
switch(Memory.FillRAM[0x2130]&0x30){
case 0x00:
CW_math=0;
break;
case 0x10:
CW_math=~CW;
break;
case 0x20:
CW_math=CW;
break;
case 0x30:
CW_math=0xff;
break;
}
for(i=0; i<n_regions; i++){
if(!(CW_color&(1<<i))) drawing_modes[i]|=1;
if(!(CW_math&(1<<i))) drawing_modes[i]|=2;
}
if (PPU.Window2Left < windows[i])
{
for (j = n_regions; j >= i; j--)
windows[j + 1] = windows[j];
// Store backdrop clip window (draw everywhere color window allows)
StoreWindowRegions(0, &IPPU.Clip[0][5], n_regions, windows, drawing_modes, FALSE, TRUE);
StoreWindowRegions(0, &IPPU.Clip[1][5], n_regions, windows, drawing_modes, TRUE, TRUE);
windows[i] = PPU.Window2Left;
n_regions++;
break;
}
}
// Store per-BG and OBJ clip windows
for(j=0; j<5; j++){
uint8 W=Settings.DisableGraphicWindows?0:CalcWindowMask(j,W1,W2);
for(int sub=0; sub<2; sub++){
if(Memory.FillRAM[sub+0x212e]&(1<<j)){
StoreWindowRegions(W, &IPPU.Clip[sub][j], n_regions, windows, drawing_modes, sub);
} else {
StoreWindowRegions(0, &IPPU.Clip[sub][j], n_regions, windows, drawing_modes, sub);
}
}
}
for (; i <= n_regions; i++)
{
if (PPU.Window2Right + 1 == windows[i])
break;
if (PPU.Window2Right + 1 < windows[i])
{
for (j = n_regions; j >= i; j--)
windows[j + 1] = windows[j];
windows[i] = PPU.Window2Right + 1;
n_regions++;
break;
}
}
}
// Get a bitmap of which regions correspond to each window.
uint8 W1, W2;
if (PPU.Window1Left <= PPU.Window1Right)
{
for (i = 0; windows[i] != PPU.Window1Left; i++) ;
for (j = i; windows[j] != PPU.Window1Right + 1; j++) ;
W1 = region_map[i][j];
}
else
W1 = 0;
if (PPU.Window2Left <= PPU.Window2Right)
{
for (i = 0; windows[i] != PPU.Window2Left; i++) ;
for (j = i; windows[j] != PPU.Window2Right + 1; j++) ;
W2 = region_map[i][j];
}
else
W2 = 0;
// Color Window affects the drawing mode for each region.
// Modes are: 3=Draw as normal, 2=clip color (math only), 1=no math (draw only), 0=nothing.
uint8 CW_color = 0, CW_math = 0;
uint8 CW = CalcWindowMask(5, W1, W2);
switch (Memory.FillRAM[0x2130] & 0xc0)
{
case 0x00: CW_color = 0; break;
case 0x40: CW_color = ~CW; break;
case 0x80: CW_color = CW; break;
case 0xc0: CW_color = 0xff; break;
}
switch (Memory.FillRAM[0x2130] & 0x30)
{
case 0x00: CW_math = 0; break;
case 0x10: CW_math = ~CW; break;
case 0x20: CW_math = CW; break;
case 0x30: CW_math = 0xff; break;
}
for (i = 0; i < n_regions; i++)
{
if (!(CW_color & (1 << i)))
drawing_modes[i] |= 1;
if (!(CW_math & (1 << i)))
drawing_modes[i] |= 2;
}
// Store backdrop clip window (draw everywhere color window allows)
StoreWindowRegions(0, &IPPU.Clip[0][5], n_regions, windows, drawing_modes, FALSE, TRUE);
StoreWindowRegions(0, &IPPU.Clip[1][5], n_regions, windows, drawing_modes, TRUE, TRUE);
// Store per-BG and OBJ clip windows
for (j = 0; j < 5; j++)
{
uint8 W = Settings.DisableGraphicWindows ? 0 : CalcWindowMask(j, W1, W2);
for (int sub = 0; sub < 2; sub++)
{
if (Memory.FillRAM[sub + 0x212e] & (1 << j))
StoreWindowRegions(W, &IPPU.Clip[sub][j], n_regions, windows, drawing_modes, sub);
else
StoreWindowRegions(0, &IPPU.Clip[sub][j], n_regions, windows, drawing_modes, sub);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,295 +172,282 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#ifndef _CONTROLS_H_
#define _CONTROLS_H_
#ifndef FOO_H
#define FOO_H
#define S9xNoMapping 0
#define S9xButtonJoypad 1
#define S9xButtonMouse 2
#define S9xButtonSuperscope 3
#define S9xButtonJustifier 4
#define S9xButtonCommand 5
#define S9xButtonMulti 6
#define S9xAxisJoypad 7
#define S9xPointer 8
#include "port.h"
#define S9xButtonPseudopointer 254
#define S9xAxisPseudopointer 253
#define S9xAxisPseudobuttons 252
#define S9xNoMapping 0
#define S9xButtonJoypad 1
#define S9xButtonMouse 2
#define S9xButtonSuperscope 3
#define S9xButtonJustifier 4
#define S9xButtonCommand 5
#define S9xButtonMulti 6
#define S9xAxisJoypad 7
#define S9xPointer 8
// These are automatically kicked out to the S9xHandlePortCommand function.
// If your port wants to define port-specific commands or whatever, use these values for the s9xcommand_t type field.
#define S9xButtonPseudopointer 254
#define S9xAxisPseudopointer 253
#define S9xAxisPseudobuttons 252
#define S9xButtonPort 251
#define S9xAxisPort 250
#define S9xPointerPort 249
// These are automatically kicked out to the S9xHandlePortCommand function. If
// your port wants to define port-specific commands or whatever, use these
// values for the s9xcommand_t type field.
#define S9xButtonPort 251
#define S9xAxisPort 250
#define S9xPointerPort 249
#define S9xBadMapping 255
#define InvalidControlID ((uint32) -1)
#define S9xBadMapping 255
#define InvalidControlID ((uint32)-1)
// S9xButtonPseudopointer and S9xAxisPseudopointer will report pointer motion using IDs PseudoPointerBase through PseudoPointerBase+7.
// S9xAxisPseudopointer command types. S9xAxisPseudobuttons will report buttons with IDs PseudoButtonBase to PseudoButtonBase+255.
// S9xButtonPseudopointer and S9xAxisPseudopointer will report pointer motion
// using IDs PseudoPointerBase through PseudoPointerBase+7.
// S9xAxisPseudopointer command types. S9xAxisPseudobuttons will report buttons
// with IDs PseudoButtonBase to PseudoButtonBase+255.
#define PseudoPointerBase (InvalidControlID-8)
#define PseudoButtonBase (PseudoPointerBase-256)
#define PseudoPointerBase (InvalidControlID - 8)
#define PseudoButtonBase (PseudoPointerBase - 256)
// Yes, this struct looks huge. But gcc makes it 6 bytes (the minimum), so it's
// not that bad.
typedef struct {
uint8 type;
uint8 multi_press:2;
uint8 button_norpt:1;
typedef struct
{
uint8 type;
uint8 multi_press:2;
uint8 button_norpt:1;
union {
union {
struct {
uint8 idx:3; // Pad number 0-7
uint8 toggle:1; // If set, toggle turbo/sticky for the button
uint8 turbo:1; // If set, be a 'turbo' button
uint8 sticky:1; // If set, toggle button state (on/turbo or off)
// when pressed and do nothing on release
uint16 buttons; // Which buttons to actuate.
// Use SNES_*_MASK constants from snes9x.h
} joypad;
union
{
union
{
struct
{
uint8 idx:3; // Pad number 0-7
uint8 toggle:1; // If set, toggle turbo/sticky for the button
uint8 turbo:1; // If set, be a 'turbo' button
uint8 sticky:1; // If set, toggle button state (on/turbo or off) when pressed and do nothing on release
uint16 buttons; // Which buttons to actuate. Use SNES_*_MASK constants from snes9x.h
} joypad;
struct {
uint8 idx:1; // Mouse number 0-1
uint8 left:1; // buttons
uint8 right:1;
} mouse;
struct
{
uint8 idx:1; // Mouse number 0-1
uint8 left:1; // buttons
uint8 right:1;
} mouse;
struct {
uint8 fire:1;
uint8 cursor:1;
uint8 turbo:1;
uint8 pause:1;
uint8 aim_offscreen:1; // Pretend we're pointing the gun
// offscreen (ignore the pointer)
} scope;
struct
{
uint8 fire:1;
uint8 cursor:1;
uint8 turbo:1;
uint8 pause:1;
uint8 aim_offscreen:1; // Pretend we're pointing the gun offscreen (ignore the pointer)
} scope;
struct {
uint8 idx:3; // Pseudo-pointer number 0-7
uint8 speed_type:2; // 0=variable, 1=slow, 2=med, 3=fast
int8 UD:2; // -1=up, 1=down, 0=no vertical motion
int8 LR:2; // -1=left, 1=right, 0=no horizontal motion
} pointer;
struct
{
uint8 idx:3; // Pseudo-pointer number 0-7
uint8 speed_type:2; // 0=variable, 1=slow, 2=med, 3=fast
int8 UD:2; // -1=up, 1=down, 0=no vertical motion
int8 LR:2; // -1=left, 1=right, 0=no horizontal motion
} pointer;
struct {
uint8 idx:1; // Justifier number 0-1
uint8 trigger:1; // buttons
uint8 start:1;
uint8 aim_offscreen:1; // Pretend we're pointing the gun
// offscreen (ignore the pointer)
} justifier;
struct
{
uint8 idx:1; // Justifier number 0-1
uint8 trigger:1; // buttons
uint8 start:1;
uint8 aim_offscreen:1; // Pretend we're pointing the gun offscreen (ignore the pointer)
} justifier;
int32 multi_idx;
uint16 command;
} button;
int32 multi_idx;
uint16 command;
} button;
union {
struct {
uint8 idx:3; // Pad number 0-7
uint8 invert:1; // 1 = positive is Left/Up/Y/X/L
uint8 axis:3; // 0=Left/Right, 1=Up/Down,
// 2=Y/A, 3=X/B, 4=L/R
uint8 threshold; // (threshold+1)/256% deflection is a
// button press
} joypad;
union
{
struct
{
uint8 idx:3; // Pad number 0-7
uint8 invert:1; // 1 = positive is Left/Up/Y/X/L
uint8 axis:3; // 0=Left/Right, 1=Up/Down, 2=Y/A, 3=X/B, 4=L/R
uint8 threshold; // (threshold+1)/256% deflection is a button press
} joypad;
struct {
uint8 idx:3; // Pseudo-pointer number 0-7
uint8 speed_type:2; // 0=variable, 1=slow, 2=med, 3=fast
uint8 invert:1; // 1 = invert axis, so positive is up/left
uint8 HV:1; // 0=horizontal, 1=vertical
} pointer;
struct
{
uint8 idx:3; // Pseudo-pointer number 0-7
uint8 speed_type:2; // 0=variable, 1=slow, 2=med, 3=fast
uint8 invert:1; // 1 = invert axis, so positive is up/left
uint8 HV:1; // 0=horizontal, 1=vertical
} pointer;
struct {
uint8 threshold; // (threshold+1)/256% deflection is a
// button press
uint8 negbutton; // Button ID for negative deflection
uint8 posbutton; // Button ID for positive deflection
} button;
} axis;
struct
{
uint8 threshold; // (threshold+1)/256% deflection is a button press
uint8 negbutton; // Button ID for negative deflection
uint8 posbutton; // Button ID for positive deflection
} button;
} axis;
struct {
// Which SNES-pointers to control with this pointer
uint16 aim_mouse0:1;
uint16 aim_mouse1:1;
uint16 aim_scope:1;
uint16 aim_justifier0:1;
uint16 aim_justifier1:1;
} pointer;
struct // Which SNES-pointers to control with this pointer
{
uint16 aim_mouse0:1;
uint16 aim_mouse1:1;
uint16 aim_scope:1;
uint16 aim_justifier0:1;
uint16 aim_justifier1:1;
} pointer;
uint8 port[4];
};
} s9xcommand_t;
uint8 port[4];
};
} s9xcommand_t;
// Starting out...
/* Starting out... */
void S9xUnmapAllControls(void);
void S9xUnmapAllControls (void);
/* Setting which controllers are plugged in */
enum controllers {
CTL_NONE, /* all ids ignored */
CTL_JOYPAD, /* use id1 to specify 0-7 */
CTL_MOUSE, /* use id1 to specify 0-1 */
CTL_SUPERSCOPE,
CTL_JUSTIFIER, /* use id1: 0=one justifier, 1=two justifiers */
CTL_MP5 /* use id1-id4 to specify pad 0-7 (or -1) */
// Setting which controllers are plugged in.
enum controllers
{
CTL_NONE, // all ids ignored
CTL_JOYPAD, // use id1 to specify 0-7
CTL_MOUSE, // use id1 to specify 0-1
CTL_SUPERSCOPE,
CTL_JUSTIFIER, // use id1: 0=one justifier, 1=two justifiers
CTL_MP5 // use id1-id4 to specify pad 0-7 (or -1)
};
void S9xSetController(int port, enum controllers controller, int8 id1, int8 id2, int8 id3, int8 id4); /* port=0-1 */
void S9xGetController(int port, enum controllers *controller, int8 *id1, int8 *id2, int8 *id3, int8 *id4);
void S9xReportControllers(void);
/* Call this when you're done with S9xSetController, or if you change any of
* the controller Settings.*Master flags. Returns true if something was
* disabled */
bool S9xVerifyControllers(void);
void S9xSetController (int port, enum controllers controller, int8 id1, int8 id2, int8 id3, int8 id4); // port=0-1
void S9xGetController (int port, enum controllers *controller, int8 *id1, int8 *id2, int8 *id3, int8 *id4);
void S9xReportControllers (void);
/*
* Functions for translation s9xcommand_t's into strings, and vice versa.
* free() the returned string after you're done with it.
*/
char *S9xGetCommandName(s9xcommand_t command);
s9xcommand_t S9xGetCommandT(const char *name);
// Call this when you're done with S9xSetController, or if you change any of the controller Settings.*Master flags.
// Returns true if something was disabled.
/*
* Returns an array of strings naming all the snes9x commands. Note that this
* is only the strings for S9xButtonCommand! The idea is that this would be
* used for a pull-down list in a config GUI. DO NOT free() the returned value.
*/
const char **S9xGetAllSnes9xCommands(void);
bool S9xVerifyControllers (void);
/*
* Generic mapping functions
*/
s9xcommand_t S9xGetMapping(uint32 id);
void S9xUnmapID(uint32 id);
// Functions for translation s9xcommand_t's into strings, and vice versa.
// free() the returned string after you're done with it.
/*
* Button mapping functions. If a button is mapped with poll=TRUE, then
* S9xPollButton will be called whenever snes9x feels a need for that mapping.
* Otherwise, snes9x will assume you will call S9xReportButton() whenever the
* button state changes. S9xMapButton() will fail and return FALSE if
* mapping.type isn't a S9xButton* type.
*/
bool S9xMapButton(uint32 id, s9xcommand_t mapping, bool poll);
void S9xReportButton(uint32 id, bool pressed);
char * S9xGetCommandName (s9xcommand_t command);
s9xcommand_t S9xGetCommandT (const char *name);
/*
* Pointer mapping functions. If a button is mapped with poll=TRUE, then
* S9xPollPointer will be called whenever snes9x feels a need for that mapping.
* Otherwise, snes9x will assume you will call S9xReportPointer() whenever the
* pointer position changes. S9xMapPointer() will fail and return FALSE if
* mapping.type isn't S9xPointer.
*
* Note that position [0,0] is considered the upper-left corner of the
* 'screen', and either [255,223] or [255,239] is the lower-right. Note that
* the SNES mouse doesn't aim at a particular point, so the SNES's idea of
* where the mouse pointer is will probably differ from your OS's idea.
*/
bool S9xMapPointer(uint32 id, s9xcommand_t mapping, bool poll);
void S9xReportPointer(uint32 id, int16 x, int16 y);
// Returns an array of strings naming all the snes9x commands.
// Note that this is only the strings for S9xButtonCommand!
// The idea is that this would be used for a pull-down list in a config GUI. DO NOT free() the returned value.
/*
* Axis mapping functions. If a button is mapped with poll=TRUE, then
* S9xPollAxis will be called whenever snes9x feels a need for that mapping.
* Otherwise, snes9x will assume you will call S9xReportAxis() whenever the
* axis deflection changes. S9xMapAxis() will fail and return FALSE if
* mapping.type isn't a S9xAxis* type.
*
* Note that value is linear -32767 through 32767 with 0 being no
* deflection. If your axis reports differently you should transform the
* value before passing it to S9xReportAxis().
*/
bool S9xMapAxis(uint32 id, s9xcommand_t mapping, bool poll);
void S9xReportAxis(uint32 id, int16 value);
const char ** S9xGetAllSnes9xCommands (void);
/*
* Do whatever the s9xcommand_t says to do. If cmd.type is a button type, data1
* should be TRUE (non-0) or FALSE (0) to indicate whether the 'button' is
* pressed or released. If cmd.type is an axis, data1 holds the deflection
* value. If cmd.type is a pointer, data1 and data2 are the positions of the
* pointer.
*/
void S9xApplyCommand(s9xcommand_t cmd, int16 data1, int16 data2);
// Generic mapping functions
/*******
* These functions are called by snes9x into your port, so each port should
* implement them.
*/
s9xcommand_t S9xGetMapping (uint32 id);
void S9xUnmapID (uint32 id);
/*
* If something was mapped with poll=TRUE, these functions will be called when
* snes9x needs the button/axis/pointer state. Fill in the reference options as
* appropriate.
*/
bool S9xPollButton(uint32 id, bool *pressed);
bool S9xPollPointer(uint32 id, int16 *x, int16 *y);
bool S9xPollAxis(uint32 id, int16 *value);
// Button mapping functions.
// If a button is mapped with poll=TRUE, then S9xPollButton will be called whenever snes9x feels a need for that mapping.
// Otherwise, snes9x will assume you will call S9xReportButton() whenever the button state changes.
// S9xMapButton() will fail and return FALSE if mapping.type isn't an S9xButton* type.
/*
* These are called when snes9x tries to apply a command with a S9x*Port type.
* data1 and data2 are filled in like S9xApplyCommand.
*/
void S9xHandlePortCommand(s9xcommand_t cmd, int16 data1, int16 data2);
bool S9xMapButton (uint32 id, s9xcommand_t mapping, bool poll);
void S9xReportButton (uint32 id, bool pressed);
// Pointer mapping functions.
// If a pointer is mapped with poll=TRUE, then S9xPollPointer will be called whenever snes9x feels a need for that mapping.
// Otherwise, snes9x will assume you will call S9xReportPointer() whenever the pointer position changes.
// S9xMapPointer() will fail and return FALSE if mapping.type isn't an S9xPointer* type.
// Note that position [0,0] is considered the upper-left corner of the 'screen',
// and either [255,223] or [255,239] is the lower-right.
// Note that the SNES mouse doesn't aim at a particular point,
// so the SNES's idea of where the mouse pointer is will probably differ from your OS's idea.
bool S9xMapPointer (uint32 id, s9xcommand_t mapping, bool poll);
void S9xReportPointer (uint32 id, int16 x, int16 y);
// Axis mapping functions.
// If an axis is mapped with poll=TRUE, then S9xPollAxis will be called whenever snes9x feels a need for that mapping.
// Otherwise, snes9x will assume you will call S9xReportAxis() whenever the axis deflection changes.
// S9xMapAxis() will fail and return FALSE if mapping.type isn't an S9xAxis* type.
// Note that value is linear -32767 through 32767 with 0 being no deflection.
// If your axis reports differently you should transform the value before passing it to S9xReportAxis().
bool S9xMapAxis (uint32 id, s9xcommand_t mapping, bool poll);
void S9xReportAxis (uint32 id, int16 value);
// Do whatever the s9xcommand_t says to do.
// If cmd.type is a button type, data1 should be TRUE (non-0) or FALSE (0) to indicate whether the 'button' is pressed or released.
// If cmd.type is an axis, data1 holds the deflection value.
// If cmd.type is a pointer, data1 and data2 are the positions of the pointer.
void S9xApplyCommand (s9xcommand_t cmd, int16 data1, int16 data2);
//////////
// These functions are called by snes9x into your port, so each port should implement them.
// If something was mapped with poll=TRUE, these functions will be called when snes9x needs the button/axis/pointer state.
// Fill in the reference options as appropriate.
bool S9xPollButton (uint32 id, bool *pressed);
bool S9xPollPointer (uint32 id, int16 *x, int16 *y);
bool S9xPollAxis (uint32 id, int16 *value);
// These are called when snes9x tries to apply a command with a S9x*Port type.
// data1 and data2 are filled in like S9xApplyCommand.
void S9xHandlePortCommand (s9xcommand_t cmd, int16 data1, int16 data2);
// Called before already-read SNES joypad data is being used by the game if your port defines SNES_JOY_READ_CALLBACKS.
/*
* Called before already-read SNES joypad data is being used by the game
* if your port defines SNES_JOY_READ_CALLBACKS
*/
#ifdef SNES_JOY_READ_CALLBACKS
void S9xOnSNESPadRead();
void S9xOnSNESPadRead (void);
#endif
/* These are for your use */
s9xcommand_t S9xGetPortCommandT(const char *name);
char *S9xGetPortCommandName(s9xcommand_t command);
void S9xSetupDefaultKeymap(void);
bool8 S9xMapInput(const char *name, s9xcommand_t *cmd);
// These are for your use.
s9xcommand_t S9xGetPortCommandT (const char *name);
char * S9xGetPortCommandName (s9xcommand_t command);
void S9xSetupDefaultKeymap (void);
bool8 S9xMapInput (const char *name, s9xcommand_t *cmd);
/*******
* These functions are called from snes9x into this subsystem. No need to use
* them from a port.
*/
//////////
// These functions are called from snes9x into this subsystem. No need to use them from a port.
/* Use when resetting snes9x */
void S9xControlsReset(void);
void S9xControlsSoftReset(void);
// Use when resetting snes9x.
/* Use when writing to $4016 */
void S9xSetJoypadLatch(bool latch);
void S9xControlsReset (void);
void S9xControlsSoftReset (void);
/* Use when reading $4016/7 (JOYSER0 and JOYSER1) */
uint8 S9xReadJOYSERn(int n);
// Use when writing to $4016.
/* End-Of-Frame processing. Sets gun latch variables and tries to draw
* crosshairs */
void S9xControlEOF(void);
void S9xSetJoypadLatch (bool latch);
struct SControlSnapshot {
uint8 ver;
uint8 port1_read_idx[2];
uint8 dummy1[4]; // for future expansion
uint8 port2_read_idx[2];
uint8 dummy2[4];
uint8 mouse_speed[2];
uint8 justifier_select;
uint8 dummy3[8];
bool8 pad_read, pad_read_last;
uint8 internal[60]; // yes, we need to save this!
// Use when reading $4016/7 (JOYSER0 and JOYSER1).
uint8 S9xReadJOYSERn (int n);
// End-Of-Frame processing. Sets gun latch variables and tries to draw crosshairs
void S9xControlEOF (void);
// Functions and a structure for snapshot.
struct SControlSnapshot
{
uint8 ver;
uint8 port1_read_idx[2];
uint8 dummy1[4]; // for future expansion
uint8 port2_read_idx[2];
uint8 dummy2[4];
uint8 mouse_speed[2];
uint8 justifier_select;
uint8 dummy3[8];
bool8 pad_read, pad_read_last;
uint8 internal[60]; // yes, we need to save this!
};
void S9xControlPreSave(struct SControlSnapshot *s);
void S9xControlPostLoad(struct SControlSnapshot *s);
void S9xControlPreSaveState (struct SControlSnapshot *s);
void S9xControlPostLoadState (struct SControlSnapshot *s);
#endif

View File

@ -1,233 +0,0 @@
/**********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
Jerremy Koot (jkoot@snes9x.com)
(c) Copyright 2002 - 2004 Matthew Kendora
(c) Copyright 2002 - 2005 Peter Bortas (peter@bortas.org)
(c) Copyright 2004 - 2005 Joel Yliluoma (http://iki.fi/bisqwit/)
(c) Copyright 2001 - 2006 John Weidman (jweidman@slip.net)
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
zones
C4 x86 assembler and some C emulation code
(c) Copyright 2000 - 2003 _Demo_ (_demo_@zsnes.com),
Nach,
zsKnight (zsknight@zsnes.com)
C4 C++ code
(c) Copyright 2003 - 2006 Brad Jorsch,
Nach
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
Kris Bleakley,
Matthew Kendora,
Nach,
neviksti (neviksti@hotmail.com)
DSP-2 emulator code
(c) Copyright 2003 John Weidman,
Kris Bleakley,
Lord Nightmare (lord_nightmare@users.sourceforge.net),
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
Lancer,
z80 gaiden
DSP-4 emulator code
(c) Copyright 2004 - 2006 Dreamer Nom,
John Weidman,
Kris Bleakley,
Nach,
z80 gaiden
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
John Weidman
ST010 C++ emulator code
(c) Copyright 2003 Feather,
John Weidman,
Kris Bleakley,
Matthew Kendora
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
2xSaI filter
(c) Copyright 1999 - 2001 Derek Liauw Kie Fa
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
fee, providing that this license information and copyright notice appear
with all copies and any derived work.
This software is provided 'as-is', without any express or implied
warranty. In no event shall the authors be held liable for any damages
arising from the use of this software or it's derivatives.
Snes9x is freeware for PERSONAL USE only. Commercial users should
seek permission of the copyright holders first. Commercial use includes,
but is not limited to, charging money for Snes9x or software derived from
Snes9x, including Snes9x or derivatives in commercial game bundles, and/or
using Snes9x as a promotion for your commercial product.
The copyright holders request that bug fixes and improvements to the code
should be forwarded to them so everyone can benefit from the modifications
in future versions.
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
/*
* Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
*
* (c) Copyright 1996 - 2001 Gary Henderson (gary.henderson@ntlworld.com) and
* Jerremy Koot (jkoot@snes9x.com)
*
* Super FX C emulator code
* (c) Copyright 1997 - 1999 Ivar (ivar@snes9x.com) and
* Gary Henderson.
* Super FX assembler emulator code (c) Copyright 1998 zsKnight and _Demo_.
*
* DSP1 emulator code (c) Copyright 1998 Ivar, _Demo_ and Gary Henderson.
* C4 asm and some C emulation code (c) Copyright 2000 zsKnight and _Demo_.
* C4 C code (c) Copyright 2001 Gary Henderson (gary.henderson@ntlworld.com).
*
* DOS port code contains the works of other authors. See headers in
* individual files.
*
* Snes9x homepage: http://www.snes9x.com
*
* Permission to use, copy, modify and distribute Snes9x in both binary and
* source form, for non-commercial purposes, is hereby granted without fee,
* providing that this license information and copyright notice appear with
* all copies and any derived work.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event shall the authors be held liable for any damages
* arising from the use of this software.
*
* Snes9x is freeware for PERSONAL USE only. Commercial users should
* seek permission of the copyright holders first. Commercial use includes
* charging money for Snes9x or software derived from Snes9x.
*
* The copyright holders request that bug fixes and improvements to the code
* should be forwarded to them so everyone can benefit from the modifications
* in future versions.
*
* Super NES and Super Nintendo Entertainment System are trademarks of
* Nintendo Co., Limited and its subsidiary companies.
*/
/*
* Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
*
* (c) Copyright 1996, 1997, 1998, 1999 Gary Henderson (gary@daniver.demon.co.uk) and
* Jerremy Koot (jkoot@snes9x.com)
*
* Super FX C emulator code (c) Copyright 1997, 1998 Ivar and
* Gary Henderson.
* Super FX assembler emulator code (c) Copyright 1998 zsKnight and _Demo_.
*
* Permission to use, copy, modify and distribute Snes9x in both binary and
* source form, for non-commercial purposes, is hereby granted without fee,
* providing that this license information and copyright notice appear with
* all copies and any derived work.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event shall the authors be held liable for any damages
* arising from the use of this software.
*
* Snes9x is freeware for PERSONAL USE only. Commercial users should
* seek permission of the copyright holders first. Commercial use includes
* charging money for Snes9x or software derived from Snes9x.
*
* The copyright holders request that bug fixes and improvements to the code
* should be forwarded to them so everyone can benefit from the modifications
* in future versions.
*
* Super NES and Super Nintendo Entertainment System are trademarks of
* Nintendo Co., Limited and its subsidiary companies.
*/

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,286 +172,168 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#include "snes9x.h"
#include "memmap.h"
#include "ppu.h"
#include "dsp1.h"
#include "cpuexec.h"
#include "s9xdebug.h"
#include "apu.h"
#include "dma.h"
#include "sa1.h"
#include "cheats.h"
#include "srtc.h"
#include "sdd1.h"
#include "spc7110.h"
#include "obc1.h"
#include "bsx.h"
#include "snapshot.h"
#ifndef NGC
#include "logger.h"
#endif
#ifndef ZSNES_FX
#include "apu/apu.h"
#include "fxemu.h"
extern struct FxInit_s SuperFX;
void S9xResetSuperFX ()
{
SuperFX.vFlags = 0; //FX_FLAG_ROM_BUFFER;// | FX_FLAG_ADDRESS_CHECKING;
// FIXME: Snes9x can't execute CPU and SuperFX at a time. Don't ask me what is 0.417 :P
SuperFX.speedPerLine = (uint32) (0.417 * 10.5e6 * ((1.0 / (float) Memory.ROMFramesPerSecond) / ((float) (Timings.V_Max))));
//printf("SFX:%d\n", SuperFX.speedPerLine);
SuperFX.oneLineDone = FALSE;
FxReset (&SuperFX);
}
#include "sdd1.h"
#include "srtc.h"
#include "snapshot.h"
#include "cheats.h"
#include "logger.h"
#ifdef DEBUGGER
#include "debug.h"
#endif
void S9xSoftResetCPU ()
static void S9xResetCPU (void);
static void S9xSoftResetCPU (void);
static void S9xResetCPU (void)
{
Registers.PBPC = 0;
Registers.PB = 0;
Registers.PCw = S9xGetWord (0xFFFC);
OpenBus = Registers.PCh;
Registers.D.W = 0;
Registers.DB = 0;
Registers.SH = 1;
Registers.SL -= 3;
Registers.XH = 0;
Registers.YH = 0;
S9xSoftResetCPU();
Registers.SL = 0xff;
Registers.P.W = 0;
Registers.A.W = 0;
Registers.X.W = 0;
Registers.Y.W = 0;
SetFlags(MemoryFlag | IndexFlag | IRQ | Emulation);
ClearFlags(Decimal);
}
ICPU.ShiftedPB = 0;
ICPU.ShiftedDB = 0;
SetFlags (MemoryFlag | IndexFlag | IRQ | Emulation);
ClearFlags (Decimal);
static void S9xSoftResetCPU (void)
{
Registers.PBPC = 0;
Registers.PB = 0;
Registers.PCw = S9xGetWord(0xfffc);
OpenBus = Registers.PCh;
Registers.D.W = 0;
Registers.DB = 0;
Registers.SH = 1;
Registers.SL -= 3;
Registers.XH = 0;
Registers.YH = 0;
CPU.Flags = CPU.Flags & (DEBUG_MODE_FLAG | TRACE_FLAG);
CPU.BranchSkip = FALSE;
CPU.NMIActive = FALSE;
CPU.IRQActive = FALSE;
CPU.WaitingForInterrupt = FALSE;
ICPU.ShiftedPB = 0;
ICPU.ShiftedDB = 0;
SetFlags(MemoryFlag | IndexFlag | IRQ | Emulation);
ClearFlags(Decimal);
CPU.Cycles = 182; // Or 188. This is the cycle count just after the jump to the Reset Vector.
CPU.PrevCycles = -1;
CPU.V_Counter = 0;
CPU.Flags = CPU.Flags & (DEBUG_MODE_FLAG | TRACE_FLAG);
CPU.PCBase = NULL;
CPU.IRQActive = FALSE;
CPU.IRQPending = 0;
CPU.MemSpeed = SLOW_ONE_CYCLE;
CPU.MemSpeedx2 = SLOW_ONE_CYCLE * 2;
CPU.FastROMSpeed = SLOW_ONE_CYCLE;
CPU.InDMA = FALSE;
CPU.InHDMA = FALSE;
CPU.InDMAorHDMA = FALSE;
CPU.InDMAorHDMA = FALSE;
CPU.InWRAMDMAorHDMA = FALSE;
CPU.HDMARanInDMA = 0;
CPU.PCBase = NULL;
CPU.PBPCAtOpcodeStart = 0xffffffff;
CPU.WaitAddress = 0xffffffff;
CPU.WaitCounter = 0;
CPU.Cycles = 182; // Or 188. This is the cycle count just after the jump to the Reset Vector.
CPU.PrevCycles = -1;
CPU.V_Counter = 0;
CPU.MemSpeed = SLOW_ONE_CYCLE;
CPU.MemSpeedx2 = SLOW_ONE_CYCLE * 2;
CPU.FastROMSpeed = SLOW_ONE_CYCLE;
CPU.AutoSaveTimer = 0;
CPU.SRAMModified = FALSE;
CPU.BRKTriggered = FALSE;
CPU.IRQPending = 0;
CPU.CurrentDMAorHDMAChannel = -1;
CPU.WhichEvent = HC_RENDER_EVENT;
CPU.NextEvent = Timings.RenderPos;
CPU.WaitingForInterrupt = FALSE;
CPU.WaitAddress = 0xffffffff;
CPU.WaitCounter = 0;
CPU.PBPCAtOpcodeStart = 0xffffffff;
CPU.AutoSaveTimer = 0;
CPU.SRAMModified = FALSE;
Timings.InterlaceField = FALSE;
Timings.H_Max = Timings.H_Max_Master;
Timings.V_Max = Timings.V_Max_Master;
Timings.NMITriggerPos = 0xffff;
Timings.NMITriggerPos = 0xffff;
if (Model->_5A22 == 2)
Timings.WRAMRefreshPos = SNES_WRAM_REFRESH_HC_v2;
else
Timings.WRAMRefreshPos = SNES_WRAM_REFRESH_HC_v1;
CPU.WhichEvent = HC_RENDER_EVENT;
CPU.NextEvent = Timings.RenderPos;
S9xSetPCBase(Registers.PBPC);
S9xSetPCBase (Registers.PBPC);
ICPU.S9xOpcodes = S9xOpcodesE1;
ICPU.S9xOpLengths = S9xOpLengthsM1X1;
ICPU.CPUExecuting = TRUE;
ICPU.S9xOpcodes = S9xOpcodesE1;
ICPU.S9xOpLengths = S9xOpLengthsM1X1;
ICPU.CPUExecuting = TRUE;
S9xUnpackStatus();
S9xUnpackStatus();
}
void S9xResetCPU ()
{
S9xSoftResetCPU ();
Registers.SL = 0xFF;
Registers.P.W = 0;
Registers.A.W = 0;
Registers.X.W = 0;
Registers.Y.W = 0;
SetFlags (MemoryFlag | IndexFlag | IRQ | Emulation);
ClearFlags (Decimal);
}
#ifdef ZSNES_FX
START_EXTERN_C
void S9xResetSuperFX ();
bool8 WinterGold = 0;
extern uint8 *C4Ram;
END_EXTERN_C
#endif
void S9xReset (void)
{
#ifndef NGC
ResetLogger();
S9xResetSaveTimer (FALSE);
#endif
S9xResetSaveTimer(FALSE);
S9xResetLogger();
ZeroMemory (Memory.FillRAM, 0x8000);
memset (Memory.VRAM, 0x00, 0x10000);
memset (Memory.RAM, 0x55, 0x20000);
memset(Memory.RAM, 0x55, 0x20000);
memset(Memory.VRAM, 0x00, 0x10000);
ZeroMemory(Memory.FillRAM, 0x8000);
if (Settings.BS)
S9xResetBSX();
if(Settings.SPC7110)
S9xSpc7110Reset();
S9xResetCPU ();
S9xResetPPU ();
S9xResetSRTC ();
if (Settings.SDD1)
S9xResetSDD1 ();
S9xResetDMA ();
S9xResetAPU ();
S9xResetDSP1 ();
S9xSA1Init ();
if (Settings.C4)
S9xInitC4 ();
S9xInitCheatData ();
S9xResetCPU();
S9xResetPPU();
S9xResetDMA();
S9xResetAPU();
if (Settings.DSP)
S9xResetDSP();
if (Settings.SuperFX)
S9xResetSuperFX();
if (Settings.SA1)
S9xSA1Init();
if (Settings.SDD1)
S9xResetSDD1();
if (Settings.SPC7110)
S9xResetSPC7110();
if (Settings.C4)
S9xInitC4();
if (Settings.OBC1)
ResetOBC1();
if (Settings.SuperFX)
S9xResetSuperFX ();
#ifdef ZSNES_FX
WinterGold = Settings.WinterGold;
#endif
// Settings.Paused = FALSE;
S9xResetOBC1();
if (Settings.SRTC)
S9xResetSRTC();
S9xInitCheatData();
}
void S9xSoftReset (void)
{
#ifndef NGC
S9xResetSaveTimer (FALSE);
#endif
S9xResetSaveTimer(FALSE);
memset(Memory.VRAM, 0x00, 0x10000);
ZeroMemory(Memory.FillRAM, 0x8000);
if (Settings.BS)
S9xResetBSX();
if (Settings.SuperFX)
S9xResetSuperFX ();
#ifdef ZSNES_FX
WinterGold = Settings.WinterGold;
#endif
ZeroMemory (Memory.FillRAM, 0x8000);
memset (Memory.VRAM, 0x00, 0x10000);
// memset (Memory.RAM, 0x55, 0x20000);
if(Settings.SPC7110)
S9xSpc7110Reset();
S9xSoftResetCPU ();
S9xSoftResetPPU ();
S9xResetSRTC ();
if (Settings.SDD1)
S9xResetSDD1 ();
S9xSoftResetCPU();
S9xSoftResetPPU();
S9xResetDMA();
S9xSoftResetAPU();
S9xResetDMA ();
S9xResetAPU ();
S9xResetDSP1 ();
if(Settings.OBC1)
ResetOBC1();
S9xSA1Init ();
if (Settings.C4)
S9xInitC4 ();
if (Settings.DSP)
S9xResetDSP();
if (Settings.SuperFX)
S9xResetSuperFX();
if (Settings.SA1)
S9xSA1Init();
if (Settings.SDD1)
S9xResetSDD1();
if (Settings.SPC7110)
S9xResetSPC7110();
if (Settings.C4)
S9xInitC4();
if (Settings.OBC1)
S9xResetOBC1();
if (Settings.SRTC)
S9xResetSRTC();
S9xInitCheatData ();
// Settings.Paused = FALSE;
S9xInitCheatData();
}
uint8 S9xOpLengthsM0X0[256] = {
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 0
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 1
3, 2, 4, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 2
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 3
1, 2, 2, 2, 3, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 4
2, 2, 2, 2, 3, 2, 2, 2, 1, 3, 1, 1, 4, 3, 3, 4, // 5
1, 2, 3, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 6
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 7
2, 2, 3, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 8
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 9
3, 2, 3, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // A
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // B
3, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // C
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // D
3, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // E
2, 2, 2, 2, 3, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4 // F
};
uint8 S9xOpLengthsM0X1[256] = {
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 0
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 1
3, 2, 4, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 2
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 3
1, 2, 2, 2, 3, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 4
2, 2, 2, 2, 3, 2, 2, 2, 1, 3, 1, 1, 4, 3, 3, 4, // 5
1, 2, 3, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 6
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 7
2, 2, 3, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 8
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 9
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // A
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // B
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // C
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // D
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // E
2, 2, 2, 2, 3, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4 // F
};
uint8 S9xOpLengthsM1X0[256] = {
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // 0
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 1
3, 2, 4, 2, 2, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // 2
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 3
1, 2, 2, 2, 3, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // 4
2, 2, 2, 2, 3, 2, 2, 2, 1, 3, 1, 1, 4, 3, 3, 4, // 5
1, 2, 3, 2, 2, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // 6
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 7
2, 2, 3, 2, 2, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // 8
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 9
3, 2, 3, 2, 2, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // A
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // B
3, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // C
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // D
3, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // E
2, 2, 2, 2, 3, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4 // F
};
uint8 S9xOpLengthsM1X1[256] = {
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // 0
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 1
3, 2, 4, 2, 2, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // 2
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 3
1, 2, 2, 2, 3, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // 4
2, 2, 2, 2, 3, 2, 2, 2, 1, 3, 1, 1, 4, 3, 3, 4, // 5
1, 2, 3, 2, 2, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // 6
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 7
2, 2, 3, 2, 2, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // 8
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 9
2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // A
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // B
2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // C
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // D
2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // E
2, 2, 2, 2, 3, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4 // F
};

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,398 +172,519 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#ifndef _CPUADDR_H_
#define _CPUADDR_H_
typedef enum {
NONE = 0,
READ = 1,
WRITE = 2,
MODIFY = 3,
JUMP = 5,
JSR = 8
} AccessMode;
typedef enum
{
NONE = 0,
READ = 1,
WRITE = 2,
MODIFY = 3,
JUMP = 5,
JSR = 8
} AccessMode;
STATIC inline uint8 Immediate8 (AccessMode a) {
uint8 val = CPU.PCBase[Registers.PCw];
if(a&READ) OpenBus = val;
AddCycles(CPU.MemSpeed);
Registers.PCw++;
return val;
static inline uint8 Immediate8Slow (AccessMode a)
{
uint8 val = S9xGetByte(Registers.PBPC);
if (a & READ)
OpenBus = val;
Registers.PCw++;
return (val);
}
STATIC inline uint8 Immediate8Slow (AccessMode a) {
uint8 val = S9xGetByte(Registers.PBPC);
if(a&READ) OpenBus = val;
Registers.PCw++;
return val;
static inline uint8 Immediate8 (AccessMode a)
{
uint8 val = CPU.PCBase[Registers.PCw];
if (a & READ)
OpenBus = val;
AddCycles(CPU.MemSpeed);
Registers.PCw++;
return (val);
}
STATIC inline uint16 Immediate16 (AccessMode a) {
uint16 val = READ_WORD(CPU.PCBase+Registers.PCw);
if(a&READ) OpenBus = (uint8)(val>>8);
AddCycles(CPU.MemSpeedx2);
Registers.PCw+=2;
return val;
static inline uint16 Immediate16Slow (AccessMode a)
{
uint16 val = S9xGetWord(Registers.PBPC, WRAP_BANK);
if (a & READ)
OpenBus = (uint8) (val >> 8);
Registers.PCw += 2;
return (val);
}
STATIC inline uint16 Immediate16Slow (AccessMode a) {
uint16 val = S9xGetWord(Registers.PBPC, WRAP_BANK);
if(a&READ) OpenBus = (uint8)(val>>8);
Registers.PCw+=2;
return val;
static inline uint16 Immediate16 (AccessMode a)
{
uint16 val = READ_WORD(CPU.PCBase + Registers.PCw);
if (a & READ)
OpenBus = (uint8) (val >> 8);
AddCycles(CPU.MemSpeedx2);
Registers.PCw += 2;
return (val);
}
static inline uint32 RelativeSlow (AccessMode a) // branch $xx
{
int8 offset = Immediate8Slow(a);
STATIC inline uint32 RelativeSlow (AccessMode a) { // branch $xx
int8 offset = Immediate8Slow(a);
return ((int16)Registers.PCw + offset) & 0xffff;
return ((int16) Registers.PCw + offset) & 0xffff;
}
STATIC inline uint32 Relative (AccessMode a) { // branch $xx
int8 offset = Immediate8(a);
return ((int16)Registers.PCw + offset) & 0xffff;
static inline uint32 Relative (AccessMode a) // branch $xx
{
int8 offset = Immediate8(a);
return ((int16) Registers.PCw + offset) & 0xffff;
}
STATIC inline uint32 RelativeLongSlow (AccessMode a) { // BRL $xxxx
int16 offset = Immediate16Slow(a);
return ((int32)Registers.PCw + offset) & 0xffff;
static inline uint32 RelativeLongSlow (AccessMode a) // BRL $xxxx
{
int16 offset = Immediate16Slow(a);
return ((int32) Registers.PCw + offset) & 0xffff;
}
STATIC inline uint32 RelativeLong (AccessMode a) { // BRL $xxxx
int16 offset = Immediate16(a);
return ((int32)Registers.PCw + offset) & 0xffff;
static inline uint32 RelativeLong (AccessMode a) // BRL $xxxx
{
int16 offset = Immediate16(a);
return ((int32) Registers.PCw + offset) & 0xffff;
}
STATIC inline uint32 AbsoluteIndexedIndirectSlow (AccessMode a) { // (a,X)
uint16 addr;
if(a&JSR){
// JSR (a,X) pushes the old address in the middle of loading the new.
// OpenBus needs to be set to account for this.
addr = Immediate8Slow(READ);
if(a==JSR) OpenBus = Registers.PCl;
addr |= Immediate8Slow(READ)<<8;
} else {
addr = Immediate16Slow(READ);
}
AddCycles(ONE_CYCLE);
addr+=Registers.X.W;
static inline uint32 AbsoluteIndexedIndirectSlow (AccessMode a) // (a,X)
{
uint16 addr;
// Address load wraps within the bank
uint16 addr2 = S9xGetWord(ICPU.ShiftedPB | addr, WRAP_BANK);
OpenBus = addr2>>8;
return addr2;
if (a & JSR)
{
// JSR (a,X) pushes the old address in the middle of loading the new.
// OpenBus needs to be set to account for this.
addr = Immediate8Slow(READ);
if (a == JSR)
OpenBus = Registers.PCl;
addr |= Immediate8Slow(READ) << 8;
}
else
addr = Immediate16Slow(READ);
AddCycles(ONE_CYCLE);
addr += Registers.X.W;
// Address load wraps within the bank
uint16 addr2 = S9xGetWord(ICPU.ShiftedPB | addr, WRAP_BANK);
OpenBus = addr2 >> 8;
return (addr2);
}
STATIC inline uint32 AbsoluteIndexedIndirect (AccessMode a) { // (a,X)
uint16 addr = Immediate16Slow(READ);
addr+=Registers.X.W;
static inline uint32 AbsoluteIndexedIndirect (AccessMode a) // (a,X)
{
uint16 addr = Immediate16Slow(READ);
addr += Registers.X.W;
// Address load wraps within the bank
uint16 addr2 = S9xGetWord(ICPU.ShiftedPB | addr, WRAP_BANK);
OpenBus = addr2>>8;
return addr2;
// Address load wraps within the bank
uint16 addr2 = S9xGetWord(ICPU.ShiftedPB | addr, WRAP_BANK);
OpenBus = addr2 >> 8;
return (addr2);
}
STATIC inline uint32 AbsoluteIndirectLongSlow (AccessMode a) { // [a]
uint16 addr = Immediate16Slow(READ);
static inline uint32 AbsoluteIndirectLongSlow (AccessMode a) // [a]
{
uint16 addr = Immediate16Slow(READ);
// No info on wrapping, but it doesn't matter anyway due to mirroring
uint32 addr2 = S9xGetWord(addr);
OpenBus=addr2>>8;
addr2 |= (OpenBus = S9xGetByte(addr+2))<<16;
return addr2;
// No info on wrapping, but it doesn't matter anyway due to mirroring
uint32 addr2 = S9xGetWord(addr);
OpenBus = addr2 >> 8;
addr2 |= (OpenBus = S9xGetByte(addr + 2)) << 16;
return (addr2);
}
STATIC inline uint32 AbsoluteIndirectLong (AccessMode a) { // [a]
uint16 addr = Immediate16(READ);
static inline uint32 AbsoluteIndirectLong (AccessMode a) // [a]
{
uint16 addr = Immediate16(READ);
// No info on wrapping, but it doesn't matter anyway due to mirroring
uint32 addr2 = S9xGetWord(addr);
OpenBus=addr2>>8;
addr2 |= (OpenBus = S9xGetByte(addr+2))<<16;
return addr2;
// No info on wrapping, but it doesn't matter anyway due to mirroring
uint32 addr2 = S9xGetWord(addr);
OpenBus = addr2 >> 8;
addr2 |= (OpenBus = S9xGetByte(addr + 2)) << 16;
return (addr2);
}
STATIC inline uint32 AbsoluteIndirectSlow (AccessMode a) { // (a)
// No info on wrapping, but it doesn't matter anyway due to mirroring
uint16 addr2 = S9xGetWord(Immediate16Slow(READ));
OpenBus=addr2>>8;
return addr2;
static inline uint32 AbsoluteIndirectSlow (AccessMode a) // (a)
{
// No info on wrapping, but it doesn't matter anyway due to mirroring
uint16 addr2 = S9xGetWord(Immediate16Slow(READ));
OpenBus = addr2 >> 8;
return (addr2);
}
STATIC inline uint32 AbsoluteIndirect (AccessMode a) { // (a)
// No info on wrapping, but it doesn't matter anyway due to mirroring
uint16 addr2 = S9xGetWord(Immediate16(READ));
OpenBus=addr2>>8;
return addr2;
static inline uint32 AbsoluteIndirect (AccessMode a) // (a)
{
// No info on wrapping, but it doesn't matter anyway due to mirroring
uint16 addr2 = S9xGetWord(Immediate16(READ));
OpenBus = addr2 >> 8;
return (addr2);
}
STATIC inline uint32 AbsoluteSlow (AccessMode a) { // a
return ICPU.ShiftedDB|Immediate16Slow(a);
static inline uint32 AbsoluteSlow (AccessMode a) // a
{
return (ICPU.ShiftedDB | Immediate16Slow(a));
}
STATIC inline uint32 Absolute (AccessMode a) { // a
return ICPU.ShiftedDB|Immediate16(a);
static inline uint32 Absolute (AccessMode a) // a
{
return (ICPU.ShiftedDB | Immediate16(a));
}
STATIC inline uint32 AbsoluteLongSlow (AccessMode a) { // l
uint32 addr = Immediate16Slow(READ);
static inline uint32 AbsoluteLongSlow (AccessMode a) // l
{
uint32 addr = Immediate16Slow(READ);
// JSR l pushes the old bank in the middle of loading the new.
// OpenBus needs to be set to account for this.
if(a==JSR) OpenBus = Registers.PB;
// JSR l pushes the old bank in the middle of loading the new.
// OpenBus needs to be set to account for this.
if (a == JSR)
OpenBus = Registers.PB;
addr |= Immediate8Slow(a)<<16;
return addr;
addr |= Immediate8Slow(a) << 16;
return (addr);
}
STATIC inline uint32 AbsoluteLong (AccessMode a) { // l
uint32 addr = READ_3WORD(CPU.PCBase+Registers.PCw);
AddCycles(CPU.MemSpeedx2+CPU.MemSpeed);
if(a&READ) OpenBus = addr>>16;
Registers.PCw+=3;
return addr;
static inline uint32 AbsoluteLong (AccessMode a) // l
{
uint32 addr = READ_3WORD(CPU.PCBase + Registers.PCw);
AddCycles(CPU.MemSpeedx2 + CPU.MemSpeed);
if (a & READ)
OpenBus = addr >> 16;
Registers.PCw += 3;
return (addr);
}
STATIC inline uint32 DirectSlow (AccessMode a) { // d
uint16 addr = Immediate8Slow(a) + Registers.D.W;
if(Registers.DL!=0) AddCycles(ONE_CYCLE);
return addr;
static inline uint32 DirectSlow (AccessMode a) // d
{
uint16 addr = Immediate8Slow(a) + Registers.D.W;
if (Registers.DL != 0)
AddCycles(ONE_CYCLE);
return (addr);
}
STATIC inline uint32 Direct (AccessMode a) { // d
uint16 addr = Immediate8(a) + Registers.D.W;
if(Registers.DL!=0) AddCycles(ONE_CYCLE);
return addr;
static inline uint32 Direct (AccessMode a) // d
{
uint16 addr = Immediate8(a) + Registers.D.W;
if (Registers.DL != 0)
AddCycles(ONE_CYCLE);
return (addr);
}
STATIC inline uint32 DirectIndirectSlow (AccessMode a) { // (d)
uint32 addr = S9xGetWord(DirectSlow(READ),
(!CheckEmulation() || Registers.DL)?WRAP_BANK:WRAP_PAGE);
if(a&READ) OpenBus=(uint8)(addr>>8);
addr |= ICPU.ShiftedDB;
return addr;
static inline uint32 DirectIndirectSlow (AccessMode a) // (d)
{
uint32 addr = S9xGetWord(DirectSlow(READ), (!CheckEmulation() || Registers.DL) ? WRAP_BANK : WRAP_PAGE);
if (a & READ)
OpenBus = (uint8) (addr >> 8);
addr |= ICPU.ShiftedDB;
return (addr);
}
STATIC inline uint32 DirectIndirectE0 (AccessMode a) { // (d)
uint32 addr = S9xGetWord(Direct(READ));
if(a&READ) OpenBus = (uint8)(addr>>8);
addr |= ICPU.ShiftedDB;
return addr;
static inline uint32 DirectIndirectE0 (AccessMode a) // (d)
{
uint32 addr = S9xGetWord(Direct(READ));
if (a & READ)
OpenBus = (uint8) (addr >> 8);
addr |= ICPU.ShiftedDB;
return (addr);
}
STATIC inline uint32 DirectIndirectE1 (AccessMode a) { // (d)
uint32 addr = S9xGetWord(DirectSlow(READ),
Registers.DL?WRAP_BANK:WRAP_PAGE);
if(a&READ) OpenBus=(uint8)(addr>>8);
addr |= ICPU.ShiftedDB;
return addr;
static inline uint32 DirectIndirectE1 (AccessMode a) // (d)
{
uint32 addr = S9xGetWord(DirectSlow(READ), Registers.DL ? WRAP_BANK : WRAP_PAGE);
if (a & READ)
OpenBus = (uint8) (addr >> 8);
addr |= ICPU.ShiftedDB;
return (addr);
}
STATIC inline uint32 DirectIndirectIndexedSlow (AccessMode a) { // (d),Y
uint32 addr = DirectIndirectSlow(a);
if(a&WRITE || !CheckIndex() || (addr&0xff)+Registers.YL>=0x100) AddCycles(ONE_CYCLE);
return (addr + Registers.Y.W);
static inline uint32 DirectIndirectIndexedSlow (AccessMode a) // (d),Y
{
uint32 addr = DirectIndirectSlow(a);
if (a & WRITE || !CheckIndex() || (addr & 0xff) + Registers.YL >= 0x100)
AddCycles(ONE_CYCLE);
return (addr + Registers.Y.W);
}
STATIC inline uint32 DirectIndirectIndexedE0X0 (AccessMode a) { // (d),Y
uint32 addr = DirectIndirectE0(a);
AddCycles(ONE_CYCLE);
return (addr + Registers.Y.W);
static inline uint32 DirectIndirectIndexedE0X0 (AccessMode a) // (d),Y
{
uint32 addr = DirectIndirectE0(a);
AddCycles(ONE_CYCLE);
return (addr + Registers.Y.W);
}
STATIC inline uint32 DirectIndirectIndexedE0X1 (AccessMode a) { // (d),Y
uint32 addr = DirectIndirectE0(a);
if(a&WRITE || (addr&0xff)+Registers.YL>=0x100) AddCycles(ONE_CYCLE);
return (addr + Registers.Y.W);
static inline uint32 DirectIndirectIndexedE0X1 (AccessMode a) // (d),Y
{
uint32 addr = DirectIndirectE0(a);
if (a & WRITE || (addr & 0xff) + Registers.YL >= 0x100)
AddCycles(ONE_CYCLE);
return (addr + Registers.Y.W);
}
STATIC inline uint32 DirectIndirectIndexedE1 (AccessMode a) { // (d),Y
uint32 addr = DirectIndirectE1(a);
if(a&WRITE || (addr&0xff)+Registers.YL>=0x100) AddCycles(ONE_CYCLE);
return (addr + Registers.Y.W);
static inline uint32 DirectIndirectIndexedE1 (AccessMode a) // (d),Y
{
uint32 addr = DirectIndirectE1(a);
if (a & WRITE || (addr & 0xff) + Registers.YL >= 0x100)
AddCycles(ONE_CYCLE);
return (addr + Registers.Y.W);
}
STATIC inline uint32 DirectIndirectLongSlow (AccessMode a) { // [d]
uint16 addr = DirectSlow(READ);
uint32 addr2 = S9xGetWord(addr);
OpenBus=addr2>>8;
addr2 |= (OpenBus = S9xGetByte(addr+2))<<16;
return addr2;
static inline uint32 DirectIndirectLongSlow (AccessMode a) // [d]
{
uint16 addr = DirectSlow(READ);
uint32 addr2 = S9xGetWord(addr);
OpenBus = addr2 >> 8;
addr2 |= (OpenBus = S9xGetByte(addr + 2)) << 16;
return (addr2);
}
STATIC inline uint32 DirectIndirectLong (AccessMode a) { // [d]
uint16 addr = Direct(READ);
uint32 addr2 = S9xGetWord(addr);
OpenBus=addr2>>8;
addr2 |= (OpenBus = S9xGetByte(addr+2))<<16;
return addr2;
static inline uint32 DirectIndirectLong (AccessMode a) // [d]
{
uint16 addr = Direct(READ);
uint32 addr2 = S9xGetWord(addr);
OpenBus = addr2 >> 8;
addr2 |= (OpenBus = S9xGetByte(addr + 2)) << 16;
return (addr2);
}
STATIC inline uint32 DirectIndirectIndexedLongSlow (AccessMode a) { // [d],Y
return DirectIndirectLongSlow(a) + Registers.Y.W;
static inline uint32 DirectIndirectIndexedLongSlow (AccessMode a) // [d],Y
{
return (DirectIndirectLongSlow(a) + Registers.Y.W);
}
STATIC inline uint32 DirectIndirectIndexedLong (AccessMode a) { // [d],Y
return DirectIndirectLong(a) + Registers.Y.W;
static inline uint32 DirectIndirectIndexedLong (AccessMode a) // [d],Y
{
return (DirectIndirectLong(a) + Registers.Y.W);
}
STATIC inline uint32 DirectIndexedXSlow (AccessMode a) { // d,X
pair addr;
addr.W = DirectSlow(a);
if(!CheckEmulation() || Registers.DL){
addr.W+=Registers.X.W;
} else {
addr.B.l+=Registers.XL;
}
AddCycles(ONE_CYCLE);
return addr.W;
static inline uint32 DirectIndexedXSlow (AccessMode a) // d,X
{
pair addr;
addr.W = DirectSlow(a);
if (!CheckEmulation() || Registers.DL)
addr.W += Registers.X.W;
else
addr.B.l += Registers.XL;
AddCycles(ONE_CYCLE);
return (addr.W);
}
STATIC inline uint32 DirectIndexedXE0 (AccessMode a) { // d,X
uint16 addr = Direct(a) + Registers.X.W;
AddCycles(ONE_CYCLE);
return addr;
static inline uint32 DirectIndexedXE0 (AccessMode a) // d,X
{
uint16 addr = Direct(a) + Registers.X.W;
AddCycles(ONE_CYCLE);
return (addr);
}
STATIC inline uint32 DirectIndexedXE1 (AccessMode a) { // d,X
if(Registers.DL){
return DirectIndexedXE0(a);
} else {
pair addr;
addr.W = Direct(a);
addr.B.l+=Registers.XL;
AddCycles(ONE_CYCLE);
return addr.W;
}
static inline uint32 DirectIndexedXE1 (AccessMode a) // d,X
{
if (Registers.DL)
return (DirectIndexedXE0(a));
else
{
pair addr;
addr.W = Direct(a);
addr.B.l += Registers.XL;
AddCycles(ONE_CYCLE);
return (addr.W);
}
}
STATIC inline uint32 DirectIndexedYSlow (AccessMode a) { // d,Y
pair addr;
addr.W = DirectSlow(a);
if(!CheckEmulation() || Registers.DL){
addr.W+=Registers.Y.W;
} else {
addr.B.l+=Registers.YL;
}
AddCycles(ONE_CYCLE);
return addr.W;
static inline uint32 DirectIndexedYSlow (AccessMode a) // d,Y
{
pair addr;
addr.W = DirectSlow(a);
if (!CheckEmulation() || Registers.DL)
addr.W += Registers.Y.W;
else
addr.B.l += Registers.YL;
AddCycles(ONE_CYCLE);
return (addr.W);
}
STATIC inline uint32 DirectIndexedYE0 (AccessMode a) { // d,Y
uint16 addr = Direct(a) + Registers.Y.W;
AddCycles(ONE_CYCLE);
return addr;
static inline uint32 DirectIndexedYE0 (AccessMode a) // d,Y
{
uint16 addr = Direct(a) + Registers.Y.W;
AddCycles(ONE_CYCLE);
return (addr);
}
STATIC inline uint32 DirectIndexedYE1 (AccessMode a) { // d,Y
if(Registers.DL){
return DirectIndexedYE0(a);
} else {
pair addr;
addr.W = Direct(a);
addr.B.l+=Registers.YL;
AddCycles(ONE_CYCLE);
return addr.W;
}
static inline uint32 DirectIndexedYE1 (AccessMode a) // d,Y
{
if (Registers.DL)
return (DirectIndexedYE0(a));
else
{
pair addr;
addr.W = Direct(a);
addr.B.l += Registers.YL;
AddCycles(ONE_CYCLE);
return (addr.W);
}
}
STATIC inline uint32 DirectIndexedIndirectSlow (AccessMode a) { // (d,X)
uint32 addr = S9xGetWord(DirectIndexedXSlow(READ),
(!CheckEmulation() || Registers.DL)?WRAP_BANK:WRAP_PAGE);
if(a&READ) OpenBus=(uint8)(addr>>8);
return ICPU.ShiftedDB|addr;
static inline uint32 DirectIndexedIndirectSlow (AccessMode a) // (d,X)
{
uint32 addr = S9xGetWord(DirectIndexedXSlow(READ), (!CheckEmulation() || Registers.DL) ? WRAP_BANK : WRAP_PAGE);
if (a & READ)
OpenBus = (uint8) (addr >> 8);
return (ICPU.ShiftedDB | addr);
}
STATIC inline uint32 DirectIndexedIndirectE0 (AccessMode a) { // (d,X)
uint32 addr = S9xGetWord(DirectIndexedXE0(READ));
if(a&READ) OpenBus = (uint8)(addr>>8);
return ICPU.ShiftedDB|addr;
static inline uint32 DirectIndexedIndirectE0 (AccessMode a) // (d,X)
{
uint32 addr = S9xGetWord(DirectIndexedXE0(READ));
if (a & READ)
OpenBus = (uint8) (addr >> 8);
return (ICPU.ShiftedDB | addr);
}
STATIC inline uint32 DirectIndexedIndirectE1 (AccessMode a) { // (d,X)
uint32 addr = S9xGetWord(DirectIndexedXE1(READ),
Registers.DL?WRAP_BANK:WRAP_PAGE);
if(a&READ) OpenBus=(uint8)(addr>>8);
return ICPU.ShiftedDB|addr;
static inline uint32 DirectIndexedIndirectE1 (AccessMode a) // (d,X)
{
uint32 addr = S9xGetWord(DirectIndexedXE1(READ), Registers.DL ? WRAP_BANK : WRAP_PAGE);
if (a & READ)
OpenBus = (uint8) (addr >> 8);
return (ICPU.ShiftedDB | addr);
}
STATIC inline uint32 AbsoluteIndexedXSlow (AccessMode a) { // a,X
uint32 addr = AbsoluteSlow(a);
if(a&WRITE || !CheckIndex() || (addr&0xff)+Registers.XL>=0x100) AddCycles(ONE_CYCLE);
return (addr + Registers.X.W);
static inline uint32 AbsoluteIndexedXSlow (AccessMode a) // a,X
{
uint32 addr = AbsoluteSlow(a);
if (a & WRITE || !CheckIndex() || (addr & 0xff) + Registers.XL >= 0x100)
AddCycles(ONE_CYCLE);
return (addr + Registers.X.W);
}
STATIC inline uint32 AbsoluteIndexedXX0 (AccessMode a) { // a,X
uint32 addr = Absolute(a);
AddCycles(ONE_CYCLE);
return (addr + Registers.X.W);
static inline uint32 AbsoluteIndexedXX0 (AccessMode a) // a,X
{
uint32 addr = Absolute(a);
AddCycles(ONE_CYCLE);
return (addr + Registers.X.W);
}
STATIC inline uint32 AbsoluteIndexedXX1 (AccessMode a) { // a,X
uint32 addr = Absolute(a);
if(a&WRITE || (addr&0xff)+Registers.XL>=0x100) AddCycles(ONE_CYCLE);
return (addr + Registers.X.W);
static inline uint32 AbsoluteIndexedXX1 (AccessMode a) // a,X
{
uint32 addr = Absolute(a);
if (a & WRITE || (addr & 0xff) + Registers.XL >= 0x100)
AddCycles(ONE_CYCLE);
return (addr + Registers.X.W);
}
STATIC inline uint32 AbsoluteIndexedYSlow (AccessMode a) { // a,Y
uint32 addr = AbsoluteSlow(a);
if(a&WRITE || !CheckIndex() || (addr&0xff)+Registers.YL>=0x100) AddCycles(ONE_CYCLE);
return (addr + Registers.Y.W);
static inline uint32 AbsoluteIndexedYSlow (AccessMode a) // a,Y
{
uint32 addr = AbsoluteSlow(a);
if (a & WRITE || !CheckIndex() || (addr & 0xff) + Registers.YL >= 0x100)
AddCycles(ONE_CYCLE);
return (addr + Registers.Y.W);
}
STATIC inline uint32 AbsoluteIndexedYX0 (AccessMode a) { // a,Y
uint32 addr = Absolute(a);
AddCycles(ONE_CYCLE);
return (addr + Registers.Y.W);
static inline uint32 AbsoluteIndexedYX0 (AccessMode a) // a,Y
{
uint32 addr = Absolute(a);
AddCycles(ONE_CYCLE);
return (addr + Registers.Y.W);
}
STATIC inline uint32 AbsoluteIndexedYX1 (AccessMode a) { // a,Y
uint32 addr = Absolute(a);
if(a&WRITE || (addr&0xff)+Registers.YL>=0x100) AddCycles(ONE_CYCLE);
return (addr + Registers.Y.W);
static inline uint32 AbsoluteIndexedYX1 (AccessMode a) // a,Y
{
uint32 addr = Absolute(a);
if (a & WRITE || (addr & 0xff) + Registers.YL >= 0x100)
AddCycles(ONE_CYCLE);
return (addr + Registers.Y.W);
}
STATIC inline uint32 AbsoluteLongIndexedXSlow (AccessMode a) { // l,X
return (AbsoluteLongSlow(a) + Registers.X.W);
static inline uint32 AbsoluteLongIndexedXSlow (AccessMode a) // l,X
{
return (AbsoluteLongSlow(a) + Registers.X.W);
}
STATIC inline uint32 AbsoluteLongIndexedX (AccessMode a) { // l,X
return (AbsoluteLong(a) + Registers.X.W);
static inline uint32 AbsoluteLongIndexedX (AccessMode a) // l,X
{
return (AbsoluteLong(a) + Registers.X.W);
}
STATIC inline uint32 StackRelativeSlow (AccessMode a) { // d,S
uint16 addr = Immediate8Slow(a) + Registers.S.W;
AddCycles(ONE_CYCLE);
return addr;
static inline uint32 StackRelativeSlow (AccessMode a) // d,S
{
uint16 addr = Immediate8Slow(a) + Registers.S.W;
AddCycles(ONE_CYCLE);
return (addr);
}
STATIC inline uint32 StackRelative (AccessMode a) { // d,S
uint16 addr = Immediate8(a) + Registers.S.W;
AddCycles(ONE_CYCLE);
return addr;
static inline uint32 StackRelative (AccessMode a) // d,S
{
uint16 addr = Immediate8(a) + Registers.S.W;
AddCycles(ONE_CYCLE);
return (addr);
}
STATIC inline uint32 StackRelativeIndirectIndexedSlow (AccessMode a) { // (d,S),Y
uint32 addr=S9xGetWord(StackRelativeSlow(READ));
if(a&READ) OpenBus = (uint8)(addr>>8);
addr = (addr+Registers.Y.W+ICPU.ShiftedDB)&0xffffff;
AddCycles(ONE_CYCLE);
return addr;
static inline uint32 StackRelativeIndirectIndexedSlow (AccessMode a) // (d,S),Y
{
uint32 addr = S9xGetWord(StackRelativeSlow(READ));
if (a & READ)
OpenBus = (uint8) (addr >> 8);
addr = (addr + Registers.Y.W + ICPU.ShiftedDB) & 0xffffff;
AddCycles(ONE_CYCLE);
return (addr);
}
STATIC inline uint32 StackRelativeIndirectIndexed (AccessMode a) { // (d,S),Y
uint32 addr=S9xGetWord(StackRelative(READ));
if(a&READ) OpenBus = (uint8)(addr>>8);
addr = (addr+Registers.Y.W+ICPU.ShiftedDB)&0xffffff;
AddCycles(ONE_CYCLE);
return addr;
static inline uint32 StackRelativeIndirectIndexed (AccessMode a) // (d,S),Y
{
uint32 addr = S9xGetWord(StackRelative(READ));
if (a & READ)
OpenBus = (uint8) (addr >> 8);
addr = (addr + Registers.Y.W + ICPU.ShiftedDB) & 0xffffff;
AddCycles(ONE_CYCLE);
return (addr);
}
#endif

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,41 +172,24 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#include "snes9x.h"
#include "memmap.h"
#include "cpuops.h"
#include "ppu.h"
#include "cpuexec.h"
#include "s9xdebug.h"
#include "snapshot.h"
#include "gfx.h"
#include "missing.h"
#include "apu.h"
#include "dma.h"
#include "sa1.h"
#include "spc7110.h"
#ifndef ZSNES_FX
#include "apu/apu.h"
#include "fxemu.h"
extern struct FxInit_s SuperFX;
#include "snapshot.h"
#ifdef DEBUGGER
#include "debug.h"
#include "missing.h"
#endif
void S9xMainLoop (void)
{
if(ICPU.SavedAtOp)
{
ICPU.SavedAtOp = FALSE;
Registers.PCw = CPU.PBPCAtOpcodeStart;
if(CPU.PCBase)
CPU.Cycles -= CPU.MemSpeed;
goto doOp;
}
for (;;)
{
if (CPU.Flags)
@ -211,7 +210,7 @@ void S9xMainLoop (void)
}
}
#ifdef DEBUGGER
#ifdef DEBUGGER
if ((CPU.Flags & BREAK_FLAG) && !(CPU.Flags & SINGLE_STEP_FLAG))
{
for (int Break = 0; Break != 6; Break++)
@ -227,15 +226,13 @@ void S9xMainLoop (void)
}
}
}
#endif
CHECK_SOUND();
#endif
if (CPU.Flags & IRQ_FLAG)
{
if (CPU.IRQPending)
// FIXME: In case of IRQ during WRAM refresh
CPU.IRQPending = 0;
CPU.IRQPending--;
else
{
if (CPU.WaitingForInterrupt)
@ -258,7 +255,7 @@ void S9xMainLoop (void)
if (CPU.Flags & SCAN_KEYS_FLAG)
break;
#ifdef DEBUGGER
#ifdef DEBUGGER
if (CPU.Flags & DEBUG_MODE_FLAG)
break;
@ -270,13 +267,13 @@ void S9xMainLoop (void)
CPU.Flags &= ~SINGLE_STEP_FLAG;
CPU.Flags |= DEBUG_MODE_FLAG;
}
#endif
#endif
}
#ifdef CPU_SHUTDOWN
#ifdef CPU_SHUTDOWN
CPU.PBPCAtOpcodeStart = Registers.PBPC;
#endif
doOp:
#endif
register uint8 Op;
register struct SOpcodes *Opcodes;
@ -295,50 +292,41 @@ void S9xMainLoop (void)
Opcodes = S9xOpcodesSlow;
}
if ((Registers.PCw&MEMMAP_MASK) + ICPU.S9xOpLengths[Op] >= MEMMAP_BLOCK_SIZE)
if ((Registers.PCw & MEMMAP_MASK) + ICPU.S9xOpLengths[Op] >= MEMMAP_BLOCK_SIZE)
{
uint8 *oldPCBase = CPU.PCBase;
CPU.PCBase = GetBasePointer(ICPU.ShiftedPB + ((uint16) (Registers.PCw + 4)));
if (oldPCBase!=CPU.PCBase || (Registers.PCw&~MEMMAP_MASK) == (0xffff & ~MEMMAP_MASK))
CPU.PCBase = S9xGetBasePointer(ICPU.ShiftedPB + ((uint16) (Registers.PCw + 4)));
if (oldPCBase != CPU.PCBase || (Registers.PCw & ~MEMMAP_MASK) == (0xffff & ~MEMMAP_MASK))
Opcodes = S9xOpcodesSlow;
}
Registers.PCw++;
(*Opcodes[Op].S9xOpcode)();
if(ICPU.SavedAtOp)
{
ICPU.SavedAtOp = false;
continue;
}
S9xAPUExecute();
if (SA1.Executing)
S9xSA1MainLoop();
while (CPU.Cycles >= CPU.NextEvent)
S9xDoHEventProcessing();
}
}
S9xPackStatus();
APURegisters.PC = IAPU.PC - IAPU.RAM;
S9xAPUPackStatus();
S9xPackStatus();
if (CPU.Flags & SCAN_KEYS_FLAG)
{
#ifdef DEBUGGER
if (CPU.Flags & SCAN_KEYS_FLAG)
{
#ifdef DEBUGGER
if (!(CPU.Flags & FRAME_ADVANCE_FLAG))
#endif
#endif
S9xSyncSpeed();
CPU.Flags &= ~SCAN_KEYS_FLAG;
}
}
}
void S9xSetIRQ (uint32 source)
{
CPU.IRQActive |= source;
CPU.IRQPending = Timings.IRQPendCount;
CPU.Flags |= IRQ_FLAG;
if (CPU.WaitingForInterrupt)
@ -348,22 +336,35 @@ void S9xSetIRQ (uint32 source)
CPU.WaitingForInterrupt = FALSE;
Registers.PCw++;
}
#ifdef DEBUGGER
S9xTraceMessage("--- /IRQ low");
#endif
}
void S9xClearIRQ (uint32 source)
{
CLEAR_IRQ_SOURCE(source);
CPU.IRQActive &= ~source;
if (!CPU.IRQActive)
CPU.Flags &= ~IRQ_FLAG;
#ifdef DEBUGGER
S9xTraceMessage("--- /IRQ high");
#endif
}
void S9xDoHEventProcessing (void)
{
#ifdef DEBUGGER
char mes[256];
if (Settings.TraceHCEvent)
S9xTraceFormattedMessage("--- HC event processing (%02d) expected HC:%04d executed HC:%04d",
CPU.WhichEvent, CPU.NextEvent, CPU.Cycles);
#endif
#ifdef CPU_SHUTDOWN
CPU.WaitCounter++;
#endif
switch (CPU.WhichEvent)
{
case HC_HBLANK_START_EVENT:
@ -375,8 +376,7 @@ void S9xDoHEventProcessing (void)
if (PPU.HDMA && CPU.V_Counter <= PPU.ScreenHeight)
{
#ifdef DEBUGGER
sprintf(mes, "*** HDMA HC:%04d, Channel:%02x", CPU.Cycles, PPU.HDMA);
S9xTraceMessage(mes);
S9xTraceFormattedMessage("*** HDMA HC:%04d, Channel:%02x", CPU.Cycles, PPU.HDMA);
#endif
PPU.HDMA = S9xDoHDMA(PPU.HDMA);
}
@ -397,20 +397,13 @@ void S9xDoHEventProcessing (void)
S9xSuperFXExec();
#endif
#ifndef STORM
if (Settings.SoundSync)
S9xGenerateSound();
#endif
S9xAPUEndScanline();
CPU.Cycles -= Timings.H_Max;
APU.NextAPUTimerPos -= (Timings.H_Max << SNES_APU_ACCURACY);
APU.Cycles -= (Timings.H_Max << SNES_APU_ACCURACY);
S9xAPUSetReferenceTime(CPU.Cycles);
if ((Timings.NMITriggerPos != 0xffff) && (Timings.NMITriggerPos >= Timings.H_Max))
Timings.NMITriggerPos -= Timings.H_Max;
ICPU.Scanline++;
CPU.V_Counter++;
if (CPU.V_Counter >= Timings.V_Max) // V ranges from 0 to Timings.V_Max - 1
{
@ -487,7 +480,7 @@ void S9xDoHEventProcessing (void)
if (PPU.OAMPriorityRotation)
tmp = (PPU.OAMAddr & 0xFE) >> 1;
if ((PPU.OAMFlip & 1) || PPU.FirstSprite!=tmp)
if ((PPU.OAMFlip & 1) || PPU.FirstSprite != tmp)
{
PPU.FirstSprite = tmp;
IPPU.OBJChanged = TRUE;
@ -531,7 +524,7 @@ void S9xDoHEventProcessing (void)
case HC_RENDER_EVENT:
if (CPU.V_Counter >= FIRST_VISIBLE_LINE && CPU.V_Counter <= PPU.ScreenHeight)
RenderLine((uint8)(CPU.V_Counter - FIRST_VISIBLE_LINE));
RenderLine((uint8) (CPU.V_Counter - FIRST_VISIBLE_LINE));
S9xCheckMissingHTimerPosition(Timings.RenderPos);
@ -539,12 +532,10 @@ void S9xDoHEventProcessing (void)
case HC_WRAM_REFRESH_EVENT:
#ifdef DEBUGGER
sprintf(mes, "*** WRAM Refresh HC:%04d", CPU.Cycles);
S9xTraceMessage(mes);
S9xTraceFormattedMessage("*** WRAM Refresh HC:%04d", CPU.Cycles);
#endif
S9xCheckMissingHTimerHalt(Timings.WRAMRefreshPos, SNES_WRAM_REFRESH_CYCLES);
CPU.Cycles += SNES_WRAM_REFRESH_CYCLES;
S9xAPUExecute();
S9xCheckMissingHTimerPosition(Timings.WRAMRefreshPos);
@ -557,13 +548,18 @@ void S9xDoHEventProcessing (void)
case HC_IRQ_9_A_EVENT:
case HC_IRQ_A_1_EVENT:
if (PPU.HTimerEnabled && (!PPU.VTimerEnabled || (CPU.V_Counter == PPU.VTimerPosition)))
S9xSetIRQ(PPU_H_BEAM_IRQ_SOURCE);
S9xSetIRQ(PPU_IRQ_SOURCE);
else
if (PPU.VTimerEnabled && (CPU.V_Counter == PPU.VTimerPosition))
S9xSetIRQ(PPU_V_BEAM_IRQ_SOURCE);
S9xSetIRQ(PPU_IRQ_SOURCE);
break;
}
S9xReschedule();
#ifdef DEBUGGER
if (Settings.TraceHCEvent)
S9xTraceFormattedMessage("--- HC event rescheduled (%02d) expected HC:%04d", CPU.WhichEvent, CPU.NextEvent);
#endif
}

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,129 +172,105 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#ifndef _CPUEXEC_H_
#define _CPUEXEC_H_
#include "snes9x.h"
#include "ppu.h"
struct SOpcodes {
#ifdef __WIN32__
void (__cdecl *S9xOpcode)( void);
#else
void (*S9xOpcode)( void);
#endif
struct SOpcodes
{
void (*S9xOpcode) (void);
};
struct SICPU
{
uint8 *Speed; // unused
struct SOpcodes *S9xOpcodes;
uint8 *S9xOpLengths;
uint8 _Carry;
uint8 _Zero;
uint8 _Negative;
uint8 _Overflow;
bool8 CPUExecuting;
uint32 ShiftedPB;
uint32 ShiftedDB;
uint32 Frame;
uint32 Scanline;
uint32 FrameAdvanceCount;
bool8 SavedAtOp;
struct SOpcodes *S9xOpcodes;
uint8 *S9xOpLengths;
uint8 _Carry;
uint8 _Zero;
uint8 _Negative;
uint8 _Overflow;
bool8 CPUExecuting;
uint32 ShiftedPB;
uint32 ShiftedDB;
uint32 Frame;
uint32 FrameAdvanceCount;
};
START_EXTERN_C
extern struct SICPU ICPU;
END_EXTERN_C
extern struct SICPU ICPU;
#include "ppu.h"
#include "memmap.h"
#include "65c816.h"
extern struct SOpcodes S9xOpcodesE1[256];
extern struct SOpcodes S9xOpcodesM1X1[256];
extern struct SOpcodes S9xOpcodesM1X0[256];
extern struct SOpcodes S9xOpcodesM0X1[256];
extern struct SOpcodes S9xOpcodesM0X0[256];
extern struct SOpcodes S9xOpcodesSlow[256];
extern uint8 S9xOpLengthsM1X1[256];
extern uint8 S9xOpLengthsM1X0[256];
extern uint8 S9xOpLengthsM0X1[256];
extern uint8 S9xOpLengthsM0X0[256];
START_EXTERN_C
void S9xMainLoop (void);
void S9xReset (void);
void S9xSoftReset (void);
void S9xDoHEventProcessing ();
void S9xDoHEventProcessing (void);
void S9xClearIRQ (uint32);
void S9xSetIRQ (uint32);
extern struct SOpcodes S9xOpcodesE1 [256];
extern struct SOpcodes S9xOpcodesM1X1 [256];
extern struct SOpcodes S9xOpcodesM1X0 [256];
extern struct SOpcodes S9xOpcodesM0X1 [256];
extern struct SOpcodes S9xOpcodesM0X0 [256];
extern struct SOpcodes S9xOpcodesSlow [256];
extern uint8 S9xOpLengthsM1X1 [256];
extern uint8 S9xOpLengthsM1X0 [256];
extern uint8 S9xOpLengthsM0X1 [256];
extern uint8 S9xOpLengthsM0X0 [256];
END_EXTERN_C
STATIC inline void S9xUnpackStatus()
static inline void S9xUnpackStatus (void)
{
ICPU._Zero = (Registers.PL & Zero) == 0;
ICPU._Negative = (Registers.PL & Negative);
ICPU._Carry = (Registers.PL & Carry);
ICPU._Overflow = (Registers.PL & Overflow) >> 6;
ICPU._Zero = (Registers.PL & Zero) == 0;
ICPU._Negative = (Registers.PL & Negative);
ICPU._Carry = (Registers.PL & Carry);
ICPU._Overflow = (Registers.PL & Overflow) >> 6;
}
STATIC inline void S9xPackStatus()
static inline void S9xPackStatus (void)
{
Registers.PL &= ~(Zero | Negative | Carry | Overflow);
Registers.PL |= ICPU._Carry | ((ICPU._Zero == 0) << 1) |
(ICPU._Negative & 0x80) | (ICPU._Overflow << 6);
Registers.PL &= ~(Zero | Negative | Carry | Overflow);
Registers.PL |= ICPU._Carry | ((ICPU._Zero == 0) << 1) | (ICPU._Negative & 0x80) | (ICPU._Overflow << 6);
}
STATIC inline void CLEAR_IRQ_SOURCE (uint32 M)
static inline void S9xFixCycles (void)
{
CPU.IRQActive &= ~M;
if (!CPU.IRQActive)
CPU.Flags &= ~IRQ_FLAG;
}
STATIC inline void S9xFixCycles ()
{
if (CheckEmulation ())
{
ICPU.S9xOpcodes = S9xOpcodesE1;
ICPU.S9xOpLengths = S9xOpLengthsM1X1;
}
else
if (CheckMemory ())
{
if (CheckIndex ())
if (CheckEmulation())
{
ICPU.S9xOpcodes = S9xOpcodesM1X1;
ICPU.S9xOpLengths = S9xOpLengthsM1X1;
ICPU.S9xOpcodes = S9xOpcodesE1;
ICPU.S9xOpLengths = S9xOpLengthsM1X1;
}
else
if (CheckMemory())
{
if (CheckIndex())
{
ICPU.S9xOpcodes = S9xOpcodesM1X1;
ICPU.S9xOpLengths = S9xOpLengthsM1X1;
}
else
{
ICPU.S9xOpcodes = S9xOpcodesM1X0;
ICPU.S9xOpLengths = S9xOpLengthsM1X0;
}
}
else
{
ICPU.S9xOpcodes = S9xOpcodesM1X0;
ICPU.S9xOpLengths = S9xOpLengthsM1X0;
if (CheckIndex())
{
ICPU.S9xOpcodes = S9xOpcodesM0X1;
ICPU.S9xOpLengths = S9xOpLengthsM0X1;
}
else
{
ICPU.S9xOpcodes = S9xOpcodesM0X0;
ICPU.S9xOpLengths = S9xOpLengthsM0X0;
}
}
}
else
{
if (CheckIndex ())
{
ICPU.S9xOpcodes = S9xOpcodesM0X1;
ICPU.S9xOpLengths = S9xOpLengthsM0X1;
}
else
{
ICPU.S9xOpcodes = S9xOpcodesM0X0;
ICPU.S9xOpLengths = S9xOpLengthsM0X0;
}
}
}
STATIC inline void S9xReschedule (void)
static inline void S9xReschedule (void)
{
uint8 next = 0;
int32 hpos = 0;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,19 +172,17 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#ifndef _CPUOPS_H_
#define _CPUOPS_H_
void S9xOpcode_NMI ();
void S9xOpcode_IRQ ();
void S9xOpcode_NMI (void);
void S9xOpcode_IRQ (void);
#define CHECK_FOR_IRQ() \
if (CPU.IRQActive && !CheckFlag (IRQ) && !Settings.DisableIRQ) \
S9xOpcode_IRQ()
if (CPU.IRQActive && !CheckFlag(IRQ) && !Settings.DisableIRQ) \
S9xOpcode_IRQ()
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,65 +172,62 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#ifndef _CROSSHAIRS_H_
#define _CROSSHAIRS_H_
#ifndef CROSSHAIRS_H
#define CROSSHAIRS_H
// Read in the specified crosshair file, replacing whatever data might be in that slot.
// Available slots are 1-31.
// The input file must be a PNG or a text file.
// PNG: 15x15 pixels, palettized, with 3 colors (white, black, and transparent).
// text: 15 lines of 16 characters (counting the \n), consisting of ' ', '#', or '.'.
/*
* Read in the specified crosshair file, replacing whatever data might be in
* that slot. Available slots are 1-31. The input file must be a PNG file,
* 15x15 pixels, palettized, with 3 colors: white, black, and transparent. Or a
* text file, 15 lines of 16 characters (counting the \n), consisting of ' ',
* '#', or '.'.
*/
bool S9xLoadCrosshairFile(int idx, const char *filename);
bool S9xLoadCrosshairFile (int idx, const char *filename);
/*
* Return the specified crosshair. Woo-hoo. char * to a 225-byte string, with
* '#' marking foreground, '.' marking background, and anything else
* transparent.
*/
const char *S9xGetCrosshair(int idx);
// Return the specified crosshair. Woo-hoo.
// char * to a 225-byte string, with '#' marking foreground, '.' marking background,
// and anything else transparent.
/*
* In controls.cpp. Sets the crosshair for the specified device. Defaults are:
* cross fgcolor bgcolor
* Mouse 1: 1 White Black
* Mouse 2: 1 Purple White
* Superscope: 2 White Black
* Justifier 1: 4 Blue Black
* Justifier 2: 4 MagicPink Black
*
* Available colors are: Trans, Black, 25Grey, 50Grey, 75Grey, White, Red,
* Orange, Yellow, Green, Cyan, Sky, Blue, Violet, MagicPink, and Purple. You
* may also prefix a 't' (e.g. tBlue) for a 50%-transparent version.
*
* Use idx=-1 or fg/bg=NULL to keep the current setting.
*/
enum crosscontrols {
X_MOUSE1,
X_MOUSE2,
X_SUPERSCOPE,
X_JUSTIFIER1,
X_JUSTIFIER2
const char * S9xGetCrosshair (int idx);
// In controls.cpp. Sets the crosshair for the specified device. Defaults are:
// cross fgcolor bgcolor
// Mouse 1: 1 White Black
// Mouse 2: 1 Purple White
// Superscope: 2 White Black
// Justifier 1: 4 Blue Black
// Justifier 2: 4 MagicPink Black
//
// Available colors are: Trans, Black, 25Grey, 50Grey, 75Grey, White, Red, Orange,
// Yellow, Green, Cyan, Sky, Blue, Violet, MagicPink, and Purple.
// You may also prefix a 't' (e.g. tBlue) for a 50%-transparent version.
// Use idx = -1 or fg/bg = NULL to keep the current setting.
enum crosscontrols
{
X_MOUSE1,
X_MOUSE2,
X_SUPERSCOPE,
X_JUSTIFIER1,
X_JUSTIFIER2
};
void S9xSetControllerCrosshair(enum crosscontrols ctl, int8 idx, const char *fg, const char *bg);
void S9xGetControllerCrosshair(enum crosscontrols ctl, int8 *idx, const char **fg, const char **bg);
/*
* In gfx.cpp, much like DisplayChar() except it takes the parameters listed
* and looks up GFX.Screen. The 'crosshair' arg is a 15x15 image, with '#'
* meaning fgcolor, '.' meaning bgcolor, and anything else meaning transparent.
* Color values should be (RGB):
* 0 = transparent 4=23 23 23 8=31 31 0 12= 0 0 31
* 1 = 0 0 0 5=31 31 31 9= 0 31 0 13=23 0 31
* 2 = 8 8 8 6=31 00 00 10= 0 31 31 14=31 0 31
* 3 = 16 16 16 7=31 16 00 11= 0 23 31 15=31 0 16
* 16-31 are 50% transparent versions of 0-15.
*/
void S9xDrawCrosshair(const char *crosshair, uint8 fgcolor, uint8 bgcolor, int16 x, int16 y);
void S9xSetControllerCrosshair (enum crosscontrols ctl, int8 idx, const char *fg, const char *bg);
void S9xGetControllerCrosshair (enum crosscontrols ctl, int8 *idx, const char **fg, const char **bg);
// In gfx.cpp, much like S9xDisplayChar() except it takes the parameters
// listed and looks up GFX.Screen.
// The 'crosshair' arg is a 15x15 image, with '#' meaning fgcolor,
// '.' meaning bgcolor, and anything else meaning transparent.
// Color values should be (RGB):
// 0 = transparent 4 = 23 23 23 8 = 31 31 0 12 = 0 0 31
// 1 = 0 0 0 5 = 31 31 31 9 = 0 31 0 13 = 23 0 31
// 2 = 8 8 8 6 = 31 0 0 10 = 0 31 31 14 = 31 0 31
// 3 = 16 16 16 7 = 31 16 0 11 = 0 23 31 15 = 31 0 16
// 16-31 are 50% transparent versions of 0-15.
void S9xDrawCrosshair (const char *crosshair, uint8 fgcolor, uint8 bgcolor, int16 x, int16 y);
#endif

View File

@ -1,613 +0,0 @@
/**********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
Jerremy Koot (jkoot@snes9x.com)
(c) Copyright 2002 - 2004 Matthew Kendora
(c) Copyright 2002 - 2005 Peter Bortas (peter@bortas.org)
(c) Copyright 2004 - 2005 Joel Yliluoma (http://iki.fi/bisqwit/)
(c) Copyright 2001 - 2006 John Weidman (jweidman@slip.net)
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
zones
C4 x86 assembler and some C emulation code
(c) Copyright 2000 - 2003 _Demo_ (_demo_@zsnes.com),
Nach,
zsKnight (zsknight@zsnes.com)
C4 C++ code
(c) Copyright 2003 - 2006 Brad Jorsch,
Nach
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
Kris Bleakley,
Matthew Kendora,
Nach,
neviksti (neviksti@hotmail.com)
DSP-2 emulator code
(c) Copyright 2003 John Weidman,
Kris Bleakley,
Lord Nightmare (lord_nightmare@users.sourceforge.net),
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
Lancer,
z80 gaiden
DSP-4 emulator code
(c) Copyright 2004 - 2006 Dreamer Nom,
John Weidman,
Kris Bleakley,
Nach,
z80 gaiden
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
John Weidman
ST010 C++ emulator code
(c) Copyright 2003 Feather,
John Weidman,
Kris Bleakley,
Matthew Kendora
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
2xSaI filter
(c) Copyright 1999 - 2001 Derek Liauw Kie Fa
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
fee, providing that this license information and copyright notice appear
with all copies and any derived work.
This software is provided 'as-is', without any express or implied
warranty. In no event shall the authors be held liable for any damages
arising from the use of this software or it's derivatives.
Snes9x is freeware for PERSONAL USE only. Commercial users should
seek permission of the copyright holders first. Commercial use includes,
but is not limited to, charging money for Snes9x or software derived from
Snes9x, including Snes9x or derivatives in commercial game bundles, and/or
using Snes9x as a promotion for your commercial product.
The copyright holders request that bug fixes and improvements to the code
should be forwarded to them so everyone can benefit from the modifications
in future versions.
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
#include "snes9x.h"
uint8 add32_32 [32][32] = {
{ 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,
0x0f,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,
0x1e,0x1f},
{ 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,
0x1f,0x1f},
{ 0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10,
0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
0x1f,0x1f},
{ 0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10,0x11,
0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,0x1f,
0x1f,0x1f},
{ 0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,
0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,0x1f,0x1f,
0x1f,0x1f},
{ 0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,0x13,
0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,0x1f,0x1f,0x1f,
0x1f,0x1f},
{ 0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,0x13,0x14,
0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,0x1f,0x1f,0x1f,0x1f,
0x1f,0x1f},
{ 0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,0x13,0x14,0x15,
0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,
0x1f,0x1f},
{ 0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,0x13,0x14,0x15,0x16,
0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,
0x1f,0x1f},
{ 0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,
0x1f,0x1f},
{ 0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,
0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,
0x1f,0x1f},
{ 0x0b,0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,
0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,
0x1f,0x1f},
{ 0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,
0x1b,0x1c,0x1d,0x1e,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,
0x1f,0x1f},
{ 0x0d,0x0e,0x0f,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,
0x1c,0x1d,0x1e,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,
0x1f,0x1f},
{ 0x0e,0x0f,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,
0x1d,0x1e,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,
0x1f,0x1f},
{ 0x0f,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,
0x1e,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,
0x1f,0x1f},
{ 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,
0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,
0x1f,0x1f},
{ 0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,
0x1f,0x1f},
{ 0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,0x1f,
0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,
0x1f,0x1f},
{ 0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,0x1f,0x1f,
0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,
0x1f,0x1f},
{ 0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,0x1f,0x1f,0x1f,
0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,
0x1f,0x1f},
{ 0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,0x1f,0x1f,0x1f,0x1f,
0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,
0x1f,0x1f},
{ 0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,
0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,
0x1f,0x1f},
{ 0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,
0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,
0x1f,0x1f},
{ 0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,
0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,
0x1f,0x1f},
{ 0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,
0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,
0x1f,0x1f},
{ 0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,
0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,
0x1f,0x1f},
{ 0x1b,0x1c,0x1d,0x1e,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,
0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,
0x1f,0x1f},
{ 0x1c,0x1d,0x1e,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,
0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,
0x1f,0x1f},
{ 0x1d,0x1e,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,
0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,
0x1f,0x1f},
{ 0x1e,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,
0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,
0x1f,0x1f},
{ 0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,
0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,
0x1f,0x1f}
};
uint8 add32_32_half [32][32] = {
{ 0x00,0x00,0x01,0x01,0x02,0x02,0x03,0x03,0x04,0x04,0x05,0x05,0x06,0x06,0x07,
0x07,0x08,0x08,0x09,0x09,0x0a,0x0a,0x0b,0x0b,0x0c,0x0c,0x0d,0x0d,0x0e,0x0e,
0x0f,0x0f},
{ 0x00,0x01,0x01,0x02,0x02,0x03,0x03,0x04,0x04,0x05,0x05,0x06,0x06,0x07,0x07,
0x08,0x08,0x09,0x09,0x0a,0x0a,0x0b,0x0b,0x0c,0x0c,0x0d,0x0d,0x0e,0x0e,0x0f,
0x0f,0x10},
{ 0x01,0x01,0x02,0x02,0x03,0x03,0x04,0x04,0x05,0x05,0x06,0x06,0x07,0x07,0x08,
0x08,0x09,0x09,0x0a,0x0a,0x0b,0x0b,0x0c,0x0c,0x0d,0x0d,0x0e,0x0e,0x0f,0x0f,
0x10,0x10},
{ 0x01,0x02,0x02,0x03,0x03,0x04,0x04,0x05,0x05,0x06,0x06,0x07,0x07,0x08,0x08,
0x09,0x09,0x0a,0x0a,0x0b,0x0b,0x0c,0x0c,0x0d,0x0d,0x0e,0x0e,0x0f,0x0f,0x10,
0x10,0x11},
{ 0x02,0x02,0x03,0x03,0x04,0x04,0x05,0x05,0x06,0x06,0x07,0x07,0x08,0x08,0x09,
0x09,0x0a,0x0a,0x0b,0x0b,0x0c,0x0c,0x0d,0x0d,0x0e,0x0e,0x0f,0x0f,0x10,0x10,
0x11,0x11},
{ 0x02,0x03,0x03,0x04,0x04,0x05,0x05,0x06,0x06,0x07,0x07,0x08,0x08,0x09,0x09,
0x0a,0x0a,0x0b,0x0b,0x0c,0x0c,0x0d,0x0d,0x0e,0x0e,0x0f,0x0f,0x10,0x10,0x11,
0x11,0x12},
{ 0x03,0x03,0x04,0x04,0x05,0x05,0x06,0x06,0x07,0x07,0x08,0x08,0x09,0x09,0x0a,
0x0a,0x0b,0x0b,0x0c,0x0c,0x0d,0x0d,0x0e,0x0e,0x0f,0x0f,0x10,0x10,0x11,0x11,
0x12,0x12},
{ 0x03,0x04,0x04,0x05,0x05,0x06,0x06,0x07,0x07,0x08,0x08,0x09,0x09,0x0a,0x0a,
0x0b,0x0b,0x0c,0x0c,0x0d,0x0d,0x0e,0x0e,0x0f,0x0f,0x10,0x10,0x11,0x11,0x12,
0x12,0x13},
{ 0x04,0x04,0x05,0x05,0x06,0x06,0x07,0x07,0x08,0x08,0x09,0x09,0x0a,0x0a,0x0b,
0x0b,0x0c,0x0c,0x0d,0x0d,0x0e,0x0e,0x0f,0x0f,0x10,0x10,0x11,0x11,0x12,0x12,
0x13,0x13},
{ 0x04,0x05,0x05,0x06,0x06,0x07,0x07,0x08,0x08,0x09,0x09,0x0a,0x0a,0x0b,0x0b,
0x0c,0x0c,0x0d,0x0d,0x0e,0x0e,0x0f,0x0f,0x10,0x10,0x11,0x11,0x12,0x12,0x13,
0x13,0x14},
{ 0x05,0x05,0x06,0x06,0x07,0x07,0x08,0x08,0x09,0x09,0x0a,0x0a,0x0b,0x0b,0x0c,
0x0c,0x0d,0x0d,0x0e,0x0e,0x0f,0x0f,0x10,0x10,0x11,0x11,0x12,0x12,0x13,0x13,
0x14,0x14},
{ 0x05,0x06,0x06,0x07,0x07,0x08,0x08,0x09,0x09,0x0a,0x0a,0x0b,0x0b,0x0c,0x0c,
0x0d,0x0d,0x0e,0x0e,0x0f,0x0f,0x10,0x10,0x11,0x11,0x12,0x12,0x13,0x13,0x14,
0x14,0x15},
{ 0x06,0x06,0x07,0x07,0x08,0x08,0x09,0x09,0x0a,0x0a,0x0b,0x0b,0x0c,0x0c,0x0d,
0x0d,0x0e,0x0e,0x0f,0x0f,0x10,0x10,0x11,0x11,0x12,0x12,0x13,0x13,0x14,0x14,
0x15,0x15},
{ 0x06,0x07,0x07,0x08,0x08,0x09,0x09,0x0a,0x0a,0x0b,0x0b,0x0c,0x0c,0x0d,0x0d,
0x0e,0x0e,0x0f,0x0f,0x10,0x10,0x11,0x11,0x12,0x12,0x13,0x13,0x14,0x14,0x15,
0x15,0x16},
{ 0x07,0x07,0x08,0x08,0x09,0x09,0x0a,0x0a,0x0b,0x0b,0x0c,0x0c,0x0d,0x0d,0x0e,
0x0e,0x0f,0x0f,0x10,0x10,0x11,0x11,0x12,0x12,0x13,0x13,0x14,0x14,0x15,0x15,
0x16,0x16},
{ 0x07,0x08,0x08,0x09,0x09,0x0a,0x0a,0x0b,0x0b,0x0c,0x0c,0x0d,0x0d,0x0e,0x0e,
0x0f,0x0f,0x10,0x10,0x11,0x11,0x12,0x12,0x13,0x13,0x14,0x14,0x15,0x15,0x16,
0x16,0x17},
{ 0x08,0x08,0x09,0x09,0x0a,0x0a,0x0b,0x0b,0x0c,0x0c,0x0d,0x0d,0x0e,0x0e,0x0f,
0x0f,0x10,0x10,0x11,0x11,0x12,0x12,0x13,0x13,0x14,0x14,0x15,0x15,0x16,0x16,
0x17,0x17},
{ 0x08,0x09,0x09,0x0a,0x0a,0x0b,0x0b,0x0c,0x0c,0x0d,0x0d,0x0e,0x0e,0x0f,0x0f,
0x10,0x10,0x11,0x11,0x12,0x12,0x13,0x13,0x14,0x14,0x15,0x15,0x16,0x16,0x17,
0x17,0x18},
{ 0x09,0x09,0x0a,0x0a,0x0b,0x0b,0x0c,0x0c,0x0d,0x0d,0x0e,0x0e,0x0f,0x0f,0x10,
0x10,0x11,0x11,0x12,0x12,0x13,0x13,0x14,0x14,0x15,0x15,0x16,0x16,0x17,0x17,
0x18,0x18},
{ 0x09,0x0a,0x0a,0x0b,0x0b,0x0c,0x0c,0x0d,0x0d,0x0e,0x0e,0x0f,0x0f,0x10,0x10,
0x11,0x11,0x12,0x12,0x13,0x13,0x14,0x14,0x15,0x15,0x16,0x16,0x17,0x17,0x18,
0x18,0x19},
{ 0x0a,0x0a,0x0b,0x0b,0x0c,0x0c,0x0d,0x0d,0x0e,0x0e,0x0f,0x0f,0x10,0x10,0x11,
0x11,0x12,0x12,0x13,0x13,0x14,0x14,0x15,0x15,0x16,0x16,0x17,0x17,0x18,0x18,
0x19,0x19},
{ 0x0a,0x0b,0x0b,0x0c,0x0c,0x0d,0x0d,0x0e,0x0e,0x0f,0x0f,0x10,0x10,0x11,0x11,
0x12,0x12,0x13,0x13,0x14,0x14,0x15,0x15,0x16,0x16,0x17,0x17,0x18,0x18,0x19,
0x19,0x1a},
{ 0x0b,0x0b,0x0c,0x0c,0x0d,0x0d,0x0e,0x0e,0x0f,0x0f,0x10,0x10,0x11,0x11,0x12,
0x12,0x13,0x13,0x14,0x14,0x15,0x15,0x16,0x16,0x17,0x17,0x18,0x18,0x19,0x19,
0x1a,0x1a},
{ 0x0b,0x0c,0x0c,0x0d,0x0d,0x0e,0x0e,0x0f,0x0f,0x10,0x10,0x11,0x11,0x12,0x12,
0x13,0x13,0x14,0x14,0x15,0x15,0x16,0x16,0x17,0x17,0x18,0x18,0x19,0x19,0x1a,
0x1a,0x1b},
{ 0x0c,0x0c,0x0d,0x0d,0x0e,0x0e,0x0f,0x0f,0x10,0x10,0x11,0x11,0x12,0x12,0x13,
0x13,0x14,0x14,0x15,0x15,0x16,0x16,0x17,0x17,0x18,0x18,0x19,0x19,0x1a,0x1a,
0x1b,0x1b},
{ 0x0c,0x0d,0x0d,0x0e,0x0e,0x0f,0x0f,0x10,0x10,0x11,0x11,0x12,0x12,0x13,0x13,
0x14,0x14,0x15,0x15,0x16,0x16,0x17,0x17,0x18,0x18,0x19,0x19,0x1a,0x1a,0x1b,
0x1b,0x1c},
{ 0x0d,0x0d,0x0e,0x0e,0x0f,0x0f,0x10,0x10,0x11,0x11,0x12,0x12,0x13,0x13,0x14,
0x14,0x15,0x15,0x16,0x16,0x17,0x17,0x18,0x18,0x19,0x19,0x1a,0x1a,0x1b,0x1b,
0x1c,0x1c},
{ 0x0d,0x0e,0x0e,0x0f,0x0f,0x10,0x10,0x11,0x11,0x12,0x12,0x13,0x13,0x14,0x14,
0x15,0x15,0x16,0x16,0x17,0x17,0x18,0x18,0x19,0x19,0x1a,0x1a,0x1b,0x1b,0x1c,
0x1c,0x1d},
{ 0x0e,0x0e,0x0f,0x0f,0x10,0x10,0x11,0x11,0x12,0x12,0x13,0x13,0x14,0x14,0x15,
0x15,0x16,0x16,0x17,0x17,0x18,0x18,0x19,0x19,0x1a,0x1a,0x1b,0x1b,0x1c,0x1c,
0x1d,0x1d},
{ 0x0e,0x0f,0x0f,0x10,0x10,0x11,0x11,0x12,0x12,0x13,0x13,0x14,0x14,0x15,0x15,
0x16,0x16,0x17,0x17,0x18,0x18,0x19,0x19,0x1a,0x1a,0x1b,0x1b,0x1c,0x1c,0x1d,
0x1d,0x1e},
{ 0x0f,0x0f,0x10,0x10,0x11,0x11,0x12,0x12,0x13,0x13,0x14,0x14,0x15,0x15,0x16,
0x16,0x17,0x17,0x18,0x18,0x19,0x19,0x1a,0x1a,0x1b,0x1b,0x1c,0x1c,0x1d,0x1d,
0x1e,0x1e},
{ 0x0f,0x10,0x10,0x11,0x11,0x12,0x12,0x13,0x13,0x14,0x14,0x15,0x15,0x16,0x16,
0x17,0x17,0x18,0x18,0x19,0x19,0x1a,0x1a,0x1b,0x1b,0x1c,0x1c,0x1d,0x1d,0x1e,
0x1e,0x1f}
};
uint8 sub32_32 [32][32] = {
{ 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,
0x0f,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,
0x1e,0x1f},
{ 0x00,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,
0x0e,0x0f,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,
0x1d,0x1e},
{ 0x00,0x00,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,
0x0d,0x0e,0x0f,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,
0x1c,0x1d},
{ 0x00,0x00,0x00,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,
0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,
0x1b,0x1c},
{ 0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,
0x0b,0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,
0x1a,0x1b},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,
0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,
0x19,0x1a},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,
0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
0x18,0x19},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,0x13,0x14,0x15,0x16,
0x17,0x18},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x03,0x04,0x05,0x06,
0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,0x13,0x14,0x15,
0x16,0x17},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x03,0x04,0x05,
0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,0x13,0x14,
0x15,0x16},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x03,0x04,
0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,0x13,
0x14,0x15},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x03,
0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,
0x13,0x14},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,
0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10,0x11,
0x12,0x13},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10,
0x11,0x12},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
0x10,0x11},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,
0x0f,0x10},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,
0x0e,0x0f},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,
0x0d,0x0e},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,
0x0c,0x0d},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,
0x0b,0x0c},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,
0x0a,0x0b},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,
0x09,0x0a},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
0x08,0x09},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x03,0x04,0x05,0x06,
0x07,0x08},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x03,0x04,0x05,
0x06,0x07},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x03,0x04,
0x05,0x06},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x03,
0x04,0x05},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,
0x03,0x04},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x02,0x03},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0x02},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x01},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00}
};
uint8 sub32_32_half [32][32] = {
{ 0x00,0x00,0x01,0x01,0x02,0x02,0x03,0x03,0x04,0x04,0x05,0x05,0x06,0x06,0x07,
0x07,0x08,0x08,0x09,0x09,0x0a,0x0a,0x0b,0x0b,0x0c,0x0c,0x0d,0x0d,0x0e,0x0e,
0x0f,0x0f},
{ 0x00,0x00,0x00,0x01,0x01,0x02,0x02,0x03,0x03,0x04,0x04,0x05,0x05,0x06,0x06,
0x07,0x07,0x08,0x08,0x09,0x09,0x0a,0x0a,0x0b,0x0b,0x0c,0x0c,0x0d,0x0d,0x0e,
0x0e,0x0f},
{ 0x00,0x00,0x00,0x00,0x01,0x01,0x02,0x02,0x03,0x03,0x04,0x04,0x05,0x05,0x06,
0x06,0x07,0x07,0x08,0x08,0x09,0x09,0x0a,0x0a,0x0b,0x0b,0x0c,0x0c,0x0d,0x0d,
0x0e,0x0e},
{ 0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x02,0x02,0x03,0x03,0x04,0x04,0x05,0x05,
0x06,0x06,0x07,0x07,0x08,0x08,0x09,0x09,0x0a,0x0a,0x0b,0x0b,0x0c,0x0c,0x0d,
0x0d,0x0e},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x02,0x02,0x03,0x03,0x04,0x04,0x05,
0x05,0x06,0x06,0x07,0x07,0x08,0x08,0x09,0x09,0x0a,0x0a,0x0b,0x0b,0x0c,0x0c,
0x0d,0x0d},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x02,0x02,0x03,0x03,0x04,0x04,
0x05,0x05,0x06,0x06,0x07,0x07,0x08,0x08,0x09,0x09,0x0a,0x0a,0x0b,0x0b,0x0c,
0x0c,0x0d},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x02,0x02,0x03,0x03,0x04,
0x04,0x05,0x05,0x06,0x06,0x07,0x07,0x08,0x08,0x09,0x09,0x0a,0x0a,0x0b,0x0b,
0x0c,0x0c},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x02,0x02,0x03,0x03,
0x04,0x04,0x05,0x05,0x06,0x06,0x07,0x07,0x08,0x08,0x09,0x09,0x0a,0x0a,0x0b,
0x0b,0x0c},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x02,0x02,0x03,
0x03,0x04,0x04,0x05,0x05,0x06,0x06,0x07,0x07,0x08,0x08,0x09,0x09,0x0a,0x0a,
0x0b,0x0b},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x02,0x02,
0x03,0x03,0x04,0x04,0x05,0x05,0x06,0x06,0x07,0x07,0x08,0x08,0x09,0x09,0x0a,
0x0a,0x0b},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x02,
0x02,0x03,0x03,0x04,0x04,0x05,0x05,0x06,0x06,0x07,0x07,0x08,0x08,0x09,0x09,
0x0a,0x0a},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,
0x02,0x02,0x03,0x03,0x04,0x04,0x05,0x05,0x06,0x06,0x07,0x07,0x08,0x08,0x09,
0x09,0x0a},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x01,0x02,0x02,0x03,0x03,0x04,0x04,0x05,0x05,0x06,0x06,0x07,0x07,0x08,0x08,
0x09,0x09},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0x01,0x02,0x02,0x03,0x03,0x04,0x04,0x05,0x05,0x06,0x06,0x07,0x07,0x08,
0x08,0x09},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x01,0x01,0x02,0x02,0x03,0x03,0x04,0x04,0x05,0x05,0x06,0x06,0x07,0x07,
0x08,0x08},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x01,0x01,0x02,0x02,0x03,0x03,0x04,0x04,0x05,0x05,0x06,0x06,0x07,
0x07,0x08},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0x01,0x02,0x02,0x03,0x03,0x04,0x04,0x05,0x05,0x06,0x06,
0x07,0x07},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x01,0x01,0x02,0x02,0x03,0x03,0x04,0x04,0x05,0x05,0x06,
0x06,0x07},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x02,0x02,0x03,0x03,0x04,0x04,0x05,0x05,
0x06,0x06},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x02,0x02,0x03,0x03,0x04,0x04,0x05,
0x05,0x06},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x02,0x02,0x03,0x03,0x04,0x04,
0x05,0x05},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x02,0x02,0x03,0x03,0x04,
0x04,0x05},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x02,0x02,0x03,0x03,
0x04,0x04},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x02,0x02,0x03,
0x03,0x04},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x02,0x02,
0x03,0x03},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x02,
0x02,0x03},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,
0x02,0x02},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x01,0x02},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0x01},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x01},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00}
};
uint8 mul_brightness [16][32] = {
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00},
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
0x02,0x02},
{ 0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,0x02,
0x02,0x02,0x02,0x02,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x04,0x04,0x04,
0x04,0x04},
{ 0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x02,0x02,0x02,0x02,0x02,0x03,0x03,
0x03,0x03,0x03,0x04,0x04,0x04,0x04,0x04,0x05,0x05,0x05,0x05,0x05,0x06,0x06,
0x06,0x06},
{ 0x00,0x00,0x01,0x01,0x01,0x01,0x02,0x02,0x02,0x02,0x03,0x03,0x03,0x03,0x04,
0x04,0x04,0x05,0x05,0x05,0x05,0x06,0x06,0x06,0x06,0x07,0x07,0x07,0x07,0x08,
0x08,0x08},
{ 0x00,0x00,0x01,0x01,0x01,0x02,0x02,0x02,0x03,0x03,0x03,0x04,0x04,0x04,0x05,
0x05,0x05,0x06,0x06,0x06,0x07,0x07,0x07,0x08,0x08,0x08,0x09,0x09,0x09,0x0a,
0x0a,0x0a},
{ 0x00,0x00,0x01,0x01,0x02,0x02,0x02,0x03,0x03,0x04,0x04,0x04,0x05,0x05,0x06,
0x06,0x06,0x07,0x07,0x08,0x08,0x08,0x09,0x09,0x0a,0x0a,0x0a,0x0b,0x0b,0x0c,
0x0c,0x0c},
{ 0x00,0x00,0x01,0x01,0x02,0x02,0x03,0x03,0x04,0x04,0x05,0x05,0x06,0x06,0x07,
0x07,0x07,0x08,0x08,0x09,0x09,0x0a,0x0a,0x0b,0x0b,0x0c,0x0c,0x0d,0x0d,0x0e,
0x0e,0x0e},
{ 0x00,0x01,0x01,0x02,0x02,0x03,0x03,0x04,0x04,0x05,0x05,0x06,0x06,0x07,0x07,
0x08,0x09,0x09,0x0a,0x0a,0x0b,0x0b,0x0c,0x0c,0x0d,0x0d,0x0e,0x0e,0x0f,0x0f,
0x10,0x11},
{ 0x00,0x01,0x01,0x02,0x02,0x03,0x04,0x04,0x05,0x05,0x06,0x07,0x07,0x08,0x08,
0x09,0x0a,0x0a,0x0b,0x0b,0x0c,0x0d,0x0d,0x0e,0x0e,0x0f,0x10,0x10,0x11,0x11,
0x12,0x13},
{ 0x00,0x01,0x01,0x02,0x03,0x03,0x04,0x05,0x05,0x06,0x07,0x07,0x08,0x09,0x09,
0x0a,0x0b,0x0b,0x0c,0x0d,0x0d,0x0e,0x0f,0x0f,0x10,0x11,0x11,0x12,0x13,0x13,
0x14,0x15},
{ 0x00,0x01,0x01,0x02,0x03,0x04,0x04,0x05,0x06,0x07,0x07,0x08,0x09,0x0a,0x0a,
0x0b,0x0c,0x0c,0x0d,0x0e,0x0f,0x0f,0x10,0x11,0x12,0x12,0x13,0x14,0x15,0x15,
0x16,0x17},
{ 0x00,0x01,0x02,0x02,0x03,0x04,0x05,0x06,0x06,0x07,0x08,0x09,0x0a,0x0a,0x0b,
0x0c,0x0d,0x0e,0x0e,0x0f,0x10,0x11,0x12,0x12,0x13,0x14,0x15,0x16,0x16,0x17,
0x18,0x19},
{ 0x00,0x01,0x02,0x03,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0a,0x0b,0x0c,
0x0d,0x0e,0x0f,0x10,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x17,0x18,0x19,
0x1a,0x1b},
{ 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,
0x0e,0x0f,0x10,0x11,0x12,0x13,0x14,0x15,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,
0x1c,0x1d},
{ 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,
0x0f,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,
0x1e,0x1f}
};

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,68 +172,64 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#ifndef _DISPLAY_H_
#define _DISPLAY_H_
START_EXTERN_C
// Routines the port specific code has to implement
void S9xSetPalette ();
void S9xTextMode ();
void S9xGraphicsMode ();
void S9xParseArg (char **argv, int &index, int argc);
void S9xExtraUsage ();
void S9xLoadConfigFiles(char **argv, int argc);
char *S9xParseArgs (char **argv, int argc);
void S9xUsage ();
void S9xInitDisplay (int argc, char **argv);
void S9xDeinitDisplay ();
void S9xInitInputDevices ();
void S9xSetTitle (const char *title);
void S9xProcessEvents (bool8 block);
void S9xPutImage (int width, int height);
void S9xParseDisplayArg (char **argv, int &index, int argc);
void S9xExtraDisplayUsage ();
void S9xToggleSoundChannel (int channel);
void S9xSetInfoString (const char *string);
int S9xMinCommandLineArgs ();
void S9xNextController ();
bool8 S9xLoadROMImage (const char *string);
const char *S9xSelectFilename (const char *def, const char *dir,
const char *ext, const char *title);
const char *S9xStringInput(const char *message);
const char *S9xChooseFilename (bool8 read_only);
bool8 S9xOpenSnapshotFile (const char *base, bool8 read_only, STREAM *file);
void S9xCloseSnapshotFile (STREAM file);
const char *S9xBasename (const char *filename);
int S9xFStrcmp (FILE *, const char *);
enum s9x_getdirtype {
DEFAULT_DIR,
HOME_DIR,
ROM_DIR,
ROMFILENAME_DIR,
SNAPSHOT_DIR,
SRAM_DIR,
SCREENSHOT_DIR,
SPC_DIR,
PATCH_DIR,
enum s9x_getdirtype
{
DEFAULT_DIR = 0,
HOME_DIR,
ROMFILENAME_DIR,
ROM_DIR,
SRAM_DIR,
SNAPSHOT_DIR,
SCREENSHOT_DIR,
SPC_DIR,
CHEAT_DIR,
PACK_DIR,
IPS_DIR,
BIOS_DIR,
LOG_DIR
LOG_DIR,
LAST_DIR
};
const char *S9xGetDirectory (enum s9x_getdirtype dirtype);
const char *S9xGetFilename (const char *extension, enum s9x_getdirtype dirtype);
const char *S9xGetFilenameInc (const char *, enum s9x_getdirtype);
END_EXTERN_C
void S9xUsage (void);
char * S9xParseArgs (char **, int);
void S9xLoadConfigFiles (char **, int);
void S9xSetInfoString (const char *);
// Routines the port has to implement even if it doesn't use them
void S9xPutImage (int, int);
void S9xInitDisplay (int, char **);
void S9xDeinitDisplay (void);
void S9xTextMode (void);
void S9xGraphicsMode (void);
void S9xSetPalette (void);
void S9xToggleSoundChannel (int);
bool8 S9xOpenSnapshotFile (const char *, bool8, STREAM *);
void S9xCloseSnapshotFile (STREAM);
const char * S9xStringInput (const char *);
const char * S9xGetDirectory (enum s9x_getdirtype);
const char * S9xGetFilename (const char *, enum s9x_getdirtype);
const char * S9xGetFilenameInc (const char *, enum s9x_getdirtype);
const char * S9xChooseFilename (bool8);
const char * S9xBasename (const char *);
// Routines the port has to implement if it uses command-line
void S9xExtraUsage (void);
void S9xParseArg (char **, int &, int);
// Routines the port may implement as needed
void S9xExtraDisplayUsage (void);
void S9xParseDisplayArg (char **, int &, int);
void S9xSetTitle (const char *);
void S9xInitInputDevices (void);
void S9xProcessEvents (bool8);
const char * S9xSelectFilename (const char *, const char *, const char *, const char *);
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,20 +172,40 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#ifndef _DMA_H_
#define _DMA_H_
START_EXTERN_C
void S9xResetDMA ();
uint8 S9xDoHDMA (uint8);
void S9xStartHDMA ();
struct SDMA
{
bool8 ReverseTransfer;
bool8 HDMAIndirectAddressing;
bool8 UnusedBit43x0;
bool8 AAddressFixed;
bool8 AAddressDecrement;
uint8 TransferMode;
uint8 BAddress;
uint16 AAddress;
uint8 ABank;
uint16 DMACount_Or_HDMAIndirectAddress;
uint8 IndirectBank;
uint16 Address;
uint8 Repeat;
uint8 LineCount;
uint8 UnknownByte;
uint8 DoTransfer;
};
#define TransferBytes DMACount_Or_HDMAIndirectAddress
#define IndirectAddress DMACount_Or_HDMAIndirectAddress
extern struct SDMA DMA[8];
bool8 S9xDoDMA (uint8);
END_EXTERN_C
void S9xStartHDMA (void);
uint8 S9xDoHDMA (uint8);
void S9xResetDMA (void);
#endif

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,67 +172,58 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
#ifndef _DSP1_H_
#define _DSP1_H_
extern void (*SetDSP)(uint8, uint16);
extern uint8 (*GetDSP)(uint16);
void DSP1SetByte(uint8 byte, uint16 address);
uint8 DSP1GetByte(uint16 address);
void DSP2SetByte(uint8 byte, uint16 address);
uint8 DSP2GetByte(uint16 address);
void DSP3SetByte(uint8 byte, uint16 address);
uint8 DSP3GetByte(uint16 address);
void DSP3_Reset();
void DSP4SetByte(uint8 byte, uint16 address);
uint8 DSP4GetByte(uint16 address);
enum
{
M_DSP1_LOROM_S,
M_DSP1_LOROM_L,
M_DSP1_HIROM,
M_DSP2_LOROM,
M_DSP3_LOROM,
M_DSP4_LOROM
};
struct SDSP1 {
uint8 version;
bool8 waiting4command;
bool8 first_parameter;
uint8 command;
uint32 in_count;
uint32 in_index;
uint32 out_count;
uint32 out_index;
uint8 parameters [512];
uint8 output [512];
uint8 temp_save_data [406];
uint32 maptype;
uint32 boundary;
};
START_EXTERN_C
void S9xResetDSP1 ();
uint8 S9xGetDSP (uint16 Address);
void S9xSetDSP (uint8 Byte, uint16 Address);
void S9xPreSaveDSP1();
void S9xPostLoadDSP1();
extern struct SDSP1 DSP1;
END_EXTERN_C
***********************************************************************************/
#include "snes9x.h"
#include "memmap.h"
#ifdef DEBUGGER
#include "missing.h"
#endif
uint8 (*GetDSP) (uint16) = NULL;
void (*SetDSP) (uint8, uint16) = NULL;
void S9xResetDSP (void)
{
memset(&DSP1, 0, sizeof(DSP1));
DSP1.waiting4command = TRUE;
DSP1.first_parameter = TRUE;
memset(&DSP2, 0, sizeof(DSP2));
DSP2.waiting4command = TRUE;
memset(&DSP3, 0, sizeof(DSP3));
DSP3_Reset();
memset(&DSP4, 0, sizeof(DSP4));
DSP4.waiting4command = TRUE;
}
uint8 S9xGetDSP (uint16 address)
{
#ifdef DEBUGGER
if (Settings.TraceDSP)
{
sprintf(String, "DSP read: 0x%04X", address);
S9xMessage(S9X_TRACE, S9X_TRACE_DSP1, String);
}
#endif
return ((*GetDSP)(address));
}
void S9xSetDSP (uint8 byte, uint16 address)
{
#ifdef DEBUGGER
missing.unknowndsp_write = address;
if (Settings.TraceDSP)
{
sprintf(String, "DSP write: 0x%04X=0x%02X", address, byte);
S9xMessage(S9X_TRACE, S9X_TRACE_DSP1, String);
}
#endif
(*SetDSP)(byte, address);
}

618
source/snes9x/dsp.h Normal file
View File

@ -0,0 +1,618 @@
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
Jerremy Koot (jkoot@snes9x.com)
(c) Copyright 2002 - 2004 Matthew Kendora
(c) Copyright 2002 - 2005 Peter Bortas (peter@bortas.org)
(c) Copyright 2004 - 2005 Joel Yliluoma (http://iki.fi/bisqwit/)
(c) Copyright 2001 - 2006 John Weidman (jweidman@slip.net)
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
zones
C4 x86 assembler and some C emulation code
(c) Copyright 2000 - 2003 _Demo_ (_demo_@zsnes.com),
Nach,
zsKnight (zsknight@zsnes.com)
C4 C++ code
(c) Copyright 2003 - 2006 Brad Jorsch,
Nach
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
Kris Bleakley,
Matthew Kendora,
Nach,
neviksti (neviksti@hotmail.com)
DSP-2 emulator code
(c) Copyright 2003 John Weidman,
Kris Bleakley,
Lord Nightmare (lord_nightmare@users.sourceforge.net),
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
Lancer,
z80 gaiden
DSP-4 emulator code
(c) Copyright 2004 - 2006 Dreamer Nom,
John Weidman,
Kris Bleakley,
Nach,
z80 gaiden
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
(c) Copyright 2003 Feather,
John Weidman,
Kris Bleakley,
Matthew Kendora
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
2xSaI filter
(c) Copyright 1999 - 2001 Derek Liauw Kie Fa
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
fee, providing that this license information and copyright notice appear
with all copies and any derived work.
This software is provided 'as-is', without any express or implied
warranty. In no event shall the authors be held liable for any damages
arising from the use of this software or it's derivatives.
Snes9x is freeware for PERSONAL USE only. Commercial users should
seek permission of the copyright holders first. Commercial use includes,
but is not limited to, charging money for Snes9x or software derived from
Snes9x, including Snes9x or derivatives in commercial game bundles, and/or
using Snes9x as a promotion for your commercial product.
The copyright holders request that bug fixes and improvements to the code
should be forwarded to them so everyone can benefit from the modifications
in future versions.
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
***********************************************************************************/
#ifndef _DSP1_H_
#define _DSP1_H_
enum
{
M_DSP1_LOROM_S,
M_DSP1_LOROM_L,
M_DSP1_HIROM,
M_DSP2_LOROM,
M_DSP3_LOROM,
M_DSP4_LOROM
};
struct SDSP0
{
uint32 maptype;
uint32 boundary;
};
struct SDSP1
{
bool8 waiting4command;
bool8 first_parameter;
uint8 command;
uint32 in_count;
uint32 in_index;
uint32 out_count;
uint32 out_index;
uint8 parameters[512];
uint8 output[512];
int16 CentreX;
int16 CentreY;
int16 VOffset;
int16 VPlane_C;
int16 VPlane_E;
// Azimuth and Zenith angles
int16 SinAas;
int16 CosAas;
int16 SinAzs;
int16 CosAzs;
// Clipped Zenith angle
int16 SinAZS;
int16 CosAZS;
int16 SecAZS_C1;
int16 SecAZS_E1;
int16 SecAZS_C2;
int16 SecAZS_E2;
int16 Nx;
int16 Ny;
int16 Nz;
int16 Gx;
int16 Gy;
int16 Gz;
int16 C_Les;
int16 E_Les;
int16 G_Les;
int16 matrixA[3][3];
int16 matrixB[3][3];
int16 matrixC[3][3];
int16 Op00Multiplicand;
int16 Op00Multiplier;
int16 Op00Result;
int16 Op20Multiplicand;
int16 Op20Multiplier;
int16 Op20Result;
int16 Op10Coefficient;
int16 Op10Exponent;
int16 Op10CoefficientR;
int16 Op10ExponentR;
int16 Op04Angle;
int16 Op04Radius;
int16 Op04Sin;
int16 Op04Cos;
int16 Op0CA;
int16 Op0CX1;
int16 Op0CY1;
int16 Op0CX2;
int16 Op0CY2;
int16 Op02FX;
int16 Op02FY;
int16 Op02FZ;
int16 Op02LFE;
int16 Op02LES;
int16 Op02AAS;
int16 Op02AZS;
int16 Op02VOF;
int16 Op02VVA;
int16 Op02CX;
int16 Op02CY;
int16 Op0AVS;
int16 Op0AA;
int16 Op0AB;
int16 Op0AC;
int16 Op0AD;
int16 Op06X;
int16 Op06Y;
int16 Op06Z;
int16 Op06H;
int16 Op06V;
int16 Op06M;
int16 Op01m;
int16 Op01Zr;
int16 Op01Xr;
int16 Op01Yr;
int16 Op11m;
int16 Op11Zr;
int16 Op11Xr;
int16 Op11Yr;
int16 Op21m;
int16 Op21Zr;
int16 Op21Xr;
int16 Op21Yr;
int16 Op0DX;
int16 Op0DY;
int16 Op0DZ;
int16 Op0DF;
int16 Op0DL;
int16 Op0DU;
int16 Op1DX;
int16 Op1DY;
int16 Op1DZ;
int16 Op1DF;
int16 Op1DL;
int16 Op1DU;
int16 Op2DX;
int16 Op2DY;
int16 Op2DZ;
int16 Op2DF;
int16 Op2DL;
int16 Op2DU;
int16 Op03F;
int16 Op03L;
int16 Op03U;
int16 Op03X;
int16 Op03Y;
int16 Op03Z;
int16 Op13F;
int16 Op13L;
int16 Op13U;
int16 Op13X;
int16 Op13Y;
int16 Op13Z;
int16 Op23F;
int16 Op23L;
int16 Op23U;
int16 Op23X;
int16 Op23Y;
int16 Op23Z;
int16 Op14Zr;
int16 Op14Xr;
int16 Op14Yr;
int16 Op14U;
int16 Op14F;
int16 Op14L;
int16 Op14Zrr;
int16 Op14Xrr;
int16 Op14Yrr;
int16 Op0EH;
int16 Op0EV;
int16 Op0EX;
int16 Op0EY;
int16 Op0BX;
int16 Op0BY;
int16 Op0BZ;
int16 Op0BS;
int16 Op1BX;
int16 Op1BY;
int16 Op1BZ;
int16 Op1BS;
int16 Op2BX;
int16 Op2BY;
int16 Op2BZ;
int16 Op2BS;
int16 Op28X;
int16 Op28Y;
int16 Op28Z;
int16 Op28R;
int16 Op1CX;
int16 Op1CY;
int16 Op1CZ;
int16 Op1CXBR;
int16 Op1CYBR;
int16 Op1CZBR;
int16 Op1CXAR;
int16 Op1CYAR;
int16 Op1CZAR;
int16 Op1CX1;
int16 Op1CY1;
int16 Op1CZ1;
int16 Op1CX2;
int16 Op1CY2;
int16 Op1CZ2;
uint16 Op0FRamsize;
uint16 Op0FPass;
int16 Op2FUnknown;
int16 Op2FSize;
int16 Op08X;
int16 Op08Y;
int16 Op08Z;
int16 Op08Ll;
int16 Op08Lh;
int16 Op18X;
int16 Op18Y;
int16 Op18Z;
int16 Op18R;
int16 Op18D;
int16 Op38X;
int16 Op38Y;
int16 Op38Z;
int16 Op38R;
int16 Op38D;
};
struct SDSP2
{
bool8 waiting4command;
uint8 command;
uint32 in_count;
uint32 in_index;
uint32 out_count;
uint32 out_index;
uint8 parameters[512];
uint8 output[512];
bool8 Op05HasLen;
int32 Op05Len;
uint8 Op05Transparent;
bool8 Op06HasLen;
int32 Op06Len;
uint16 Op09Word1;
uint16 Op09Word2;
bool8 Op0DHasLen;
int32 Op0DOutLen;
int32 Op0DInLen;
};
struct SDSP3
{
uint16 DR;
uint16 SR;
uint16 MemoryIndex;
int16 WinLo;
int16 WinHi;
int16 AddLo;
int16 AddHi;
uint16 Codewords;
uint16 Outwords;
uint16 Symbol;
uint16 BitCount;
uint16 Index;
uint16 Codes[512];
uint16 BitsLeft;
uint16 ReqBits;
uint16 ReqData;
uint16 BitCommand;
uint8 BaseLength;
uint16 BaseCodes;
uint16 BaseCode;
uint8 CodeLengths[8];
uint16 CodeOffsets[8];
uint16 LZCode;
uint8 LZLength;
uint16 X;
uint16 Y;
uint8 Bitmap[8];
uint8 Bitplane[8];
uint16 BMIndex;
uint16 BPIndex;
uint16 Count;
int16 op3e_x;
int16 op3e_y;
int16 op1e_terrain[0x2000];
int16 op1e_cost[0x2000];
int16 op1e_weight[0x2000];
int16 op1e_cell;
int16 op1e_turn;
int16 op1e_search;
int16 op1e_x;
int16 op1e_y;
int16 op1e_min_radius;
int16 op1e_max_radius;
int16 op1e_max_search_radius;
int16 op1e_max_path_radius;
int16 op1e_lcv_radius;
int16 op1e_lcv_steps;
int16 op1e_lcv_turns;
};
struct SDSP4
{
bool8 waiting4command;
bool8 half_command;
uint16 command;
uint32 in_count;
uint32 in_index;
uint32 out_count;
uint32 out_index;
uint8 parameters[512];
uint8 output[512];
uint8 byte;
uint16 address;
// op control
int8 Logic; // controls op flow
// projection format
int16 lcv; // loop-control variable
int16 distance; // z-position into virtual world
int16 raster; // current raster line
int16 segments; // number of raster lines drawn
// 1.15.16 or 1.15.0 [sign, integer, fraction]
int32 world_x; // line of x-projection in world
int32 world_y; // line of y-projection in world
int32 world_dx; // projection line x-delta
int32 world_dy; // projection line y-delta
int16 world_ddx; // x-delta increment
int16 world_ddy; // y-delta increment
int32 world_xenv; // world x-shaping factor
int16 world_yofs; // world y-vertical scroll
int16 view_x1; // current viewer-x
int16 view_y1; // current viewer-y
int16 view_x2; // future viewer-x
int16 view_y2; // future viewer-y
int16 view_dx; // view x-delta factor
int16 view_dy; // view y-delta factor
int16 view_xofs1; // current viewer x-vertical scroll
int16 view_yofs1; // current viewer y-vertical scroll
int16 view_xofs2; // future viewer x-vertical scroll
int16 view_yofs2; // future viewer y-vertical scroll
int16 view_yofsenv; // y-scroll shaping factor
int16 view_turnoff_x; // road turnoff data
int16 view_turnoff_dx; // road turnoff delta factor
// drawing area
int16 viewport_cx; // x-center of viewport window
int16 viewport_cy; // y-center of render window
int16 viewport_left; // x-left of viewport
int16 viewport_right; // x-right of viewport
int16 viewport_top; // y-top of viewport
int16 viewport_bottom; // y-bottom of viewport
// sprite structure
int16 sprite_x; // projected x-pos of sprite
int16 sprite_y; // projected y-pos of sprite
int16 sprite_attr; // obj attributes
bool8 sprite_size; // sprite size: 8x8 or 16x16
int16 sprite_clipy; // visible line to clip pixels off
int16 sprite_count;
// generic projection variables designed for two solid polygons + two polygon sides
int16 poly_clipLf[2][2]; // left clip boundary
int16 poly_clipRt[2][2]; // right clip boundary
int16 poly_ptr[2][2]; // HDMA structure pointers
int16 poly_raster[2][2]; // current raster line below horizon
int16 poly_top[2][2]; // top clip boundary
int16 poly_bottom[2][2]; // bottom clip boundary
int16 poly_cx[2][2]; // center for left/right points
int16 poly_start[2]; // current projection points
int16 poly_plane[2]; // previous z-plane distance
// OAM
int16 OAM_attr[16]; // OAM (size, MSB) data
int16 OAM_index; // index into OAM table
int16 OAM_bits; // offset into OAM table
int16 OAM_RowMax; // maximum number of tiles per 8 aligned pixels (row)
int16 OAM_Row[32]; // current number of tiles per row
};
extern struct SDSP0 DSP0;
extern struct SDSP1 DSP1;
extern struct SDSP2 DSP2;
extern struct SDSP3 DSP3;
extern struct SDSP4 DSP4;
uint8 S9xGetDSP (uint16);
void S9xSetDSP (uint8, uint16);
void S9xResetDSP (void);
uint8 DSP1GetByte (uint16);
void DSP1SetByte (uint8, uint16);
uint8 DSP2GetByte (uint16);
void DSP2SetByte (uint8, uint16);
uint8 DSP3GetByte (uint16);
void DSP3SetByte (uint8, uint16);
uint8 DSP4GetByte (uint16);
void DSP4SetByte (uint8, uint16);
void DSP3_Reset (void);
extern uint8 (*GetDSP) (uint16);
extern void (*SetDSP) (uint8, uint16);
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,23 +172,87 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#include "snes9x.h"
#include "memmap.h"
static void DSP2_Op01 (void);
static void DSP2_Op03 (void);
static void DSP2_Op05 (void);
static void DSP2_Op06 (void);
static void DSP2_Op09 (void);
static void DSP2_Op0D (void);
uint16 DSP2Op09Word1=0;
uint16 DSP2Op09Word2=0;
bool DSP2Op05HasLen=false;
int DSP2Op05Len=0;
bool DSP2Op06HasLen=false;
int DSP2Op06Len=0;
uint8 DSP2Op05Transparent=0;
void DSP2_Op05 ()
// convert bitmap to bitplane tile
static void DSP2_Op01 (void)
{
// Op01 size is always 32 bytes input and output
// The hardware does strange things if you vary the size
uint8 c0, c1, c2, c3;
uint8 *p1 = DSP2.parameters;
uint8 *p2a = DSP2.output;
uint8 *p2b = DSP2.output + 16; // halfway
// Process 8 blocks of 4 bytes each
for (int j = 0; j < 8; j++)
{
c0 = *p1++;
c1 = *p1++;
c2 = *p1++;
c3 = *p1++;
*p2a++ = (c0 & 0x10) << 3 |
(c0 & 0x01) << 6 |
(c1 & 0x10) << 1 |
(c1 & 0x01) << 4 |
(c2 & 0x10) >> 1 |
(c2 & 0x01) << 2 |
(c3 & 0x10) >> 3 |
(c3 & 0x01);
*p2a++ = (c0 & 0x20) << 2 |
(c0 & 0x02) << 5 |
(c1 & 0x20) |
(c1 & 0x02) << 3 |
(c2 & 0x20) >> 2 |
(c2 & 0x02) << 1 |
(c3 & 0x20) >> 4 |
(c3 & 0x02) >> 1;
*p2b++ = (c0 & 0x40) << 1 |
(c0 & 0x04) << 4 |
(c1 & 0x40) >> 1 |
(c1 & 0x04) << 2 |
(c2 & 0x40) >> 3 |
(c2 & 0x04) |
(c3 & 0x40) >> 5 |
(c3 & 0x04) >> 2;
*p2b++ = (c0 & 0x80) |
(c0 & 0x08) << 3 |
(c1 & 0x80) >> 2 |
(c1 & 0x08) << 1 |
(c2 & 0x80) >> 4 |
(c2 & 0x08) >> 1 |
(c3 & 0x80) >> 6 |
(c3 & 0x08) >> 3;
}
}
// set transparent color
static void DSP2_Op03 (void)
{
DSP2.Op05Transparent = DSP2.parameters[0];
}
// replace bitmap using transparent color
static void DSP2_Op05 (void)
{
uint8 color;
// Overlay bitmap with transparency.
// Input:
//
@ -198,136 +278,48 @@ void DSP2_Op05 ()
// size = 0. I don't think it's worth implementing this quirk unless it's
// proven necessary.
int n;
unsigned char c1;
unsigned char c2;
unsigned char *p1 = DSP1.parameters;
unsigned char *p2 = &DSP1.parameters[DSP2Op05Len];
unsigned char *p3 = DSP1.output;
uint8 color;
uint8 c1, c2;
uint8 *p1 = DSP2.parameters;
uint8 *p2 = DSP2.parameters + DSP2.Op05Len;
uint8 *p3 = DSP2.output;
color = DSP2Op05Transparent&0x0f;
color = DSP2.Op05Transparent & 0x0f;
for( n = 0; n < DSP2Op05Len; n++ )
for (int32 n = 0; n < DSP2.Op05Len; n++)
{
c1 = *p1++;
c2 = *p2++;
*p3++ = ( ((c2 >> 4) == color ) ? c1 & 0xf0: c2 & 0xf0 ) |
( ((c2 & 0x0f)==color) ? c1 & 0x0f: c2 & 0x0f );
*p3++ = (((c2 >> 4) == color) ? c1 & 0xf0: c2 & 0xf0) | (((c2 & 0x0f) == color) ? c1 & 0x0f: c2 & 0x0f);
}
}
void DSP2_Op01 ()
{
// Op01 size is always 32 bytes input and output.
// The hardware does strange things if you vary the size.
int j;
unsigned char c0, c1, c2, c3;
unsigned char *p1 = DSP1.parameters;
unsigned char *p2a = DSP1.output;
unsigned char *p2b = &DSP1.output[16]; // halfway
// Process 8 blocks of 4 bytes each
for ( j = 0; j < 8; j++ )
{
c0 = *p1++;
c1 = *p1++;
c2 = *p1++;
c3 = *p1++;
*p2a++ = (c0 & 0x10) << 3 |
(c0 & 0x01) << 6 |
(c1 & 0x10) << 1 |
(c1 & 0x01) << 4 |
(c2 & 0x10) >> 1 |
(c2 & 0x01) << 2 |
(c3 & 0x10) >> 3 |
(c3 & 0x01);
*p2a++ = (c0 & 0x20) << 2 |
(c0 & 0x02) << 5 |
(c1 & 0x20) |
(c1 & 0x02) << 3 |
(c2 & 0x20) >> 2 |
(c2 & 0x02) << 1 |
(c3 & 0x20) >> 4 |
(c3 & 0x02) >> 1;
*p2b++ = (c0 & 0x40) << 1 |
(c0 & 0x04) << 4 |
(c1 & 0x40) >> 1 |
(c1 & 0x04) << 2 |
(c2 & 0x40) >> 3 |
(c2 & 0x04) |
(c3 & 0x40) >> 5 |
(c3 & 0x04) >> 2;
*p2b++ = (c0 & 0x80) |
(c0 & 0x08) << 3 |
(c1 & 0x80) >> 2 |
(c1 & 0x08) << 1 |
(c2 & 0x80) >> 4 |
(c2 & 0x08) >> 1 |
(c3 & 0x80) >> 6 |
(c3 & 0x08) >> 3;
}
return;
}
void DSP2_Op06 ()
// reverse bitmap
static void DSP2_Op06 (void)
{
// Input:
// size
// bitmap
int i, j;
for ( i = 0, j = DSP2Op06Len - 1; i < DSP2Op06Len; i++, j-- )
{
DSP1.output[j] = (DSP1.parameters[i] << 4) | (DSP1.parameters[i] >> 4);
}
for (int32 i = 0, j = DSP2.Op06Len - 1; i < DSP2.Op06Len; i++, j--)
DSP2.output[j] = (DSP2.parameters[i] << 4) | (DSP2.parameters[i] >> 4);
}
bool DSP2Op0DHasLen=false;
int DSP2Op0DOutLen=0;
int DSP2Op0DInLen=0;
#ifndef DSP2_BIT_ACCURRATE_CODE
// Scale bitmap based on input length out output length
void DSP2_Op0D()
// multiply
static void DSP2_Op09 (void)
{
// Overload's algorithm - use this unless doing hardware testing
DSP2.Op09Word1 = DSP2.parameters[0] | (DSP2.parameters[1] << 8);
DSP2.Op09Word2 = DSP2.parameters[2] | (DSP2.parameters[3] << 8);
// One note: the HW can do odd byte scaling but since we divide
// by two to get the count of bytes this won't work well for
// odd byte scaling (in any of the current algorithm implementations).
// So far I haven't seen Dungeon Master use it.
// If it does we can adjust the parameters and code to work with it
int i;
int pixel_offset;
uint8 pixelarray[512];
for(i=0; i<DSP2Op0DOutLen*2; i++)
{
pixel_offset = (i * DSP2Op0DInLen) / DSP2Op0DOutLen;
if ( (pixel_offset&1) == 0 )
pixelarray[i] = DSP1.parameters[pixel_offset>>1] >> 4;
else
pixelarray[i] = DSP1.parameters[pixel_offset>>1] & 0x0f;
}
for ( i=0; i < DSP2Op0DOutLen; i++ )
DSP1.output[i] = ( pixelarray[i<<1] << 4 ) | pixelarray[(i<<1)+1];
uint32 temp = DSP2.Op09Word1 * DSP2.Op09Word2;
DSP2.output[0] = temp & 0xFF;
DSP2.output[1] = (temp >> 8) & 0xFF;
DSP2.output[2] = (temp >> 16) & 0xFF;
DSP2.output[3] = (temp >> 24) & 0xFF;
}
#else
void DSP2_Op0D()
// scale bitmap
static void DSP2_Op0D (void)
{
// Bit accurate hardware algorithm - uses fixed point math
// This should match the DSP2 Op0D output exactly
@ -343,74 +335,198 @@ void DSP2_Op0D()
// So far I haven't seen Dungeon Master use it.
// If it does we can adjust the parameters and code to work with it
uint32 multiplier; // Any size int >= 32-bits
uint32 pixloc; // match size of multiplier
uint8 pixelarray[512];
uint32 multiplier; // Any size int >= 32-bits
uint32 pixloc; // match size of multiplier
int i, j;
uint8 pixelarray[512];
if (DSP2Op0DInLen <= DSP2Op0DOutLen)
multiplier = 0x10000; // In our self defined fixed point 0x10000 == 1
if (DSP2.Op0DInLen <= DSP2.Op0DOutLen)
multiplier = 0x10000; // In our self defined fixed point 0x10000 == 1
else
multiplier = (DSP2Op0DInLen << 17) / ((DSP2Op0DOutLen<<1) + 1);
multiplier = (DSP2.Op0DInLen << 17) / ((DSP2.Op0DOutLen << 1) + 1);
pixloc = 0;
for ( i=0; i < DSP2Op0DOutLen * 2; i++ )
{
j = pixloc >> 16;
if ( j & 1 )
pixelarray[i] = DSP1.parameters[j>>1] & 0x0f;
for (int32 i = 0; i < DSP2.Op0DOutLen * 2; i++)
{
int32 j = pixloc >> 16;
if (j & 1)
pixelarray[i] = DSP2.parameters[j >> 1] & 0x0f;
else
pixelarray[i] = (DSP1.parameters[j>>1] & 0xf0) >> 4;
pixelarray[i] = (DSP2.parameters[j >> 1] & 0xf0) >> 4;
pixloc += multiplier;
}
for ( i=0; i < DSP2Op0DOutLen; i++ )
DSP1.output[i] = ( pixelarray[i<<1] << 4 ) | pixelarray[(i<<1)+1];
for (int32 i = 0; i < DSP2.Op0DOutLen; i++)
DSP2.output[i] = (pixelarray[i << 1] << 4) | pixelarray[(i << 1) + 1];
}
#endif
#if 0 // Probably no reason to use this code - it's not quite bit accurate and it doesn't look as good as Overload's algorithm
void DSP2_Op0D()
/*
static void DSP2_Op0D (void)
{
// Float implementation of Neviksti's algorithm
// This is the right algorithm to match the DSP2 bits but the precision
// of the PC float does not match the precision of the fixed point math
// on the DSP2 causing occasional one off data mismatches (which should
// be no problem because its just a one pixel difference in a scaled image
// to be displayed).
// Overload's algorithm - use this unless doing hardware testing
float multiplier;
float pixloc;
int i, j;
uint8 pixelarray[512];
// One note: the HW can do odd byte scaling but since we divide
// by two to get the count of bytes this won't work well for
// odd byte scaling (in any of the current algorithm implementations).
// So far I haven't seen Dungeon Master use it.
// If it does we can adjust the parameters and code to work with it
if (DSP2Op0DInLen <= DSP2Op0DOutLen)
multiplier = (float) 1.0;
else
multiplier = (float) ((DSP2Op0DInLen * 2.0) / (DSP2Op0DOutLen * 2.0 + 1.0));
int32 pixel_offset;
uint8 pixelarray[512];
pixloc = 0.0;
for ( i=0; i < DSP2Op0DOutLen * 2; i++ )
for (int32 i = 0; i < DSP2.Op0DOutLen * 2; i++)
{
// j = (int)(i * multiplier);
j = (int) pixloc;
pixel_offset = (i * DSP2.Op0DInLen) / DSP2.Op0DOutLen;
if ( j & 1 )
pixelarray[i] = DSP1.parameters[j>>1] & 0x0f;
if ((pixel_offset & 1) == 0)
pixelarray[i] = DSP2.parameters[pixel_offset >> 1] >> 4;
else
pixelarray[i] = (DSP1.parameters[j>>1] & 0xf0) >> 4;
pixloc += multiplier; // use an add in the loop instead of multiply to increase loop speed
pixelarray[i] = DSP2.parameters[pixel_offset >> 1] & 0x0f;
}
for ( i=0; i < DSP2Op0DOutLen; i++ )
DSP1.output[i] = ( pixelarray[i<<1] << 4 ) | pixelarray[(i<<1)+1];
for (int32 i = 0; i < DSP2.Op0DOutLen; i++)
DSP2.output[i] = (pixelarray[i << 1] << 4) | pixelarray[(i << 1) + 1];
}
*/
void DSP2SetByte (uint8 byte, uint16 address)
{
if ((address & 0xf000) == 0x6000 || (address >= 0x8000 && address < 0xc000))
{
if (DSP2.waiting4command)
{
DSP2.command = byte;
DSP2.in_index = 0;
DSP2.waiting4command = FALSE;
switch (byte)
{
case 0x01: DSP2.in_count = 32; break;
case 0x03: DSP2.in_count = 1; break;
case 0x05: DSP2.in_count = 1; break;
case 0x06: DSP2.in_count = 1; break;
case 0x09: DSP2.in_count = 4; break;
case 0x0D: DSP2.in_count = 2; break;
default:
#ifdef DEBUGGER
//printf("Op%02X\n", byte);
#endif
case 0x0f: DSP2.in_count = 0; break;
}
}
else
{
DSP2.parameters[DSP2.in_index] = byte;
DSP2.in_index++;
}
if (DSP2.in_count == DSP2.in_index)
{
DSP2.waiting4command = TRUE;
DSP2.out_index = 0;
switch (DSP2.command)
{
case 0x01:
DSP2.out_count = 32;
DSP2_Op01();
break;
case 0x03:
DSP2_Op03();
break;
case 0x05:
if (DSP2.Op05HasLen)
{
DSP2.Op05HasLen = FALSE;
DSP2.out_count = DSP2.Op05Len;
DSP2_Op05();
}
else
{
DSP2.Op05Len = DSP2.parameters[0];
DSP2.in_index = 0;
DSP2.in_count = 2 * DSP2.Op05Len;
DSP2.Op05HasLen = TRUE;
if (byte)
DSP2.waiting4command = FALSE;
}
break;
case 0x06:
if (DSP2.Op06HasLen)
{
DSP2.Op06HasLen = FALSE;
DSP2.out_count = DSP2.Op06Len;
DSP2_Op06();
}
else
{
DSP2.Op06Len = DSP2.parameters[0];
DSP2.in_index = 0;
DSP2.in_count = DSP2.Op06Len;
DSP2.Op06HasLen = TRUE;
if (byte)
DSP2.waiting4command = FALSE;
}
break;
case 0x09:
DSP2.out_count = 4;
DSP2_Op09();
break;
case 0x0D:
if (DSP2.Op0DHasLen)
{
DSP2.Op0DHasLen = FALSE;
DSP2.out_count = DSP2.Op0DOutLen;
DSP2_Op0D();
}
else
{
DSP2.Op0DInLen = DSP2.parameters[0];
DSP2.Op0DOutLen = DSP2.parameters[1];
DSP2.in_index = 0;
DSP2.in_count = (DSP2.Op0DInLen + 1) >> 1;
DSP2.Op0DHasLen = TRUE;
if (byte)
DSP2.waiting4command = FALSE;
}
break;
case 0x0f:
default:
break;
}
}
}
}
#endif
uint8 DSP2GetByte (uint16 address)
{
uint8 t;
if ((address & 0xf000) == 0x6000 || (address >= 0x8000 && address < 0xc000))
{
if (DSP2.out_count)
{
t = (uint8) DSP2.output[DSP2.out_index];
DSP2.out_index++;
if (DSP2.out_count == DSP2.out_index)
DSP2.out_count = 0;
}
else
t = 0xff;
}
else
t = 0x80;
return (t);
}

File diff suppressed because it is too large Load Diff

2220
source/snes9x/dsp4.cpp Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,145 +172,154 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#ifndef _FONT_H_
#define _FONT_H_
static char *font[] = {
" . . . . .. . . ",
" .#. .#.#. . . ... .#. . . .##. .#. .#. . . . . ",
" .#. .#.#. .#.#. .###. .#..#. .#. .#. .#. .#. .#.#. .#. .#. ",
" .#. .#.#. .#####. .#.#. ..#. .#.#. .#. .#. .#. .#. ..#.. .... .#. ",
" .#. . . .#.#. .###. .#.. .#. . .#. .#. .###. .#####. .. .####. .. .#. ",
" . .#####. .#.#. .#..#. .#.#. .#. .#. .#. ..#.. .##. .... .##. .#. ",
" .#. .#.#. .###. . .#. .#.#. .#. .#. .#.#. .#. .#. .##. . ",
" . . . ... . . . . . . . . .#. .. ",
" . ",
" . . .. .... . .... .. .... .. .. . ",
" .#. .#. .##. .####. .#. .####. .##. .####. .##. .##. .. .. . . .#. ",
".#.#. .##. .#..#. ...#. .##. .#... .#.. ...#. .#..#. .#..#. .##. .##. .#. .... .#. .#.#. ",
".#.#. .#. . .#. .##. .#.#. .###. .###. .#. .##. .#..#. .##. .##. .#. .####. .#. ..#. ",
".#.#. .#. .#. ...#. .####. ...#. .#..#. .#. .#..#. .###. .. .. .#. .... .#. .#. ",
".#.#. .#. .#.. .#..#. ..#. .#..#. .#..#. .#. .#..#. ..#. .##. .##. .#. .####. .#. . ",
" .#. .###. .####. .##. .#. .##. .##. .#. .##. .##. .##. .#. .#. .... .#. .#. ",
" . ... .... .. . .. .. . .. .. .. .#. . . . ",
" . ",
" .. .. ... .. ... .... .... .. . . ... . . . . . . . . .. ",
" .##. .##. .###. .##. .###. .####. .####. .##. .#..#. .###. .#. .#..#. .#. .#. .#. .#. .#. .##. ",
".#..#. .#..#. .#..#. .#..#. .#..#. .#... .#... .#..#. .#..#. .#. .#. .#.#. .#. .##.##. .##..#. .#..#. ",
".#.##. .#..#. .###. .#. . .#..#. .###. .###. .#... .####. .#. .#. .##. .#. .#.#.#. .#.#.#. .#..#. ",
".#.##. .####. .#..#. .#. . .#..#. .#.. .#.. .#.##. .#..#. .#. . .#. .##. .#. .#...#. .#.#.#. .#..#. ",
".#... .#..#. .#..#. .#..#. .#..#. .#... .#. .#..#. .#..#. .#. .#..#. .#.#. .#... .#. .#. .#..##. .#..#. ",
" .##. .#..#. .###. .##. .###. .####. .#. .###. .#..#. .###. .##. .#..#. .####. .#. .#. .#. .#. .##. ",
" .. . . ... .. ... .... . ... . . ... .. . . .... . . . . .. ",
" ",
" ... .. ... .. ... . . . . . . . . . . .... ... ... . ",
".###. .##. .###. .##. .###. .#. .#. .#. .#. .#. .#. .#..#. .#.#. .####. .###. . .###. .#. ",
".#..#. .#..#. .#..#. .#..#. .#. .#. .#. .#. .#. .#...#. .#..#. .#.#. ...#. .#.. .#. ..#. .#.#. ",
".#..#. .#..#. .#..#. .#.. .#. .#. .#. .#. .#. .#.#.#. .##. .#.#. .#. .#. .#. .#. . . ",
".###. .#..#. .###. ..#. .#. .#. .#. .#. .#. .#.#.#. .#..#. .#. .#. .#. .#. .#. ",
".#.. .##.#. .#.#. .#..#. .#. .#...#. .#.#. .##.##. .#..#. .#. .#... .#.. .#. ..#. .... ",
".#. .##. .#..#. .##. .#. .###. .#. .#. .#. .#..#. .#. .####. .###. . .###. .####. ",
" . ..#. . . .. . ... . . . . . . .... ... ... .... ",
" . ",
" .. . . . . . . . .. ",
".##. .#. .#. .#. .#. .#. .#. .#. .##. ",
" .#. ... .#.. .. ..#. .. .#.#. ... .#.. .. . .#.. .#. .. .. ... .. ",
" .#. .###. .###. .##. .###. .##. .#.. .###. .###. .##. .#. .#.#. .#. .##.##. .###. .##. ",
" . .#..#. .#..#. .#.. .#..#. .#.##. .###. .#..#. .#..#. .#. .#. .##. .#. .#.#.#. .#..#. .#..#. ",
" .#.##. .#..#. .#.. .#..#. .##.. .#. .##. .#..#. .#. ..#. .#.#. .#. .#...#. .#..#. .#..#. ",
" .#.#. .###. .##. .###. .##. .#. .#... .#..#. .###. .#.#. .#..#. .###. .#. .#. .#..#. .##. ",
" . . ... .. ... .. . .###. . . ... .#. . . ... . . . . .. ",
" ... . ",
" . . . . . . ",
" .#. .#. .#. .#. .#.#. ",
" ... ... ... ... .#. . . . . . . . . . . .... .#. .#. .#. .#.#. ",
".###. .###. .###. .###. .###. .#..#. .#.#. .#...#. .#..#. .#..#. .####. .##. .#. .##. . . ",
".#..#. .#..#. .#..#. .##.. .#. .#..#. .#.#. .#.#.#. .##. .#..#. ..#. .#. .#. .#. ",
".#..#. .#..#. .#. . ..##. .#.. .#..#. .#.#. .#.#.#. .##. .#.#. .#.. .#. .#. .#. ",
".###. .###. .#. .###. .##. .###. .#. .#.#. .#..#. .#. .####. .#. .#. .#. ",
".#.. ..#. . ... .. ... . . . . . .#. .... . . . ",
" . . . ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
//2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678
" .. ..... ",
" .##. .#####. ... . . . . .. ",
" .#. . .. ....#. .###. .#. .#. .#. .#.. .##. . . . ",
" .#. .#. .##. .#####. .#. .#. .###. ... .###. .###. .. .#. .#.#.#. ",
" . .#. .#. . .##. ....#. .#. .##. .#.#. .###. .#. .##.#. .##. .##. .#.#.#. ",
" .#. . .#. .#. .. ...#. .#. .#. ..#. .#. .##. .#.. ..#. .#. ...#. ",
" .#.#. .##. .#. .###. .#. .#. .#. .###. .#. .#. .####. .##. .##. ",
" .#. .. .#. ... . . . ... . . .... .. .. ",
" . . ",
//2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678
" .... . . ... . . . .... . . . .. . ..... . . . ",
" .####. .#. ..#.. .###. ...#. ..#.. ..#.. .####. .#... .... .#.#. .##..#. .#####. .#... .#. .#. ",
" .... ...#. .#. .#####. .#. .#####. .#####. .#####. .#..#. .####. .####. .#####. .. .#. ....#. .#####. .#. .#. ",
".####. .##. .## .#...#. .#. ...#. ..#.#. ..#.. .# .#. .#..#. ...#. .#.#. .##..#. .#. .#..#. .#..#. ",
" .... .#. .#.# . .#. .#. .##. .#..#. .#####. .#. .#. . .#. .#. ..#. .. .#. .#. .#.#. . .#. ",
" .#. .#. ..#. ..#.. .#.#. .#..#. ..#.. . .#. .#. ...#. .#. ...#. .#.#. .#... ...#. ",
" .#. .#. .##. .#####. .#..#. .#..#. .#. .#. .#. .####. .#. .###. .#. .#. .###. .###. ",
" . . .. ..... . . . . . . . .... . ... . . ... ... ",
" ",
//2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678
" .... .. . . . ... . . ... .... . . . ..... . . ",
" .####. ..##. .#.#.#. .###. .#. ..#.. .###. .####. ..#.. .#. . . .#. .. .#####. .#. ..#.. ..... ",
" .#..#. .###. .#.#.#. ..... .#. .#####. ... ...#. .#####. .#. .#.#. .#..##. ....#. .#.#. .#####. .#####. ",
" .####. ..#. .#.#.#. .#####. .##. ..#.. .#.#. ....#. .#. .#.#. .###.. .#. .#..#. ..#.. .#. ",
".#...#. .####. . ..#. ..#.. .#.#. .#. .#. .###. .#. .#. .#. .#.. .#. . .#. .#.#.#. .#.#. ",
" . .#. ..#. ...#. .#. .#.. ..#. ..... .#.#. .#.#.#. .#. .#. .#. .#.... ..#. .#. .#.#.#. .#. ",
" .#. .##. .###. .#. .#. .##. .#####. .#. .#. ..#.. .#. .#. .#. .####. .##. .#. ..#.. .#. ",
" . .. ... . . .. ..... . . . . . . .... .. . . . ",
" ",
//2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678
" .. . . ... . .... .... . . . . . ..... . . . . ",
" .##. .#. .#. .###. .#... ... .####. .####. .#..#. .#.#. .#. ..... .#####. ....#. .#.#. .#. ",
" ..#. .#. . .#. .#. .#.##. .###. ...#. ..... .#..#. .#.#. .#. .#####. .#...#. .###.#. .#.#. .#.#. ",
" .##. .#. . .#.#. .#####. .##.#. .#. .###. .#####. .#..#. .#.#. .#. . .#...#. . .#. ....#. . . .#. ",
" ..#. .#..#. .##. ..#.. .#.#. ..#. ..#. ....#. . .#. .#.#. .#..#. .#...#. .#. .#. . ",
" .##. .####. ..#.#. .#.. .#. ...#. ...#. ..#. ..#. .#.#. .#.#. .#####. ..#. ...#. ",
" ..#. ...#. .##. . .###. .#. .#####. .####. .##. .##. .#..##. .##. .#...#. .##. .###. ",
" . . .. ... . ..... .... .. ... . .. .. . . .. ... ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "
static const char *font[] =
{
//2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678
" . . . . .. . . ",
" .#. .#.#. . . ... .#. . . .##. .#. .#. . . . . ",
" .#. .#.#. .#.#. .###. .#..#. .#. .#. .#. .#. .#.#. .#. .#. ",
" .#. .#.#. .#####. .#.#. ..#. .#.#. .#. .#. .#. .#. ..#.. .... .#. ",
" .#. . . .#.#. .###. .#.. .#. . .#. .#. .###. .#####. .. .####. .. .#. ",
" . .#####. .#.#. .#..#. .#.#. .#. .#. .#. ..#.. .##. .... .##. .#. ",
" .#. .#.#. .###. . .#. .#.#. .#. .#. .#.#. .#. .#. .##. . ",
" . . . ... . . . . . . . . .#. .. ",
" . ",
//2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678
" . . .. .... . .... .. .... .. .. . ",
" .#. .#. .##. .####. .#. .####. .##. .####. .##. .##. .. .. . . .#. ",
".#.#. .##. .#..#. ...#. .##. .#... .#.. ...#. .#..#. .#..#. .##. .##. .#. .... .#. .#.#. ",
".#.#. .#. . .#. .##. .#.#. .###. .###. .#. .##. .#..#. .##. .##. .#. .####. .#. ..#. ",
".#.#. .#. .#. ...#. .####. ...#. .#..#. .#. .#..#. .###. .. .. .#. .... .#. .#. ",
".#.#. .#. .#.. .#..#. ..#. .#..#. .#..#. .#. .#..#. ..#. .##. .##. .#. .####. .#. . ",
" .#. .###. .####. .##. .#. .##. .##. .#. .##. .##. .##. .#. .#. .... .#. .#. ",
" . ... .... .. . .. .. . .. .. .. .#. . . . ",
" . ",
//2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678
" .. .. ... .. ... .... .... .. . . ... . . . . . . . . .. ",
" .##. .##. .###. .##. .###. .####. .####. .##. .#..#. .###. .#. .#..#. .#. .#. .#. .#. .#. .##. ",
".#..#. .#..#. .#..#. .#..#. .#..#. .#... .#... .#..#. .#..#. .#. .#. .#.#. .#. .##.##. .##..#. .#..#. ",
".#.##. .#..#. .###. .#. . .#..#. .###. .###. .#... .####. .#. .#. .##. .#. .#.#.#. .#.#.#. .#..#. ",
".#.##. .####. .#..#. .#. . .#..#. .#.. .#.. .#.##. .#..#. .#. . .#. .##. .#. .#...#. .#.#.#. .#..#. ",
".#... .#..#. .#..#. .#..#. .#..#. .#... .#. .#..#. .#..#. .#. .#..#. .#.#. .#... .#. .#. .#..##. .#..#. ",
" .##. .#..#. .###. .##. .###. .####. .#. .###. .#..#. .###. .##. .#..#. .####. .#. .#. .#. .#. .##. ",
" .. . . ... .. ... .... . ... . . ... .. . . .... . . . . .. ",
" ",
//2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678
" ... .. ... .. ... . . . . . . . . . . .... ... ... . ",
".###. .##. .###. .##. .###. .#. .#. .#. .#. .#. .#. .#..#. .#.#. .####. .###. . .###. .#. ",
".#..#. .#..#. .#..#. .#..#. .#. .#. .#. .#. .#. .#...#. .#..#. .#.#. ...#. .#.. .#. ..#. .#.#. ",
".#..#. .#..#. .#..#. .#.. .#. .#. .#. .#. .#. .#.#.#. .##. .#.#. .#. .#. .#. .#. . . ",
".###. .#..#. .###. ..#. .#. .#. .#. .#. .#. .#.#.#. .#..#. .#. .#. .#. .#. .#. ",
".#.. .##.#. .#.#. .#..#. .#. .#...#. .#.#. .##.##. .#..#. .#. .#... .#.. .#. ..#. .... ",
".#. .##. .#..#. .##. .#. .###. .#. .#. .#. .#..#. .#. .####. .###. . .###. .####. ",
" . ..#. . . .. . ... . . . . . . .... ... ... .... ",
" . ",
//2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678
" .. . . . . . . . .. ",
".##. .#. .#. .#. .#. .#. .#. .#. .##. ",
" .#. ... .#.. .. ..#. .. .#.#. ... .#.. .. . .#.. .#. .. .. ... .. ",
" .#. .###. .###. .##. .###. .##. .#.. .###. .###. .##. .#. .#.#. .#. .##.##. .###. .##. ",
" . .#..#. .#..#. .#.. .#..#. .#.##. .###. .#..#. .#..#. .#. .#. .##. .#. .#.#.#. .#..#. .#..#. ",
" .#.##. .#..#. .#.. .#..#. .##.. .#. .##. .#..#. .#. ..#. .#.#. .#. .#...#. .#..#. .#..#. ",
" .#.#. .###. .##. .###. .##. .#. .#... .#..#. .###. .#.#. .#..#. .###. .#. .#. .#..#. .##. ",
" . . ... .. ... .. . .###. . . ... .#. . . ... . . . . .. ",
" ... . ",
//2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678
" . . . . . . ",
" .#. .#. .#. .#. .#.#. ",
" ... ... ... ... .#. . . . . . . . . . . .... .#. .#. .#. .#.#. ",
".###. .###. .###. .###. .###. .#..#. .#.#. .#...#. .#..#. .#..#. .####. .##. .#. .##. . . ",
".#..#. .#..#. .#..#. .##.. .#. .#..#. .#.#. .#.#.#. .##. .#..#. ..#. .#. .#. .#. ",
".#..#. .#..#. .#. . ..##. .#.. .#..#. .#.#. .#.#.#. .##. .#.#. .#.. .#. .#. .#. ",
".###. .###. .#. .###. .##. .###. .#. .#.#. .#..#. .#. .####. .#. .#. .#. ",
".#.. ..#. . ... .. ... . . . . . .#. .... . . . ",
" . . . ",
//2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
//2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
//2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678
" .. ..... ",
" .##. .#####. ... . . . . .. ",
" .#. . .. ....#. .###. .#. .#. .#. .#.. .##. . . . ",
" .#. .#. .##. .#####. .#. .#. .###. ... .###. .###. .. .#. .#.#.#. ",
" . .#. .#. . .##. ....#. .#. .##. .#.#. .###. .#. .##.#. .##. .##. .#.#.#. ",
" .#. . .#. .#. .. ...#. .#. .#. ..#. .#. .##. .#.. ..#. .#. ...#. ",
" .#.#. .##. .#. .###. .#. .#. .#. .###. .#. .#. .####. .##. .##. ",
" .#. .. .#. ... . . . ... . . .... .. .. ",
" . . ",
//2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678
" .... . . ... . . . .... . . . .. . ..... . . . ",
" .####. .#. ..#.. .###. ...#. ..#.. ..#.. .####. .#... .... .#.#. .##..#. .#####. .#... .#. .#. ",
" .... ...#. .#. .#####. .#. .#####. .#####. .#####. .#..#. .####. .####. .#####. .. .#. ....#. .#####. .#. .#. ",
".####. .##. .## .#...#. .#. ...#. ..#.#. ..#.. .# .#. .#..#. ...#. .#.#. .##..#. .#. .#..#. .#..#. ",
" .... .#. .#.# . .#. .#. .##. .#..#. .#####. .#. .#. . .#. .#. ..#. .. .#. .#. .#.#. . .#. ",
" .#. .#. ..#. ..#.. .#.#. .#..#. ..#.. . .#. .#. ...#. .#. ...#. .#.#. .#... ...#. ",
" .#. .#. .##. .#####. .#..#. .#..#. .#. .#. .#. .####. .#. .###. .#. .#. .###. .###. ",
" . . .. ..... . . . . . . . .... . ... . . ... ... ",
" ",
//2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678
" .... .. . . . ... . . ... .... . . . ..... . . ",
" .####. ..##. .#.#.#. .###. .#. ..#.. .###. .####. ..#.. .#. . . .#. .. .#####. .#. ..#.. ..... ",
" .#..#. .###. .#.#.#. ..... .#. .#####. ... ...#. .#####. .#. .#.#. .#..##. ....#. .#.#. .#####. .#####. ",
" .####. ..#. .#.#.#. .#####. .##. ..#.. .#.#. ....#. .#. .#.#. .###.. .#. .#..#. ..#.. .#. ",
".#...#. .####. . ..#. ..#.. .#.#. .#. .#. .###. .#. .#. .#. .#.. .#. . .#. .#.#.#. .#.#. ",
" . .#. ..#. ...#. .#. .#.. ..#. ..... .#.#. .#.#.#. .#. .#. .#. .#.... ..#. .#. .#.#.#. .#. ",
" .#. .##. .###. .#. .#. .##. .#####. .#. .#. ..#.. .#. .#. .#. .####. .##. .#. ..#.. .#. ",
" . .. ... . . .. ..... . . . . . . .... .. . . . ",
" ",
//2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678
" .. . . ... . .... .... . . . . . ..... . . . . ",
" .##. .#. .#. .###. .#... ... .####. .####. .#..#. .#.#. .#. ..... .#####. ....#. .#.#. .#. ",
" ..#. .#. . .#. .#. .#.##. .###. ...#. ..... .#..#. .#.#. .#. .#####. .#...#. .###.#. .#.#. .#.#. ",
" .##. .#. . .#.#. .#####. .##.#. .#. .###. .#####. .#..#. .#.#. .#. . .#...#. . .#. ....#. . . .#. ",
" ..#. .#..#. .##. ..#.. .#.#. ..#. ..#. ....#. . .#. .#.#. .#..#. .#...#. .#. .#. . ",
" .##. .####. ..#.#. .#.. .#. ...#. ...#. ..#. ..#. .#.#. .#.#. .#####. ..#. ...#. ",
" ..#. ...#. .##. . .###. .#. .#####. .####. .##. .##. .#..##. .##. .#...#. .##. .###. ",
" . . .. ... . ..... .... .. ... . .. .. . . .. ... ",
" ",
//2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
//2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "
};
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,79 +172,65 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#ifndef _FXEMU_H_
#define _FXEMU_H_ 1
#define _FXEMU_H_
#include "port.h"
#ifndef ZSNES_FX
/* The FxInfo_s structure, the link between the FxEmulator and the Snes Emulator */
struct FxInit_s
// The FxInfo_s structure, the link between the FxEmulator and the Snes Emulator
struct FxInfo_s
{
uint32 vFlags;
uint8 * pvRegisters; /* 768 bytes located in the memory at address 0x3000 */
uint32 nRamBanks; /* Number of 64kb-banks in GSU-RAM/BackupRAM (banks 0x70-0x73) */
uint8 * pvRam; /* Pointer to GSU-RAM */
uint32 nRomBanks; /* Number of 32kb-banks in Cart-ROM */
uint8 * pvRom; /* Pointer to Cart-ROM */
uint32 vFlags;
uint8 *pvRegisters; // 768 bytes located in the memory at address 0x3000
uint32 nRamBanks; // Number of 64kb-banks in GSU-RAM/BackupRAM (banks 0x70-0x73)
uint8 *pvRam; // Pointer to GSU-RAM
uint32 nRomBanks; // Number of 32kb-banks in Cart-ROM
uint8 *pvRom; // Pointer to Cart-ROM
uint32 speedPerLine;
bool8 oneLineDone;
};
/* Reset the FxChip */
extern void FxReset(struct FxInit_s *psFxInfo);
extern struct FxInfo_s SuperFX;
/* Execute until the next stop instruction */
extern int FxEmulate(uint32 nInstructions);
void S9xInitSuperFX (void);
void S9xSetSuperFX (uint8, uint16);
uint8 S9xGetSuperFX (uint16);
void fx_flushCache (void);
void fx_computeScreenPointers (void);
uint32 fx_run (uint32);
/* Write access to the cache */
extern void FxCacheWriteAccess(uint16 vAddress);
extern void FxFlushCache(); /* Callled when the G flag in SFR is set to zero */
#define FX_BREAKPOINT (-1)
#define FX_ERROR_ILLEGAL_ADDRESS (-2)
/* Breakpoint */
extern void FxBreakPointSet(uint32 vAddress);
extern void FxBreakPointClear();
#else
/* Step by step execution */
extern int FxStepOver(uint32 nInstructions);
#define S9xSetSuperFX S9xSuperFXWriteReg
#define S9xGetSuperFX S9xSuperFXReadReg
/* Errors */
extern int FxGetErrorCode();
extern int FxGetIllegalAddress();
START_EXTERN_C
extern uint8 *SFXPlotTable;
/* Access to internal registers */
extern uint32 FxGetColorRegister();
extern uint32 FxGetPlotOptionRegister();
extern uint32 FxGetSourceRegisterIndex();
extern uint32 FxGetDestinationRegisterIndex();
/* Get string for opcode currently in the pipe */
extern void FxPipeString(char * pvString);
/* Get the byte currently in the pipe */
extern uint8 FxPipe();
/* SCBR write seen. We need to update our cached screen pointers */
extern void fx_dirtySCBR (void);
/* Update RamBankReg and RAM Bank pointer */
extern void fx_updateRamBank(uint8 Byte);
/* Option flags */
#define FX_FLAG_ADDRESS_CHECKING 0x01
#define FX_FLAG_ROM_BUFFER 0x02
/* Return codes from FxEmulate(), FxStepInto() or FxStepOver() */
#define FX_BREAKPOINT -1
#define FX_ERROR_ILLEGAL_ADDRESS -2
/* Return the number of bytes in an opcode */
#define OPCODE_BYTES(op) ((((op)>=0x05&&(op)<=0xf)||((op)>=0xa0&&(op)<=0xaf))?2:(((op)>=0xf0)?3:1))
extern void fx_computeScreenPointers ();
void S9xSuperFXWriteReg (uint8, uint32);
uint8 S9xSuperFXReadReg (uint32);
void S9xSuperFXPreSaveState (void);
void S9xSuperFXPostSaveState (void);
void S9xSuperFXPostLoadState (void);
END_EXTERN_C
#endif
#ifdef ZSNES_FX
START_EXTERN_C
#endif
void S9xResetSuperFX (void);
void S9xSuperFXExec (void);
#ifdef ZSNES_FX
END_EXTERN_C
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,76 +172,77 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#ifndef _FXINST_H_
#define _FXINST_H_ 1
#define _FXINST_H_
#ifndef ZSNES_FX
/*
* FxChip(GSU) register space specification
* (Register address space 3000->32ff)
* (Register address space 3000-32ff)
*
* The 16 generic 16 bit registers:
* (Some have a special function in special circumstances)
* 3000 - R0 default source/destination register
* 3002 - R1 pixel plot X position register
* 3004 - R2 pixel plot Y position register
* 3000 - R0 default source/destination register
* 3002 - R1 pixel plot X position register
* 3004 - R2 pixel plot Y position register
* 3006 - R3
* 3008 - R4 lower 16 bit result of lmult
* 3008 - R4 lower 16 bit result of lmult
* 300a - R5
* 300c - R6 multiplier for fmult and lmult
* 300e - R7 fixed point texel X position for merge
* 3010 - R8 fixed point texel Y position for merge
* 300c - R6 multiplier for fmult and lmult
* 300e - R7 fixed point texel X position for merge
* 3010 - R8 fixed point texel Y position for merge
* 3012 - R9
* 3014 - R10
* 3016 - R11 return address set by link
* 3018 - R12 loop counter
* 301a - R13 loop point address
* 301c - R14 rom address for getb, getbh, getbl, getbs
* 301e - R15 program counter
* 3016 - R11 return address set by link
* 3018 - R12 loop counter
* 301a - R13 loop point address
* 301c - R14 rom address for getb, getbh, getbl, getbs
* 301e - R15 program counter
*
* 3020-302f - unused
* 3020-302f - unused
*
* Other internal registers
* 3030 - SFR status flag register (16bit)
* 3032 - unused
* 3033 - BRAMR Backup RAM register (8bit)
* 3034 - PBR program bank register (8bit)
* 3035 - unused
* 3036 - ROMBR rom bank register (8bit)
* 3037 - CFGR control flags register (8bit)
* 3038 - SCBR screen base register (8bit)
* 3039 - CLSR clock speed register (8bit)
* 303a - SCMR screen mode register (8bit)
* 303b - VCR version code register (8bit) (read only)
* 303c - RAMBR ram bank register (8bit)
* 303d - unused
* 303e - CBR cache base register (16bit)
* 3030 - SFR status flag register (16bit)
* 3032 - unused
* 3033 - BRAMR Backup RAM register (8bit)
* 3034 - PBR program bank register (8bit)
* 3035 - unused
* 3036 - ROMBR rom bank register (8bit)
* 3037 - CFGR control flags register (8bit)
* 3038 - SCBR screen base register (8bit)
* 3039 - CLSR clock speed register (8bit)
* 303a - SCMR screen mode register (8bit)
* 303b - VCR version code register (8bit) (read only)
* 303c - RAMBR ram bank register (8bit)
* 303d - unused
* 303e - CBR cache base register (16bit)
*
* 3040-30ff - unused
* 3040-30ff - unused
*
* 3100-32ff - CACHERAM 512 bytes of GSU cache memory
* 3100-32ff - CACHERAM 512 bytes of GSU cache memory
*
* SFR status flag register bits:
* 0 -
* 1 Z Zero flag
* 2 CY Carry flag
* 3 S Sign flag
* 4 OV Overflow flag
* 5 G Go flag (set to 1 when the GSU is running)
* 6 R Set to 1 when reading ROM using R14 address
* 1 Z Zero flag
* 2 CY Carry flag
* 3 S Sign flag
* 4 OV Overflow flag
* 5 G Go flag (set to 1 when the GSU is running)
* 6 R Set to 1 when reading ROM using R14 address
* 7 -
* 8 ALT1 Mode set-up flag for the next instruction
* 9 ALT2 Mode set-up flag for the next instruction
* 10 IL Immediate lower 8-bit flag
* 11 IH Immediate higher 8-bit flag
* 12 B Set to 1 when the WITH instruction is executed
* 8 ALT1 Mode set-up flag for the next instruction
* 9 ALT2 Mode set-up flag for the next instruction
* 10 IL Immediate lower 8-bit flag
* 11 IH Immediate higher 8-bit flag
* 12 B Set to 1 when the WITH instruction is executed
* 13 -
* 14 -
* 15 IRQ Set to 1 when GSU caused an interrupt
* Set to 0 when read by 658c16
* 15 IRQ Set to 1 when GSU caused an interrupt
* Set to 0 when read by 658c16
*
* BRAMR = 0, BackupRAM is disabled
* BRAMR = 1, BackupRAM is enabled
@ -236,44 +253,44 @@
* 2 -
* 3 -
* 4 -
* 5 MS0 Multiplier speed, 0=standard, 1=high speed
* 5 MS0 Multiplier speed, 0=standard, 1=high speed
* 6 -
* 7 IRQ Set to 1 when GSU interrupt request is masked
* 7 IRQ Set to 1 when GSU interrupt request is masked
*
* CLSR clock speed register bits:
* 0 CLSR clock speed, 0 = 10.7Mhz, 1 = 21.4Mhz
* 0 CLSR clock speed, 0 = 10.7Mhz, 1 = 21.4Mhz
*
* SCMR screen mode register bits:
* 0 MD0 color depth mode bit 0
* 1 MD1 color depth mode bit 1
* 2 HT0 screen height bit 1
* 3 RAN RAM access control
* 4 RON ROM access control
* 5 HT1 screen height bit 2
* 0 MD0 color depth mode bit 0
* 1 MD1 color depth mode bit 1
* 2 HT0 screen height bit 1
* 3 RAN RAM access control
* 4 RON ROM access control
* 5 HT1 screen height bit 2
* 6 -
* 7 -
*
* RON = 0 SNES CPU has ROM access
* RON = 1 GSU has ROM access
* RON = 0 SNES CPU has ROM access
* RON = 1 GSU has ROM access
*
* RAN = 0 SNES has game pak RAM access
* RAN = 1 GSU has game pak RAM access
* RAN = 0 SNES has game pak RAM access
* RAN = 1 GSU has game pak RAM access
*
* HT1 HT0 Screen height mode
* 0 0 128 pixels high
* 0 1 160 pixels high
* 1 0 192 pixels high
* 1 1 OBJ mode
* HT1 HT0 Screen height mode
* 0 0 128 pixels high
* 0 1 160 pixels high
* 1 0 192 pixels high
* 1 1 OBJ mode
*
* MD1 MD0 Color depth mode
* 0 0 4 color mode
* 0 1 16 color mode
* 1 0 not used
* 1 1 256 color mode
* MD1 MD0 Color depth mode
* 0 0 4 color mode
* 0 1 16 color mode
* 1 0 not used
* 1 1 256 color mode
*
* CBR cache base register bits:
* 15-4 Specify base address for data to cache from ROM or RAM
* 3-0 Are 0 when address is read
* 15-4 Specify base address for data to cache from ROM or RAM
* 3-0 Are 0 when address is read
*
* Write access to the program counter (301e) from
* the SNES-CPU will start the GSU, and it will not
@ -281,270 +298,249 @@
*
*/
/* Number of banks in GSU RAM */
#define FX_RAM_BANKS 4
// Number of banks in GSU RAM
#define FX_RAM_BANKS 4
/* Emulate proper R14 ROM access (slower, but safer) */
/* #define FX_DO_ROMBUFFER */
// Emulate proper R14 ROM access (slower, but safer)
#define FX_DO_ROMBUFFER
/* Address checking (definately slow) */
/* #define FX_ADDRESS_CHECK */
// Address checking (definately slow)
//#define FX_ADDRESS_CHECK
struct FxRegs_s
{
/* FxChip registers */
uint32 avReg[16]; /* 16 Generic registers */
uint32 vColorReg; /* Internal color register */
uint32 vPlotOptionReg; /* Plot option register */
uint32 vStatusReg; /* Status register */
uint32 vPrgBankReg; /* Program bank index register */
uint32 vRomBankReg; /* Rom bank index register */
uint32 vRamBankReg; /* Ram bank index register */
uint32 vCacheBaseReg; /* Cache base address register */
uint32 vCacheFlags; /* Saying what parts of the cache was written to */
uint32 vLastRamAdr; /* Last RAM address accessed */
uint32 * pvDreg; /* Pointer to current destination register */
uint32 * pvSreg; /* Pointer to current source register */
uint8 vRomBuffer; /* Current byte read by R14 */
uint8 vPipe; /* Instructionset pipe */
uint32 vPipeAdr; /* The address of where the pipe was read from */
// FxChip registers
uint32 avReg[16]; // 16 Generic registers
uint32 vColorReg; // Internal color register
uint32 vPlotOptionReg; // Plot option register
uint32 vStatusReg; // Status register
uint32 vPrgBankReg; // Program bank index register
uint32 vRomBankReg; // Rom bank index register
uint32 vRamBankReg; // Ram bank index register
uint32 vCacheBaseReg; // Cache base address register
uint32 vCacheFlags; // Saying what parts of the cache was written to
uint32 vLastRamAdr; // Last RAM address accessed
uint32 *pvDreg; // Pointer to current destination register
uint32 *pvSreg; // Pointer to current source register
uint8 vRomBuffer; // Current byte read by R14
uint8 vPipe; // Instructionset pipe
uint32 vPipeAdr; // The address of where the pipe was read from
/* status register optimization stuff */
uint32 vSign; /* v & 0x8000 */
uint32 vZero; /* v == 0 */
uint32 vCarry; /* a value of 1 or 0 */
int32 vOverflow; /* (v >= 0x8000 || v < -0x8000) */
// Status register optimization stuff
uint32 vSign; // v & 0x8000
uint32 vZero; // v == 0
uint32 vCarry; // a value of 1 or 0
int32 vOverflow; // (v >= 0x8000 || v < -0x8000)
/* Other emulator variables */
// Other emulator variables
int32 vErrorCode;
uint32 vIllegalAddress;
int32 vErrorCode;
uint32 vIllegalAddress;
uint8 bBreakPoint;
uint32 vBreakPoint;
uint32 vStepPoint;
uint8 bBreakPoint;
uint32 vBreakPoint;
uint32 vStepPoint;
uint8 *pvRegisters; // 768 bytes located in the memory at address 0x3000
uint32 nRamBanks; // Number of 64kb-banks in FxRam (Don't confuse it with SNES-Ram!!!)
uint8 *pvRam; // Pointer to FxRam
uint32 nRomBanks; // Number of 32kb-banks in Cart-ROM
uint8 *pvRom; // Pointer to Cart-ROM
uint8 * pvRegisters; /* 768 bytes located in the memory at address 0x3000 */
uint32 nRamBanks; /* Number of 64kb-banks in FxRam (Don't confuse it with SNES-Ram!!!) */
uint8 * pvRam; /* Pointer to FxRam */
uint32 nRomBanks; /* Number of 32kb-banks in Cart-ROM */
uint8 * pvRom; /* Pointer to Cart-ROM */
uint32 vMode; // Color depth/mode
uint32 vPrevMode; // Previous depth
uint8 *pvScreenBase;
uint8 *apvScreen[32]; // Pointer to each of the 32 screen colums
int32 x[32];
uint32 vScreenHeight; // 128, 160, 192 or 256 (could be overriden by cmode)
uint32 vScreenRealHeight; // 128, 160, 192 or 256
uint32 vPrevScreenHeight;
uint32 vScreenSize;
void (*pfPlot) (void);
void (*pfRpix) (void);
uint32 vMode; /* Color depth/mode */
uint32 vPrevMode; /* Previous depth */
uint8 * pvScreenBase;
uint8 * apvScreen[32]; /* Pointer to each of the 32 screen colums */
int32 x[32];
uint32 vScreenHeight; /* 128, 160, 192 or 256 (could be overriden by cmode) */
uint32 vScreenRealHeight; /* 128, 160, 192 or 256 */
uint32 vPrevScreenHeight;
uint32 vScreenSize;
void (*pfPlot)();
void (*pfRpix)();
uint8 *pvRamBank; // Pointer to current RAM-bank
uint8 *pvRomBank; // Pointer to current ROM-bank
uint8 *pvPrgBank; // Pointer to current program ROM-bank
uint8 * pvRamBank; /* Pointer to current RAM-bank */
uint8 * pvRomBank; /* Pointer to current ROM-bank */
uint8 * pvPrgBank; /* Pointer to current program ROM-bank */
uint8 *apvRamBank[FX_RAM_BANKS]; // Ram bank table (max 256kb)
uint8 *apvRomBank[256]; // Rom bank table
uint8 * apvRamBank[FX_RAM_BANKS];/* Ram bank table (max 256kb) */
uint8 * apvRomBank[256]; /* Rom bank table */
uint8 bCacheActive;
uint8 *pvCache; // Pointer to the GSU cache
uint8 avCacheBackup[512]; // Backup of ROM when the cache has replaced it
uint32 vCounter;
uint32 vInstCount;
uint32 vSCBRDirty; // If SCBR is written, our cached screen pointers need updating
uint8 bCacheActive;
uint8 * pvCache; /* Pointer to the GSU cache */
uint8 avCacheBackup[512]; /* Backup of ROM when the cache has replaced it */
uint32 vCounter;
uint32 vInstCount;
uint32 vSCBRDirty; /* if SCBR is written, our cached screen pointers need updating */
uint8 *avRegAddr; // To reference avReg in snapshot.cpp
};
#define FxRegs_s_null { \
{0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, \
0, 0, 0, 0, NULL, 0, NULL, 0, NULL, 0, \
0, NULL, {NULL}, {0}, 0, 0, 0, 0, NULL, NULL, \
NULL, NULL, NULL, {NULL}, {NULL}, 0, NULL, {0}, 0, 0, \
0, \
}
extern struct FxRegs_s GSU;
/* GSU registers */
#define GSU_R0 0x000
#define GSU_R1 0x002
#define GSU_R2 0x004
#define GSU_R3 0x006
#define GSU_R4 0x008
#define GSU_R5 0x00a
#define GSU_R6 0x00c
#define GSU_R7 0x00e
#define GSU_R8 0x010
#define GSU_R9 0x012
#define GSU_R10 0x014
#define GSU_R11 0x016
#define GSU_R12 0x018
#define GSU_R13 0x01a
#define GSU_R14 0x01c
#define GSU_R15 0x01e
#define GSU_SFR 0x030
#define GSU_BRAMR 0x033
#define GSU_PBR 0x034
#define GSU_ROMBR 0x036
#define GSU_CFGR 0x037
#define GSU_SCBR 0x038
#define GSU_CLSR 0x039
#define GSU_SCMR 0x03a
#define GSU_VCR 0x03b
#define GSU_RAMBR 0x03c
#define GSU_CBR 0x03e
#define GSU_CACHERAM 0x100
// GSU registers
#define GSU_R0 0x000
#define GSU_R1 0x002
#define GSU_R2 0x004
#define GSU_R3 0x006
#define GSU_R4 0x008
#define GSU_R5 0x00a
#define GSU_R6 0x00c
#define GSU_R7 0x00e
#define GSU_R8 0x010
#define GSU_R9 0x012
#define GSU_R10 0x014
#define GSU_R11 0x016
#define GSU_R12 0x018
#define GSU_R13 0x01a
#define GSU_R14 0x01c
#define GSU_R15 0x01e
#define GSU_SFR 0x030
#define GSU_BRAMR 0x033
#define GSU_PBR 0x034
#define GSU_ROMBR 0x036
#define GSU_CFGR 0x037
#define GSU_SCBR 0x038
#define GSU_CLSR 0x039
#define GSU_SCMR 0x03a
#define GSU_VCR 0x03b
#define GSU_RAMBR 0x03c
#define GSU_CBR 0x03e
#define GSU_CACHERAM 0x100
/* SFR flags */
#define FLG_Z (1<<1)
#define FLG_CY (1<<2)
#define FLG_S (1<<3)
#define FLG_OV (1<<4)
#define FLG_G (1<<5)
#define FLG_R (1<<6)
#define FLG_ALT1 (1<<8)
#define FLG_ALT2 (1<<9)
#define FLG_IL (1<<10)
#define FLG_IH (1<<11)
#define FLG_B (1<<12)
#define FLG_IRQ (1<<15)
// SFR flags
#define FLG_Z (1 << 1)
#define FLG_CY (1 << 2)
#define FLG_S (1 << 3)
#define FLG_OV (1 << 4)
#define FLG_G (1 << 5)
#define FLG_R (1 << 6)
#define FLG_ALT1 (1 << 8)
#define FLG_ALT2 (1 << 9)
#define FLG_IL (1 << 10)
#define FLG_IH (1 << 11)
#define FLG_B (1 << 12)
#define FLG_IRQ (1 << 15)
/* Test flag */
#define TF(a) (GSU.vStatusReg & FLG_##a )
#define CF(a) (GSU.vStatusReg &= ~FLG_##a )
#define SF(a) (GSU.vStatusReg |= FLG_##a )
// Test flag
#define TF(a) (GSU.vStatusReg & FLG_##a)
#define CF(a) (GSU.vStatusReg &= ~FLG_##a)
#define SF(a) (GSU.vStatusReg |= FLG_##a)
/* Test and set flag if condition, clear if not */
#define TS(a,b) GSU.vStatusReg = ( (GSU.vStatusReg & (~FLG_##a)) | ( (!!(##b)) * FLG_##a ) )
// Test and set flag if condition, clear if not
#define TS(a, b) GSU.vStatusReg = ((GSU.vStatusReg & (~FLG_##a)) | ((!!(##b)) * FLG_##a))
/* Testing ALT1 & ALT2 bits */
#define ALT0 (!TF(ALT1)&&!TF(ALT2))
#define ALT1 (TF(ALT1)&&!TF(ALT2))
#define ALT2 (!TF(ALT1)&&TF(ALT2))
#define ALT3 (TF(ALT1)&&TF(ALT2))
// Testing ALT1 & ALT2 bits
#define ALT0 (!TF(ALT1) && !TF(ALT2))
#define ALT1 ( TF(ALT1) && !TF(ALT2))
#define ALT2 (!TF(ALT1) && TF(ALT2))
#define ALT3 ( TF(ALT1) && TF(ALT2))
/* Sign extend from 8/16 bit to 32 bit */
#define SEX16(a) ((int32)((int16)(a)))
#define SEX8(a) ((int32)((int8)(a)))
// Sign extend from 8/16 bit to 32 bit
#define SEX8(a) ((int32) ((int8) (a)))
#define SEX16(a) ((int32) ((int16) (a)))
/* Unsign extend from 8/16 bit to 32 bit */
#define USEX16(a) ((uint32)((uint16)(a)))
#define USEX8(a) ((uint32)((uint8)(a)))
// Unsign extend from 8/16 bit to 32 bit
#define USEX8(a) ((uint32) ((uint8) (a)))
#define USEX16(a) ((uint32) ((uint16) (a)))
#define SUSEX16(a) ((int32) ((uint16) (a)))
#define SUSEX16(a) ((int32)((uint16)(a)))
// Set/Clr Sign and Zero flag
#define TSZ(num) TS(S, ((num) & 0x8000)); TS(Z, (!USEX16(num)))
/* Set/Clr Sign and Zero flag */
#define TSZ(num) TS(S, (num & 0x8000)); TS(Z, (!USEX16(num)) )
// Clear flags
#define CLRFLAGS GSU.vStatusReg &= ~(FLG_ALT1 | FLG_ALT2 | FLG_B); GSU.pvDreg = GSU.pvSreg = &R0
/* Clear flags */
#define CLRFLAGS GSU.vStatusReg &= ~(FLG_ALT1|FLG_ALT2|FLG_B); GSU.pvDreg = GSU.pvSreg = &R0;
// Read current RAM-Bank
#define RAM(adr) GSU.pvRamBank[USEX16(adr)]
/* Read current RAM-Bank */
#define RAM(adr) GSU.pvRamBank[USEX16(adr)]
// Read current ROM-Bank
#define ROM(idx) GSU.pvRomBank[USEX16(idx)]
/* Read current ROM-Bank */
#define ROM(idx) (GSU.pvRomBank[USEX16(idx)])
// Access the current value in the pipe
#define PIPE GSU.vPipe
/* Access the current value in the pipe */
#define PIPE GSU.vPipe
// Access data in the current program bank
#define PRGBANK(idx) GSU.pvPrgBank[USEX16(idx)]
/* Access data in the current program bank */
#define PRGBANK(idx) GSU.pvPrgBank[USEX16(idx)]
/* Update pipe from ROM */
// Update pipe from ROM
#if 0
#define FETCHPIPE { PIPE = PRGBANK(R15); GSU.vPipeAdr = (GSU.vPrgBankReg<<16) + R15; }
#define FETCHPIPE { PIPE = PRGBANK(R15); GSU.vPipeAdr = (GSU.vPrgBankReg << 16) + R15; }
#else
#define FETCHPIPE { PIPE = PRGBANK(R15); }
#define FETCHPIPE { PIPE = PRGBANK(R15); }
#endif
/* ABS */
#define ABS(x) ((x)<0?-(x):(x))
// ABS
#define ABS(x) ((x) < 0 ? -(x) : (x))
/* Access source register */
#define SREG (*GSU.pvSreg)
// Access source register
#define SREG (*GSU.pvSreg)
/* Access destination register */
#define DREG (*GSU.pvDreg)
// Access destination register
#define DREG (*GSU.pvDreg)
#ifndef FX_DO_ROMBUFFER
/* Don't read R14 */
// Don't read R14
#define READR14
/* Don't test and/or read R14 */
// Don't test and/or read R14
#define TESTR14
#else
/* Read R14 */
#define READR14 GSU.vRomBuffer = ROM(R14)
// Read R14
#define READR14 GSU.vRomBuffer = ROM(R14)
/* Test and/or read R14 */
#define TESTR14 if(GSU.pvDreg == &R14) READR14
// Test and/or read R14
#define TESTR14 if (GSU.pvDreg == &R14) READR14
#endif
/* Access to registers */
#define R0 GSU.avReg[0]
#define R1 GSU.avReg[1]
#define R2 GSU.avReg[2]
#define R3 GSU.avReg[3]
#define R4 GSU.avReg[4]
#define R5 GSU.avReg[5]
#define R6 GSU.avReg[6]
#define R7 GSU.avReg[7]
#define R8 GSU.avReg[8]
#define R9 GSU.avReg[9]
#define R10 GSU.avReg[10]
#define R11 GSU.avReg[11]
#define R12 GSU.avReg[12]
#define R13 GSU.avReg[13]
#define R14 GSU.avReg[14]
#define R15 GSU.avReg[15]
#define SFR GSU.vStatusReg
#define PBR GSU.vPrgBankReg
#define ROMBR GSU.vRomBankReg
#define RAMBR GSU.vRamBankReg
#define CBR GSU.vCacheBaseReg
#define SCBR USEX8(GSU.pvRegisters[GSU_SCBR])
#define SCMR USEX8(GSU.pvRegisters[GSU_SCMR])
#define COLR GSU.vColorReg
#define POR GSU.vPlotOptionReg
#define BRAMR USEX8(GSU.pvRegisters[GSU_BRAMR])
#define VCR USEX8(GSU.pvRegisters[GSU_VCR])
#define CFGR USEX8(GSU.pvRegisters[GSU_CFGR])
#define CLSR USEX8(GSU.pvRegisters[GSU_CLSR])
// Access to registers
#define R0 GSU.avReg[0]
#define R1 GSU.avReg[1]
#define R2 GSU.avReg[2]
#define R3 GSU.avReg[3]
#define R4 GSU.avReg[4]
#define R5 GSU.avReg[5]
#define R6 GSU.avReg[6]
#define R7 GSU.avReg[7]
#define R8 GSU.avReg[8]
#define R9 GSU.avReg[9]
#define R10 GSU.avReg[10]
#define R11 GSU.avReg[11]
#define R12 GSU.avReg[12]
#define R13 GSU.avReg[13]
#define R14 GSU.avReg[14]
#define R15 GSU.avReg[15]
#define SFR GSU.vStatusReg
#define PBR GSU.vPrgBankReg
#define ROMBR GSU.vRomBankReg
#define RAMBR GSU.vRamBankReg
#define CBR GSU.vCacheBaseReg
#define SCBR USEX8(GSU.pvRegisters[GSU_SCBR])
#define SCMR USEX8(GSU.pvRegisters[GSU_SCMR])
#define COLR GSU.vColorReg
#define POR GSU.vPlotOptionReg
#define BRAMR USEX8(GSU.pvRegisters[GSU_BRAMR])
#define VCR USEX8(GSU.pvRegisters[GSU_VCR])
#define CFGR USEX8(GSU.pvRegisters[GSU_CFGR])
#define CLSR USEX8(GSU.pvRegisters[GSU_CLSR])
/* Execute instruction from the pipe, and fetch next byte to the pipe */
#define FX_STEP { uint32 vOpcode = (uint32)PIPE; FETCHPIPE; \
(*fx_ppfOpcodeTable[ (GSU.vStatusReg & 0x300) | vOpcode ])(); } \
// Execute instruction from the pipe, and fetch next byte to the pipe
#define FX_STEP \
{ \
uint32 vOpcode = (uint32) PIPE; \
FETCHPIPE; \
(*fx_OpcodeTable[(GSU.vStatusReg & 0x300) | vOpcode])(); \
}
#define FX_FUNCTION_RUN 0
#define FX_FUNCTION_RUN_TO_BREAKPOINT 1
#define FX_FUNCTION_STEP_OVER 2
extern void (*fx_PlotTable[]) (void);
extern void (*fx_OpcodeTable[]) (void);
extern uint32 (**fx_ppfFunctionTable)(uint32);
extern void (**fx_ppfPlotTable)();
extern void (**fx_ppfOpcodeTable)();
extern uint32 (*fx_apfFunctionTable[])(uint32);
extern void (*fx_apfOpcodeTable[])();
extern void (*fx_apfPlotTable[])();
extern uint32 (*fx_a_apfFunctionTable[])(uint32);
extern void (*fx_a_apfOpcodeTable[])();
extern void (*fx_a_apfPlotTable[])();
extern uint32 (*fx_r_apfFunctionTable[])(uint32);
extern void (*fx_r_apfOpcodeTable[])();
extern void (*fx_r_apfPlotTable[])();
extern uint32 (*fx_ar_apfFunctionTable[])(uint32);
extern void (*fx_ar_apfOpcodeTable[])();
extern void (*fx_ar_apfPlotTable[])();
/* Set this define if branches are relative to the instruction in the delay slot */
/* (I think they are) */
// Set this define if branches are relative to the instruction in the delay slot (I think they are)
#define BRANCH_DELAY_RELATIVE
#endif
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,180 +172,153 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#ifndef _GFX_H_
#define _GFX_H_
#include "port.h"
#include "snes9x.h"
struct SGFX
{
uint16 *Screen;
uint16 *SubScreen;
uint8 *ZBuffer;
uint8 *SubZBuffer;
uint32 Pitch;
uint32 ScreenSize;
uint16 *S;
uint8 *DB;
uint16 *X2;
uint16 *ZERO;
uint32 RealPPL; // true PPL of Screen buffer
uint32 PPL; // number of pixels on each of Screen buffer
uint32 LinesPerTile; // number of lines in 1 tile (4 or 8 due to interlace)
uint16 *ScreenColors; // screen colors for rendering main
uint16 *RealScreenColors; // screen colors, ignoring color window clipping
uint8 Z1; // depth for comparison
uint8 Z2; // depth to save
uint32 FixedColour;
uint8 DoInterlace;
uint8 InterlaceFrame;
uint32 StartY;
uint32 EndY;
bool8 ClipColors;
uint8 OBJWidths[128];
uint8 OBJVisibleTiles[128];
struct SGFX{
// Initialize these variables
uint16 *Screen;
uint16 *SubScreen;
uint8 *ZBuffer;
uint8 *SubZBuffer;
uint32 Pitch;
uint32 ScreenSize;
struct ClipData *Clip;
uint16 *S;
uint8 *DB;
struct
{
uint8 RTOFlags;
int16 Tiles;
// Setup in call to S9xGraphicsInit()
uint16 *X2;
uint16 *ZERO_OR_X2;
uint16 *ZERO;
uint32 RealPPL; // True PPL of Screen buffer.
uint32 PPL; // Number of pixels on each of Screen buffer
uint32 LinesPerTile; // number of lines in 1 tile (4 or 8 due to interlace)
uint16 *ScreenColors; // Screen colors for rendering main
uint16 *RealScreenColors; // Screen colors, ignoring color window clipping
uint8 Z1; // Depth for comparison
uint8 Z2; // Depth to save
uint32 FixedColour;
const char *InfoString;
uint32 InfoStringTimeout;
char FrameDisplayString[256];
bool8 FrameDisplay;
bool8 Repainting; // True if the frame is being re-drawn
uint8 DoInterlace;
uint8 InterlaceFrame;
uint32 StartY;
uint32 EndY;
struct ClipData *Clip;
bool8 ClipColors;
uint8 OBJWidths[128];
uint8 OBJVisibleTiles[128];
struct {
uint8 RTOFlags;
int16 Tiles;
struct {
int8 Sprite;
uint8 Line;
} OBJ[32];
} OBJLines [SNES_HEIGHT_EXTENDED];
struct
{
int8 Sprite;
uint8 Line;
} OBJ[32];
} OBJLines[SNES_HEIGHT_EXTENDED];
#ifdef GFX_MULTI_FORMAT
uint32 PixelFormat;
uint32 (*BuildPixel) (uint32 R, uint32 G, uint32 B);
uint32 (*BuildPixel2) (uint32 R, uint32 G, uint32 B);
void (*DecomposePixel) (uint32 Pixel, uint32 &R, uint32 &G, uint32 &B);
uint32 PixelFormat;
uint32 (*BuildPixel) (uint32, uint32, uint32);
uint32 (*BuildPixel2) (uint32, uint32, uint32);
void (*DecomposePixel) (uint32, uint32 &, uint32 &, uint32 &);
#endif
void (*DrawBackdropMath)(uint32,uint32,uint32);
void (*DrawBackdropNomath)(uint32,uint32,uint32);
void (*DrawTileMath)(uint32,uint32,uint32,uint32);
void (*DrawTileNomath)(uint32,uint32,uint32,uint32);
void (*DrawClippedTileMath)(uint32,uint32,uint32,uint32,uint32,uint32);
void (*DrawClippedTileNomath)(uint32,uint32,uint32,uint32,uint32,uint32);
void (*DrawMosaicPixelMath)(uint32,uint32,uint32,uint32,uint32,uint32);
void (*DrawMosaicPixelNomath)(uint32,uint32,uint32,uint32,uint32,uint32);
void (*DrawMode7BG1Math)(uint32,uint32,int);
void (*DrawMode7BG1Nomath)(uint32,uint32,int);
void (*DrawMode7BG2Math)(uint32,uint32,int);
void (*DrawMode7BG2Nomath)(uint32,uint32,int);
void (*DrawBackdropMath) (uint32, uint32, uint32);
void (*DrawBackdropNomath) (uint32, uint32, uint32);
void (*DrawTileMath) (uint32, uint32, uint32, uint32);
void (*DrawTileNomath) (uint32, uint32, uint32, uint32);
void (*DrawClippedTileMath) (uint32, uint32, uint32, uint32, uint32, uint32);
void (*DrawClippedTileNomath) (uint32, uint32, uint32, uint32, uint32, uint32);
void (*DrawMosaicPixelMath) (uint32, uint32, uint32, uint32, uint32, uint32);
void (*DrawMosaicPixelNomath) (uint32, uint32, uint32, uint32, uint32, uint32);
void (*DrawMode7BG1Math) (uint32, uint32, int);
void (*DrawMode7BG1Nomath) (uint32, uint32, int);
void (*DrawMode7BG2Math) (uint32, uint32, int);
void (*DrawMode7BG2Nomath) (uint32, uint32, int);
const char *InfoString;
uint32 InfoStringTimeout;
char FrameDisplayString[256];
};
struct SLineData {
struct {
uint16 VOffset;
uint16 HOffset;
} BG [4];
struct SBG
{
uint8 (*ConvertTile) (uint8 *, uint32, uint32);
uint8 (*ConvertTileFlip) (uint8 *, uint32, uint32);
uint32 TileSizeH;
uint32 TileSizeV;
uint32 OffsetSizeH;
uint32 OffsetSizeV;
uint32 TileShift;
uint32 TileAddress;
uint32 NameSelect;
uint32 SCBase;
uint32 StartPalette;
uint32 PaletteShift;
uint32 PaletteMask;
uint8 EnableMath;
uint8 InterlaceLine;
uint8 *Buffer;
uint8 *BufferFlip;
uint8 *Buffered;
uint8 *BufferedFlip;
bool8 DirectColourMode;
};
#define H_FLIP 0x4000
#define V_FLIP 0x8000
#define BLANK_TILE 2
struct SBG {
uint8 (*ConvertTile)(uint8 *,uint32,uint32);
uint8 (*ConvertTileFlip)(uint8 *,uint32,uint32);
uint32 TileSizeH;
uint32 TileSizeV;
uint32 OffsetSizeH;
uint32 OffsetSizeV;
uint32 TileShift;
uint32 TileAddress;
uint32 NameSelect;
uint32 SCBase;
uint32 StartPalette;
uint32 PaletteShift;
uint32 PaletteMask;
uint8 EnableMath;
uint8 InterlaceLine;
uint8 *Buffer, *BufferFlip;
uint8 *Buffered, *BufferedFlip;
bool8 DirectColourMode;
struct SLineData
{
struct
{
uint16 VOffset;
uint16 HOffset;
} BG[4];
};
struct SLineMatrixData
{
short MatrixA;
short MatrixB;
short MatrixC;
short MatrixD;
short CentreX;
short CentreY;
short M7HOFS;
short M7VOFS;
short MatrixA;
short MatrixB;
short MatrixC;
short MatrixD;
short CentreX;
short CentreY;
short M7HOFS;
short M7VOFS;
};
extern SBG BG;
extern uint16 BlackColourMap [256];
extern uint16 DirectColourMaps [8][256];
extern uint16 BlackColourMap[256];
extern uint16 DirectColourMaps[8][256];
extern uint8 mul_brightness[16][32];
extern struct SBG BG;
extern struct SGFX GFX;
extern uint8 add32_32 [32][32];
extern uint8 add32_32_half [32][32];
extern uint8 sub32_32 [32][32];
extern uint8 sub32_32_half [32][32];
extern uint8 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 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
#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)] | \
(((C1) ^ (C2)) & RGB_LOW_BITS_MASK))
#endif
#define H_FLIP 0x4000
#define V_FLIP 0x8000
#define BLANK_TILE 2
#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)
((((((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 COLOR_SUB(uint16, uint16);
#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)] | \
(((C1) ^ (C2)) & RGB_LOW_BITS_MASK))
inline uint16 COLOR_SUB(uint16 C1, uint16 C2)
#define COLOR_SUB1_2(C1, C2) \
GFX.ZERO[(((C1) | RGB_HI_BITS_MASKx2) - \
((C2) & RGB_REMOVE_LOW_BITS_MASK)) >> 1]
inline uint16 COLOR_SUB (uint16 C1, uint16 C2)
{
uint16 mC1, mC2, v = ALPHA_BITS_MASK;
@ -345,44 +334,33 @@ inline uint16 COLOR_SUB(uint16 C1, uint16 C2)
mC2 = C2 & THIRD_COLOR_MASK;
if (mC1 > mC2) v += (mC1 - mC2);
return v;
return (v);
}
#endif
#define COLOR_SUB1_2(C1, C2) \
GFX.ZERO [(((C1) | RGB_HI_BITS_MASKx2) - \
((C2) & RGB_REMOVE_LOW_BITS_MASK)) >> 1]
START_EXTERN_C
void S9xStartScreenRefresh ();
void S9xDrawScanLine (uint8 Line);
void S9xEndScreenRefresh ();
void S9xSetupOBJ ();
void S9xUpdateScreen ();
void RenderLine (uint8 line);
void S9xBuildDirectColourMaps ();
void S9xDisplayMessages (uint16 *screen, int ppl, int width, int height, int scale); // called automatically unless Settings.AutoDisplayMessages is false
extern struct SGFX GFX;
// External port interface which must be implemented or initialised for each
// port.
bool8 S9xGraphicsInit ();
void S9xGraphicsDeinit();
bool8 S9xInitUpdate (void);
bool8 S9xDeinitUpdate (int Width, int Height);
bool8 S9xContinueUpdate (int Width, int Height);
void S9xSetPalette ();
void S9xSyncSpeed ();
extern void (*S9xCustomDisplayString) (const char *string, int linesFromBottom, int pixelsFromLeft, bool allowWrap); // called instead of S9xDisplayString if set to non-NULL
void S9xStartScreenRefresh (void);
void S9xEndScreenRefresh (void);
void S9xUpdateScreen (void);
void S9xBuildDirectColourMaps (void);
void RenderLine (uint8);
void S9xComputeClipWindows (void);
void S9xDisplayChar (uint16 *, uint8);
// called automatically unless Settings.AutoDisplayMessages is false
void S9xDisplayMessages (uint16 *, int, int, int, int);
#ifdef GFX_MULTI_FORMAT
bool8 S9xSetRenderPixelFormat (int format);
bool8 S9xSetRenderPixelFormat (int);
#endif
END_EXTERN_C
// external port interface which must be implemented or initialised for each port
bool8 S9xGraphicsInit (void);
void S9xGraphicsDeinit (void);
bool8 S9xInitUpdate (void);
bool8 S9xDeinitUpdate (int, int);
bool8 S9xContinueUpdate (int, int);
void S9xReRefresh (void);
void S9xSetPalette (void);
void S9xSyncSpeed (void);
// called instead of S9xDisplayString if set to non-NULL
extern void (*S9xCustomDisplayString) (const char *, int, int, bool);
#endif

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,238 +172,239 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#include "snes9x.h"
#include "memmap.h"
#include "ppu.h"
#include "dsp1.h"
#include "missing.h"
#include "cpuexec.h"
#include "s9xdebug.h"
#include "apu.h"
#include "dma.h"
#include "apu/apu.h"
#include "fxinst.h"
#include "fxemu.h"
#include "gfx.h"
#include "soundux.h"
#include "srtc.h"
#include "cheats.h"
#include "sa1.h"
#include "bsx.h"
#include "spc7110.h"
#ifdef NETPLAY_SUPPORT
#include "netplay.h"
#endif
#ifdef DEBUGGER
#include "debug.h"
#include "missing.h"
#endif
START_EXTERN_C
char String[513];
struct SCPUState CPU;
struct SICPU ICPU;
struct SRegisters Registers;
struct SPPU PPU;
struct InternalPPU IPPU;
struct SDMA DMA[8];
struct STimings Timings;
struct SGFX GFX;
struct SBG BG;
struct SLineData LineData[240];
struct SLineMatrixData LineMatrixData[240];
struct SDSP0 DSP0;
struct SDSP1 DSP1;
struct SDSP2 DSP2;
struct SDSP3 DSP3;
struct SDSP4 DSP4;
struct SSA1 SA1;
struct SSA1Registers SA1Registers;
struct SST010 ST010;
struct SST011 ST011;
struct SST018 ST018;
struct SOBC1 OBC1;
struct SSPC7110Snapshot s7snap;
struct SSRTCSnapshot srtcsnap;
struct SRTCData RTCData;
struct SBSX BSX;
struct SMulti Multi;
struct SSettings Settings;
struct SSNESGameFixes SNESGameFixes;
#ifdef NETPLAY_SUPPORT
struct SNetPlay NetPlay;
#endif
#ifdef DEBUGGER
struct Missing missing;
#endif
struct SCheatData Cheat;
struct Watch watches[16];
#ifndef ZSNES_FX
struct FxRegs_s GSU;
struct FxInfo_s SuperFX;
#endif
CMemory Memory;
struct Missing missing;
char String[513];
uint8 OpenBus = 0;
uint8 *HDMAMemPointers[8];
uint16 BlackColourMap[256];
uint16 DirectColourMaps[8][256];
struct SICPU ICPU;
struct SCPUState CPU;
struct STimings Timings;
struct SRegisters Registers;
struct SAPU APU;
struct SIAPU IAPU;
struct SAPURegisters APURegisters;
struct SSettings Settings;
struct SSA1Registers SA1Registers;
struct SSA1 SA1;
struct SBSX BSX;
struct SMulti Multi;
SSoundData SoundData;
SnesModel M1SNES = { 1, 3, 2 };
SnesModel M2SNES = { 2, 4, 3 };
SnesModel *Model = &M1SNES;
#if defined(ZSNES_FX) || defined(ZSNES_C4)
uint8 *ROM = NULL;
uint8 *SRAM = NULL;
uint8 *RegRAM = NULL;
uint8 *ROM = NULL;
uint8 *SRAM = NULL;
uint8 *RegRAM = NULL;
#endif
CMemory Memory;
struct SSNESGameFixes SNESGameFixes;
unsigned char OpenBus = 0;
END_EXTERN_C
struct SDSP1 DSP1;
SnesModel M1SNES={1,3,2};
SnesModel M2SNES={2,4,3};
SnesModel* Model=&M1SNES;
#ifndef ZSNES_FX
struct FxInit_s SuperFX;
#else
START_EXTERN_C
uint8 *SFXPlotTable = NULL;
END_EXTERN_C
#ifdef ZSNES_FX
uint8 *SFXPlotTable = NULL;
#endif
struct SPPU PPU;
struct InternalPPU IPPU;
struct SDMA DMA[8];
uint8 *HDMAMemPointers [8];
uint8 *HDMABasePointers [8];
struct SBG BG;
struct SGFX GFX;
struct SLineData LineData[240];
struct SLineMatrixData LineMatrixData [240];
#ifdef GFX_MULTI_FORMAT
uint32 RED_LOW_BIT_MASK = RED_LOW_BIT_MASK_RGB565;
uint32 GREEN_LOW_BIT_MASK = GREEN_LOW_BIT_MASK_RGB565;
uint32 BLUE_LOW_BIT_MASK = BLUE_LOW_BIT_MASK_RGB565;
uint32 RED_HI_BIT_MASK = RED_HI_BIT_MASK_RGB565;
uint32 GREEN_HI_BIT_MASK = GREEN_HI_BIT_MASK_RGB565;
uint32 BLUE_HI_BIT_MASK = BLUE_HI_BIT_MASK_RGB565;
uint32 MAX_RED = MAX_RED_RGB565;
uint32 MAX_GREEN = MAX_GREEN_RGB565;
uint32 MAX_BLUE = MAX_BLUE_RGB565;
uint32 SPARE_RGB_BIT_MASK = SPARE_RGB_BIT_MASK_RGB565;
uint32 GREEN_HI_BIT = (MAX_GREEN_RGB565 + 1) >> 1;
uint32 RGB_LOW_BITS_MASK = (RED_LOW_BIT_MASK_RGB565 |
GREEN_LOW_BIT_MASK_RGB565 |
BLUE_LOW_BIT_MASK_RGB565);
uint32 RGB_HI_BITS_MASK = (RED_HI_BIT_MASK_RGB565 |
GREEN_HI_BIT_MASK_RGB565 |
BLUE_HI_BIT_MASK_RGB565);
uint32 RGB_HI_BITS_MASKx2 = (RED_HI_BIT_MASK_RGB565 |
GREEN_HI_BIT_MASK_RGB565 |
BLUE_HI_BIT_MASK_RGB565) << 1;
uint32 RGB_REMOVE_LOW_BITS_MASK = ~RGB_LOW_BITS_MASK;
uint32 FIRST_COLOR_MASK = FIRST_COLOR_MASK_RGB565;
uint32 SECOND_COLOR_MASK = SECOND_COLOR_MASK_RGB565;
uint32 THIRD_COLOR_MASK = THIRD_COLOR_MASK_RGB565;
uint32 ALPHA_BITS_MASK = ALPHA_BITS_MASK_RGB565;
uint32 FIRST_THIRD_COLOR_MASK = 0;
uint32 TWO_LOW_BITS_MASK = 0;
uint32 HIGH_BITS_SHIFTED_TWO_MASK = 0;
uint32 current_graphic_format = RGB565;
uint32 RED_LOW_BIT_MASK = RED_LOW_BIT_MASK_RGB565;
uint32 GREEN_LOW_BIT_MASK = GREEN_LOW_BIT_MASK_RGB565;
uint32 BLUE_LOW_BIT_MASK = BLUE_LOW_BIT_MASK_RGB565;
uint32 RED_HI_BIT_MASK = RED_HI_BIT_MASK_RGB565;
uint32 GREEN_HI_BIT_MASK = GREEN_HI_BIT_MASK_RGB565;
uint32 BLUE_HI_BIT_MASK = BLUE_HI_BIT_MASK_RGB565;
uint32 MAX_RED = MAX_RED_RGB565;
uint32 MAX_GREEN = MAX_GREEN_RGB565;
uint32 MAX_BLUE = MAX_BLUE_RGB565;
uint32 SPARE_RGB_BIT_MASK = SPARE_RGB_BIT_MASK_RGB565;
uint32 GREEN_HI_BIT = (MAX_GREEN_RGB565 + 1) >> 1;
uint32 RGB_LOW_BITS_MASK = (RED_LOW_BIT_MASK_RGB565 | GREEN_LOW_BIT_MASK_RGB565 | BLUE_LOW_BIT_MASK_RGB565);
uint32 RGB_HI_BITS_MASK = (RED_HI_BIT_MASK_RGB565 | GREEN_HI_BIT_MASK_RGB565 | BLUE_HI_BIT_MASK_RGB565);
uint32 RGB_HI_BITS_MASKx2 = (RED_HI_BIT_MASK_RGB565 | GREEN_HI_BIT_MASK_RGB565 | BLUE_HI_BIT_MASK_RGB565) << 1;
uint32 RGB_REMOVE_LOW_BITS_MASK = ~RGB_LOW_BITS_MASK;
uint32 FIRST_COLOR_MASK = FIRST_COLOR_MASK_RGB565;
uint32 SECOND_COLOR_MASK = SECOND_COLOR_MASK_RGB565;
uint32 THIRD_COLOR_MASK = THIRD_COLOR_MASK_RGB565;
uint32 ALPHA_BITS_MASK = ALPHA_BITS_MASK_RGB565;
uint32 FIRST_THIRD_COLOR_MASK = 0;
uint32 TWO_LOW_BITS_MASK = 0;
uint32 HIGH_BITS_SHIFTED_TWO_MASK = 0;
#endif
uint8 GetBank = 0;
struct SCheatData Cheat;
volatile SoundStatus so;
int32 Loop[16];
int32 Echo[24000];
int32 FilterTaps[8];
int32 MixBuffer[SOUND_BUFFER_SIZE];
int32 EchoBuffer[SOUND_BUFFER_SIZE];
int32 DummyEchoBuffer[SOUND_BUFFER_SIZE];
uint32 FIRIndex = 0;
uint16 SignExtend [2] = {
0x00, 0xff00
};
//modified per anomie Mode 5 findings
int HDMA_ModeByteCounts [8] = {
1, 2, 2, 4, 4, 4, 2, 4
};
uint16 BlackColourMap [256];
uint16 DirectColourMaps [8][256];
uint32 HeadMask [4] = {
#ifdef LSB_FIRST
0xffffffff, 0xffffff00, 0xffff0000, 0xff000000
#else
0xffffffff, 0x00ffffff, 0x0000ffff, 0x000000ff
#endif
};
uint32 TailMask [5] = {
#ifdef LSB_FIRST
0x00000000, 0x000000ff, 0x0000ffff, 0x00ffffff, 0xffffffff
#else
0x00000000, 0xff000000, 0xffff0000, 0xffffff00, 0xffffffff
#endif
};
START_EXTERN_C
uint8 APUROM [64] =
uint16 SignExtend[2] =
{
0xCD,0xEF,0xBD,0xE8,0x00,0xC6,0x1D,0xD0,0xFC,0x8F,0xAA,0xF4,0x8F,
0xBB,0xF5,0x78,0xCC,0xF4,0xD0,0xFB,0x2F,0x19,0xEB,0xF4,0xD0,0xFC,
0x7E,0xF4,0xD0,0x0B,0xE4,0xF5,0xCB,0xF4,0xD7,0x00,0xFC,0xD0,0xF3,
0xAB,0x01,0x10,0xEF,0x7E,0xF4,0x10,0xEB,0xBA,0xF6,0xDA,0x00,0xBA,
0xF4,0xC4,0xF4,0xDD,0x5D,0xD0,0xDB,0x1F,0x00,0x00,0xC0,0xFF
0x0000,
0xff00
};
#ifdef NETPLAY_SUPPORT
struct SNetPlay NetPlay;
#endif
// Raw SPC700 instruction cycle lengths
int32 S9xAPUCycleLengths [256] =
int HDMA_ModeByteCounts[8] =
{
/* 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,
/* 30 */ 2, 8, 4, 5, 4, 5, 5, 6, 5, 5, 6, 5, 2, 2, 3, 8,
/* 40 */ 2, 8, 4, 5, 3, 4, 3, 6, 2, 6, 4, 4, 5, 4, 6, 6,
/* 50 */ 2, 8, 4, 5, 4, 5, 5, 6, 5, 5, 4, 5, 2, 2, 4, 3,
/* 60 */ 2, 8, 4, 5, 3, 4, 3, 6, 2, 6, 4, 4, 5, 4, 5, 5,
/* 70 */ 2, 8, 4, 5, 4, 5, 5, 6, 5, 5, 5, 5, 2, 2, 3, 6,
/* 80 */ 2, 8, 4, 5, 3, 4, 3, 6, 2, 6, 5, 4, 5, 2, 4, 5,
/* 90 */ 2, 8, 4, 5, 4, 5, 5, 6, 5, 5, 5, 5, 2, 2,12, 5,
/* A0 */ 3, 8, 4, 5, 3, 4, 3, 6, 2, 6, 4, 4, 5, 2, 4, 4,
/* B0 */ 2, 8, 4, 5, 4, 5, 5, 6, 5, 5, 5, 5, 2, 2, 3, 4,
/* C0 */ 3, 8, 4, 5, 4, 5, 4, 7, 2, 5, 6, 4, 5, 2, 4, 9,
/* D0 */ 2, 8, 4, 5, 5, 6, 6, 7, 4, 5, 5, 5, 2, 2, 6, 3,
/* E0 */ 2, 8, 4, 5, 3, 4, 3, 6, 2, 4, 5, 3, 4, 3, 4, 3,
/* F0 */ 2, 8, 4, 5, 4, 5, 5, 6, 3, 4, 5, 4, 2, 2, 4, 3
1, 2, 2, 4, 4, 4, 2, 4
};
// Actual data used by CPU emulation, will be scaled by APUReset routine
// to be relative to the 65c816 instruction lengths.
int32 S9xAPUCycles [256] =
uint8 mul_brightness[16][32] =
{
/* 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,
/* 30 */ 2, 8, 4, 5, 4, 5, 5, 6, 5, 5, 6, 5, 2, 2, 3, 8,
/* 40 */ 2, 8, 4, 5, 3, 4, 3, 6, 2, 6, 4, 4, 5, 4, 6, 6,
/* 50 */ 2, 8, 4, 5, 4, 5, 5, 6, 5, 5, 4, 5, 2, 2, 4, 3,
/* 60 */ 2, 8, 4, 5, 3, 4, 3, 6, 2, 6, 4, 4, 5, 4, 5, 5,
/* 70 */ 2, 8, 4, 5, 4, 5, 5, 6, 5, 5, 5, 5, 2, 2, 3, 6,
/* 80 */ 2, 8, 4, 5, 3, 4, 3, 6, 2, 6, 5, 4, 5, 2, 4, 5,
/* 90 */ 2, 8, 4, 5, 4, 5, 5, 6, 5, 5, 5, 5, 2, 2,12, 5,
/* A0 */ 3, 8, 4, 5, 3, 4, 3, 6, 2, 6, 4, 4, 5, 2, 4, 4,
/* B0 */ 2, 8, 4, 5, 4, 5, 5, 6, 5, 5, 5, 5, 2, 2, 3, 4,
/* C0 */ 3, 8, 4, 5, 4, 5, 4, 7, 2, 5, 6, 4, 5, 2, 4, 9,
/* D0 */ 2, 8, 4, 5, 5, 6, 6, 7, 4, 5, 5, 5, 2, 2, 6, 3,
/* E0 */ 2, 8, 4, 5, 3, 4, 3, 6, 2, 4, 5, 3, 4, 3, 4, 3,
/* F0 */ 2, 8, 4, 5, 4, 5, 5, 6, 3, 4, 5, 4, 2, 2, 4, 3
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02 },
{ 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02,
0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04 },
{ 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03,
0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06 },
{ 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04,
0x04, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x08, 0x08, 0x08 },
{ 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x05, 0x05,
0x05, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x08, 0x08, 0x08, 0x09, 0x09, 0x09, 0x0a, 0x0a, 0x0a },
{ 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x03, 0x03, 0x04, 0x04, 0x04, 0x05, 0x05, 0x06, 0x06,
0x06, 0x07, 0x07, 0x08, 0x08, 0x08, 0x09, 0x09, 0x0a, 0x0a, 0x0a, 0x0b, 0x0b, 0x0c, 0x0c, 0x0c },
{ 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x03, 0x03, 0x04, 0x04, 0x05, 0x05, 0x06, 0x06, 0x07, 0x07,
0x07, 0x08, 0x08, 0x09, 0x09, 0x0a, 0x0a, 0x0b, 0x0b, 0x0c, 0x0c, 0x0d, 0x0d, 0x0e, 0x0e, 0x0e },
{ 0x00, 0x01, 0x01, 0x02, 0x02, 0x03, 0x03, 0x04, 0x04, 0x05, 0x05, 0x06, 0x06, 0x07, 0x07, 0x08,
0x09, 0x09, 0x0a, 0x0a, 0x0b, 0x0b, 0x0c, 0x0c, 0x0d, 0x0d, 0x0e, 0x0e, 0x0f, 0x0f, 0x10, 0x11 },
{ 0x00, 0x01, 0x01, 0x02, 0x02, 0x03, 0x04, 0x04, 0x05, 0x05, 0x06, 0x07, 0x07, 0x08, 0x08, 0x09,
0x0a, 0x0a, 0x0b, 0x0b, 0x0c, 0x0d, 0x0d, 0x0e, 0x0e, 0x0f, 0x10, 0x10, 0x11, 0x11, 0x12, 0x13 },
{ 0x00, 0x01, 0x01, 0x02, 0x03, 0x03, 0x04, 0x05, 0x05, 0x06, 0x07, 0x07, 0x08, 0x09, 0x09, 0x0a,
0x0b, 0x0b, 0x0c, 0x0d, 0x0d, 0x0e, 0x0f, 0x0f, 0x10, 0x11, 0x11, 0x12, 0x13, 0x13, 0x14, 0x15 },
{ 0x00, 0x01, 0x01, 0x02, 0x03, 0x04, 0x04, 0x05, 0x06, 0x07, 0x07, 0x08, 0x09, 0x0a, 0x0a, 0x0b,
0x0c, 0x0c, 0x0d, 0x0e, 0x0f, 0x0f, 0x10, 0x11, 0x12, 0x12, 0x13, 0x14, 0x15, 0x15, 0x16, 0x17 },
{ 0x00, 0x01, 0x02, 0x02, 0x03, 0x04, 0x05, 0x06, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0a, 0x0b, 0x0c,
0x0d, 0x0e, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x12, 0x13, 0x14, 0x15, 0x16, 0x16, 0x17, 0x18, 0x19 },
{ 0x00, 0x01, 0x02, 0x03, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0a, 0x0b, 0x0c, 0x0d,
0x0e, 0x0f, 0x10, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x17, 0x18, 0x19, 0x1a, 0x1b },
{ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d },
{ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f }
};
END_EXTERN_C
uint8 S9xOpLengthsM0X0[256] =
{
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 0
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 1
3, 2, 4, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 2
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 3
1, 2, 2, 2, 3, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 4
2, 2, 2, 2, 3, 2, 2, 2, 1, 3, 1, 1, 4, 3, 3, 4, // 5
1, 2, 3, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 6
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 7
2, 2, 3, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 8
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 9
3, 2, 3, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // A
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // B
3, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // C
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // D
3, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // E
2, 2, 2, 2, 3, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4 // F
};
uint8 S9xOpLengthsM0X1[256] =
{
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 0
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 1
3, 2, 4, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 2
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 3
1, 2, 2, 2, 3, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 4
2, 2, 2, 2, 3, 2, 2, 2, 1, 3, 1, 1, 4, 3, 3, 4, // 5
1, 2, 3, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 6
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 7
2, 2, 3, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 8
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 9
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // A
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // B
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // C
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // D
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // E
2, 2, 2, 2, 3, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4 // F
};
uint8 S9xOpLengthsM1X0[256] =
{
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // 0
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 1
3, 2, 4, 2, 2, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // 2
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 3
1, 2, 2, 2, 3, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // 4
2, 2, 2, 2, 3, 2, 2, 2, 1, 3, 1, 1, 4, 3, 3, 4, // 5
1, 2, 3, 2, 2, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // 6
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 7
2, 2, 3, 2, 2, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // 8
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 9
3, 2, 3, 2, 2, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // A
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // B
3, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // C
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // D
3, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // E
2, 2, 2, 2, 3, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4 // F
};
uint8 S9xOpLengthsM1X1[256] =
{
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // 0
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 1
3, 2, 4, 2, 2, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // 2
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 3
1, 2, 2, 2, 3, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // 4
2, 2, 2, 2, 3, 2, 2, 2, 1, 3, 1, 1, 4, 3, 3, 4, // 5
1, 2, 3, 2, 2, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // 6
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 7
2, 2, 3, 2, 2, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // 8
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // 9
2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // A
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // B
2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // C
2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4, // D
2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 1, 3, 3, 3, 4, // E
2, 2, 2, 2, 3, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3, 4 // F
};

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,33 +172,31 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#ifndef _LANGUAGE_H_
#define _LANGUAGE_H_
// Movie Messages
#define MOVIE_ERR_SNAPSHOT_WRONG_MOVIE "Snapshot not from this movie"
#define MOVIE_ERR_SNAPSHOT_NOT_MOVIE "Not a movie snapshot"
#define MOVIE_INFO_REPLAY "Movie replay"
#define MOVIE_INFO_RECORD "Movie record"
#define MOVIE_INFO_RERECORD "Movie re-record"
#define MOVIE_INFO_REWIND "Movie rewind"
#define MOVIE_INFO_STOP "Movie stop"
#define MOVIE_INFO_END "Movie end"
#define MOVIE_INFO_SNAPSHOT "Movie snapshot"
#define MOVIE_ERR_SNAPSHOT_INCONSISTENT "Snapshot inconsistent with movie"
/* This file is for core emulator messages. Use a port-specific file for *
* GUI strings and the like. Thank you. */
/* Movie Messages */
#define MOVIE_ERR_SNAPSHOT_WRONG_MOVIE "Snapshot not from this movie"
#define MOVIE_ERR_SNAPSHOT_NOT_MOVIE "Not a movie snapshot"
#define MOVIE_INFO_REPLAY "Movie replay"
#define MOVIE_INFO_RECORD "Movie record"
#define MOVIE_INFO_RERECORD "Movie re-record"
#define MOVIE_INFO_REWIND "Movie rewind"
#define MOVIE_INFO_STOP "Movie stop"
#define MOVIE_INFO_END "Movie end"
#define MOVIE_INFO_SNAPSHOT "Movie snapshot"
#define MOVIE_ERR_SNAPSHOT_INCONSISTENT "Snapshot inconsistent with movie"
/* Snapshot Messages */
#define SAVE_INFO_SNAPSHOT "Saved"
#define SAVE_INFO_LOAD "Loaded"
#define SAVE_ERR_WRONG_FORMAT "File not in Snes9x freeze format"
#define SAVE_ERR_WRONG_VERSION "Incompatable Snes9x freeze file format version"
#define SAVE_ERR_ROM_NOT_FOUND "ROM image \"%s\" for freeze file not found"
#define SAVE_ERR_SAVE_NOT_FOUND "Save file %s does not exist."
// Snapshot Messages
#define SAVE_INFO_SNAPSHOT "Saved"
#define SAVE_INFO_LOAD "Loaded"
#define SAVE_INFO_OOPS "Auto-saving 'oops' snapshot"
#define SAVE_ERR_WRONG_FORMAT "File not in Snes9x snapshot format"
#define SAVE_ERR_WRONG_VERSION "Incompatable snapshot version"
#define SAVE_ERR_ROM_NOT_FOUND "ROM image \"%s\" for snapshot not found"
#define SAVE_ERR_SAVE_NOT_FOUND "Snapshot %s does not exist"
#endif

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,82 +172,96 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#include "snes9x.h"
#include "movie.h"
#include "logger.h"
#ifndef _SPC700_H_
#define _SPC700_H_
static int resetno = 0;
static int framecounter = 0;
static FILE *video = NULL;
static FILE *audio = NULL;
#define Carry 1
#define Zero 2
#define Interrupt 4
#define HalfCarry 8
#define BreakFlag 16
#define DirectPageFlag 32
#define Overflow 64
#define Negative 128
#define APUClearCarry() (IAPU._Carry = 0)
#define APUSetCarry() (IAPU._Carry = 1)
#define APUSetInterrupt() (APURegisters.P |= Interrupt)
#define APUClearInterrupt() (APURegisters.P &= ~Interrupt)
#define APUSetHalfCarry() (APURegisters.P |= HalfCarry)
#define APUClearHalfCarry() (APURegisters.P &= ~HalfCarry)
#define APUSetBreak() (APURegisters.P |= BreakFlag)
#define APUClearBreak() (APURegisters.P &= ~BreakFlag)
#define APUSetDirectPage() (APURegisters.P |= DirectPageFlag)
#define APUClearDirectPage() (APURegisters.P &= ~DirectPageFlag)
#define APUSetOverflow() (IAPU._Overflow = 1)
#define APUClearOverflow() (IAPU._Overflow = 0)
#define APUCheckZero() (IAPU._Zero == 0)
#define APUCheckCarry() (IAPU._Carry)
#define APUCheckInterrupt() (APURegisters.P & Interrupt)
#define APUCheckHalfCarry() (APURegisters.P & HalfCarry)
#define APUCheckBreak() (APURegisters.P & BreakFlag)
#define APUCheckDirectPage() (APURegisters.P & DirectPageFlag)
#define APUCheckOverflow() (IAPU._Overflow)
#define APUCheckNegative() (IAPU._Zero & 0x80)
#define APUClearFlags(f) (APURegisters.P &= ~(f))
#define APUSetFlags(f) (APURegisters.P |= (f))
#define APUCheckFlag(f) (APURegisters.P & (f))
typedef union
void S9xResetLogger (void)
{
#ifdef LSB_FIRST
struct { uint8 A, Y; } B;
#else
struct { uint8 Y, A; } B;
#endif
uint16 W;
} YAndA;
if (!Settings.DumpStreams)
return;
struct SAPURegisters{
uint8 P;
YAndA YA;
uint8 X;
uint8 S;
uint16 PC;
};
char buffer[128];
EXTERN_C struct SAPURegisters APURegisters;
S9xCloseLogger();
framecounter = 0;
#ifdef DEBUGGER
#define APU_EXECUTE1() \
{ \
if (APU.Flags & TRACE_FLAG) \
S9xTraceAPU (); \
APU.Cycles += S9xAPUCycles [*IAPU.PC]; \
(*S9xApuOpcodes[*IAPU.PC]) (); \
sprintf(buffer, "videostream%d.dat", resetno);
video = fopen(buffer, "wb");
if (!video)
{
printf("Opening %s failed. Logging cancelled.\n", buffer);
return;
}
sprintf(buffer, "audiostream%d.dat", resetno);
audio = fopen(buffer, "wb");
if (!audio)
{
printf("Opening %s failed. Logging cancelled.\n", buffer);
fclose(video);
return;
}
resetno++;
}
#else
#define APU_EXECUTE1() \
{ \
APU.Cycles += S9xAPUCycles [*IAPU.PC]; \
(*S9xApuOpcodes[*IAPU.PC]) (); \
}
#endif
#endif
void S9xCloseLogger (void)
{
if (video)
{
fclose(video);
video = NULL;
}
if (audio)
{
fclose(audio);
audio = NULL;
}
}
void S9xVideoLogger (void *pixels, int width, int height, int depth, int bytes_per_line)
{
int fc = S9xMovieGetFrameCounter();
if (fc > 0)
framecounter = fc;
else
framecounter++;
if (video)
{
char *data = (char *) pixels;
size_t ignore;
for (int i = 0; i < height; i++)
ignore = fwrite(data + i * bytes_per_line, depth, width, video);
fflush(video);
fflush(audio);
if (Settings.DumpStreamsMaxFrames > 0 && framecounter >= Settings.DumpStreamsMaxFrames)
{
printf("Logging ended.\n");
S9xCloseLogger();
}
}
}
void S9xAudioLogger (void *samples, int length)
{
if (audio)
{
size_t ignore;
ignore = fwrite(samples, 1, length, audio);
}
}

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,32 +172,15 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#ifndef _LOGGER_H_
#define _LOGGER_H_
void S9xResetLogger(void);
void S9xCloseLogger(void);
void S9xVideoLogger(void *, int, int, int, int);
void S9xAudioLogger(void *, int);
#ifndef _DEBUG_H_
#define _DEBUG_H_
START_EXTERN_C
void S9xDoDebug ();
void S9xTrace ();
void S9xSA1Trace ();
void S9xTraceMessage (const char *);
// Structures
struct SBreakPoint{
bool8 Enabled;
uint8 Bank;
uint16 Address;
};
uint8 S9xOPrint( char *Line, uint8 Bank, uint16 Address);
uint8 S9xSA1OPrint( char *Line, uint8 Bank, uint16 Address);
extern struct SBreakPoint S9xBreakpoint[ 6];
extern char *S9xMnemonics[256];
END_EXTERN_C
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,29 +172,22 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#ifndef _MEMMAP_H_
#define _MEMMAP_H_
#ifndef _memmap_h_
#define _memmap_h_
#include "snes9x.h"
#define MEMMAP_BLOCK_SIZE (0x1000)
#define MEMMAP_NUM_BLOCKS (0x1000000 / MEMMAP_BLOCK_SIZE)
#define MEMMAP_SHIFT (12)
#define MEMMAP_MASK (MEMMAP_BLOCK_SIZE - 1)
#define MEMMAP_MAX_SDD1_LOGGED_ENTRIES (0x10000 / 8)
#define MEMMAP_BLOCK_SIZE (0x1000)
#define MEMMAP_NUM_BLOCKS (0x1000000 / MEMMAP_BLOCK_SIZE)
#define MEMMAP_SHIFT (12)
#define MEMMAP_MASK (MEMMAP_BLOCK_SIZE - 1)
struct CMemory
{
enum
#ifdef HW_RVL
{ MAX_ROM_SIZE = 0x800000 }; // Wii - lots of memory
#else
{ MAX_ROM_SIZE = 0x500000 }; // GameCube - less memory to play with
#endif
{ MAX_ROM_SIZE = 0x800000 };
enum file_formats
{ FILE_ZIP, FILE_JMA, FILE_DEFAULT };
@ -190,26 +199,25 @@ struct CMemory
enum
{
MAP_PPU,
MAP_CPU,
MAP_PPU,
MAP_LOROM_SRAM,
MAP_LOROM_SRAM_B,
MAP_HIROM_SRAM,
MAP_DSP,
MAP_C4,
MAP_SA1RAM,
MAP_BWRAM,
MAP_BWRAM_BITMAP,
MAP_BWRAM_BITMAP2,
MAP_SA1RAM,
MAP_SPC7110_ROM,
MAP_SPC7110_DRAM,
MAP_RONLY_SRAM,
MAP_C4,
MAP_OBC_RAM,
MAP_SETA_DSP,
MAP_SETA_RISC,
MAP_BSX,
MAP_NONE,
MAP_DEBUG,
MAP_LAST
};
@ -223,6 +231,7 @@ struct CMemory
uint8 *FillRAM;
uint8 *BWRAM;
uint8 *C4RAM;
uint8 *OBC1RAM;
uint8 *BSRAM;
uint8 *BIOSROM;
@ -233,11 +242,11 @@ struct CMemory
uint8 MemorySpeed[MEMMAP_NUM_BLOCKS];
uint8 ExtendedFormat;
char ROMFilename[_MAX_PATH + 1];
char ROMFilename[PATH_MAX + 1];
char ROMName[ROM_NAME_LEN];
char RawROMName[ROM_NAME_LEN];
char ROMId[5];
char CompanyId[3];
int32 CompanyId;
uint8 ROMRegion;
uint8 ROMSpeed;
uint8 ROMType;
@ -254,19 +263,11 @@ struct CMemory
uint32 CalculatedSize;
uint32 CalculatedChecksum;
uint8 *SDD1Index;
uint8 *SDD1Data;
uint32 SDD1Entries;
uint32 SDD1LoggedDataCountPrev;
uint32 SDD1LoggedDataCount;
uint8 SDD1LoggedData[MEMMAP_MAX_SDD1_LOGGED_ENTRIES];
// ports can assign this to perform some custom action upon loading a ROM (such as adjusting controls)
void (*PostRomInitFunc) ();
void (*PostRomInitFunc) (void);
bool8 Init (void);
void Deinit (void);
void FreeSDD1Data (void);
int ScoreHiROM (bool8, int32 romoff = 0);
int ScoreLoROM (bool8, int32 romoff = 0);
@ -276,10 +277,11 @@ struct CMemory
bool8 LoadMultiCart (const char *, const char *);
bool8 LoadSufamiTurbo (const char *, const char *);
bool8 LoadSameGame (const char *, const char *);
bool8 LoadLastROM (void);
bool8 LoadSRAM (const char *);
bool8 SaveSRAM (const char *);
void ClearSRAM (bool8 onlyNonSavedSRAM = 0);
bool8 LoadSRTC (void);
bool8 SaveSRTC (void);
char * Safe (const char *);
char * SafeANK (const char *);
@ -331,15 +333,17 @@ struct CMemory
bool8 match_nc (const char *);
bool8 match_id (const char *);
void ApplyROMFixes (void);
void CheckForIPSPatch (const char *, bool8, int32 &);
void CheckForAnyPatch (const char *, bool8, int32 &);
void MakeRomInfoText (char *);
const char * TVStandard (void);
const char * MapType (void);
const char * MapMode (void);
const char * StaticRAMSize (void);
const char * Size (void);
const char * Revision (void);
const char * KartContents (void);
const char * Country (void);
const char * PublishingCompany (void);
};
struct SMulti
@ -350,21 +354,22 @@ struct SMulti
uint32 sramMaskA, sramMaskB;
uint32 cartOffsetA, cartOffsetB;
uint8 *sramA, *sramB;
char fileNameA[_MAX_PATH + 1], fileNameB[_MAX_PATH + 1];
char fileNameA[PATH_MAX + 1], fileNameB[PATH_MAX + 1];
};
START_EXTERN_C
extern CMemory Memory;
extern SMulti Multi;
#if defined(ZSNES_FX) || defined(ZSNES_C4)
START_EXTERN_C
extern uint8 *ROM;
extern uint8 *SRAM;
extern uint8 *RegRAM;
#endif
bool8 LoadZip(const char *, int32 *, int32 *, uint8 *);
END_EXTERN_C
#endif
void S9xAutoSaveSRAM (void);
bool8 LoadZip(const char *, int32 *, int32 *, uint8 *);
enum s9xwrap_t
{
@ -379,25 +384,6 @@ enum s9xwriteorder_t
WRITE_10
};
#ifdef NO_INLINE_SET_GET
uint8 S9xGetByte (uint32);
uint16 S9xGetWord (uint32, enum s9xwrap_t w = WRAP_NONE);
void S9xSetByte (uint8, uint32);
void S9xSetWord (uint16, uint32, enum s9xwrap_t w = WRAP_NONE, enum s9xwriteorder_t o = WRITE_01);
void S9xSetPCBase (uint32);
uint8 * S9xGetMemPointer (uint32);
uint8 * GetBasePointer (uint32);
START_EXTERN_C
extern uint8 OpenBus;
END_EXTERN_C
#else
#define INLINE inline
#include "getset.h"
#endif // NO_INLINE_SET_GET
#endif // _memmap_h_
#endif

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,52 +172,52 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#ifndef _MESSAGES_H_
#define _MESSAGES_H_
#ifndef _messages_h_
#define _messages_h_
/* Types of message sent to S9xMessage routine */
enum {
S9X_TRACE,
S9X_DEBUG,
S9X_WARNING,
S9X_INFO,
S9X_ERROR,
S9X_FATAL_ERROR
// Types of message sent to S9xMessage()
enum
{
S9X_TRACE,
S9X_DEBUG,
S9X_WARNING,
S9X_INFO,
S9X_ERROR,
S9X_FATAL_ERROR
};
/* Individual message numbers */
enum {
S9X_ROM_INFO,
S9X_HEADERS_INFO,
S9X_CONFIG_INFO,
S9X_ROM_CONFUSING_FORMAT_INFO,
S9X_ROM_INTERLEAVED_INFO,
S9X_SOUND_DEVICE_OPEN_FAILED,
S9X_APU_STOPPED,
S9X_USAGE,
S9X_GAME_GENIE_CODE_ERROR,
S9X_ACTION_REPLY_CODE_ERROR,
S9X_GOLD_FINGER_CODE_ERROR,
S9X_DEBUG_OUTPUT,
S9X_DMA_TRACE,
S9X_HDMA_TRACE,
S9X_WRONG_FORMAT,
S9X_WRONG_VERSION,
S9X_ROM_NOT_FOUND,
S9X_FREEZE_FILE_NOT_FOUND,
S9X_PPU_TRACE,
S9X_TRACE_DSP1,
S9X_FREEZE_ROM_NAME,
S9X_HEADER_WARNING,
S9X_NETPLAY_NOT_SERVER,
S9X_FREEZE_FILE_INFO,
S9X_TURBO_MODE,
S9X_SOUND_NOT_BUILT,
// Individual message numbers
enum
{
S9X_ROM_INFO,
S9X_HEADERS_INFO,
S9X_CONFIG_INFO,
S9X_ROM_CONFUSING_FORMAT_INFO,
S9X_ROM_INTERLEAVED_INFO,
S9X_SOUND_DEVICE_OPEN_FAILED,
S9X_APU_STOPPED,
S9X_USAGE,
S9X_GAME_GENIE_CODE_ERROR,
S9X_ACTION_REPLY_CODE_ERROR,
S9X_GOLD_FINGER_CODE_ERROR,
S9X_DEBUG_OUTPUT,
S9X_DMA_TRACE,
S9X_HDMA_TRACE,
S9X_WRONG_FORMAT,
S9X_WRONG_VERSION,
S9X_ROM_NOT_FOUND,
S9X_FREEZE_FILE_NOT_FOUND,
S9X_PPU_TRACE,
S9X_TRACE_DSP1,
S9X_FREEZE_ROM_NAME,
S9X_HEADER_WARNING,
S9X_NETPLAY_NOT_SERVER,
S9X_FREEZE_FILE_INFO,
S9X_TURBO_MODE,
S9X_SOUND_NOT_BUILT,
S9X_MOVIE_INFO,
S9X_WRONG_MOVIE_SNAPSHOT,
S9X_NOT_A_MOVIE_SNAPSHOT,
@ -210,4 +226,3 @@ enum {
};
#endif

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,83 +172,85 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#ifdef DEBUGGER
#ifndef _MISSING_H_
#define _MISSING_H_
struct HDMA
struct MissingHDMA
{
uint8 used;
uint8 bbus_address;
uint8 abus_bank;
uint16 abus_address;
uint8 indirect_address;
uint8 force_table_address_write;
uint8 force_table_address_read;
uint8 line_count_write;
uint8 line_count_read;
uint8 used;
uint8 bbus_address;
uint8 abus_bank;
uint16 abus_address;
uint8 indirect_address;
uint8 force_table_address_write;
uint8 force_table_address_read;
uint8 line_count_write;
uint8 line_count_read;
};
struct Missing
{
uint8 emulate6502;
uint8 decimal_mode;
uint8 mv_8bit_index;
uint8 mv_8bit_acc;
uint8 interlace;
uint8 lines_239;
uint8 pseudo_512;
struct HDMA hdma [8];
uint8 modes [8];
uint8 mode7_fx;
uint8 mode7_flip;
uint8 mode7_bgmode;
uint8 direct;
uint8 matrix_multiply;
uint8 oam_read;
uint8 vram_read;
uint8 cgram_read;
uint8 wram_read;
uint8 dma_read;
uint8 vram_inc;
uint8 vram_full_graphic_inc;
uint8 virq;
uint8 hirq;
uint16 virq_pos;
uint16 hirq_pos;
uint8 h_v_latch;
uint8 h_counter_read;
uint8 v_counter_read;
uint8 fast_rom;
uint8 window1 [6];
uint8 window2 [6];
uint8 sprite_priority_rotation;
uint8 subscreen;
uint8 subscreen_add;
uint8 subscreen_sub;
uint8 fixed_colour_add;
uint8 fixed_colour_sub;
uint8 mosaic;
uint8 sprite_double_height;
uint8 dma_channels;
uint8 dma_this_frame;
uint8 oam_address_read;
uint8 bg_offset_read;
uint8 matrix_read;
uint8 hdma_channels;
uint8 hdma_this_frame;
uint16 unknownppu_read;
uint16 unknownppu_write;
uint16 unknowncpu_read;
uint16 unknowncpu_write;
uint16 unknowndsp_read;
uint16 unknowndsp_write;
struct MissingHDMA hdma[8];
uint8 emulate6502;
uint8 decimal_mode;
uint8 mv_8bit_index;
uint8 mv_8bit_acc;
uint8 interlace;
uint8 lines_239;
uint8 pseudo_512;
uint8 modes[8];
uint8 mode7_fx;
uint8 mode7_flip;
uint8 mode7_bgmode;
uint8 direct;
uint8 matrix_multiply;
uint8 oam_read;
uint8 vram_read;
uint8 cgram_read;
uint8 wram_read;
uint8 dma_read;
uint8 vram_inc;
uint8 vram_full_graphic_inc;
uint8 virq;
uint8 hirq;
uint16 virq_pos;
uint16 hirq_pos;
uint8 h_v_latch;
uint8 h_counter_read;
uint8 v_counter_read;
uint8 fast_rom;
uint8 window1[6];
uint8 window2[6];
uint8 sprite_priority_rotation;
uint8 subscreen;
uint8 subscreen_add;
uint8 subscreen_sub;
uint8 fixed_colour_add;
uint8 fixed_colour_sub;
uint8 mosaic;
uint8 sprite_double_height;
uint8 dma_channels;
uint8 dma_this_frame;
uint8 oam_address_read;
uint8 bg_offset_read;
uint8 matrix_read;
uint8 hdma_channels;
uint8 hdma_this_frame;
uint16 unknownppu_read;
uint16 unknownppu_write;
uint16 unknowncpu_read;
uint16 unknowncpu_write;
uint16 unknowndsp_read;
uint16 unknowndsp_write;
};
EXTERN_C struct Missing missing;
extern struct Missing missing;
#endif
#endif

1201
source/snes9x/movie.cpp Normal file

File diff suppressed because it is too large Load Diff

254
source/snes9x/movie.h Normal file
View File

@ -0,0 +1,254 @@
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
Jerremy Koot (jkoot@snes9x.com)
(c) Copyright 2002 - 2004 Matthew Kendora
(c) Copyright 2002 - 2005 Peter Bortas (peter@bortas.org)
(c) Copyright 2004 - 2005 Joel Yliluoma (http://iki.fi/bisqwit/)
(c) Copyright 2001 - 2006 John Weidman (jweidman@slip.net)
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
zones
C4 x86 assembler and some C emulation code
(c) Copyright 2000 - 2003 _Demo_ (_demo_@zsnes.com),
Nach,
zsKnight (zsknight@zsnes.com)
C4 C++ code
(c) Copyright 2003 - 2006 Brad Jorsch,
Nach
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
Kris Bleakley,
Matthew Kendora,
Nach,
neviksti (neviksti@hotmail.com)
DSP-2 emulator code
(c) Copyright 2003 John Weidman,
Kris Bleakley,
Lord Nightmare (lord_nightmare@users.sourceforge.net),
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
Lancer,
z80 gaiden
DSP-4 emulator code
(c) Copyright 2004 - 2006 Dreamer Nom,
John Weidman,
Kris Bleakley,
Nach,
z80 gaiden
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
(c) Copyright 2003 Feather,
John Weidman,
Kris Bleakley,
Matthew Kendora
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
2xSaI filter
(c) Copyright 1999 - 2001 Derek Liauw Kie Fa
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
fee, providing that this license information and copyright notice appear
with all copies and any derived work.
This software is provided 'as-is', without any express or implied
warranty. In no event shall the authors be held liable for any damages
arising from the use of this software or it's derivatives.
Snes9x is freeware for PERSONAL USE only. Commercial users should
seek permission of the copyright holders first. Commercial use includes,
but is not limited to, charging money for Snes9x or software derived from
Snes9x, including Snes9x or derivatives in commercial game bundles, and/or
using Snes9x as a promotion for your commercial product.
The copyright holders request that bug fixes and improvements to the code
should be forwarded to them so everyone can benefit from the modifications
in future versions.
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
***********************************************************************************/
#ifndef _MOVIE_H_
#define _MOVIE_H_
#define MOVIE_OPT_FROM_SNAPSHOT 0
#define MOVIE_OPT_FROM_RESET (1 << 0)
#define MOVIE_OPT_PAL (1 << 1)
#define MOVIE_OPT_NOSAVEDATA (1 << 2)
#define MOVIE_SYNC_DATA_EXISTS 0x01
#define MOVIE_SYNC_OBSOLETE 0x02
#define MOVIE_SYNC_LEFTRIGHT 0x04
#define MOVIE_SYNC_VOLUMEENVX 0x08
#define MOVIE_SYNC_FAKEMUTE 0x10
#define MOVIE_SYNC_SYNCSOUND 0x20
#define MOVIE_SYNC_HASROMINFO 0x40
#define MOVIE_SYNC_NOCPUSHUTDOWN 0x80
#define MOVIE_MAX_METADATA 512
#define CONTROLLER_DATA_SIZE 2
#define MOUSE_DATA_SIZE 5
#define SCOPE_DATA_SIZE 6
#define JUSTIFIER_DATA_SIZE 11
struct MovieInfo
{
time_t TimeCreated;
uint32 Version;
uint32 LengthFrames;
uint32 LengthSamples;
uint32 RerecordCount;
uint8 Opts;
uint8 ControllersMask;
uint8 SyncFlags;
bool8 ReadOnly;
uint8 PortType[2];
wchar_t Metadata[MOVIE_MAX_METADATA];
uint32 ROMCRC32;
char ROMName[23];
};
// methods used by the user-interface code
int S9xMovieOpen (const char *, bool8);
int S9xMovieCreate (const char *, uint8, uint8, const wchar_t *, int);
int S9xMovieGetInfo (const char *, struct MovieInfo *);
void S9xMovieStop (bool8);
void S9xMovieToggleRecState (void);
void S9xMovieToggleFrameDisplay (void);
const char * S9xChooseMovieFilename (bool8);
// methods used by the emulation
void S9xMovieInit (void);
void S9xMovieShutdown (void);
void S9xMovieUpdate (bool a = true);
void S9xMovieUpdateOnReset (void);
void S9xUpdateFrameCounter (int o = 0);
void S9xMovieFreeze (uint8 **, uint32 *);
int S9xMovieUnfreeze (uint8 *, uint32);
// accessor functions
bool8 S9xMovieActive (void);
bool8 S9xMoviePlaying (void);
bool8 S9xMovieRecording (void);
bool8 S9xMovieReadOnly (void);
uint8 S9xMovieControllers (void);
uint32 S9xMovieGetId (void);
uint32 S9xMovieGetLength (void);
uint32 S9xMovieGetFrameCounter (void);
uint16 MovieGetJoypad (int);
void MovieSetJoypad (int, uint16);
bool MovieGetMouse (int, uint8 d[MOUSE_DATA_SIZE]);
void MovieSetMouse (int, uint8 d[MOUSE_DATA_SIZE], bool);
bool MovieGetScope (int, uint8 d[SCOPE_DATA_SIZE]);
void MovieSetScope (int, uint8 d[SCOPE_DATA_SIZE]);
bool MovieGetJustifier (int, uint8 d[JUSTIFIER_DATA_SIZE]);
void MovieSetJustifier (int, uint8 d[JUSTIFIER_DATA_SIZE]);
#endif

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,127 +172,105 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#include <string.h>
#include "snes9x.h"
#include "memmap.h"
#include "obc1.h"
static uint8 *OBC1_RAM = NULL;
int OBC1_Address;
int OBC1_BasePtr;
int OBC1_Shift;
extern "C"
uint8 S9xGetOBC1 (uint16 Address)
{
uint8 GetOBC1 (uint16 Address)
{
switch(Address) {
switch (Address)
{
case 0x7ff0:
return OBC1_RAM[OBC1_BasePtr + (OBC1_Address << 2)];
return (Memory.OBC1RAM[OBC1.basePtr + (OBC1.address << 2)]);
case 0x7ff1:
return OBC1_RAM[OBC1_BasePtr + (OBC1_Address << 2) + 1];
return (Memory.OBC1RAM[OBC1.basePtr + (OBC1.address << 2) + 1]);
case 0x7ff2:
return OBC1_RAM[OBC1_BasePtr + (OBC1_Address << 2) + 2];
return (Memory.OBC1RAM[OBC1.basePtr + (OBC1.address << 2) + 2]);
case 0x7ff3:
return OBC1_RAM[OBC1_BasePtr + (OBC1_Address << 2) + 3];
return (Memory.OBC1RAM[OBC1.basePtr + (OBC1.address << 2) + 3]);
case 0x7ff4:
return OBC1_RAM[OBC1_BasePtr + (OBC1_Address >> 2) + 0x200];
return (Memory.OBC1RAM[OBC1.basePtr + (OBC1.address >> 2) + 0x200]);
}
return OBC1_RAM[Address & 0x1fff];
return (Memory.OBC1RAM[Address - 0x6000]);
}
void SetOBC1 (uint8 Byte, uint16 Address)
void S9xSetOBC1 (uint8 Byte, uint16 Address)
{
switch(Address) {
switch (Address)
{
case 0x7ff0:
{
OBC1_RAM[OBC1_BasePtr + (OBC1_Address << 2)] = Byte;
Memory.OBC1RAM[OBC1.basePtr + (OBC1.address << 2)] = Byte;
break;
}
case 0x7ff1:
{
OBC1_RAM[OBC1_BasePtr + (OBC1_Address << 2) + 1] = Byte;
Memory.OBC1RAM[OBC1.basePtr + (OBC1.address << 2) + 1] = Byte;
break;
}
case 0x7ff2:
{
OBC1_RAM[OBC1_BasePtr + (OBC1_Address << 2) + 2] = Byte;
Memory.OBC1RAM[OBC1.basePtr + (OBC1.address << 2) + 2] = Byte;
break;
}
case 0x7ff3:
{
OBC1_RAM[OBC1_BasePtr + (OBC1_Address << 2) + 3] = Byte;
Memory.OBC1RAM[OBC1.basePtr + (OBC1.address << 2) + 3] = Byte;
break;
}
case 0x7ff4:
{
unsigned char Temp;
Temp = OBC1_RAM[OBC1_BasePtr + (OBC1_Address >> 2) + 0x200];
Temp = (Temp & ~(3 << OBC1_Shift)) | ((Byte & 3) << OBC1_Shift);
OBC1_RAM[OBC1_BasePtr + (OBC1_Address >> 2) + 0x200] = Temp;
uint8 Temp;
Temp = Memory.OBC1RAM[OBC1.basePtr + (OBC1.address >> 2) + 0x200];
Temp = (Temp & ~(3 << OBC1.shift)) | ((Byte & 3) << OBC1.shift);
Memory.OBC1RAM[OBC1.basePtr + (OBC1.address >> 2) + 0x200] = Temp;
break;
}
case 0x7ff5:
{
if (Byte & 1)
OBC1_BasePtr = 0x1800;
OBC1.basePtr = 0x1800;
else
OBC1_BasePtr = 0x1c00;
OBC1.basePtr = 0x1c00;
break;
}
case 0x7ff6:
{
OBC1_Address = Byte & 0x7f;
OBC1_Shift = (Byte & 3) << 1;
OBC1.address = Byte & 0x7f;
OBC1.shift = (Byte & 3) << 1;
break;
}
}
OBC1_RAM[Address & 0x1fff] = Byte;
Memory.OBC1RAM[Address - 0x6000] = Byte;
}
void S9xResetOBC1 (void)
{
for (int i = 0; i <= 0x1fff; i++)
Memory.OBC1RAM[i] = 0xff;
if (Memory.OBC1RAM[0x1ff5] & 1)
OBC1.basePtr = 0x1800;
else
OBC1.basePtr = 0x1c00;
OBC1.address = Memory.OBC1RAM[0x1ff6] & 0x7f;
OBC1.shift = (Memory.OBC1RAM[0x1ff6] & 3) << 1;
}
uint8 * S9xGetBasePointerOBC1 (uint16 Address)
{
if (Address >= 0x7ff0 && Address <= 0x7ff6)
return (NULL);
return (OBC1_RAM - 0x6000);
return (Memory.OBC1RAM - 0x6000);
}
uint8 * S9xGetMemPointerOBC1 (uint16 Address)
{
if (Address >= 0x7ff0 && Address <= 0x7ff6)
return (NULL);
return (OBC1_RAM - 0x6000 + (Address & 0xffff));
}
void ResetOBC1()
{
OBC1_RAM = &Memory.FillRAM[0x6000];
if (OBC1_RAM[0x1ff5] & 1)
OBC1_BasePtr = 0x1800;
else
OBC1_BasePtr = 0x1c00;
OBC1_Address = OBC1_RAM[0x1ff6] & 0x7f;
OBC1_Shift = (OBC1_RAM[0x1ff6] & 3) << 1;
}
return (Memory.OBC1RAM + Address - 0x6000);
}

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,21 +172,25 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#ifndef _OBC1_H_
#define _OBC1_H_
START_EXTERN_C
uint8 GetOBC1 (uint16 Address);
void SetOBC1 (uint8 Byte, uint16 Address);
struct SOBC1
{
uint16 address;
uint16 basePtr;
uint16 shift;
};
extern struct SOBC1 OBC1;
void S9xSetOBC1 (uint8, uint16);
uint8 S9xGetOBC1 (uint16);
void S9xResetOBC1 (void);
uint8 * S9xGetBasePointerOBC1 (uint16);
uint8 * S9xGetMemPointerOBC1 (uint16);
void ResetOBC1();//bool8 full);
END_EXTERN_C
#endif

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,9 +172,7 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#ifndef _PIXFORM_H_
@ -168,229 +182,226 @@
enum { RGB565, RGB555, BGR565, BGR555, GBR565, GBR555, RGB5551 };
#define BUILD_PIXEL(R,G,B) ((*GFX.BuildPixel) (R, G, B))
#define BUILD_PIXEL2(R,G,B) ((*GFX.BuildPixel2) (R, G, B))
#define DECOMPOSE_PIXEL(Pixel,R,G,B) ((*GFX.DecomposePixel) (Pixel, R,G,B))
#define BUILD_PIXEL(R, G, B) ((*GFX.BuildPixel) (R, G, B))
#define BUILD_PIXEL2(R, G, B) ((*GFX.BuildPixel2) (R, G, B))
#define DECOMPOSE_PIXEL(PIX, R, G, B) ((*GFX.DecomposePixel) (PIX, R, G, B))
extern uint32 RED_LOW_BIT_MASK;
extern uint32 GREEN_LOW_BIT_MASK;
extern uint32 BLUE_LOW_BIT_MASK;
extern uint32 RED_HI_BIT_MASK;
extern uint32 GREEN_HI_BIT_MASK;
extern uint32 BLUE_HI_BIT_MASK;
extern uint32 MAX_RED;
extern uint32 MAX_GREEN;
extern uint32 MAX_BLUE;
extern uint32 SPARE_RGB_BIT_MASK;
extern uint32 GREEN_HI_BIT;
extern uint32 RGB_LOW_BITS_MASK;
extern uint32 RGB_HI_BITS_MASK;
extern uint32 RGB_HI_BITS_MASKx2;
extern uint32 RGB_REMOVE_LOW_BITS_MASK;
extern uint32 FIRST_COLOR_MASK;
extern uint32 SECOND_COLOR_MASK;
extern uint32 THIRD_COLOR_MASK;
extern uint32 ALPHA_BITS_MASK;
extern uint32 FIRST_THIRD_COLOR_MASK;
extern uint32 TWO_LOW_BITS_MASK;
extern uint32 HIGH_BITS_SHIFTED_TWO_MASK;
extern uint32 MAX_RED;
extern uint32 MAX_GREEN;
extern uint32 MAX_BLUE;
extern uint32 RED_LOW_BIT_MASK;
extern uint32 GREEN_LOW_BIT_MASK;
extern uint32 BLUE_LOW_BIT_MASK;
extern uint32 RED_HI_BIT_MASK;
extern uint32 GREEN_HI_BIT_MASK;
extern uint32 BLUE_HI_BIT_MASK;
extern uint32 FIRST_COLOR_MASK;
extern uint32 SECOND_COLOR_MASK;
extern uint32 THIRD_COLOR_MASK;
extern uint32 ALPHA_BITS_MASK;
extern uint32 GREEN_HI_BIT;
extern uint32 RGB_LOW_BITS_MASK;
extern uint32 RGB_HI_BITS_MASK;
extern uint32 RGB_HI_BITS_MASKx2;
extern uint32 RGB_REMOVE_LOW_BITS_MASK;
extern uint32 FIRST_THIRD_COLOR_MASK;
extern uint32 TWO_LOW_BITS_MASK;
extern uint32 HIGH_BITS_SHIFTED_TWO_MASK;
extern uint32 SPARE_RGB_BIT_MASK;
#endif
/* RGB565 format */
#define BUILD_PIXEL_RGB565(R,G,B) (((int) (R) << 11) | ((int) (G) << 6) | (int) (B))
#define BUILD_PIXEL2_RGB565(R,G,B) (((int) (R) << 11) | ((int) (G) << 5) | (int) (B))
#define DECOMPOSE_PIXEL_RGB565(PIX,R,G,B) {(R) = (PIX) >> 11; (G) = ((PIX) >> 6) & 0x1f; (B) = (PIX) & 0x1f; }
#define SPARE_RGB_BIT_MASK_RGB565 (1 << 5)
#define BUILD_PIXEL_RGB565(R, G, B) (((int) (R) << 11) | ((int) (G) << 6) | (int) (B))
#define BUILD_PIXEL2_RGB565(R, G, B) (((int) (R) << 11) | ((int) (G) << 5) | (int) (B))
#define DECOMPOSE_PIXEL_RGB565(PIX, R, G, B) { (R) = (PIX) >> 11; (G) = ((PIX) >> 6) & 0x1f; (B) = (PIX) & 0x1f; }
#define SPARE_RGB_BIT_MASK_RGB565 (1 << 5)
#define MAX_RED_RGB565 31
#define MAX_GREEN_RGB565 63
#define MAX_BLUE_RGB565 31
#define RED_LOW_BIT_MASK_RGB565 0x0800
#define GREEN_LOW_BIT_MASK_RGB565 0x0020
#define BLUE_LOW_BIT_MASK_RGB565 0x0001
#define RED_HI_BIT_MASK_RGB565 0x8000
#define GREEN_HI_BIT_MASK_RGB565 0x0400
#define BLUE_HI_BIT_MASK_RGB565 0x0010
#define FIRST_COLOR_MASK_RGB565 0xF800
#define SECOND_COLOR_MASK_RGB565 0x07E0
#define THIRD_COLOR_MASK_RGB565 0x001F
#define ALPHA_BITS_MASK_RGB565 0x0000
#define MAX_RED_RGB565 31
#define MAX_GREEN_RGB565 63
#define MAX_BLUE_RGB565 31
#define RED_LOW_BIT_MASK_RGB565 0x0800
#define GREEN_LOW_BIT_MASK_RGB565 0x0020
#define BLUE_LOW_BIT_MASK_RGB565 0x0001
#define RED_HI_BIT_MASK_RGB565 0x8000
#define GREEN_HI_BIT_MASK_RGB565 0x0400
#define BLUE_HI_BIT_MASK_RGB565 0x0010
#define FIRST_COLOR_MASK_RGB565 0xF800
#define SECOND_COLOR_MASK_RGB565 0x07E0
#define THIRD_COLOR_MASK_RGB565 0x001F
#define ALPHA_BITS_MASK_RGB565 0x0000
/* RGB555 format */
#define BUILD_PIXEL_RGB555(R,G,B) (((int) (R) << 10) | ((int) (G) << 5) | (int) (B))
#define BUILD_PIXEL2_RGB555(R,G,B) (((int) (R) << 10) | ((int) (G) << 5) | (int) (B))
#define DECOMPOSE_PIXEL_RGB555(PIX,R,G,B) {(R) = (PIX) >> 10; (G) = ((PIX) >> 5) & 0x1f; (B) = (PIX) & 0x1f; }
#define SPARE_RGB_BIT_MASK_RGB555 (1 << 15)
#define BUILD_PIXEL_RGB555(R, G, B) (((int) (R) << 10) | ((int) (G) << 5) | (int) (B))
#define BUILD_PIXEL2_RGB555(R, G, B) (((int) (R) << 10) | ((int) (G) << 5) | (int) (B))
#define DECOMPOSE_PIXEL_RGB555(PIX, R, G, B) { (R) = (PIX) >> 10; (G) = ((PIX) >> 5) & 0x1f; (B) = (PIX) & 0x1f; }
#define SPARE_RGB_BIT_MASK_RGB555 (1 << 15)
#define MAX_RED_RGB555 31
#define MAX_GREEN_RGB555 31
#define MAX_BLUE_RGB555 31
#define RED_LOW_BIT_MASK_RGB555 0x0400
#define GREEN_LOW_BIT_MASK_RGB555 0x0020
#define BLUE_LOW_BIT_MASK_RGB555 0x0001
#define RED_HI_BIT_MASK_RGB555 0x4000
#define GREEN_HI_BIT_MASK_RGB555 0x0200
#define BLUE_HI_BIT_MASK_RGB555 0x0010
#define FIRST_COLOR_MASK_RGB555 0x7C00
#define SECOND_COLOR_MASK_RGB555 0x03E0
#define THIRD_COLOR_MASK_RGB555 0x001F
#define ALPHA_BITS_MASK_RGB555 0x0000
#define MAX_RED_RGB555 31
#define MAX_GREEN_RGB555 31
#define MAX_BLUE_RGB555 31
#define RED_LOW_BIT_MASK_RGB555 0x0400
#define GREEN_LOW_BIT_MASK_RGB555 0x0020
#define BLUE_LOW_BIT_MASK_RGB555 0x0001
#define RED_HI_BIT_MASK_RGB555 0x4000
#define GREEN_HI_BIT_MASK_RGB555 0x0200
#define BLUE_HI_BIT_MASK_RGB555 0x0010
#define FIRST_COLOR_MASK_RGB555 0x7C00
#define SECOND_COLOR_MASK_RGB555 0x03E0
#define THIRD_COLOR_MASK_RGB555 0x001F
#define ALPHA_BITS_MASK_RGB555 0x0000
/* BGR565 format */
#define BUILD_PIXEL_BGR565(R,G,B) (((int) (B) << 11) | ((int) (G) << 6) | (int) (R))
#define BUILD_PIXEL2_BGR565(R,G,B) (((int) (B) << 11) | ((int) (G) << 5) | (int) (R))
#define DECOMPOSE_PIXEL_BGR565(PIX,R,G,B) {(B) = (PIX) >> 11; (G) = ((PIX) >> 6) & 0x1f; (R) = (PIX) & 0x1f; }
#define SPARE_RGB_BIT_MASK_BGR565 (1 << 5)
#define BUILD_PIXEL_BGR565(R, G, B) (((int) (B) << 11) | ((int) (G) << 6) | (int) (R))
#define BUILD_PIXEL2_BGR565(R, G, B) (((int) (B) << 11) | ((int) (G) << 5) | (int) (R))
#define DECOMPOSE_PIXEL_BGR565(PIX, R, G, B) { (B) = (PIX) >> 11; (G) = ((PIX) >> 6) & 0x1f; (R) = (PIX) & 0x1f; }
#define SPARE_RGB_BIT_MASK_BGR565 (1 << 5)
#define MAX_RED_BGR565 31
#define MAX_GREEN_BGR565 63
#define MAX_BLUE_BGR565 31
#define RED_LOW_BIT_MASK_BGR565 0x0001
#define GREEN_LOW_BIT_MASK_BGR565 0x0040
#define BLUE_LOW_BIT_MASK_BGR565 0x0800
#define RED_HI_BIT_MASK_BGR565 0x0010
#define GREEN_HI_BIT_MASK_BGR565 0x0400
#define BLUE_HI_BIT_MASK_BGR565 0x8000
#define FIRST_COLOR_MASK_BGR565 0xF800
#define SECOND_COLOR_MASK_BGR565 0x07E0
#define THIRD_COLOR_MASK_BGR565 0x001F
#define ALPHA_BITS_MASK_BGR565 0x0000
#define MAX_RED_BGR565 31
#define MAX_GREEN_BGR565 63
#define MAX_BLUE_BGR565 31
#define RED_LOW_BIT_MASK_BGR565 0x0001
#define GREEN_LOW_BIT_MASK_BGR565 0x0040
#define BLUE_LOW_BIT_MASK_BGR565 0x0800
#define RED_HI_BIT_MASK_BGR565 0x0010
#define GREEN_HI_BIT_MASK_BGR565 0x0400
#define BLUE_HI_BIT_MASK_BGR565 0x8000
#define FIRST_COLOR_MASK_BGR565 0xF800
#define SECOND_COLOR_MASK_BGR565 0x07E0
#define THIRD_COLOR_MASK_BGR565 0x001F
#define ALPHA_BITS_MASK_BGR565 0x0000
/* BGR555 format */
#define BUILD_PIXEL_BGR555(R,G,B) (((int) (B) << 10) | ((int) (G) << 5) | (int) (R))
#define BUILD_PIXEL2_BGR555(R,G,B) (((int) (B) << 10) | ((int) (G) << 5) | (int) (R))
#define DECOMPOSE_PIXEL_BGR555(PIX,R,G,B) {(B) = (PIX) >> 10; (G) = ((PIX) >> 5) & 0x1f; (R) = (PIX) & 0x1f; }
#define SPARE_RGB_BIT_MASK_BGR555 (1 << 15)
#define BUILD_PIXEL_BGR555(R, G, B) (((int) (B) << 10) | ((int) (G) << 5) | (int) (R))
#define BUILD_PIXEL2_BGR555(R, G, B) (((int) (B) << 10) | ((int) (G) << 5) | (int) (R))
#define DECOMPOSE_PIXEL_BGR555(PIX, R, G, B) { (B) = (PIX) >> 10; (G) = ((PIX) >> 5) & 0x1f; (R) = (PIX) & 0x1f; }
#define SPARE_RGB_BIT_MASK_BGR555 (1 << 15)
#define MAX_RED_BGR555 31
#define MAX_GREEN_BGR555 31
#define MAX_BLUE_BGR555 31
#define RED_LOW_BIT_MASK_BGR555 0x0001
#define GREEN_LOW_BIT_MASK_BGR555 0x0020
#define BLUE_LOW_BIT_MASK_BGR555 0x0400
#define RED_HI_BIT_MASK_BGR555 0x0010
#define GREEN_HI_BIT_MASK_BGR555 0x0200
#define BLUE_HI_BIT_MASK_BGR555 0x4000
#define FIRST_COLOR_MASK_BGR555 0x7C00
#define SECOND_COLOR_MASK_BGR555 0x03E0
#define THIRD_COLOR_MASK_BGR555 0x001F
#define ALPHA_BITS_MASK_BGR555 0x0000
#define MAX_RED_BGR555 31
#define MAX_GREEN_BGR555 31
#define MAX_BLUE_BGR555 31
#define RED_LOW_BIT_MASK_BGR555 0x0001
#define GREEN_LOW_BIT_MASK_BGR555 0x0020
#define BLUE_LOW_BIT_MASK_BGR555 0x0400
#define RED_HI_BIT_MASK_BGR555 0x0010
#define GREEN_HI_BIT_MASK_BGR555 0x0200
#define BLUE_HI_BIT_MASK_BGR555 0x4000
#define FIRST_COLOR_MASK_BGR555 0x7C00
#define SECOND_COLOR_MASK_BGR555 0x03E0
#define THIRD_COLOR_MASK_BGR555 0x001F
#define ALPHA_BITS_MASK_BGR555 0x0000
/* GBR565 format */
#define BUILD_PIXEL_GBR565(R,G,B) (((int) (G) << 11) | ((int) (B) << 6) | (int) (R))
#define BUILD_PIXEL2_GBR565(R,G,B) (((int) (G) << 11) | ((int) (B) << 5) | (int) (R))
#define DECOMPOSE_PIXEL_GBR565(PIX,R,G,B) {(G) = (PIX) >> 11; (B) = ((PIX) >> 6) & 0x1f; (R) = (PIX) & 0x1f; }
#define SPARE_RGB_BIT_MASK_GBR565 (1 << 5)
#define BUILD_PIXEL_GBR565(R, G, B) (((int) (G) << 11) | ((int) (B) << 6) | (int) (R))
#define BUILD_PIXEL2_GBR565(R, G, B) (((int) (G) << 11) | ((int) (B) << 5) | (int) (R))
#define DECOMPOSE_PIXEL_GBR565(PIX, R, G, B) { (G) = (PIX) >> 11; (B) = ((PIX) >> 6) & 0x1f; (R) = (PIX) & 0x1f; }
#define SPARE_RGB_BIT_MASK_GBR565 (1 << 5)
#define MAX_RED_GBR565 31
#define MAX_BLUE_GBR565 63
#define MAX_GREEN_GBR565 31
#define RED_LOW_BIT_MASK_GBR565 0x0001
#define BLUE_LOW_BIT_MASK_GBR565 0x0040
#define GREEN_LOW_BIT_MASK_GBR565 0x0800
#define RED_HI_BIT_MASK_GBR565 0x0010
#define BLUE_HI_BIT_MASK_GBR565 0x0400
#define GREEN_HI_BIT_MASK_GBR565 0x8000
#define FIRST_COLOR_MASK_GBR565 0xF800
#define SECOND_COLOR_MASK_GBR565 0x07E0
#define THIRD_COLOR_MASK_GBR565 0x001F
#define ALPHA_BITS_MASK_GBR565 0x0000
#define MAX_RED_GBR565 31
#define MAX_GREEN_GBR565 31
#define MAX_BLUE_GBR565 63
#define RED_LOW_BIT_MASK_GBR565 0x0001
#define GREEN_LOW_BIT_MASK_GBR565 0x0800
#define BLUE_LOW_BIT_MASK_GBR565 0x0040
#define RED_HI_BIT_MASK_GBR565 0x0010
#define GREEN_HI_BIT_MASK_GBR565 0x8000
#define BLUE_HI_BIT_MASK_GBR565 0x0400
#define FIRST_COLOR_MASK_GBR565 0xF800
#define SECOND_COLOR_MASK_GBR565 0x07E0
#define THIRD_COLOR_MASK_GBR565 0x001F
#define ALPHA_BITS_MASK_GBR565 0x0000
/* GBR555 format */
#define BUILD_PIXEL_GBR555(R,G,B) (((int) (G) << 10) | ((int) (B) << 5) | (int) (R))
#define BUILD_PIXEL2_GBR555(R,G,B) (((int) (G) << 10) | ((int) (B) << 5) | (int) (R))
#define DECOMPOSE_PIXEL_GBR555(PIX,R,G,B) {(G) = (PIX) >> 10; (B) = ((PIX) >> 5) & 0x1f; (R) = (PIX) & 0x1f; }
#define SPARE_RGB_BIT_MASK_GBR555 (1 << 15)
#define BUILD_PIXEL_GBR555(R, G, B) (((int) (G) << 10) | ((int) (B) << 5) | (int) (R))
#define BUILD_PIXEL2_GBR555(R, G, B) (((int) (G) << 10) | ((int) (B) << 5) | (int) (R))
#define DECOMPOSE_PIXEL_GBR555(PIX, R, G, B) { (G) = (PIX) >> 10; (B) = ((PIX) >> 5) & 0x1f; (R) = (PIX) & 0x1f; }
#define SPARE_RGB_BIT_MASK_GBR555 (1 << 15)
#define MAX_RED_GBR555 31
#define MAX_BLUE_GBR555 31
#define MAX_GREEN_GBR555 31
#define RED_LOW_BIT_MASK_GBR555 0x0001
#define BLUE_LOW_BIT_MASK_GBR555 0x0020
#define GREEN_LOW_BIT_MASK_GBR555 0x0400
#define RED_HI_BIT_MASK_GBR555 0x0010
#define BLUE_HI_BIT_MASK_GBR555 0x0200
#define GREEN_HI_BIT_MASK_GBR555 0x4000
#define FIRST_COLOR_MASK_GBR555 0x7C00
#define SECOND_COLOR_MASK_GBR555 0x03E0
#define THIRD_COLOR_MASK_GBR555 0x001F
#define ALPHA_BITS_MASK_GBR555 0x0000
#define MAX_RED_GBR555 31
#define MAX_GREEN_GBR555 31
#define MAX_BLUE_GBR555 31
#define RED_LOW_BIT_MASK_GBR555 0x0001
#define GREEN_LOW_BIT_MASK_GBR555 0x0400
#define BLUE_LOW_BIT_MASK_GBR555 0x0020
#define RED_HI_BIT_MASK_GBR555 0x0010
#define GREEN_HI_BIT_MASK_GBR555 0x4000
#define BLUE_HI_BIT_MASK_GBR555 0x0200
#define FIRST_COLOR_MASK_GBR555 0x7C00
#define SECOND_COLOR_MASK_GBR555 0x03E0
#define THIRD_COLOR_MASK_GBR555 0x001F
#define ALPHA_BITS_MASK_GBR555 0x0000
/* RGB5551 format */
#define BUILD_PIXEL_RGB5551(R,G,B) (((int) (R) << 11) | ((int) (G) << 6) | (int) ((B) << 1) | 1)
#define BUILD_PIXEL2_RGB5551(R,G,B) (((int) (R) << 11) | ((int) (G) << 6) | (int) ((B) << 1) | 1)
#define DECOMPOSE_PIXEL_RGB5551(PIX,R,G,B) {(R) = (PIX) >> 11; (G) = ((PIX) >> 6) & 0x1f; (B) = ((PIX) >> 1) & 0x1f; }
#define SPARE_RGB_BIT_MASK_RGB5551 (1)
#define BUILD_PIXEL_RGB5551(R, G, B) (((int) (R) << 11) | ((int) (G) << 6) | (int) ((B) << 1) | 1)
#define BUILD_PIXEL2_RGB5551(R, G, B) (((int) (R) << 11) | ((int) (G) << 6) | (int) ((B) << 1) | 1)
#define DECOMPOSE_PIXEL_RGB5551(PIX, R, G, B) { (R) = (PIX) >> 11; (G) = ((PIX) >> 6) & 0x1f; (B) = ((PIX) >> 1) & 0x1f; }
#define SPARE_RGB_BIT_MASK_RGB5551 (1)
#define MAX_RED_RGB5551 31
#define MAX_GREEN_RGB5551 31
#define MAX_BLUE_RGB5551 31
#define RED_LOW_BIT_MASK_RGB5551 0x0800
#define GREEN_LOW_BIT_MASK_RGB5551 0x0040
#define BLUE_LOW_BIT_MASK_RGB5551 0x0002
#define RED_HI_BIT_MASK_RGB5551 0x8000
#define GREEN_HI_BIT_MASK_RGB5551 0x0400
#define BLUE_HI_BIT_MASK_RGB5551 0x0020
#define FIRST_COLOR_MASK_RGB5551 0xf800
#define SECOND_COLOR_MASK_RGB5551 0x07c0
#define THIRD_COLOR_MASK_RGB5551 0x003e
#define ALPHA_BITS_MASK_RGB5551 0x0001
#define MAX_RED_RGB5551 31
#define MAX_GREEN_RGB5551 31
#define MAX_BLUE_RGB5551 31
#define RED_LOW_BIT_MASK_RGB5551 0x0800
#define GREEN_LOW_BIT_MASK_RGB5551 0x0040
#define BLUE_LOW_BIT_MASK_RGB5551 0x0002
#define RED_HI_BIT_MASK_RGB5551 0x8000
#define GREEN_HI_BIT_MASK_RGB5551 0x0400
#define BLUE_HI_BIT_MASK_RGB5551 0x0020
#define FIRST_COLOR_MASK_RGB5551 0xf800
#define SECOND_COLOR_MASK_RGB5551 0x07c0
#define THIRD_COLOR_MASK_RGB5551 0x003e
#define ALPHA_BITS_MASK_RGB5551 0x0001
#ifndef GFX_MULTI_FORMAT
#define CONCAT(X,Y) X##Y
/* C pre-processor needs a two stage macro define to enable it to concat
* to macro names together to form the name of another macro. */
#define BUILD_PIXEL_D(F,R,G,B) CONCAT(BUILD_PIXEL_,F) (R,G,B)
#define BUILD_PIXEL2_D(F,R,G,B) CONCAT(BUILD_PIXEL2_,F) (R,G,B)
#define DECOMPOSE_PIXEL_D(F,PIX,R,G,B) CONCAT(DECOMPOSE_PIXEL_,F) (PIX,R,G,B)
#define CONCAT(X, Y) X##Y
#define BUILD_PIXEL(R,G,B) BUILD_PIXEL_D(PIXEL_FORMAT,R,G,B)
#define BUILD_PIXEL2(R,G,B) BUILD_PIXEL2_D(PIXEL_FORMAT,R,G,B)
#define DECOMPOSE_PIXEL(PIX,R,G,B) DECOMPOSE_PIXEL_D(PIXEL_FORMAT,PIX,R,G,B)
// C pre-processor needs a two stage macro define to enable it to concat
// to macro names together to form the name of another macro.
#define BUILD_PIXEL_D(F, R, G, B) CONCAT(BUILD_PIXEL_,F) (R, G, B)
#define BUILD_PIXEL2_D(F, R, G, B) CONCAT(BUILD_PIXEL2_,F) (R, G, B)
#define DECOMPOSE_PIXEL_D(F, PIX, R, G, B) CONCAT(DECOMPOSE_PIXEL_,F) (PIX, R, G, B)
#define MAX_RED_D(F) CONCAT(MAX_RED_,F)
#define MAX_BLUE_D(F) CONCAT(MAX_BLUE_,F)
#define MAX_GREEN_D(F) CONCAT(MAX_GREEN_,F)
#define RED_LOW_BIT_MASK_D(F) CONCAT(RED_LOW_BIT_MASK_,F)
#define BLUE_LOW_BIT_MASK_D(F) CONCAT(BLUE_LOW_BIT_MASK_,F)
#define GREEN_LOW_BIT_MASK_D(F) CONCAT(GREEN_LOW_BIT_MASK_,F)
#define RED_HI_BIT_MASK_D(F) CONCAT(RED_HI_BIT_MASK_,F)
#define BLUE_HI_BIT_MASK_D(F) CONCAT(BLUE_HI_BIT_MASK_,F)
#define GREEN_HI_BIT_MASK_D(F) CONCAT(GREEN_HI_BIT_MASK_,F)
#define FIRST_COLOR_MASK_D(F) CONCAT(FIRST_COLOR_MASK_,F)
#define SECOND_COLOR_MASK_D(F) CONCAT(SECOND_COLOR_MASK_,F)
#define THIRD_COLOR_MASK_D(F) CONCAT(THIRD_COLOR_MASK_,F)
#define ALPHA_BITS_MASK_D(F) CONCAT(ALPHA_BITS_MASK_,F)
#define BUILD_PIXEL(R, G, B) BUILD_PIXEL_D(PIXEL_FORMAT, R, G, B)
#define BUILD_PIXEL2(R, G, B) BUILD_PIXEL2_D(PIXEL_FORMAT, R, G, B)
#define DECOMPOSE_PIXEL(PIX, R, G, B) DECOMPOSE_PIXEL_D(PIXEL_FORMAT, PIX, R, G, B)
#define MAX_RED MAX_RED_D(PIXEL_FORMAT)
#define MAX_BLUE MAX_BLUE_D(PIXEL_FORMAT)
#define MAX_GREEN MAX_GREEN_D(PIXEL_FORMAT)
#define RED_LOW_BIT_MASK RED_LOW_BIT_MASK_D(PIXEL_FORMAT)
#define BLUE_LOW_BIT_MASK BLUE_LOW_BIT_MASK_D(PIXEL_FORMAT)
#define GREEN_LOW_BIT_MASK GREEN_LOW_BIT_MASK_D(PIXEL_FORMAT)
#define RED_HI_BIT_MASK RED_HI_BIT_MASK_D(PIXEL_FORMAT)
#define BLUE_HI_BIT_MASK BLUE_HI_BIT_MASK_D(PIXEL_FORMAT)
#define GREEN_HI_BIT_MASK GREEN_HI_BIT_MASK_D(PIXEL_FORMAT)
#define FIRST_COLOR_MASK FIRST_COLOR_MASK_D(PIXEL_FORMAT)
#define SECOND_COLOR_MASK SECOND_COLOR_MASK_D(PIXEL_FORMAT)
#define THIRD_COLOR_MASK THIRD_COLOR_MASK_D(PIXEL_FORMAT)
#define ALPHA_BITS_MASK ALPHA_BITS_MASK_D(PIXEL_FORMAT)
#define MAX_RED_D(F) CONCAT(MAX_RED_, F)
#define MAX_GREEN_D(F) CONCAT(MAX_GREEN_, F)
#define MAX_BLUE_D(F) CONCAT(MAX_BLUE_, F)
#define RED_LOW_BIT_MASK_D(F) CONCAT(RED_LOW_BIT_MASK_, F)
#define GREEN_LOW_BIT_MASK_D(F) CONCAT(GREEN_LOW_BIT_MASK_, F)
#define BLUE_LOW_BIT_MASK_D(F) CONCAT(BLUE_LOW_BIT_MASK_, F)
#define RED_HI_BIT_MASK_D(F) CONCAT(RED_HI_BIT_MASK_, F)
#define GREEN_HI_BIT_MASK_D(F) CONCAT(GREEN_HI_BIT_MASK_, F)
#define BLUE_HI_BIT_MASK_D(F) CONCAT(BLUE_HI_BIT_MASK_, F)
#define FIRST_COLOR_MASK_D(F) CONCAT(FIRST_COLOR_MASK_, F)
#define SECOND_COLOR_MASK_D(F) CONCAT(SECOND_COLOR_MASK_, F)
#define THIRD_COLOR_MASK_D(F) CONCAT(THIRD_COLOR_MASK_, F)
#define ALPHA_BITS_MASK_D(F) CONCAT(ALPHA_BITS_MASK_, F)
#define GREEN_HI_BIT ((MAX_GREEN + 1) >> 1)
#define RGB_LOW_BITS_MASK (RED_LOW_BIT_MASK | GREEN_LOW_BIT_MASK | \
BLUE_LOW_BIT_MASK)
#define RGB_HI_BITS_MASK (RED_HI_BIT_MASK | GREEN_HI_BIT_MASK | \
BLUE_HI_BIT_MASK)
#define RGB_HI_BITS_MASKx2 ((RED_HI_BIT_MASK | GREEN_HI_BIT_MASK | \
BLUE_HI_BIT_MASK) << 1)
#define RGB_REMOVE_LOW_BITS_MASK (~RGB_LOW_BITS_MASK)
#define FIRST_THIRD_COLOR_MASK (FIRST_COLOR_MASK | THIRD_COLOR_MASK)
#define TWO_LOW_BITS_MASK (RGB_LOW_BITS_MASK | (RGB_LOW_BITS_MASK << 1))
#define HIGH_BITS_SHIFTED_TWO_MASK (( (FIRST_COLOR_MASK | SECOND_COLOR_MASK | THIRD_COLOR_MASK) & \
~TWO_LOW_BITS_MASK ) >> 2)
#endif
#define MAX_RED MAX_RED_D(PIXEL_FORMAT)
#define MAX_GREEN MAX_GREEN_D(PIXEL_FORMAT)
#define MAX_BLUE MAX_BLUE_D(PIXEL_FORMAT)
#define RED_LOW_BIT_MASK RED_LOW_BIT_MASK_D(PIXEL_FORMAT)
#define GREEN_LOW_BIT_MASK GREEN_LOW_BIT_MASK_D(PIXEL_FORMAT)
#define BLUE_LOW_BIT_MASK BLUE_LOW_BIT_MASK_D(PIXEL_FORMAT)
#define RED_HI_BIT_MASK RED_HI_BIT_MASK_D(PIXEL_FORMAT)
#define GREEN_HI_BIT_MASK GREEN_HI_BIT_MASK_D(PIXEL_FORMAT)
#define BLUE_HI_BIT_MASK BLUE_HI_BIT_MASK_D(PIXEL_FORMAT)
#define FIRST_COLOR_MASK FIRST_COLOR_MASK_D(PIXEL_FORMAT)
#define SECOND_COLOR_MASK SECOND_COLOR_MASK_D(PIXEL_FORMAT)
#define THIRD_COLOR_MASK THIRD_COLOR_MASK_D(PIXEL_FORMAT)
#define ALPHA_BITS_MASK ALPHA_BITS_MASK_D(PIXEL_FORMAT)
#define GREEN_HI_BIT ((MAX_GREEN + 1) >> 1)
#define RGB_LOW_BITS_MASK (RED_LOW_BIT_MASK | GREEN_LOW_BIT_MASK | BLUE_LOW_BIT_MASK)
#define RGB_HI_BITS_MASK (RED_HI_BIT_MASK | GREEN_HI_BIT_MASK | BLUE_HI_BIT_MASK)
#define RGB_HI_BITS_MASKx2 ((RED_HI_BIT_MASK | GREEN_HI_BIT_MASK | BLUE_HI_BIT_MASK) << 1)
#define RGB_REMOVE_LOW_BITS_MASK (~RGB_LOW_BITS_MASK)
#define FIRST_THIRD_COLOR_MASK (FIRST_COLOR_MASK | THIRD_COLOR_MASK)
#define TWO_LOW_BITS_MASK (RGB_LOW_BITS_MASK | (RGB_LOW_BITS_MASK << 1))
#define HIGH_BITS_SHIFTED_TWO_MASK (((FIRST_COLOR_MASK | SECOND_COLOR_MASK | THIRD_COLOR_MASK) & ~TWO_LOW_BITS_MASK ) >> 2)
#endif
#endif

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,246 +172,151 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#ifndef _PORT_H_
#define _PORT_H_
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#ifndef STORM
//#include <memory.h>
#include <string.h>
#else
#include <time.h>
#include <string.h>
#ifdef HAVE_STRINGS_H
#include <strings.h>
#include <clib/powerpc_protos.h>
#endif
#ifndef ACCEPT_SIZE_T
#ifdef __WIN32__
#define ACCEPT_SIZE_T int
#else
#define ACCEPT_SIZE_T unsigned int
#endif
#endif
#include <sys/types.h>
/* #define PIXEL_FORMAT RGB565 */
#ifdef __WIN32__
#define NOMINMAX
#include <windows.h>
#endif
#define GFX_MULTI_FORMAT
#ifndef NOASM
//#define USE_X86_ASM
#ifdef __WIN32__
//#define RIGHTSHIFT_IS_SAR
#define RIGHTSHIFT_int8_IS_SAR
#define RIGHTSHIFT_int16_IS_SAR
#define RIGHTSHIFT_int32_IS_SAR
#define SNES_JOY_READ_CALLBACKS
#endif
#ifdef __MACOSX__
#ifdef _C
#undef _C
#endif
#ifdef _D
#undef _D
#endif
#define CHECK_SOUND()
#define PIXEL_FORMAT RGB555
#undef GFX_MULTI_FORMAT
#undef USE_X86_ASM
#undef _MAX_PATH
#define SET_UI_COLOR(r,g,b) SetInfoDlgColor(r,g,b)
void SetInfoDlgColor(unsigned char, unsigned char, unsigned char);
#endif /* __MACOSX__ */
#undef GFX_MULTI_FORMAT
#define PIXEL_FORMAT RGB555
#endif
#ifndef snes9x_types_defined
#define snes9x_types_defined
typedef unsigned char bool8;
typedef unsigned char bool8;
#ifdef HAVE_STDINT_H
#include <stdint.h>
typedef int8_t int8;
typedef uint8_t uint8;
typedef int16_t int16;
typedef uint16_t uint16;
typedef int32_t int32;
typedef uint32_t uint32;
typedef int64_t int64;
typedef uint64_t uint64;
typedef intptr_t pint;
#else /* Don't have stdint.h */
typedef intptr_t pint;
typedef int8_t int8;
typedef uint8_t uint8;
typedef int16_t int16;
typedef uint16_t uint16;
typedef int32_t int32;
typedef uint32_t uint32;
typedef int64_t int64;
typedef uint64_t uint64;
#else // HAVE_STDINT_H
#ifdef PTR_NOT_INT
typedef long pint;
#else /* pointer is int */
typedef int pint;
#endif /* PTR_NOT_INT */
/* FIXME: Refactor this by moving out the BORLAND part and unifying typedefs */
#ifndef __WIN32__
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef signed char int8;
typedef short int16;
typedef int int32;
typedef unsigned int uint32;
# ifdef __GNUC__ /* long long is not part of ISO C++ */
__extension__
# endif
typedef long long int64;
typedef unsigned long long uint64;
#else /* __WIN32__ */
#ifndef PATH_MAX
#define PATH_MAX _MAX_PATH
typedef long pint;
#else
typedef int pint;
#endif
# ifdef __BORLANDC__
# include <systypes.h>
# else
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef signed char int8;
typedef short int16;
# ifndef WSAAPI
/* winsock2.h typedefs int32 as well. */
typedef long int32;
# define PLAT_SOUND_BUFFER SoundBuffer
# define RIGHTSHIFT_IS_SAR
# endif
# if defined(_MSC_VER) && (_MSC_VER == 1400) /* VC8.0 */
/* temporary solution for fatal error C1063 (cl.exe 14.00.50727.762) */
# ifdef RIGHTSHIFT_IS_SAR
# undef RIGHTSHIFT_IS_SAR
# endif /* RIGHTSHIFT_IS_SAR */
# define RIGHTSHIFT_INT8_IS_SAR
# define RIGHTSHIFT_INT16_IS_SAR
# define RIGHTSHIFT_INT32_IS_SAR
# endif /* VC8.0 */
typedef unsigned int uint32;
# endif /* __BORLANDC__ */
typedef __int64 int64;
typedef unsigned __int64 uint64;
#endif /* __WIN32__ */
#endif /* HAVE_STDINT_H */
#endif /* snes9x_types_defined */
#include "pixform.h"
#ifdef __WIN32__
#ifdef __BORLANDC__
#include <systypes.h>
#else
typedef signed char int8;
typedef unsigned char uint8;
typedef signed short int16;
typedef unsigned short uint16;
#ifndef WSAAP
// winsock2.h typedefs int32 as well
typedef signed int int32;
#endif
typedef unsigned int uint32;
#endif
typedef unsigned char uint8_t;
typedef signed __int64 int64;
typedef unsigned __int64 uint64;
typedef int socklen_t;
#else // __WIN32__
typedef signed char int8;
typedef unsigned char uint8;
typedef signed short int16;
typedef unsigned short uint16;
typedef signed int int32;
typedef unsigned int uint32;
#ifdef __GNUC__
// long long is not part of ISO C++
__extension__
#endif
typedef long long int64;
typedef unsigned long long uint64;
#endif // __WIN32__
#endif // HAVE_STDINT_H
#endif // snes9x_types_defined
#ifndef TRUE
#define TRUE 1
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#define FALSE 0
#endif
#ifdef STORM
#define EXTERN_C
#define START_EXTERN_C
#define END_EXTERN_C
#define START_EXTERN_C extern "C" {
#define END_EXTERN_C }
#ifndef __WIN32__
#ifndef PATH_MAX
#define PATH_MAX 1024
#endif
#define _MAX_DRIVE 1
#define _MAX_DIR PATH_MAX
#define _MAX_FNAME PATH_MAX
#define _MAX_EXT PATH_MAX
#define _MAX_PATH PATH_MAX
#else
#if defined(__cplusplus) || defined(c_plusplus)
#define EXTERN_C extern "C"
#define START_EXTERN_C extern "C" {
#define END_EXTERN_C }
#else
#define EXTERN_C extern
#define START_EXTERN_C
#define END_EXTERN_C
#ifndef PATH_MAX
#define PATH_MAX _MAX_PATH
#endif
#endif
#ifndef __WIN32__
#ifndef PATH_MAX
#define PATH_MAX 1024
#endif
#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 ZeroMemory(a,b) memset((a),0,(b))
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 strncasecmp strnicmp
#define SNES_JOY_READ_CALLBACKS
#endif
EXTERN_C void S9xGenerateSound ();
#ifdef __WIN32__
EXTERN_C void S9xGenerateFrameSound ();
#endif
#ifdef STORM
EXTERN_C int soundsignal;
EXTERN_C void MixSound(void);
/* Yes, CHECK_SOUND is getting defined correctly! */
#define CHECK_SOUND if (Settings.APUEnabled) if(SetSignalPPC(0L, soundsignal) & soundsignal) MixSound
#define ZeroMemory(a, b) memset((a), 0, (b))
void _splitpath (const char *, char *, char *, char *, char *);
void _makepath (char *, const char *, const char *, const char *, const char *);
#define S9xDisplayString DisplayStringFromBottom
#else
#define CHECK_SOUND()
#define snprintf _snprintf
#define strcasecmp stricmp
#define strncasecmp strnicmp
void WinDisplayStringFromBottom(const char *string, int linesFromBottom, int pixelsFromLeft, bool allowWrap);
#define S9xDisplayString WinDisplayStringFromBottom
#endif
#ifdef __DJGPP
#define SLASH_STR "\\"
#define SLASH_CHAR '\\'
#define SLASH_STR "\\"
#define SLASH_CHAR '\\'
#else
#define SLASH_STR "/"
#define SLASH_CHAR '/'
#define SLASH_STR "/"
#define SLASH_CHAR '/'
#endif
/* Taken care of in signal.h on Linux.
* #ifdef __linux
* typedef void (*SignalHandler)(int);
* #define SIG_PF SignalHandler
* #endif
*/
/* If including signal.h, do it before snes9.h and port.h to avoid clashes. */
#ifndef SIG_PF
#define SIG_PF void(*)(int)
#endif
#if defined(__i386__) || defined(__i486__) || defined(__i586__) || \
defined(__x86_64__) || defined(__WIN32__) || defined(__alpha__)
#define LSB_FIRST
#define FAST_LSB_WORD_ACCESS
#else
#define MSB_FIRST
#endif
#ifdef __sun
#define TITLE "Snes9X: Solaris"
#define SIG_PF void (*) (int)
#endif
#ifdef __linux
#define TITLE "Snes9X: Linux"
#define TITLE "Snes9x: Linux"
#define SYS_CONFIG_FILE "/etc/snes9x/snes9x.conf"
#endif
@ -403,41 +324,32 @@ EXTERN_C void MixSound(void);
#define TITLE "Snes9x"
#endif
#ifdef STORM
#define STATIC
#define strncasecmp strnicmp
#if defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) || defined(__x86_64__) || defined(__alpha__) || defined(__MIPSEL__) || defined(_M_IX86)
#define LSB_FIRST
#define FAST_LSB_WORD_ACCESS
#else
#define STATIC static
#define MSB_FIRST
#endif
#ifdef FAST_LSB_WORD_ACCESS
#define READ_WORD(s) (*(uint16 *) (s))
#define READ_3WORD(s) (0x00ffffff & *(uint32 *) (s))
#define READ_DWORD(s) (*(uint32 *) (s))
#define WRITE_WORD(s, d) (*(uint16 *) (s)) = (d)
#define WRITE_3WORD(s, d) *(uint16 *) (s) = (uint16)(d),\
*((uint8 *) (s) + 2) = (uint8) ((d) >> 16)
#define WRITE_DWORD(s, d) (*(uint32 *) (s)) = (d)
#define READ_WORD(s) (*(uint16 *) (s))
#define READ_3WORD(s) (*(uint32 *) (s) & 0x00ffffff)
#define READ_DWORD(s) (*(uint32 *) (s))
#define WRITE_WORD(s, d) *(uint16 *) (s) = (d)
#define WRITE_3WORD(s, d) *(uint16 *) (s) = (uint16) (d), *((uint8 *) (s) + 2) = (uint8) ((d) >> 16)
#define WRITE_DWORD(s, d) *(uint32 *) (s) = (d)
#else
#define READ_WORD(s) ( *(uint8 *) (s) |\
(*((uint8 *) (s) + 1) << 8))
#define READ_3WORD(s) ( *(uint8 *) (s) |\
(*((uint8 *) (s) + 1) << 8) |\
(*((uint8 *) (s) + 2) << 16))
#define READ_DWORD(s) ( *(uint8 *) (s) |\
(*((uint8 *) (s) + 1) << 8) |\
(*((uint8 *) (s) + 2) << 16) |\
(*((uint8 *) (s) + 3) << 24))
#define WRITE_WORD(s, d) *(uint8 *) (s) = (d), \
*((uint8 *) (s) + 1) = (d) >> 8
#define WRITE_3WORD(s, d) *(uint8 *) (s) = (uint8) (d), \
*((uint8 *) (s) + 1) = (uint8) ((d) >> 8),\
*((uint8 *) (s) + 2) = (uint8) ((d) >> 16)
#define WRITE_DWORD(s, d) *(uint8 *) (s) = (uint8) (d), \
*((uint8 *) (s) + 1) = (uint8) ((d) >> 8),\
*((uint8 *) (s) + 2) = (uint8) ((d) >> 16),\
*((uint8 *) (s) + 3) = (uint8) ((d) >> 24)
#define READ_WORD(s) (*(uint8 *) (s) | (*((uint8 *) (s) + 1) << 8))
#define READ_3WORD(s) (*(uint8 *) (s) | (*((uint8 *) (s) + 1) << 8) | (*((uint8 *) (s) + 2) << 16))
#define READ_DWORD(s) (*(uint8 *) (s) | (*((uint8 *) (s) + 1) << 8) | (*((uint8 *) (s) + 2) << 16) | (*((uint8 *) (s) + 3) << 24))
#define WRITE_WORD(s, d) *(uint8 *) (s) = (uint8) (d), *((uint8 *) (s) + 1) = (uint8) ((d) >> 8)
#define WRITE_3WORD(s, d) *(uint8 *) (s) = (uint8) (d), *((uint8 *) (s) + 1) = (uint8) ((d) >> 8), *((uint8 *) (s) + 2) = (uint8) ((d) >> 16)
#define WRITE_DWORD(s, d) *(uint8 *) (s) = (uint8) (d), *((uint8 *) (s) + 1) = (uint8) ((d) >> 8), *((uint8 *) (s) + 2) = (uint8) ((d) >> 16), *((uint8 *) (s) + 3) = (uint8) ((d) >> 24)
#endif
#endif
#define SWAP_WORD(s) (s) = (((s) & 0xff) << 8) | (((s) & 0xff00) >> 8)
#define SWAP_DWORD(s) (s) = (((s) & 0xff) << 24) | (((s) & 0xff00) << 8) | (((s) & 0xff0000) >> 8) | (((s) & 0xff000000) >> 24)
#include "pixform.h"
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

353
source/snes9x/reader.cpp Normal file
View File

@ -0,0 +1,353 @@
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
Jerremy Koot (jkoot@snes9x.com)
(c) Copyright 2002 - 2004 Matthew Kendora
(c) Copyright 2002 - 2005 Peter Bortas (peter@bortas.org)
(c) Copyright 2004 - 2005 Joel Yliluoma (http://iki.fi/bisqwit/)
(c) Copyright 2001 - 2006 John Weidman (jweidman@slip.net)
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
zones
C4 x86 assembler and some C emulation code
(c) Copyright 2000 - 2003 _Demo_ (_demo_@zsnes.com),
Nach,
zsKnight (zsknight@zsnes.com)
C4 C++ code
(c) Copyright 2003 - 2006 Brad Jorsch,
Nach
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
Kris Bleakley,
Matthew Kendora,
Nach,
neviksti (neviksti@hotmail.com)
DSP-2 emulator code
(c) Copyright 2003 John Weidman,
Kris Bleakley,
Lord Nightmare (lord_nightmare@users.sourceforge.net),
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
Lancer,
z80 gaiden
DSP-4 emulator code
(c) Copyright 2004 - 2006 Dreamer Nom,
John Weidman,
Kris Bleakley,
Nach,
z80 gaiden
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
(c) Copyright 2003 Feather,
John Weidman,
Kris Bleakley,
Matthew Kendora
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
2xSaI filter
(c) Copyright 1999 - 2001 Derek Liauw Kie Fa
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
fee, providing that this license information and copyright notice appear
with all copies and any derived work.
This software is provided 'as-is', without any express or implied
warranty. In no event shall the authors be held liable for any damages
arising from the use of this software or it's derivatives.
Snes9x is freeware for PERSONAL USE only. Commercial users should
seek permission of the copyright holders first. Commercial use includes,
but is not limited to, charging money for Snes9x or software derived from
Snes9x, including Snes9x or derivatives in commercial game bundles, and/or
using Snes9x as a promotion for your commercial product.
The copyright holders request that bug fixes and improvements to the code
should be forwarded to them so everyone can benefit from the modifications
in future versions.
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
***********************************************************************************/
// Abstract the details of reading from zip files versus FILE *'s.
#include <string>
#ifdef UNZIP_SUPPORT
#include "unzip.h"
#endif
#include "snes9x.h"
#include "reader.h"
// Generic constructor/destructor
Reader::Reader (void)
{
return;
}
Reader::~Reader (void)
{
return;
}
// Generic getline function, based on gets. Reimlpement if you can do better.
char * Reader::getline (void)
{
bool eof;
std::string ret;
ret = getline(eof);
if (ret.size() == 0 && eof)
return (NULL);
return (strdup(ret.c_str()));
}
std::string Reader::getline (bool &eof)
{
char buf[1024];
std::string ret;
eof = false;
ret.clear();
do
{
if (gets(buf, sizeof(buf)) == NULL)
{
eof = true;
break;
}
ret.append(buf);
}
while (*ret.rbegin() != '\n');
return (ret);
}
// snes9x.h STREAM reader
fReader::fReader (STREAM f)
{
fp = f;
}
fReader::~fReader (void)
{
return;
}
int fReader::get_char (void)
{
return (GETC_STREAM(fp));
}
char * fReader::gets (char *buf, size_t len)
{
return (GETS_STREAM(buf, len, fp));
}
size_t fReader::read (char *buf, size_t len)
{
return (READ_STREAM(buf, len, fp));
}
// unzip reader
#ifdef UNZIP_SUPPORT
unzReader::unzReader (unzFile &v)
{
file = v;
head = NULL;
numbytes = 0;
}
unzReader::~unzReader (void)
{
return;
}
int unzReader::get_char (void)
{
unsigned char c;
if (numbytes <= 0)
{
numbytes = unzReadCurrentFile(file, buffer, unz_BUFFSIZ);
if (numbytes <= 0)
return (EOF);
head = buffer;
}
c = *head;
head++;
numbytes--;
return ((int) c);
}
char * unzReader::gets (char *buf, size_t len)
{
size_t i;
int c;
for (i = 0; i < len - 1; i++)
{
c = get_char();
if (c == EOF)
{
if (i == 0)
return (NULL);
break;
}
buf[i] = (char) c;
if (buf[i] == '\n')
break;
}
buf[i] = '\0';
return (buf);
}
size_t unzReader::read (char *buf, size_t len)
{
if (len == 0)
return (len);
if (len <= numbytes)
{
memcpy(buf, head, len);
numbytes -= len;
head += len;
return (len);
}
size_t numread = 0;
if (numbytes > 0)
{
memcpy(buf, head, numbytes);
numread += numbytes;
head = NULL;
numbytes = 0;
}
int l = unzReadCurrentFile(file, buf + numread, len - numread);
if (l > 0)
numread += l;
return (numread);
}
#endif

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,70 +172,57 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#ifndef _READER_H_
#define _READER_H_
#ifndef _3D_H_
#define _3D_H_
#if defined(USE_OPENGL)
#include <GL/gl.h>
#include <GL/glu.h>
#ifdef __linux__
#include <GL/glx.h>
#endif
typedef struct
class Reader
{
bool8 packed_pixels_extension_present;
bool8 draw_cube;
uint32 version;
// Texture format
GLint internal_format;
GLint format;
GLint type;
public:
Reader (void);
virtual ~Reader (void);
virtual int get_char (void) = 0;
virtual char * gets (char *, size_t) = 0;
virtual char * getline (void); // free() when done
virtual std::string getline (bool &);
virtual size_t read (char *, size_t) = 0;
};
GLint max_texture_size;// 256 or 512
GLint texture_size;
uint32 num_textures; // 1 if max_texture_size == 256, 2 otherwise
GLuint textures [2];
bool8 initialized;
} OpenGLData;
extern OpenGLData OpenGL;
bool8 S9xOpenGLInit ();
bool8 S9xOpenGLInit2 ();
void S9xOpenGLPutImage (int width, int height);
void S9xOpenGLDeinit ();
#endif
#ifdef USE_GLIDE
#include <glide.h>
typedef struct
class fReader : public Reader
{
bool8 voodoo_present;
GrVertex sq[4];
GrTexInfo texture;
int32 texture_mem_size;
int32 texture_mem_start;
float x_offset, y_offset;
float x_scale, y_scale;
float voodoo_width;
float voodoo_height;
} GlideData;
public:
fReader (STREAM);
virtual ~fReader (void);
virtual int get_char (void);
virtual char * gets (char *, size_t);
virtual size_t read (char *, size_t);
extern GlideData Glide;
bool8 S9xGlideEnable (bool8 enable);
void S9xGlideDeinit ();
bool8 S9xGlideInit ();
bool8 S9xVoodooInitialise ();
#endif
private:
STREAM fp;
};
#ifdef UNZIP_SUPPORT
#define unz_BUFFSIZ 1024
class unzReader : public Reader
{
public:
unzReader (unzFile &);
virtual ~unzReader (void);
virtual int get_char (void);
virtual char * gets (char *, size_t);
virtual size_t read (char *, size_t);
private:
unzFile file;
char buffer[unz_BUFFSIZ];
char *head;
size_t numbytes;
};
#endif
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,153 +172,152 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#ifndef _SA1_H_
#define _SA1_H_
#ifndef _sa1_h_
#define _sa1_h_
#include "memmap.h"
struct SSA1Registers {
uint8 DB;
pair P;
pair A;
pair D;
pair S;
pair X;
pair Y;
PC_t PC;
struct SSA1Registers
{
uint8 DB;
pair P;
pair A;
pair D;
pair S;
pair X;
pair Y;
PC_t PC;
};
struct SSA1 {
struct SOpcodes *S9xOpcodes;
uint8 *S9xOpLengths;
uint8 _Carry;
uint8 _Zero;
uint8 _Negative;
uint8 _Overflow;
bool8 CPUExecuting;
uint32 ShiftedPB;
uint32 ShiftedDB;
uint32 Flags;
bool8 Executing;
bool8 NMIActive;
bool8 IRQActive;
bool8 WaitingForInterrupt;
bool8 Waiting;
// uint8 WhichEvent;
uint8 *PCBase;
uint8 *BWRAM;
uint32 PBPCAtOpcodeStart;
uint32 WaitAddress;
uint32 WaitCounter;
uint8 *WaitByteAddress1;
uint8 *WaitByteAddress2;
// int32 Cycles;
// int32 NextEvent;
// int32 V_Counter;
uint8 *Map [MEMMAP_NUM_BLOCKS];
uint8 *WriteMap [MEMMAP_NUM_BLOCKS];
int16 op1;
int16 op2;
int32 arithmetic_op;
int64 sum;
bool8 overflow;
uint8 VirtualBitmapFormat;
bool8 in_char_dma;
uint8 variable_bit_pos;
struct SSA1
{
struct SOpcodes *S9xOpcodes;
uint8 *S9xOpLengths;
uint8 _Carry;
uint8 _Zero;
uint8 _Negative;
uint8 _Overflow;
bool8 CPUExecuting;
uint32 ShiftedPB;
uint32 ShiftedDB;
uint32 Flags;
uint8 *PCBase;
bool8 IRQActive;
bool8 Waiting;
bool8 WaitingForInterrupt;
uint32 WaitAddress;
uint32 WaitCounter;
uint32 PBPCAtOpcodeStart;
uint8 *WaitByteAddress1;
uint8 *WaitByteAddress2;
uint8 *Map[MEMMAP_NUM_BLOCKS];
uint8 *WriteMap[MEMMAP_NUM_BLOCKS];
uint8 *BWRAM;
bool8 Executing;
bool8 overflow;
bool8 in_char_dma;
int16 op1;
int16 op2;
int32 arithmetic_op;
int64 sum;
uint8 VirtualBitmapFormat;
uint8 variable_bit_pos;
};
#define SA1CheckZero() (SA1._Zero == 0)
#define SA1CheckCarry() (SA1._Carry)
#define SA1CheckIRQ() (SA1Registers.PL & IRQ)
#define SA1CheckDecimal() (SA1Registers.PL & Decimal)
#define SA1CheckIndex() (SA1Registers.PL & IndexFlag)
#define SA1CheckMemory() (SA1Registers.PL & MemoryFlag)
#define SA1CheckOverflow() (SA1._Overflow)
#define SA1CheckNegative() (SA1._Negative & 0x80)
#define SA1CheckEmulation() (SA1Registers.P.W & Emulation)
#define SA1CheckCarry() (SA1._Carry)
#define SA1CheckZero() (SA1._Zero == 0)
#define SA1CheckIRQ() (SA1Registers.PL & IRQ)
#define SA1CheckDecimal() (SA1Registers.PL & Decimal)
#define SA1CheckIndex() (SA1Registers.PL & IndexFlag)
#define SA1CheckMemory() (SA1Registers.PL & MemoryFlag)
#define SA1CheckOverflow() (SA1._Overflow)
#define SA1CheckNegative() (SA1._Negative & 0x80)
#define SA1CheckEmulation() (SA1Registers.P.W & Emulation)
#define SA1ClearFlags(f) (SA1Registers.P.W &= ~(f))
#define SA1SetFlags(f) (SA1Registers.P.W |= (f))
#define SA1CheckFlag(f) (SA1Registers.PL & (f))
#define SA1SetFlags(f) (SA1Registers.P.W |= (f))
#define SA1ClearFlags(f) (SA1Registers.P.W &= ~(f))
#define SA1CheckFlag(f) (SA1Registers.PL & (f))
extern struct SSA1Registers SA1Registers;
extern struct SSA1 SA1;
extern uint8 SA1OpenBus;
extern struct SOpcodes S9xSA1OpcodesM1X1[256];
extern struct SOpcodes S9xSA1OpcodesM1X0[256];
extern struct SOpcodes S9xSA1OpcodesM0X1[256];
extern struct SOpcodes S9xSA1OpcodesM0X0[256];
extern uint8 S9xOpLengthsM1X1[256];
extern uint8 S9xOpLengthsM1X0[256];
extern uint8 S9xOpLengthsM0X1[256];
extern uint8 S9xOpLengthsM0X0[256];
START_EXTERN_C
uint8 S9xSA1GetByte (uint32);
uint16 S9xSA1GetWord (uint32, enum s9xwrap_t w=WRAP_NONE);
void S9xSA1SetByte (uint8, uint32);
void S9xSA1SetWord (uint16, uint32, enum s9xwrap_t w=WRAP_NONE, enum s9xwriteorder_t o=WRITE_01);
uint16 S9xSA1GetWord (uint32, enum s9xwrap_t w = WRAP_NONE);
void S9xSA1SetWord (uint16, uint32, enum s9xwrap_t w = WRAP_NONE, enum s9xwriteorder_t o = WRITE_01);
void S9xSA1SetPCBase (uint32);
uint8 S9xGetSA1 (uint32);
void S9xSetSA1 (uint8, uint32);
void S9xSA1Init (void);
void S9xSA1MainLoop (void);
void S9xSA1ExecuteDuringSleep (void);
void S9xSA1PostLoadState (void);
extern struct SOpcodes S9xSA1OpcodesM1X1 [256];
extern struct SOpcodes S9xSA1OpcodesM1X0 [256];
extern struct SOpcodes S9xSA1OpcodesM0X1 [256];
extern struct SOpcodes S9xSA1OpcodesM0X0 [256];
extern uint8 S9xOpLengthsM1X1 [256];
extern uint8 S9xOpLengthsM1X0 [256];
extern uint8 S9xOpLengthsM0X1 [256];
extern uint8 S9xOpLengthsM0X0 [256];
extern struct SSA1Registers SA1Registers;
extern struct SSA1 SA1;
extern uint8 SA1OpenBus;
#define SNES_IRQ_SOURCE (1 << 7)
#define TIMER_IRQ_SOURCE (1 << 6)
#define DMA_IRQ_SOURCE (1 << 5)
void S9xSA1MainLoop ();
void S9xSA1Init ();
void S9xFixSA1AfterSnapshotLoad ();
void S9xSA1ExecuteDuringSleep ();
END_EXTERN_C
#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 = (SA1Registers.PL & Zero) == 0;
SA1._Negative = (SA1Registers.PL & Negative);
SA1._Carry = (SA1Registers.PL & Carry);
SA1._Overflow = (SA1Registers.PL & Overflow) >> 6;
SA1._Zero = (SA1Registers.PL & Zero) == 0;
SA1._Negative = (SA1Registers.PL & Negative);
SA1._Carry = (SA1Registers.PL & Carry);
SA1._Overflow = (SA1Registers.PL & Overflow) >> 6;
}
STATIC inline void S9xSA1PackStatus()
static inline void S9xSA1PackStatus (void)
{
SA1Registers.PL &= ~(Zero | Negative | Carry | Overflow);
SA1Registers.PL |= SA1._Carry | ((SA1._Zero == 0) << 1) |
(SA1._Negative & 0x80) | (SA1._Overflow << 6);
SA1Registers.PL &= ~(Zero | Negative | Carry | Overflow);
SA1Registers.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 = S9xSA1OpcodesM1X1;
SA1.S9xOpLengths = S9xOpLengthsM1X1;
} else
if (SA1CheckMemory ())
{
if (SA1CheckIndex ()){
SA1.S9xOpcodes = S9xSA1OpcodesM1X1;
SA1.S9xOpLengths = S9xOpLengthsM1X1;
} else {
SA1.S9xOpcodes = S9xSA1OpcodesM1X0;
SA1.S9xOpLengths = S9xOpLengthsM1X0;
}
}
else
{
if (SA1CheckIndex ()){
SA1.S9xOpcodes = S9xSA1OpcodesM0X1;
SA1.S9xOpLengths = S9xOpLengthsM0X1;
} else {
SA1.S9xOpcodes = S9xSA1OpcodesM0X0;
SA1.S9xOpLengths = S9xOpLengthsM0X0;
}
}
if (SA1CheckEmulation())
{
SA1.S9xOpcodes = S9xSA1OpcodesM1X1;
SA1.S9xOpLengths = S9xOpLengthsM1X1;
}
else
if (SA1CheckMemory())
{
if (SA1CheckIndex())
{
SA1.S9xOpcodes = S9xSA1OpcodesM1X1;
SA1.S9xOpLengths = S9xOpLengthsM1X1;
}
else
{
SA1.S9xOpcodes = S9xSA1OpcodesM1X0;
SA1.S9xOpLengths = S9xOpLengthsM1X0;
}
}
else
{
if (SA1CheckIndex())
{
SA1.S9xOpcodes = S9xSA1OpcodesM0X1;
SA1.S9xOpLengths = S9xOpLengthsM0X1;
}
else
{
SA1.S9xOpcodes = S9xSA1OpcodesM0X0;
SA1.S9xOpLengths = S9xOpLengthsM0X0;
}
}
}
#endif

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,123 +172,128 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#include "snes9x.h"
#include "memmap.h"
#include "ppu.h"
#include "cpuexec.h"
#include "sa1.h"
#define CPU SA1
#define ICPU SA1
#define Registers SA1Registers
#define OpenBus SA1OpenBus
#define S9xGetByte S9xSA1GetByte
#define S9xGetWord S9xSA1GetWord
#define S9xSetByte S9xSA1SetByte
#define S9xSetWord S9xSA1SetWord
#define S9xSetPCBase S9xSA1SetPCBase
#define S9xOpcodesM1X1 S9xSA1OpcodesM1X1
#define S9xOpcodesM1X0 S9xSA1OpcodesM1X0
#define S9xOpcodesM0X1 S9xSA1OpcodesM0X1
#define S9xOpcodesM0X0 S9xSA1OpcodesM0X0
#define S9xOpcodesE1 S9xSA1OpcodesE1
#define S9xOpcodesSlow S9xSA1OpcodesSlow
#define S9xOpcode_IRQ S9xSA1Opcode_IRQ
#define S9xOpcode_NMI S9xSA1Opcode_NMI
#define S9xUnpackStatus S9xSA1UnpackStatus
#define S9xPackStatus S9xSA1PackStatus
#define S9xFixCycles S9xSA1FixCycles
#define Immediate8 SA1Immediate8
#define Immediate16 SA1Immediate16
#define Relative SA1Relative
#define RelativeLong SA1RelativeLong
#define AbsoluteIndexedIndirect SA1AbsoluteIndexedIndirect
#define AbsoluteIndirectLong SA1AbsoluteIndirectLong
#define AbsoluteIndirect SA1AbsoluteIndirect
#define Absolute SA1Absolute
#define AbsoluteLong SA1AbsoluteLong
#define Direct SA1Direct
#define DirectIndirectIndexed SA1DirectIndirectIndexed
#define DirectIndirectIndexedLong SA1DirectIndirectIndexedLong
#define DirectIndexedIndirect SA1DirectIndexedIndirect
#define DirectIndexedX SA1DirectIndexedX
#define DirectIndexedY SA1DirectIndexedY
#define AbsoluteIndexedX SA1AbsoluteIndexedX
#define AbsoluteIndexedY SA1AbsoluteIndexedY
#define AbsoluteLongIndexedX SA1AbsoluteLongIndexedX
#define DirectIndirect SA1DirectIndirect
#define DirectIndirectLong SA1DirectIndirectLong
#define StackRelative SA1StackRelative
#define StackRelativeIndirectIndexed SA1StackRelativeIndirectIndexed
#define CPU SA1
#define ICPU SA1
#define Registers SA1Registers
#define OpenBus SA1OpenBus
#define S9xGetByte S9xSA1GetByte
#define S9xGetWord S9xSA1GetWord
#define S9xSetByte S9xSA1SetByte
#define S9xSetWord S9xSA1SetWord
#define S9xSetPCBase S9xSA1SetPCBase
#define S9xOpcodesM1X1 S9xSA1OpcodesM1X1
#define S9xOpcodesM1X0 S9xSA1OpcodesM1X0
#define S9xOpcodesM0X1 S9xSA1OpcodesM0X1
#define S9xOpcodesM0X0 S9xSA1OpcodesM0X0
#define S9xOpcodesE1 S9xSA1OpcodesE1
#define S9xOpcodesSlow S9xSA1OpcodesSlow
#define S9xOpcode_IRQ S9xSA1Opcode_IRQ
#define S9xOpcode_NMI S9xSA1Opcode_NMI
#define S9xUnpackStatus S9xSA1UnpackStatus
#define S9xPackStatus S9xSA1PackStatus
#define S9xFixCycles S9xSA1FixCycles
#define Immediate8 SA1Immediate8
#define Immediate16 SA1Immediate16
#define Relative SA1Relative
#define RelativeLong SA1RelativeLong
#define Absolute SA1Absolute
#define AbsoluteLong SA1AbsoluteLong
#define AbsoluteIndirect SA1AbsoluteIndirect
#define AbsoluteIndirectLong SA1AbsoluteIndirectLong
#define AbsoluteIndexedIndirect SA1AbsoluteIndexedIndirect
#define Direct SA1Direct
#define DirectIndirectIndexed SA1DirectIndirectIndexed
#define DirectIndirectIndexedLong SA1DirectIndirectIndexedLong
#define DirectIndexedIndirect SA1DirectIndexedIndirect
#define DirectIndexedX SA1DirectIndexedX
#define DirectIndexedY SA1DirectIndexedY
#define AbsoluteIndexedX SA1AbsoluteIndexedX
#define AbsoluteIndexedY SA1AbsoluteIndexedY
#define AbsoluteLongIndexedX SA1AbsoluteLongIndexedX
#define DirectIndirect SA1DirectIndirect
#define DirectIndirectLong SA1DirectIndirectLong
#define StackRelative SA1StackRelative
#define StackRelativeIndirectIndexed SA1StackRelativeIndirectIndexed
//#undef CPU_SHUTDOWN
#define SA1_OPCODES
#include "cpuops.cpp"
void S9xSA1MainLoop ()
void S9xSA1MainLoop (void)
{
int i;
#if 0
if (SA1.Flags & NMI_FLAG)
{
SA1.Flags &= ~NMI_FLAG;
if (SA1.WaitingForInterrupt)
if (SA1.Flags & NMI_FLAG)
{
SA1.WaitingForInterrupt = FALSE;
SA1Registers.PCw++;
SA1.Flags &= ~NMI_FLAG;
if (SA1.WaitingForInterrupt)
{
SA1.WaitingForInterrupt = FALSE;
SA1Registers.PCw++;
}
S9xSA1Opcode_NMI();
}
S9xSA1Opcode_NMI ();
}
#endif
if (SA1.Flags & IRQ_FLAG)
{
if (SA1.IRQActive)
{
if (SA1.WaitingForInterrupt)
{
SA1.WaitingForInterrupt = FALSE;
SA1Registers.PCw++;
}
if (!SA1CheckFlag (IRQ))
S9xSA1Opcode_IRQ ();
}
else
SA1.Flags &= ~IRQ_FLAG;
}
for (i = 0; i < 3 && SA1.Executing; i++)
{
#ifdef DEBUGGER
if (SA1.Flags & TRACE_FLAG){ S9xSA1Trace(); }
#endif
#ifdef CPU_SHUTDOWN
SA1.PBPCAtOpcodeStart = SA1Registers.PBPC;
#endif
register uint8 Op;
register struct SOpcodes *Opcodes;
if(SA1.PCBase){
SA1OpenBus = Op = SA1.PCBase[Registers.PCw];
Opcodes = SA1.S9xOpcodes;
} else {
Op = S9xSA1GetByte(Registers.PBPC);
Opcodes = S9xOpcodesSlow;
}
if((SA1Registers.PCw&MEMMAP_MASK)+SA1.S9xOpLengths[Op]>=MEMMAP_BLOCK_SIZE){
uint32 oldPC = SA1Registers.PBPC;
S9xSA1SetPCBase(SA1Registers.PBPC);
SA1Registers.PBPC = oldPC;
Opcodes = S9xSA1OpcodesSlow;
}
Registers.PCw++;
(*Opcodes[Op].S9xOpcode) ();
}
if (SA1.Flags & IRQ_FLAG)
{
if (SA1.IRQActive)
{
if (SA1.WaitingForInterrupt)
{
SA1.WaitingForInterrupt = FALSE;
SA1Registers.PCw++;
}
if (!SA1CheckFlag(IRQ))
S9xSA1Opcode_IRQ();
}
else
SA1.Flags &= ~IRQ_FLAG;
}
for (int i = 0; i < 3 && SA1.Executing; i++)
{
#ifdef DEBUGGER
if (SA1.Flags & TRACE_FLAG)
S9xSA1Trace();
#endif
#ifdef CPU_SHUTDOWN
SA1.PBPCAtOpcodeStart = SA1Registers.PBPC;
#endif
register uint8 Op;
register struct SOpcodes *Opcodes;
if (SA1.PCBase)
{
SA1OpenBus = Op = SA1.PCBase[Registers.PCw];
Opcodes = SA1.S9xOpcodes;
}
else
{
Op = S9xSA1GetByte(Registers.PBPC);
Opcodes = S9xOpcodesSlow;
}
if ((SA1Registers.PCw & MEMMAP_MASK) + SA1.S9xOpLengths[Op] >= MEMMAP_BLOCK_SIZE)
{
uint32 oldPC = SA1Registers.PBPC;
S9xSA1SetPCBase(SA1Registers.PBPC);
SA1Registers.PBPC = oldPC;
Opcodes = S9xSA1OpcodesSlow;
}
Registers.PCw++;
(*Opcodes[Op].S9xOpcode)();
}
}

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,57 +172,52 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#ifndef _SAR_H_
#define _SAR_H_
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "port.h"
#ifndef snes9x_types_defined
#include "9xtypes.h"
#endif
#ifdef RIGHTSHIFT_IS_SAR
#define SAR(b, n) ((b)>>(n))
#define SAR(b, n) ((b) >> (n))
#else
static inline int8 SAR(const int8 b, const int n){
static inline int8 SAR (const int8 b, const int n)
{
#ifndef RIGHTSHIFT_int8_IS_SAR
if(b<0) return (b>>n)|(-1<<(8-n));
if (b < 0)
return ((b >> n) | (-1 << (8 - n)));
#endif
return b>>n;
return (b >> n);
}
static inline int16 SAR(const int16 b, const int n){
static inline int16 SAR (const int16 b, const int n)
{
#ifndef RIGHTSHIFT_int16_IS_SAR
if(b<0) return (b>>n)|(-1<<(16-n));
if (b < 0)
return ((b >> n) | (-1 << (16 - n)));
#endif
return b>>n;
return (b >> n);
}
static inline int32 SAR(const int32 b, const int n){
static inline int32 SAR (const int32 b, const int n)
{
#ifndef RIGHTSHIFT_int32_IS_SAR
if(b<0) return (b>>n)|(-1<<(32-n));
if (b < 0)
return ((b >> n) | (-1 << (32 - n)));
#endif
return b>>n;
return (b >> n);
}
static inline int64 SAR(const int64 b, const int n){
static inline int64 SAR (const int64 b, const int n)
{
#ifndef RIGHTSHIFT_int64_IS_SAR
if(b<0) return (b>>n)|(-1<<(64-n));
if (b < 0)
return ((b >> n) | (-1 << (64 - n)));
#endif
return b>>n;
return (b >> n);
}
#endif
#endif

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,155 +172,144 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#ifdef HAVE_LIBPNG
#include <png.h>
#endif
#include "snes9x.h"
#include "memmap.h"
#include "display.h"
#include "screenshot.h"
#ifndef _apumemory_h_
#define _apumemory_h_
START_EXTERN_C
extern uint8 APUROM[64];
END_EXTERN_C
static INLINE uint8 apu_get_reg (uint8 Address)
bool8 S9xDoScreenshot (int width, int height)
{
switch (Address)
Settings.TakeScreenshot = FALSE;
#ifdef HAVE_LIBPNG
FILE *fp;
png_structp png_ptr;
png_infop info_ptr;
png_color_8 sig_bit;
int imgwidth, imgheight;
const char *fname;
fname = S9xGetFilenameInc(".png", SCREENSHOT_DIR);
fp = fopen(fname, "wb");
if (!fp)
{
case 0xf0: // -w TEST
return 0;
case 0xf1: // -w CONTROL
return 0;
case 0xf2: // rw DSPADDR
return (IAPU.RAM[Address]);
case 0xf3: // rw DSPDATA
return (S9xGetAPUDSP());
case 0xf4: // r- CPUI0
case 0xf5: // r- CPUI1
case 0xf6: // r- CPUI2
case 0xf7: // r- CPUI3
#ifdef SPC700_SHUTDOWN
IAPU.WaitAddress2 = IAPU.WaitAddress1;
IAPU.WaitAddress1 = IAPU.PC;
#endif
return (IAPU.RAM[Address]);
case 0xf8: // rw - Normal RAM
case 0xf9: // rw - Normal RAM
return (IAPU.RAM[Address]);
case 0xfa: // -w T0TARGET
case 0xfb: // -w T1TARGET
case 0xfc: // -w T2TARGET
return 0;
case 0xfd: // r- T0OUT
case 0xfe: // r- T1OUT
case 0xff: // r- T2OUT
#ifdef SPC700_SHUTDOWN
IAPU.WaitAddress2 = IAPU.WaitAddress1;
IAPU.WaitAddress1 = IAPU.PC;
#endif
uint8 t = IAPU.RAM[Address] & 0xF;
IAPU.RAM[Address] = 0;
return (t);
S9xMessage(S9X_ERROR, 0, "Failed to take screenshot.");
return (FALSE);
}
return 0;
}
static INLINE void apu_set_reg (uint8 byte, uint8 Address)
{
switch (Address)
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!png_ptr)
{
case 0xf0: // -w TEST
//printf("Write %02X to APU 0xF0!\n", byte);
return;
case 0xf1: // -w CONTROL
S9xSetAPUControl(byte);
return;
case 0xf2: // rw DSPADDR
IAPU.RAM[Address] = byte;
return;
case 0xf3: // rw DSPDATA
S9xSetAPUDSP(byte);
return;
case 0xf4: // -w CPUO0
case 0xf5: // -w CPUO1
case 0xf6: // -w CPUO2
case 0xf7: // -w CPUO3
APU.OutPorts[Address - 0xf4] = byte;
return;
case 0xf8: // rw - Normal RAM
case 0xf9: // rw - Normal RAM
IAPU.RAM[Address] = byte;
return;
case 0xfa: // -w T0TARGET
case 0xfb: // -w T1TARGET
case 0xfc: // -w T2TARGET
IAPU.RAM[Address] = byte;
if (byte == 0)
APU.TimerTarget[Address - 0xfa] = 0x100;
else
APU.TimerTarget[Address - 0xfa] = byte;
return;
case 0xfd: // r- T0OUT
case 0xfe: // r- T1OUT
case 0xff: // r- T2OUT
return;
fclose(fp);
unlink(fname);
S9xMessage(S9X_ERROR, 0, "Failed to take screenshot.");
return (FALSE);
}
}
INLINE uint8 S9xAPUGetByteZ (uint8 Address)
{
if (Address >= 0xf0 && IAPU.DirectPage == IAPU.RAM)
return (apu_get_reg(Address));
else
return (IAPU.DirectPage[Address]);
}
INLINE void S9xAPUSetByteZ (uint8 byte, uint8 Address)
{
if (Address >= 0xf0 && IAPU.DirectPage == IAPU.RAM)
apu_set_reg(byte, Address);
else
IAPU.DirectPage[Address] = byte;
}
INLINE uint8 S9xAPUGetByte (uint32 Address)
{
Address &= 0xffff;
if (Address <= 0xff && Address >= 0xf0)
return (apu_get_reg(Address & 0xff));
else
return (IAPU.RAM[Address]);
}
INLINE void S9xAPUSetByte (uint8 byte, uint32 Address)
{
Address &= 0xffff;
if (Address <= 0xff && Address >= 0xf0)
apu_set_reg(byte, Address & 0xff);
else
if (Address < 0xffc0)
IAPU.RAM[Address] = byte;
else
info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr)
{
APU.ExtraRAM[Address - 0xffc0] = byte;
if (!APU.ShowROM)
IAPU.RAM[Address] = byte;
png_destroy_write_struct(&png_ptr, (png_infopp) NULL);
fclose(fp);
unlink(fname);
S9xMessage(S9X_ERROR, 0, "Failed to take screenshot.");
return (FALSE);
}
}
#endif // _apumemory_h_
if (setjmp(png_jmpbuf(png_ptr)))
{
png_destroy_write_struct(&png_ptr, &info_ptr);
fclose(fp);
unlink(fname);
S9xMessage(S9X_ERROR, 0, "Failed to take screenshot.");
return (FALSE);
}
imgwidth = width;
imgheight = height;
if (Settings.StretchScreenshots == 1)
{
if (width > SNES_WIDTH && height <= SNES_HEIGHT_EXTENDED)
imgheight = height << 1;
}
else
if (Settings.StretchScreenshots == 2)
{
if (width <= SNES_WIDTH)
imgwidth = width << 1;
if (height <= SNES_HEIGHT_EXTENDED)
imgheight = height << 1;
}
png_init_io(png_ptr, fp);
png_set_IHDR(png_ptr, info_ptr, imgwidth, imgheight, 8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
sig_bit.red = 5;
sig_bit.green = 5;
sig_bit.blue = 5;
png_set_sBIT(png_ptr, info_ptr, &sig_bit);
png_set_shift(png_ptr, &sig_bit);
png_write_info(png_ptr, info_ptr);
png_set_packing(png_ptr);
png_byte *row_pointer = new png_byte[png_get_rowbytes(png_ptr, info_ptr)];
uint16 *screen = GFX.Screen;
for (int y = 0; y < height; y++, screen += GFX.RealPPL)
{
png_byte *rowpix = row_pointer;
for (int x = 0; x < width; x++)
{
uint32 r, g, b;
DECOMPOSE_PIXEL(screen[x], r, g, b);
*(rowpix++) = r;
*(rowpix++) = g;
*(rowpix++) = b;
if (imgwidth != width)
{
*(rowpix++) = r;
*(rowpix++) = g;
*(rowpix++) = b;
}
}
png_write_row(png_ptr, row_pointer);
if (imgheight != height)
png_write_row(png_ptr, row_pointer);
}
delete [] row_pointer;
png_write_end(png_ptr, info_ptr);
png_destroy_write_struct(&png_ptr, &info_ptr);
fclose(fp);
fprintf(stderr, "%s saved.\n", fname);
const char *base = S9xBasename(fname);
sprintf(String, "Saved screenshot %s", base);
S9xMessage(S9X_INFO, 0, String);
return (TRUE);
#else
fprintf(stderr, "Screenshot support not available (libpng was not found at build time).\n");
return (FALSE);
#endif
}

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,15 +172,12 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#ifndef _SCREENSHOT_H_
#define _SCREENSHOT_H_
#ifndef SCREENSHOT_H
#define SCREENSHOT_H
bool8 S9xDoScreenshot(int width, int height);
bool8 S9xDoScreenshot (int, int);
#endif

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,100 +172,40 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#include "snes9x.h"
#include "memmap.h"
#include "ppu.h"
#include "sdd1.h"
#include "display.h"
#ifdef __linux
#include <unistd.h>
#endif
void S9xSetSDD1MemoryMap (uint32 bank, uint32 value)
{
bank = 0xc00 + bank * 0x100;
value = value * 1024 * 1024;
bank = 0xc00 + bank * 0x100;
value = value * 1024 * 1024;
int c;
for (c = 0; c < 0x100; c += 16)
{
uint8 *block = &Memory.ROM [value + (c << 12)];
int i;
for (i = c; i < c + 16; i++)
Memory.Map [i + bank] = block;
}
}
void S9xResetSDD1 ()
{
memset (&Memory.FillRAM [0x4800], 0, 4);
for (int i = 0; i < 4; i++)
{
Memory.FillRAM [0x4804 + i] = i;
S9xSetSDD1MemoryMap (i, i);
}
}
void S9xSDD1PostLoadState ()
{
for (int i = 0; i < 4; i++)
S9xSetSDD1MemoryMap (i, Memory.FillRAM [0x4804 + i]);
}
static int S9xCompareSDD1LoggedDataEntries (const void *p1, const void *p2)
{
uint8 *b1 = (uint8 *) p1;
uint8 *b2 = (uint8 *) p2;
uint32 a1 = (*b1 << 16) + (*(b1 + 1) << 8) + *(b1 + 2);
uint32 a2 = (*b2 << 16) + (*(b2 + 1) << 8) + *(b2 + 2);
return (a1 - a2);
}
void S9xSDD1SaveLoggedData ()
{
if (Memory.SDD1LoggedDataCount != Memory.SDD1LoggedDataCountPrev)
{
qsort (Memory.SDD1LoggedData, Memory.SDD1LoggedDataCount, 8,
S9xCompareSDD1LoggedDataEntries);
FILE *fs = fopen (S9xGetFilename (".dat", PATCH_DIR), "wb");
if (fs)
for (int c = 0; c < 0x100; c += 16)
{
fwrite (Memory.SDD1LoggedData, 8,
Memory.SDD1LoggedDataCount, fs);
fclose (fs);
#if defined(__linux)
chown (S9xGetFilename (".dat", PATCH_DIR), getuid (), getgid ());
#endif
uint8 *block = &Memory.ROM[value + (c << 12)];
for (int i = c; i < c + 16; i++)
Memory.Map[i + bank] = block;
}
Memory.SDD1LoggedDataCountPrev = Memory.SDD1LoggedDataCount;
}
}
void S9xSDD1LoadLoggedData ()
void S9xResetSDD1 (void)
{
FILE *fs = fopen (S9xGetFilename (".dat", PATCH_DIR), "rb");
Memory.SDD1LoggedDataCount = Memory.SDD1LoggedDataCountPrev = 0;
if (fs)
{
int c = fread (Memory.SDD1LoggedData, 8,
MEMMAP_MAX_SDD1_LOGGED_ENTRIES, fs);
if (c != EOF)
Memory.SDD1LoggedDataCount = Memory.SDD1LoggedDataCountPrev = c;
fclose (fs);
}
memset(&Memory.FillRAM[0x4800], 0, 4);
for (int i = 0; i < 4; i++)
{
Memory.FillRAM[0x4804 + i] = i;
S9xSetSDD1MemoryMap(i, i);
}
}
void S9xSDD1PostLoadState (void)
{
for (int i = 0; i < 4; i++)
S9xSetSDD1MemoryMap(i, Memory.FillRAM[0x4804 + i]);
}

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,17 +172,14 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#ifndef _SDD1_H_
#define _SDD1_H_
void S9xSetSDD1MemoryMap (uint32 bank, uint32 value);
void S9xResetSDD1 ();
void S9xSDD1PostLoadState ();
void S9xSDD1SaveLoggedData ();
void S9xSDD1LoadLoggedData ();
#endif
void S9xSetSDD1MemoryMap (uint32, uint32);
void S9xResetSDD1 (void);
void S9xSDD1PostLoadState (void);
#endif

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,9 +172,7 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
/* S-DD1 decompressor
*
@ -174,7 +188,7 @@
* S-DD1 issue in the past.
*/
#include <string.h>
#include "port.h"
#include "sdd1emu.h"
@ -390,6 +404,7 @@ void SDD1_decompress(uint8 *out, uint8 *in, int len){
}
}
#if 0
static uint8 cur_plane;
static uint8 num_bits;
static uint8 next_byte;
@ -485,4 +500,4 @@ uint8 SDD1_get_byte(void){
return 0;
}
}
#endif

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,23 +172,12 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#ifndef _SDD1EMU_H_
#define _SDD1EMU_H_
#ifndef SDD1EMU_H
#define SDD1EMU_H
/* for START_EXTERN_C/END_EXTERN_C */
#include "port.h"
START_EXTERN_C
void SDD1_decompress(uint8 *out, uint8 *in, int output_length);
void SDD1_init(uint8 *in);
uint8 SDD1_get_byte(void);
END_EXTERN_C
void SDD1_decompress (uint8 *, uint8 *, int);
#endif

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,24 +172,22 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#include "snes9x.h"
#include "seta.h"
void (*SetSETA)(uint32, uint8)=&S9xSetST010;
uint8 (*GetSETA)(uint32)=&S9xGetST010;
uint8 (*GetSETA) (uint32) = &S9xGetST010;
void (*SetSETA) (uint32, uint8) = &S9xSetST010;
extern "C"{
uint8 S9xGetSetaDSP(uint32 Address)
uint8 S9xGetSetaDSP (uint32 Address)
{
return GetSETA(Address);
return (GetSETA(Address));
}
void S9xSetSetaDSP(uint8 Byte, uint32 Address)
void S9xSetSetaDSP (uint8 Byte, uint32 Address)
{
SetSETA(Address, Byte);
SetSETA (Address, Byte);
}
}

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,75 +172,67 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#ifndef _SETA_H_
#define _SETA_H_
#define ST_010 0x01
#define ST_011 0x02
#define ST_018 0x03
#ifndef NO_SETA
#ifndef _seta_h
#define _seta_h
#include "port.h"
#define ST_010 0x01
#define ST_011 0x02
#define ST_018 0x03
extern "C"
struct SST010
{
uint8 S9xGetSetaDSP(uint32 Address);
void S9xSetSetaDSP(uint8 byte,uint32 Address);
uint8 S9xGetST018(uint32 Address);
void S9xSetST018(uint8 Byte, uint32 Address);
uint8 input_params[16];
uint8 output_params[16];
uint8 op_reg;
uint8 execute;
bool8 control_enable;
};
uint8 S9xGetST010(uint32 Address);
void S9xSetST010(uint32 Address, uint8 Byte);
uint8 S9xGetST011(uint32 Address);
void S9xSetST011(uint32 Address, uint8 Byte);
}
extern void (*SetSETA)(uint32, uint8);
extern uint8 (*GetSETA)(uint32);
typedef struct SETA_ST010_STRUCT
struct SST011
{
uint8 input_params[16];
uint8 output_params[16];
uint8 op_reg;
uint8 execute;
bool8 control_enable;
} ST010_Regs;
bool8 waiting4command;
uint8 status;
uint8 command;
uint32 in_count;
uint32 in_index;
uint32 out_count;
uint32 out_index;
uint8 parameters[512];
uint8 output[512];
};
typedef struct SETA_ST011_STRUCT
struct SST018
{
bool8 waiting4command;
uint8 status;
uint8 command;
uint32 in_count;
uint32 in_index;
uint32 out_count;
uint32 out_index;
uint8 parameters [512];
uint8 output [512];
} ST011_Regs;
bool8 waiting4command;
uint8 status;
uint8 part_command;
uint8 pass;
uint32 command;
uint32 in_count;
uint32 in_index;
uint32 out_count;
uint32 out_index;
uint8 parameters[512];
uint8 output[512];
};
typedef struct SETA_ST018_STRUCT
{
bool8 waiting4command;
uint8 status;
uint8 part_command;
uint8 pass;
uint32 command;
uint32 in_count;
uint32 in_index;
uint32 out_count;
uint32 out_index;
uint8 parameters [512];
uint8 output [512];
} ST018_Regs;
extern struct SST010 ST010;
extern struct SST011 ST011;
extern struct SST018 ST018;
uint8 S9xGetST010 (uint32);
void S9xSetST010 (uint32, uint8);
uint8 S9xGetST011 (uint32);
void S9xSetST011 (uint32, uint8);
uint8 S9xGetST018 (uint32);
void S9xSetST018 (uint8, uint32);
uint8 S9xGetSetaDSP (uint32);
void S9xSetSetaDSP (uint8, uint32);
extern uint8 (*GetSETA) (uint32);
extern void (*SetSETA) (uint32, uint8);
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,151 +172,138 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#include <stdio.h>
#include "seta.h"
#include "snes9x.h"
#include "memmap.h"
#include "seta.h"
ST011_Regs ST011;
static uint8 board[9][9]; // shougi playboard
static int line = 0; // line counter
// shougi playboard
uint8 board[9][9];
// debug
static int line = 0;
uint8 S9xGetST011(uint32 Address)
uint8 S9xGetST011 (uint32 Address)
{
uint8 t;
uint16 address = (uint16) Address & 0xFFFF;
uint8 t;
uint16 address = (uint16) Address & 0xFFFF;
// line counter
line++;
// status check
if (address == 0x01)
{
t = 0xFF;
}
// read directly from s-ram
t = 0xFF;
else
{
t = Memory.SRAM[address];
}
t = Memory.SRAM[address]; // read directly from s-ram
// debug
// if(address<0x150)
// printf( "ST011 R: %06X %02X\n", Address, t);
#ifdef DEBUGGER
if (address < 0x150)
printf("ST011 R: %06X %02X\n", Address, t);
#endif
return t;
return (t);
}
void S9xSetST011(uint32 Address, uint8 Byte)
void S9xSetST011 (uint32 Address, uint8 Byte)
{
uint16 address = (uint16) Address & 0xFFFF;
static bool reset = false;
static bool reset = false;
uint16 address = (uint16) Address & 0xFFFF;
// debug
line++;
if(!reset)
if (!reset)
{
// bootup values
ST011.waiting4command = true;
reset = true;
}
// debug
// if(address<0x150)
// printf( "ST011 W: %06X %02X\n", Address, Byte );
#ifdef DEBUGGER
if (address < 0x150)
printf("ST011 W: %06X %02X\n", Address, Byte);
#endif
Memory.SRAM[address]=Byte;
Memory.SRAM[address] = Byte;
// op commands/data goes through this address
if(address==0x00)
if (address == 0x00)
{
// check for new commands
if (ST011.waiting4command)
{
ST011.waiting4command = false;
ST011.command = Byte;
ST011.in_index = 0;
ST011.out_index = 0;
switch(ST011.command)
ST011.command = Byte;
ST011.in_index = 0;
ST011.out_index = 0;
switch (ST011.command)
{
case 0x01: ST011.in_count = 12*10+8; break;
case 0x02: ST011.in_count = 4; break;
case 0x04: ST011.in_count = 0; break;
case 0x05: ST011.in_count = 0; break;
case 0x06: ST011.in_count = 0; break;
case 0x07: ST011.in_count = 0; break;
case 0x0E: ST011.in_count = 0; break;
default: ST011.waiting4command=true; break;
case 0x01: ST011.in_count = 12 * 10 + 8; break;
case 0x02: ST011.in_count = 4; break;
case 0x04: ST011.in_count = 0; break;
case 0x05: ST011.in_count = 0; break;
case 0x06: ST011.in_count = 0; break;
case 0x07: ST011.in_count = 0; break;
case 0x0E: ST011.in_count = 0; break;
default: ST011.waiting4command = true; break;
}
}
else
{
ST011.parameters [ST011.in_index] = Byte;
ST011.parameters[ST011.in_index] = Byte;
ST011.in_index++;
}
}
if (ST011.in_count==ST011.in_index)
if (ST011.in_count == ST011.in_index)
{
// Actually execute the command
// actually execute the command
ST011.waiting4command = true;
ST011.out_index = 0;
ST011.out_index = 0;
switch (ST011.command)
{
// unknown: download playboard
case 0x01:
{
// unknown: download playboard
case 0x01:
// 9x9 board data: top to bottom, left to right
// Values represent piece types and ownership
for( int lcv=0; lcv<9; lcv++ )
memcpy( board[lcv], ST011.parameters+lcv*10, 9*1 );
}
break;
for (int lcv = 0; lcv < 9; lcv++)
memcpy(board[lcv], ST011.parameters + lcv * 10, 9 * 1);
break;
// unknown
case 0x02: break;
// unknown
case 0x02:
break;
// unknown
case 0x04:
{
// unknown
case 0x04:
// outputs
Memory.SRAM[0x12C] = 0x00;
//Memory.SRAM[0x12D] = 0x00;
Memory.SRAM[0x12E] = 0x00;
}
break;
break;
// unknown
case 0x05:
{
// unknown
case 0x05:
// outputs
Memory.SRAM[0x12C] = 0x00;
//Memory.SRAM[0x12D] = 0x00;
Memory.SRAM[0x12E] = 0x00;
}
break;
break;
// unknown
case 0x06: break;
case 0x07: break;
// unknown
case 0x06:
break;
// unknown
case 0x0E:
{
case 0x07:
break;
// unknown
case 0x0E:
// outputs
Memory.SRAM[0x12C] = 0x00;
Memory.SRAM[0x12D] = 0x00;
}
break;
break;
}
}
}

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,22 +172,20 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#include "seta.h"
#include "snes9x.h"
#include "memmap.h"
#include "seta.h"
ST018_Regs ST018;
static int line; // line counter
static int line; // line counter
extern "C"{
uint8 S9xGetST018(uint32 Address)
uint8 S9xGetST018 (uint32 Address)
{
uint8 t = 0;
uint16 address = (uint16) Address & 0xFFFF;
uint8 t = 0;
uint16 address = (uint16) Address & 0xFFFF;
line++;
@ -181,29 +195,34 @@ uint8 S9xGetST018(uint32 Address)
{
if (ST018.out_count)
{
t = (uint8) ST018.output [ST018.out_index];
t = (uint8) ST018.output[ST018.out_index];
ST018.out_index++;
if (ST018.out_count==ST018.out_index)
ST018.out_count=0;
if (ST018.out_count == ST018.out_index)
ST018.out_count = 0;
}
else
t = 0x81;
}
// status register
else if (address == 0x3800)
else
if (address == 0x3800)
t = ST018.status;
//printf( "ST018 R: %06X %02X\n", Address, t);
#ifdef DEBUGGER
printf("ST018 R: %06X %02X\n", Address, t);
#endif
return t;
return (t);
}
void S9xSetST018(uint8 Byte, uint32 Address)
void S9xSetST018 (uint8 Byte, uint32 Address)
{
uint16 address = (uint16) Address&0xFFFF;
static bool reset = false;
static bool reset = false;
uint16 address = (uint16) Address & 0xFFFF;
//printf( "ST018 W: %06X %02X\n", Address, Byte );
#ifdef DEBUGGER
printf("ST018 W: %06X %02X\n", Address, Byte);
#endif
line++;
@ -211,36 +230,38 @@ void S9xSetST018(uint8 Byte, uint32 Address)
{
// bootup values
ST018.waiting4command = true;
ST018.part_command = 0;
ST018.part_command = 0;
reset = true;
}
Memory.SRAM[address]=Byte;
Memory.SRAM[address] = Byte;
// default status for now
ST018.status = 0x00;
// op data goes through this address
if (address==0x3804)
if (address == 0x3804)
{
// check for new commands: 3 bytes length
if(ST018.waiting4command && ST018.part_command==2)
if (ST018.waiting4command && ST018.part_command == 2)
{
ST018.waiting4command = false;
ST018.in_index = 0;
ST018.out_index = 0;
ST018.part_command = 0; // 3-byte commands
ST018.pass = 0; // data streams into the chip
ST018.command <<= 8;
ST018.command |= Byte;
ST018.in_index = 0;
ST018.out_index = 0;
ST018.part_command = 0; // 3-byte commands
ST018.pass = 0; // data streams into the chip
switch(ST018.command & 0xFFFFFF)
switch (ST018.command & 0xFFFFFF)
{
case 0x0100: ST018.in_count = 0; break;
case 0xFF00: ST018.in_count = 0; break;
default: ST018.waiting4command = true; break;
case 0x0100: ST018.in_count = 0; break;
case 0xFF00: ST018.in_count = 0; break;
default: ST018.waiting4command = true; break;
}
}
else if(ST018.waiting4command)
else
if (ST018.waiting4command)
{
// 3-byte commands
ST018.part_command++;
@ -249,80 +270,84 @@ void S9xSetST018(uint8 Byte, uint32 Address)
}
}
// extra parameters
else if (address==0x3802)
else
if (address == 0x3802)
{
ST018.parameters[ST018.in_index] = Byte;
ST018.in_index++;
}
if (ST018.in_count==ST018.in_index)
if (ST018.in_count == ST018.in_index)
{
// Actually execute the command
// qctually execute the command
ST018.waiting4command = true;
ST018.in_index = 0;
ST018.out_index = 0;
ST018.in_index = 0;
ST018.out_index = 0;
switch (ST018.command)
{
// hardware check?
case 0x0100:
ST018.waiting4command = false;
ST018.pass++;
if (ST018.pass==1)
{
ST018.in_count = 1;
ST018.out_count = 2;
// hardware check?
case 0x0100:
ST018.waiting4command = false;
ST018.pass++;
// Overload's research
ST018.output[0x00] = 0x81;
ST018.output[0x01] = 0x81;
}
else
{
//ST018.in_count = 1;
ST018.out_count = 3;
if (ST018.pass == 1)
{
ST018.in_count = 1;
ST018.out_count = 2;
// no reason to change this
//ST018.output[0x00] = 0x81;
//ST018.output[0x01] = 0x81;
ST018.output[0x02] = 0x81;
// Overload's research
ST018.output[0x00] = 0x81;
ST018.output[0x01] = 0x81;
}
else
{
//ST018.in_count = 1;
ST018.out_count = 3;
// done processing requests
if (ST018.pass==3)
ST018.waiting4command = true;
}
break;
// no reason to change this
//ST018.output[0x00] = 0x81;
//ST018.output[0x01] = 0x81;
ST018.output[0x02] = 0x81;
// unknown: feels like a security detection
// format identical to 0x0100
case 0xFF00:
ST018.waiting4command = false;
ST018.pass++;
if (ST018.pass==1)
{
ST018.in_count = 1;
ST018.out_count = 2;
// done processing requests
if (ST018.pass == 3)
ST018.waiting4command = true;
}
// Overload's research
ST018.output[0x00] = 0x81;
ST018.output[0x01] = 0x81;
}
else
{
//ST018.in_count = 1;
ST018.out_count = 3;
break;
// no reason to change this
//ST018.output[0x00] = 0x81;
//ST018.output[0x01] = 0x81;
ST018.output[0x02] = 0x81;
// unknown: feels like a security detection
// format identical to 0x0100
case 0xFF00:
ST018.waiting4command = false;
ST018.pass++;
// done processing requests
if (ST018.pass==3)
ST018.waiting4command = true;
}
break;
if (ST018.pass == 1)
{
ST018.in_count = 1;
ST018.out_count = 2;
// Overload's research
ST018.output[0x00] = 0x81;
ST018.output[0x01] = 0x81;
}
else
{
//ST018.in_count = 1;
ST018.out_count = 3;
// no reason to change this
//ST018.output[0x00] = 0x81;
//ST018.output[0x01] = 0x81;
ST018.output[0x02] = 0x81;
// done processing requests
if (ST018.pass == 3)
ST018.waiting4command = true;
}
break;
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,37 +172,28 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#ifndef _SNAPSHOT_H_
#define _SNAPSHOT_H_
#include <stdio.h>
#include "snes9x.h"
#define SNAPSHOT_MAGIC "#!s9xsnp"
#define SNAPSHOT_VERSION 6
#define SNAPSHOT_MAGIC "#!snes9x"
#define SNAPSHOT_VERSION 5
#define SUCCESS 1
#define WRONG_FORMAT (-1)
#define WRONG_VERSION (-2)
#define FILE_NOT_FOUND (-3)
#define WRONG_MOVIE_SNAPSHOT (-4)
#define NOT_A_MOVIE_SNAPSHOT (-5)
#define SNAPSHOT_INCONSISTENT (-6)
#define SUCCESS 1
#define WRONG_FORMAT (-1)
#define WRONG_VERSION (-2)
#define FILE_NOT_FOUND (-3)
#define WRONG_MOVIE_SNAPSHOT (-4)
#define NOT_A_MOVIE_SNAPSHOT (-5)
#define SNAPSHOT_INCONSISTENT (-6)
START_EXTERN_C
void S9xResetSaveTimer(bool8 dontsave);
bool8 S9xFreezeGame (const char *filename);
bool8 S9xUnfreezeGame (const char *filename);
bool8 Snapshot (const char *filename);
bool8 S9xLoadSnapshot (const char *filename);
bool8 S9xSPCDump (const char *filename);
void S9xResetSaveTimer (bool8);
bool8 S9xFreezeGame (const char *);
bool8 S9xUnfreezeGame (const char *);
void S9xFreezeToStream (STREAM);
int S9xUnfreezeFromStream (STREAM);
END_EXTERN_C
int S9xUnfreezeFromStream (STREAM);
bool8 S9xSPCDump (const char *);
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/**********************************************************************************
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
@ -15,12 +15,15 @@
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2010 BearOso,
OV2
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
@ -37,7 +40,7 @@
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
@ -53,7 +56,6 @@
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
@ -70,22 +72,26 @@
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
@ -97,17 +103,20 @@
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
@ -117,23 +126,30 @@
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2010 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2010 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
(c) Copyright 2001 - 2010 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
@ -156,65 +172,45 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
***********************************************************************************/
#ifndef _SNES9X_H_
#define _SNES9X_H_
#define VERSION "1.51"
#include <stdio.h>
#include <stdlib.h>
#ifdef __WIN32__
#include <windows.h>
#ifdef ZLIB
#include <zlib.h>
#ifndef VERSION
#define VERSION "1.52"
#endif
#endif
//#include "language.h" // files should include this as needed, no need to recompile practically everything when it changes
#include "port.h"
#include "65c816.h"
#include "messages.h"
#if defined(USE_GLIDE) && !defined(GFX_MULTI_FORMAT)
#define GFX_MULTI_FORMAT
#endif
#define ROM_NAME_LEN 23
#ifdef ZLIB
#ifndef __WIN32__
#include <zlib.h>
#endif
#define STREAM gzFile
#define READ_STREAM(p,l,s) gzread (s,p,l)
#define WRITE_STREAM(p,l,s) gzwrite (s,p,l)
#define GETS_STREAM(p,l,s) gzgets(s,p,l)
#define GETC_STREAM(s) gzgetc(s)
#define OPEN_STREAM(f,m) gzopen (f,m)
#define REOPEN_STREAM(f,m) gzdopen (f,m)
#define FIND_STREAM(f) gztell(f)
#define REVERT_STREAM(f,o,s) gzseek(f,o,s)
#define CLOSE_STREAM(s) gzclose (s)
#define STREAM gzFile
#define READ_STREAM(p, l, s) gzread(s, p, l)
#define WRITE_STREAM(p, l, s) gzwrite(s, p, l)
#define GETS_STREAM(p, l, s) gzgets(s, p, l)
#define GETC_STREAM(s) gzgetc(s)
#define OPEN_STREAM(f, m) gzopen(f, m)
#define REOPEN_STREAM(f, m) gzdopen(f, m)
#define FIND_STREAM(f) gztell(f)
#define REVERT_STREAM(f, o, s) gzseek(f, o, s)
#define CLOSE_STREAM(s) gzclose(s)
#else
#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 GETS_STREAM(p,l,s) fgets(p,l,s)
#define GETC_STREAM(s) fgetc(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)
#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 GETS_STREAM(p, l, s) fgets(p, l, s)
#define GETC_STREAM(s) fgetc(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)
#endif
#define SNES_WIDTH 256
#define SNES_HEIGHT 224
#define SNES_HEIGHT_EXTENDED 239
@ -248,88 +244,62 @@
#define SNES_HDMA_INIT_HC 20 // FIXME: not true
#define SNES_RENDER_START_HC (48 * ONE_DOT_CYCLE) // FIXME: Snes9x renders a line at a time.
#define SNES_APU_CLOCK 1024000.0 // 1026900.0?
#define SNES_APU_ACCURACY 10
#define SNES_APU_ONE_CYCLE_SCALED ((int32) (NTSC_MASTER_CLOCK / SNES_APU_CLOCK * (1 << SNES_APU_ACCURACY)))
#define SNES_APUTIMER2_CYCLE_SCALED ((int32) (NTSC_MASTER_CLOCK / 64000.0 * (1 << SNES_APU_ACCURACY)))
#define AUTO_FRAMERATE 200
#define SNES_TR_MASK (1 << 4)
#define SNES_TL_MASK (1 << 5)
#define SNES_X_MASK (1 << 6)
#define SNES_A_MASK (1 << 7)
#define SNES_RIGHT_MASK (1 << 8)
#define SNES_LEFT_MASK (1 << 9)
#define SNES_DOWN_MASK (1 << 10)
#define SNES_UP_MASK (1 << 11)
#define SNES_START_MASK (1 << 12)
#define SNES_SELECT_MASK (1 << 13)
#define SNES_TR_MASK (1 << 4)
#define SNES_TL_MASK (1 << 5)
#define SNES_X_MASK (1 << 6)
#define SNES_A_MASK (1 << 7)
#define SNES_RIGHT_MASK (1 << 8)
#define SNES_LEFT_MASK (1 << 9)
#define SNES_DOWN_MASK (1 << 10)
#define SNES_UP_MASK (1 << 11)
#define SNES_START_MASK (1 << 12)
#define SNES_SELECT_MASK (1 << 13)
#define SNES_Y_MASK (1 << 14)
#define SNES_B_MASK (1 << 15)
#define DEBUG_MODE_FLAG (1 << 0)
#define TRACE_FLAG (1 << 1)
#define SINGLE_STEP_FLAG (1 << 2)
#define BREAK_FLAG (1 << 3)
#define SCAN_KEYS_FLAG (1 << 4)
#define SAVE_SNAPSHOT_FLAG (1 << 5)
#define DELAYED_NMI_FLAG (1 << 6)
#define NMI_FLAG (1 << 7)
#define PROCESS_SOUND_FLAG (1 << 8)
#define FRAME_ADVANCE_FLAG (1 << 9)
#define DELAYED_NMI_FLAG2 (1 << 10)
#define IRQ_FLAG (1 << 11)
#define HALTED_FLAG (1 << 12)
#define DEBUG_MODE_FLAG (1 << 0) // debugger
#define TRACE_FLAG (1 << 1) // debugger
#define SINGLE_STEP_FLAG (1 << 2) // debugger
#define BREAK_FLAG (1 << 3) // debugger
#define NMI_FLAG (1 << 7) // CPU
#define IRQ_FLAG (1 << 11) // CPU
#define SCAN_KEYS_FLAG (1 << 4) // CPU
#define HALTED_FLAG (1 << 12) // APU
#define FRAME_ADVANCE_FLAG (1 << 9)
struct SCPUState{
uint32 Flags;
bool8 BranchSkip;
bool8 NMIActive;
bool8 IRQActive;
bool8 WaitingForInterrupt;
bool8 InDMAorHDMA;
bool8 InWRAMDMAorHDMA;
uint8 WhichEvent;
uint8 *PCBase;
uint32 PBPCAtOpcodeStart;
uint32 WaitAddress;
uint32 WaitCounter;
#define ROM_NAME_LEN 23
#define AUTO_FRAMERATE 200
struct SCPUState
{
int32 Cycles;
int32 NextEvent;
int32 PrevCycles;
int32 V_Counter;
uint32 Flags;
uint8 *PCBase;
bool8 IRQActive;
int32 IRQPending;
int32 MemSpeed;
int32 MemSpeedx2;
int32 FastROMSpeed;
uint32 AutoSaveTimer;
bool8 SRAMModified;
bool8 BRKTriggered;
bool8 TriedInterleavedMode2;
int32 IRQPending;
bool8 InDMA;
bool8 InHDMA;
bool8 InDMAorHDMA;
bool8 InWRAMDMAorHDMA;
uint8 HDMARanInDMA;
int32 PrevCycles;
int32 CurrentDMAorHDMAChannel;
uint8 WhichEvent;
int32 NextEvent;
bool8 WaitingForInterrupt;
uint32 WaitAddress;
uint32 WaitCounter;
uint32 PBPCAtOpcodeStart;
uint32 AutoSaveTimer;
bool8 SRAMModified;
};
struct STimings {
int32 H_Max_Master;
int32 H_Max;
int32 V_Max_Master;
int32 V_Max;
int32 HBlankStart;
int32 HBlankEnd;
int32 HDMAInit;
int32 HDMAStart;
int32 NMITriggerPos;
int32 WRAMRefreshPos;
int32 RenderPos;
bool8 InterlaceField;
int32 DMACPUSync;
};
enum {
enum
{
HC_HBLANK_START_EVENT = 1,
HC_IRQ_1_3_EVENT = 2,
HC_HDMA_START_EVENT = 3,
@ -344,187 +314,164 @@ enum {
HC_IRQ_A_1_EVENT = 12
};
struct SSettings{
/* CPU options */
bool8 APUEnabled;
bool8 Shutdown;
uint8 SoundSkipMethod;
int32 HDMATimingHack;
bool8 DisableIRQ;
bool8 Paused;
bool8 ForcedPause;
bool8 StopEmulation;
bool8 FrameAdvance;
struct STimings
{
int32 H_Max_Master;
int32 H_Max;
int32 V_Max_Master;
int32 V_Max;
int32 HBlankStart;
int32 HBlankEnd;
int32 HDMAInit;
int32 HDMAStart;
int32 NMITriggerPos;
int32 WRAMRefreshPos;
int32 RenderPos;
bool8 InterlaceField;
int32 DMACPUSync; // The cycles to synchronize DMA and CPU. Snes9x cannot emulate correctly.
int32 NMIDMADelay; // The delay of NMI trigger after DMA transfers. Snes9x cannot emulate correctly.
int32 IRQPendCount; // This value is just a hack, because Snes9x cannot emulate any events in an opcode.
int32 APUSpeedup;
};
/* Tracing options */
bool8 TraceDMA;
bool8 TraceHDMA;
bool8 TraceVRAM;
bool8 TraceUnknownRegisters;
bool8 TraceDSP;
struct SSettings
{
bool8 TraceDMA;
bool8 TraceHDMA;
bool8 TraceVRAM;
bool8 TraceUnknownRegisters;
bool8 TraceDSP;
bool8 TraceHCEvent;
/* Joystick options */
bool8 JoystickEnabled;
bool8 SuperFX;
uint8 DSP;
bool8 SA1;
bool8 C4;
bool8 SDD1;
bool8 SPC7110;
bool8 SPC7110RTC;
bool8 OBC1;
uint8 SETA;
bool8 SRTC;
bool8 BS;
bool8 BSXItself;
bool8 BSXBootup;
bool8 MouseMaster;
bool8 SuperScopeMaster;
bool8 JustifierMaster;
bool8 MultiPlayer5Master;
/* ROM timing options (see also H_Max above) */
bool8 ForcePAL;
bool8 ForceNTSC;
bool8 PAL;
uint32 FrameTimePAL;
uint32 FrameTimeNTSC;
uint32 FrameTime;
uint32 SkipFrames;
bool8 ForceLoROM;
bool8 ForceHiROM;
bool8 ForceHeader;
bool8 ForceNoHeader;
bool8 ForceInterleaved;
bool8 ForceInterleaved2;
bool8 ForceInterleaveGD24;
bool8 ForceNotInterleaved;
bool8 ForcePAL;
bool8 ForceNTSC;
bool8 PAL;
uint32 FrameTimePAL;
uint32 FrameTimeNTSC;
uint32 FrameTime;
/* ROM image options */
bool8 ForceLoROM;
bool8 ForceHiROM;
bool8 ForceHeader;
bool8 ForceNoHeader;
bool8 ForceInterleaved;
bool8 ForceInterleaved2;
bool8 ForceNotInterleaved;
bool8 SoundSync;
bool8 SixteenBitSound;
uint32 SoundPlaybackRate;
uint32 SoundInputRate;
bool8 Stereo;
bool8 ReverseStereo;
bool8 Mute;
/* Peripherial options */
bool8 ForceSuperFX;
bool8 ForceNoSuperFX;
bool8 ForceDSP1;
bool8 ForceNoDSP1;
bool8 ForceSA1;
bool8 ForceNoSA1;
bool8 ForceC4;
bool8 ForceNoC4;
bool8 ForceSDD1;
bool8 ForceNoSDD1;
bool8 SRTC;
bool8 SupportHiRes;
bool8 Transparency;
uint8 BG_Forced;
bool8 DisableGraphicWindows;
bool8 ShutdownMaster;
bool8 MultiPlayer5Master;
bool8 SuperScopeMaster;
bool8 MouseMaster;
bool8 JustifierMaster;
bool8 SuperFX;
bool8 DSP1Master;
bool8 SA1;
bool8 C4;
bool8 SDD1;
bool8 SPC7110;
bool8 SPC7110RTC;
bool8 OBC1;
/* Sound options */
uint32 SoundPlaybackRate;
bool8 TraceSoundDSP;
bool8 Stereo;
bool8 ReverseStereo;
bool8 SixteenBitSound;
int SoundBufferSize;
int SoundMixInterval;
bool8 SoundEnvelopeHeightReading;
bool8 DisableSoundEcho;
bool8 DisableSampleCaching;
bool8 DisableMasterVolume;
bool8 SoundSync;
bool8 FakeMuteFix;
bool8 InterpolatedSound;
bool8 ThreadSound;
bool8 Mute;
bool8 NextAPUEnabled;
uint8 AltSampleDecode;
bool8 FixFrequency;
bool8 DisplayFrameRate;
bool8 DisplayWatchedAddresses;
bool8 DisplayPressedKeys;
bool8 DisplayMovieFrame;
bool8 AutoDisplayMessages;
uint32 InitialInfoStringTimeout;
uint16 DisplayColor;
/* Graphics options */
bool8 Transparency;
bool8 SupportHiRes;
bool8 Mode7Interpolate; // no longer used?
bool8 AutoDisplayMessages;
uint8 BG_Forced;
bool8 SnapshotScreenshots;
uint32 InitialInfoStringTimeout; // Messages normally display for this many frames
bool8 Multi;
char CartAName[PATH_MAX + 1];
char CartBName[PATH_MAX + 1];
/* SNES graphics options */
bool8 BGLayering;
bool8 DisableGraphicWindows;
bool8 ForceTransparency;
bool8 ForceNoTransparency;
bool8 DisableHDMA;
bool8 DisplayFrameRate;
bool8 DisableRangeTimeOver; /* XXX: unused */
bool8 DisplayWatchedAddresses;
bool8 DisableGameSpecificHacks;
bool8 ShutdownMaster;
bool8 Shutdown;
bool8 BlockInvalidVRAMAccessMaster;
bool8 BlockInvalidVRAMAccess;
bool8 DisableIRQ;
bool8 DisableHDMA;
int32 HDMATimingHack;
/* Multi ROMs */
bool8 Multi;
char CartAName[_MAX_PATH + 1];
char CartBName[_MAX_PATH + 1];
bool8 ForcedPause;
bool8 Paused;
bool8 StopEmulation;
/* Others */
bool8 NetPlay;
bool8 NetPlayServer;
char ServerName [128];
int Port;
bool8 GlideEnable;
bool8 OpenGLEnable;
int32 AutoSaveDelay; /* Time in seconds before S-RAM auto-saved if modified. */
bool8 ApplyCheats;
bool8 TurboMode;
bool8 OldTurbo;
bool8 UpAndDown;
uint8 DisplayPressedKeys; // The value indicates how to do it.
uint32 HighSpeedSeek;
uint32 TurboSkipFrames;
uint32 AutoMaxSkipFrames;
bool8 MovieTruncate;
bool8 MovieNotifyIgnored;
bool8 WrongMovieStateProtection;
uint32 SkipFrames;
uint32 TurboSkipFrames;
uint32 AutoMaxSkipFrames;
bool8 TurboMode;
uint32 HighSpeedSeek;
bool8 FrameAdvance;
/* Fixes for individual games */
bool8 WinterGold;
bool8 BS; /* Japanese Satellite System games. */
bool8 BSXItself;
bool8 BSXBootup;
uint8 APURAMInitialValue;
bool8 SampleCatchup;
int8 SETA;
bool8 BlockInvalidVRAMAccess;
bool8 TakeScreenshot;
int8 StretchScreenshots;
uint16 DisplayColor;
int SoundDriver;
int AIDOShmId;
bool8 SDD1Pack;
bool8 NoPatch;
bool8 ForceInterleaveGD24;
bool8 NetPlay;
bool8 NetPlayServer;
char ServerName[128];
int Port;
bool8 MovieTruncate;
bool8 MovieNotifyIgnored;
bool8 WrongMovieStateProtection;
bool8 DumpStreams;
int DumpStreamsMaxFrames;
bool8 TakeScreenshot;
int8 StretchScreenshots;
bool8 SnapshotScreenshots;
bool8 ApplyCheats;
bool8 NoPatch;
int32 AutoSaveDelay;
bool8 DontSaveOopsSnapshot;
bool8 UpAndDown;
bool8 OpenGLEnable;
};
struct SSNESGameFixes
{
uint8 APU_OutPorts_ReturnValueFix;
uint8 SRAMInitialValue;
uint8 Uniracers;
uint8 SRAMInitialValue;
uint8 Uniracers;
};
START_EXTERN_C
extern struct SSettings Settings;
extern struct SCPUState CPU;
extern struct STimings Timings;
extern struct SSNESGameFixes SNESGameFixes;
extern char String [513];
void S9xExit ();
void S9xMessage (int type, int number, const char *message);
void S9xLoadSDD1Data ();
END_EXTERN_C
enum {
PAUSE_NETPLAY_CONNECT = (1 << 0),
PAUSE_TOGGLE_FULL_SCREEN = (1 << 1),
PAUSE_EXIT = (1 << 2),
PAUSE_MENU = (1 << 3),
PAUSE_INACTIVE_WINDOW = (1 << 4),
PAUSE_WINDOW_ICONISED = (1 << 5),
PAUSE_RESTORE_GUI = (1 << 6),
PAUSE_FREEZE_FILE = (1 << 7)
enum
{
PAUSE_NETPLAY_CONNECT = (1 << 0),
PAUSE_TOGGLE_FULL_SCREEN = (1 << 1),
PAUSE_EXIT = (1 << 2),
PAUSE_MENU = (1 << 3),
PAUSE_INACTIVE_WINDOW = (1 << 4),
PAUSE_WINDOW_ICONISED = (1 << 5),
PAUSE_RESTORE_GUI = (1 << 6),
PAUSE_FREEZE_FILE = (1 << 7)
};
void S9xSetPause (uint32 mask);
void S9xClearPause (uint32 mask);
void S9xSetPause(uint32);
void S9xClearPause(uint32);
void S9xExit(void);
void S9xMessage(int, int, const char *);
extern struct SSettings Settings;
extern struct SCPUState CPU;
extern struct STimings Timings;
extern struct SSNESGameFixes SNESGameFixes;
extern char String[513];
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,352 +0,0 @@
/**********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
Jerremy Koot (jkoot@snes9x.com)
(c) Copyright 2002 - 2004 Matthew Kendora
(c) Copyright 2002 - 2005 Peter Bortas (peter@bortas.org)
(c) Copyright 2004 - 2005 Joel Yliluoma (http://iki.fi/bisqwit/)
(c) Copyright 2001 - 2006 John Weidman (jweidman@slip.net)
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
zones
C4 x86 assembler and some C emulation code
(c) Copyright 2000 - 2003 _Demo_ (_demo_@zsnes.com),
Nach,
zsKnight (zsknight@zsnes.com)
C4 C++ code
(c) Copyright 2003 - 2006 Brad Jorsch,
Nach
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
Kris Bleakley,
Matthew Kendora,
Nach,
neviksti (neviksti@hotmail.com)
DSP-2 emulator code
(c) Copyright 2003 John Weidman,
Kris Bleakley,
Lord Nightmare (lord_nightmare@users.sourceforge.net),
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
Lancer,
z80 gaiden
DSP-4 emulator code
(c) Copyright 2004 - 2006 Dreamer Nom,
John Weidman,
Kris Bleakley,
Nach,
z80 gaiden
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
John Weidman
ST010 C++ emulator code
(c) Copyright 2003 Feather,
John Weidman,
Kris Bleakley,
Matthew Kendora
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
2xSaI filter
(c) Copyright 1999 - 2001 Derek Liauw Kie Fa
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
fee, providing that this license information and copyright notice appear
with all copies and any derived work.
This software is provided 'as-is', without any express or implied
warranty. In no event shall the authors be held liable for any damages
arising from the use of this software or it's derivatives.
Snes9x is freeware for PERSONAL USE only. Commercial users should
seek permission of the copyright holders first. Commercial use includes,
but is not limited to, charging money for Snes9x or software derived from
Snes9x, including Snes9x or derivatives in commercial game bundles, and/or
using Snes9x as a promotion for your commercial product.
The copyright holders request that bug fixes and improvements to the code
should be forwarded to them so everyone can benefit from the modifications
in future versions.
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/
#ifndef _SOUND_H_
#define _SOUND_H_
enum
{
SOUND_SAMPLE = 0,
SOUND_NOISE
};
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 NUM_CHANNELS 8
#define SOUND_DECODE_LENGTH 16
#define SOUND_BUFFER_SIZE (1024 * 16)
#define MAX_BUFFER_SIZE SOUND_BUFFER_SIZE
#define SOUND_BUFFER_SIZE_MASK (SOUND_BUFFER_SIZE - 1)
#define ENV_RANGE 0x800
#define ENV_MAX 0x7FF
#define ENV_SHIFT 4
#ifdef __sgi
#include <audio.h>
#endif /* __sgi */
typedef struct {
int sound_fd; // ** port specific
int sound_switch; // channel on/off
int playback_rate; // 32000Hz is recommended
int buffer_size; // ** port specific
int noise_gen; // ** unused
bool8 mute_sound; // mute
int stereo; // stereo or mono
bool8 sixteen_bit; // 16bit or 8bit sample
bool8 encoded; // ** port specific
#ifdef __sun
int last_eof; // ** port specific
#endif
#ifdef __sgi
ALport al_port; // ** port specific
#endif /* __sgi */
int32 samples_mixed_so_far; // ** port specific
int32 play_position; // ** port specific
uint32 err_counter; // ** port specific
uint32 err_rate; // ** port specific
uint16 stereo_switch; // stereo channel on/off
double pitch_mul; // used with Settings.FixFrequency
} SoundStatus;
EXTERN_C volatile SoundStatus so;
typedef struct {
int32 state; // ADSR/GAIN/RELEASE/SILENT
int32 type; // sample or noise
short volume_left; // VOL(L)
short volume_right; // VOL(R)
uint32 hertz; // ((P(H) << 8) + P(L)) * 8
uint32 frequency; // normalized pitch
uint32 count; // ** unused
bool8 loop; // loop flag in BRR header
int32 envx; // ** unused
short left_vol_level; // ** unused
short right_vol_level; // ** unused
short envx_target; // ** unused
uint32 env_error; // ** unused
uint32 erate; // ** unused
int32 direction; // ** unused
uint32 attack_rate; // ** unused
uint32 decay_rate; // ** unused
uint32 sustain_rate; // ** unused
uint32 release_rate; // ** unused
uint32 sustain_level; // ** unused
signed short sample; // signed 16 bit sample
signed short decoded[16]; // decoded 16 samples
signed short previous16[2];
signed short *block;
uint16 sample_number; // SRCN
bool8 last_block; // end flag in BRR header
bool8 needs_decode; // true when BRR block will be decoded
uint32 block_pointer; // currect block
uint32 sample_pointer; // pointer in a block
int32 *echo_buf_ptr; // EchoBuffer[] or DummyEchoBuffer[]
int32 mode; // ADSR/GAIN/RELEASE/SILENT
int32 envxx; // ** unused
signed short next_sample; // ** unused
int32 interpolate; // ** unused
int32 previous[2]; // last two nybbles for BRR decode
uint32 dummy[8]; // Just incase they are needed in the future,
// for snapshot compatibility.
int32 nb_index; // index of cached samples
int16 nb_sample[4]; // cached samples for interpolation
int16 out_sample; // OUTX << 4
int32 xenvx; // ENVX << 4
int32 xenvx_target; // ENVX target << 4
int32 xenv_count; // counter for envelope timing
int32 xenv_rate; // envelope timing from env_counter_table
int32 xsmp_count; // counter for pitch
int32 xattack_rate; // envelope timing from env_counter_table
int32 xdecay_rate; // envelope timing from env_counter_table
int32 xsustain_rate; // envelope timing from env_counter_table
int32 xsustain_level; // (128 / 8 * (SR + 1)) << 4
} Channel;
typedef struct
{
short master_volume_left; // MVOL(L)
short master_volume_right; // MVOL(R)
short echo_volume_left; // EVOL(L)
short echo_volume_right; // EVOL(R)
int32 echo_enable; // EON
int32 echo_feedback; // EFB
int32 echo_ptr; // index of Echo[]
int32 echo_buffer_size; // num of echo samples
int32 echo_write_enabled; // ECEN
int32 echo_channel_enable; // ** unused
int32 pitch_mod; // PMOD
uint32 dummy[3]; // Just incase they are needed in the future,
// for snapshot compatibility.
Channel channels[NUM_CHANNELS];
bool8 no_filter; // true when simple echo
int32 master_volume[2];
int32 echo_volume[2];
int32 noise_hertz; // ** unused
int32 noise_count; // counter for noise frequency
int32 noise_rate; // noise frequency from env_counter_table
} SSoundData;
EXTERN_C SSoundData SoundData;
void S9xSetEnvelopeRate (int channel, int32 rate_count, int32 xtarget);
void S9xSetSoundVolume (int channel, short volume_left, short volume_right);
void S9xSetMasterVolume (short volume_left, short volume_right);
void S9xSetEchoVolume (short volume_left, short volume_right);
void S9xSetEchoEnable (uint8 byte);
void S9xSetEchoFeedback (int echo_feedback);
void S9xSetEchoDelay (unsigned int byte);
void S9xSetEchoWriteEnable (uint8 byte);
void S9xSetFrequencyModulationEnable (uint8 byte);
void S9xSetSoundKeyOff (int channel);
void S9xPrepareSoundForSnapshotSave (bool8 restore);
void S9xFixSoundAfterSnapshotLoad (int version);
void S9xSetFilterCoefficient (int tap, int value);
void S9xSetSoundADSR (int channel, int ar, int dr, int sr, int sl);
void S9xSetEnvelopeHeight (int channel, int32 xlevel);
uint8 S9xGetEnvelopeHeight (int channel);
void S9xSetSoundHertz (int channel, int hertz);
void S9xSetSoundType (int channel, int type_of_sound);
bool8 S9xSetSoundMute (bool8 mute);
void S9xResetSound (bool8 full);
void S9xSetPlaybackRate (uint32 playback_rate);
bool8 S9xSetSoundMode (int channel, int mode);
void S9xSetSoundControl (int sound_switch);
void S9xPlaySample (int channel);
void S9xFixEnvelope (int channel, uint8 gain, uint8 adsr1, uint8 adsr2);
bool8 S9xOpenSoundDevice (int mode, bool8 stereo, int buffer_size);
EXTERN_C void S9xMixSamples (uint8 *buffer, int sample_count);
EXTERN_C void S9xMixSamplesO (uint8 *buffer, int sample_count, int byte_offset);
#endif

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More