Moving everything to Trunk in prep for Branch "helper app" Open Emu project.
git-svn-id: https://openemu.svn.sourceforge.net/svnroot/openemu/Trunk@669 a16923d9-94c8-4a39-ae78-11df2d60a2ba
This commit is contained in:
File diff suppressed because it is too large
Load Diff
Binary file not shown.
+63
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* GameCore.h
|
||||
* OpenEmu
|
||||
*
|
||||
* Created by Josh Weinberg on 9/1/08.
|
||||
* Copyright 2008 __MyCompanyName__. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
typedef enum{
|
||||
eButton_A,
|
||||
eButton_B,
|
||||
eButton_X,
|
||||
eButton_Y,
|
||||
eButton_START,
|
||||
eButton_SELECT,
|
||||
eButton_UP,
|
||||
eButton_DOWN,
|
||||
eButton_RIGHT,
|
||||
eButton_LEFT,
|
||||
eButton_L,
|
||||
eButton_R,
|
||||
}eButton_Type;
|
||||
|
||||
@protocol GameCore
|
||||
|
||||
#pragma mark Exectuion
|
||||
- (void) pause: (bool) b;
|
||||
- (void) stop;
|
||||
- (void) start;
|
||||
- (void) reset;
|
||||
- (void) executeFrame;
|
||||
|
||||
- (void) setup;
|
||||
- (bool) load: (NSString*) path withParent: (NSDocument*) newParent;
|
||||
|
||||
|
||||
#pragma mark Video
|
||||
- (int) width;
|
||||
- (int) height;
|
||||
- (unsigned char*) buffer;
|
||||
- (GLenum) pixelFormat;
|
||||
- (GLenum) pixelType;
|
||||
- (GLenum) internalPixelFormat;
|
||||
|
||||
#pragma mark Audio
|
||||
- (UInt16*) sndBuf;
|
||||
- (int) channels;
|
||||
- (int) samplesFrame;
|
||||
- (int) sizeSoundBuffer;
|
||||
- (int) sampleRate;
|
||||
|
||||
#pragma mark Input
|
||||
- (void) buttonPressed: (int) gameButton forPlayer: (int) player;
|
||||
- (void) buttonRelease: (int) gameButton forPlayer: (int) player;
|
||||
|
||||
#pragma mark Optional
|
||||
@optional
|
||||
- (void) saveState: (NSString *) fileName;
|
||||
- (void) loadState: (NSString *) fileName;
|
||||
- (void) requestAudio: (int) frames inBuffer: (void*)buf;
|
||||
@end
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleDocumentTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CFBundleTypeExtensions</key>
|
||||
<array>
|
||||
<string>jma</string>
|
||||
<string>zip</string>
|
||||
<string>smc</string>
|
||||
</array>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>SNES Game</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>APPL.icns</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.openemu.${PRODUCT_NAME:identifier}</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>BNDL</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.52.1</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>SNESGameController</string>
|
||||
<key>SUPublicDSAKeyFile</key>
|
||||
<string>dsa_pub.pem</string>
|
||||
<key>SUFeedURL</key>
|
||||
<string>http://openemu.sourceforge.net/snes9x_appcast.xml</string>
|
||||
<key>SUEnableAutomaticChecks</key>
|
||||
<string>1</string>
|
||||
</dict>
|
||||
</plist>
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
Copyright (c) 2009, OpenEmu Team
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the OpenEmu Team nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY OpenEmu Team ''AS IS'' AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL OpenEmu Team BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
//
|
||||
// Prefix header for all source files of the 'SNES9x' target in the 'SNES9x' project.
|
||||
//
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define OE_EXTERN extern "C"
|
||||
#else
|
||||
#define OE_EXTERN extern
|
||||
#endif
|
||||
|
||||
#ifdef __OBJC__
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#endif
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
Copyright (c) 2009, OpenEmu Team
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the OpenEmu Team nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY OpenEmu Team ''AS IS'' AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL OpenEmu Team BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <OEGameCoreController.h>
|
||||
|
||||
@interface SNESGameController : OEGameCoreController
|
||||
@end
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
Copyright (c) 2009, OpenEmu Team
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the OpenEmu Team nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY OpenEmu Team ''AS IS'' AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL OpenEmu Team BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#import "SNESGameController.h"
|
||||
#import "SNESGameEmu.h"
|
||||
#import "SNESPreferenceViewController.h"
|
||||
|
||||
NSArray *SNESRawControlNames = nil;
|
||||
|
||||
@implementation SNESGameController
|
||||
|
||||
+ (void)initialize
|
||||
{
|
||||
if(self == [SNESGameController class])
|
||||
{
|
||||
[self registerPreferenceViewControllerClasses:
|
||||
[NSDictionary dictionaryWithObject:[SNESPreferenceViewController class]
|
||||
forKey:OEControlsPreferenceKey]];
|
||||
|
||||
SNESRawControlNames = [[NSArray alloc] initWithObjects:SNESEmulatorNames
|
||||
count:SNES_CONTROL_COUNT];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSArray *)genericControlNames
|
||||
{
|
||||
return SNESRawControlNames;
|
||||
}
|
||||
|
||||
- (NSUInteger)playerCount
|
||||
{
|
||||
return MAC_MAX_PLAYERS;
|
||||
}
|
||||
|
||||
- (NSString *)pluginName
|
||||
{
|
||||
return @"SNESPlugin";
|
||||
}
|
||||
|
||||
- (Class)gameCoreClass
|
||||
{
|
||||
return [SNESGameEmu class];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
Copyright (c) 2009, OpenEmu Team
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the OpenEmu Team nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY OpenEmu Team ''AS IS'' AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL OpenEmu Team BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <GameCore.h>
|
||||
|
||||
#define MAC_MAX_PLAYERS 8
|
||||
#define SNES_CONTROL_COUNT 12
|
||||
|
||||
OE_EXTERN NSString *SNESEmulatorNames[];
|
||||
|
||||
@class OERingBuffer;
|
||||
|
||||
@interface SNESGameEmu : GameCore {
|
||||
uint32 controlPad[MAC_MAX_PLAYERS];
|
||||
UInt16 *soundBuffer;
|
||||
unsigned char *videoBuffer;
|
||||
}
|
||||
- (void) reportControlPad: (int) padID withFlags: (uint32) flags;
|
||||
|
||||
@end
|
||||
+435
@@ -0,0 +1,435 @@
|
||||
/*
|
||||
Copyright (c) 2009, OpenEmu Team
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the OpenEmu Team nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY OpenEmu Team ''AS IS'' AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL OpenEmu Team BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#import "SNESGameEmu.h"
|
||||
#import <OERingBuffer.h>
|
||||
|
||||
#include "memmap.h"
|
||||
#include "pixform.h"
|
||||
#include "gfx.h"
|
||||
#include "display.h"
|
||||
#include "ppu.h"
|
||||
#include "soundux.h"
|
||||
#include "apu.h"
|
||||
#include "controls.h"
|
||||
#include "snes9x.h"
|
||||
#include "movie.h"
|
||||
#include "snapshot.h"
|
||||
#include "screenshot.h"
|
||||
|
||||
|
||||
#define SAMPLERATE 48000
|
||||
#define SAMPLEFRAME 800
|
||||
#define SIZESOUNDBUFFER SAMPLEFRAME*4
|
||||
|
||||
@interface SNESGameEmu ()
|
||||
- (NSUInteger)SNES_buttonMaskForButton:(OEButton)gameButton;
|
||||
@end
|
||||
|
||||
@implementation SNESGameEmu
|
||||
|
||||
enum
|
||||
{
|
||||
kMacCMapPad1PX,
|
||||
kMacCMapPad1PA,
|
||||
kMacCMapPad1PB,
|
||||
kMacCMapPad1PY,
|
||||
kMacCMapPad1PL,
|
||||
kMacCMapPad1PR,
|
||||
kMacCMapPad1PSelect,
|
||||
kMacCMapPad1PStart,
|
||||
kMacCMapPad1PUp,
|
||||
kMacCMapPad1PDown,
|
||||
kMacCMapPad1PLeft,
|
||||
kMacCMapPad1PRight,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
SNESPadPX,
|
||||
SNESPadPA,
|
||||
SNESPadPB,
|
||||
SNESPadPY,
|
||||
SNESPadPL,
|
||||
SNESPadPR,
|
||||
SNESPadPSelect,
|
||||
SNESPadPStart,
|
||||
SNESPadPUp,
|
||||
SNESPadPDown,
|
||||
SNESPadPLeft,
|
||||
SNESPadPRight,
|
||||
SNESPadCount
|
||||
};
|
||||
|
||||
NSUInteger SNESEmulatorValues[] = { SNES_TR_MASK, SNES_TL_MASK, SNES_X_MASK, SNES_A_MASK, SNES_RIGHT_MASK, SNES_LEFT_MASK, SNES_DOWN_MASK, SNES_UP_MASK, SNES_START_MASK, SNES_SELECT_MASK, SNES_Y_MASK, SNES_B_MASK };
|
||||
NSString *SNESEmulatorNames[] = { @"Joypad@ R", @"Joypad@ L", @"Joypad@ X", @"Joypad@ A", @"Joypad@ Right", @"Joypad@ Left", @"Joypad@ Down", @"Joypad@ Up", @"Joypad@ Start", @"Joypad@ Select", @"Joypad@ Y", @"Joypad@ B" };
|
||||
|
||||
|
||||
#define ASSIGN_BUTTONf(n, s) S9xMapButton (n, cmd = S9xGetCommandT(s), false)
|
||||
#define PLAYER_MASK(player) (1 << (15 + (player)))
|
||||
#define EMULATOR_CMD(aKey) (PLAYER_MASK((aKey).player) | ((aKey).key))
|
||||
- (void)mapButtons
|
||||
{
|
||||
[self.owner forceKeyBindingRecover];
|
||||
#if 0
|
||||
s9xcommand_t cmd;
|
||||
|
||||
ASSIGN_BUTTONf(kMacCMapPad1PX, "Joypad1 X");
|
||||
ASSIGN_BUTTONf(kMacCMapPad1PA, "Joypad1 A");
|
||||
ASSIGN_BUTTONf(kMacCMapPad1PB, "Joypad1 B");
|
||||
ASSIGN_BUTTONf(kMacCMapPad1PY, "Joypad1 Y");
|
||||
ASSIGN_BUTTONf(kMacCMapPad1PL, "Joypad1 L");
|
||||
ASSIGN_BUTTONf(kMacCMapPad1PR, "Joypad1 R");
|
||||
ASSIGN_BUTTONf(kMacCMapPad1PSelect, "Joypad1 Select");
|
||||
ASSIGN_BUTTONf(kMacCMapPad1PStart, "Joypad1 Start");
|
||||
ASSIGN_BUTTONf(kMacCMapPad1PUp, "Joypad1 Up");
|
||||
ASSIGN_BUTTONf(kMacCMapPad1PDown, "Joypad1 Down");
|
||||
ASSIGN_BUTTONf(kMacCMapPad1PLeft, "Joypad1 Left");
|
||||
ASSIGN_BUTTONf(kMacCMapPad1PRight, "Joypad1 Right");
|
||||
#endif
|
||||
}
|
||||
|
||||
- (OEEmulatorKey)emulatorKeyForKey:(NSString *)aKey index:(NSUInteger)index player:(NSUInteger)thePlayer
|
||||
{
|
||||
NSUInteger val = SNESEmulatorValues[index];
|
||||
OEEmulatorKey ret = OEMakeEmulatorKey(thePlayer, val);
|
||||
s9xcommand_t cmd = S9xGetCommandT([aKey UTF8String]);
|
||||
S9xMapButton(EMULATOR_CMD(ret), cmd, false);
|
||||
return ret;
|
||||
}
|
||||
|
||||
- (void)pressEmulatorKey:(OEEmulatorKey)aKey
|
||||
{
|
||||
S9xReportButton(EMULATOR_CMD(aKey), true);
|
||||
}
|
||||
|
||||
- (void)releaseEmulatorKey:(OEEmulatorKey)aKey
|
||||
{
|
||||
S9xReportButton(EMULATOR_CMD(aKey), false);
|
||||
}
|
||||
#undef EMULATOR_CMD
|
||||
#pragma mark Exectuion
|
||||
|
||||
- (void) reportControlPad: (int) padID withFlags: (uint32) flags
|
||||
{
|
||||
#if 0
|
||||
S9xReportButton(base + 0, (flags & SNES_X_MASK));
|
||||
S9xReportButton(base + 1, (flags & SNES_A_MASK));
|
||||
S9xReportButton(base + 2, (flags & SNES_B_MASK));
|
||||
S9xReportButton(base + 3, (flags & SNES_Y_MASK));
|
||||
S9xReportButton(base + 4, (flags & SNES_TL_MASK));
|
||||
S9xReportButton(base + 5, (flags & SNES_TR_MASK));
|
||||
S9xReportButton(base + 6, (flags & SNES_SELECT_MASK));
|
||||
S9xReportButton(base + 7, (flags & SNES_START_MASK));
|
||||
S9xReportButton(base + 8, (flags & SNES_UP_MASK));
|
||||
S9xReportButton(base + 9, (flags & SNES_DOWN_MASK));
|
||||
S9xReportButton(base + 10, (flags & SNES_LEFT_MASK));
|
||||
S9xReportButton(base + 11, (flags & SNES_RIGHT_MASK));
|
||||
#endif
|
||||
}
|
||||
- (void)executeFrame
|
||||
{
|
||||
[self executeFrameSkippingFrame:NO];
|
||||
}
|
||||
|
||||
- (void)executeFrameSkippingFrame: (BOOL) skip
|
||||
{
|
||||
[self reportControlPad:0 withFlags:controlPad[0]];
|
||||
|
||||
IPPU.RenderThisFrame = !skip;
|
||||
S9xMainLoop();
|
||||
|
||||
S9xMixSamples((unsigned char*)soundBuffer, SAMPLEFRAME * [self channelCount]);
|
||||
[[self ringBufferAtIndex:0] write:soundBuffer maxLength:sizeof(UInt16) * [self channelCount] * SAMPLEFRAME];
|
||||
}
|
||||
|
||||
- (BOOL)loadFileAtPath: (NSString*) path
|
||||
{
|
||||
|
||||
memset(&Settings, 0, sizeof(Settings));
|
||||
Settings.ForcePAL = false;
|
||||
Settings.ForceNTSC = false;
|
||||
Settings.ForceHeader = false;
|
||||
Settings.ForceNoHeader = false;
|
||||
|
||||
Settings.ForceSuperFX = Settings.ForceNoSuperFX = false;
|
||||
Settings.ForceDSP1 = Settings.ForceNoDSP1 = false;
|
||||
Settings.ForceSA1 = Settings.ForceNoSA1 = false;
|
||||
Settings.ForceC4 = Settings.ForceNoC4 = false;
|
||||
Settings.ForceSDD1 = Settings.ForceNoSDD1 = false;
|
||||
|
||||
Settings.MouseMaster = true;
|
||||
Settings.SuperScopeMaster = true;
|
||||
Settings.MultiPlayer5Master = true;
|
||||
Settings.JustifierMaster = true;
|
||||
Settings.ShutdownMaster = false;
|
||||
Settings.BlockInvalidVRAMAccess = true;
|
||||
Settings.HDMATimingHack = 100;
|
||||
Settings.APUEnabled = true;
|
||||
Settings.NextAPUEnabled = true;
|
||||
Settings.SoundPlaybackRate = 48000;
|
||||
Settings.Stereo = true;
|
||||
Settings.SixteenBitSound = true;
|
||||
Settings.SoundEnvelopeHeightReading = true;
|
||||
Settings.DisableSampleCaching = false;
|
||||
Settings.DisableSoundEcho = false;
|
||||
Settings.InterpolatedSound = true;
|
||||
Settings.Transparency = true;
|
||||
Settings.SupportHiRes = true;
|
||||
Settings.SDD1Pack = true;
|
||||
GFX.InfoString = nil;
|
||||
GFX.InfoStringTimeout = 0;
|
||||
|
||||
if(videoBuffer)
|
||||
free(videoBuffer);
|
||||
videoBuffer = (unsigned char*)malloc(1024*1024*2);
|
||||
//GFX.PixelFormat = 3;
|
||||
|
||||
GFX.Pitch = 512 * 2;
|
||||
// GFX.PPL = SNES_WIDTH;
|
||||
GFX.Screen = (short unsigned int*)videoBuffer;
|
||||
|
||||
S9xUnmapAllControls();
|
||||
|
||||
[self mapButtons];
|
||||
|
||||
S9xSetController(0, CTL_JOYPAD, 0, 0, 0, 0);
|
||||
S9xSetController(1, CTL_JOYPAD, 1, 0, 0, 0);
|
||||
|
||||
//S9xSetRenderPixelFormat(RGB565);
|
||||
if (!Memory.Init() || !S9xInitAPU() || !S9xGraphicsInit())
|
||||
NSLog(@"Couldn't init");
|
||||
NSLog(@"loading %@", path);
|
||||
|
||||
Settings.NoPatch = true;
|
||||
if(Memory.LoadROM([path UTF8String]))
|
||||
{
|
||||
NSString* path = [NSString stringWithUTF8String:Memory.ROMFilename];
|
||||
NSString *extensionlessFilename = [[path lastPathComponent] stringByDeletingPathExtension];
|
||||
NSString *appSupportPath = [[[NSHomeDirectory() stringByAppendingPathComponent:@"Library"] stringByAppendingPathComponent:@"Application Support"] stringByAppendingPathComponent:@"Snes9x"];
|
||||
if(![[NSFileManager defaultManager] fileExistsAtPath:appSupportPath])
|
||||
[[NSFileManager defaultManager] createDirectoryAtPath:appSupportPath attributes:nil];
|
||||
|
||||
|
||||
NSLog(@"Trying to save SRAM");
|
||||
|
||||
NSString *batterySavesDirectory = [appSupportPath stringByAppendingPathComponent:@"Battery Saves"];
|
||||
if(![[NSFileManager defaultManager] fileExistsAtPath:batterySavesDirectory])
|
||||
[[NSFileManager defaultManager] createDirectoryAtPath:batterySavesDirectory attributes:nil];
|
||||
NSString *filePath = [batterySavesDirectory stringByAppendingPathComponent:[extensionlessFilename stringByAppendingPathExtension:@"sav"]];
|
||||
|
||||
|
||||
Memory.LoadSRAM([filePath UTF8String]);
|
||||
S9xInitSound(1, Settings.Stereo, SIZESOUNDBUFFER);
|
||||
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
bool8 S9xOpenSoundDevice (int mode, bool8 stereo, int buffer_size)
|
||||
{
|
||||
NSLog(@"Open sound");
|
||||
so.buffer_size = buffer_size;
|
||||
|
||||
so.playback_rate = Settings.SoundPlaybackRate;
|
||||
so.stereo = Settings.Stereo;
|
||||
so.sixteen_bit = Settings.SixteenBitSound;
|
||||
so.encoded = false;
|
||||
|
||||
so.samples_mixed_so_far = 0;
|
||||
|
||||
S9xSetPlaybackRate(so.playback_rate);
|
||||
|
||||
so.mute_sound = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
#pragma mark Video
|
||||
- (const void *)videoBuffer
|
||||
{
|
||||
return GFX.Screen;
|
||||
}
|
||||
|
||||
- (NSUInteger)screenWidth
|
||||
{
|
||||
return MAX_SNES_WIDTH;
|
||||
}
|
||||
|
||||
- (NSUInteger)screenHeight
|
||||
{
|
||||
return MAX_SNES_HEIGHT;
|
||||
}
|
||||
|
||||
- (CGRect)sourceRect
|
||||
{
|
||||
return CGRectMake(0, 0, IPPU.RenderedScreenWidth, IPPU.RenderedScreenHeight);
|
||||
}
|
||||
|
||||
- (NSUInteger)bufferWidth
|
||||
{
|
||||
return MAX_SNES_WIDTH;
|
||||
}
|
||||
- (NSUInteger)bufferHeight
|
||||
{
|
||||
return MAX_SNES_HEIGHT;
|
||||
}
|
||||
|
||||
- (void)setupEmulation
|
||||
{
|
||||
if(soundBuffer)
|
||||
free(soundBuffer);
|
||||
soundBuffer = (UInt16*)malloc(SIZESOUNDBUFFER* sizeof(UInt16));
|
||||
memset(soundBuffer, 0, SIZESOUNDBUFFER*sizeof(UInt16));
|
||||
}
|
||||
|
||||
- (void)resetEmulation
|
||||
{
|
||||
S9xSoftReset();
|
||||
}
|
||||
|
||||
- (void)stopEmulation
|
||||
{
|
||||
NSString* path = [NSString stringWithUTF8String:Memory.ROMFilename];
|
||||
NSString *extensionlessFilename = [[path lastPathComponent] stringByDeletingPathExtension];
|
||||
NSString *appSupportPath = [[[NSHomeDirectory() stringByAppendingPathComponent:@"Library"] stringByAppendingPathComponent:@"Application Support"] stringByAppendingPathComponent:@"Snes9x"];
|
||||
if(![[NSFileManager defaultManager] fileExistsAtPath:appSupportPath])
|
||||
[[NSFileManager defaultManager] createDirectoryAtPath:appSupportPath attributes:nil];
|
||||
|
||||
|
||||
NSLog(@"Trying to save SRAM");
|
||||
|
||||
NSString *batterySavesDirectory = [appSupportPath stringByAppendingPathComponent:@"Battery Saves"];
|
||||
if(![[NSFileManager defaultManager] fileExistsAtPath:batterySavesDirectory])
|
||||
[[NSFileManager defaultManager] createDirectoryAtPath:batterySavesDirectory attributes:nil];
|
||||
NSString *filePath = [batterySavesDirectory stringByAppendingPathComponent:[extensionlessFilename stringByAppendingPathExtension:@"sav"]];
|
||||
|
||||
Memory.SaveSRAM( [filePath UTF8String] );
|
||||
[super stopEmulation];
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
free(videoBuffer);
|
||||
free(soundBuffer);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (GLenum)pixelFormat
|
||||
{
|
||||
return GL_RGB;
|
||||
}
|
||||
|
||||
- (GLenum)pixelType
|
||||
{
|
||||
return GL_UNSIGNED_SHORT_5_6_5;
|
||||
}
|
||||
|
||||
- (GLenum)internalPixelFormat
|
||||
{
|
||||
return GL_RGB5;
|
||||
}
|
||||
|
||||
- (NSUInteger)soundBufferSize
|
||||
{
|
||||
return SIZESOUNDBUFFER;
|
||||
}
|
||||
|
||||
- (NSUInteger)frameSampleCount
|
||||
{
|
||||
return SAMPLEFRAME;
|
||||
}
|
||||
|
||||
- (NSUInteger)frameSampleRate
|
||||
{
|
||||
return SAMPLERATE;
|
||||
}
|
||||
|
||||
- (NSTimeInterval)frameInterval
|
||||
{
|
||||
if( Settings.PAL )
|
||||
return 50;
|
||||
else
|
||||
return 60;
|
||||
}
|
||||
|
||||
- (NSUInteger)channelCount
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
- (NSUInteger)SNES_buttonMaskForButton:(OEButton)gameButton
|
||||
{
|
||||
NSUInteger button = 0;
|
||||
switch (gameButton)
|
||||
{
|
||||
case OEButton_1 : button = SNES_A_MASK; break;
|
||||
case OEButton_2 : button = SNES_B_MASK; break;
|
||||
case OEButton_3 : button = SNES_X_MASK; break;
|
||||
case OEButton_4 : button = SNES_Y_MASK; break;
|
||||
case OEButton_5 : button = SNES_TL_MASK; break;
|
||||
case OEButton_6 : button = SNES_TR_MASK; break;
|
||||
case OEButton_Up : button = SNES_UP_MASK; break;
|
||||
case OEButton_Down : button = SNES_DOWN_MASK; break;
|
||||
case OEButton_Left : button = SNES_LEFT_MASK; break;
|
||||
case OEButton_Right : button = SNES_RIGHT_MASK; break;
|
||||
case OEButton_Start : button = SNES_START_MASK; break;
|
||||
case OEButton_Select : button = SNES_SELECT_MASK; break;
|
||||
}
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
- (void)player:(NSUInteger)thePlayer didPressButton:(OEButton)gameButton;
|
||||
{
|
||||
controlPad[thePlayer - 1] |= [self SNES_buttonMaskForButton:gameButton];
|
||||
}
|
||||
|
||||
- (void)player:(NSUInteger)thePlayer didReleaseButton:(OEButton)gameButton;
|
||||
{
|
||||
controlPad[thePlayer - 1] &= ~[self SNES_buttonMaskForButton:gameButton];
|
||||
}
|
||||
|
||||
- (BOOL) saveStateToFileAtPath: (NSString *) fileName
|
||||
{
|
||||
bool8 success = S9xFreezeGame([fileName UTF8String]);
|
||||
|
||||
if(success)
|
||||
return YES;
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL) loadStateFromFileAtPath: (NSString *) fileName
|
||||
{
|
||||
bool8 success = S9xUnfreezeGame([fileName UTF8String]);
|
||||
|
||||
if(success)
|
||||
return YES;
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
Copyright (c) 2009, OpenEmu Team
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the OpenEmu Team nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY OpenEmu Team ''AS IS'' AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL OpenEmu Team BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <OEControlsViewController.h>
|
||||
|
||||
@interface SNESPreferenceViewController : OEControlsViewController
|
||||
@end
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
Copyright (c) 2009, OpenEmu Team
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the OpenEmu Team nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY OpenEmu Team ''AS IS'' AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL OpenEmu Team BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#import "SNESPreferenceViewController.h"
|
||||
#import <OEGameControllerView.h>
|
||||
|
||||
@implementation SNESPreferenceViewController
|
||||
|
||||
- (void)awakeFromNib
|
||||
{
|
||||
[super awakeFromNib];
|
||||
|
||||
OEGameControllerView *view = (OEGameControllerView *)[self view];
|
||||
NSString *path = [[NSBundle bundleForClass:[self class]] pathForImageResource:@"snes_pad.png"];
|
||||
[view setGameController:[[[NSImage alloc] initWithContentsOfFile:path] autorelease]];
|
||||
[view setControlZone:NSMakeRect(0, 0, 600, 230)];
|
||||
|
||||
[view addButtonWithName:@"Joypad@ L" toolTip:@"Left Trigger" target:self startPosition:NSMakePoint(50, 180) endPosition:NSMakePoint(217, 178)];
|
||||
[view addButtonWithName:@"Joypad@ Up" toolTip:@"D-Pad Up" target:self startPosition:NSMakePoint(50, 148) endPosition:NSMakePoint(220, 121)];
|
||||
[view addButtonWithName:@"Joypad@ Left" toolTip:@"D-Pad Left" target:self startPosition:NSMakePoint(50, 116) endPosition:NSMakePoint(202, 107)];
|
||||
[view addButtonWithName:@"Joypad@ Right" toolTip:@"D-Pad Right" target:self startPosition:NSMakePoint(50, 84) endPosition:NSMakePoint(234, 106)];
|
||||
[view addButtonWithName:@"Joypad@ Down" toolTip:@"D-Pad Down" target:self startPosition:NSMakePoint(50, 52) endPosition:NSMakePoint(218, 91)];
|
||||
|
||||
[view addButtonWithName:@"Joypad@ Select" toolTip:@"Select Button" target:self startPosition:NSMakePoint(252, 25) endPosition:NSMakePoint(276, 98)];
|
||||
[view addButtonWithName:@"Joypad@ Start" toolTip:@"Start Button" target:self startPosition:NSMakePoint(348, 25) endPosition:NSMakePoint(308, 98)];
|
||||
|
||||
[view addButtonWithName:@"Joypad@ R" toolTip:@"Right Trigger" target:self startPosition:NSMakePoint(550, 180) endPosition:NSMakePoint(389, 177)];
|
||||
[view addButtonWithName:@"Joypad@ X" toolTip:@"X Button" target:self startPosition:NSMakePoint(550, 148) endPosition:NSMakePoint(389, 128)];
|
||||
[view addButtonWithName:@"Joypad@ A" toolTip:@"A Button" target:self startPosition:NSMakePoint(550, 116) endPosition:NSMakePoint(415, 107)];
|
||||
[view addButtonWithName:@"Joypad@ Y" toolTip:@"Y Button" target:self startPosition:NSMakePoint(550, 84) endPosition:NSMakePoint(361, 108)];
|
||||
[view addButtonWithName:@"Joypad@ B" toolTip:@"B Button" target:self startPosition:NSMakePoint(550, 52) endPosition:NSMakePoint(386, 86)];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,9 @@
|
||||
build_now: 'YES'
|
||||
create_core_path: 'YES'
|
||||
download_base_url: http://openemu.sourceforge.net/
|
||||
release_notes_base_url: http://openemu.sourceforge.net/category/releasenotes/snes9x/
|
||||
appcast_basefolder: '/Users/dan/Desktop/Appcast'
|
||||
appcast_xml_name: 'snes9x_appcast.xml'
|
||||
keychain_privkey_name: 'OE App Sparkle Private Key'
|
||||
css_file_name: 'rnotes.css'
|
||||
bundle_extension: 'oecoreplugin'
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
MIIDOjCCAi0GByqGSM44BAEwggIgAoIBAQD/nSuLzikeU6MrymSPr34AiU2RDJz6
|
||||
0pm/3PPs27f6QTtbUAvGC13q6XWrE3HJU8Gz7RM0EJZGpiwb86LgqOJhjfQ7WKse
|
||||
uaGdbHnvJEFsGqpKX7rnUWaWO3HAsKzDx4HzJqKupFEbTbzXl/GT3JMm+a3PXA3S
|
||||
kyATydRPrX583Ih8iHO1zQs1pwp2AnUvaQXvp4QOLFWheH5napkDZBjc9B7H38dg
|
||||
f4c0QqEXJw0lJbG26FxhpOWMiXwpWpOHSfb+XtmzpeTDIHxKPLMEdf2wc+xNC/M9
|
||||
GdVBfM7+hCEhl1JGqNWPpT7ZzciX8Cxg+5/MIfx+BQ7xQ4wo1SN7y1bZAhUAuBcT
|
||||
+ZsHbLXlR3uGHLIMg8boUKcCggEAGKgD56/tB6siFr5zEY+RTozPLmbBEcvhz5/p
|
||||
hAQo7z7ODimZAA1MN1J7Hv7o1S5D9dpZuOnGhiXaN3Z50WdePb9LVH7twrB8v3Xn
|
||||
ZOEHpumYNcYhvXrIx8LbhnMZmU27xSnrOQF9UfokRxGnXkNmlIwjT0NWqZCqQZwM
|
||||
wVj1Bgld3YV7CpGTF3aGM6a0pk9LBB71PoczXAx0Cum87ouXXy3c8F/82RF9tgXE
|
||||
ZBQ+7K2QXYPv9smbYDB+ZlsQ4VTOi3AReG5AeHTVWha3uaSFxY5vKpfau31iMRuT
|
||||
b1VQ2HVynBpemwhAw4FFvj5dm94aN0Rrvq9BKM09DL4zoOlLogOCAQUAAoIBAE8B
|
||||
I8z38GdbtswSoSV5JZ9z9cBMj/7x/sHi5ED9v1M8MD6AcxJSbo2cbK98xA3A9U22
|
||||
6XFHthGReVLa0dyN3Ov+GhBdf8b4CBuebAAS4z8du2EvUFtwDUHorLIo2Qtq2SYR
|
||||
wpznpB9+3g+z+8GZbzZkdm2mFBKa6GItj82qfEHwxB40aEBx7uQXzM3TH0rV8sMq
|
||||
u91aAVUQuoiG2/IYWc5O34kKMlHUTt6+uuJiSG0ax8ysWE5XltCfSh/VJcGrzKU6
|
||||
ZjGBzh8j5+KSXgoe9TuKlsnN5HDCZKaFTCvrxq889HJj0/ks4UrIF+meEyJvDt4P
|
||||
O4HHoKRtUdLEBMcY0JA=
|
||||
-----END PUBLIC KEY-----
|
||||
@@ -0,0 +1,262 @@
|
||||
/**********************************************************************************
|
||||
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 _65c816_h_
|
||||
#define _65c816_h_
|
||||
|
||||
#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 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))
|
||||
|
||||
typedef union
|
||||
{
|
||||
#ifdef LSB_FIRST
|
||||
struct { uint8 l,h; } B;
|
||||
#else
|
||||
struct { uint8 h,l; } B;
|
||||
#endif
|
||||
uint16 W;
|
||||
} pair;
|
||||
|
||||
typedef union {
|
||||
#ifdef LSB_FIRST
|
||||
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;
|
||||
#endif
|
||||
uint32 xPBPC;
|
||||
} PC_t;
|
||||
|
||||
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
|
||||
|
||||
EXTERN_C struct SRegisters Registers;
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,292 @@
|
||||
/**********************************************************************************
|
||||
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;
|
||||
int32 NextAPUTimerPos;
|
||||
int32 APUTimerCounter;
|
||||
uint32 Scanline;
|
||||
int32 OneCycle;
|
||||
int32 TwoCycles;
|
||||
};
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
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
|
||||
|
||||
@@ -0,0 +1,509 @@
|
||||
/**********************************************************************************
|
||||
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
|
||||
|
||||
|
||||
@@ -0,0 +1,310 @@
|
||||
/**********************************************************************************
|
||||
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 _apumemory_h_
|
||||
#define _apumemory_h_
|
||||
|
||||
START_EXTERN_C
|
||||
extern uint8 APUROM[64];
|
||||
END_EXTERN_C
|
||||
|
||||
static INLINE uint8 apu_get_reg (uint8 Address)
|
||||
{
|
||||
switch (Address)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static INLINE void apu_set_reg (uint8 byte, uint8 Address)
|
||||
{
|
||||
switch (Address)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
APU.ExtraRAM[Address - 0xffc0] = byte;
|
||||
if (!APU.ShowROM)
|
||||
IAPU.RAM[Address] = byte;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // _apumemory_h_
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,199 @@
|
||||
/**********************************************************************************
|
||||
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 _BSX_H_
|
||||
#define _BSX_H_
|
||||
|
||||
struct SBSX
|
||||
{
|
||||
bool8 dirty; // Changed register values
|
||||
bool8 dirty2; // Changed register values
|
||||
bool8 bootup; // Start in bios mapping
|
||||
bool8 flash_enable; // Flash state
|
||||
bool8 write_enable; // ROM write protection
|
||||
bool8 read_enable; // Allow card vendor reading
|
||||
uint32 flash_command; // Flash command
|
||||
uint32 old_write; // Previous flash write address
|
||||
uint32 new_write; // Current flash write address
|
||||
uint8 out_index;
|
||||
uint8 output[32];
|
||||
uint8 PPU[32];
|
||||
uint8 MMC[16];
|
||||
uint8 prevMMC[16];
|
||||
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
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,320 @@
|
||||
/**********************************************************************************
|
||||
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 <math.h>
|
||||
#include <stdlib.h>
|
||||
#include "c4.h"
|
||||
#include "memmap.h"
|
||||
extern "C" {
|
||||
|
||||
short C4WFXVal;
|
||||
short C4WFYVal;
|
||||
short C4WFZVal;
|
||||
short C4WFX2Val;
|
||||
short C4WFY2Val;
|
||||
short C4WFDist;
|
||||
short C4WFScale;
|
||||
|
||||
static double tanval;
|
||||
static double c4x, c4y, c4z;
|
||||
static double c4x2, c4y2, c4z2;
|
||||
|
||||
void C4TransfWireFrame ()
|
||||
{
|
||||
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 Y
|
||||
tanval = -(double)C4WFY2Val*3.14159265*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);
|
||||
|
||||
// Scale
|
||||
C4WFXVal = (short) (c4x*(double)C4WFScale/(0x90*(c4z+0x95))*0x95);
|
||||
C4WFYVal = (short) (c4y*(double)C4WFScale/(0x90*(c4z+0x95))*0x95);
|
||||
}
|
||||
|
||||
void C4TransfWireFrame2 ()
|
||||
{
|
||||
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 Y
|
||||
tanval = -(double) C4WFY2Val * 3.14159265 * 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);
|
||||
|
||||
// Scale
|
||||
C4WFXVal =(short)(c4x * (double)C4WFScale / 0x100);
|
||||
C4WFYVal =(short)(c4y * (double)C4WFScale / 0x100);
|
||||
}
|
||||
|
||||
void C4CalcWireFrame ()
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
short C41FXVal;
|
||||
short C41FYVal;
|
||||
short C41FAngleRes;
|
||||
short C41FDist;
|
||||
short C41FDistVal;
|
||||
|
||||
void C4Op1F ()
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
void C4Op15()
|
||||
{
|
||||
tanval = sqrt ((double) C41FYVal * C41FYVal + (double) C41FXVal * C41FXVal);
|
||||
C41FDist = (short) tanval;
|
||||
}
|
||||
|
||||
void C4Op0D()
|
||||
{
|
||||
tanval = sqrt ((double) C41FYVal * C41FYVal + (double) C41FXVal * C41FXVal);
|
||||
tanval = C41FDistVal / tanval;
|
||||
C41FYVal = (short) (C41FYVal * tanval * 0.99);
|
||||
C41FXVal = (short) (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&~MEMMAP_MASK)>=(0x7f40&~MEMMAP_MASK) &&
|
||||
(Address&~MEMMAP_MASK)<=(0x7f5e&~MEMMAP_MASK)){
|
||||
return NULL;
|
||||
}
|
||||
return Memory.C4RAM-0x6000;
|
||||
}
|
||||
|
||||
}//end extern C
|
||||
@@ -0,0 +1,203 @@
|
||||
/**********************************************************************************
|
||||
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 _C4_H_
|
||||
#define _C4_H_
|
||||
|
||||
#include "port.h"
|
||||
#include "memmap.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
extern int16 C4WFXVal;
|
||||
extern int16 C4WFYVal;
|
||||
extern int16 C4WFZVal;
|
||||
extern int16 C4WFX2Val;
|
||||
extern int16 C4WFY2Val;
|
||||
extern int16 C4WFDist;
|
||||
extern int16 C4WFScale;
|
||||
|
||||
void C4TransfWireFrame();
|
||||
void C4TransfWireFrame2();
|
||||
void C4CalcWireFrame();
|
||||
|
||||
extern int16 C41FXVal;
|
||||
extern int16 C41FYVal;
|
||||
extern int16 C41FAngleRes;
|
||||
extern int16 C41FDist;
|
||||
extern int16 C41FDistVal;
|
||||
|
||||
void C4Op1F();
|
||||
void C4Op15();
|
||||
void C4Op0D();
|
||||
|
||||
extern int16 C4CosTable[];
|
||||
extern int16 C4SinTable[];
|
||||
|
||||
}
|
||||
|
||||
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
@@ -0,0 +1,580 @@
|
||||
/**********************************************************************************
|
||||
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 <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include "snes9x.h"
|
||||
#include "cheats.h"
|
||||
#include "memmap.h"
|
||||
|
||||
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);
|
||||
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
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.");
|
||||
|
||||
address = data >> 8;
|
||||
byte = (uint8) data;
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
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.");
|
||||
|
||||
strncpy (tmp, code, 5);
|
||||
tmp [5] = 0;
|
||||
if (sscanf (tmp, "%x", &address) != 1)
|
||||
return ("Invalid Gold Finger code.");
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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++)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
#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)))
|
||||
|
||||
#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)
|
||||
{
|
||||
int l;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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 < 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 < 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 < 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);
|
||||
}
|
||||
|
||||
void S9xSearchForValue (SCheatData *d, S9xCheatComparisonType cmp,
|
||||
S9xCheatDataSize size, uint32 value,
|
||||
bool8 is_signed, bool8 update)
|
||||
{
|
||||
int l;
|
||||
|
||||
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), (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) &&
|
||||
_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) &&
|
||||
_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) &&
|
||||
_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) &&
|
||||
_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);
|
||||
}
|
||||
|
||||
void S9xSearchForAddress (SCheatData *d, S9xCheatComparisonType cmp,
|
||||
S9xCheatDataSize size, uint32 value, bool8 update)
|
||||
{
|
||||
int l;
|
||||
|
||||
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) &&
|
||||
_C(cmp, i, (int)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) &&
|
||||
_C(cmp, i+0x20000, (int)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) &&
|
||||
_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);
|
||||
}
|
||||
|
||||
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]);
|
||||
}
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,247 @@
|
||||
/**********************************************************************************
|
||||
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 _CHEATS_H_
|
||||
#define _CHEATS_H_
|
||||
|
||||
struct SCheat
|
||||
{
|
||||
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 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;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
S9X_8_BITS, S9X_16_BITS, S9X_24_BITS, S9X_32_BITS
|
||||
} S9xCheatDataSize;
|
||||
|
||||
void S9xInitCheatData ();
|
||||
|
||||
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 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 S9xOutputCheatSearchResults (SCheatData *);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,381 @@
|
||||
/**********************************************************************************
|
||||
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 <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include "snes9x.h"
|
||||
#include "cheats.h"
|
||||
#include "memmap.h"
|
||||
|
||||
#ifndef INLINE
|
||||
#define INLINE inline
|
||||
#endif
|
||||
|
||||
extern SCheatData Cheat;
|
||||
Watch watches [16];
|
||||
|
||||
// read a byte without altering CPU
|
||||
INLINE uint8 S9xGetByteFree (uint32 Address)
|
||||
{
|
||||
uint32 Cycles = CPU.Cycles;
|
||||
uint32 WaitAddress = CPU.WaitAddress;
|
||||
uint8 rv = S9xGetByte (Address);
|
||||
CPU.WaitAddress = WaitAddress;
|
||||
CPU.Cycles = Cycles;
|
||||
return rv;
|
||||
}
|
||||
INLINE void S9xSetByteFree (uint8 Byte, uint32 Address)
|
||||
{
|
||||
uint32 Cycles = CPU.Cycles;
|
||||
uint32 WaitAddress = CPU.WaitAddress;
|
||||
S9xSetByte (Byte, Address);
|
||||
CPU.WaitAddress = WaitAddress;
|
||||
CPU.Cycles = Cycles;
|
||||
}
|
||||
|
||||
void S9xInitCheatData ()
|
||||
{
|
||||
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].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.c [Cheat.num_cheats].saved_byte = S9xGetByteFree (address);
|
||||
Cheat.c [Cheat.num_cheats].saved = TRUE;
|
||||
}
|
||||
Cheat.num_cheats++;
|
||||
}
|
||||
}
|
||||
|
||||
void S9xDeleteCheat (uint32 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??
|
||||
}
|
||||
}
|
||||
|
||||
void S9xDeleteCheats ()
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
void S9xRemoveCheat (uint32 which1)
|
||||
{
|
||||
if (Cheat.c [which1].saved)
|
||||
{
|
||||
uint32 address = Cheat.c [which1].address;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
void S9xApplyCheat (uint32 which1)
|
||||
{
|
||||
uint32 address = Cheat.c [which1].address;
|
||||
|
||||
if (!Cheat.c [which1].saved)
|
||||
Cheat.c [which1].saved_byte = S9xGetByteFree (address);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void S9xApplyCheats ()
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
bool8 S9xLoadCheatFile (const char *filename)
|
||||
{
|
||||
Cheat.num_cheats = 0;
|
||||
|
||||
FILE *fs = fopen (filename, "rb");
|
||||
uint8 data [28];
|
||||
|
||||
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);
|
||||
|
||||
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)
|
||||
{
|
||||
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;
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,347 @@
|
||||
/**********************************************************************************
|
||||
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 "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 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;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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
@@ -0,0 +1,450 @@
|
||||
/**********************************************************************************
|
||||
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 FOO_H
|
||||
#define FOO_H
|
||||
|
||||
#include "port.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
|
||||
|
||||
#define S9xButtonPseudopointer 254
|
||||
#define S9xAxisPseudopointer 253
|
||||
#define S9xAxisPseudobuttons 252
|
||||
|
||||
// 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)
|
||||
|
||||
// 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)
|
||||
|
||||
// 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;
|
||||
|
||||
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 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: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;
|
||||
|
||||
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 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;
|
||||
|
||||
uint8 port[4];
|
||||
};
|
||||
} s9xcommand_t;
|
||||
|
||||
|
||||
/* Starting out... */
|
||||
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) */
|
||||
};
|
||||
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);
|
||||
|
||||
/*
|
||||
* 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);
|
||||
|
||||
/*
|
||||
* 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);
|
||||
|
||||
/*
|
||||
* Generic mapping functions
|
||||
*/
|
||||
s9xcommand_t S9xGetMapping(uint32 id);
|
||||
void S9xUnmapID(uint32 id);
|
||||
|
||||
/*
|
||||
* 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);
|
||||
|
||||
/*
|
||||
* 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);
|
||||
|
||||
/*
|
||||
* 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);
|
||||
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
#ifdef SNES_JOY_READ_CALLBACKS
|
||||
void S9xOnSNESPadRead();
|
||||
#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 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 writing to $4016 */
|
||||
void S9xSetJoypadLatch(bool latch);
|
||||
|
||||
/* 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);
|
||||
|
||||
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);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,433 @@
|
||||
/**********************************************************************************
|
||||
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 "memmap.h"
|
||||
#include "ppu.h"
|
||||
#include "dsp1.h"
|
||||
#include "cpuexec.h"
|
||||
#include "debug.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"
|
||||
#include "logger.h"
|
||||
|
||||
|
||||
#ifndef ZSNES_FX
|
||||
#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);
|
||||
}
|
||||
#endif
|
||||
|
||||
void S9xSoftResetCPU ()
|
||||
{
|
||||
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;
|
||||
|
||||
ICPU.ShiftedPB = 0;
|
||||
ICPU.ShiftedDB = 0;
|
||||
SetFlags (MemoryFlag | IndexFlag | IRQ | Emulation);
|
||||
ClearFlags (Decimal);
|
||||
|
||||
CPU.Flags = CPU.Flags & (DEBUG_MODE_FLAG | TRACE_FLAG);
|
||||
CPU.BranchSkip = FALSE;
|
||||
CPU.NMIActive = FALSE;
|
||||
CPU.IRQActive = FALSE;
|
||||
CPU.WaitingForInterrupt = FALSE;
|
||||
CPU.InDMA = FALSE;
|
||||
CPU.InHDMA = 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;
|
||||
|
||||
Timings.InterlaceField = FALSE;
|
||||
Timings.H_Max = Timings.H_Max_Master;
|
||||
Timings.V_Max = Timings.V_Max_Master;
|
||||
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);
|
||||
|
||||
ICPU.S9xOpcodes = S9xOpcodesE1;
|
||||
ICPU.S9xOpLengths = S9xOpLengthsM1X1;
|
||||
ICPU.CPUExecuting = TRUE;
|
||||
|
||||
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)
|
||||
{
|
||||
ResetLogger();
|
||||
S9xResetSaveTimer (FALSE);
|
||||
|
||||
ZeroMemory (Memory.FillRAM, 0x8000);
|
||||
memset (Memory.VRAM, 0x00, 0x10000);
|
||||
memset (Memory.RAM, 0x55, 0x20000);
|
||||
|
||||
if (Settings.BS)
|
||||
S9xResetBSX();
|
||||
if(Settings.SPC7110)
|
||||
S9xSpc7110Reset();
|
||||
S9xResetCPU ();
|
||||
S9xResetPPU ();
|
||||
S9xResetSRTC ();
|
||||
if (Settings.SDD1)
|
||||
S9xResetSDD1 ();
|
||||
|
||||
S9xResetDMA ();
|
||||
S9xResetAPU ();
|
||||
S9xResetDSP1 ();
|
||||
S9xSA1Init ();
|
||||
if (Settings.C4)
|
||||
S9xInitC4 ();
|
||||
S9xInitCheatData ();
|
||||
if (Settings.OBC1)
|
||||
ResetOBC1();
|
||||
if (Settings.SuperFX)
|
||||
S9xResetSuperFX ();
|
||||
#ifdef ZSNES_FX
|
||||
WinterGold = Settings.WinterGold;
|
||||
#endif
|
||||
// Settings.Paused = FALSE;
|
||||
}
|
||||
|
||||
void S9xSoftReset (void)
|
||||
{
|
||||
S9xResetSaveTimer (FALSE);
|
||||
|
||||
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 ();
|
||||
|
||||
S9xResetDMA ();
|
||||
S9xResetAPU ();
|
||||
S9xResetDSP1 ();
|
||||
if(Settings.OBC1)
|
||||
ResetOBC1();
|
||||
S9xSA1Init ();
|
||||
if (Settings.C4)
|
||||
S9xInitC4 ();
|
||||
S9xInitCheatData ();
|
||||
|
||||
// Settings.Paused = FALSE;
|
||||
}
|
||||
|
||||
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
|
||||
};
|
||||
@@ -0,0 +1,553 @@
|
||||
/**********************************************************************************
|
||||
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 _CPUADDR_H_
|
||||
#define _CPUADDR_H_
|
||||
|
||||
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 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 uint32 RelativeSlow (AccessMode a) { // branch $xx
|
||||
int8 offset = Immediate8Slow(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 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;
|
||||
|
||||
// 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;
|
||||
|
||||
// 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);
|
||||
|
||||
// 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);
|
||||
|
||||
// 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 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 Absolute (AccessMode a) { // a
|
||||
return ICPU.ShiftedDB|Immediate16(a);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,569 @@
|
||||
/**********************************************************************************
|
||||
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 "memmap.h"
|
||||
#include "cpuops.h"
|
||||
#include "ppu.h"
|
||||
#include "cpuexec.h"
|
||||
#include "debug.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 "fxemu.h"
|
||||
extern struct FxInit_s SuperFX;
|
||||
#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)
|
||||
{
|
||||
if (CPU.Flags & NMI_FLAG)
|
||||
{
|
||||
if (Timings.NMITriggerPos <= CPU.Cycles)
|
||||
{
|
||||
CPU.Flags &= ~NMI_FLAG;
|
||||
Timings.NMITriggerPos = 0xffff;
|
||||
if (CPU.WaitingForInterrupt)
|
||||
{
|
||||
CPU.WaitingForInterrupt = FALSE;
|
||||
Registers.PCw++;
|
||||
}
|
||||
|
||||
S9xOpcode_NMI();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUGGER
|
||||
if ((CPU.Flags & BREAK_FLAG) && !(CPU.Flags & SINGLE_STEP_FLAG))
|
||||
{
|
||||
for (int Break = 0; Break != 6; Break++)
|
||||
{
|
||||
if (S9xBreakpoint[Break].Enabled &&
|
||||
S9xBreakpoint[Break].Bank == Registers.PB &&
|
||||
S9xBreakpoint[Break].Address == Registers.PCw)
|
||||
{
|
||||
if (S9xBreakpoint[Break].Enabled == 2)
|
||||
S9xBreakpoint[Break].Enabled = TRUE;
|
||||
else
|
||||
CPU.Flags |= DEBUG_MODE_FLAG;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
CHECK_SOUND();
|
||||
|
||||
if (CPU.Flags & IRQ_FLAG)
|
||||
{
|
||||
if (CPU.IRQPending)
|
||||
// FIXME: In case of IRQ during WRAM refresh
|
||||
CPU.IRQPending = 0;
|
||||
else
|
||||
{
|
||||
if (CPU.WaitingForInterrupt)
|
||||
{
|
||||
CPU.WaitingForInterrupt = FALSE;
|
||||
Registers.PCw++;
|
||||
}
|
||||
|
||||
if (CPU.IRQActive && !Settings.DisableIRQ)
|
||||
{
|
||||
if (!CheckFlag(IRQ))
|
||||
// in IRQ handler $4211 is supposed to be read, so IRQ_FLAG should be cleared.
|
||||
S9xOpcode_IRQ();
|
||||
}
|
||||
else
|
||||
CPU.Flags &= ~IRQ_FLAG;
|
||||
}
|
||||
}
|
||||
|
||||
if (CPU.Flags & SCAN_KEYS_FLAG)
|
||||
break;
|
||||
|
||||
#ifdef DEBUGGER
|
||||
if (CPU.Flags & DEBUG_MODE_FLAG)
|
||||
break;
|
||||
|
||||
if (CPU.Flags & TRACE_FLAG)
|
||||
S9xTrace();
|
||||
|
||||
if (CPU.Flags & SINGLE_STEP_FLAG)
|
||||
{
|
||||
CPU.Flags &= ~SINGLE_STEP_FLAG;
|
||||
CPU.Flags |= DEBUG_MODE_FLAG;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef CPU_SHUTDOWN
|
||||
CPU.PBPCAtOpcodeStart = Registers.PBPC;
|
||||
#endif
|
||||
doOp:
|
||||
register uint8 Op;
|
||||
register struct SOpcodes *Opcodes;
|
||||
|
||||
CPU.PrevCycles = CPU.Cycles;
|
||||
|
||||
if (CPU.PCBase)
|
||||
{
|
||||
Op = CPU.PCBase[Registers.PCw];
|
||||
CPU.Cycles += CPU.MemSpeed;
|
||||
Opcodes = ICPU.S9xOpcodes;
|
||||
}
|
||||
else
|
||||
{
|
||||
Op = S9xGetByte(Registers.PBPC);
|
||||
OpenBus = Op;
|
||||
Opcodes = S9xOpcodesSlow;
|
||||
}
|
||||
|
||||
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))
|
||||
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();
|
||||
|
||||
if (CPU.Flags & SCAN_KEYS_FLAG)
|
||||
{
|
||||
#ifdef DEBUGGER
|
||||
if (!(CPU.Flags & FRAME_ADVANCE_FLAG))
|
||||
#endif
|
||||
S9xSyncSpeed();
|
||||
CPU.Flags &= ~SCAN_KEYS_FLAG;
|
||||
}
|
||||
}
|
||||
|
||||
void S9xSetIRQ (uint32 source)
|
||||
{
|
||||
CPU.IRQActive |= source;
|
||||
CPU.Flags |= IRQ_FLAG;
|
||||
|
||||
if (CPU.WaitingForInterrupt)
|
||||
{
|
||||
// Force IRQ to trigger immediately after WAI -
|
||||
// Final Fantasy Mystic Quest crashes without this.
|
||||
CPU.WaitingForInterrupt = FALSE;
|
||||
Registers.PCw++;
|
||||
}
|
||||
}
|
||||
|
||||
void S9xClearIRQ (uint32 source)
|
||||
{
|
||||
CLEAR_IRQ_SOURCE(source);
|
||||
}
|
||||
|
||||
void S9xDoHEventProcessing (void)
|
||||
{
|
||||
#ifdef DEBUGGER
|
||||
char mes[256];
|
||||
#endif
|
||||
|
||||
#ifdef CPU_SHUTDOWN
|
||||
CPU.WaitCounter++;
|
||||
#endif
|
||||
switch (CPU.WhichEvent)
|
||||
{
|
||||
case HC_HBLANK_START_EVENT:
|
||||
S9xCheckMissingHTimerPosition(Timings.HBlankStart);
|
||||
|
||||
break;
|
||||
|
||||
case HC_HDMA_START_EVENT:
|
||||
if (IPPU.HDMA && CPU.V_Counter <= PPU.ScreenHeight)
|
||||
{
|
||||
#ifdef DEBUGGER
|
||||
sprintf(mes, "*** HDMA HC:%04d, Channel:%02x", CPU.Cycles, IPPU.HDMA);
|
||||
S9xTraceMessage(mes);
|
||||
#endif
|
||||
IPPU.HDMA = S9xDoHDMA(IPPU.HDMA);
|
||||
}
|
||||
|
||||
S9xCheckMissingHTimerPosition(Timings.HDMAStart);
|
||||
|
||||
break;
|
||||
|
||||
case HC_HCOUNTER_MAX_EVENT:
|
||||
#ifndef ZSNES_FX
|
||||
if (Settings.SuperFX)
|
||||
{
|
||||
if (!SuperFX.oneLineDone)
|
||||
S9xSuperFXExec();
|
||||
SuperFX.oneLineDone = FALSE;
|
||||
}
|
||||
#else
|
||||
S9xSuperFXExec();
|
||||
#endif
|
||||
|
||||
#ifndef STORM
|
||||
if (Settings.SoundSync)
|
||||
S9xGenerateSound();
|
||||
#endif
|
||||
|
||||
CPU.Cycles -= Timings.H_Max;
|
||||
IAPU.NextAPUTimerPos -= (Timings.H_Max << SNES_APU_ACCURACY);
|
||||
APU.Cycles -= (Timings.H_Max << SNES_APU_ACCURACY);
|
||||
|
||||
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
|
||||
{
|
||||
CPU.V_Counter = 0;
|
||||
Timings.InterlaceField ^= 1;
|
||||
|
||||
// From byuu:
|
||||
// [NTSC]
|
||||
// interlace mode has 525 scanlines: 263 on the even frame, and 262 on the odd.
|
||||
// non-interlace mode has 524 scanlines: 262 scanlines on both even and odd frames.
|
||||
// [PAL] <PAL info is unverified on hardware>
|
||||
// interlace mode has 625 scanlines: 313 on the even frame, and 312 on the odd.
|
||||
// non-interlace mode has 624 scanlines: 312 scanlines on both even and odd frames.
|
||||
if (IPPU.Interlace && !Timings.InterlaceField)
|
||||
Timings.V_Max = Timings.V_Max_Master + 1; // 263 (NTSC), 313?(PAL)
|
||||
else
|
||||
Timings.V_Max = Timings.V_Max_Master; // 262 (NTSC), 312?(PAL)
|
||||
|
||||
Memory.FillRAM[0x213F] ^= 0x80;
|
||||
PPU.RangeTimeOver = 0;
|
||||
|
||||
// FIXME: reading $4210 will wait 2 cycles, then perform reading, then wait 4 more cycles.
|
||||
Memory.FillRAM[0x4210] = Model->_5A22;
|
||||
CPU.Flags &= ~NMI_FLAG;
|
||||
Timings.NMITriggerPos = 0xffff;
|
||||
|
||||
ICPU.Frame++;
|
||||
PPU.HVBeamCounterLatched = 0;
|
||||
CPU.Flags |= SCAN_KEYS_FLAG;
|
||||
}
|
||||
|
||||
// From byuu:
|
||||
// In non-interlace mode, there are 341 dots per scanline, and 262 scanlines per frame.
|
||||
// On odd frames, scanline 240 is one dot short.
|
||||
// In interlace mode, there are always 341 dots per scanline. Even frames have 263 scanlines,
|
||||
// and odd frames have 262 scanlines.
|
||||
// Interlace mode scanline 240 on odd frames is not missing a dot.
|
||||
if (CPU.V_Counter == 240 && !IPPU.Interlace && Timings.InterlaceField) // V=240
|
||||
Timings.H_Max = Timings.H_Max_Master - ONE_DOT_CYCLE; // HC=1360
|
||||
else
|
||||
Timings.H_Max = Timings.H_Max_Master; // HC=1364
|
||||
|
||||
if (Model->_5A22 == 2)
|
||||
{
|
||||
if (CPU.V_Counter != 240 || IPPU.Interlace || !Timings.InterlaceField) // V=240
|
||||
{
|
||||
if (Timings.WRAMRefreshPos == SNES_WRAM_REFRESH_HC_v2 - ONE_DOT_CYCLE) // HC=534
|
||||
Timings.WRAMRefreshPos = SNES_WRAM_REFRESH_HC_v2; // HC=538
|
||||
else
|
||||
Timings.WRAMRefreshPos = SNES_WRAM_REFRESH_HC_v2 - ONE_DOT_CYCLE; // HC=534
|
||||
}
|
||||
}
|
||||
else
|
||||
Timings.WRAMRefreshPos = SNES_WRAM_REFRESH_HC_v1;
|
||||
|
||||
S9xCheckMissingHTimerPosition(0);
|
||||
|
||||
if (CPU.V_Counter == PPU.ScreenHeight + FIRST_VISIBLE_LINE) // VBlank starts from V=225(240).
|
||||
{
|
||||
S9xEndScreenRefresh();
|
||||
IPPU.HDMA = 0;
|
||||
// Bits 7 and 6 of $4212 are computed when read in S9xGetPPU.
|
||||
#ifdef DEBUGGER
|
||||
missing.dma_this_frame = 0;
|
||||
#endif
|
||||
IPPU.MaxBrightness = PPU.Brightness;
|
||||
PPU.ForcedBlanking = (Memory.FillRAM [0x2100] >> 7) & 1;
|
||||
|
||||
if (!PPU.ForcedBlanking)
|
||||
{
|
||||
PPU.OAMAddr = PPU.SavedOAMAddr;
|
||||
|
||||
uint8 tmp = 0;
|
||||
|
||||
if (PPU.OAMPriorityRotation)
|
||||
tmp = (PPU.OAMAddr & 0xFE) >> 1;
|
||||
if ((PPU.OAMFlip & 1) || PPU.FirstSprite!=tmp)
|
||||
{
|
||||
PPU.FirstSprite = tmp;
|
||||
IPPU.OBJChanged = TRUE;
|
||||
}
|
||||
|
||||
PPU.OAMFlip = 0;
|
||||
}
|
||||
|
||||
// FIXME: writing to $4210 will wait 6 cycles.
|
||||
Memory.FillRAM[0x4210] = 0x80 | Model->_5A22;
|
||||
if (Memory.FillRAM[0x4200] & 0x80)
|
||||
{
|
||||
// FIXME: triggered at HC=6, checked just before the final CPU cycle,
|
||||
// then, when to call S9xOpcode_NMI()?
|
||||
CPU.Flags |= NMI_FLAG;
|
||||
Timings.NMITriggerPos = 6 + 6;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (CPU.V_Counter == PPU.ScreenHeight + 3) // FIXME: not true
|
||||
{
|
||||
if (Memory.FillRAM[0x4200] & 1)
|
||||
S9xDoAutoJoypad();
|
||||
}
|
||||
|
||||
if (CPU.V_Counter == FIRST_VISIBLE_LINE) // V=1
|
||||
S9xStartScreenRefresh();
|
||||
|
||||
CPU.NextEvent = -1;
|
||||
|
||||
break;
|
||||
|
||||
case HC_HDMA_INIT_EVENT:
|
||||
if (CPU.V_Counter == 0)
|
||||
S9xStartHDMA();
|
||||
|
||||
S9xCheckMissingHTimerPosition(Timings.HDMAInit);
|
||||
|
||||
break;
|
||||
|
||||
case HC_RENDER_EVENT:
|
||||
if (CPU.V_Counter >= FIRST_VISIBLE_LINE && CPU.V_Counter <= PPU.ScreenHeight)
|
||||
RenderLine((uint8)(CPU.V_Counter - FIRST_VISIBLE_LINE));
|
||||
|
||||
S9xCheckMissingHTimerPosition(Timings.RenderPos);
|
||||
|
||||
break;
|
||||
|
||||
case HC_WRAM_REFRESH_EVENT:
|
||||
#ifdef DEBUGGER
|
||||
sprintf(mes, "*** WRAM Refresh HC:%04d", CPU.Cycles);
|
||||
S9xTraceMessage(mes);
|
||||
#endif
|
||||
S9xCheckMissingHTimerHalt(Timings.WRAMRefreshPos, SNES_WRAM_REFRESH_CYCLES);
|
||||
CPU.Cycles += SNES_WRAM_REFRESH_CYCLES;
|
||||
S9xAPUExecute();
|
||||
|
||||
S9xCheckMissingHTimerPosition(Timings.WRAMRefreshPos);
|
||||
|
||||
break;
|
||||
|
||||
case HC_IRQ_1_3_EVENT:
|
||||
case HC_IRQ_3_5_EVENT:
|
||||
case HC_IRQ_5_7_EVENT:
|
||||
case HC_IRQ_7_9_EVENT:
|
||||
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);
|
||||
else
|
||||
if (PPU.VTimerEnabled && (CPU.V_Counter == PPU.VTimerPosition))
|
||||
S9xSetIRQ(PPU_V_BEAM_IRQ_SOURCE);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
S9xReschedule();
|
||||
}
|
||||
@@ -0,0 +1,361 @@
|
||||
/**********************************************************************************
|
||||
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 _CPUEXEC_H_
|
||||
#define _CPUEXEC_H_
|
||||
|
||||
#include "snes9x.h"
|
||||
|
||||
struct SOpcodes {
|
||||
#ifdef __WIN32__
|
||||
void (__cdecl *S9xOpcode)( void);
|
||||
#else
|
||||
void (*S9xOpcode)( void);
|
||||
#endif
|
||||
};
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
START_EXTERN_C
|
||||
extern struct SICPU ICPU;
|
||||
END_EXTERN_C
|
||||
|
||||
#include "ppu.h"
|
||||
#include "memmap.h"
|
||||
#include "65c816.h"
|
||||
|
||||
START_EXTERN_C
|
||||
void S9xMainLoop (void);
|
||||
void S9xReset (void);
|
||||
void S9xSoftReset (void);
|
||||
void S9xDoHEventProcessing ();
|
||||
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()
|
||||
{
|
||||
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()
|
||||
{
|
||||
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)
|
||||
{
|
||||
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 ())
|
||||
{
|
||||
ICPU.S9xOpcodes = S9xOpcodesM1X1;
|
||||
ICPU.S9xOpLengths = S9xOpLengthsM1X1;
|
||||
}
|
||||
else
|
||||
{
|
||||
ICPU.S9xOpcodes = S9xOpcodesM1X0;
|
||||
ICPU.S9xOpLengths = S9xOpLengthsM1X0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CheckIndex ())
|
||||
{
|
||||
ICPU.S9xOpcodes = S9xOpcodesM0X1;
|
||||
ICPU.S9xOpLengths = S9xOpLengthsM0X1;
|
||||
}
|
||||
else
|
||||
{
|
||||
ICPU.S9xOpcodes = S9xOpcodesM0X0;
|
||||
ICPU.S9xOpLengths = S9xOpLengthsM0X0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
STATIC inline void S9xReschedule (void)
|
||||
{
|
||||
uint8 next = 0;
|
||||
int32 hpos = 0;
|
||||
|
||||
switch (CPU.WhichEvent)
|
||||
{
|
||||
case HC_HBLANK_START_EVENT:
|
||||
case HC_IRQ_1_3_EVENT:
|
||||
next = HC_HDMA_START_EVENT;
|
||||
hpos = Timings.HDMAStart;
|
||||
break;
|
||||
|
||||
case HC_HDMA_START_EVENT:
|
||||
case HC_IRQ_3_5_EVENT:
|
||||
next = HC_HCOUNTER_MAX_EVENT;
|
||||
hpos = Timings.H_Max;
|
||||
break;
|
||||
|
||||
case HC_HCOUNTER_MAX_EVENT:
|
||||
case HC_IRQ_5_7_EVENT:
|
||||
next = HC_HDMA_INIT_EVENT;
|
||||
hpos = Timings.HDMAInit;
|
||||
break;
|
||||
|
||||
case HC_HDMA_INIT_EVENT:
|
||||
case HC_IRQ_7_9_EVENT:
|
||||
next = HC_RENDER_EVENT;
|
||||
hpos = Timings.RenderPos;
|
||||
break;
|
||||
|
||||
case HC_RENDER_EVENT:
|
||||
case HC_IRQ_9_A_EVENT:
|
||||
next = HC_WRAM_REFRESH_EVENT;
|
||||
hpos = Timings.WRAMRefreshPos;
|
||||
break;
|
||||
|
||||
case HC_WRAM_REFRESH_EVENT:
|
||||
case HC_IRQ_A_1_EVENT:
|
||||
next = HC_HBLANK_START_EVENT;
|
||||
hpos = Timings.HBlankStart;
|
||||
break;
|
||||
}
|
||||
|
||||
if (((int32) PPU.HTimerPosition > CPU.NextEvent) && ((int32) PPU.HTimerPosition < hpos))
|
||||
{
|
||||
hpos = (int32) PPU.HTimerPosition;
|
||||
|
||||
switch (next)
|
||||
{
|
||||
case HC_HDMA_START_EVENT:
|
||||
next = HC_IRQ_1_3_EVENT;
|
||||
break;
|
||||
|
||||
case HC_HCOUNTER_MAX_EVENT:
|
||||
next = HC_IRQ_3_5_EVENT;
|
||||
break;
|
||||
|
||||
case HC_HDMA_INIT_EVENT:
|
||||
next = HC_IRQ_5_7_EVENT;
|
||||
break;
|
||||
|
||||
case HC_RENDER_EVENT:
|
||||
next = HC_IRQ_7_9_EVENT;
|
||||
break;
|
||||
|
||||
case HC_WRAM_REFRESH_EVENT:
|
||||
next = HC_IRQ_9_A_EVENT;
|
||||
break;
|
||||
|
||||
case HC_HBLANK_START_EVENT:
|
||||
next = HC_IRQ_A_1_EVENT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
CPU.NextEvent = hpos;
|
||||
CPU.WhichEvent = next;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,800 @@
|
||||
/**********************************************************************************
|
||||
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 _CPUMACRO_H_
|
||||
#define _CPUMACRO_H_
|
||||
|
||||
#define rOP8(OP, ADDR, WRAP, FUNC) \
|
||||
static void Op##OP (void) { \
|
||||
uint8 val = OpenBus = S9xGetByte(ADDR(READ)); \
|
||||
FUNC(val); \
|
||||
}
|
||||
|
||||
#define rOP16(OP, ADDR, WRAP, FUNC) \
|
||||
static void Op##OP (void) { \
|
||||
uint16 val = S9xGetWord(ADDR(READ), WRAP); \
|
||||
OpenBus = (uint8)(val>>8); \
|
||||
FUNC(val); \
|
||||
}
|
||||
|
||||
#define rOPC(OP, COND, ADDR, WRAP, FUNC) \
|
||||
static void Op##OP (void) { \
|
||||
if(Check##COND()){ \
|
||||
uint8 val = OpenBus = S9xGetByte(ADDR(READ)); \
|
||||
FUNC(val); \
|
||||
} else { \
|
||||
uint16 val = S9xGetWord(ADDR(READ), WRAP); \
|
||||
OpenBus = (uint8)(val>>8); \
|
||||
FUNC(val); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define rOPM(OP, ADDR, WRAP, FUNC) \
|
||||
rOPC(OP, Memory, ADDR, WRAP, FUNC)
|
||||
|
||||
#define rOPX(OP, ADDR, WRAP, FUNC) \
|
||||
rOPC(OP, Index, ADDR, WRAP, FUNC)
|
||||
|
||||
|
||||
#define wOP8(OP, ADDR, WRAP, FUNC) \
|
||||
static void Op##OP (void) { \
|
||||
FUNC##8 (ADDR(WRITE)); \
|
||||
}
|
||||
|
||||
#define wOP16(OP, ADDR, WRAP, FUNC) \
|
||||
static void Op##OP (void) { \
|
||||
FUNC##16 (ADDR(WRITE), WRAP); \
|
||||
}
|
||||
|
||||
#define wOPC(OP, COND, ADDR, WRAP, FUNC) \
|
||||
static void Op##OP (void) { \
|
||||
if(Check##COND()){ \
|
||||
FUNC##8 (ADDR(WRITE)); \
|
||||
} else { \
|
||||
FUNC##16 (ADDR(WRITE), WRAP); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define wOPM(OP, ADDR, WRAP, FUNC) \
|
||||
wOPC(OP, Memory, ADDR, WRAP, FUNC)
|
||||
|
||||
#define wOPX(OP, ADDR, WRAP, FUNC) \
|
||||
wOPC(OP, Index, ADDR, WRAP, FUNC)
|
||||
|
||||
|
||||
#define mOP8(OP, ADDR, WRAP, FUNC) \
|
||||
static void Op##OP (void) { \
|
||||
FUNC##8 (ADDR(MODIFY)); \
|
||||
}
|
||||
|
||||
#define mOP16(OP, ADDR, WRAP, FUNC) \
|
||||
static void Op##OP (void) { \
|
||||
FUNC##16 (ADDR(MODIFY), WRAP); \
|
||||
}
|
||||
|
||||
#define mOPC(OP, COND, ADDR, WRAP, FUNC) \
|
||||
static void Op##OP (void) { \
|
||||
if(Check##COND()){ \
|
||||
FUNC##8 (ADDR(MODIFY)); \
|
||||
} else { \
|
||||
FUNC##16 (ADDR(MODIFY), WRAP); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define mOPM(OP, ADDR, WRAP, FUNC) \
|
||||
mOPC(OP, Memory, ADDR, WRAP, FUNC)
|
||||
|
||||
|
||||
#define bOP(OP, REL, COND, CHK, E) \
|
||||
static void Op##OP (void) { \
|
||||
pair newPC; \
|
||||
newPC.W = REL(JUMP); \
|
||||
BranchCheck##CHK (); \
|
||||
if(COND){ \
|
||||
AddCycles(ONE_CYCLE); \
|
||||
if(E && Registers.PCh!=newPC.B.h){AddCycles(ONE_CYCLE);} \
|
||||
if((Registers.PCw&~MEMMAP_MASK)!=(newPC.W&~MEMMAP_MASK)){ \
|
||||
S9xSetPCBase(ICPU.ShiftedPB + newPC.W); \
|
||||
} else { \
|
||||
Registers.PCw = newPC.W; \
|
||||
} \
|
||||
CPUShutdown (); \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
STATIC inline void SetZN (uint16 Work) {
|
||||
ICPU._Zero = Work != 0;
|
||||
ICPU._Negative = (uint8) (Work >> 8);
|
||||
}
|
||||
|
||||
STATIC inline void SetZN (uint8 Work) {
|
||||
ICPU._Zero = Work;
|
||||
ICPU._Negative = Work;
|
||||
}
|
||||
|
||||
STATIC inline void ADC (uint8 Work8) {
|
||||
if(CheckDecimal()) {
|
||||
uint8 A1 = Registers.A.W & 0x0F;
|
||||
uint16 A2 = Registers.A.W & 0xF0;
|
||||
uint8 W1 = Work8 & 0x0F;
|
||||
uint8 W2 = Work8 & 0xF0;
|
||||
|
||||
A1 += W1+CheckCarry();
|
||||
if(A1>0x09){
|
||||
A1-=0x0A;
|
||||
A1&=0x0F;
|
||||
A2+=0x10;
|
||||
}
|
||||
|
||||
A2 += W2;
|
||||
if(A2>0x90){
|
||||
A2-=0xA0;
|
||||
A2&=0xF0;
|
||||
SetCarry();
|
||||
} else {
|
||||
ClearCarry();
|
||||
}
|
||||
|
||||
uint8 Ans8 = A2|A1;
|
||||
if (~(Registers.AL ^ Work8) &
|
||||
(Work8 ^ Ans8) & 0x80)
|
||||
SetOverflow();
|
||||
else
|
||||
ClearOverflow();
|
||||
Registers.AL = Ans8;
|
||||
SetZN (Registers.AL);
|
||||
} else {
|
||||
uint16 Ans16 = Registers.AL + Work8 + CheckCarry();
|
||||
|
||||
ICPU._Carry = Ans16 >= 0x100;
|
||||
|
||||
if (~(Registers.AL ^ Work8) &
|
||||
(Work8 ^ (uint8) Ans16) & 0x80)
|
||||
SetOverflow();
|
||||
else
|
||||
ClearOverflow();
|
||||
Registers.AL = (uint8) Ans16;
|
||||
SetZN (Registers.AL);
|
||||
}
|
||||
}
|
||||
|
||||
STATIC inline void ADC (uint16 Work16) {
|
||||
if (CheckDecimal ()) {
|
||||
uint16 A1 = Registers.A.W & 0x000F;
|
||||
uint16 A2 = Registers.A.W & 0x00F0;
|
||||
uint16 A3 = Registers.A.W & 0x0F00;
|
||||
uint32 A4 = Registers.A.W & 0xF000;
|
||||
uint16 W1 = Work16 & 0x000F;
|
||||
uint16 W2 = Work16 & 0x00F0;
|
||||
uint16 W3 = Work16 & 0x0F00;
|
||||
uint16 W4 = Work16 & 0xF000;
|
||||
|
||||
A1 += W1 + CheckCarry ();
|
||||
if(A1>0x0009) {
|
||||
A1 -= 0x000A;
|
||||
A1 &= 0x000F;
|
||||
A2 += 0x0010;
|
||||
}
|
||||
|
||||
A2 += W2;
|
||||
if(A2>0x0090){
|
||||
A2 -= 0x00A0;
|
||||
A2 &= 0x00F0;
|
||||
A3 += 0x0100;
|
||||
}
|
||||
|
||||
A3 += W3;
|
||||
if(A3>0x0900){
|
||||
A3 -= 0x0A00;
|
||||
A3 &= 0x0F00;
|
||||
A4 += 0x1000;
|
||||
}
|
||||
|
||||
A4 += W4;
|
||||
if(A4>0x9000){
|
||||
A4 -= 0xA000;
|
||||
A4 &= 0xF000;
|
||||
SetCarry ();
|
||||
} else {
|
||||
ClearCarry ();
|
||||
}
|
||||
|
||||
uint16 Ans16 = A4|A3|A2|A1;
|
||||
if (~(Registers.A.W ^ Work16) &
|
||||
(Work16 ^ Ans16) & 0x8000)
|
||||
SetOverflow();
|
||||
else
|
||||
ClearOverflow();
|
||||
Registers.A.W = Ans16;
|
||||
SetZN (Registers.A.W);
|
||||
} else {
|
||||
uint32 Ans32 = Registers.A.W + Work16 + CheckCarry();
|
||||
|
||||
ICPU._Carry = Ans32 >= 0x10000;
|
||||
|
||||
if (~(Registers.A.W ^ Work16) &
|
||||
(Work16 ^ (uint16) Ans32) & 0x8000)
|
||||
SetOverflow();
|
||||
else
|
||||
ClearOverflow();
|
||||
Registers.A.W = (uint16) Ans32;
|
||||
SetZN (Registers.A.W);
|
||||
}
|
||||
}
|
||||
|
||||
STATIC inline void AND (uint16 Work16) {
|
||||
Registers.A.W &= Work16;
|
||||
SetZN (Registers.A.W);
|
||||
}
|
||||
|
||||
STATIC inline void AND (uint8 Work8) {
|
||||
Registers.AL &= Work8;
|
||||
SetZN (Registers.AL);
|
||||
}
|
||||
|
||||
STATIC inline void ASL16 (uint32 OpAddress, s9xwrap_t w) {
|
||||
uint16 Work16 = S9xGetWord (OpAddress, w);
|
||||
ICPU._Carry = (Work16 & 0x8000) != 0;
|
||||
Work16 <<= 1;
|
||||
AddCycles(ONE_CYCLE);
|
||||
S9xSetWord (Work16, OpAddress, w, WRITE_10);
|
||||
OpenBus = (Work16&0xff);
|
||||
SetZN (Work16);
|
||||
}
|
||||
|
||||
STATIC inline void ASL8 (uint32 OpAddress) {
|
||||
uint8 Work8 = S9xGetByte (OpAddress);
|
||||
ICPU._Carry = (Work8 & 0x80) != 0;
|
||||
Work8 <<= 1;
|
||||
AddCycles(ONE_CYCLE);
|
||||
S9xSetByte (Work8, OpAddress);
|
||||
OpenBus = Work8;
|
||||
SetZN (Work8);
|
||||
}
|
||||
|
||||
STATIC inline void BIT (uint16 Work16) {
|
||||
ICPU._Overflow = (Work16 & 0x4000) != 0;
|
||||
ICPU._Negative = (uint8) (Work16 >> 8);
|
||||
ICPU._Zero = (Work16 & Registers.A.W) != 0;
|
||||
}
|
||||
|
||||
STATIC inline void BIT (uint8 Work8) {
|
||||
ICPU._Overflow = (Work8 & 0x40) != 0;
|
||||
ICPU._Negative = Work8;
|
||||
ICPU._Zero = Work8 & Registers.AL;
|
||||
}
|
||||
|
||||
STATIC inline void CMP (uint16 val) {
|
||||
int32 Int32 = (int32) Registers.A.W - (int32) val;
|
||||
ICPU._Carry = Int32 >= 0;
|
||||
SetZN ((uint16) Int32);
|
||||
}
|
||||
|
||||
STATIC inline void CMP (uint8 val) {
|
||||
int16 Int16 = (int16) Registers.AL - (int16) val;
|
||||
ICPU._Carry = Int16 >= 0;
|
||||
SetZN ((uint8) Int16);
|
||||
}
|
||||
|
||||
STATIC inline void CPX (uint16 val) {
|
||||
int32 Int32 = (int32) Registers.X.W - (int32) val;
|
||||
ICPU._Carry = Int32 >= 0;
|
||||
SetZN ((uint16) Int32);
|
||||
}
|
||||
|
||||
STATIC inline void CPX (uint8 val) {
|
||||
int16 Int16 = (int16) Registers.XL - (int16) val;
|
||||
ICPU._Carry = Int16 >= 0;
|
||||
SetZN ((uint8) Int16);
|
||||
}
|
||||
|
||||
STATIC inline void CPY (uint16 val) {
|
||||
int32 Int32 = (int32) Registers.Y.W - (int32) val;
|
||||
ICPU._Carry = Int32 >= 0;
|
||||
SetZN ((uint16) Int32);
|
||||
}
|
||||
|
||||
STATIC inline void CPY (uint8 val) {
|
||||
int16 Int16 = (int16) Registers.YL - (int16) val;
|
||||
ICPU._Carry = Int16 >= 0;
|
||||
SetZN ((uint8) Int16);
|
||||
}
|
||||
|
||||
STATIC inline void DEC16 (uint32 OpAddress, s9xwrap_t w) {
|
||||
#ifdef CPU_SHUTDOWN
|
||||
CPU.WaitAddress = 0xffffffff;
|
||||
#endif
|
||||
|
||||
uint16 Work16 = S9xGetWord(OpAddress, w) - 1;
|
||||
AddCycles(ONE_CYCLE);
|
||||
S9xSetWord (Work16, OpAddress, w, WRITE_10);
|
||||
OpenBus = Work16&0xff;
|
||||
SetZN (Work16);
|
||||
}
|
||||
|
||||
STATIC inline void DEC8 (uint32 OpAddress) {
|
||||
#ifdef CPU_SHUTDOWN
|
||||
CPU.WaitAddress = 0xffffffff;
|
||||
#endif
|
||||
|
||||
uint8 Work8 = S9xGetByte (OpAddress) - 1;
|
||||
AddCycles(ONE_CYCLE);
|
||||
S9xSetByte (Work8, OpAddress);
|
||||
OpenBus = Work8;
|
||||
SetZN (Work8);
|
||||
}
|
||||
|
||||
STATIC inline void EOR (uint16 val) {
|
||||
Registers.A.W ^= val;
|
||||
SetZN (Registers.A.W);
|
||||
}
|
||||
|
||||
STATIC inline void EOR (uint8 val) {
|
||||
Registers.AL ^= val;
|
||||
SetZN (Registers.AL);
|
||||
}
|
||||
|
||||
STATIC inline void INC16 (uint32 OpAddress, s9xwrap_t w) {
|
||||
#ifdef CPU_SHUTDOWN
|
||||
CPU.WaitAddress = 0xffffffff;
|
||||
#endif
|
||||
|
||||
uint16 Work16 = S9xGetWord(OpAddress, w) + 1;
|
||||
AddCycles(ONE_CYCLE);
|
||||
S9xSetWord (Work16, OpAddress, w, WRITE_10);
|
||||
OpenBus = Work16&0xff;
|
||||
SetZN (Work16);
|
||||
}
|
||||
|
||||
STATIC inline void INC8 (uint32 OpAddress) {
|
||||
#ifdef CPU_SHUTDOWN
|
||||
CPU.WaitAddress = 0xffffffff;
|
||||
#endif
|
||||
|
||||
uint8 Work8 = S9xGetByte (OpAddress) + 1;
|
||||
AddCycles(ONE_CYCLE);
|
||||
S9xSetByte (Work8, OpAddress);
|
||||
OpenBus = Work8;
|
||||
SetZN (Work8);
|
||||
}
|
||||
|
||||
STATIC inline void LDA (uint16 val) {
|
||||
Registers.A.W = val;
|
||||
SetZN (Registers.A.W);
|
||||
}
|
||||
|
||||
STATIC inline void LDA (uint8 val) {
|
||||
Registers.AL = val;
|
||||
SetZN (Registers.AL);
|
||||
}
|
||||
|
||||
STATIC inline void LDX (uint16 val) {
|
||||
Registers.X.W = val;
|
||||
SetZN (Registers.X.W);
|
||||
}
|
||||
|
||||
STATIC inline void LDX (uint8 val) {
|
||||
Registers.XL = val;
|
||||
SetZN (Registers.XL);
|
||||
}
|
||||
|
||||
STATIC inline void LDY (uint16 val) {
|
||||
Registers.Y.W = val;
|
||||
SetZN (Registers.Y.W);
|
||||
}
|
||||
|
||||
STATIC inline void LDY (uint8 val) {
|
||||
Registers.YL = val;
|
||||
SetZN (Registers.YL);
|
||||
}
|
||||
|
||||
STATIC inline void LSR16 (uint32 OpAddress, s9xwrap_t w) {
|
||||
uint16 Work16 = S9xGetWord (OpAddress, w);
|
||||
ICPU._Carry = Work16 & 1;
|
||||
Work16 >>= 1;
|
||||
AddCycles(ONE_CYCLE);
|
||||
S9xSetWord (Work16, OpAddress, w, WRITE_10);
|
||||
OpenBus = (Work16&0xff);
|
||||
SetZN (Work16);
|
||||
}
|
||||
|
||||
STATIC inline void LSR8 (uint32 OpAddress) {
|
||||
uint8 Work8 = S9xGetByte (OpAddress);
|
||||
ICPU._Carry = Work8 & 1;
|
||||
Work8 >>= 1;
|
||||
AddCycles(ONE_CYCLE);
|
||||
S9xSetByte (Work8, OpAddress);
|
||||
OpenBus = Work8;
|
||||
SetZN (Work8);
|
||||
}
|
||||
|
||||
STATIC inline void ORA (uint16 val) {
|
||||
Registers.A.W |= val;
|
||||
SetZN (Registers.A.W);
|
||||
}
|
||||
|
||||
STATIC inline void ORA (uint8 val) {
|
||||
Registers.AL |= val;
|
||||
SetZN (Registers.AL);
|
||||
}
|
||||
|
||||
STATIC inline void ROL16 (uint32 OpAddress, s9xwrap_t w) {
|
||||
uint32 Work32 = (((uint32)S9xGetWord(OpAddress, w))<<1) | CheckCarry();
|
||||
ICPU._Carry = Work32>=0x10000;
|
||||
AddCycles(ONE_CYCLE);
|
||||
S9xSetWord ((uint16)Work32, OpAddress, w, WRITE_10);
|
||||
OpenBus = (Work32&0xff);
|
||||
SetZN ((uint16)Work32);
|
||||
}
|
||||
|
||||
STATIC inline void ROL8 (uint32 OpAddress) {
|
||||
uint16 Work16 = (((uint16)S9xGetByte(OpAddress))<<1) | CheckCarry();
|
||||
ICPU._Carry = Work16>=0x100;
|
||||
AddCycles(ONE_CYCLE);
|
||||
S9xSetByte ((uint8)Work16, OpAddress);
|
||||
OpenBus = Work16&0xff;
|
||||
SetZN ((uint8)Work16);
|
||||
}
|
||||
|
||||
STATIC inline void ROR16 (uint32 OpAddress, s9xwrap_t w) {
|
||||
uint32 Work32 = ((uint32)S9xGetWord(OpAddress, w)) | (((uint32)CheckCarry())<<16);
|
||||
ICPU._Carry = Work32&1;
|
||||
Work32 >>= 1;
|
||||
AddCycles(ONE_CYCLE);
|
||||
S9xSetWord ((uint16)Work32, OpAddress, w, WRITE_10);
|
||||
OpenBus = (Work32&0xff);
|
||||
SetZN ((uint16)Work32);
|
||||
}
|
||||
|
||||
STATIC inline void ROR8 (uint32 OpAddress) {
|
||||
uint16 Work16 = ((uint16)S9xGetByte(OpAddress)) | (((uint16)CheckCarry())<<8);
|
||||
ICPU._Carry = Work16&1;
|
||||
Work16 >>= 1;
|
||||
AddCycles(ONE_CYCLE);
|
||||
S9xSetByte ((uint8)Work16, OpAddress);
|
||||
OpenBus = Work16&0xff;
|
||||
SetZN ((uint8)Work16);
|
||||
}
|
||||
|
||||
STATIC inline void SBC (uint16 Work16) {
|
||||
if (CheckDecimal ()) {
|
||||
uint16 A1 = Registers.A.W & 0x000F;
|
||||
uint16 A2 = Registers.A.W & 0x00F0;
|
||||
uint16 A3 = Registers.A.W & 0x0F00;
|
||||
uint32 A4 = Registers.A.W & 0xF000;
|
||||
uint16 W1 = Work16 & 0x000F;
|
||||
uint16 W2 = Work16 & 0x00F0;
|
||||
uint16 W3 = Work16 & 0x0F00;
|
||||
uint16 W4 = Work16 & 0xF000;
|
||||
|
||||
A1 -= W1 + !CheckCarry ();
|
||||
A2 -= W2;
|
||||
A3 -= W3;
|
||||
A4 -= W4;
|
||||
if (A1 > 0x000F) {
|
||||
A1 += 0x000A;
|
||||
A1 &= 0x000F;
|
||||
A2 -= 0x0010;
|
||||
}
|
||||
if (A2 > 0x00F0) {
|
||||
A2 += 0x00A0;
|
||||
A2 &= 0x00F0;
|
||||
A3 -= 0x0100;
|
||||
}
|
||||
if (A3 > 0x0F00) {
|
||||
A3 += 0x0A00;
|
||||
A3 &= 0x0F00;
|
||||
A4 -= 0x1000;
|
||||
}
|
||||
if (A4 > 0xF000) {
|
||||
A4 += 0xA000;
|
||||
A4 &= 0xF000;
|
||||
ClearCarry ();
|
||||
} else {
|
||||
SetCarry ();
|
||||
}
|
||||
|
||||
uint16 Ans16 = A4|A3|A2|A1;
|
||||
if ((Registers.A.W ^ Work16) &
|
||||
(Registers.A.W ^ Ans16) & 0x8000)
|
||||
SetOverflow();
|
||||
else
|
||||
ClearOverflow();
|
||||
Registers.A.W = Ans16;
|
||||
SetZN (Registers.A.W);
|
||||
} else {
|
||||
int32 Int32 = (int32) Registers.A.W - (int32) Work16 + (int32) CheckCarry() - 1;
|
||||
|
||||
ICPU._Carry = Int32 >= 0;
|
||||
|
||||
if ((Registers.A.W ^ Work16) &
|
||||
(Registers.A.W ^ (uint16) Int32) & 0x8000)
|
||||
SetOverflow();
|
||||
else
|
||||
ClearOverflow ();
|
||||
Registers.A.W = (uint16) Int32;
|
||||
SetZN (Registers.A.W);
|
||||
}
|
||||
}
|
||||
|
||||
STATIC inline void SBC (uint8 Work8) {
|
||||
if (CheckDecimal ()) {
|
||||
uint8 A1 = Registers.A.W & 0x0F;
|
||||
uint16 A2 = Registers.A.W & 0xF0;
|
||||
uint8 W1 = Work8 & 0x0F;
|
||||
uint8 W2 = Work8 & 0xF0;
|
||||
|
||||
A1 -= W1 + !CheckCarry ();
|
||||
A2 -= W2;
|
||||
if (A1 > 0x0F) {
|
||||
A1 += 0x0A;
|
||||
A1 &= 0x0F;
|
||||
A2 -= 0x10;
|
||||
}
|
||||
if (A2 > 0xF0) {
|
||||
A2 += 0xA0;
|
||||
A2 &= 0xF0;
|
||||
ClearCarry ();
|
||||
} else {
|
||||
SetCarry ();
|
||||
}
|
||||
|
||||
uint8 Ans8 = A2|A1;
|
||||
if ((Registers.AL ^ Work8) &
|
||||
(Registers.AL ^ Ans8) & 0x80)
|
||||
SetOverflow ();
|
||||
else
|
||||
ClearOverflow ();
|
||||
Registers.AL = Ans8;
|
||||
SetZN (Registers.AL);
|
||||
} else {
|
||||
int16 Int16 = (int16) Registers.AL - (int16) Work8 + (int16) CheckCarry() - 1;
|
||||
|
||||
ICPU._Carry = Int16 >= 0;
|
||||
if ((Registers.AL ^ Work8) &
|
||||
(Registers.AL ^ (uint8) Int16) & 0x80)
|
||||
SetOverflow ();
|
||||
else
|
||||
ClearOverflow ();
|
||||
Registers.AL = (uint8) Int16;
|
||||
SetZN (Registers.AL);
|
||||
}
|
||||
}
|
||||
|
||||
STATIC inline void STA16 (uint32 OpAddress, enum s9xwrap_t w) {
|
||||
S9xSetWord (Registers.A.W, OpAddress, w);
|
||||
OpenBus = Registers.AH;
|
||||
}
|
||||
|
||||
STATIC inline void STA8 (uint32 OpAddress) {
|
||||
S9xSetByte (Registers.AL, OpAddress);
|
||||
OpenBus = Registers.AL;
|
||||
}
|
||||
|
||||
STATIC inline void STX16 (uint32 OpAddress, enum s9xwrap_t w) {
|
||||
S9xSetWord (Registers.X.W, OpAddress, w);
|
||||
OpenBus = Registers.XH;
|
||||
}
|
||||
|
||||
STATIC inline void STX8 (uint32 OpAddress) {
|
||||
S9xSetByte (Registers.XL, OpAddress);
|
||||
OpenBus = Registers.XL;
|
||||
}
|
||||
|
||||
STATIC inline void STY16 (uint32 OpAddress, enum s9xwrap_t w) {
|
||||
S9xSetWord (Registers.Y.W, OpAddress, w);
|
||||
OpenBus = Registers.YH;
|
||||
}
|
||||
|
||||
STATIC inline void STY8 (uint32 OpAddress) {
|
||||
S9xSetByte (Registers.YL, OpAddress);
|
||||
OpenBus = Registers.YL;
|
||||
}
|
||||
|
||||
STATIC inline void STZ16 (uint32 OpAddress, enum s9xwrap_t w) {
|
||||
S9xSetWord (0, OpAddress, w);
|
||||
OpenBus = 0;
|
||||
}
|
||||
|
||||
STATIC inline void STZ8 (uint32 OpAddress) {
|
||||
S9xSetByte (0, OpAddress);
|
||||
OpenBus = 0;
|
||||
}
|
||||
|
||||
STATIC inline void TSB16 (uint32 OpAddress, enum s9xwrap_t w) {
|
||||
uint16 Work16 = S9xGetWord (OpAddress, w);
|
||||
ICPU._Zero = (Work16 & Registers.A.W) != 0;
|
||||
Work16 |= Registers.A.W;
|
||||
AddCycles(ONE_CYCLE);
|
||||
S9xSetWord (Work16, OpAddress, w, WRITE_10);
|
||||
OpenBus = Work16&0xff;
|
||||
}
|
||||
|
||||
STATIC inline void TSB8 (uint32 OpAddress) {
|
||||
uint8 Work8 = S9xGetByte (OpAddress);
|
||||
ICPU._Zero = Work8 & Registers.AL;
|
||||
Work8 |= Registers.AL;
|
||||
AddCycles(ONE_CYCLE);
|
||||
S9xSetByte (Work8, OpAddress);
|
||||
OpenBus = Work8;
|
||||
}
|
||||
|
||||
STATIC inline void TRB16 (uint32 OpAddress, enum s9xwrap_t w) {
|
||||
uint16 Work16 = S9xGetWord (OpAddress, w);
|
||||
ICPU._Zero = (Work16 & Registers.A.W) != 0;
|
||||
Work16 &= ~Registers.A.W;
|
||||
AddCycles(ONE_CYCLE);
|
||||
S9xSetWord (Work16, OpAddress, w, WRITE_10);
|
||||
OpenBus = Work16&0xff;
|
||||
}
|
||||
|
||||
STATIC inline void TRB8 (uint32 OpAddress) {
|
||||
uint8 Work8 = S9xGetByte (OpAddress);
|
||||
ICPU._Zero = Work8 & Registers.AL;
|
||||
Work8 &= ~Registers.AL;
|
||||
AddCycles(ONE_CYCLE);
|
||||
S9xSetByte (Work8, OpAddress);
|
||||
OpenBus = Work8;
|
||||
}
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,174 @@
|
||||
/**********************************************************************************
|
||||
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 _CPUOPS_H_
|
||||
#define _CPUOPS_H_
|
||||
void S9xOpcode_NMI ();
|
||||
void S9xOpcode_IRQ ();
|
||||
|
||||
#define CHECK_FOR_IRQ() \
|
||||
if (CPU.IRQActive && !CheckFlag (IRQ) && !Settings.DisableIRQ) \
|
||||
S9xOpcode_IRQ()
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,645 @@
|
||||
/**********************************************************************************
|
||||
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.
|
||||
**********************************************************************************/
|
||||
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef HAVE_LIBPNG
|
||||
#include <png.h>
|
||||
#endif
|
||||
|
||||
#include "port.h"
|
||||
#include "crosshairs.h"
|
||||
|
||||
static char *crosshairs[32]={
|
||||
"` " /* Crosshair 0 (no image) */
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" ",
|
||||
|
||||
"` " /* Crosshair 1 (the classic small dot) */
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" #. "
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" ",
|
||||
|
||||
"` " /* Crosshair 2 (a standard cross) */
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" .#. "
|
||||
" .#. "
|
||||
" ...#... "
|
||||
" ####### "
|
||||
" ...#... "
|
||||
" .#. "
|
||||
" .#. "
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" ",
|
||||
|
||||
"` .#. " /* Crosshair 3 (a standard cross) */
|
||||
" .#. "
|
||||
" .#. "
|
||||
" .#. "
|
||||
" .#. "
|
||||
" .#. "
|
||||
".......#......."
|
||||
"###############"
|
||||
".......#......."
|
||||
" .#. "
|
||||
" .#. "
|
||||
" .#. "
|
||||
" .#. "
|
||||
" .#. "
|
||||
" .#. ",
|
||||
|
||||
"` " /* Crosshair 4 (an X) */
|
||||
" "
|
||||
" "
|
||||
" . . "
|
||||
" .#. .#. "
|
||||
" .#. .#. "
|
||||
" .#.#. "
|
||||
" .#. "
|
||||
" .#.#. "
|
||||
" .#. .#. "
|
||||
" .#. .#. "
|
||||
" . . "
|
||||
" "
|
||||
" "
|
||||
" ",
|
||||
|
||||
"`. . " /* Crosshair 5 (an X) */
|
||||
".#. .#."
|
||||
" .#. .#. "
|
||||
" .#. .#. "
|
||||
" .#. .#. "
|
||||
" .#. .#. "
|
||||
" .#.#. "
|
||||
" .#. "
|
||||
" .#.#. "
|
||||
" .#. .#. "
|
||||
" .#. .#. "
|
||||
" .#. .#. "
|
||||
" .#. .#. "
|
||||
".#. .#."
|
||||
" . . ",
|
||||
|
||||
"` " /* Crosshair 6 (a combo) */
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" # . # "
|
||||
" # . # "
|
||||
" #.# "
|
||||
" ...#... "
|
||||
" #.# "
|
||||
" # . # "
|
||||
" # . # "
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" ",
|
||||
|
||||
"` . " /* Crosshair 7 (a combo) */
|
||||
" # . # "
|
||||
" # . # "
|
||||
" # . # "
|
||||
" # . # "
|
||||
" # . # "
|
||||
" #.# "
|
||||
".......#......."
|
||||
" #.# "
|
||||
" # . # "
|
||||
" # . # "
|
||||
" # . # "
|
||||
" # . # "
|
||||
" # . # "
|
||||
" . ",
|
||||
|
||||
"` # " /* Crosshair 8 (a diamond cross) */
|
||||
" #.# "
|
||||
" # . # "
|
||||
" # . # "
|
||||
" # . # "
|
||||
" # . # "
|
||||
" # . # "
|
||||
"#......#......#"
|
||||
" # . # "
|
||||
" # . # "
|
||||
" # . # "
|
||||
" # . # "
|
||||
" # . # "
|
||||
" #.# "
|
||||
" # ",
|
||||
|
||||
"` ### " /* Crosshair 9 (a circle cross) */
|
||||
" ## . ## "
|
||||
" # . # "
|
||||
" # . # "
|
||||
" # . # "
|
||||
" # . # "
|
||||
"# . #"
|
||||
"#......#......#"
|
||||
"# . #"
|
||||
" # . # "
|
||||
" # . # "
|
||||
" # . # "
|
||||
" # . # "
|
||||
" ## . ## "
|
||||
" ### ",
|
||||
|
||||
"` .#. " /* Crosshair 10 (a square cross) */
|
||||
" .#. "
|
||||
" .#. "
|
||||
" ....#.... "
|
||||
" .#######. "
|
||||
" .# #. "
|
||||
"....# #...."
|
||||
"##### #####"
|
||||
"....# #...."
|
||||
" .# #. "
|
||||
" .#######. "
|
||||
" ....#.... "
|
||||
" .#. "
|
||||
" .#. "
|
||||
" .#. ",
|
||||
|
||||
"` .#. " /* Crosshair 11 (an interrupted cross) */
|
||||
" .#. "
|
||||
" .#. "
|
||||
" .#. "
|
||||
" .#. "
|
||||
" "
|
||||
"..... ....."
|
||||
"##### #####"
|
||||
"..... ....."
|
||||
" "
|
||||
" .#. "
|
||||
" .#. "
|
||||
" .#. "
|
||||
" .#. "
|
||||
" .#. ",
|
||||
|
||||
"`. . " /* Crosshair 12 (an interrupted X) */
|
||||
".#. .#."
|
||||
" .#. .#. "
|
||||
" .#. .#. "
|
||||
" .#. .#. "
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" .#. .#. "
|
||||
" .#. .#. "
|
||||
" .#. .#. "
|
||||
".#. .#."
|
||||
" . . ",
|
||||
|
||||
"` . " /* Crosshair 13 (an interrupted combo) */
|
||||
" # . # "
|
||||
" # . # "
|
||||
" # . # "
|
||||
" # . # "
|
||||
" "
|
||||
" "
|
||||
"..... ....."
|
||||
" "
|
||||
" "
|
||||
" # . # "
|
||||
" # . # "
|
||||
" # . # "
|
||||
" # . # "
|
||||
" . ",
|
||||
|
||||
"`#### #### " /* Crosshair 14 */
|
||||
"#.... ....#"
|
||||
"#. .#"
|
||||
"#. .#"
|
||||
"#. .#"
|
||||
" # "
|
||||
" # "
|
||||
" ##### "
|
||||
" # "
|
||||
" # "
|
||||
"#. .#"
|
||||
"#. .#"
|
||||
"#. .#"
|
||||
"#.... ....#"
|
||||
" #### #### ",
|
||||
|
||||
"` .# #. " /* Crosshair 15 */
|
||||
" .# #. "
|
||||
" .# #. "
|
||||
"....# #...."
|
||||
"##### #####"
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
"##### #####"
|
||||
"....# #...."
|
||||
" .# #. "
|
||||
" .# #. "
|
||||
" .# #. ",
|
||||
|
||||
"` # " /* Crosshair 16 */
|
||||
" # "
|
||||
" # "
|
||||
" ....#.... "
|
||||
" . # . "
|
||||
" . # . "
|
||||
" . # . "
|
||||
"###############"
|
||||
" . # . "
|
||||
" . # . "
|
||||
" . # . "
|
||||
" ....#.... "
|
||||
" # "
|
||||
" # "
|
||||
" # ",
|
||||
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL
|
||||
};
|
||||
|
||||
bool S9xLoadCrosshairFile(int idx, const char *filename){
|
||||
int i, r;
|
||||
char *s;
|
||||
FILE *fp;
|
||||
|
||||
if(idx<1 || idx>31) return false;
|
||||
if((s=(char *)calloc(15*15+1, sizeof(char)))==NULL){
|
||||
fprintf(stderr, "S9xLoadCrosshairFile: malloc error while reading ");
|
||||
perror(filename);
|
||||
return false;
|
||||
}
|
||||
|
||||
if((fp=fopen(filename, "rb"))==NULL){
|
||||
fprintf(stderr, "S9xLoadCrosshairFile: Couldn't open ");
|
||||
perror(filename);
|
||||
free(s);
|
||||
return false;
|
||||
}
|
||||
|
||||
i=fread(s, 1, 8, fp);
|
||||
if(i!=8){
|
||||
fprintf(stderr, "S9xLoadCrosshairFile: File is too short!\n");
|
||||
free(s);
|
||||
fclose(fp);
|
||||
return false;
|
||||
}
|
||||
#ifdef HAVE_LIBPNG
|
||||
png_structp png_ptr;
|
||||
png_infop info_ptr;
|
||||
|
||||
if(!png_sig_cmp((png_byte *)s, 0, 8)){
|
||||
png_ptr=png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||
if (!png_ptr){
|
||||
free(s);
|
||||
fclose(fp);
|
||||
return false;
|
||||
}
|
||||
info_ptr=png_create_info_struct(png_ptr);
|
||||
if(!info_ptr){
|
||||
png_destroy_read_struct(&png_ptr, (png_infopp)NULL, (png_infopp)NULL);
|
||||
free(s);
|
||||
fclose(fp);
|
||||
return false;
|
||||
}
|
||||
|
||||
png_init_io(png_ptr, fp);
|
||||
png_set_sig_bytes(png_ptr, 8);
|
||||
png_read_info(png_ptr, info_ptr);
|
||||
|
||||
png_uint_32 width, height;
|
||||
int bit_depth, color_type;
|
||||
|
||||
png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, NULL, NULL, NULL);
|
||||
if(color_type!=PNG_COLOR_TYPE_PALETTE){
|
||||
fprintf(stderr, "S9xLoadCrosshairFile: Input PNG is not a palettized image!\n");
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
|
||||
free(s);
|
||||
fclose(fp);
|
||||
return false;
|
||||
}
|
||||
if(bit_depth==16)
|
||||
png_set_strip_16(png_ptr);
|
||||
|
||||
if(width!=15 || height!=15){
|
||||
fprintf(stderr, "S9xLoadCrosshairFile: Expecting a 15x15 PNG\n");
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
|
||||
free(s);
|
||||
fclose(fp);
|
||||
return false;
|
||||
}
|
||||
|
||||
int num_palette=0, num_trans=0;
|
||||
int fgcol=-1, bgcol=-1, transcol=-1;
|
||||
png_color *pngpal;
|
||||
png_byte *trans;
|
||||
|
||||
png_get_PLTE(png_ptr, info_ptr, &pngpal, &num_palette);
|
||||
png_get_tRNS(png_ptr, info_ptr, &trans, &num_trans, NULL);
|
||||
|
||||
if(num_palette!=3 || num_trans!=1){
|
||||
fprintf(stderr, "S9xLoadCrosshairFile: Expecting a 3-color PNG with 1 trasnparent color\n");
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
|
||||
free(s);
|
||||
fclose(fp);
|
||||
return false;
|
||||
}
|
||||
|
||||
for(i=0; i<3; i++){
|
||||
if(trans[0]==i){
|
||||
transcol=i;
|
||||
} else if(pngpal[i].red==0 && pngpal[i].green==0 && pngpal[i].blue==0){
|
||||
bgcol=i;
|
||||
} else if(pngpal[i].red==255 && pngpal[i].green==255 && pngpal[i].blue==255){
|
||||
fgcol=i;
|
||||
}
|
||||
}
|
||||
|
||||
if(transcol<0 || fgcol<0 || bgcol<0){
|
||||
fprintf(stderr, "S9xLoadCrosshairFile: PNG must have 3 colors: white (fg), black (bg), and transparent.\n");
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
|
||||
free(s);
|
||||
fclose(fp);
|
||||
return false;
|
||||
}
|
||||
|
||||
png_set_packing(png_ptr);
|
||||
png_read_update_info(png_ptr, info_ptr);
|
||||
png_byte *row_pointer = new png_byte [png_get_rowbytes(png_ptr, info_ptr)];
|
||||
|
||||
for(r=0; r<15*15; r+=15){
|
||||
png_read_row(png_ptr, row_pointer, NULL);
|
||||
for(i=0; i<15; i++){
|
||||
if(row_pointer[i]==transcol) s[r+i]=' ';
|
||||
else if(row_pointer[i]==fgcol) s[r+i]='#';
|
||||
else if(row_pointer[i]==bgcol) s[r+i]='.';
|
||||
else {
|
||||
fprintf(stderr, "S9xLoadCrosshairFile: WTF? This was supposed to be a 3-color PNG!\n");
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
|
||||
free(s);
|
||||
fclose(fp);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
s[15*15]=0;
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
i=fread(s+8, 1, 15-8, fp);
|
||||
if(i!=15-8){
|
||||
fprintf(stderr, "S9xLoadCrosshairFile: File is too short!\n");
|
||||
free(s);
|
||||
fclose(fp);
|
||||
return false;
|
||||
}
|
||||
if(getc(fp)!='\n'){
|
||||
fprintf(stderr, "S9xLoadCrosshairFile: Invalid file format!");
|
||||
#ifndef HAVE_LIBPNG
|
||||
fprintf(stderr, " (note: PNG support is not available)");
|
||||
#endif
|
||||
fprintf(stderr, "\n");
|
||||
free(s);
|
||||
fclose(fp);
|
||||
return false;
|
||||
}
|
||||
for(r=1; r<15; r++){
|
||||
i=fread(s+r*15, 1, 15, fp);
|
||||
if(i!=15){
|
||||
fprintf(stderr, "S9xLoadCrosshairFile: File is too short!");
|
||||
#ifndef HAVE_LIBPNG
|
||||
fprintf(stderr, " (note: PNG support is not available)");
|
||||
#endif
|
||||
fprintf(stderr, "\n");
|
||||
free(s);
|
||||
fclose(fp);
|
||||
return false;
|
||||
}
|
||||
if(getc(fp)!='\n'){
|
||||
fprintf(stderr, "S9xLoadCrosshairFile: Invalid file format!");
|
||||
#ifndef HAVE_LIBPNG
|
||||
fprintf(stderr, " (note: PNG support is not available)");
|
||||
#endif
|
||||
fprintf(stderr, "\n");
|
||||
free(s);
|
||||
fclose(fp);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for(i=0; i<15*15; i++){
|
||||
if(s[i]!=' ' && s[i]!='#' && s[i]!='.'){
|
||||
fprintf(stderr, "S9xLoadCrosshairFile: Invalid file format!");
|
||||
#ifndef HAVE_LIBPNG
|
||||
fprintf(stderr, " (note: PNG support is not available)");
|
||||
#endif
|
||||
fprintf(stderr, "\n");
|
||||
free(s);
|
||||
fclose(fp);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
if(crosshairs[idx]!=NULL && crosshairs[idx][0]!='`') free(crosshairs[idx]);
|
||||
crosshairs[idx]=s;
|
||||
return true;
|
||||
}
|
||||
|
||||
const char *S9xGetCrosshair(int idx){
|
||||
if(idx<0 || idx>31) return NULL;
|
||||
return crosshairs[idx];
|
||||
}
|
||||
@@ -0,0 +1,220 @@
|
||||
/**********************************************************************************
|
||||
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 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 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);
|
||||
|
||||
/*
|
||||
* 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);
|
||||
|
||||
/*
|
||||
* 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);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,613 @@
|
||||
/**********************************************************************************
|
||||
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}
|
||||
};
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,187 @@
|
||||
/**********************************************************************************
|
||||
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 _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
|
||||
|
||||
@@ -0,0 +1,223 @@
|
||||
/**********************************************************************************
|
||||
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 _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,
|
||||
CHEAT_DIR,
|
||||
PACK_DIR,
|
||||
BIOS_DIR,
|
||||
LOG_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
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,175 @@
|
||||
/**********************************************************************************
|
||||
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 _DMA_H_
|
||||
#define _DMA_H_
|
||||
|
||||
START_EXTERN_C
|
||||
void S9xResetDMA ();
|
||||
uint8 S9xDoHDMA (uint8);
|
||||
void S9xStartHDMA ();
|
||||
bool8 S9xDoDMA (uint8);
|
||||
END_EXTERN_C
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,222 @@
|
||||
/**********************************************************************************
|
||||
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 _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
|
||||
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,416 @@
|
||||
/**********************************************************************************
|
||||
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.
|
||||
**********************************************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
uint16 DSP2Op09Word1=0;
|
||||
uint16 DSP2Op09Word2=0;
|
||||
bool DSP2Op05HasLen=false;
|
||||
int DSP2Op05Len=0;
|
||||
bool DSP2Op06HasLen=false;
|
||||
int DSP2Op06Len=0;
|
||||
uint8 DSP2Op05Transparent=0;
|
||||
|
||||
void DSP2_Op05 ()
|
||||
{
|
||||
uint8 color;
|
||||
// Overlay bitmap with transparency.
|
||||
// Input:
|
||||
//
|
||||
// Bitmap 1: i[0] <=> i[size-1]
|
||||
// Bitmap 2: i[size] <=> i[2*size-1]
|
||||
//
|
||||
// Output:
|
||||
//
|
||||
// Bitmap 3: o[0] <=> o[size-1]
|
||||
//
|
||||
// Processing:
|
||||
//
|
||||
// Process all 4-bit pixels (nibbles) in the bitmap
|
||||
//
|
||||
// if ( BM2_pixel == transparent_color )
|
||||
// pixelout = BM1_pixel
|
||||
// else
|
||||
// pixelout = BM2_pixel
|
||||
|
||||
// The max size bitmap is limited to 255 because the size parameter is a byte
|
||||
// I think size=0 is an error. The behavior of the chip on size=0 is to
|
||||
// return the last value written to DR if you read DR on Op05 with
|
||||
// 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;
|
||||
|
||||
color = DSP2Op05Transparent&0x0f;
|
||||
|
||||
for( n = 0; n < DSP2Op05Len; n++ )
|
||||
{
|
||||
c1 = *p1++;
|
||||
c2 = *p2++;
|
||||
*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 ()
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
// Overload's algorithm - use this unless doing hardware testing
|
||||
|
||||
// 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];
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void DSP2_Op0D()
|
||||
{
|
||||
// Bit accurate hardware algorithm - uses fixed point math
|
||||
// This should match the DSP2 Op0D output exactly
|
||||
// I wouldn't recommend using this unless you're doing hardware debug.
|
||||
// In some situations it has small visual artifacts that
|
||||
// are not readily apparent on a TV screen but show up clearly
|
||||
// on a monitor. Use Overload's scaling instead.
|
||||
// This is for hardware verification testing.
|
||||
//
|
||||
// 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
|
||||
|
||||
|
||||
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
|
||||
else
|
||||
multiplier = (DSP2Op0DInLen << 17) / ((DSP2Op0DOutLen<<1) + 1);
|
||||
|
||||
pixloc = 0;
|
||||
for ( i=0; i < DSP2Op0DOutLen * 2; i++ )
|
||||
{
|
||||
j = pixloc >> 16;
|
||||
|
||||
if ( j & 1 )
|
||||
pixelarray[i] = DSP1.parameters[j>>1] & 0x0f;
|
||||
else
|
||||
pixelarray[i] = (DSP1.parameters[j>>1] & 0xf0) >> 4;
|
||||
|
||||
pixloc += multiplier;
|
||||
}
|
||||
|
||||
for ( i=0; i < DSP2Op0DOutLen; i++ )
|
||||
DSP1.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()
|
||||
{
|
||||
// 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).
|
||||
|
||||
float multiplier;
|
||||
float pixloc;
|
||||
int i, j;
|
||||
uint8 pixelarray[512];
|
||||
|
||||
if (DSP2Op0DInLen <= DSP2Op0DOutLen)
|
||||
multiplier = (float) 1.0;
|
||||
else
|
||||
multiplier = (float) ((DSP2Op0DInLen * 2.0) / (DSP2Op0DOutLen * 2.0 + 1.0));
|
||||
|
||||
pixloc = 0.0;
|
||||
for ( i=0; i < DSP2Op0DOutLen * 2; i++ )
|
||||
{
|
||||
// j = (int)(i * multiplier);
|
||||
j = (int) pixloc;
|
||||
|
||||
if ( j & 1 )
|
||||
pixelarray[i] = DSP1.parameters[j>>1] & 0x0f;
|
||||
else
|
||||
pixelarray[i] = (DSP1.parameters[j>>1] & 0xf0) >> 4;
|
||||
|
||||
pixloc += multiplier; // use an add in the loop instead of multiply to increase loop speed
|
||||
}
|
||||
|
||||
for ( i=0; i < DSP2Op0DOutLen; i++ )
|
||||
DSP1.output[i] = ( pixelarray[i<<1] << 4 ) | pixelarray[(i<<1)+1];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,300 @@
|
||||
/**********************************************************************************
|
||||
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.
|
||||
**********************************************************************************/
|
||||
|
||||
|
||||
|
||||
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
|
||||
" .. . . ... . .... .... . . . . . ..... . . . . ",
|
||||
" .##. .#. .#. .###. .#... ... .####. .####. .#..#. .#.#. .#. ..... .#####. ....#. .#.#. .#. ",
|
||||
" ..#. .#. . .#. .#. .#.##. .###. ...#. ..... .#..#. .#.#. .#. .#####. .#...#. .###.#. .#.#. .#.#. ",
|
||||
" .##. .#. . .#.#. .#####. .##.#. .#. .###. .#####. .#..#. .#.#. .#. . .#...#. . .#. ....#. . . .#. ",
|
||||
" ..#. .#..#. .##. ..#.. .#.#. ..#. ..#. ....#. . .#. .#.#. .#..#. .#...#. .#. .#. . ",
|
||||
" .##. .####. ..#.#. .#.. .#. ...#. ...#. ..#. ..#. .#.#. .#.#. .#####. ..#. ...#. ",
|
||||
" ..#. ...#. .##. . .###. .#. .#####. .####. .##. .##. .#..##. .##. .#...#. .##. .###. ",
|
||||
" . . .. ... . ..... .... .. ... . .. .. . . .. ... ",
|
||||
" ",
|
||||
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" "
|
||||
};
|
||||
|
||||
@@ -0,0 +1,483 @@
|
||||
/**********************************************************************************
|
||||
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 "fxemu.h"
|
||||
#include "fxinst.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
extern const char *fx_apvMnemonicTable[];
|
||||
extern struct FxRegs_s GSU;
|
||||
|
||||
|
||||
/*
|
||||
When printing a line from the pipe, it could look like this:
|
||||
|
||||
01:8006 f4 fb 86 iwt r4,#$86fb
|
||||
|
||||
The values are:
|
||||
program bank: 01
|
||||
adress: 8006
|
||||
values at memory address 8006: f4 fb 86
|
||||
instruction in the pipe: iwt r4,#$86fb
|
||||
|
||||
Note! If the instruction has more than one byte (like in 'iwt')
|
||||
and the instruction is in a delay slot, the second and third
|
||||
byte displayed will not be the same as those used.
|
||||
Since the instrction is in a delay slot, the first byte
|
||||
of the instruction will be taken from the pipe at the address
|
||||
after the branch instruction, and the next one or two bytes
|
||||
will be taken from the address that the branch points to.
|
||||
This is a bit complicated, but I've taken this into account,
|
||||
in this debug function. (See the diffrence of how the values
|
||||
vPipe1 and vPipe2 are read, compared to the values vByte1 and
|
||||
vByte2)
|
||||
|
||||
*/
|
||||
void FxPipeString(char * pvString)
|
||||
{
|
||||
char *p;
|
||||
uint32 vOpcode = (GSU.vStatusReg & 0x300) | ((uint32)PIPE);
|
||||
const char *m = fx_apvMnemonicTable[vOpcode];
|
||||
uint8 vPipe1,vPipe2,vByte1,vByte2;
|
||||
uint8 vPipeBank = GSU.vPipeAdr >> 16;
|
||||
|
||||
/* The next two bytes after the pipe's address */
|
||||
vPipe1 = GSU.apvRomBank[vPipeBank][USEX16(GSU.vPipeAdr+1)];
|
||||
vPipe2 = GSU.apvRomBank[vPipeBank][USEX16(GSU.vPipeAdr+2)];
|
||||
|
||||
/* The actual next two bytes to be read */
|
||||
vByte1 = PRGBANK(USEX16(R15));
|
||||
vByte2 = PRGBANK(USEX16(R15+1));
|
||||
|
||||
/* Print ROM address of the pipe */
|
||||
sprintf(pvString, "%02x:%04x %02x ",
|
||||
USEX8(vPipeBank), USEX16(GSU.vPipeAdr), USEX8(PIPE));
|
||||
p = &pvString[strlen(pvString)];
|
||||
|
||||
/* Check if it's a branch instruction */
|
||||
if( PIPE >= 0x05 && PIPE <= 0x0f )
|
||||
{
|
||||
sprintf(&pvString[11], "%02x ", USEX8(vPipe1));
|
||||
#ifdef BRANCH_DELAY_RELATIVE
|
||||
sprintf(p, m, USEX16(R15 + SEX8(vByte1) + 1 ) );
|
||||
#else
|
||||
sprintf(p, m, USEX16(R15 + SEX8(vByte1) - 1 ) );
|
||||
#endif
|
||||
}
|
||||
/* Check for 'move' instruction */
|
||||
else if( PIPE >= 0x10 && PIPE <= 0x1f && TF(B) )
|
||||
sprintf(p, "move r%d,r%d", USEX8(PIPE & 0x0f), (uint32)(GSU.pvSreg - GSU.avReg));
|
||||
/* Check for 'ibt', 'lms' or 'sms' */
|
||||
else if( PIPE >= 0xa0 && PIPE <= 0xaf )
|
||||
{
|
||||
sprintf(&pvString[11], "%02x ", USEX8(vPipe1));
|
||||
if( (GSU.vStatusReg & 0x300) == 0x100 || (GSU.vStatusReg & 0x300) == 0x200 )
|
||||
sprintf(p, m, USEX16(vByte1) << 1 );
|
||||
else
|
||||
sprintf(p, m, USEX16(vByte1) );
|
||||
}
|
||||
/* Check for 'moves' */
|
||||
else if( PIPE >= 0xb0 && PIPE <= 0xbf && TF(B) )
|
||||
sprintf(p, "moves r%d,r%d", (uint32)(GSU.pvDreg - GSU.avReg), USEX8(PIPE & 0x0f));
|
||||
/* Check for 'iwt', 'lm' or 'sm' */
|
||||
else if( PIPE >= 0xf0 )
|
||||
{
|
||||
sprintf(&pvString[11], "%02x %02x ", USEX8(vPipe1), USEX8(vPipe2));
|
||||
sprintf(p, m, USEX8(vByte1) | (USEX16(vByte2)<<8) );
|
||||
}
|
||||
/* Normal instruction */
|
||||
else
|
||||
strcpy(p, m);
|
||||
}
|
||||
|
||||
const char *fx_apvMnemonicTable[] =
|
||||
{
|
||||
/*
|
||||
* ALT0 Table
|
||||
*/
|
||||
/* 00 - 0f */
|
||||
"stop", "nop", "cache", "lsr", "rol", "bra $%04x","blt $%04x","bge $%04x",
|
||||
"bne $%04x","beq $%04x","bpl $%04x","bmi $%04x","bcc $%04x","bcs $%04x","bvc $%04x","bvs $%04x",
|
||||
/* 10 - 1f */
|
||||
"to r0", "to r1", "to r2", "to r3", "to r4", "to r5", "to r6", "to r7",
|
||||
"to r8", "to r9", "to r10", "to r11", "to r12", "to r13", "to r14", "to r15",
|
||||
/* 20 - 2f */
|
||||
"with r0", "with r1", "with r2", "with r3", "with r4", "with r5", "with r6", "with r7",
|
||||
"with r8", "with r9", "with r10", "with r11", "with r12", "with r13", "with r14", "with r15",
|
||||
/* 30 - 3f */
|
||||
"stw (r0)","stw (r1)","stw (r2)", "stw (r3)", "stw (r4)", "stw (r5)", "stw (r6)", "stw (r7)",
|
||||
"stw (r8)","stw (r9)","stw (r10)","stw (r11)","loop", "alt1", "alt2", "alt3",
|
||||
/* 40 - 4f */
|
||||
"ldw (r0)","ldw (r1)","ldw (r2)", "ldw (r3)", "ldw (r4)", "ldw (r5)", "ldw (r6)", "ldw (r7)",
|
||||
"ldw (r8)","ldw (r9)","ldw (r10)","ldw (r11)","plot", "swap", "color", "not",
|
||||
/* 50 - 5f */
|
||||
"add r0", "add r1", "add r2", "add r3", "add r4", "add r5", "add r6", "add r7",
|
||||
"add r8", "add r9", "add r10", "add r11", "add r12", "add r13", "add r14", "add r15",
|
||||
/* 60 - 6f */
|
||||
"sub r0", "sub r1", "sub r2", "sub r3", "sub r4", "sub r5", "sub r6", "sub r7",
|
||||
"sub r8", "sub r9", "sub r10", "sub r11", "sub r12", "sub r13", "sub r14", "sub r15",
|
||||
/* 70 - 7f */
|
||||
"merge", "and r1", "and r2", "and r3", "and r4", "and r5", "and r6", "and r7",
|
||||
"and r8", "and r9", "and r10", "and r11", "and r12", "and r13", "and r14", "and r15",
|
||||
/* 80 - 8f */
|
||||
"mult r0", "mult r1", "mult r2", "mult r3", "mult r4", "mult r5", "mult r6", "mult r7",
|
||||
"mult r8", "mult r9", "mult r10", "mult r11", "mult r12", "mult r13", "mult r14", "mult r15",
|
||||
/* 90 - 9f */
|
||||
"sbk", "link #1", "link #2", "link #3", "link #4", "sex", "asr", "ror",
|
||||
"jmp (r8)","jmp (r9)","jmp (r10)","jmp (r11)","jmp (r12)","jmp (r13)","lob", "fmult",
|
||||
/* a0 - af */
|
||||
"ibt r0,#$%02x", "ibt r1,#$%02x", "ibt r2,#$%02x", "ibt r3,#$%02x",
|
||||
"ibt r4,#$%02x", "ibt r5,#$%02x", "ibt r6,#$%02x", "ibt r7,#$%02x",
|
||||
"ibt r8,#$%02x", "ibt r9,#$%02x", "ibt r10,#$%02x", "ibt r11,#$%02x",
|
||||
"ibt r12,#$%02x", "ibt r13,#$%02x", "ibt r14,#$%02x", "ibt r15,#$%02x",
|
||||
/* b0 - bf */
|
||||
"from r0", "from r1", "from r2", "from r3", "from r4", "from r5", "from r6", "from r7",
|
||||
"from r8", "from r9", "from r10", "from r11", "from r12", "from r13", "from r14", "from r15",
|
||||
/* c0 - cf */
|
||||
"hib", "or r1", "or r2", "or r3", "or r4", "or r5", "or r6", "or r7",
|
||||
"or r8", "or r9", "or r10", "or r11", "or r12", "or r13", "or r14", "or r15",
|
||||
/* d0 - df */
|
||||
"inc r0", "inc r1", "inc r2", "inc r3", "inc r4", "inc r5", "inc r6", "inc r7",
|
||||
"inc r8", "inc r9", "inc r10", "inc r11", "inc r12", "inc r13", "inc r14", "getc",
|
||||
/* e0 - ef */
|
||||
"dec r0", "dec r1", "dec r2", "dec r3", "dec r4", "dec r5", "dec r6", "dec r7",
|
||||
"dec r8", "dec r9", "dec r10", "dec r11", "dec r12", "dec r13", "dec r14", "getb",
|
||||
/* f0 - ff */
|
||||
"iwt r0,#$%04x", "iwt r1,#$%04x", "iwt r2,#$%04x", "iwt r3,#$%04x",
|
||||
"iwt r4,#$%04x", "iwt r5,#$%04x", "iwt r6,#$%04x", "iwt r7,#$%04x",
|
||||
"iwt r8,#$%04x", "iwt r9,#$%04x", "iwt r10,#$%04x", "iwt r11,#$%04x",
|
||||
"iwt r12,#$%04x", "iwt r13,#$%04x", "iwt r14,#$%04x", "iwt r15,#$%04x",
|
||||
|
||||
/*
|
||||
* ALT1 Table
|
||||
*/
|
||||
|
||||
/* 00 - 0f */
|
||||
"stop", "nop", "cache", "lsr", "rol", "bra $%04x","blt $%04x","bge $%04x",
|
||||
"bne $%04x","beq $%04x","bpl $%04x","bmi $%04x","bcc $%04x","bcs $%04x","bvc $%04x","bvs $%04x",
|
||||
/* 10 - 1f */
|
||||
"to r0", "to r1", "to r2", "to r3", "to r4", "to r5", "to r6", "to r7",
|
||||
"to r8", "to r9", "to r10", "to r11", "to r12", "to r13", "to r14", "to r15",
|
||||
/* 20 - 2f */
|
||||
"with r0", "with r1", "with r2", "with r3", "with r4", "with r5", "with r6", "with r7",
|
||||
"with r8", "with r9", "with r10", "with r11", "with r12", "with r13", "with r14", "with r15",
|
||||
/* 30 - 3f */
|
||||
"stb (r0)","stb (r1)","stb (r2)", "stb (r3)", "stb (r4)", "stb (r5)", "stb (r6)", "stb (r7)",
|
||||
"stb (r8)","stb (r9)","stb (r10)","stb (r11)","loop", "alt1", "alt2", "alt3",
|
||||
/* 40 - 4f */
|
||||
"ldb (r0)","ldb (r1)","ldb (r2)", "ldb (r3)", "ldb (r4)", "ldb (r5)", "ldb (r6)", "ldb (r7)",
|
||||
"ldb (r8)","ldb (r9)","ldb (r10)","ldb (r11)","rpix", "swap", "cmode", "not",
|
||||
/* 50 - 5f */
|
||||
"adc r0", "adc r1", "adc r2", "adc r3", "adc r4", "adc r5", "adc r6", "adc r7",
|
||||
"adc r8", "adc r9", "adc r10", "adc r11", "adc r12", "adc r13", "adc r14", "adc r15",
|
||||
/* 60 - 6f */
|
||||
"sbc r0", "sbc r1", "sbc r2", "sbc r3", "sbc r4", "sbc r5", "sbc r6", "sbc r7",
|
||||
"sbc r8", "sbc r9", "sbc r10", "sbc r11", "sbc r12", "sbc r13", "sbc r14", "sbc r15",
|
||||
/* 70 - 7f */
|
||||
"merge", "bic r1", "bic r2", "bic r3", "bic r4", "bic r5", "bic r6", "bic r7",
|
||||
"bic r8", "bic r9", "bic r10", "bic r11", "bic r12", "bic r13", "bic r14", "bic r15",
|
||||
/* 80 - 8f */
|
||||
"umult r0","umult r1","umult r2", "umult r3", "umult r4", "umult r5", "umult r6", "umult r7",
|
||||
"umult r8","umult r9","umult r10","umult r11","umult r12","umult r13","umult r14","umult r15",
|
||||
/* 90 - 9f */
|
||||
"sbk", "link #1", "link #2", "link #3", "link #4", "sex", "div2", "ror",
|
||||
"ljmp (r8)","ljmp (r9)","ljmp (r10)","ljmp (r11)", "ljmp (r12)", "ljmp (r13)", "lob", "lmult",
|
||||
/* a0 - af */
|
||||
"lms r0,($%04x)", "lms r1,($%04x)", "lms r2,($%04x)", "lms r3,($%04x)",
|
||||
"lms r4,($%04x)", "lms r5,($%04x)", "lms r6,($%04x)", "lms r7,($%04x)",
|
||||
"lms r8,($%04x)", "lms r9,($%04x)", "lms r10,($%04x)", "lms r11,($%04x)",
|
||||
"lms r12,($%04x)", "lms r13,($%04x)", "lms r14,($%04x)", "lms r15,($%04x)",
|
||||
/* b0 - bf */
|
||||
"from r0", "from r1", "from r2", "from r3", "from r4", "from r5", "from r6", "from r7",
|
||||
"from r8", "from r9", "from r10", "from r11", "from r12", "from r13", "from r14", "from r15",
|
||||
/* c0 - cf */
|
||||
"hib", "xor r1", "xor r2", "xor r3", "xor r4", "xor r5", "xor r6", "xor r7",
|
||||
"xor r8", "xor r9", "xor r10", "xor r11", "xor r12", "xor r13", "xor r14", "xor r15",
|
||||
/* d0 - df */
|
||||
"inc r0", "inc r1", "inc r2", "inc r3", "inc r4", "inc r5", "inc r6", "inc r7",
|
||||
"inc r8", "inc r9", "inc r10", "inc r11", "inc r12", "inc r13", "inc r14", "getc",
|
||||
/* e0 - ef */
|
||||
"dec r0", "dec r1", "dec r2", "dec r3", "dec r4", "dec r5", "dec r6", "dec r7",
|
||||
"dec r8", "dec r9", "dec r10", "dec r11", "dec r12", "dec r13", "dec r14", "getbh",
|
||||
/* f0 - ff */
|
||||
"lm r0,($%04x)", "lm r1,($%04x)", "lm r2,($%04x)", "lm r3,($%04x)",
|
||||
"lm r4,($%04x)", "lm r5,($%04x)", "lm r6,($%04x)", "lm r7,($%04x)",
|
||||
"lm r8,($%04x)", "lm r9,($%04x)", "lm r10,($%04x)", "lm r11,($%04x)",
|
||||
"lm r12,($%04x)", "lm r13,($%04x)", "lm r14,($%04x)", "lm r15,($%04x)",
|
||||
|
||||
/*
|
||||
* ALT2 Table
|
||||
*/
|
||||
|
||||
/* 00 - 0f */
|
||||
"stop", "nop", "cache", "lsr", "rol", "bra $%04x","blt $%04x","bge $%04x",
|
||||
"bne $%04x","beq $%04x","bpl $%04x","bmi $%04x","bcc $%04x","bcs $%04x","bvc $%04x","bvs $%04x",
|
||||
/* 10 - 1f */
|
||||
"to r0", "to r1", "to r2", "to r3", "to r4", "to r5", "to r6", "to r7",
|
||||
"to r8", "to r9", "to r10", "to r11", "to r12", "to r13", "to r14", "to r15",
|
||||
/* 20 - 2f */
|
||||
"with r0", "with r1", "with r2", "with r3", "with r4", "with r5", "with r6", "with r7",
|
||||
"with r8", "with r9", "with r10", "with r11", "with r12", "with r13", "with r14", "with r15",
|
||||
/* 30 - 3f */
|
||||
"stw (r0)","stw (r1)","stw (r2)", "stw (r3)", "stw (r4)", "stw (r5)", "stw (r6)", "stw (r7)",
|
||||
"stw (r8)","stw (r9)","stw (r10)","stw (r11)","loop", "alt1", "alt2", "alt3",
|
||||
/* 40 - 4f */
|
||||
"ldw (r0)","ldw (r1)","ldw (r2)", "ldw (r3)", "ldw (r4)", "ldw (r5)", "ldw (r6)", "ldw (r7)",
|
||||
"ldw (r8)","ldw (r9)","ldw (r10)","ldw (r11)","plot", "swap", "color", "not",
|
||||
/* 50 - 5f */
|
||||
"add #0", "add #1", "add #2", "add #3", "add #4", "add #5", "add #6", "add #7",
|
||||
"add #8", "add #9", "add #10", "add #11", "add #12", "add #13", "add #14", "add #15",
|
||||
/* 60 - 6f */
|
||||
"sub #0", "sub #1", "sub #2", "sub #3", "sub #4", "sub #5", "sub #6", "sub #7",
|
||||
"sub #8", "sub #9", "sub #10", "sub #11", "sub #12", "sub #13", "sub #14", "sub #15",
|
||||
/* 70 - 7f */
|
||||
"merge", "and #1", "and #2", "and #3", "and #4", "and #5", "and #6", "and #7",
|
||||
"and #8", "and #9", "and #10", "and #11", "and #12", "and #13", "and #14", "and #15",
|
||||
/* 80 - 8f */
|
||||
"mult #0", "mult #1", "mult #2", "mult #3", "mult #4", "mult #5", "mult #6", "mult #7",
|
||||
"mult #8", "mult #9", "mult #10", "mult #11", "mult #12", "mult #13", "mult #14", "mult #15",
|
||||
/* 90 - 9f */
|
||||
"sbk", "link #1", "link #2", "link #3", "link #4", "sex", "asr", "ror",
|
||||
"jmp (r8)","jmp (r9)","jmp (r10)","jmp (r11)","jmp (r12)","jmp (r13)","lob", "fmult",
|
||||
/* a0 - af */
|
||||
"sms ($%04x),r0", "sms ($%04x),r1", "sms ($%04x),r2", "sms ($%04x),r3",
|
||||
"sms ($%04x),r4", "sms ($%04x),r5", "sms ($%04x),r6", "sms ($%04x),r7",
|
||||
"sms ($%04x),r8", "sms ($%04x),r9", "sms ($%04x),r10", "sms ($%04x),r11",
|
||||
"sms ($%04x),r12", "sms ($%04x),r13", "sms ($%04x),r14", "sms ($%04x),r15",
|
||||
/* b0 - bf */
|
||||
"from r0", "from r1", "from r2", "from r3", "from r4", "from r5", "from r6", "from r7",
|
||||
"from r8", "from r9", "from r10", "from r11", "from r12", "from r13", "from r14", "from r15",
|
||||
/* c0 - cf */
|
||||
"hib", "or #1", "or #2", "or #3", "or #4", "or #5", "or #6", "or #7",
|
||||
"or #8", "or #9", "or #10", "or #11", "or #12", "or #13", "or #14", "or #15",
|
||||
/* d0 - df */
|
||||
"inc r0", "inc r1", "inc r2", "inc r3", "inc r4", "inc r5", "inc r6", "inc r7",
|
||||
"inc r8", "inc r9", "inc r10", "inc r11", "inc r12", "inc r13", "inc r14", "ramb",
|
||||
/* e0 - ef */
|
||||
"dec r0", "dec r1", "dec r2", "dec r3", "dec r4", "dec r5", "dec r6", "dec r7",
|
||||
"dec r8", "dec r9", "dec r10", "dec r11", "dec r12", "dec r13", "dec r14", "getbl",
|
||||
/* f0 - ff */
|
||||
"sm ($%04x),r0", "sm ($%04x),r1", "sm ($%04x),r2", "sm ($%04x),r3",
|
||||
"sm ($%04x),r4", "sm ($%04x),r5", "sm ($%04x),r6", "sm ($%04x),r7",
|
||||
"sm ($%04x),r8", "sm ($%04x),r9", "sm ($%04x),r10", "sm ($%04x),r11",
|
||||
"sm ($%04x),r12", "sm ($%04x),r13", "sm ($%04x),r14", "sm ($%04x),r15",
|
||||
|
||||
/*
|
||||
* ALT3 Table
|
||||
*/
|
||||
|
||||
/* 00 - 0f */
|
||||
"stop", "nop", "cache", "lsr", "rol", "bra $%04x","blt $%04x","bge $%04x",
|
||||
"bne $%04x","beq $%04x","bpl $%04x","bmi $%04x","bcc $%04x","bcs $%04x","bvc $%04x","bvs $%04x",
|
||||
/* 10 - 1f */
|
||||
"to r0", "to r1", "to r2", "to r3", "to r4", "to r5", "to r6", "to r7",
|
||||
"to r8", "to r9", "to r10", "to r11", "to r12", "to r13", "to r14", "to r15",
|
||||
/* 20 - 2f */
|
||||
"with r0", "with r1", "with r2", "with r3", "with r4", "with r5", "with r6", "with r7",
|
||||
"with r8", "with r9", "with r10", "with r11", "with r12", "with r13", "with r14", "with r15",
|
||||
/* 30 - 3f */
|
||||
"stb (r0)","stb (r1)","stb (r2)", "stb (r3)", "stb (r4)", "stb (r5)", "stb (r6)", "stb (r7)",
|
||||
"stb (r8)","stb (r9)","stb (r10)","stb (r11)","loop", "alt1", "alt2", "alt3",
|
||||
/* 40 - 4f */
|
||||
"ldb (r0)","ldb (r1)","ldb (r2)", "ldb (r3)", "ldb (r4)", "ldb (r5)", "ldb (r6)", "ldb (r7)",
|
||||
"ldb (r8)","ldb (r9)","ldb (r10)","ldb (r11)","rpix", "swap", "cmode", "not",
|
||||
/* 50 - 5f */
|
||||
"adc #0", "adc #1", "adc #2", "adc #3", "adc #4", "adc #5", "adc #6", "adc #7",
|
||||
"adc #8", "adc #9", "adc #10", "adc #11", "adc #12", "adc #13", "adc #14", "adc #15",
|
||||
/* 60 - 6f */
|
||||
"cmp r0", "cmp r1", "cmp r2", "cmp r3", "cmp r4", "cmp r5", "cmp r6", "cmp r7",
|
||||
"cmp r8", "cmp r9", "cmp r10", "cmp r11", "cmp r12", "cmp r13", "cmp r14", "cmp r15",
|
||||
/* 70 - 7f */
|
||||
"merge", "bic #1", "bic #2", "bic #3", "bic #4", "bic #5", "bic #6", "bic #7",
|
||||
"bic #8", "bic #9", "bic #10", "bic #11", "bic #12", "bic #13", "bic #14", "bic #15",
|
||||
/* 80 - 8f */
|
||||
"umult #0","umult #1","umult #2", "umult #3", "umult #4", "umult #5", "umult #6", "umult #7",
|
||||
"umult #8","umult #9","umult #10","umult #11","umult #12","umult #13","umult #14","umult #15",
|
||||
/* 90 - 9f */
|
||||
"sbk", "link #1", "link #2", "link #3", "link #4", "sex", "div2", "ror",
|
||||
"ljmp (r8)","ljmp (r9)","ljmp (r10)","ljmp (r11)", "ljmp (r12)", "ljmp (r13)", "lob", "lmult",
|
||||
/* a0 - af */
|
||||
"lms r0,($%04x)", "lms r1,($%04x)", "lms r2,($%04x)", "lms r3,($%04x)",
|
||||
"lms r4,($%04x)", "lms r5,($%04x)", "lms r6,($%04x)", "lms r7,($%04x)",
|
||||
"lms r8,($%04x)", "lms r9,($%04x)", "lms r10,($%04x)", "lms r11,($%04x)",
|
||||
"lms r12,($%04x)", "lms r13,($%04x)", "lms r14,($%04x)", "lms r15,($%04x)",
|
||||
/* b0 - bf */
|
||||
"from r0", "from r1", "from r2", "from r3", "from r4", "from r5", "from r6", "from r7",
|
||||
"from r8", "from r9", "from r10", "from r11", "from r12", "from r13", "from r14", "from r15",
|
||||
/* c0 - cf */
|
||||
"hib", "xor #1", "xor #2", "xor #3", "xor #4", "xor #5", "xor #6", "xor #7",
|
||||
"xor #8", "xor #9", "xor #10", "xor #11", "xor #12", "xor #13", "xor #14", "xor #15",
|
||||
/* d0 - df */
|
||||
"inc r0", "inc r1", "inc r2", "inc r3", "inc r4", "inc r5", "inc r6", "inc r7",
|
||||
"inc r8", "inc r9", "inc r10", "inc r11", "inc r12", "inc r13", "inc r14", "romb",
|
||||
/* e0 - ef */
|
||||
"dec r0", "dec r1", "dec r2", "dec r3", "dec r4", "dec r5", "dec r6", "dec r7",
|
||||
"dec r8", "dec r9", "dec r10", "dec r11", "dec r12", "dec r13", "dec r14", "getbs",
|
||||
/* f0 - ff */
|
||||
"lm r0,($%04x)", "lm r1,($%04x)", "lm r2,($%04x)", "lm r3,($%04x)",
|
||||
"lm r4,($%04x)", "lm r5,($%04x)", "lm r6,($%04x)", "lm r7,($%04x)",
|
||||
"lm r8,($%04x)", "lm r9,($%04x)", "lm r10,($%04x)", "lm r11,($%04x)",
|
||||
"lm r12,($%04x)", "lm r13,($%04x)", "lm r14,($%04x)", "lm r15,($%04x)",
|
||||
};
|
||||
|
||||
@@ -0,0 +1,802 @@
|
||||
/**********************************************************************************
|
||||
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 "fxemu.h"
|
||||
#include "fxinst.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/* The FxChip Emulator's internal variables */
|
||||
struct FxRegs_s GSU = FxRegs_s_null;
|
||||
|
||||
uint32 (**fx_ppfFunctionTable)(uint32) = 0;
|
||||
void (**fx_ppfPlotTable)() = 0;
|
||||
void (**fx_ppfOpcodeTable)() = 0;
|
||||
|
||||
#if 0
|
||||
void fx_setCache()
|
||||
{
|
||||
uint32 c;
|
||||
GSU.bCacheActive = TRUE;
|
||||
GSU.pvRegisters[0x3e] &= 0xf0;
|
||||
c = (uint32)GSU.pvRegisters[0x3e];
|
||||
c |= ((uint32)GSU.pvRegisters[0x3f])<<8;
|
||||
if(c == GSU.vCacheBaseReg)
|
||||
return;
|
||||
GSU.vCacheBaseReg = c;
|
||||
GSU.vCacheFlags = 0;
|
||||
if(c < (0x10000-512))
|
||||
{
|
||||
uint8 const* t = &ROM(c);
|
||||
memcpy(GSU.pvCache,t,512);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint8 const* t1;
|
||||
uint8 const* t2;
|
||||
uint32 i = 0x10000 - c;
|
||||
t1 = &ROM(c);
|
||||
t2 = &ROM(0);
|
||||
memcpy(GSU.pvCache,t1,i);
|
||||
memcpy(&GSU.pvCache[i],t2,512-i);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void FxCacheWriteAccess(uint16 vAddress)
|
||||
{
|
||||
#if 0
|
||||
if(!GSU.bCacheActive)
|
||||
{
|
||||
uint8 v = GSU.pvCache[GSU.pvCache[vAddress&0x1ff];
|
||||
fx_setCache();
|
||||
GSU.pvCache[GSU.pvCache[vAddress&0x1ff] = v;
|
||||
}
|
||||
#endif
|
||||
if((vAddress & 0x00f) == 0x00f)
|
||||
GSU.vCacheFlags |= 1 << ((vAddress&0x1f0) >> 4);
|
||||
}
|
||||
|
||||
void FxFlushCache()
|
||||
{
|
||||
GSU.vCacheFlags = 0;
|
||||
GSU.vCacheBaseReg = 0;
|
||||
GSU.bCacheActive = FALSE;
|
||||
// GSU.vPipe = 0x1;
|
||||
}
|
||||
|
||||
static void fx_backupCache()
|
||||
{
|
||||
#if 0
|
||||
uint32 i;
|
||||
uint32 v = GSU.vCacheFlags;
|
||||
uint32 c = USEX16(GSU.vCacheBaseReg);
|
||||
if(v)
|
||||
for(i=0; i<32; i++)
|
||||
{
|
||||
if(v&1)
|
||||
{
|
||||
if(c < (0x10000-16))
|
||||
{
|
||||
uint8 * t = &GSU.pvPrgBank[c];
|
||||
memcpy(&GSU.avCacheBackup[i<<4],t,16);
|
||||
memcpy(t,&GSU.pvCache[i<<4],16);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint8 * t1;
|
||||
uint8 * t2;
|
||||
uint32 a = 0x10000 - c;
|
||||
t1 = &GSU.pvPrgBank[c];
|
||||
t2 = &GSU.pvPrgBank[0];
|
||||
memcpy(&GSU.avCacheBackup[i<<4],t1,a);
|
||||
memcpy(t1,&GSU.pvCache[i<<4],a);
|
||||
memcpy(&GSU.avCacheBackup[(i<<4)+a],t2,16-a);
|
||||
memcpy(t2,&GSU.pvCache[(i<<4)+a],16-a);
|
||||
}
|
||||
}
|
||||
c = USEX16(c+16);
|
||||
v >>= 1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void fx_restoreCache()
|
||||
{
|
||||
#if 0
|
||||
uint32 i;
|
||||
uint32 v = GSU.vCacheFlags;
|
||||
uint32 c = USEX16(GSU.vCacheBaseReg);
|
||||
if(v)
|
||||
for(i=0; i<32; i++)
|
||||
{
|
||||
if(v&1)
|
||||
{
|
||||
if(c < (0x10000-16))
|
||||
{
|
||||
uint8 * t = &GSU.pvPrgBank[c];
|
||||
memcpy(t,&GSU.avCacheBackup[i<<4],16);
|
||||
memcpy(&GSU.pvCache[i<<4],t,16);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint8 * t1;
|
||||
uint8 * t2;
|
||||
uint32 a = 0x10000 - c;
|
||||
t1 = &GSU.pvPrgBank[c];
|
||||
t2 = &GSU.pvPrgBank[0];
|
||||
memcpy(t1,&GSU.avCacheBackup[i<<4],a);
|
||||
memcpy(&GSU.pvCache[i<<4],t1,a);
|
||||
memcpy(t2,&GSU.avCacheBackup[(i<<4)+a],16-a);
|
||||
memcpy(&GSU.pvCache[(i<<4)+a],t2,16-a);
|
||||
}
|
||||
}
|
||||
c = USEX16(c+16);
|
||||
v >>= 1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void fx_flushCache()
|
||||
{
|
||||
fx_restoreCache();
|
||||
GSU.vCacheFlags = 0;
|
||||
GSU.bCacheActive = FALSE;
|
||||
}
|
||||
|
||||
|
||||
void fx_updateRamBank(uint8 Byte)
|
||||
{
|
||||
// Update BankReg and Bank pointer
|
||||
GSU.vRamBankReg = (uint32)Byte & (FX_RAM_BANKS-1);
|
||||
GSU.pvRamBank = GSU.apvRamBank[Byte & 0x3];
|
||||
}
|
||||
|
||||
|
||||
static void fx_readRegisterSpace()
|
||||
{
|
||||
int i;
|
||||
uint8 *p;
|
||||
static uint32 avHeight[] = { 128, 160, 192, 256 };
|
||||
static uint32 avMult[] = { 16, 32, 32, 64 };
|
||||
|
||||
GSU.vErrorCode = 0;
|
||||
|
||||
/* Update R0-R15 */
|
||||
p = GSU.pvRegisters;
|
||||
for(i=0; i<16; i++)
|
||||
{
|
||||
GSU.avReg[i] = *p++;
|
||||
GSU.avReg[i] += ((uint32)(*p++)) << 8;
|
||||
}
|
||||
|
||||
/* Update other registers */
|
||||
p = GSU.pvRegisters;
|
||||
GSU.vStatusReg = (uint32)p[GSU_SFR];
|
||||
GSU.vStatusReg |= ((uint32)p[GSU_SFR+1]) << 8;
|
||||
GSU.vPrgBankReg = (uint32)p[GSU_PBR];
|
||||
GSU.vRomBankReg = (uint32)p[GSU_ROMBR];
|
||||
GSU.vRamBankReg = ((uint32)p[GSU_RAMBR]) & (FX_RAM_BANKS-1);
|
||||
GSU.vCacheBaseReg = (uint32)p[GSU_CBR];
|
||||
GSU.vCacheBaseReg |= ((uint32)p[GSU_CBR+1]) << 8;
|
||||
|
||||
/* Update status register variables */
|
||||
GSU.vZero = !(GSU.vStatusReg & FLG_Z);
|
||||
GSU.vSign = (GSU.vStatusReg & FLG_S) << 12;
|
||||
GSU.vOverflow = (GSU.vStatusReg & FLG_OV) << 16;
|
||||
GSU.vCarry = (GSU.vStatusReg & FLG_CY) >> 2;
|
||||
|
||||
/* Set bank pointers */
|
||||
GSU.pvRamBank = GSU.apvRamBank[GSU.vRamBankReg & 0x3];
|
||||
GSU.pvRomBank = GSU.apvRomBank[GSU.vRomBankReg];
|
||||
GSU.pvPrgBank = GSU.apvRomBank[GSU.vPrgBankReg];
|
||||
|
||||
/* Set screen pointers */
|
||||
GSU.pvScreenBase = &GSU.pvRam[ USEX8(p[GSU_SCBR]) << 10 ];
|
||||
i = (int)(!!(p[GSU_SCMR] & 0x04));
|
||||
i |= ((int)(!!(p[GSU_SCMR] & 0x20))) << 1;
|
||||
GSU.vScreenHeight = GSU.vScreenRealHeight = avHeight[i];
|
||||
GSU.vMode = p[GSU_SCMR] & 0x03;
|
||||
#if 0
|
||||
if(GSU.vMode == 2)
|
||||
error illegal color depth GSU.vMode;
|
||||
#endif
|
||||
if(i == 3)
|
||||
GSU.vScreenSize = (256/8) * (256/8) * 32;
|
||||
else
|
||||
GSU.vScreenSize = (GSU.vScreenHeight/8) * (256/8) * avMult[GSU.vMode];
|
||||
if (GSU.vPlotOptionReg & 0x10)
|
||||
{
|
||||
/* OBJ Mode (for drawing into sprites) */
|
||||
GSU.vScreenHeight = 256;
|
||||
}
|
||||
#if 0
|
||||
if(GSU.pvScreenBase + GSU.vScreenSize > GSU.pvRam + (GSU.nRamBanks * 65536))
|
||||
error illegal address for screen base register
|
||||
#else
|
||||
if(GSU.pvScreenBase + GSU.vScreenSize > GSU.pvRam + (GSU.nRamBanks * 65536))
|
||||
GSU.pvScreenBase = GSU.pvRam + (GSU.nRamBanks * 65536) - GSU.vScreenSize;
|
||||
#endif
|
||||
GSU.pfPlot = fx_apfPlotTable[GSU.vMode];
|
||||
GSU.pfRpix = fx_apfPlotTable[GSU.vMode + 5];
|
||||
|
||||
fx_ppfOpcodeTable[0x04c] = GSU.pfPlot;
|
||||
fx_ppfOpcodeTable[0x14c] = GSU.pfRpix;
|
||||
fx_ppfOpcodeTable[0x24c] = GSU.pfPlot;
|
||||
fx_ppfOpcodeTable[0x34c] = GSU.pfRpix;
|
||||
|
||||
fx_computeScreenPointers ();
|
||||
|
||||
fx_backupCache();
|
||||
}
|
||||
|
||||
void fx_dirtySCBR()
|
||||
{
|
||||
GSU.vSCBRDirty = TRUE;
|
||||
}
|
||||
|
||||
void fx_computeScreenPointers ()
|
||||
{
|
||||
if (GSU.vMode != GSU.vPrevMode ||
|
||||
GSU.vPrevScreenHeight != GSU.vScreenHeight ||
|
||||
GSU.vSCBRDirty)
|
||||
{
|
||||
int i;
|
||||
|
||||
GSU.vSCBRDirty = FALSE;
|
||||
|
||||
/* Make a list of pointers to the start of each screen column */
|
||||
switch (GSU.vScreenHeight)
|
||||
{
|
||||
case 128:
|
||||
switch (GSU.vMode)
|
||||
{
|
||||
case 0:
|
||||
for (i = 0; i < 32; i++)
|
||||
{
|
||||
GSU.apvScreen[i] = GSU.pvScreenBase + (i << 4);
|
||||
GSU.x[i] = i << 8;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
for (i = 0; i < 32; i++)
|
||||
{
|
||||
GSU.apvScreen[i] = GSU.pvScreenBase + (i << 5);
|
||||
GSU.x[i] = i << 9;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
for (i = 0; i < 32; i++)
|
||||
{
|
||||
GSU.apvScreen[i] = GSU.pvScreenBase + (i << 6);
|
||||
GSU.x[i] = i << 10;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 160:
|
||||
switch (GSU.vMode)
|
||||
{
|
||||
case 0:
|
||||
for (i = 0; i < 32; i++)
|
||||
{
|
||||
GSU.apvScreen[i] = GSU.pvScreenBase + (i << 4);
|
||||
GSU.x[i] = (i << 8) + (i << 6);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
for (i = 0; i < 32; i++)
|
||||
{
|
||||
GSU.apvScreen[i] = GSU.pvScreenBase + (i << 5);
|
||||
GSU.x[i] = (i << 9) + (i << 7);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
for (i = 0; i < 32; i++)
|
||||
{
|
||||
GSU.apvScreen[i] = GSU.pvScreenBase + (i << 6);
|
||||
GSU.x[i] = (i << 10) + (i << 8);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 192:
|
||||
switch (GSU.vMode)
|
||||
{
|
||||
case 0:
|
||||
for (i = 0; i < 32; i++)
|
||||
{
|
||||
GSU.apvScreen[i] = GSU.pvScreenBase + (i << 4);
|
||||
GSU.x[i] = (i << 8) + (i << 7);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
for (i = 0; i < 32; i++)
|
||||
{
|
||||
GSU.apvScreen[i] = GSU.pvScreenBase + (i << 5);
|
||||
GSU.x[i] = (i << 9) + (i << 8);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
for (i = 0; i < 32; i++)
|
||||
{
|
||||
GSU.apvScreen[i] = GSU.pvScreenBase + (i << 6);
|
||||
GSU.x[i] = (i << 10) + (i << 9);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 256:
|
||||
switch (GSU.vMode)
|
||||
{
|
||||
case 0:
|
||||
for (i = 0; i < 32; i++)
|
||||
{
|
||||
GSU.apvScreen[i] = GSU.pvScreenBase +
|
||||
((i & 0x10) << 9) + ((i & 0xf) << 8);
|
||||
GSU.x[i] = ((i & 0x10) << 8) + ((i & 0xf) << 4);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
for (i = 0; i < 32; i++)
|
||||
{
|
||||
GSU.apvScreen[i] = GSU.pvScreenBase +
|
||||
((i & 0x10) << 10) + ((i & 0xf) << 9);
|
||||
GSU.x[i] = ((i & 0x10) << 9) + ((i & 0xf) << 5);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
for (i = 0; i < 32; i++)
|
||||
{
|
||||
GSU.apvScreen[i] = GSU.pvScreenBase +
|
||||
((i & 0x10) << 11) + ((i & 0xf) << 10);
|
||||
GSU.x[i] = ((i & 0x10) << 10) + ((i & 0xf) << 6);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
GSU.vPrevMode = GSU.vMode;
|
||||
GSU.vPrevScreenHeight = GSU.vScreenHeight;
|
||||
}
|
||||
}
|
||||
|
||||
static void fx_writeRegisterSpace()
|
||||
{
|
||||
int i;
|
||||
uint8 *p;
|
||||
|
||||
p = GSU.pvRegisters;
|
||||
for(i=0; i<16; i++)
|
||||
{
|
||||
*p++ = (uint8)GSU.avReg[i];
|
||||
*p++ = (uint8)(GSU.avReg[i] >> 8);
|
||||
}
|
||||
|
||||
/* Update status register */
|
||||
if( USEX16(GSU.vZero) == 0 ) SF(Z);
|
||||
else CF(Z);
|
||||
if( GSU.vSign & 0x8000 ) SF(S);
|
||||
else CF(S);
|
||||
if(GSU.vOverflow >= 0x8000 || GSU.vOverflow < -0x8000) SF(OV);
|
||||
else CF(OV);
|
||||
if(GSU.vCarry) SF(CY);
|
||||
else CF(CY);
|
||||
|
||||
p = GSU.pvRegisters;
|
||||
p[GSU_SFR] = (uint8)GSU.vStatusReg;
|
||||
p[GSU_SFR+1] = (uint8)(GSU.vStatusReg>>8);
|
||||
p[GSU_PBR] = (uint8)GSU.vPrgBankReg;
|
||||
p[GSU_ROMBR] = (uint8)GSU.vRomBankReg;
|
||||
p[GSU_RAMBR] = (uint8)GSU.vRamBankReg;
|
||||
p[GSU_CBR] = (uint8)GSU.vCacheBaseReg;
|
||||
p[GSU_CBR+1] = (uint8)(GSU.vCacheBaseReg>>8);
|
||||
|
||||
fx_restoreCache();
|
||||
}
|
||||
|
||||
/* Reset the FxChip */
|
||||
void FxReset(struct FxInit_s *psFxInfo)
|
||||
{
|
||||
int i;
|
||||
static uint32 (**appfFunction[])(uint32) = {
|
||||
&fx_apfFunctionTable[0],
|
||||
#if 0
|
||||
&fx_a_apfFunctionTable[0],
|
||||
&fx_r_apfFunctionTable[0],
|
||||
&fx_ar_apfFunctionTable[0],
|
||||
#endif
|
||||
};
|
||||
static void (**appfPlot[])() = {
|
||||
&fx_apfPlotTable[0],
|
||||
#if 0
|
||||
&fx_a_apfPlotTable[0],
|
||||
&fx_r_apfPlotTable[0],
|
||||
&fx_ar_apfPlotTable[0],
|
||||
#endif
|
||||
};
|
||||
static void (**appfOpcode[])() = {
|
||||
&fx_apfOpcodeTable[0],
|
||||
#if 0
|
||||
&fx_a_apfOpcodeTable[0],
|
||||
&fx_r_apfOpcodeTable[0],
|
||||
&fx_ar_apfOpcodeTable[0],
|
||||
#endif
|
||||
};
|
||||
|
||||
/* Get function pointers for the current emulation mode */
|
||||
fx_ppfFunctionTable = appfFunction[psFxInfo->vFlags & 0x3];
|
||||
fx_ppfPlotTable = appfPlot[psFxInfo->vFlags & 0x3];
|
||||
fx_ppfOpcodeTable = appfOpcode[psFxInfo->vFlags & 0x3];
|
||||
|
||||
/* Clear all internal variables */
|
||||
memset((uint8*)&GSU,0,sizeof(struct FxRegs_s));
|
||||
|
||||
/* Set default registers */
|
||||
GSU.pvSreg = GSU.pvDreg = &R0;
|
||||
|
||||
/* Set RAM and ROM pointers */
|
||||
GSU.pvRegisters = psFxInfo->pvRegisters;
|
||||
GSU.nRamBanks = psFxInfo->nRamBanks;
|
||||
GSU.pvRam = psFxInfo->pvRam;
|
||||
GSU.nRomBanks = psFxInfo->nRomBanks;
|
||||
GSU.pvRom = psFxInfo->pvRom;
|
||||
GSU.vPrevScreenHeight = ~0;
|
||||
GSU.vPrevMode = ~0;
|
||||
|
||||
/* The GSU can't access more than 2mb (16mbits) */
|
||||
if(GSU.nRomBanks > 0x20)
|
||||
GSU.nRomBanks = 0x20;
|
||||
|
||||
/* Clear FxChip register space */
|
||||
memset(GSU.pvRegisters,0,0x300);
|
||||
|
||||
/* Set FxChip version Number */
|
||||
GSU.pvRegisters[0x3b] = 0;
|
||||
|
||||
/* Make ROM bank table */
|
||||
for(i=0; i<256; i++)
|
||||
{
|
||||
uint32 b = i & 0x7f;
|
||||
if (b >= 0x40)
|
||||
{
|
||||
if (GSU.nRomBanks > 1)
|
||||
b %= GSU.nRomBanks;
|
||||
else
|
||||
b &= 1;
|
||||
|
||||
GSU.apvRomBank[i] = &GSU.pvRom[ b << 16 ];
|
||||
}
|
||||
else
|
||||
{
|
||||
b %= GSU.nRomBanks * 2;
|
||||
GSU.apvRomBank[i] = &GSU.pvRom[ (b << 16) + 0x200000];
|
||||
}
|
||||
}
|
||||
|
||||
/* Make RAM bank table */
|
||||
for(i=0; i<4; i++)
|
||||
{
|
||||
GSU.apvRamBank[i] = &GSU.pvRam[(i % GSU.nRamBanks) << 16];
|
||||
GSU.apvRomBank[0x70 + i] = GSU.apvRamBank[i];
|
||||
}
|
||||
|
||||
/* Start with a nop in the pipe */
|
||||
GSU.vPipe = 0x01;
|
||||
|
||||
/* Set pointer to GSU cache */
|
||||
GSU.pvCache = &GSU.pvRegisters[0x100];
|
||||
|
||||
fx_readRegisterSpace();
|
||||
}
|
||||
|
||||
static uint8 fx_checkStartAddress()
|
||||
{
|
||||
/* Check if we start inside the cache */
|
||||
if(GSU.bCacheActive && R15 >= GSU.vCacheBaseReg && R15 < (GSU.vCacheBaseReg+512))
|
||||
return TRUE;
|
||||
|
||||
/* Check if we're in an unused area */
|
||||
#if 0
|
||||
if(GSU.vPrgBankReg < 0x40 && R15 < 0x8000)
|
||||
return FALSE;
|
||||
#endif
|
||||
if(GSU.vPrgBankReg >= 0x60 && GSU.vPrgBankReg <= 0x6f)
|
||||
return FALSE;
|
||||
if(GSU.vPrgBankReg >= 0x74)
|
||||
return FALSE;
|
||||
|
||||
/* Check if we're in RAM and the RAN flag is not set */
|
||||
if(GSU.vPrgBankReg >= 0x70 && GSU.vPrgBankReg <= 0x73 && !(SCMR&(1<<3)) )
|
||||
return FALSE;
|
||||
|
||||
/* If not, we're in ROM, so check if the RON flag is set */
|
||||
if(!(SCMR&(1<<4)))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Execute until the next stop instruction */
|
||||
int FxEmulate(uint32 nInstructions)
|
||||
{
|
||||
uint32 vCount;
|
||||
|
||||
/* Read registers and initialize GSU session */
|
||||
fx_readRegisterSpace();
|
||||
|
||||
/* Check if the start address is valid */
|
||||
if(!fx_checkStartAddress())
|
||||
{
|
||||
CF(G);
|
||||
fx_writeRegisterSpace();
|
||||
#if 0
|
||||
GSU.vIllegalAddress = (GSU.vPrgBankReg << 24) | R15;
|
||||
return FX_ERROR_ILLEGAL_ADDRESS;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Execute GSU session */
|
||||
CF(IRQ);
|
||||
|
||||
if(GSU.bBreakPoint)
|
||||
vCount = fx_ppfFunctionTable[FX_FUNCTION_RUN_TO_BREAKPOINT](nInstructions);
|
||||
else
|
||||
vCount = fx_ppfFunctionTable[FX_FUNCTION_RUN](nInstructions);
|
||||
|
||||
/* Store GSU registers */
|
||||
fx_writeRegisterSpace();
|
||||
|
||||
/* Check for error code */
|
||||
if(GSU.vErrorCode)
|
||||
return GSU.vErrorCode;
|
||||
else
|
||||
return vCount;
|
||||
}
|
||||
|
||||
/* Breakpoints */
|
||||
void FxBreakPointSet(uint32 vAddress)
|
||||
{
|
||||
GSU.bBreakPoint = TRUE;
|
||||
GSU.vBreakPoint = USEX16(vAddress);
|
||||
}
|
||||
void FxBreakPointClear()
|
||||
{
|
||||
GSU.bBreakPoint = FALSE;
|
||||
}
|
||||
|
||||
/* Step by step execution */
|
||||
int FxStepOver(uint32 nInstructions)
|
||||
{
|
||||
uint32 vCount;
|
||||
fx_readRegisterSpace();
|
||||
|
||||
/* Check if the start address is valid */
|
||||
if(!fx_checkStartAddress())
|
||||
{
|
||||
CF(G);
|
||||
#if 0
|
||||
GSU.vIllegalAddress = (GSU.vPrgBankReg << 24) | R15;
|
||||
return FX_ERROR_ILLEGAL_ADDRESS;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
if( PIPE >= 0xf0 )
|
||||
GSU.vStepPoint = USEX16(R15+3);
|
||||
else if( (PIPE >= 0x05 && PIPE <= 0x0f) || (PIPE >= 0xa0 && PIPE <= 0xaf) )
|
||||
GSU.vStepPoint = USEX16(R15+2);
|
||||
else
|
||||
GSU.vStepPoint = USEX16(R15+1);
|
||||
vCount = fx_ppfFunctionTable[FX_FUNCTION_STEP_OVER](nInstructions);
|
||||
fx_writeRegisterSpace();
|
||||
if(GSU.vErrorCode)
|
||||
return GSU.vErrorCode;
|
||||
else
|
||||
return vCount;
|
||||
}
|
||||
|
||||
/* Errors */
|
||||
int FxGetErrorCode()
|
||||
{
|
||||
return GSU.vErrorCode;
|
||||
}
|
||||
|
||||
int FxGetIllegalAddress()
|
||||
{
|
||||
return GSU.vIllegalAddress;
|
||||
}
|
||||
|
||||
/* Access to internal registers */
|
||||
uint32 FxGetColorRegister()
|
||||
{
|
||||
return GSU.vColorReg & 0xff;
|
||||
}
|
||||
|
||||
uint32 FxGetPlotOptionRegister()
|
||||
{
|
||||
return GSU.vPlotOptionReg & 0x1f;
|
||||
}
|
||||
|
||||
uint32 FxGetSourceRegisterIndex()
|
||||
{
|
||||
return GSU.pvSreg - GSU.avReg;
|
||||
}
|
||||
|
||||
uint32 FxGetDestinationRegisterIndex()
|
||||
{
|
||||
return GSU.pvDreg - GSU.avReg;
|
||||
}
|
||||
|
||||
uint8 FxPipe()
|
||||
{
|
||||
return GSU.vPipe;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,234 @@
|
||||
/**********************************************************************************
|
||||
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 _FXEMU_H_
|
||||
#define _FXEMU_H_ 1
|
||||
|
||||
#include "port.h"
|
||||
|
||||
/* The FxInfo_s structure, the link between the FxEmulator and the Snes Emulator */
|
||||
struct FxInit_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 speedPerLine;
|
||||
bool8 oneLineDone;
|
||||
};
|
||||
|
||||
/* Reset the FxChip */
|
||||
extern void FxReset(struct FxInit_s *psFxInfo);
|
||||
|
||||
/* Execute until the next stop instruction */
|
||||
extern int FxEmulate(uint32 nInstructions);
|
||||
|
||||
/* Write access to the cache */
|
||||
extern void FxCacheWriteAccess(uint16 vAddress);
|
||||
extern void FxFlushCache(); /* Callled when the G flag in SFR is set to zero */
|
||||
|
||||
/* Breakpoint */
|
||||
extern void FxBreakPointSet(uint32 vAddress);
|
||||
extern void FxBreakPointClear();
|
||||
|
||||
/* Step by step execution */
|
||||
extern int FxStepOver(uint32 nInstructions);
|
||||
|
||||
/* Errors */
|
||||
extern int FxGetErrorCode();
|
||||
extern int FxGetIllegalAddress();
|
||||
|
||||
/* 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 ();
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,550 @@
|
||||
/**********************************************************************************
|
||||
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 _FXINST_H_
|
||||
#define _FXINST_H_ 1
|
||||
|
||||
/*
|
||||
* FxChip(GSU) register space specification
|
||||
* (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
|
||||
* 3006 - R3
|
||||
* 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
|
||||
* 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
|
||||
*
|
||||
* 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)
|
||||
*
|
||||
* 3040-30ff - unused
|
||||
*
|
||||
* 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
|
||||
* 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
|
||||
* 13 -
|
||||
* 14 -
|
||||
* 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
|
||||
*
|
||||
* CFGR control flags register bits:
|
||||
* 0 -
|
||||
* 1 -
|
||||
* 2 -
|
||||
* 3 -
|
||||
* 4 -
|
||||
* 5 MS0 Multiplier speed, 0=standard, 1=high speed
|
||||
* 6 -
|
||||
* 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
|
||||
*
|
||||
* 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
|
||||
* 6 -
|
||||
* 7 -
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* Write access to the program counter (301e) from
|
||||
* the SNES-CPU will start the GSU, and it will not
|
||||
* stop until it reaches a stop instruction.
|
||||
*
|
||||
*/
|
||||
|
||||
/* Number of banks in GSU RAM */
|
||||
#define FX_RAM_BANKS 4
|
||||
|
||||
/* Emulate proper R14 ROM access (slower, but safer) */
|
||||
/* #define FX_DO_ROMBUFFER */
|
||||
|
||||
/* 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 */
|
||||
|
||||
/* 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 */
|
||||
|
||||
int32 vErrorCode;
|
||||
uint32 vIllegalAddress;
|
||||
|
||||
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 */
|
||||
|
||||
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 * 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 */
|
||||
};
|
||||
|
||||
#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, \
|
||||
}
|
||||
|
||||
/* 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)
|
||||
|
||||
/* 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 ) )
|
||||
|
||||
/* 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)))
|
||||
|
||||
/* Unsign extend from 8/16 bit to 32 bit */
|
||||
#define USEX16(a) ((uint32)((uint16)(a)))
|
||||
#define USEX8(a) ((uint32)((uint8)(a)))
|
||||
|
||||
#define SUSEX16(a) ((int32)((uint16)(a)))
|
||||
|
||||
/* 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;
|
||||
|
||||
/* Read current RAM-Bank */
|
||||
#define RAM(adr) GSU.pvRamBank[USEX16(adr)]
|
||||
|
||||
/* Read current ROM-Bank */
|
||||
#define ROM(idx) (GSU.pvRomBank[USEX16(idx)])
|
||||
|
||||
/* 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)]
|
||||
|
||||
/* Update pipe from ROM */
|
||||
#if 0
|
||||
#define FETCHPIPE { PIPE = PRGBANK(R15); GSU.vPipeAdr = (GSU.vPrgBankReg<<16) + R15; }
|
||||
#else
|
||||
#define FETCHPIPE { PIPE = PRGBANK(R15); }
|
||||
#endif
|
||||
|
||||
/* ABS */
|
||||
#define ABS(x) ((x)<0?-(x):(x))
|
||||
|
||||
/* Access source register */
|
||||
#define SREG (*GSU.pvSreg)
|
||||
|
||||
/* Access destination register */
|
||||
#define DREG (*GSU.pvDreg)
|
||||
|
||||
#ifndef FX_DO_ROMBUFFER
|
||||
|
||||
/* Don't read R14 */
|
||||
#define READR14
|
||||
|
||||
/* Don't test and/or read R14 */
|
||||
#define TESTR14
|
||||
|
||||
#else
|
||||
|
||||
/* Read R14 */
|
||||
#define READR14 GSU.vRomBuffer = ROM(R14)
|
||||
|
||||
/* 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])
|
||||
|
||||
/* 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 ])(); } \
|
||||
|
||||
#define FX_FUNCTION_RUN 0
|
||||
#define FX_FUNCTION_RUN_TO_BREAKPOINT 1
|
||||
#define FX_FUNCTION_STEP_OVER 2
|
||||
|
||||
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) */
|
||||
#define BRANCH_DELAY_RELATIVE
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,955 @@
|
||||
/**********************************************************************************
|
||||
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 _GETSET_H_
|
||||
#define _GETSET_H_
|
||||
|
||||
#include "ppu.h"
|
||||
#include "dsp1.h"
|
||||
#include "cpuexec.h"
|
||||
#include "sa1.h"
|
||||
#include "spc7110.h"
|
||||
#include "obc1.h"
|
||||
#include "seta.h"
|
||||
#include "bsx.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
extern uint8 OpenBus;
|
||||
}
|
||||
|
||||
INLINE uint8 S9xGetByte (uint32 Address)
|
||||
{
|
||||
int block;
|
||||
uint8 *GetAddress = Memory.Map [block = ((Address&0xffffff) >> MEMMAP_SHIFT)];
|
||||
|
||||
if(!CPU.InDMAorHDMA)
|
||||
CPU.Cycles += Memory.MemorySpeed [block];
|
||||
|
||||
if (GetAddress >= (uint8 *) CMemory::MAP_LAST)
|
||||
{
|
||||
#ifdef CPU_SHUTDOWN
|
||||
if (Memory.BlockIsRAM [block])
|
||||
CPU.WaitAddress = CPU.PBPCAtOpcodeStart;
|
||||
#endif
|
||||
return (*(GetAddress + (Address & 0xffff)));
|
||||
}
|
||||
|
||||
switch ((pint) GetAddress)
|
||||
{
|
||||
case CMemory::MAP_PPU:
|
||||
if(CPU.InDMAorHDMA && (Address&0xff00)==0x2100) return OpenBus;
|
||||
return (S9xGetPPU (Address & 0xffff));
|
||||
case CMemory::MAP_CPU:
|
||||
return (S9xGetCPU (Address & 0xffff));
|
||||
case CMemory::MAP_DSP:
|
||||
return (S9xGetDSP (Address & 0xffff));
|
||||
case CMemory::MAP_SA1RAM:
|
||||
case CMemory::MAP_LOROM_SRAM:
|
||||
//Address &0x7FFF -offset into bank
|
||||
//Address&0xFF0000 -bank
|
||||
//bank>>1 | offset = s-ram address, unbound
|
||||
//unbound & SRAMMask = Sram offset
|
||||
return (*(Memory.SRAM + ((((Address&0xFF0000)>>1) |(Address&0x7FFF)) &Memory.SRAMMask)));
|
||||
|
||||
case CMemory::MAP_LOROM_SRAM_B:
|
||||
return (*(Multi.sramB + ((((Address&0xFF0000)>>1) |(Address&0x7FFF)) &Multi.sramMaskB)));
|
||||
|
||||
case CMemory::MAP_RONLY_SRAM:
|
||||
case CMemory::MAP_HIROM_SRAM:
|
||||
return (*(Memory.SRAM + (((Address & 0x7fff) - 0x6000 +
|
||||
((Address & 0xf0000) >> 3)) & Memory.SRAMMask)));
|
||||
|
||||
case CMemory::MAP_BWRAM:
|
||||
return (*(Memory.BWRAM + ((Address & 0x7fff) - 0x6000)));
|
||||
|
||||
case CMemory::MAP_C4:
|
||||
return (S9xGetC4 (Address & 0xffff));
|
||||
|
||||
case CMemory::MAP_SPC7110_ROM:
|
||||
#ifdef SPC7110_DEBUG
|
||||
printf("reading spc7110 ROM (byte) at %06X\n", Address);
|
||||
#endif
|
||||
return S9xGetSPC7110Byte(Address);
|
||||
|
||||
case CMemory::MAP_SPC7110_DRAM:
|
||||
#ifdef SPC7110_DEBUG
|
||||
printf("reading Bank 50 (byte)\n");
|
||||
#endif
|
||||
return S9xGetSPC7110(0x4800);
|
||||
|
||||
case CMemory::MAP_OBC_RAM:
|
||||
return GetOBC1(Address & 0xffff);
|
||||
|
||||
case CMemory::MAP_SETA_DSP:
|
||||
return S9xGetSetaDSP(Address);
|
||||
|
||||
case CMemory::MAP_SETA_RISC:
|
||||
return S9xGetST018(Address);
|
||||
|
||||
case CMemory::MAP_BSX:
|
||||
return S9xGetBSX(Address);
|
||||
|
||||
case CMemory::MAP_DEBUG:
|
||||
#ifdef DEBUGGER
|
||||
printf ("DEBUG R(B) %06x\n", Address);
|
||||
#endif
|
||||
default:
|
||||
case CMemory::MAP_NONE:
|
||||
return OpenBus;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef NO_INLINE_SET_GET
|
||||
INLINE uint16 S9xGetWord (uint32 Address, enum s9xwrap_t w)
|
||||
#else
|
||||
INLINE uint16 S9xGetWord (uint32 Address, enum s9xwrap_t w=WRAP_NONE)
|
||||
#endif
|
||||
{
|
||||
uint32 mask=MEMMAP_MASK&(w==WRAP_PAGE?0xff:(w==WRAP_BANK?0xffff:0xffffff));
|
||||
if ((Address & mask) == mask)
|
||||
{
|
||||
OpenBus=S9xGetByte(Address);
|
||||
switch(w){
|
||||
case WRAP_PAGE:
|
||||
{
|
||||
PC_t a;
|
||||
a.xPBPC = Address;
|
||||
a.B.xPCl++;
|
||||
return (OpenBus | (S9xGetByte (a.xPBPC) << 8));
|
||||
}
|
||||
case WRAP_BANK:
|
||||
{
|
||||
PC_t a;
|
||||
a.xPBPC = Address;
|
||||
a.W.xPC++;
|
||||
return (OpenBus | (S9xGetByte (a.xPBPC) << 8));
|
||||
}
|
||||
case WRAP_NONE:
|
||||
default:
|
||||
return (OpenBus | (S9xGetByte (Address + 1) << 8));
|
||||
}
|
||||
}
|
||||
int block;
|
||||
uint8 *GetAddress = Memory.Map [block = ((Address&0xffffff) >> MEMMAP_SHIFT)];
|
||||
|
||||
if(!CPU.InDMAorHDMA)
|
||||
CPU.Cycles += (Memory.MemorySpeed [block]<<1);
|
||||
|
||||
|
||||
if (GetAddress >= (uint8 *) CMemory::MAP_LAST)
|
||||
{
|
||||
#ifdef CPU_SHUTDOWN
|
||||
if (Memory.BlockIsRAM [block])
|
||||
CPU.WaitAddress = CPU.PBPCAtOpcodeStart;
|
||||
#endif
|
||||
return READ_WORD(GetAddress + (Address & 0xffff));
|
||||
}
|
||||
|
||||
switch ((pint) GetAddress)
|
||||
{
|
||||
case CMemory::MAP_PPU:
|
||||
if(CPU.InDMAorHDMA){
|
||||
OpenBus=S9xGetByte (Address);
|
||||
return (OpenBus | (S9xGetByte (Address + 1) << 8));
|
||||
}
|
||||
return (S9xGetPPU (Address & 0xffff) |
|
||||
(S9xGetPPU ((Address + 1) & 0xffff) << 8));
|
||||
case CMemory::MAP_CPU:
|
||||
return (S9xGetCPU (Address & 0xffff) |
|
||||
(S9xGetCPU ((Address + 1) & 0xffff) << 8));
|
||||
case CMemory::MAP_DSP:
|
||||
#ifdef DSP_DUMMY_LOOPS
|
||||
printf("Get DSP Word @ %06X\n", Address);
|
||||
#endif
|
||||
return (S9xGetDSP (Address & 0xffff) |
|
||||
(S9xGetDSP ((Address + 1) & 0xffff) << 8));
|
||||
case CMemory::MAP_SA1RAM:
|
||||
case CMemory::MAP_LOROM_SRAM:
|
||||
//Address &0x7FFF -offset into bank
|
||||
//Address&0xFF0000 -bank
|
||||
//bank>>1 | offset = s-ram address, unbound
|
||||
//unbound & SRAMMask = Sram offset
|
||||
if(Memory.SRAMMask>=MEMMAP_MASK){
|
||||
return READ_WORD(Memory.SRAM + ((((Address&0xFF0000)>>1) |(Address&0x7FFF)) &Memory.SRAMMask));
|
||||
} else {
|
||||
/* no READ_WORD here, since if Memory.SRAMMask=0x7ff
|
||||
* then the high byte doesn't follow the low byte. */
|
||||
return
|
||||
(*(Memory.SRAM + ((((Address&0xFF0000)>>1) |(Address&0x7FFF)) &Memory.SRAMMask)))|
|
||||
((*(Memory.SRAM + (((((Address+1)&0xFF0000)>>1) |((Address+1)&0x7FFF)) &Memory.SRAMMask)))<<8);
|
||||
}
|
||||
|
||||
case CMemory::MAP_LOROM_SRAM_B:
|
||||
if(Multi.sramMaskB>=MEMMAP_MASK){
|
||||
return READ_WORD(Multi.sramB + ((((Address&0xFF0000)>>1) |(Address&0x7FFF)) &Multi.sramMaskB));
|
||||
} else {
|
||||
return
|
||||
(*(Multi.sramB + ((((Address&0xFF0000)>>1) |(Address&0x7FFF)) &Multi.sramMaskB)))|
|
||||
((*(Multi.sramB + (((((Address+1)&0xFF0000)>>1) |((Address+1)&0x7FFF)) &Multi.sramMaskB)))<<8);
|
||||
}
|
||||
|
||||
case CMemory::MAP_RONLY_SRAM:
|
||||
case CMemory::MAP_HIROM_SRAM:
|
||||
if(Memory.SRAMMask>=MEMMAP_MASK){
|
||||
return READ_WORD(Memory.SRAM +
|
||||
(((Address & 0x7fff) - 0x6000 +
|
||||
((Address & 0xf0000) >> 3)) & Memory.SRAMMask));
|
||||
} else {
|
||||
/* no READ_WORD here, since if Memory.SRAMMask=0x7ff
|
||||
* then the high byte doesn't follow the low byte. */
|
||||
return (*(Memory.SRAM +
|
||||
(((Address & 0x7fff) - 0x6000 +
|
||||
((Address & 0xf0000) >> 3)) & Memory.SRAMMask)) |
|
||||
(*(Memory.SRAM +
|
||||
((((Address + 1) & 0x7fff) - 0x6000 +
|
||||
(((Address + 1) & 0xf0000) >> 3)) & Memory.SRAMMask)) << 8));
|
||||
}
|
||||
|
||||
case CMemory::MAP_BWRAM:
|
||||
return READ_WORD(Memory.BWRAM + ((Address & 0x7fff) - 0x6000));
|
||||
|
||||
case CMemory::MAP_C4:
|
||||
return (S9xGetC4 (Address & 0xffff) |
|
||||
(S9xGetC4 ((Address + 1) & 0xffff) << 8));
|
||||
|
||||
case CMemory::MAP_SPC7110_ROM:
|
||||
#ifdef SPC7110_DEBUG
|
||||
printf("reading spc7110 ROM (word) at %06X\n", Address);
|
||||
#endif
|
||||
return (S9xGetSPC7110Byte(Address)|
|
||||
(S9xGetSPC7110Byte (Address+1))<<8);
|
||||
case CMemory::MAP_SPC7110_DRAM:
|
||||
#ifdef SPC7110_DEBUG
|
||||
printf("reading Bank 50 (word)\n");
|
||||
#endif
|
||||
return (S9xGetSPC7110(0x4800)|
|
||||
(S9xGetSPC7110 (0x4800) << 8));
|
||||
case CMemory::MAP_OBC_RAM:
|
||||
return GetOBC1(Address&0xFFFF)| (GetOBC1((Address+1)&0xFFFF)<<8);
|
||||
|
||||
case CMemory::MAP_SETA_DSP:
|
||||
return S9xGetSetaDSP(Address)| (S9xGetSetaDSP((Address+1))<<8);
|
||||
|
||||
case CMemory::MAP_SETA_RISC:
|
||||
return S9xGetST018(Address)| (S9xGetST018((Address+1))<<8);
|
||||
|
||||
case CMemory::MAP_BSX:
|
||||
return S9xGetBSX(Address)| (S9xGetBSX((Address+1))<<8);
|
||||
|
||||
case CMemory::MAP_DEBUG:
|
||||
#ifdef DEBUGGER
|
||||
printf ("DEBUG R(W) %06x\n", Address);
|
||||
#endif
|
||||
default:
|
||||
case CMemory::MAP_NONE:
|
||||
return (OpenBus | (OpenBus<<8));
|
||||
}
|
||||
}
|
||||
|
||||
INLINE void S9xSetByte (uint8 Byte, uint32 Address)
|
||||
{
|
||||
#if defined(CPU_SHUTDOWN)
|
||||
CPU.WaitAddress = 0xffffffff;
|
||||
#endif
|
||||
int block;
|
||||
uint8 *SetAddress = Memory.WriteMap [block = ((Address&0xffffff) >> MEMMAP_SHIFT)];
|
||||
|
||||
if (!CPU.InDMAorHDMA)
|
||||
CPU.Cycles += Memory.MemorySpeed [block];
|
||||
|
||||
|
||||
if (SetAddress >= (uint8 *) CMemory::MAP_LAST)
|
||||
{
|
||||
#ifdef CPU_SHUTDOWN
|
||||
SetAddress += Address & 0xffff;
|
||||
if (SetAddress == SA1.WaitByteAddress1 ||
|
||||
SetAddress == SA1.WaitByteAddress2)
|
||||
{
|
||||
SA1.Executing = SA1.S9xOpcodes != NULL;
|
||||
SA1.WaitCounter = 0;
|
||||
}
|
||||
*SetAddress = Byte;
|
||||
#else
|
||||
*(SetAddress + (Address & 0xffff)) = Byte;
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
switch ((pint) SetAddress)
|
||||
{
|
||||
case CMemory::MAP_PPU:
|
||||
if(CPU.InDMAorHDMA && (Address&0xff00)==0x2100) return;
|
||||
S9xSetPPU (Byte, Address & 0xffff);
|
||||
return;
|
||||
|
||||
case CMemory::MAP_CPU:
|
||||
S9xSetCPU (Byte, Address & 0xffff);
|
||||
return;
|
||||
|
||||
case CMemory::MAP_DSP:
|
||||
#ifdef DSP_DUMMY_LOOPS
|
||||
printf("DSP Byte: %02X to %06X\n", Byte, Address);
|
||||
#endif
|
||||
S9xSetDSP (Byte, Address & 0xffff);
|
||||
return;
|
||||
|
||||
case CMemory::MAP_LOROM_SRAM:
|
||||
if (Memory.SRAMMask)
|
||||
{
|
||||
*(Memory.SRAM + ((((Address&0xFF0000)>>1)|(Address&0x7FFF))& Memory.SRAMMask))=Byte;
|
||||
CPU.SRAMModified = TRUE;
|
||||
}
|
||||
return;
|
||||
|
||||
case CMemory::MAP_LOROM_SRAM_B:
|
||||
if (Multi.sramMaskB)
|
||||
{
|
||||
*(Multi.sramB + ((((Address&0xFF0000)>>1)|(Address&0x7FFF))& Multi.sramMaskB))=Byte;
|
||||
CPU.SRAMModified = TRUE;
|
||||
}
|
||||
return;
|
||||
|
||||
case CMemory::MAP_HIROM_SRAM:
|
||||
if (Memory.SRAMMask)
|
||||
{
|
||||
*(Memory.SRAM + (((Address & 0x7fff) - 0x6000 +
|
||||
((Address & 0xf0000) >> 3)) & Memory.SRAMMask)) = Byte;
|
||||
CPU.SRAMModified = TRUE;
|
||||
}
|
||||
return;
|
||||
|
||||
case CMemory::MAP_BWRAM:
|
||||
*(Memory.BWRAM + ((Address & 0x7fff) - 0x6000)) = Byte;
|
||||
CPU.SRAMModified = TRUE;
|
||||
return;
|
||||
|
||||
case CMemory::MAP_SA1RAM:
|
||||
*(Memory.SRAM + (Address & 0xffff)) = Byte;
|
||||
SA1.Executing = !SA1.Waiting;
|
||||
break;
|
||||
|
||||
case CMemory::MAP_C4:
|
||||
S9xSetC4 (Byte, Address & 0xffff);
|
||||
return;
|
||||
|
||||
case CMemory::MAP_SPC7110_DRAM:
|
||||
#ifdef SPC7110_DEBUG
|
||||
printf("Writing Byte at %06X\n", Address);
|
||||
#endif
|
||||
s7r.bank50[(Address & 0xffff)]= (uint8) Byte;
|
||||
break;
|
||||
|
||||
case CMemory::MAP_OBC_RAM:
|
||||
SetOBC1(Byte, Address &0xFFFF);
|
||||
return;
|
||||
|
||||
case CMemory::MAP_SETA_DSP:
|
||||
S9xSetSetaDSP(Byte,Address);
|
||||
return;
|
||||
|
||||
case CMemory::MAP_SETA_RISC:
|
||||
S9xSetST018(Byte,Address);
|
||||
return;
|
||||
|
||||
case CMemory::MAP_BSX:
|
||||
S9xSetBSX(Byte,Address);
|
||||
return;
|
||||
|
||||
case CMemory::MAP_DEBUG:
|
||||
#ifdef DEBUGGER
|
||||
printf ("W(B) %06x\n", Address);
|
||||
#endif
|
||||
default:
|
||||
case CMemory::MAP_NONE:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef NO_INLINE_SET_GET
|
||||
INLINE void S9xSetWord (uint16 Word, uint32 Address, enum s9xwrap_t w, enum s9xwriteorder_t o)
|
||||
#else
|
||||
INLINE void S9xSetWord (uint16 Word, uint32 Address, enum s9xwrap_t w=WRAP_NONE, enum s9xwriteorder_t o=WRITE_01)
|
||||
#endif
|
||||
{
|
||||
uint32 mask=MEMMAP_MASK&(w==WRAP_PAGE?0xff:(w==WRAP_BANK?0xffff:0xffffff));
|
||||
if ((Address & mask) == mask)
|
||||
{
|
||||
if(!o) S9xSetByte(Word&0x00FF, Address);
|
||||
switch(w){
|
||||
case WRAP_PAGE:
|
||||
{
|
||||
PC_t a;
|
||||
a.xPBPC = Address;
|
||||
a.B.xPCl++;
|
||||
S9xSetByte(Word>>8, a.xPBPC);
|
||||
}
|
||||
case WRAP_BANK:
|
||||
{
|
||||
PC_t a;
|
||||
a.xPBPC = Address;
|
||||
a.W.xPC++;
|
||||
S9xSetByte(Word>>8, a.xPBPC);
|
||||
}
|
||||
case WRAP_NONE:
|
||||
default:
|
||||
S9xSetByte(Word>>8, Address+1);
|
||||
}
|
||||
if(o) S9xSetByte(Word&0x00FF, Address);
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(CPU_SHUTDOWN)
|
||||
CPU.WaitAddress = 0xffffffff;
|
||||
#endif
|
||||
int block;
|
||||
uint8 *SetAddress = Memory.WriteMap [block = ((Address&0xffffff) >> MEMMAP_SHIFT)];
|
||||
|
||||
if (!CPU.InDMAorHDMA)
|
||||
CPU.Cycles += Memory.MemorySpeed [block] << 1;
|
||||
|
||||
|
||||
if (SetAddress >= (uint8 *) CMemory::MAP_LAST)
|
||||
{
|
||||
#ifdef CPU_SHUTDOWN
|
||||
SetAddress += Address & 0xffff;
|
||||
if (SetAddress == SA1.WaitByteAddress1 ||
|
||||
SetAddress == SA1.WaitByteAddress2)
|
||||
{
|
||||
SA1.Executing = SA1.S9xOpcodes != NULL;
|
||||
SA1.WaitCounter = 0;
|
||||
}
|
||||
WRITE_WORD(SetAddress, Word);
|
||||
#else
|
||||
WRITE_WORD(SetAddress + (Address & 0xffff), Word);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
switch ((pint) SetAddress)
|
||||
{
|
||||
case CMemory::MAP_PPU:
|
||||
if(CPU.InDMAorHDMA){
|
||||
if((Address&0xff00)!=0x2100) S9xSetPPU((uint8)Word, Address&0xffff);
|
||||
if(((Address+1)&0xff00)!=0x2100) S9xSetPPU(Word>>8, (Address+1)&0xffff);
|
||||
return;
|
||||
}
|
||||
if(o){
|
||||
S9xSetPPU (Word >> 8, (Address & 0xffff) + 1);
|
||||
S9xSetPPU ((uint8) Word, Address & 0xffff);
|
||||
} else {
|
||||
S9xSetPPU ((uint8) Word, Address & 0xffff);
|
||||
S9xSetPPU (Word >> 8, (Address & 0xffff) + 1);
|
||||
}
|
||||
return;
|
||||
|
||||
case CMemory::MAP_CPU:
|
||||
if(o){
|
||||
S9xSetCPU (Word >> 8, (Address & 0xffff) + 1);
|
||||
S9xSetCPU ((uint8) Word, (Address & 0xffff));
|
||||
} else {
|
||||
S9xSetCPU ((uint8) Word, (Address & 0xffff));
|
||||
S9xSetCPU (Word >> 8, (Address & 0xffff) + 1);
|
||||
}
|
||||
return;
|
||||
|
||||
case CMemory::MAP_DSP:
|
||||
#ifdef DSP_DUMMY_LOOPS
|
||||
printf("DSP Word: %04X to %06X\n", Word, Address);
|
||||
#endif
|
||||
if(o){
|
||||
S9xSetDSP (Word >> 8, (Address & 0xffff) + 1);
|
||||
S9xSetDSP ((uint8) Word, (Address & 0xffff));
|
||||
} else {
|
||||
S9xSetDSP ((uint8) Word, (Address & 0xffff));
|
||||
S9xSetDSP (Word >> 8, (Address & 0xffff) + 1);
|
||||
}
|
||||
return;
|
||||
|
||||
case CMemory::MAP_LOROM_SRAM:
|
||||
if (Memory.SRAMMask) {
|
||||
if(Memory.SRAMMask>=MEMMAP_MASK){
|
||||
WRITE_WORD(Memory.SRAM + ((((Address&0xFF0000)>>1)|(Address&0x7FFF))&Memory.SRAMMask), Word);
|
||||
} else {
|
||||
/* no WRITE_WORD here, since if Memory.SRAMMask=0x7ff
|
||||
* then the high byte doesn't follow the low byte. */
|
||||
*(Memory.SRAM + ((((Address&0xFF0000)>>1)|(Address&0x7FFF))& Memory.SRAMMask)) = (uint8) Word;
|
||||
*(Memory.SRAM + (((((Address+1)&0xFF0000)>>1)|((Address+1)&0x7FFF))& Memory.SRAMMask)) = Word >> 8;
|
||||
}
|
||||
|
||||
CPU.SRAMModified = TRUE;
|
||||
}
|
||||
return;
|
||||
|
||||
case CMemory::MAP_LOROM_SRAM_B:
|
||||
if (Multi.sramMaskB) {
|
||||
if(Multi.sramMaskB>=MEMMAP_MASK){
|
||||
WRITE_WORD(Multi.sramB + ((((Address&0xFF0000)>>1)|(Address&0x7FFF))&Multi.sramMaskB), Word);
|
||||
} else {
|
||||
*(Multi.sramB + ((((Address&0xFF0000)>>1)|(Address&0x7FFF))& Multi.sramMaskB)) = (uint8) Word;
|
||||
*(Multi.sramB + (((((Address+1)&0xFF0000)>>1)|((Address+1)&0x7FFF))& Multi.sramMaskB)) = Word >> 8;
|
||||
}
|
||||
|
||||
CPU.SRAMModified = TRUE;
|
||||
}
|
||||
return;
|
||||
|
||||
case CMemory::MAP_HIROM_SRAM:
|
||||
if (Memory.SRAMMask) {
|
||||
if(Memory.SRAMMask>=MEMMAP_MASK){
|
||||
WRITE_WORD(Memory.SRAM +
|
||||
(((Address & 0x7fff) - 0x6000 +
|
||||
((Address & 0xf0000) >> 3) & Memory.SRAMMask)), Word);
|
||||
} else {
|
||||
/* no WRITE_WORD here, since if Memory.SRAMMask=0x7ff
|
||||
* then the high byte doesn't follow the low byte. */
|
||||
*(Memory.SRAM +
|
||||
(((Address & 0x7fff) - 0x6000 +
|
||||
((Address & 0xf0000) >> 3) & Memory.SRAMMask))) = (uint8) Word;
|
||||
*(Memory.SRAM +
|
||||
((((Address + 1) & 0x7fff) - 0x6000 +
|
||||
(((Address + 1) & 0xf0000) >> 3) & Memory.SRAMMask))) = (uint8) (Word >> 8);
|
||||
}
|
||||
CPU.SRAMModified = TRUE;
|
||||
}
|
||||
return;
|
||||
|
||||
case CMemory::MAP_BWRAM:
|
||||
WRITE_WORD(Memory.BWRAM + ((Address & 0x7fff) - 0x6000), Word);
|
||||
CPU.SRAMModified = TRUE;
|
||||
return;
|
||||
|
||||
case CMemory::MAP_SPC7110_DRAM:
|
||||
#ifdef SPC7110_DEBUG
|
||||
printf("Writing Word at %06X\n", Address);
|
||||
#endif
|
||||
WRITE_WORD(s7r.bank50+(Address & 0xffff), Word);
|
||||
break;
|
||||
|
||||
case CMemory::MAP_SA1RAM:
|
||||
WRITE_WORD(Memory.SRAM + (Address & 0xffff), Word);
|
||||
SA1.Executing = !SA1.Waiting;
|
||||
break;
|
||||
|
||||
case CMemory::MAP_C4:
|
||||
if(o){
|
||||
S9xSetC4 ((uint8) (Word >> 8), (Address + 1) & 0xffff);
|
||||
S9xSetC4 (Word & 0xff, Address & 0xffff);
|
||||
} else {
|
||||
S9xSetC4 (Word & 0xff, Address & 0xffff);
|
||||
S9xSetC4 ((uint8) (Word >> 8), (Address + 1) & 0xffff);
|
||||
}
|
||||
return;
|
||||
|
||||
case CMemory::MAP_OBC_RAM:
|
||||
if(o){
|
||||
SetOBC1((uint8) (Word >> 8), (Address + 1) & 0xffff);
|
||||
SetOBC1(Word & 0xff, Address &0xFFFF);
|
||||
} else {
|
||||
SetOBC1(Word & 0xff, Address &0xFFFF);
|
||||
SetOBC1 ((uint8) (Word >> 8), (Address + 1) & 0xffff);
|
||||
}
|
||||
return;
|
||||
|
||||
case CMemory::MAP_SETA_DSP:
|
||||
if(o){
|
||||
S9xSetSetaDSP ((uint8) (Word >> 8),(Address + 1));
|
||||
S9xSetSetaDSP (Word & 0xff, Address);
|
||||
} else {
|
||||
S9xSetSetaDSP (Word & 0xff, Address);
|
||||
S9xSetSetaDSP ((uint8) (Word >> 8),(Address + 1));
|
||||
}
|
||||
return;
|
||||
|
||||
case CMemory::MAP_SETA_RISC:
|
||||
if(o){
|
||||
S9xSetST018 ((uint8) (Word >> 8),(Address + 1));
|
||||
S9xSetST018 (Word & 0xff, Address);
|
||||
} else {
|
||||
S9xSetST018 (Word & 0xff, Address);
|
||||
S9xSetST018 ((uint8) (Word >> 8),(Address + 1));
|
||||
}
|
||||
return;
|
||||
|
||||
case CMemory::MAP_BSX:
|
||||
if(o){
|
||||
S9xSetBSX ((uint8) (Word >> 8),(Address + 1));
|
||||
S9xSetBSX (Word & 0xff, Address);
|
||||
} else {
|
||||
S9xSetBSX (Word & 0xff, Address);
|
||||
S9xSetBSX ((uint8) (Word >> 8),(Address + 1));
|
||||
}
|
||||
return;
|
||||
|
||||
case CMemory::MAP_DEBUG:
|
||||
#ifdef DEBUGGER
|
||||
printf ("W(W) %06x\n", Address);
|
||||
#endif
|
||||
default:
|
||||
case CMemory::MAP_NONE:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
INLINE uint8 *GetBasePointer (uint32 Address)
|
||||
{
|
||||
uint8 *GetAddress = Memory.Map [((Address&0xffffff) >> MEMMAP_SHIFT)];
|
||||
if (GetAddress >= (uint8 *) CMemory::MAP_LAST)
|
||||
return (GetAddress);
|
||||
|
||||
switch ((pint) GetAddress)
|
||||
{
|
||||
// case CMemory::MAP_SPC7110_DRAM:
|
||||
#ifdef SPC7110_DEBUG
|
||||
// printf("Getting Base pointer to DRAM\n");
|
||||
#endif
|
||||
// {
|
||||
// return s7r.bank50;
|
||||
// }
|
||||
|
||||
case CMemory::MAP_SPC7110_ROM:
|
||||
#ifdef SPC7110_DEBUG
|
||||
printf("Getting Base pointer to SPC7110ROM\n");
|
||||
#endif
|
||||
return Get7110BasePtr(Address);
|
||||
|
||||
case CMemory::MAP_SA1RAM:
|
||||
return (Memory.SRAM);
|
||||
|
||||
case CMemory::MAP_LOROM_SRAM:
|
||||
if((Memory.SRAMMask&MEMMAP_MASK)!=MEMMAP_MASK) return NULL;
|
||||
return (Memory.SRAM + ((((Address&0xFF0000)>>1)|(Address&0x7FFF)) & Memory.SRAMMask) - (Address&0xffff));
|
||||
|
||||
case CMemory::MAP_LOROM_SRAM_B:
|
||||
if((Multi.sramMaskB&MEMMAP_MASK)!=MEMMAP_MASK) return NULL;
|
||||
return (Multi.sramB + ((((Address&0xFF0000)>>1)|(Address&0x7FFF)) & Multi.sramMaskB) - (Address&0xffff));
|
||||
|
||||
case CMemory::MAP_BWRAM:
|
||||
return (Memory.BWRAM - 0x6000 - (Address&0x8000));
|
||||
|
||||
case CMemory::MAP_HIROM_SRAM:
|
||||
if((Memory.SRAMMask&MEMMAP_MASK)!=MEMMAP_MASK) return NULL;
|
||||
return (Memory.SRAM + (((Address & 0x7fff) - 0x6000 + ((Address & 0xf0000) >> 3)) & Memory.SRAMMask) - (Address&0xffff));
|
||||
|
||||
case CMemory::MAP_C4:
|
||||
return S9xGetBasePointerC4(Address);
|
||||
|
||||
case CMemory::MAP_OBC_RAM:
|
||||
return GetBasePointerOBC1(Address);
|
||||
|
||||
case CMemory::MAP_DEBUG:
|
||||
#ifdef DEBUGGER
|
||||
printf ("GBP %06x\n", Address);
|
||||
#endif
|
||||
default:
|
||||
case CMemory::MAP_NONE:
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
INLINE uint8 *S9xGetMemPointer (uint32 Address)
|
||||
{
|
||||
uint8 *GetAddress = Memory.Map [((Address&0xffffff) >> MEMMAP_SHIFT)];
|
||||
if (GetAddress >= (uint8 *) CMemory::MAP_LAST)
|
||||
return (GetAddress + (Address&0xffff));
|
||||
|
||||
switch ((pint) GetAddress)
|
||||
{
|
||||
// case CMemory::MAP_SPC7110_DRAM:
|
||||
#ifdef SPC7110_DEBUG
|
||||
// printf("Getting Mem pointer to DRAM\n");
|
||||
#endif
|
||||
// {
|
||||
// return s7r.bank50 + (Address&0xffff);
|
||||
// }
|
||||
|
||||
case CMemory::MAP_SPC7110_ROM:
|
||||
#ifdef SPC7110_DEBUG
|
||||
printf("Getting Mem pointer to SPC7110ROM\n");
|
||||
#endif
|
||||
return Get7110BasePtr(Address) + (Address&0xffff);
|
||||
|
||||
case CMemory::MAP_SA1RAM:
|
||||
return (Memory.SRAM + (Address&0xffff));
|
||||
|
||||
case CMemory::MAP_LOROM_SRAM:
|
||||
if((Memory.SRAMMask&MEMMAP_MASK)!=MEMMAP_MASK) return NULL;
|
||||
return (Memory.SRAM + ((((Address&0xFF0000)>>1)|(Address&0x7FFF)) & Memory.SRAMMask));
|
||||
|
||||
case CMemory::MAP_LOROM_SRAM_B:
|
||||
if((Multi.sramMaskB&MEMMAP_MASK)!=MEMMAP_MASK) return NULL;
|
||||
return (Multi.sramB + ((((Address&0xFF0000)>>1)|(Address&0x7FFF)) & Multi.sramMaskB));
|
||||
|
||||
case CMemory::MAP_BWRAM:
|
||||
return (Memory.BWRAM - 0x6000 + (Address&0x7fff));
|
||||
|
||||
case CMemory::MAP_HIROM_SRAM:
|
||||
if((Memory.SRAMMask&MEMMAP_MASK)!=MEMMAP_MASK) return NULL;
|
||||
return (Memory.SRAM + (((Address & 0x7fff) - 0x6000 + ((Address & 0xf0000) >> 3)) & Memory.SRAMMask));
|
||||
|
||||
case CMemory::MAP_C4:
|
||||
return S9xGetBasePointerC4(Address) + (Address&0xffff);
|
||||
|
||||
case CMemory::MAP_OBC_RAM:
|
||||
return GetMemPointerOBC1(Address);
|
||||
|
||||
case CMemory::MAP_DEBUG:
|
||||
#ifdef DEBUGGER
|
||||
printf ("GMP %06x\n", Address);
|
||||
#endif
|
||||
default:
|
||||
case CMemory::MAP_NONE:
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
INLINE void S9xSetPCBase (uint32 Address)
|
||||
{
|
||||
Registers.PBPC = Address & 0xffffff;
|
||||
ICPU.ShiftedPB = Address & 0xff0000;
|
||||
|
||||
int block;
|
||||
uint8 *GetAddress = Memory.Map [block = ((Address&0xffffff) >> MEMMAP_SHIFT)];
|
||||
|
||||
CPU.MemSpeed = Memory.MemorySpeed [block];
|
||||
CPU.MemSpeedx2 = CPU.MemSpeed << 1;
|
||||
|
||||
if (GetAddress >= (uint8 *) CMemory::MAP_LAST){
|
||||
CPU.PCBase = GetAddress;
|
||||
return;
|
||||
}
|
||||
|
||||
switch ((pint) GetAddress)
|
||||
{
|
||||
// case CMemory::MAP_SPC7110_DRAM:
|
||||
#ifdef SPC7110_DEBUG
|
||||
// printf("Getting Base pointer to DRAM\n");
|
||||
#endif
|
||||
// {
|
||||
// CPU.PCBase = s7r.bank50;
|
||||
// return;
|
||||
// }
|
||||
|
||||
case CMemory::MAP_SPC7110_ROM:
|
||||
#ifdef SPC7110_DEBUG
|
||||
printf("Getting Base pointer to SPC7110ROM\n");
|
||||
#endif
|
||||
CPU.PCBase = Get7110BasePtr(Address);
|
||||
return;
|
||||
|
||||
case CMemory::MAP_SA1RAM:
|
||||
CPU.PCBase = Memory.SRAM;
|
||||
return;
|
||||
|
||||
case CMemory::MAP_LOROM_SRAM:
|
||||
if((Memory.SRAMMask&MEMMAP_MASK)!=MEMMAP_MASK){
|
||||
CPU.PCBase = NULL;
|
||||
} else {
|
||||
CPU.PCBase = (Memory.SRAM + ((((Address&0xFF0000)>>1)|(Address&0x7FFF)) & Memory.SRAMMask)) - (Address&0xffff);
|
||||
}
|
||||
return;
|
||||
|
||||
case CMemory::MAP_LOROM_SRAM_B:
|
||||
if((Multi.sramMaskB&MEMMAP_MASK)!=MEMMAP_MASK){
|
||||
CPU.PCBase = NULL;
|
||||
} else {
|
||||
CPU.PCBase = (Multi.sramB + ((((Address&0xFF0000)>>1)|(Address&0x7FFF)) & Multi.sramMaskB)) - (Address&0xffff);
|
||||
}
|
||||
return;
|
||||
|
||||
case CMemory::MAP_BWRAM:
|
||||
CPU.PCBase = (Memory.BWRAM - 0x6000 - (Address&0x8000));
|
||||
return;
|
||||
|
||||
case CMemory::MAP_HIROM_SRAM:
|
||||
if((Memory.SRAMMask&MEMMAP_MASK)!=MEMMAP_MASK){
|
||||
CPU.PCBase = NULL;
|
||||
} else {
|
||||
CPU.PCBase = (Memory.SRAM + (((Address & 0x7fff) - 0x6000 + ((Address & 0xf0000) >> 3)) & Memory.SRAMMask)) - (Address&0xffff);
|
||||
}
|
||||
return;
|
||||
|
||||
case CMemory::MAP_C4:
|
||||
CPU.PCBase = S9xGetBasePointerC4(Address);
|
||||
return;
|
||||
|
||||
case CMemory::MAP_OBC_RAM:
|
||||
CPU.PCBase = GetBasePointerOBC1(Address);
|
||||
return;
|
||||
|
||||
case CMemory::MAP_BSX:
|
||||
CPU.PCBase = S9xGetBasePointerBSX(Address);
|
||||
return;
|
||||
|
||||
case CMemory::MAP_DEBUG:
|
||||
#ifdef DEBUGGER
|
||||
printf ("SBP %06x\n", Address);
|
||||
#endif
|
||||
default:
|
||||
case CMemory::MAP_NONE:
|
||||
CPU.PCBase = NULL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,388 @@
|
||||
/**********************************************************************************
|
||||
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 _GFX_H_
|
||||
#define _GFX_H_
|
||||
|
||||
#include "port.h"
|
||||
#include "snes9x.h"
|
||||
|
||||
struct SGFX{
|
||||
// Initialize these variables
|
||||
uint16 *Screen;
|
||||
uint16 *SubScreen;
|
||||
uint8 *ZBuffer;
|
||||
uint8 *SubZBuffer;
|
||||
uint32 Pitch;
|
||||
uint32 ScreenSize;
|
||||
|
||||
uint16 *S;
|
||||
uint8 *DB;
|
||||
|
||||
// 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];
|
||||
|
||||
#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);
|
||||
#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);
|
||||
};
|
||||
|
||||
struct SLineData {
|
||||
struct {
|
||||
uint16 VOffset;
|
||||
uint16 HOffset;
|
||||
} BG [4];
|
||||
};
|
||||
|
||||
#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 SLineMatrixData
|
||||
{
|
||||
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 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 COLOR_ADD1_2(C1, C2) \
|
||||
(((((C1) & RGB_REMOVE_LOW_BITS_MASK) + \
|
||||
((C2) & RGB_REMOVE_LOW_BITS_MASK)) >> 1) + \
|
||||
((C1) & (C2) & RGB_LOW_BITS_MASK) | ALPHA_BITS_MASK)
|
||||
|
||||
#if defined(OLD_COLOUR_BLENDING)
|
||||
#define COLOR_SUB(C1, C2) \
|
||||
GFX.ZERO_OR_X2 [(((C1) | RGB_HI_BITS_MASKx2) - \
|
||||
((C2) & RGB_REMOVE_LOW_BITS_MASK)) >> 1]
|
||||
#elif !defined(NEW_COLOUR_BLENDING)
|
||||
#define COLOR_SUB(C1, C2) \
|
||||
(GFX.ZERO_OR_X2 [(((C1) | RGB_HI_BITS_MASKx2) - \
|
||||
((C2) & RGB_REMOVE_LOW_BITS_MASK)) >> 1] + \
|
||||
((C1) & RGB_LOW_BITS_MASK) - ((C2) & RGB_LOW_BITS_MASK))
|
||||
#else
|
||||
inline uint16 COLOR_SUB(uint16, uint16);
|
||||
|
||||
inline uint16 COLOR_SUB(uint16 C1, uint16 C2)
|
||||
{
|
||||
uint16 mC1, mC2, v = 0;
|
||||
|
||||
mC1 = C1 & FIRST_COLOR_MASK;
|
||||
mC2 = C2 & FIRST_COLOR_MASK;
|
||||
if (mC1 > mC2) v += (mC1 - mC2);
|
||||
|
||||
mC1 = C1 & SECOND_COLOR_MASK;
|
||||
mC2 = C2 & SECOND_COLOR_MASK;
|
||||
if (mC1 > mC2) v += (mC1 - mC2);
|
||||
|
||||
mC1 = C1 & THIRD_COLOR_MASK;
|
||||
mC2 = C2 & THIRD_COLOR_MASK;
|
||||
if (mC1 > mC2) v += (mC1 - mC2);
|
||||
|
||||
return v;
|
||||
}
|
||||
#endif
|
||||
|
||||
#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
|
||||
|
||||
#ifdef GFX_MULTI_FORMAT
|
||||
bool8 S9xSetRenderPixelFormat (int format);
|
||||
#endif
|
||||
|
||||
END_EXTERN_C
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,393 @@
|
||||
/**********************************************************************************
|
||||
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 "memmap.h"
|
||||
#include "ppu.h"
|
||||
#include "dsp1.h"
|
||||
#include "missing.h"
|
||||
#include "cpuexec.h"
|
||||
#include "debug.h"
|
||||
#include "apu.h"
|
||||
#include "dma.h"
|
||||
#include "fxemu.h"
|
||||
#include "gfx.h"
|
||||
#include "soundux.h"
|
||||
#include "cheats.h"
|
||||
#include "sa1.h"
|
||||
#include "bsx.h"
|
||||
#include "spc7110.h"
|
||||
#ifdef NETPLAY_SUPPORT
|
||||
#include "netplay.h"
|
||||
#endif
|
||||
|
||||
START_EXTERN_C
|
||||
char String[513];
|
||||
|
||||
struct Missing missing;
|
||||
|
||||
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 SDSP1 DSP1;
|
||||
|
||||
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;
|
||||
#endif
|
||||
|
||||
CMemory Memory;
|
||||
|
||||
struct SSNESGameFixes SNESGameFixes;
|
||||
|
||||
unsigned char OpenBus = 0;
|
||||
|
||||
|
||||
END_EXTERN_C
|
||||
|
||||
#ifndef ZSNES_FX
|
||||
struct FxInit_s SuperFX;
|
||||
#else
|
||||
START_EXTERN_C
|
||||
uint8 *SFXPlotTable = NULL;
|
||||
END_EXTERN_C
|
||||
#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;
|
||||
#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] =
|
||||
{
|
||||
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
|
||||
};
|
||||
|
||||
#ifdef NETPLAY_SUPPORT
|
||||
struct SNetPlay NetPlay;
|
||||
#endif
|
||||
|
||||
// Raw SPC700 instruction cycle lengths
|
||||
int32 S9xAPUCycleLengths [256] =
|
||||
{
|
||||
/* 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
|
||||
};
|
||||
|
||||
// Actual data used by CPU emulation, will be scaled by APUReset routine
|
||||
// to be relative to the 65c816 instruction lengths.
|
||||
int32 S9xAPUCycles [256] =
|
||||
{
|
||||
/* 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
|
||||
};
|
||||
|
||||
END_EXTERN_C
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
Copyright (C) 2005-2006 NSRT Team ( http://nsrt.edgeemu.com )
|
||||
Copyright (C) 2002 Andrea Mazzoleni ( http://advancemame.sf.net )
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License version 2.1 as published by the Free Software Foundation.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef __7Z_H
|
||||
#define __7Z_H
|
||||
|
||||
#include "iiostrm.h"
|
||||
|
||||
bool decompress_lzma_7z(ISequentialInStream& in, unsigned in_size, ISequentialOutStream& out, unsigned out_size) throw ();
|
||||
bool decompress_lzma_7z(const unsigned char* in_data, unsigned in_size, unsigned char* out_data, unsigned out_size) throw ();
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
Copyright (C) 2005-2006 NSRT Team ( http://nsrt.edgeemu.com )
|
||||
Copyright (C) 2002 Andrea Mazzoleni ( http://advancemame.sf.net )
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License version 2.1 as published by the Free Software Foundation.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "7z.h"
|
||||
|
||||
#include "lzmadec.h"
|
||||
|
||||
bool decompress_lzma_7z(ISequentialInStream& in, unsigned in_size, ISequentialOutStream& out, unsigned out_size) throw ()
|
||||
{
|
||||
try
|
||||
{
|
||||
NCompress::NLZMA::CDecoder cc;
|
||||
|
||||
UINT64 in_size_l = in_size;
|
||||
UINT64 out_size_l = out_size;
|
||||
|
||||
if (cc.ReadCoderProperties(&in) != S_OK) { return(false); }
|
||||
if (cc.Code(&in, &out, &in_size_l, &out_size_l) != S_OK) { return(false); }
|
||||
if (out.size_get() != out_size || out.overflow_get()) { return(false); }
|
||||
|
||||
return(true);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
|
||||
bool decompress_lzma_7z(const unsigned char* in_data, unsigned int in_size, unsigned char* out_data, unsigned int out_size) throw ()
|
||||
{
|
||||
ISequentialInStream_Array in(reinterpret_cast<const char*>(in_data), in_size);
|
||||
ISequentialOutStream_Array out(reinterpret_cast<char*>(out_data), out_size);
|
||||
|
||||
return(decompress_lzma_7z(in, in_size, out, out_size));
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
#ifndef __COMPRESSION_BITCODER_H
|
||||
#define __COMPRESSION_BITCODER_H
|
||||
|
||||
#include "rngcoder.h"
|
||||
|
||||
namespace NCompression {
|
||||
namespace NArithmetic {
|
||||
|
||||
const int kNumBitModelTotalBits = 11;
|
||||
const UINT32 kBitModelTotal = (1 << kNumBitModelTotalBits);
|
||||
|
||||
const int kNumMoveReducingBits = 2;
|
||||
|
||||
/////////////////////////////
|
||||
// CBitModel
|
||||
|
||||
template <int aNumMoveBits>
|
||||
class CBitModel
|
||||
{
|
||||
public:
|
||||
UINT32 m_Probability;
|
||||
void UpdateModel(UINT32 aSymbol)
|
||||
{
|
||||
/*
|
||||
m_Probability -= (m_Probability + ((aSymbol - 1) & ((1 << aNumMoveBits) - 1))) >> aNumMoveBits;
|
||||
m_Probability += (1 - aSymbol) << (kNumBitModelTotalBits - aNumMoveBits);
|
||||
*/
|
||||
if (aSymbol == 0)
|
||||
m_Probability += (kBitModelTotal - m_Probability) >> aNumMoveBits;
|
||||
else
|
||||
m_Probability -= (m_Probability) >> aNumMoveBits;
|
||||
}
|
||||
public:
|
||||
void Init() { m_Probability = kBitModelTotal / 2; }
|
||||
};
|
||||
|
||||
template <int aNumMoveBits>
|
||||
class CBitDecoder: public CBitModel<aNumMoveBits>
|
||||
{
|
||||
public:
|
||||
UINT32 Decode(CRangeDecoder *aRangeDecoder)
|
||||
{
|
||||
UINT32 aNewBound = (aRangeDecoder->m_Range >> kNumBitModelTotalBits) * CBitModel<aNumMoveBits>::m_Probability;
|
||||
if (aRangeDecoder->m_Code < aNewBound)
|
||||
{
|
||||
aRangeDecoder->m_Range = aNewBound;
|
||||
CBitModel<aNumMoveBits>::m_Probability += (kBitModelTotal - CBitModel<aNumMoveBits>::m_Probability) >> aNumMoveBits;
|
||||
if (aRangeDecoder->m_Range < kTopValue)
|
||||
{
|
||||
aRangeDecoder->m_Code = (aRangeDecoder->m_Code << 8) | aRangeDecoder->m_Stream.ReadByte();
|
||||
aRangeDecoder->m_Range <<= 8;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
aRangeDecoder->m_Range -= aNewBound;
|
||||
aRangeDecoder->m_Code -= aNewBound;
|
||||
CBitModel<aNumMoveBits>::m_Probability -= (CBitModel<aNumMoveBits>::m_Probability) >> aNumMoveBits;
|
||||
if (aRangeDecoder->m_Range < kTopValue)
|
||||
{
|
||||
aRangeDecoder->m_Code = (aRangeDecoder->m_Code << 8) | aRangeDecoder->m_Stream.ReadByte();
|
||||
aRangeDecoder->m_Range <<= 8;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
Copyright (C) 2002 Andrea Mazzoleni ( http://advancemame.sf.net )
|
||||
Copyright (C) 2001-4 Igor Pavlov ( http://www.7-zip.org )
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License version 2.1 as published by the Free Software Foundation.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef __ARICONST_H
|
||||
#define __ARICONST_H
|
||||
|
||||
#include "aribitcd.h"
|
||||
|
||||
|
||||
typedef NCompression::NArithmetic::CRangeDecoder CMyRangeDecoder;
|
||||
template <int aNumMoveBits> class CMyBitDecoder:
|
||||
public NCompression::NArithmetic::CBitDecoder<aNumMoveBits> {};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,12 @@
|
||||
#ifndef __COMPRESSION_ARIPRICE_H
|
||||
#define __COMPRESSION_ARIPRICE_H
|
||||
|
||||
namespace NCompression {
|
||||
namespace NArithmetic {
|
||||
|
||||
const UINT32 kNumBitPriceShiftBits = 6;
|
||||
const UINT32 kBitPrice = 1 << kNumBitPriceShiftBits;
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
Copyright (C) 2002 Andrea Mazzoleni ( http://advancemame.sf.net )
|
||||
Copyright (C) 2001-4 Igor Pavlov ( http://www.7-zip.org )
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License version 2.1 as published by the Free Software Foundation.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef __BITTREECODER_H
|
||||
#define __BITTREECODER_H
|
||||
|
||||
#include "aribitcd.h"
|
||||
#include "rcdefs.h"
|
||||
|
||||
|
||||
//////////////////////////
|
||||
// CBitTreeDecoder
|
||||
|
||||
template <int aNumMoveBits, UINT32 m_NumBitLevels>
|
||||
class CBitTreeDecoder
|
||||
{
|
||||
CMyBitDecoder<aNumMoveBits> m_Models[1 << m_NumBitLevels];
|
||||
public:
|
||||
void Init()
|
||||
{
|
||||
for(UINT32 i = 1; i < (1 << m_NumBitLevels); i++)
|
||||
m_Models[i].Init();
|
||||
}
|
||||
UINT32 Decode(CMyRangeDecoder *aRangeDecoder)
|
||||
{
|
||||
UINT32 aModelIndex = 1;
|
||||
RC_INIT_VAR
|
||||
for(UINT32 aBitIndex = m_NumBitLevels; aBitIndex > 0; aBitIndex--)
|
||||
{
|
||||
// aModelIndex = (aModelIndex << 1) + m_Models[aModelIndex].Decode(aRangeDecoder);
|
||||
RC_GETBIT(aNumMoveBits, m_Models[aModelIndex].m_Probability, aModelIndex)
|
||||
}
|
||||
RC_FLUSH_VAR
|
||||
return aModelIndex - (1 << m_NumBitLevels);
|
||||
};
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
// CReverseBitTreeDecoder
|
||||
|
||||
template <int aNumMoveBits>
|
||||
class CReverseBitTreeDecoder2
|
||||
{
|
||||
CMyBitDecoder<aNumMoveBits> *m_Models;
|
||||
UINT32 m_NumBitLevels;
|
||||
public:
|
||||
CReverseBitTreeDecoder2(): m_Models(0) { }
|
||||
~CReverseBitTreeDecoder2() { delete []m_Models; }
|
||||
bool Create(UINT32 aNumBitLevels)
|
||||
{
|
||||
m_NumBitLevels = aNumBitLevels;
|
||||
m_Models = new CMyBitDecoder<aNumMoveBits>[1 << aNumBitLevels];
|
||||
return (m_Models != 0);
|
||||
}
|
||||
void Init()
|
||||
{
|
||||
UINT32 aNumModels = 1 << m_NumBitLevels;
|
||||
for(UINT32 i = 1; i < aNumModels; i++)
|
||||
m_Models[i].Init();
|
||||
}
|
||||
UINT32 Decode(CMyRangeDecoder *aRangeDecoder)
|
||||
{
|
||||
UINT32 aModelIndex = 1;
|
||||
UINT32 aSymbol = 0;
|
||||
RC_INIT_VAR
|
||||
for(UINT32 aBitIndex = 0; aBitIndex < m_NumBitLevels; aBitIndex++)
|
||||
{
|
||||
// UINT32 aBit = m_Models[aModelIndex].Decode(aRangeDecoder);
|
||||
// aModelIndex <<= 1;
|
||||
// aModelIndex += aBit;
|
||||
// aSymbol |= (aBit << aBitIndex);
|
||||
RC_GETBIT2(aNumMoveBits, m_Models[aModelIndex].m_Probability, aModelIndex, ; , aSymbol |= (1 << aBitIndex))
|
||||
}
|
||||
RC_FLUSH_VAR
|
||||
return aSymbol;
|
||||
};
|
||||
};
|
||||
////////////////////////////
|
||||
// CReverseBitTreeDecoder2
|
||||
|
||||
template <int aNumMoveBits, UINT32 m_NumBitLevels>
|
||||
class CReverseBitTreeDecoder
|
||||
{
|
||||
CMyBitDecoder<aNumMoveBits> m_Models[1 << m_NumBitLevels];
|
||||
public:
|
||||
void Init()
|
||||
{
|
||||
for(UINT32 i = 1; i < (1 << m_NumBitLevels); i++)
|
||||
m_Models[i].Init();
|
||||
}
|
||||
UINT32 Decode(CMyRangeDecoder *aRangeDecoder)
|
||||
{
|
||||
UINT32 aModelIndex = 1;
|
||||
UINT32 aSymbol = 0;
|
||||
RC_INIT_VAR
|
||||
for(UINT32 aBitIndex = 0; aBitIndex < m_NumBitLevels; aBitIndex++)
|
||||
{
|
||||
// UINT32 aBit = m_Models[aModelIndex].Decode(aRangeDecoder);
|
||||
// aModelIndex <<= 1;
|
||||
// aModelIndex += aBit;
|
||||
// aSymbol |= (aBit << aBitIndex);
|
||||
RC_GETBIT2(aNumMoveBits, m_Models[aModelIndex].m_Probability, aModelIndex, ; , aSymbol |= (1 << aBitIndex))
|
||||
}
|
||||
RC_FLUSH_VAR
|
||||
return aSymbol;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
Copyright (C) 2004-2006 NSRT Team ( http://nsrt.edgeemu.com )
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
version 2 as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
namespace CRC32lib
|
||||
{
|
||||
//Don't ask questions, this is the PKZip CRC32 table
|
||||
const unsigned int crc32Table[256] = {
|
||||
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
|
||||
0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
|
||||
0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,
|
||||
0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
|
||||
0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
|
||||
0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
|
||||
0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c,
|
||||
0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
|
||||
0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423,
|
||||
0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
|
||||
0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106,
|
||||
0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
|
||||
0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d,
|
||||
0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
|
||||
0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
|
||||
0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
|
||||
0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7,
|
||||
0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
|
||||
0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa,
|
||||
0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
|
||||
0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81,
|
||||
0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
|
||||
0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84,
|
||||
0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
|
||||
0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
|
||||
0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
|
||||
0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e,
|
||||
0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
|
||||
0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55,
|
||||
0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
|
||||
0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28,
|
||||
0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
|
||||
0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f,
|
||||
0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
|
||||
0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
|
||||
0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
|
||||
0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69,
|
||||
0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
|
||||
0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc,
|
||||
0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
|
||||
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693,
|
||||
0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
|
||||
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d };
|
||||
|
||||
|
||||
//CRC32 for char arrays
|
||||
unsigned int CRC32(const unsigned char *array, size_t size, register unsigned int crc32)
|
||||
{
|
||||
const unsigned char *end_p = array+size;
|
||||
for (register const unsigned char *p = array; p < end_p; p++)
|
||||
{
|
||||
crc32 = ((crc32 >> 8) & 0x00FFFFFF) ^ crc32Table[(crc32 ^ *p) & 0xFF];
|
||||
}
|
||||
|
||||
return(~crc32);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
Copyright (C) 2004-2006 NSRT Team ( http://nsrt.edgeemu.com )
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
version 2 as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef CRC32_H
|
||||
#define CRC32_H
|
||||
|
||||
namespace CRC32lib
|
||||
{
|
||||
unsigned int CRC32(const unsigned char *, size_t, register unsigned int crc32 = 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
Copyright (C) 2005-2006 NSRT Team ( http://nsrt.edgeemu.com )
|
||||
Copyright (C) 2002 Andrea Mazzoleni ( http://advancemame.sf.net )
|
||||
Copyright (C) 2001-4 Igor Pavlov ( http://www.7-zip.org )
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License version 2.1 as published by the Free Software Foundation.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "portable.h"
|
||||
#include "iiostrm.h"
|
||||
#include "crc32.h"
|
||||
|
||||
HRESULT ISequentialInStream_Array::Read(void *aData, UINT32 aSize, UINT32 *aProcessedSize)
|
||||
{
|
||||
if (aSize > size)
|
||||
{
|
||||
aSize = size;
|
||||
}
|
||||
|
||||
*aProcessedSize = aSize;
|
||||
memcpy(aData, data, aSize);
|
||||
size -= aSize;
|
||||
data += aSize;
|
||||
return(S_OK);
|
||||
}
|
||||
|
||||
HRESULT ISequentialOutStream_Array::Write(const void *aData, UINT32 aSize, UINT32 *aProcessedSize)
|
||||
{
|
||||
if (aSize > size)
|
||||
{
|
||||
overflow = true;
|
||||
aSize = size;
|
||||
}
|
||||
|
||||
*aProcessedSize = aSize;
|
||||
memcpy(data, aData, aSize);
|
||||
size -= aSize;
|
||||
data += aSize;
|
||||
total += aSize;
|
||||
return(S_OK);
|
||||
}
|
||||
|
||||
HRESULT ISequentialInStream_String::Read(void *aData, UINT32 aSize, UINT32 *aProcessedSize)
|
||||
{
|
||||
if (aSize > data.size())
|
||||
{
|
||||
aSize = data.size();
|
||||
}
|
||||
|
||||
*aProcessedSize = aSize;
|
||||
memcpy(aData, data.c_str(), aSize);
|
||||
data.erase(0, aSize);
|
||||
return(S_OK);
|
||||
}
|
||||
|
||||
HRESULT ISequentialOutStream_String::Write(const void *aData, UINT32 aSize, UINT32 *aProcessedSize)
|
||||
{
|
||||
*aProcessedSize = aSize;
|
||||
data.append((const char *)aData, aSize);
|
||||
total += aSize;
|
||||
return(S_OK);
|
||||
}
|
||||
|
||||
HRESULT ISequentialInStream_Istream::Read(void *aData, UINT32 aSize, UINT32 *aProcessedSize)
|
||||
{
|
||||
data.read((char *)aData, aSize);
|
||||
*aProcessedSize = data.gcount();
|
||||
return(S_OK);
|
||||
}
|
||||
|
||||
HRESULT ISequentialOutStream_Ostream::Write(const void *aData, UINT32 aSize, UINT32 *aProcessedSize)
|
||||
{
|
||||
*aProcessedSize = aSize;
|
||||
data.write((char *)aData, aSize);
|
||||
total += aSize;
|
||||
return(S_OK);
|
||||
}
|
||||
|
||||
|
||||
|
||||
HRESULT ISequentialInStreamCRC32_Array::Read(void *aData, UINT32 aSize, UINT32 *aProcessedSize)
|
||||
{
|
||||
ISequentialInStream_Array::Read(aData, aSize, aProcessedSize);
|
||||
crc32 = CRC32lib::CRC32((const unsigned char *)aData, *aProcessedSize, ~crc32);
|
||||
return(S_OK);
|
||||
}
|
||||
|
||||
HRESULT ISequentialOutStreamCRC32_Array::Write(const void *aData, UINT32 aSize, UINT32 *aProcessedSize)
|
||||
{
|
||||
ISequentialOutStream_Array::Write(aData, aSize, aProcessedSize);
|
||||
crc32 = CRC32lib::CRC32((const unsigned char *)aData, *aProcessedSize, ~crc32);
|
||||
return(S_OK);
|
||||
}
|
||||
|
||||
HRESULT ISequentialInStreamCRC32_String::Read(void *aData, UINT32 aSize, UINT32 *aProcessedSize)
|
||||
{
|
||||
ISequentialInStream_String::Read(aData, aSize, aProcessedSize);
|
||||
crc32 = CRC32lib::CRC32((const unsigned char *)aData, *aProcessedSize, ~crc32);
|
||||
return(S_OK);
|
||||
}
|
||||
|
||||
HRESULT ISequentialOutStreamCRC32_String::Write(const void *aData, UINT32 aSize, UINT32 *aProcessedSize)
|
||||
{
|
||||
ISequentialOutStream_String::Write(aData, aSize, aProcessedSize);
|
||||
crc32 = CRC32lib::CRC32((const unsigned char *)aData, *aProcessedSize, ~crc32);
|
||||
return(S_OK);
|
||||
}
|
||||
|
||||
HRESULT ISequentialInStreamCRC32_Istream::Read(void *aData, UINT32 aSize, UINT32 *aProcessedSize)
|
||||
{
|
||||
ISequentialInStream_Istream::Read(aData, aSize, aProcessedSize);
|
||||
crc32 = CRC32lib::CRC32((const unsigned char *)aData, *aProcessedSize, ~crc32);
|
||||
return(S_OK);
|
||||
}
|
||||
|
||||
HRESULT ISequentialOutStreamCRC32_Ostream::Write(const void *aData, UINT32 aSize, UINT32 *aProcessedSize)
|
||||
{
|
||||
ISequentialOutStream_Ostream::Write(aData, aSize, aProcessedSize);
|
||||
crc32 = CRC32lib::CRC32((const unsigned char *)aData, *aProcessedSize, ~crc32);
|
||||
return(S_OK);
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
/*
|
||||
Copyright (C) 2005-2006 NSRT Team ( http://nsrt.edgeemu.com )
|
||||
Copyright (C) 2002 Andrea Mazzoleni ( http://advancemame.sf.net )
|
||||
Copyright (C) 2001-4 Igor Pavlov ( http://www.7-zip.org )
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License version 2.1 as published by the Free Software Foundation.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef __IINOUTSTREAMS_H
|
||||
#define __IINOUTSTREAMS_H
|
||||
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
|
||||
#include "portable.h"
|
||||
|
||||
|
||||
class ISequentialInStream
|
||||
{
|
||||
public:
|
||||
virtual HRESULT Read(void *, UINT32, UINT32 *) = 0;
|
||||
|
||||
virtual ~ISequentialInStream() {}
|
||||
};
|
||||
|
||||
|
||||
class ISequentialInStream_Array : public ISequentialInStream
|
||||
{
|
||||
const char *data;
|
||||
unsigned int size;
|
||||
public:
|
||||
ISequentialInStream_Array(const char *Adata, unsigned Asize) : data(Adata), size(Asize) { }
|
||||
|
||||
HRESULT Read(void *aData, UINT32 aSize, UINT32 *aProcessedSize);
|
||||
|
||||
virtual ~ISequentialInStream_Array() {}
|
||||
};
|
||||
|
||||
class ISequentialInStream_String : public ISequentialInStream
|
||||
{
|
||||
std::string& data;
|
||||
public:
|
||||
ISequentialInStream_String(std::string& Adata) : data(Adata) { }
|
||||
|
||||
HRESULT Read(void *aData, UINT32 aSize, UINT32 *aProcessedSize);
|
||||
|
||||
virtual ~ISequentialInStream_String() {}
|
||||
};
|
||||
|
||||
class ISequentialInStream_Istream : public ISequentialInStream
|
||||
{
|
||||
std::istream& data;
|
||||
public:
|
||||
ISequentialInStream_Istream(std::istream& Adata) : data(Adata) { }
|
||||
|
||||
HRESULT Read(void *aData, UINT32 aSize, UINT32 *aProcessedSize);
|
||||
|
||||
virtual ~ISequentialInStream_Istream() {}
|
||||
};
|
||||
|
||||
|
||||
|
||||
class ISequentialOutStream
|
||||
{
|
||||
public:
|
||||
virtual bool overflow_get() const = 0;
|
||||
virtual unsigned int size_get() const = 0;
|
||||
|
||||
virtual HRESULT Write(const void *, UINT32, UINT32 *) = 0;
|
||||
|
||||
virtual ~ISequentialOutStream() {}
|
||||
};
|
||||
|
||||
|
||||
class ISequentialOutStream_Array : public ISequentialOutStream
|
||||
{
|
||||
char *data;
|
||||
unsigned int size;
|
||||
bool overflow;
|
||||
unsigned int total;
|
||||
public:
|
||||
ISequentialOutStream_Array(char *Adata, unsigned Asize) : data(Adata), size(Asize), overflow(false), total(0) { }
|
||||
|
||||
bool overflow_get() const { return(overflow); }
|
||||
unsigned int size_get() const { return(total); }
|
||||
|
||||
HRESULT Write(const void *aData, UINT32 aSize, UINT32 *aProcessedSize);
|
||||
|
||||
virtual ~ISequentialOutStream_Array() {}
|
||||
};
|
||||
|
||||
class ISequentialOutStream_String : public ISequentialOutStream
|
||||
{
|
||||
std::string& data;
|
||||
unsigned int total;
|
||||
public:
|
||||
ISequentialOutStream_String(std::string& Adata) : data(Adata), total(0) { }
|
||||
|
||||
bool overflow_get() const { return(false); }
|
||||
unsigned int size_get() const { return(total); }
|
||||
|
||||
HRESULT Write(const void *aData, UINT32 aSize, UINT32 *aProcessedSize);
|
||||
|
||||
virtual ~ISequentialOutStream_String() {}
|
||||
};
|
||||
|
||||
|
||||
class ISequentialOutStream_Ostream : public ISequentialOutStream
|
||||
{
|
||||
std::ostream& data;
|
||||
unsigned int total;
|
||||
public:
|
||||
ISequentialOutStream_Ostream(std::ostream& Adata) : data(Adata), total(0) { }
|
||||
|
||||
bool overflow_get() const { return(false); }
|
||||
unsigned int size_get() const { return(total); }
|
||||
|
||||
HRESULT Write(const void *aData, UINT32 aSize, UINT32 *aProcessedSize);
|
||||
|
||||
virtual ~ISequentialOutStream_Ostream() {}
|
||||
};
|
||||
|
||||
|
||||
|
||||
class ISequentialStreamCRC32
|
||||
{
|
||||
protected:
|
||||
unsigned int crc32;
|
||||
public:
|
||||
ISequentialStreamCRC32() : crc32(0) {}
|
||||
unsigned int crc32_get() const { return(crc32); }
|
||||
|
||||
virtual ~ISequentialStreamCRC32() {}
|
||||
};
|
||||
|
||||
|
||||
class ISequentialInStreamCRC32_Array : public ISequentialInStream_Array, public ISequentialStreamCRC32
|
||||
{
|
||||
public:
|
||||
ISequentialInStreamCRC32_Array(const char *Adata, unsigned Asize) : ISequentialInStream_Array(Adata, Asize) { }
|
||||
|
||||
HRESULT Read(void *aData, UINT32 aSize, UINT32 *aProcessedSize);
|
||||
|
||||
virtual ~ISequentialInStreamCRC32_Array() {}
|
||||
};
|
||||
|
||||
class ISequentialInStreamCRC32_String : public ISequentialInStream_String, public ISequentialStreamCRC32
|
||||
{
|
||||
public:
|
||||
ISequentialInStreamCRC32_String(std::string& Adata) : ISequentialInStream_String(Adata) { }
|
||||
|
||||
HRESULT Read(void *aData, UINT32 aSize, UINT32 *aProcessedSize);
|
||||
|
||||
virtual ~ISequentialInStreamCRC32_String() {}
|
||||
};
|
||||
|
||||
class ISequentialInStreamCRC32_Istream : public ISequentialInStream_Istream, public ISequentialStreamCRC32
|
||||
{
|
||||
public:
|
||||
ISequentialInStreamCRC32_Istream(std::istream& Adata) : ISequentialInStream_Istream(Adata) { }
|
||||
|
||||
HRESULT Read(void *aData, UINT32 aSize, UINT32 *aProcessedSize);
|
||||
|
||||
virtual ~ISequentialInStreamCRC32_Istream() {}
|
||||
};
|
||||
|
||||
|
||||
class ISequentialOutStreamCRC32_Array : public ISequentialOutStream_Array, public ISequentialStreamCRC32
|
||||
{
|
||||
public:
|
||||
ISequentialOutStreamCRC32_Array(char *Adata, unsigned Asize) : ISequentialOutStream_Array(Adata, Asize) { }
|
||||
|
||||
HRESULT Write(const void *aData, UINT32 aSize, UINT32 *aProcessedSize);
|
||||
|
||||
virtual ~ISequentialOutStreamCRC32_Array() {}
|
||||
};
|
||||
|
||||
class ISequentialOutStreamCRC32_String : public ISequentialOutStream_String, public ISequentialStreamCRC32
|
||||
{
|
||||
public:
|
||||
ISequentialOutStreamCRC32_String(std::string& Adata) : ISequentialOutStream_String(Adata) { }
|
||||
|
||||
HRESULT Write(const void *aData, UINT32 aSize, UINT32 *aProcessedSize);
|
||||
|
||||
virtual ~ISequentialOutStreamCRC32_String() {}
|
||||
};
|
||||
|
||||
|
||||
class ISequentialOutStreamCRC32_Ostream : public ISequentialOutStream_Ostream, public ISequentialStreamCRC32
|
||||
{
|
||||
public:
|
||||
ISequentialOutStreamCRC32_Ostream(std::ostream& Adata) : ISequentialOutStream_Ostream(Adata) { }
|
||||
|
||||
HRESULT Write(const void *aData, UINT32 aSize, UINT32 *aProcessedSize);
|
||||
|
||||
virtual ~ISequentialOutStreamCRC32_Ostream() {}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
Copyright (C) 2005-2006 NSRT Team ( http://nsrt.edgeemu.com )
|
||||
Copyright (C) 2002 Andrea Mazzoleni ( http://advancemame.sf.net )
|
||||
Copyright (C) 2001-4 Igor Pavlov ( http://www.7-zip.org )
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License version 2.1 as published by the Free Software Foundation.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "inbyte.h"
|
||||
|
||||
namespace NStream{
|
||||
|
||||
CInByte::CInByte(UINT32 aBufferSize):
|
||||
m_BufferBase(0),
|
||||
m_BufferSize(aBufferSize)
|
||||
{
|
||||
m_BufferBase = new BYTE[m_BufferSize];
|
||||
}
|
||||
|
||||
CInByte::~CInByte()
|
||||
{
|
||||
delete []m_BufferBase;
|
||||
}
|
||||
|
||||
void CInByte::Init(ISequentialInStream *aStream)
|
||||
{
|
||||
m_Stream = aStream;
|
||||
m_ProcessedSize = 0;
|
||||
m_Buffer = m_BufferBase;
|
||||
m_BufferLimit = m_Buffer;
|
||||
m_StreamWasExhausted = false;
|
||||
}
|
||||
|
||||
bool CInByte::ReadBlock()
|
||||
{
|
||||
if (m_StreamWasExhausted)
|
||||
return false;
|
||||
m_ProcessedSize += (m_Buffer - m_BufferBase);
|
||||
UINT32 aNumProcessedBytes;
|
||||
HRESULT aResult = m_Stream->Read(m_BufferBase, m_BufferSize, &aNumProcessedBytes);
|
||||
if (aResult != S_OK)
|
||||
throw aResult;
|
||||
m_Buffer = m_BufferBase;
|
||||
m_BufferLimit = m_Buffer + aNumProcessedBytes;
|
||||
m_StreamWasExhausted = (aNumProcessedBytes == 0);
|
||||
return (!m_StreamWasExhausted);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
Copyright (C) 2002 Andrea Mazzoleni ( http://advancemame.sf.net )
|
||||
Copyright (C) 2001-4 Igor Pavlov ( http://www.7-zip.org )
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License version 2.1 as published by the Free Software Foundation.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef __STREAM_INBYTE_H
|
||||
#define __STREAM_INBYTE_H
|
||||
|
||||
#include "iiostrm.h"
|
||||
|
||||
namespace NStream {
|
||||
|
||||
class CInByte
|
||||
{
|
||||
UINT64 m_ProcessedSize;
|
||||
BYTE *m_BufferBase;
|
||||
UINT32 m_BufferSize;
|
||||
BYTE *m_Buffer;
|
||||
BYTE *m_BufferLimit;
|
||||
ISequentialInStream* m_Stream;
|
||||
bool m_StreamWasExhausted;
|
||||
|
||||
bool ReadBlock();
|
||||
|
||||
public:
|
||||
CInByte(UINT32 aBufferSize = 0x100000);
|
||||
~CInByte();
|
||||
|
||||
void Init(ISequentialInStream *aStream);
|
||||
|
||||
bool ReadByte(BYTE &aByte)
|
||||
{
|
||||
if(m_Buffer >= m_BufferLimit)
|
||||
if(!ReadBlock())
|
||||
return false;
|
||||
aByte = *m_Buffer++;
|
||||
return true;
|
||||
}
|
||||
BYTE ReadByte()
|
||||
{
|
||||
if(m_Buffer >= m_BufferLimit)
|
||||
if(!ReadBlock())
|
||||
return 0x0;
|
||||
return *m_Buffer++;
|
||||
}
|
||||
void ReadBytes(void *aData, UINT32 aSize, UINT32 &aProcessedSize)
|
||||
{
|
||||
for(aProcessedSize = 0; aProcessedSize < aSize; aProcessedSize++)
|
||||
if (!ReadByte(((BYTE *)aData)[aProcessedSize]))
|
||||
return;
|
||||
}
|
||||
bool ReadBytes(void *aData, UINT32 aSize)
|
||||
{
|
||||
UINT32 aProcessedSize;
|
||||
ReadBytes(aData, aSize, aProcessedSize);
|
||||
return (aProcessedSize == aSize);
|
||||
}
|
||||
UINT64 GetProcessedSize() const { return m_ProcessedSize + (m_Buffer - m_BufferBase); }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,550 @@
|
||||
/*
|
||||
Copyright (C) 2005-2006 NSRT Team ( http://nsrt.edgeemu.com )
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
version 2 as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <sstream>
|
||||
#include "jma.h"
|
||||
using namespace std;
|
||||
|
||||
#include "portable.h"
|
||||
#include "7z.h"
|
||||
#include "crc32.h"
|
||||
|
||||
namespace JMA
|
||||
{
|
||||
const char jma_magic[] = { 'J', 'M', 'A', 0, 'N' };
|
||||
const unsigned int jma_header_length = 5;
|
||||
const unsigned char jma_version = 1;
|
||||
const unsigned int jma_version_length = 1;
|
||||
const unsigned int jma_total_header_length = jma_header_length + jma_version_length + UINT_SIZE;
|
||||
|
||||
//Convert DOS/zip/JMA integer time to to time_t
|
||||
time_t uint_to_time(unsigned short date, unsigned short time)
|
||||
{
|
||||
tm formatted_time;
|
||||
|
||||
formatted_time.tm_mday = date & 0x1F;
|
||||
formatted_time.tm_mon = ((date >> 5) & 0xF) - 1;
|
||||
formatted_time.tm_year = ((date >> 9) & 0x7f) + 80;
|
||||
formatted_time.tm_sec = (time & 0x1F) * 2;
|
||||
formatted_time.tm_min = (time >> 5) & 0x3F;
|
||||
formatted_time.tm_hour = (time >> 11) & 0x1F;
|
||||
|
||||
return(mktime(&formatted_time));
|
||||
}
|
||||
|
||||
|
||||
//Retreive the file block, what else?
|
||||
void jma_open::retrieve_file_block() throw(jma_errors)
|
||||
{
|
||||
unsigned char uint_buffer[UINT_SIZE];
|
||||
unsigned char ushort_buffer[USHORT_SIZE];
|
||||
|
||||
//File block size is the last UINT in the file
|
||||
stream.seekg(-UINT_SIZE,ios::end);
|
||||
stream.read((char *)uint_buffer, UINT_SIZE);
|
||||
size_t file_block_size = charp_to_uint(uint_buffer);
|
||||
|
||||
//Currently at the end of the file, so that's the file size
|
||||
size_t jma_file_size = stream.tellg();
|
||||
|
||||
//The file block can't be larger than the JMA file without it's header.
|
||||
//This if can probably be improved
|
||||
if (file_block_size >= jma_file_size-jma_total_header_length)
|
||||
{
|
||||
throw(JMA_BAD_FILE);
|
||||
}
|
||||
|
||||
//Seek to before file block so we can read the file block
|
||||
stream.seekg(-((int)file_block_size+UINT_SIZE),ios::end);
|
||||
|
||||
//This is needed if the file block is compressed
|
||||
stringstream decompressed_file_block;
|
||||
//Pointer to where to read file block from (file or decompressed buffer)
|
||||
istream *file_block_stream;
|
||||
|
||||
//Setup file info buffer and byte to read with
|
||||
jma_file_info file_info;
|
||||
char byte;
|
||||
|
||||
stream.get(byte);
|
||||
if (!byte) //If file block is compressed
|
||||
{
|
||||
//Compressed size isn't counting the byte we just read or the UINT for compressed size
|
||||
size_t compressed_size = file_block_size - (1+UINT_SIZE);
|
||||
|
||||
//Read decompressed size / true file block size
|
||||
stream.read((char *)uint_buffer, UINT_SIZE);
|
||||
file_block_size = charp_to_uint(uint_buffer);
|
||||
|
||||
//Setup access methods for decompression
|
||||
ISequentialInStream_Istream compressed_data(stream);
|
||||
ISequentialOutStream_Ostream decompressed_data(decompressed_file_block);
|
||||
|
||||
//Decompress the data
|
||||
if (!decompress_lzma_7z(compressed_data, compressed_size, decompressed_data, file_block_size))
|
||||
{
|
||||
throw(JMA_DECOMPRESS_FAILED);
|
||||
}
|
||||
|
||||
//Go to beginning, setup pointer to buffer
|
||||
decompressed_file_block.seekg(0, ios::beg);
|
||||
file_block_stream = &decompressed_file_block;
|
||||
}
|
||||
else
|
||||
{
|
||||
stream.putback(byte); //Putback byte, byte is part of filename, not compressed indicator
|
||||
file_block_stream = &stream;
|
||||
}
|
||||
|
||||
|
||||
//Minimum file name length is 2 bytes, a char and a null
|
||||
//Minimum comment length is 1 byte, a null
|
||||
//There are currently 2 UINTs and 2 USHORTs per file
|
||||
while (file_block_size >= 2+1+UINT_SIZE*2+USHORT_SIZE*2) //This does allow for a gap, but that's okay
|
||||
{
|
||||
//First stored in the file block is the file name null terminated
|
||||
file_info.name = "";
|
||||
|
||||
file_block_stream->get(byte);
|
||||
while (byte)
|
||||
{
|
||||
file_info.name += byte;
|
||||
file_block_stream->get(byte);
|
||||
}
|
||||
|
||||
//There must be a file name or the file is bad
|
||||
if (!file_info.name.length())
|
||||
{
|
||||
throw(JMA_BAD_FILE);
|
||||
}
|
||||
|
||||
//Same trick as above for the comment
|
||||
file_info.comment = "";
|
||||
|
||||
file_block_stream->get(byte);
|
||||
while (byte)
|
||||
{
|
||||
file_info.comment += byte;
|
||||
file_block_stream->get(byte);
|
||||
}
|
||||
|
||||
//Next is a UINT representing the file's size
|
||||
file_block_stream->read((char *)uint_buffer, UINT_SIZE);
|
||||
file_info.size = charp_to_uint(uint_buffer);
|
||||
|
||||
//Followed by CRC32
|
||||
file_block_stream->read((char *)uint_buffer, UINT_SIZE);
|
||||
file_info.crc32 = charp_to_uint(uint_buffer);
|
||||
|
||||
//Special USHORT representation of file's date
|
||||
file_block_stream->read((char *)ushort_buffer, USHORT_SIZE);
|
||||
file_info.date = charp_to_ushort(ushort_buffer);
|
||||
|
||||
//Special USHORT representation of file's time
|
||||
file_block_stream->read((char *)ushort_buffer, USHORT_SIZE);
|
||||
file_info.time = charp_to_ushort(ushort_buffer);
|
||||
|
||||
file_info.buffer = 0; //Pointing to null till we decompress files
|
||||
|
||||
files.push_back(file_info); //Put file info into our structure
|
||||
|
||||
//Subtract size of the file info we just read
|
||||
file_block_size -= file_info.name.length()+file_info.comment.length()+2+UINT_SIZE*2+USHORT_SIZE*2;
|
||||
}
|
||||
}
|
||||
|
||||
//Constructor for opening JMA files for reading
|
||||
jma_open::jma_open(const char *compressed_file_name) throw (jma_errors)
|
||||
{
|
||||
decompressed_buffer = 0;
|
||||
compressed_buffer = 0;
|
||||
|
||||
stream.open(compressed_file_name, ios::in | ios::binary);
|
||||
if (!stream.is_open())
|
||||
{
|
||||
throw(JMA_NO_OPEN);
|
||||
}
|
||||
|
||||
//Header is "JMA\0N"
|
||||
unsigned char header[jma_header_length];
|
||||
stream.read((char *)header, jma_header_length);
|
||||
if (memcmp(jma_magic, header, jma_header_length))
|
||||
{
|
||||
throw(JMA_BAD_FILE);
|
||||
}
|
||||
|
||||
//Not the cleanest code but logical
|
||||
stream.read((char *)header, 5);
|
||||
if (*header <= jma_version)
|
||||
{
|
||||
chunk_size = charp_to_uint(header+1); //Chunk size is a UINT that follows version #
|
||||
retrieve_file_block();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw(JMA_UNSUPPORTED_VERSION);
|
||||
}
|
||||
}
|
||||
|
||||
//Destructor only has to close the stream if neccesary
|
||||
jma_open::~jma_open()
|
||||
{
|
||||
if (stream.is_open())
|
||||
{
|
||||
stream.close();
|
||||
}
|
||||
}
|
||||
|
||||
//Return a vector containing useful info about the files in the JMA
|
||||
vector<jma_public_file_info> jma_open::get_files_info()
|
||||
{
|
||||
vector<jma_public_file_info> file_info_vector;
|
||||
jma_public_file_info file_info;
|
||||
|
||||
for (vector<jma_file_info>::iterator i = files.begin(); i != files.end(); i++)
|
||||
{
|
||||
file_info.name = i->name;
|
||||
file_info.comment = i->comment;
|
||||
file_info.size = i->size;
|
||||
file_info.datetime = uint_to_time(i->date, i->time);
|
||||
file_info.crc32 = i->crc32;
|
||||
file_info_vector.push_back(file_info);
|
||||
}
|
||||
|
||||
return(file_info_vector);
|
||||
}
|
||||
|
||||
//Skip forward a given number of chunks
|
||||
void jma_open::chunk_seek(unsigned int chunk_num) throw(jma_errors)
|
||||
{
|
||||
//Check the stream is open
|
||||
if (!stream.is_open())
|
||||
{
|
||||
throw(JMA_NO_OPEN);
|
||||
}
|
||||
|
||||
//Clear possible errors so the seek will work
|
||||
stream.clear();
|
||||
|
||||
//Move forward over header
|
||||
stream.seekg(jma_total_header_length, ios::beg);
|
||||
|
||||
unsigned char int4_buffer[UINT_SIZE];
|
||||
|
||||
while (chunk_num--)
|
||||
{
|
||||
//Read in size of chunk
|
||||
stream.read((char *)int4_buffer, UINT_SIZE);
|
||||
|
||||
//Skip chunk plus it's CRC32
|
||||
stream.seekg(charp_to_uint(int4_buffer)+UINT_SIZE, ios::cur);
|
||||
}
|
||||
}
|
||||
|
||||
//Return a vector of pointers to each file in the JMA, the buffer to hold all the files
|
||||
//must be initilized outside.
|
||||
vector<unsigned char *> jma_open::get_all_files(unsigned char *buffer) throw(jma_errors)
|
||||
{
|
||||
//If there's no stream we can't read from it, so exit
|
||||
if (!stream.is_open())
|
||||
{
|
||||
throw(JMA_NO_OPEN);
|
||||
}
|
||||
|
||||
//Seek to the first chunk
|
||||
chunk_seek(0);
|
||||
|
||||
//Set the buffer that decompressed data goes to
|
||||
decompressed_buffer = buffer;
|
||||
|
||||
//If the JMA is not solid
|
||||
if (chunk_size)
|
||||
{
|
||||
unsigned char int4_buffer[UINT_SIZE];
|
||||
size_t size = get_total_size(files);
|
||||
|
||||
//For each chunk in the file...
|
||||
for (size_t remaining_size = size; remaining_size; remaining_size -= chunk_size)
|
||||
{
|
||||
//Read the compressed size
|
||||
stream.read((char *)int4_buffer, UINT_SIZE);
|
||||
size_t compressed_size = charp_to_uint(int4_buffer);
|
||||
|
||||
//Allocate memory of the correct size to hold the compressed data in the JMA
|
||||
//Throw error on failure as that is unrecoverable from
|
||||
try
|
||||
{
|
||||
compressed_buffer = new unsigned char[compressed_size];
|
||||
}
|
||||
catch (bad_alloc xa)
|
||||
{
|
||||
throw(JMA_NO_MEM_ALLOC);
|
||||
}
|
||||
|
||||
//Read all the compressed data in
|
||||
stream.read((char *)compressed_buffer, compressed_size);
|
||||
|
||||
//Read the expected CRC of compressed data from the file
|
||||
stream.read((char *)int4_buffer, UINT_SIZE);
|
||||
|
||||
//If it doesn't match, throw error and cleanup memory
|
||||
if (CRC32lib::CRC32(compressed_buffer, compressed_size) != charp_to_uint(int4_buffer))
|
||||
{
|
||||
delete[] compressed_buffer;
|
||||
throw(JMA_BAD_FILE);
|
||||
}
|
||||
|
||||
//Decompress the data, cleanup memory on failure
|
||||
if (!decompress_lzma_7z(compressed_buffer, compressed_size,
|
||||
decompressed_buffer+size-remaining_size,
|
||||
(remaining_size > chunk_size) ? chunk_size : remaining_size))
|
||||
{
|
||||
delete[] compressed_buffer;
|
||||
throw(JMA_DECOMPRESS_FAILED);
|
||||
}
|
||||
delete[] compressed_buffer;
|
||||
|
||||
if (remaining_size <= chunk_size) //If we just decompressed the remainder
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else //Solidly compressed JMA
|
||||
{
|
||||
unsigned char int4_buffer[UINT_SIZE];
|
||||
|
||||
//Read the size of the compressed data
|
||||
stream.read((char *)int4_buffer, UINT_SIZE);
|
||||
size_t compressed_size = charp_to_uint(int4_buffer);
|
||||
|
||||
//Get decompressed size
|
||||
size_t size = get_total_size(files);
|
||||
|
||||
//Setup access methods for decompression
|
||||
ISequentialInStream_Istream compressed_data(stream);
|
||||
ISequentialOutStream_Array decompressed_data(reinterpret_cast<char*>(decompressed_buffer), size);
|
||||
|
||||
//Decompress the data
|
||||
if (!decompress_lzma_7z(compressed_data, compressed_size, decompressed_data, size))
|
||||
{
|
||||
throw(JMA_DECOMPRESS_FAILED);
|
||||
}
|
||||
|
||||
/*
|
||||
//Allocate memory of the right size to hold the compressed data in the JMA
|
||||
try
|
||||
{
|
||||
compressed_buffer = new unsigned char[compressed_size];
|
||||
}
|
||||
catch (bad_alloc xa)
|
||||
{
|
||||
throw(JMA_NO_MEM_ALLOC);
|
||||
}
|
||||
|
||||
//Copy the compressed data into memory
|
||||
stream.read((char *)compressed_buffer, compressed_size);
|
||||
size_t size = get_total_size(files);
|
||||
|
||||
//Read the CRC of the compressed data
|
||||
stream.read((char *)int4_buffer, UINT_SIZE);
|
||||
|
||||
//If it doesn't match, complain
|
||||
if (CRC32lib::CRC32(compressed_buffer, compressed_size) != charp_to_uint(int4_buffer))
|
||||
{
|
||||
delete[] compressed_buffer;
|
||||
throw(JMA_BAD_FILE);
|
||||
}
|
||||
|
||||
//Decompress the data
|
||||
if (!decompress_lzma_7z(compressed_buffer, compressed_size, decompressed_buffer, size))
|
||||
{
|
||||
delete[] compressed_buffer;
|
||||
throw(JMA_DECOMPRESS_FAILED);
|
||||
}
|
||||
delete[] compressed_buffer;
|
||||
*/
|
||||
}
|
||||
|
||||
vector<unsigned char *> file_pointers;
|
||||
size_t size = 0;
|
||||
|
||||
//For each file, add it's pointer to the vector, size is pointer offset in the buffer
|
||||
for (vector<jma_file_info>::iterator i = files.begin(); i != files.end(); i++)
|
||||
{
|
||||
i->buffer = decompressed_buffer+size;
|
||||
file_pointers.push_back(decompressed_buffer+size);
|
||||
size += i->size;
|
||||
}
|
||||
|
||||
//Return the vector of pointers
|
||||
return(file_pointers);
|
||||
}
|
||||
|
||||
//Extracts the file with a given name found in the archive to the given buffer
|
||||
void jma_open::extract_file(string& name, unsigned char *buffer) throw(jma_errors)
|
||||
{
|
||||
if (!stream.is_open())
|
||||
{
|
||||
throw(JMA_NO_OPEN);
|
||||
}
|
||||
|
||||
size_t size_to_skip = 0;
|
||||
size_t our_file_size = 0;
|
||||
|
||||
//Search through the vector of file information
|
||||
for (vector<jma_file_info>::iterator i = files.begin(); i != files.end(); i++)
|
||||
{
|
||||
if (i->name == name)
|
||||
{
|
||||
//Set the variable so we can tell we found it
|
||||
our_file_size = i->size;
|
||||
break;
|
||||
}
|
||||
|
||||
//Keep a running total of size
|
||||
size_to_skip += i->size;
|
||||
}
|
||||
|
||||
if (!our_file_size) //File with the specified name was not found in the archive
|
||||
{
|
||||
throw(JMA_FILE_NOT_FOUND);
|
||||
}
|
||||
|
||||
//If the JMA only contains one file, we can skip a lot of overhead
|
||||
if (files.size() == 1)
|
||||
{
|
||||
get_all_files(buffer);
|
||||
return;
|
||||
}
|
||||
|
||||
if (chunk_size) //we are using non-solid archive..
|
||||
{
|
||||
unsigned int chunks_to_skip = size_to_skip / chunk_size;
|
||||
|
||||
//skip over requisite number of chunks
|
||||
chunk_seek(chunks_to_skip);
|
||||
|
||||
//Allocate memory for compressed and decompressed data
|
||||
unsigned char *comp_buffer = 0, *decomp_buffer = 0;
|
||||
try
|
||||
{
|
||||
//Compressed data size is <= non compressed size
|
||||
unsigned char *combined_buffer = new unsigned char[chunk_size*2];
|
||||
comp_buffer = combined_buffer;
|
||||
decomp_buffer = combined_buffer+chunk_size;
|
||||
}
|
||||
catch (bad_alloc xa)
|
||||
{
|
||||
throw(JMA_NO_MEM_ALLOC);
|
||||
}
|
||||
|
||||
size_t first_chunk_offset = size_to_skip % chunk_size;
|
||||
unsigned char int4_buffer[UINT_SIZE];
|
||||
for (size_t i = 0; i < our_file_size;)
|
||||
{
|
||||
//Get size
|
||||
stream.read((char *)int4_buffer, UINT_SIZE);
|
||||
size_t compressed_size = charp_to_uint(int4_buffer);
|
||||
|
||||
//Read all the compressed data in
|
||||
stream.read((char *)comp_buffer, compressed_size);
|
||||
|
||||
//Read the CRC of the compressed data
|
||||
stream.read((char *)int4_buffer, UINT_SIZE);
|
||||
|
||||
//If it doesn't match, complain
|
||||
if (CRC32lib::CRC32(comp_buffer, compressed_size) != charp_to_uint(int4_buffer))
|
||||
{
|
||||
delete[] comp_buffer;
|
||||
throw(JMA_BAD_FILE);
|
||||
}
|
||||
|
||||
//Decompress chunk
|
||||
if (!decompress_lzma_7z(comp_buffer, compressed_size, decomp_buffer, chunk_size))
|
||||
{
|
||||
delete[] comp_buffer;
|
||||
throw(JMA_DECOMPRESS_FAILED);
|
||||
}
|
||||
|
||||
size_t copy_amount = our_file_size-i > chunk_size-first_chunk_offset ? chunk_size-first_chunk_offset : our_file_size-i;
|
||||
|
||||
memcpy(buffer+i, decomp_buffer+first_chunk_offset, copy_amount);
|
||||
first_chunk_offset = 0; //Set to zero since this is only for the first iteration
|
||||
i += copy_amount;
|
||||
}
|
||||
delete[] comp_buffer;
|
||||
}
|
||||
else //Solid JMA
|
||||
{
|
||||
unsigned char *decomp_buffer = 0;
|
||||
try
|
||||
{
|
||||
decomp_buffer = new unsigned char[get_total_size(files)];
|
||||
}
|
||||
catch (bad_alloc xa)
|
||||
{
|
||||
throw(JMA_NO_MEM_ALLOC);
|
||||
}
|
||||
|
||||
get_all_files(decomp_buffer);
|
||||
|
||||
memcpy(buffer, decomp_buffer+size_to_skip, our_file_size);
|
||||
|
||||
delete[] decomp_buffer;
|
||||
}
|
||||
}
|
||||
|
||||
bool jma_open::is_solid()
|
||||
{
|
||||
return(chunk_size ? false : true);
|
||||
}
|
||||
|
||||
const char *jma_error_text(jma_errors error)
|
||||
{
|
||||
switch (error)
|
||||
{
|
||||
case JMA_NO_CREATE:
|
||||
return("JMA could not be created");
|
||||
|
||||
case JMA_NO_MEM_ALLOC:
|
||||
return("Memory for JMA could be allocated");
|
||||
|
||||
case JMA_NO_OPEN:
|
||||
return("JMA could not be opened");
|
||||
|
||||
case JMA_BAD_FILE:
|
||||
return("Invalid/Corrupt JMA");
|
||||
|
||||
case JMA_UNSUPPORTED_VERSION:
|
||||
return("JMA version not supported");
|
||||
|
||||
case JMA_COMPRESS_FAILED:
|
||||
return("JMA compression failed");
|
||||
|
||||
case JMA_DECOMPRESS_FAILED:
|
||||
return("JMA decompression failed");
|
||||
|
||||
case JMA_FILE_NOT_FOUND:
|
||||
return("File not found in JMA");
|
||||
}
|
||||
return("Unknown error");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
Copyright (C) 2005-2006 NSRT Team ( http://nsrt.edgeemu.com )
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
version 2 as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef JMA_H
|
||||
#define JMA_H
|
||||
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
#include <time.h>
|
||||
|
||||
namespace JMA
|
||||
{
|
||||
enum jma_errors { JMA_NO_CREATE, JMA_NO_MEM_ALLOC, JMA_NO_OPEN, JMA_BAD_FILE,
|
||||
JMA_UNSUPPORTED_VERSION, JMA_COMPRESS_FAILED, JMA_DECOMPRESS_FAILED,
|
||||
JMA_FILE_NOT_FOUND };
|
||||
|
||||
struct jma_file_info_base
|
||||
{
|
||||
std::string name;
|
||||
std::string comment;
|
||||
size_t size;
|
||||
unsigned int crc32;
|
||||
};
|
||||
|
||||
struct jma_public_file_info : jma_file_info_base
|
||||
{
|
||||
time_t datetime;
|
||||
};
|
||||
|
||||
struct jma_file_info : jma_file_info_base
|
||||
{
|
||||
unsigned short date;
|
||||
unsigned short time;
|
||||
const unsigned char *buffer;
|
||||
};
|
||||
|
||||
template<class jma_file_type>
|
||||
inline size_t get_total_size(std::vector<jma_file_type>& files)
|
||||
{
|
||||
size_t size = 0;
|
||||
for (typename std::vector<jma_file_type>::iterator i = files.begin(); i != files.end(); i++)
|
||||
{
|
||||
size += i->size; //We do have a problem if this wraps around
|
||||
}
|
||||
|
||||
return(size);
|
||||
}
|
||||
|
||||
class jma_open
|
||||
{
|
||||
public:
|
||||
jma_open(const char *) throw(jma_errors);
|
||||
~jma_open();
|
||||
|
||||
std::vector<jma_public_file_info> get_files_info();
|
||||
std::vector<unsigned char *> get_all_files(unsigned char *) throw(jma_errors);
|
||||
void extract_file(std::string& name, unsigned char *) throw(jma_errors);
|
||||
bool is_solid();
|
||||
|
||||
private:
|
||||
std::ifstream stream;
|
||||
std::vector<jma_file_info> files;
|
||||
size_t chunk_size;
|
||||
unsigned char *decompressed_buffer;
|
||||
unsigned char *compressed_buffer;
|
||||
|
||||
void chunk_seek(unsigned int) throw(jma_errors);
|
||||
void retrieve_file_block() throw(jma_errors);
|
||||
};
|
||||
|
||||
const char *jma_error_text(jma_errors);
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
Copyright (C) 2005-2006 NSRT Team ( http://nsrt.edgeemu.com )
|
||||
Copyright (C) 2002 Andrea Mazzoleni ( http://advancemame.sf.net )
|
||||
Copyright (C) 2001-4 Igor Pavlov ( http://www.7-zip.org )
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License version 2.1 as published by the Free Software Foundation.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef __LENCODER_H
|
||||
#define __LENCODER_H
|
||||
|
||||
#include "btreecd.h"
|
||||
|
||||
namespace NLength {
|
||||
|
||||
const UINT32 kNumPosStatesBitsMax = 4;
|
||||
const int kNumPosStatesMax = (1 << kNumPosStatesBitsMax);
|
||||
|
||||
|
||||
const int kNumPosStatesBitsEncodingMax = 4;
|
||||
const int kNumPosStatesEncodingMax = (1 << kNumPosStatesBitsEncodingMax);
|
||||
|
||||
|
||||
const int kNumMoveBits = 5;
|
||||
|
||||
const int kNumLenBits = 3;
|
||||
const int kNumLowSymbols = 1 << kNumLenBits;
|
||||
const int kNumMidBits = 3;
|
||||
const int kNumMidSymbols = 1 << kNumMidBits;
|
||||
|
||||
const int kNumHighBits = 8;
|
||||
|
||||
const int kNumSymbolsTotal = kNumLowSymbols + kNumMidSymbols + (1 << kNumHighBits);
|
||||
|
||||
const int kNumSpecSymbols = kNumLowSymbols + kNumMidSymbols;
|
||||
|
||||
class CDecoder
|
||||
{
|
||||
CMyBitDecoder<kNumMoveBits> m_Choice;
|
||||
CBitTreeDecoder<kNumMoveBits, kNumLenBits> m_LowCoder[kNumPosStatesMax];
|
||||
CMyBitDecoder<kNumMoveBits> m_Choice2;
|
||||
CBitTreeDecoder<kNumMoveBits, kNumMidBits> m_MidCoder[kNumPosStatesMax];
|
||||
CBitTreeDecoder<kNumMoveBits, kNumHighBits> m_HighCoder;
|
||||
UINT32 m_NumPosStates;
|
||||
public:
|
||||
void Create(UINT32 aNumPosStates)
|
||||
{ m_NumPosStates = aNumPosStates; }
|
||||
void Init()
|
||||
{
|
||||
m_Choice.Init();
|
||||
for (UINT32 aPosState = 0; aPosState < m_NumPosStates; aPosState++)
|
||||
{
|
||||
m_LowCoder[aPosState].Init();
|
||||
m_MidCoder[aPosState].Init();
|
||||
}
|
||||
m_Choice2.Init();
|
||||
m_HighCoder.Init();
|
||||
}
|
||||
UINT32 Decode(CMyRangeDecoder *aRangeDecoder, UINT32 aPosState)
|
||||
{
|
||||
if(m_Choice.Decode(aRangeDecoder) == 0)
|
||||
return m_LowCoder[aPosState].Decode(aRangeDecoder);
|
||||
else
|
||||
{
|
||||
UINT32 aSymbol = kNumLowSymbols;
|
||||
if(m_Choice2.Decode(aRangeDecoder) == 0)
|
||||
aSymbol += m_MidCoder[aPosState].Decode(aRangeDecoder);
|
||||
else
|
||||
{
|
||||
aSymbol += kNumMidSymbols;
|
||||
aSymbol += m_HighCoder.Decode(aRangeDecoder);
|
||||
}
|
||||
return aSymbol;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
Copyright (C) 2002 Andrea Mazzoleni ( http://advancemame.sf.net )
|
||||
Copyright (C) 2001-4 Igor Pavlov ( http://www.7-zip.org )
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License version 2.1 as published by the Free Software Foundation.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef __LITERALCODER_H
|
||||
#define __LITERALCODER_H
|
||||
|
||||
#include "aribitcd.h"
|
||||
#include "rcdefs.h"
|
||||
|
||||
namespace NLiteral {
|
||||
|
||||
const int kNumMoveBits = 5;
|
||||
|
||||
class CDecoder2
|
||||
{
|
||||
CMyBitDecoder<kNumMoveBits> m_Decoders[3][1 << 8];
|
||||
public:
|
||||
void Init()
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
for (int j = 1; j < (1 << 8); j++)
|
||||
m_Decoders[i][j].Init();
|
||||
}
|
||||
|
||||
BYTE DecodeNormal(CMyRangeDecoder *aRangeDecoder)
|
||||
{
|
||||
UINT32 aSymbol = 1;
|
||||
RC_INIT_VAR
|
||||
do
|
||||
{
|
||||
// aSymbol = (aSymbol << 1) | m_Decoders[0][aSymbol].Decode(aRangeDecoder);
|
||||
RC_GETBIT(kNumMoveBits, m_Decoders[0][aSymbol].m_Probability, aSymbol)
|
||||
}
|
||||
while (aSymbol < 0x100);
|
||||
RC_FLUSH_VAR
|
||||
return aSymbol;
|
||||
}
|
||||
|
||||
BYTE DecodeWithMatchByte(CMyRangeDecoder *aRangeDecoder, BYTE aMatchByte)
|
||||
{
|
||||
UINT32 aSymbol = 1;
|
||||
RC_INIT_VAR
|
||||
do
|
||||
{
|
||||
UINT32 aMatchBit = (aMatchByte >> 7) & 1;
|
||||
aMatchByte <<= 1;
|
||||
// UINT32 aBit = m_Decoders[1 + aMatchBit][aSymbol].Decode(aRangeDecoder);
|
||||
// aSymbol = (aSymbol << 1) | aBit;
|
||||
UINT32 aBit;
|
||||
RC_GETBIT2(kNumMoveBits, m_Decoders[1 + aMatchBit][aSymbol].m_Probability, aSymbol,
|
||||
aBit = 0, aBit = 1)
|
||||
if (aMatchBit != aBit)
|
||||
{
|
||||
while (aSymbol < 0x100)
|
||||
{
|
||||
// aSymbol = (aSymbol << 1) | m_Decoders[0][aSymbol].Decode(aRangeDecoder);
|
||||
RC_GETBIT(kNumMoveBits, m_Decoders[0][aSymbol].m_Probability, aSymbol)
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (aSymbol < 0x100);
|
||||
RC_FLUSH_VAR
|
||||
return aSymbol;
|
||||
}
|
||||
};
|
||||
|
||||
class CDecoder
|
||||
{
|
||||
CDecoder2 *m_Coders;
|
||||
UINT32 m_NumPrevBits;
|
||||
UINT32 m_NumPosBits;
|
||||
UINT32 m_PosMask;
|
||||
public:
|
||||
CDecoder(): m_Coders(0) {}
|
||||
~CDecoder() { Free(); }
|
||||
void Free()
|
||||
{
|
||||
delete []m_Coders;
|
||||
m_Coders = 0;
|
||||
}
|
||||
void Create(UINT32 aNumPosBits, UINT32 aNumPrevBits)
|
||||
{
|
||||
Free();
|
||||
m_NumPosBits = aNumPosBits;
|
||||
m_PosMask = (1 << aNumPosBits) - 1;
|
||||
m_NumPrevBits = aNumPrevBits;
|
||||
UINT32 aNumStates = 1 << (m_NumPrevBits + m_NumPosBits);
|
||||
m_Coders = new CDecoder2[aNumStates];
|
||||
}
|
||||
void Init()
|
||||
{
|
||||
UINT32 aNumStates = 1 << (m_NumPrevBits + m_NumPosBits);
|
||||
for (UINT32 i = 0; i < aNumStates; i++)
|
||||
m_Coders[i].Init();
|
||||
}
|
||||
UINT32 GetState(UINT32 aPos, BYTE aPrevByte) const
|
||||
{ return ((aPos & m_PosMask) << m_NumPrevBits) + (aPrevByte >> (8 - m_NumPrevBits)); }
|
||||
BYTE DecodeNormal(CMyRangeDecoder *aRangeDecoder, UINT32 aPos, BYTE aPrevByte)
|
||||
{ return m_Coders[GetState(aPos, aPrevByte)].DecodeNormal(aRangeDecoder); }
|
||||
BYTE DecodeWithMatchByte(CMyRangeDecoder *aRangeDecoder, UINT32 aPos, BYTE aPrevByte, BYTE aMatchByte)
|
||||
{ return m_Coders[GetState(aPos, aPrevByte)].DecodeWithMatchByte(aRangeDecoder, aMatchByte); }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
Copyright (C) 2002 Andrea Mazzoleni ( http://advancemame.sf.net )
|
||||
Copyright (C) 2001-4 Igor Pavlov ( http://www.7-zip.org )
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License version 2.1 as published by the Free Software Foundation.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "lzma.h"
|
||||
|
||||
namespace NCompress {
|
||||
namespace NLZMA {
|
||||
|
||||
UINT32 kDistStart[kDistTableSizeMax];
|
||||
|
||||
static class CConstInit
|
||||
{
|
||||
public:
|
||||
CConstInit()
|
||||
{
|
||||
UINT32 aStartValue = 0;
|
||||
int i;
|
||||
for (i = 0; i < kDistTableSizeMax; i++)
|
||||
{
|
||||
kDistStart[i] = aStartValue;
|
||||
aStartValue += (1 << kDistDirectBits[i]);
|
||||
}
|
||||
}
|
||||
} g_ConstInit;
|
||||
|
||||
}}
|
||||
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
Copyright (C) 2005-2006 NSRT Team ( http://nsrt.edgeemu.com )
|
||||
Copyright (C) 2002 Andrea Mazzoleni ( http://advancemame.sf.net )
|
||||
Copyright (C) 2001-4 Igor Pavlov ( http://www.7-zip.org )
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License version 2.1 as published by the Free Software Foundation.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "lencoder.h"
|
||||
|
||||
#ifndef __LZMA_H
|
||||
#define __LZMA_H
|
||||
|
||||
namespace NCompress {
|
||||
namespace NLZMA {
|
||||
|
||||
const UINT32 kNumRepDistances = 4;
|
||||
|
||||
const BYTE kNumStates = 12;
|
||||
|
||||
const BYTE kLiteralNextStates[kNumStates] = {0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5};
|
||||
const BYTE kMatchNextStates[kNumStates] = {7, 7, 7, 7, 7, 7, 7, 10, 10, 10, 10, 10};
|
||||
const BYTE kRepNextStates[kNumStates] = {8, 8, 8, 8, 8, 8, 8, 11, 11, 11, 11, 11};
|
||||
const BYTE kShortRepNextStates[kNumStates]= {9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11};
|
||||
|
||||
class CState
|
||||
{
|
||||
public:
|
||||
BYTE m_Index;
|
||||
void Init()
|
||||
{ m_Index = 0; }
|
||||
void UpdateChar()
|
||||
{ m_Index = kLiteralNextStates[m_Index]; }
|
||||
void UpdateMatch()
|
||||
{ m_Index = kMatchNextStates[m_Index]; }
|
||||
void UpdateRep()
|
||||
{ m_Index = kRepNextStates[m_Index]; }
|
||||
void UpdateShortRep()
|
||||
{ m_Index = kShortRepNextStates[m_Index]; }
|
||||
};
|
||||
|
||||
class CBaseCoder
|
||||
{
|
||||
protected:
|
||||
CState m_State;
|
||||
BYTE m_PreviousByte;
|
||||
bool m_PeviousIsMatch;
|
||||
UINT32 m_RepDistances[kNumRepDistances];
|
||||
void Init()
|
||||
{
|
||||
m_State.Init();
|
||||
m_PreviousByte = 0;
|
||||
m_PeviousIsMatch = false;
|
||||
for(UINT32 i = 0 ; i < kNumRepDistances; i++)
|
||||
m_RepDistances[i] = 0;
|
||||
}
|
||||
};
|
||||
|
||||
const int kNumPosSlotBits = 6;
|
||||
const int kDicLogSizeMax = 28;
|
||||
const int kDistTableSizeMax = kDicLogSizeMax * 2;
|
||||
|
||||
extern UINT32 kDistStart[kDistTableSizeMax];
|
||||
const BYTE kDistDirectBits[kDistTableSizeMax] =
|
||||
{
|
||||
0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9,
|
||||
10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19,
|
||||
20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26
|
||||
};
|
||||
|
||||
const UINT32 kNumLenToPosStates = 4;
|
||||
inline UINT32 GetLenToPosState(UINT32 aLen)
|
||||
{
|
||||
aLen -= 2;
|
||||
if (aLen < kNumLenToPosStates)
|
||||
return aLen;
|
||||
return kNumLenToPosStates - 1;
|
||||
}
|
||||
|
||||
const int kMatchMinLen = 2;
|
||||
|
||||
const int kMatchMaxLen = kMatchMinLen + NLength::kNumSymbolsTotal - 1;
|
||||
|
||||
const int kNumAlignBits = 4;
|
||||
const int kAlignTableSize = 1 << kNumAlignBits;
|
||||
const UINT32 kAlignMask = (kAlignTableSize - 1);
|
||||
|
||||
const int kStartPosModelIndex = 4;
|
||||
const int kEndPosModelIndex = 14;
|
||||
const int kNumPosModels = kEndPosModelIndex - kStartPosModelIndex;
|
||||
|
||||
const int kNumFullDistances = 1 << (kEndPosModelIndex / 2);
|
||||
|
||||
|
||||
const int kMainChoiceLiteralIndex = 0;
|
||||
const int kMainChoiceMatchIndex = 1;
|
||||
|
||||
const int kMatchChoiceDistanceIndex= 0;
|
||||
const int kMatchChoiceRepetitionIndex = 1;
|
||||
|
||||
const int kNumMoveBitsForMainChoice = 5;
|
||||
const int kNumMoveBitsForPosCoders = 5;
|
||||
|
||||
const int kNumMoveBitsForAlignCoders = 5;
|
||||
|
||||
const int kNumMoveBitsForPosSlotCoder = 5;
|
||||
|
||||
const int kNumLitPosStatesBitsEncodingMax = 4;
|
||||
const int kNumLitContextBitsMax = 8;
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,298 @@
|
||||
/*
|
||||
Copyright (C) 2005-2006 NSRT Team ( http://nsrt.edgeemu.com )
|
||||
Copyright (C) 2002 Andrea Mazzoleni ( http://advancemame.sf.net )
|
||||
Copyright (C) 2001-4 Igor Pavlov ( http://www.7-zip.org )
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License version 2.1 as published by the Free Software Foundation.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "portable.h"
|
||||
#include "lzmadec.h"
|
||||
|
||||
#define RETURN_E_OUTOFMEMORY_IF_FALSE(x) { if (!(x)) return E_OUTOFMEMORY; }
|
||||
|
||||
namespace NCompress {
|
||||
namespace NLZMA {
|
||||
|
||||
HRESULT CDecoder::SetDictionarySize(UINT32 aDictionarySize)
|
||||
{
|
||||
if (aDictionarySize > (1 << kDicLogSizeMax))
|
||||
return E_INVALIDARG;
|
||||
|
||||
UINT32 aWindowReservSize = MyMax(aDictionarySize, UINT32(1 << 21));
|
||||
|
||||
if (m_DictionarySize != aDictionarySize)
|
||||
{
|
||||
m_OutWindowStream.Create(aDictionarySize, kMatchMaxLen, aWindowReservSize);
|
||||
m_DictionarySize = aDictionarySize;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CDecoder::SetLiteralProperties(
|
||||
UINT32 aLiteralPosStateBits, UINT32 aLiteralContextBits)
|
||||
{
|
||||
if (aLiteralPosStateBits > 8)
|
||||
return E_INVALIDARG;
|
||||
if (aLiteralContextBits > 8)
|
||||
return E_INVALIDARG;
|
||||
m_LiteralDecoder.Create(aLiteralPosStateBits, aLiteralContextBits);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CDecoder::SetPosBitsProperties(UINT32 aNumPosStateBits)
|
||||
{
|
||||
if (aNumPosStateBits > NLength::kNumPosStatesBitsMax)
|
||||
return E_INVALIDARG;
|
||||
UINT32 aNumPosStates = 1 << aNumPosStateBits;
|
||||
m_LenDecoder.Create(aNumPosStates);
|
||||
m_RepMatchLenDecoder.Create(aNumPosStates);
|
||||
m_PosStateMask = aNumPosStates - 1;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
CDecoder::CDecoder():
|
||||
m_DictionarySize((UINT32)-1)
|
||||
{
|
||||
Create();
|
||||
}
|
||||
|
||||
HRESULT CDecoder::Create()
|
||||
{
|
||||
for(int i = 0; i < kNumPosModels; i++)
|
||||
{
|
||||
RETURN_E_OUTOFMEMORY_IF_FALSE(
|
||||
m_PosDecoders[i].Create(kDistDirectBits[kStartPosModelIndex + i]));
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
HRESULT CDecoder::Init(ISequentialInStream *anInStream,
|
||||
ISequentialOutStream *anOutStream)
|
||||
{
|
||||
m_RangeDecoder.Init(anInStream);
|
||||
|
||||
m_OutWindowStream.Init(anOutStream);
|
||||
|
||||
int i;
|
||||
for(i = 0; i < kNumStates; i++)
|
||||
{
|
||||
for (UINT32 j = 0; j <= m_PosStateMask; j++)
|
||||
{
|
||||
m_MainChoiceDecoders[i][j].Init();
|
||||
m_MatchRepShortChoiceDecoders[i][j].Init();
|
||||
}
|
||||
m_MatchChoiceDecoders[i].Init();
|
||||
m_MatchRepChoiceDecoders[i].Init();
|
||||
m_MatchRep1ChoiceDecoders[i].Init();
|
||||
m_MatchRep2ChoiceDecoders[i].Init();
|
||||
}
|
||||
|
||||
m_LiteralDecoder.Init();
|
||||
|
||||
// m_RepMatchLenDecoder.Init();
|
||||
|
||||
for (i = 0; (UINT32) i < kNumLenToPosStates; i++)
|
||||
m_PosSlotDecoder[i].Init();
|
||||
|
||||
for(i = 0; i < kNumPosModels; i++)
|
||||
m_PosDecoders[i].Init();
|
||||
|
||||
m_LenDecoder.Init();
|
||||
m_RepMatchLenDecoder.Init();
|
||||
|
||||
m_PosAlignDecoder.Init();
|
||||
return S_OK;
|
||||
|
||||
}
|
||||
|
||||
HRESULT CDecoder::CodeReal(ISequentialInStream *anInStream,
|
||||
ISequentialOutStream *anOutStream,
|
||||
const UINT64 *anInSize, const UINT64 *anOutSize)
|
||||
{
|
||||
if (anOutSize == NULL)
|
||||
return E_INVALIDARG;
|
||||
|
||||
Init(anInStream, anOutStream);
|
||||
|
||||
CState aState;
|
||||
aState.Init();
|
||||
bool aPeviousIsMatch = false;
|
||||
BYTE aPreviousByte = 0;
|
||||
UINT32 aRepDistances[kNumRepDistances];
|
||||
for(UINT32 i = 0 ; i < kNumRepDistances; i++)
|
||||
aRepDistances[i] = 0;
|
||||
|
||||
UINT64 aNowPos64 = 0;
|
||||
UINT64 aSize = *anOutSize;
|
||||
while(aNowPos64 < aSize)
|
||||
{
|
||||
UINT64 aNext = MyMin(aNowPos64 + (1 << 18), aSize);
|
||||
while(aNowPos64 < aNext)
|
||||
{
|
||||
UINT32 aPosState = UINT32(aNowPos64) & m_PosStateMask;
|
||||
if (m_MainChoiceDecoders[aState.m_Index][aPosState].Decode(&m_RangeDecoder) == (UINT32) kMainChoiceLiteralIndex)
|
||||
{
|
||||
// aCounts[0]++;
|
||||
aState.UpdateChar();
|
||||
if(aPeviousIsMatch)
|
||||
{
|
||||
BYTE aMatchByte = m_OutWindowStream.GetOneByte(0 - aRepDistances[0] - 1);
|
||||
aPreviousByte = m_LiteralDecoder.DecodeWithMatchByte(&m_RangeDecoder,
|
||||
UINT32(aNowPos64), aPreviousByte, aMatchByte);
|
||||
aPeviousIsMatch = false;
|
||||
}
|
||||
else
|
||||
aPreviousByte = m_LiteralDecoder.DecodeNormal(&m_RangeDecoder,
|
||||
UINT32(aNowPos64), aPreviousByte);
|
||||
m_OutWindowStream.PutOneByte(aPreviousByte);
|
||||
aNowPos64++;
|
||||
}
|
||||
else
|
||||
{
|
||||
aPeviousIsMatch = true;
|
||||
UINT32 aDistance, aLen;
|
||||
if(m_MatchChoiceDecoders[aState.m_Index].Decode(&m_RangeDecoder) ==
|
||||
(UINT32) kMatchChoiceRepetitionIndex)
|
||||
{
|
||||
if(m_MatchRepChoiceDecoders[aState.m_Index].Decode(&m_RangeDecoder) == 0)
|
||||
{
|
||||
if(m_MatchRepShortChoiceDecoders[aState.m_Index][aPosState].Decode(&m_RangeDecoder) == 0)
|
||||
{
|
||||
aState.UpdateShortRep();
|
||||
aPreviousByte = m_OutWindowStream.GetOneByte(0 - aRepDistances[0] - 1);
|
||||
m_OutWindowStream.PutOneByte(aPreviousByte);
|
||||
aNowPos64++;
|
||||
// aCounts[3 + 4]++;
|
||||
continue;
|
||||
}
|
||||
// aCounts[3 + 0]++;
|
||||
aDistance = aRepDistances[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
if(m_MatchRep1ChoiceDecoders[aState.m_Index].Decode(&m_RangeDecoder) == 0)
|
||||
{
|
||||
aDistance = aRepDistances[1];
|
||||
aRepDistances[1] = aRepDistances[0];
|
||||
// aCounts[3 + 1]++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_MatchRep2ChoiceDecoders[aState.m_Index].Decode(&m_RangeDecoder) == 0)
|
||||
{
|
||||
// aCounts[3 + 2]++;
|
||||
aDistance = aRepDistances[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
// aCounts[3 + 3]++;
|
||||
aDistance = aRepDistances[3];
|
||||
aRepDistances[3] = aRepDistances[2];
|
||||
}
|
||||
aRepDistances[2] = aRepDistances[1];
|
||||
aRepDistances[1] = aRepDistances[0];
|
||||
}
|
||||
aRepDistances[0] = aDistance;
|
||||
}
|
||||
aLen = m_RepMatchLenDecoder.Decode(&m_RangeDecoder, aPosState) + kMatchMinLen;
|
||||
// aCounts[aLen]++;
|
||||
aState.UpdateRep();
|
||||
}
|
||||
else
|
||||
{
|
||||
aLen = kMatchMinLen + m_LenDecoder.Decode(&m_RangeDecoder, aPosState);
|
||||
aState.UpdateMatch();
|
||||
UINT32 aPosSlot = m_PosSlotDecoder[GetLenToPosState(aLen)].Decode(&m_RangeDecoder);
|
||||
// aCounts[aPosSlot]++;
|
||||
if (aPosSlot >= (UINT32) kStartPosModelIndex)
|
||||
{
|
||||
aDistance = kDistStart[aPosSlot];
|
||||
if (aPosSlot < (UINT32) kEndPosModelIndex)
|
||||
aDistance += m_PosDecoders[aPosSlot - kStartPosModelIndex].Decode(&m_RangeDecoder);
|
||||
else
|
||||
{
|
||||
aDistance += (m_RangeDecoder.DecodeDirectBits(kDistDirectBits[aPosSlot] -
|
||||
kNumAlignBits) << kNumAlignBits);
|
||||
aDistance += m_PosAlignDecoder.Decode(&m_RangeDecoder);
|
||||
}
|
||||
}
|
||||
else
|
||||
aDistance = aPosSlot;
|
||||
|
||||
|
||||
aRepDistances[3] = aRepDistances[2];
|
||||
aRepDistances[2] = aRepDistances[1];
|
||||
aRepDistances[1] = aRepDistances[0];
|
||||
|
||||
aRepDistances[0] = aDistance;
|
||||
// UpdateStat(aLen, aPosSlot);
|
||||
}
|
||||
if (aDistance >= aNowPos64)
|
||||
throw E_INVALIDDATA;
|
||||
m_OutWindowStream.CopyBackBlock(aDistance, aLen);
|
||||
aNowPos64 += aLen;
|
||||
aPreviousByte = m_OutWindowStream.GetOneByte(0 - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return Flush();
|
||||
}
|
||||
|
||||
HRESULT CDecoder::Code(ISequentialInStream *anInStream, ISequentialOutStream *anOutStream, const UINT64 *anInSize, const UINT64 *anOutSize)
|
||||
{
|
||||
try {
|
||||
return CodeReal(anInStream, anOutStream, anInSize, anOutSize);
|
||||
} catch (HRESULT& e) {
|
||||
return e;
|
||||
} catch (...) {
|
||||
return E_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT CDecoder::ReadCoderProperties(ISequentialInStream *anInStream)
|
||||
{
|
||||
UINT32 aNumPosStateBits;
|
||||
UINT32 aLiteralPosStateBits;
|
||||
UINT32 aLiteralContextBits;
|
||||
UINT32 aDictionarySize;
|
||||
|
||||
UINT32 aProcessesedSize;
|
||||
|
||||
BYTE aByte;
|
||||
RETURN_IF_NOT_S_OK(anInStream->Read(&aByte, sizeof(aByte), &aProcessesedSize));
|
||||
if (aProcessesedSize != sizeof(aByte))
|
||||
return E_INVALIDARG;
|
||||
|
||||
aLiteralContextBits = aByte % 9;
|
||||
BYTE aRemainder = aByte / 9;
|
||||
aLiteralPosStateBits = aRemainder % 5;
|
||||
aNumPosStateBits = aRemainder / 5;
|
||||
|
||||
UINT8 uint_buffer[UINT_SIZE];
|
||||
RETURN_IF_NOT_S_OK(anInStream->Read(uint_buffer, sizeof(aDictionarySize), &aProcessesedSize));
|
||||
aDictionarySize = charp_to_uint(uint_buffer);
|
||||
|
||||
if (aProcessesedSize != sizeof(aDictionarySize))
|
||||
return E_INVALIDARG;
|
||||
|
||||
RETURN_IF_NOT_S_OK(SetDictionarySize(aDictionarySize));
|
||||
RETURN_IF_NOT_S_OK(SetLiteralProperties(aLiteralPosStateBits, aLiteralContextBits));
|
||||
RETURN_IF_NOT_S_OK(SetPosBitsProperties(aNumPosStateBits));
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
}}
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
Copyright (C) 2002 Andrea Mazzoleni ( http://advancemame.sf.net )
|
||||
Copyright (C) 2001-4 Igor Pavlov ( http://www.7-zip.org )
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License version 2.1 as published by the Free Software Foundation.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef __LZARITHMETIC_DECODER_H
|
||||
#define __LZARITHMETIC_DECODER_H
|
||||
|
||||
#include "winout.h"
|
||||
#include "lzma.h"
|
||||
#include "lencoder.h"
|
||||
#include "litcoder.h"
|
||||
|
||||
namespace NCompress {
|
||||
namespace NLZMA {
|
||||
|
||||
typedef CMyBitDecoder<kNumMoveBitsForMainChoice> CMyBitDecoder2;
|
||||
|
||||
class CDecoder
|
||||
{
|
||||
NStream::NWindow::COut m_OutWindowStream;
|
||||
CMyRangeDecoder m_RangeDecoder;
|
||||
|
||||
CMyBitDecoder2 m_MainChoiceDecoders[kNumStates][NLength::kNumPosStatesMax];
|
||||
CMyBitDecoder2 m_MatchChoiceDecoders[kNumStates];
|
||||
CMyBitDecoder2 m_MatchRepChoiceDecoders[kNumStates];
|
||||
CMyBitDecoder2 m_MatchRep1ChoiceDecoders[kNumStates];
|
||||
CMyBitDecoder2 m_MatchRep2ChoiceDecoders[kNumStates];
|
||||
CMyBitDecoder2 m_MatchRepShortChoiceDecoders[kNumStates][NLength::kNumPosStatesMax];
|
||||
|
||||
CBitTreeDecoder<kNumMoveBitsForPosSlotCoder, kNumPosSlotBits> m_PosSlotDecoder[kNumLenToPosStates];
|
||||
|
||||
CReverseBitTreeDecoder2<kNumMoveBitsForPosCoders> m_PosDecoders[kNumPosModels];
|
||||
CReverseBitTreeDecoder<kNumMoveBitsForAlignCoders, kNumAlignBits> m_PosAlignDecoder;
|
||||
// CBitTreeDecoder2<kNumMoveBitsForPosCoders> m_PosDecoders[kNumPosModels];
|
||||
// CBitTreeDecoder<kNumMoveBitsForAlignCoders, kNumAlignBits> m_PosAlignDecoder;
|
||||
|
||||
NLength::CDecoder m_LenDecoder;
|
||||
NLength::CDecoder m_RepMatchLenDecoder;
|
||||
|
||||
NLiteral::CDecoder m_LiteralDecoder;
|
||||
|
||||
UINT32 m_DictionarySize;
|
||||
|
||||
UINT32 m_PosStateMask;
|
||||
|
||||
HRESULT Create();
|
||||
|
||||
HRESULT Init(ISequentialInStream *anInStream, ISequentialOutStream *anOutStream);
|
||||
|
||||
HRESULT Flush() { return m_OutWindowStream.Flush(); }
|
||||
|
||||
HRESULT CodeReal(ISequentialInStream *anInStream, ISequentialOutStream *anOutStream, const UINT64 *anInSize, const UINT64 *anOutSize);
|
||||
|
||||
public:
|
||||
|
||||
CDecoder();
|
||||
|
||||
HRESULT Code(ISequentialInStream *anInStream, ISequentialOutStream *anOutStream, const UINT64 *anInSize, const UINT64 *anOutSize);
|
||||
HRESULT ReadCoderProperties(ISequentialInStream *anInStream);
|
||||
|
||||
HRESULT SetDictionarySize(UINT32 aDictionarySize);
|
||||
HRESULT SetLiteralProperties(UINT32 aLiteralPosStateBits, UINT32 aLiteralContextBits);
|
||||
HRESULT SetPosBitsProperties(UINT32 aNumPosStateBits);
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
Copyright (C) 2004-2006 NSRT Team ( http://nsrt.edgeemu.com )
|
||||
Copyright (C) 2002 Andrea Mazzoleni ( http://advancemame.sf.net )
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
version 2 as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef __PORTABLE_H
|
||||
#define __PORTABLE_H
|
||||
|
||||
#include <string.h>
|
||||
|
||||
typedef signed char INT8;
|
||||
typedef unsigned char UINT8;
|
||||
typedef short INT16;
|
||||
typedef unsigned short UINT16;
|
||||
typedef long INT32;
|
||||
typedef unsigned long UINT32;
|
||||
|
||||
//Not correct, but should work for Snes9x
|
||||
typedef int INT64;
|
||||
typedef unsigned int UINT64;
|
||||
//typedef long long INT64;
|
||||
//typedef unsigned long long UINT64;
|
||||
|
||||
typedef UINT8 BYTE;
|
||||
typedef UINT16 WORD;
|
||||
typedef UINT32 DWORD;
|
||||
|
||||
typedef unsigned UINT_PTR;
|
||||
|
||||
typedef int BOOL;
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
|
||||
#define HRESULT int
|
||||
#define S_OK 0
|
||||
#define E_INVALIDARG -1
|
||||
#define E_OUTOFMEMORY -2
|
||||
#define E_FAIL -3
|
||||
#define E_INTERNAL_ERROR -4
|
||||
#define E_INVALIDDATA -5
|
||||
|
||||
template <class T> inline T MyMin(T a, T b) {
|
||||
return a < b ? a : b;
|
||||
}
|
||||
|
||||
template <class T> inline T MyMax(T a, T b) {
|
||||
return a > b ? a : b;
|
||||
}
|
||||
|
||||
#define RETURN_IF_NOT_S_OK(x) { HRESULT __aResult_ = (x); if(__aResult_ != S_OK) return __aResult_; }
|
||||
|
||||
|
||||
#define UINT_SIZE (4)
|
||||
#define USHORT_SIZE (2)
|
||||
|
||||
//Convert an array of 4 bytes back into an integer
|
||||
inline unsigned int charp_to_uint(const unsigned char buffer[UINT_SIZE])
|
||||
{
|
||||
unsigned int num = (unsigned int)buffer[3];
|
||||
num |= ((unsigned int)buffer[2]) << 8;
|
||||
num |= ((unsigned int)buffer[1]) << 16;
|
||||
num |= ((unsigned int)buffer[0]) << 24;
|
||||
return(num);
|
||||
}
|
||||
|
||||
//Convert an array of 2 bytes back into a short integer
|
||||
inline unsigned short charp_to_ushort(const unsigned char buffer[USHORT_SIZE])
|
||||
{
|
||||
unsigned short num = (unsigned short)buffer[1];
|
||||
num |= ((unsigned short)buffer[0]) << 8;
|
||||
return(num);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
Copyright (C) 2002 Andrea Mazzoleni ( http://advancemame.sf.net )
|
||||
Copyright (C) 2001-4 Igor Pavlov ( http://www.7-zip.org )
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License version 2.1 as published by the Free Software Foundation.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef __RCDEFS_H
|
||||
#define __RCDEFS_H
|
||||
|
||||
#include "aribitcd.h"
|
||||
#include "ariconst.h"
|
||||
|
||||
#define RC_INIT_VAR \
|
||||
UINT32 aRange = aRangeDecoder->m_Range; \
|
||||
UINT32 aCode = aRangeDecoder->m_Code;
|
||||
|
||||
#define RC_FLUSH_VAR \
|
||||
aRangeDecoder->m_Range = aRange; \
|
||||
aRangeDecoder->m_Code = aCode;
|
||||
|
||||
#define RC_NORMALIZE \
|
||||
if (aRange < NCompression::NArithmetic::kTopValue) \
|
||||
{ \
|
||||
aCode = (aCode << 8) | aRangeDecoder->m_Stream.ReadByte(); \
|
||||
aRange <<= 8; }
|
||||
|
||||
#define RC_GETBIT2(aNumMoveBits, aProb, aModelIndex, Action0, Action1) \
|
||||
{UINT32 aNewBound = (aRange >> NCompression::NArithmetic::kNumBitModelTotalBits) * aProb; \
|
||||
if (aCode < aNewBound) \
|
||||
{ \
|
||||
Action0; \
|
||||
aRange = aNewBound; \
|
||||
aProb += (NCompression::NArithmetic::kBitModelTotal - aProb) >> aNumMoveBits; \
|
||||
aModelIndex <<= 1; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
Action1; \
|
||||
aRange -= aNewBound; \
|
||||
aCode -= aNewBound; \
|
||||
aProb -= (aProb) >> aNumMoveBits; \
|
||||
aModelIndex = (aModelIndex << 1) + 1; \
|
||||
}} \
|
||||
RC_NORMALIZE
|
||||
|
||||
#define RC_GETBIT(aNumMoveBits, aProb, aModelIndex) RC_GETBIT2(aNumMoveBits, aProb, aModelIndex, ; , ;)
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
Copyright (C) 2002 Andrea Mazzoleni ( http://advancemame.sf.net )
|
||||
Copyright (C) 2001-4 Igor Pavlov ( http://www.7-zip.org )
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License version 2.1 as published by the Free Software Foundation.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef __COMPRESSION_RANGECODER_H
|
||||
#define __COMPRESSION_RANGECODER_H
|
||||
|
||||
#include "inbyte.h"
|
||||
|
||||
namespace NCompression {
|
||||
namespace NArithmetic {
|
||||
|
||||
const UINT32 kNumTopBits = 24;
|
||||
const UINT32 kTopValue = (1 << kNumTopBits);
|
||||
|
||||
class CRangeDecoder
|
||||
{
|
||||
public:
|
||||
NStream::CInByte m_Stream;
|
||||
UINT32 m_Range;
|
||||
UINT32 m_Code;
|
||||
UINT32 m_Word;
|
||||
void Normalize()
|
||||
{
|
||||
while (m_Range < kTopValue)
|
||||
{
|
||||
m_Code = (m_Code << 8) | m_Stream.ReadByte();
|
||||
m_Range <<= 8;
|
||||
}
|
||||
}
|
||||
|
||||
void Init(ISequentialInStream *aStream)
|
||||
{
|
||||
m_Stream.Init(aStream);
|
||||
m_Code = 0;
|
||||
m_Range = UINT32(-1);
|
||||
for(int i = 0; i < 5; i++)
|
||||
m_Code = (m_Code << 8) | m_Stream.ReadByte();
|
||||
}
|
||||
|
||||
UINT32 GetThreshold(UINT32 aTotal)
|
||||
{
|
||||
return (m_Code) / ( m_Range /= aTotal);
|
||||
}
|
||||
|
||||
void Decode(UINT32 aStart, UINT32 aSize, UINT32 aTotal)
|
||||
{
|
||||
m_Code -= aStart * m_Range;
|
||||
m_Range *= aSize;
|
||||
Normalize();
|
||||
}
|
||||
|
||||
/*
|
||||
UINT32 DecodeDirectBitsDiv(UINT32 aNumTotalBits)
|
||||
{
|
||||
m_Range >>= aNumTotalBits;
|
||||
UINT32 aThreshold = m_Code / m_Range;
|
||||
m_Code -= aThreshold * m_Range;
|
||||
|
||||
Normalize();
|
||||
return aThreshold;
|
||||
}
|
||||
|
||||
UINT32 DecodeDirectBitsDiv2(UINT32 aNumTotalBits)
|
||||
{
|
||||
if (aNumTotalBits <= kNumBottomBits)
|
||||
return DecodeDirectBitsDiv(aNumTotalBits);
|
||||
UINT32 aResult = DecodeDirectBitsDiv(aNumTotalBits - kNumBottomBits) << kNumBottomBits;
|
||||
return (aResult | DecodeDirectBitsDiv(kNumBottomBits));
|
||||
}
|
||||
*/
|
||||
|
||||
UINT32 DecodeDirectBits(UINT32 aNumTotalBits)
|
||||
{
|
||||
UINT32 aRange = m_Range;
|
||||
UINT32 aCode = m_Code;
|
||||
UINT32 aResult = 0;
|
||||
for (UINT32 i = aNumTotalBits; i > 0; i--)
|
||||
{
|
||||
aRange >>= 1;
|
||||
/*
|
||||
aResult <<= 1;
|
||||
if (aCode >= aRange)
|
||||
{
|
||||
aCode -= aRange;
|
||||
aResult |= 1;
|
||||
}
|
||||
*/
|
||||
UINT32 t = (aCode - aRange) >> 31;
|
||||
aCode -= aRange & (t - 1);
|
||||
// aRange = aRangeTmp + ((aRange & 1) & (1 - t));
|
||||
aResult = (aResult << 1) | (1 - t);
|
||||
|
||||
if (aRange < kTopValue)
|
||||
{
|
||||
aCode = (aCode << 8) | m_Stream.ReadByte();
|
||||
aRange <<= 8;
|
||||
}
|
||||
}
|
||||
m_Range = aRange;
|
||||
m_Code = aCode;
|
||||
return aResult;
|
||||
}
|
||||
|
||||
UINT32 DecodeBit(UINT32 aSize0, UINT32 aNumTotalBits)
|
||||
{
|
||||
UINT32 aNewBound = (m_Range >> aNumTotalBits) * aSize0;
|
||||
UINT32 aSymbol;
|
||||
if (m_Code < aNewBound)
|
||||
{
|
||||
aSymbol = 0;
|
||||
m_Range = aNewBound;
|
||||
}
|
||||
else
|
||||
{
|
||||
aSymbol = 1;
|
||||
m_Code -= aNewBound;
|
||||
m_Range -= aNewBound;
|
||||
}
|
||||
Normalize();
|
||||
return aSymbol;
|
||||
}
|
||||
|
||||
UINT64 GetProcessedSize() {return m_Stream.GetProcessedSize(); }
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,208 @@
|
||||
/**********************************************************************************
|
||||
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.
|
||||
**********************************************************************************/
|
||||
|
||||
|
||||
|
||||
// JMA compressed file support
|
||||
// (c) Copyright 2004-2006 NSRT Team (http://nsrt.edgeemu.com)
|
||||
|
||||
#include "../memmap.h"
|
||||
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
|
||||
#include "s9x-jma.h"
|
||||
#include "jma.h"
|
||||
|
||||
size_t load_jma_file(const char *filename, unsigned char *buffer)
|
||||
{
|
||||
try
|
||||
{
|
||||
JMA::jma_open JMAFile(filename);
|
||||
vector<JMA::jma_public_file_info> file_info = JMAFile.get_files_info();
|
||||
|
||||
string our_file_name;
|
||||
size_t our_file_size = 0;
|
||||
|
||||
for (vector<JMA::jma_public_file_info>::iterator i = file_info.begin(); i != file_info.end(); i++)
|
||||
{
|
||||
//Check for valid ROM based on size
|
||||
if ((i->size <= CMemory::MAX_ROM_SIZE+512) && (i->size > our_file_size))
|
||||
{
|
||||
our_file_name = i->name;
|
||||
our_file_size = i->size;
|
||||
}
|
||||
}
|
||||
|
||||
if (!our_file_size)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
JMAFile.extract_file(our_file_name, buffer);
|
||||
|
||||
return(our_file_size);
|
||||
}
|
||||
catch (JMA::jma_errors jma_error)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
/**********************************************************************************
|
||||
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.
|
||||
**********************************************************************************/
|
||||
|
||||
|
||||
|
||||
// JMA compressed file support
|
||||
// (c) Copyright 2004-2006 NSRT Team (http://nsrt.edgeemu.com)
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
size_t load_jma_file(const char *filename, unsigned char *buffer);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
Copyright (C) 2002 Andrea Mazzoleni ( http://advancemame.sf.net )
|
||||
Copyright (C) 2001-4 Igor Pavlov ( http://www.7-zip.org )
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License version 2.1 as published by the Free Software Foundation.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "winout.h"
|
||||
|
||||
namespace NStream {
|
||||
namespace NWindow {
|
||||
|
||||
void COut::Create(UINT32 aKeepSizeBefore, UINT32 aKeepSizeAfter, UINT32 aKeepSizeReserv)
|
||||
{
|
||||
m_Pos = 0;
|
||||
m_PosLimit = aKeepSizeReserv + aKeepSizeBefore;
|
||||
m_KeepSizeBefore = aKeepSizeBefore;
|
||||
m_KeepSizeAfter = aKeepSizeAfter;
|
||||
m_KeepSizeReserv = aKeepSizeReserv;
|
||||
m_StreamPos = 0;
|
||||
m_MoveFrom = m_KeepSizeReserv;
|
||||
m_WindowSize = aKeepSizeBefore;
|
||||
UINT32 aBlockSize = m_KeepSizeBefore + m_KeepSizeAfter + m_KeepSizeReserv;
|
||||
delete []m_Buffer;
|
||||
m_Buffer = new BYTE[aBlockSize];
|
||||
}
|
||||
|
||||
COut::~COut()
|
||||
{
|
||||
delete []m_Buffer;
|
||||
}
|
||||
|
||||
void COut::SetWindowSize(UINT32 aWindowSize)
|
||||
{
|
||||
m_WindowSize = aWindowSize;
|
||||
m_MoveFrom = m_KeepSizeReserv + m_KeepSizeBefore - aWindowSize;
|
||||
}
|
||||
|
||||
void COut::Init(ISequentialOutStream *aStream, bool aSolid)
|
||||
{
|
||||
m_Stream = aStream;
|
||||
|
||||
if(aSolid)
|
||||
m_StreamPos = m_Pos;
|
||||
else
|
||||
{
|
||||
m_Pos = 0;
|
||||
m_PosLimit = m_KeepSizeReserv + m_KeepSizeBefore;
|
||||
m_StreamPos = 0;
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT COut::Flush()
|
||||
{
|
||||
UINT32 aSize = m_Pos - m_StreamPos;
|
||||
if(aSize == 0)
|
||||
return S_OK;
|
||||
UINT32 aProcessedSize;
|
||||
HRESULT aResult = m_Stream->Write(m_Buffer + m_StreamPos, aSize, &aProcessedSize);
|
||||
if (aResult != S_OK)
|
||||
return aResult;
|
||||
if (aSize != aProcessedSize)
|
||||
return E_FAIL;
|
||||
m_StreamPos = m_Pos;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void COut::MoveBlockBackward()
|
||||
{
|
||||
HRESULT aResult = Flush();
|
||||
if (aResult != S_OK)
|
||||
throw aResult;
|
||||
memmove(m_Buffer, m_Buffer + m_MoveFrom, m_WindowSize + m_KeepSizeAfter);
|
||||
m_Pos -= m_MoveFrom;
|
||||
m_StreamPos -= m_MoveFrom;
|
||||
}
|
||||
|
||||
}}
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
Copyright (C) 2002 Andrea Mazzoleni ( http://advancemame.sf.net )
|
||||
Copyright (C) 2001-4 Igor Pavlov ( http://www.7-zip.org )
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License version 2.1 as published by the Free Software Foundation.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef __STREAM_WINDOWOUT_H
|
||||
#define __STREAM_WINDOWOUT_H
|
||||
|
||||
#include "iiostrm.h"
|
||||
|
||||
namespace NStream {
|
||||
namespace NWindow {
|
||||
|
||||
// m_KeepSizeBefore: how mach BYTEs must be in buffer before m_Pos;
|
||||
// m_KeepSizeAfter: how mach BYTEs must be in buffer after m_Pos;
|
||||
// m_KeepSizeReserv: how mach BYTEs must be in buffer for Moving Reserv;
|
||||
// must be >= aKeepSizeAfter; // test it
|
||||
|
||||
class COut
|
||||
{
|
||||
BYTE *m_Buffer;
|
||||
UINT32 m_Pos;
|
||||
UINT32 m_PosLimit;
|
||||
UINT32 m_KeepSizeBefore;
|
||||
UINT32 m_KeepSizeAfter;
|
||||
UINT32 m_KeepSizeReserv;
|
||||
UINT32 m_StreamPos;
|
||||
|
||||
UINT32 m_WindowSize;
|
||||
UINT32 m_MoveFrom;
|
||||
|
||||
ISequentialOutStream *m_Stream;
|
||||
|
||||
virtual void MoveBlockBackward();
|
||||
public:
|
||||
COut(): m_Buffer(0), m_Stream(0) {}
|
||||
virtual ~COut();
|
||||
void Create(UINT32 aKeepSizeBefore,
|
||||
UINT32 aKeepSizeAfter, UINT32 aKeepSizeReserv = (1<<17));
|
||||
void SetWindowSize(UINT32 aWindowSize);
|
||||
|
||||
void Init(ISequentialOutStream *aStream, bool aSolid = false);
|
||||
HRESULT Flush();
|
||||
|
||||
UINT32 GetCurPos() const { return m_Pos; }
|
||||
const BYTE *GetPointerToCurrentPos() const { return m_Buffer + m_Pos;};
|
||||
|
||||
void CopyBackBlock(UINT32 aDistance, UINT32 aLen)
|
||||
{
|
||||
if (m_Pos >= m_PosLimit)
|
||||
MoveBlockBackward();
|
||||
BYTE *p = m_Buffer + m_Pos;
|
||||
aDistance++;
|
||||
for(UINT32 i = 0; i < aLen; i++)
|
||||
p[i] = p[i - aDistance];
|
||||
m_Pos += aLen;
|
||||
}
|
||||
|
||||
void PutOneByte(BYTE aByte)
|
||||
{
|
||||
if (m_Pos >= m_PosLimit)
|
||||
MoveBlockBackward();
|
||||
m_Buffer[m_Pos++] = aByte;
|
||||
}
|
||||
|
||||
BYTE GetOneByte(UINT32 anIndex) const
|
||||
{
|
||||
return m_Buffer[m_Pos + anIndex];
|
||||
}
|
||||
|
||||
BYTE *GetBuffer() const { return m_Buffer; }
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,188 @@
|
||||
/**********************************************************************************
|
||||
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.
|
||||
**********************************************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
/* 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."
|
||||
|
||||
@@ -0,0 +1,341 @@
|
||||
/**********************************************************************************
|
||||
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.
|
||||
**********************************************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef UNZIP_SUPPORT
|
||||
/**********************************************************************************************/
|
||||
/* Loadzip.CPP */
|
||||
/* This file contains a function for loading a SNES ROM image from a zip file */
|
||||
/**********************************************************************************************/
|
||||
|
||||
#include <string.h>
|
||||
#ifdef HAVE_STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
#include <ctype.h>
|
||||
|
||||
#ifndef NO_INLINE_SET_GET
|
||||
#define NO_INLINE_SET_GET
|
||||
#endif
|
||||
|
||||
#include "snes9x.h"
|
||||
#include "memmap.h"
|
||||
|
||||
#include "unzip/unzip.h"
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
bool8 LoadZip(const char* zipname,
|
||||
int32 *TotalFileSize,
|
||||
int32 *headers, uint8* buffer)
|
||||
{
|
||||
*TotalFileSize = 0;
|
||||
*headers = 0;
|
||||
|
||||
unzFile file = unzOpen(zipname);
|
||||
if(file == NULL)
|
||||
return (FALSE);
|
||||
|
||||
// find largest file in zip file (under MAX_ROM_SIZE)
|
||||
// or a file with extension .1
|
||||
char filename[132];
|
||||
int filesize = 0;
|
||||
int port = unzGoToFirstFile(file);
|
||||
unz_file_info info;
|
||||
while(port == UNZ_OK)
|
||||
{
|
||||
char name[132];
|
||||
unzGetCurrentFileInfo(file, &info, name,128, NULL,0, NULL,0);
|
||||
|
||||
#if 0
|
||||
int calc_size = info.uncompressed_size / 0x2000;
|
||||
calc_size *= 0x2000;
|
||||
if(!(info.uncompressed_size - calc_size == 512 || info.uncompressed_size == calc_size))
|
||||
{
|
||||
port = unzGoToNextFile(file);
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
if(info.uncompressed_size > (CMemory::MAX_ROM_SIZE + 512))
|
||||
{
|
||||
port = unzGoToNextFile(file);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((int) info.uncompressed_size > filesize)
|
||||
{
|
||||
strcpy(filename,name);
|
||||
filesize = info.uncompressed_size;
|
||||
}
|
||||
int len = strlen(name);
|
||||
if(name[len-2] == '.' && name[len-1] == '1')
|
||||
{
|
||||
strcpy(filename,name);
|
||||
filesize = info.uncompressed_size;
|
||||
break;
|
||||
}
|
||||
port = unzGoToNextFile(file);
|
||||
}
|
||||
if( !(port == UNZ_END_OF_LIST_OF_FILE || port == UNZ_OK) || filesize == 0)
|
||||
{
|
||||
assert( unzClose(file) == UNZ_OK );
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
// Find extension
|
||||
char tmp[2];
|
||||
tmp[0] = tmp[1] = 0;
|
||||
char *ext = strrchr(filename,'.');
|
||||
if(ext) ext++;
|
||||
else ext = tmp;
|
||||
|
||||
uint8 *ptr = buffer;
|
||||
bool8 more = FALSE;
|
||||
|
||||
printf("Using ROM %s in %s\n", filename, zipname);
|
||||
unzLocateFile(file,filename,1);
|
||||
unzGetCurrentFileInfo(file, &info, filename,128, NULL,0, NULL,0);
|
||||
|
||||
if( unzOpenCurrentFile(file) != UNZ_OK )
|
||||
{
|
||||
unzClose(file);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
assert(info.uncompressed_size <= CMemory::MAX_ROM_SIZE + 512);
|
||||
int FileSize = info.uncompressed_size;
|
||||
|
||||
int l = unzReadCurrentFile(file,ptr,FileSize);
|
||||
if(unzCloseCurrentFile(file) == UNZ_CRCERROR)
|
||||
{
|
||||
unzClose(file);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
if(l <= 0 || l != FileSize)
|
||||
{
|
||||
unzClose(file);
|
||||
switch(l)
|
||||
{
|
||||
case UNZ_ERRNO:
|
||||
break;
|
||||
case UNZ_EOF:
|
||||
break;
|
||||
case UNZ_PARAMERROR:
|
||||
break;
|
||||
case UNZ_BADZIPFILE:
|
||||
break;
|
||||
case UNZ_INTERNALERROR:
|
||||
break;
|
||||
case UNZ_CRCERROR:
|
||||
break;
|
||||
}
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
FileSize = (int)Memory.HeaderRemove((uint32)FileSize, *headers, ptr);
|
||||
ptr += FileSize;
|
||||
(*TotalFileSize) += FileSize;
|
||||
|
||||
int len;
|
||||
if (ptr - Memory.ROM < CMemory::MAX_ROM_SIZE + 0x200 &&
|
||||
(isdigit (ext [0]) && ext [1] == 0 && ext [0] < '9'))
|
||||
{
|
||||
more = TRUE;
|
||||
ext [0]++;
|
||||
}
|
||||
else if (ptr - Memory.ROM < CMemory::MAX_ROM_SIZE + 0x200)
|
||||
{
|
||||
if (ext == tmp) len = strlen (filename);
|
||||
else len = ext - filename - 1;
|
||||
if ((len == 7 || len == 8) &&
|
||||
strncasecmp (filename, "sf", 2) == 0 &&
|
||||
isdigit (filename [2]) && isdigit (filename [3]) && isdigit (filename [4]) &&
|
||||
isdigit (filename [5]) && isalpha (filename [len - 1]))
|
||||
{
|
||||
more = TRUE;
|
||||
filename [len - 1]++;
|
||||
}
|
||||
}
|
||||
else
|
||||
more = FALSE;
|
||||
|
||||
if(more)
|
||||
{
|
||||
if( unzLocateFile(file,filename,1) != UNZ_OK ||
|
||||
unzGetCurrentFileInfo(file, &info, filename,128, NULL,0, NULL,0) != UNZ_OK ||
|
||||
unzOpenCurrentFile(file) != UNZ_OK)
|
||||
break;
|
||||
printf(" ... and %s in %s\n", filename, zipname);
|
||||
}
|
||||
|
||||
} while(more);
|
||||
|
||||
unzClose(file);
|
||||
return (TRUE);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,338 @@
|
||||
/**********************************************************************************
|
||||
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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "snes9x.h"
|
||||
#include "gfx.h"
|
||||
#include "soundux.h"
|
||||
#include "movie.h"
|
||||
#include "display.h"
|
||||
#include "logger.h"
|
||||
|
||||
#if !(defined(__unix) || defined(__linux) || defined(__sun) || defined(__DJGPP))
|
||||
#define __builtin_expect(exp,c) ((exp)!=(c))
|
||||
#endif
|
||||
|
||||
int dumpstreams = 0;
|
||||
int maxframes = -1;
|
||||
|
||||
static int resetno = 0;
|
||||
static int framecounter = 0;
|
||||
|
||||
int fastforwardpoint = -1;
|
||||
int fastforwarddistance = 0;
|
||||
|
||||
int keypressscreen = 0;
|
||||
|
||||
static int drift = 0;
|
||||
|
||||
FILE *video=NULL, *audio=NULL;
|
||||
char autodemo[128] = "";
|
||||
|
||||
int Logger_FrameCounter()
|
||||
{
|
||||
return framecounter;
|
||||
}
|
||||
|
||||
void Logger_NextFrame()
|
||||
{
|
||||
framecounter++;
|
||||
}
|
||||
|
||||
void breakpoint()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ResetLogger()
|
||||
{
|
||||
char buffer[256*224*4];
|
||||
|
||||
if (!dumpstreams)
|
||||
return;
|
||||
|
||||
framecounter = 0;
|
||||
drift=0;
|
||||
|
||||
if (video)
|
||||
fclose(video);
|
||||
if (audio)
|
||||
fclose(audio);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
char *logo = getenv("LOGO");
|
||||
if (!logo)
|
||||
logo = "logo.dat";
|
||||
FILE *l = fopen(logo, "rb");
|
||||
if (l)
|
||||
{
|
||||
const int soundsize = (so.sixteen_bit ? 2 : 1)*(so.stereo?2:1)*so.playback_rate * Settings.FrameTime / 1000000;
|
||||
printf("Soundsize: %d\n", soundsize);
|
||||
while (!feof(l))
|
||||
{
|
||||
if (fread(buffer, 1024,224, l) != 224)
|
||||
break;
|
||||
VideoLogger(buffer, 256, 224, 4,1024);
|
||||
memset(buffer, 0, soundsize);
|
||||
AudioLogger(buffer, soundsize);
|
||||
}
|
||||
fclose(l);
|
||||
}
|
||||
resetno++;
|
||||
}
|
||||
|
||||
char message[128];
|
||||
int messageframe;
|
||||
|
||||
|
||||
void VideoLogger(void *pixels, int width, int height, int depth, int bytes_per_line)
|
||||
{
|
||||
int fc = S9xMovieGetFrameCounter();
|
||||
if (fc > 0)
|
||||
framecounter = fc;
|
||||
else
|
||||
framecounter++;
|
||||
|
||||
if (video)
|
||||
{
|
||||
int i;
|
||||
char *data = (char*)pixels;
|
||||
for (i=0; i < height; i++)
|
||||
fwrite(data + i*bytes_per_line, depth, width, video);
|
||||
fflush(video);
|
||||
fflush(audio);
|
||||
drift++;
|
||||
|
||||
if (maxframes > 0 && __builtin_expect(framecounter >= maxframes, 0))
|
||||
{
|
||||
printf("-maxframes hit\ndrift:%d\n",drift);
|
||||
S9xExit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (Settings.DisplayPressedKeys==1 || keypressscreen)
|
||||
{
|
||||
uint16 MovieGetJoypad(int i);
|
||||
|
||||
int buttons = MovieGetJoypad(0);
|
||||
static char buffer[128];
|
||||
|
||||
// This string spacing pattern is optimized for the 256 pixel wide screen.
|
||||
sprintf(buffer, "%s %s %s %s %s %s %c%c%c%c%c%c",
|
||||
buttons & SNES_START_MASK ? "Start" : "_____",
|
||||
buttons & SNES_SELECT_MASK ? "Select" : "______",
|
||||
buttons & SNES_UP_MASK ? "Up" : "__",
|
||||
buttons & SNES_DOWN_MASK ? "Down" : "____",
|
||||
buttons & SNES_LEFT_MASK ? "Left" : "____",
|
||||
buttons & SNES_RIGHT_MASK ? "Right" : "_____",
|
||||
buttons & SNES_A_MASK ? 'A':'_',
|
||||
buttons & SNES_B_MASK ? 'B':'_',
|
||||
buttons & SNES_X_MASK ? 'X':'_',
|
||||
buttons & SNES_Y_MASK ? 'Y':'_',
|
||||
buttons & SNES_TL_MASK ? 'L':'_',
|
||||
buttons & SNES_TR_MASK ? 'R':'_'
|
||||
/*framecounter*/);
|
||||
if (Settings.DisplayPressedKeys==1)
|
||||
fprintf(stderr, "%s %d \r", buffer, framecounter);
|
||||
//if (keypressscreen)
|
||||
S9xSetInfoString(buffer);
|
||||
}
|
||||
|
||||
if (__builtin_expect(messageframe >= 0 && framecounter == messageframe, 0))
|
||||
{
|
||||
S9xMessage(S9X_INFO, S9X_MOVIE_INFO, message);
|
||||
GFX.InfoStringTimeout = 300;
|
||||
messageframe = -1;
|
||||
}
|
||||
|
||||
/* if (__builtin_expect(fastforwardpoint >= 0 && framecounter >= fastforwardpoint, 0))
|
||||
{
|
||||
Settings.FramesToSkip = fastforwarddistance;
|
||||
fastforwardpoint = -1;
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
void AudioLogger(void *samples, int length)
|
||||
{
|
||||
if (audio)
|
||||
fwrite(samples, 1, length, audio);
|
||||
drift--;
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
/**********************************************************************************
|
||||
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 LOGGER_H
|
||||
#define LOGGER_H
|
||||
|
||||
extern int dumpstreams;
|
||||
extern char autodemo[128];
|
||||
extern int maxframes;
|
||||
extern int logger_pivot;
|
||||
|
||||
int Logger_FrameCounter();
|
||||
void Logger_NextFrame();
|
||||
|
||||
void ResetLogger();
|
||||
void VideoLogger(void *pixels, int width, int height, int depth, int bytes_per_row);
|
||||
void AudioLogger(void *samples, int length);
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,400 @@
|
||||
/**********************************************************************************
|
||||
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 _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)
|
||||
|
||||
struct CMemory
|
||||
{
|
||||
enum
|
||||
{ MAX_ROM_SIZE = 0x800000 };
|
||||
|
||||
enum file_formats
|
||||
{ FILE_ZIP, FILE_JMA, FILE_DEFAULT };
|
||||
|
||||
enum
|
||||
{ NOPE, YEAH, BIGFIRST, SMALLFIRST };
|
||||
|
||||
enum
|
||||
{ MAP_TYPE_I_O, MAP_TYPE_ROM, MAP_TYPE_RAM };
|
||||
|
||||
enum
|
||||
{
|
||||
MAP_PPU,
|
||||
MAP_CPU,
|
||||
MAP_LOROM_SRAM,
|
||||
MAP_LOROM_SRAM_B,
|
||||
MAP_HIROM_SRAM,
|
||||
MAP_DSP,
|
||||
MAP_C4,
|
||||
MAP_BWRAM,
|
||||
MAP_BWRAM_BITMAP,
|
||||
MAP_BWRAM_BITMAP2,
|
||||
MAP_SA1RAM,
|
||||
MAP_SPC7110_ROM,
|
||||
MAP_SPC7110_DRAM,
|
||||
MAP_RONLY_SRAM,
|
||||
MAP_OBC_RAM,
|
||||
MAP_SETA_DSP,
|
||||
MAP_SETA_RISC,
|
||||
MAP_BSX,
|
||||
MAP_NONE,
|
||||
MAP_DEBUG,
|
||||
MAP_LAST
|
||||
};
|
||||
|
||||
uint8 NSRTHeader[32];
|
||||
int32 HeaderCount;
|
||||
|
||||
uint8 *RAM;
|
||||
uint8 *ROM;
|
||||
uint8 *SRAM;
|
||||
uint8 *VRAM;
|
||||
uint8 *FillRAM;
|
||||
uint8 *BWRAM;
|
||||
uint8 *C4RAM;
|
||||
uint8 *BSRAM;
|
||||
uint8 *BIOSROM;
|
||||
|
||||
uint8 *Map[MEMMAP_NUM_BLOCKS];
|
||||
uint8 *WriteMap[MEMMAP_NUM_BLOCKS];
|
||||
uint8 BlockIsRAM[MEMMAP_NUM_BLOCKS];
|
||||
uint8 BlockIsROM[MEMMAP_NUM_BLOCKS];
|
||||
uint8 MemorySpeed[MEMMAP_NUM_BLOCKS];
|
||||
uint8 ExtendedFormat;
|
||||
|
||||
char ROMFilename[_MAX_PATH + 1];
|
||||
char ROMName[ROM_NAME_LEN];
|
||||
char RawROMName[ROM_NAME_LEN];
|
||||
char ROMId[5];
|
||||
char CompanyId[3];
|
||||
uint8 ROMRegion;
|
||||
uint8 ROMSpeed;
|
||||
uint8 ROMType;
|
||||
uint8 ROMSize;
|
||||
uint32 ROMChecksum;
|
||||
uint32 ROMComplementChecksum;
|
||||
uint32 ROMCRC32;
|
||||
int32 ROMFramesPerSecond;
|
||||
|
||||
bool8 HiROM;
|
||||
bool8 LoROM;
|
||||
uint8 SRAMSize;
|
||||
uint32 SRAMMask;
|
||||
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) ();
|
||||
|
||||
bool8 Init (void);
|
||||
void Deinit (void);
|
||||
void FreeSDD1Data (void);
|
||||
|
||||
int ScoreHiROM (bool8, int32 romoff = 0);
|
||||
int ScoreLoROM (bool8, int32 romoff = 0);
|
||||
uint32 HeaderRemove (uint32, int32 &, uint8 *);
|
||||
uint32 FileLoader (uint8 *, const char *, int32);
|
||||
bool8 LoadROM (const char *);
|
||||
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);
|
||||
|
||||
char * Safe (const char *);
|
||||
char * SafeANK (const char *);
|
||||
void ParseSNESHeader (uint8 *);
|
||||
void InitROM (void);
|
||||
void FixROMSpeed (void);
|
||||
void ResetSpeedMap (void);
|
||||
|
||||
uint32 map_mirror (uint32, uint32);
|
||||
void map_lorom (uint32, uint32, uint32, uint32, uint32);
|
||||
void map_hirom (uint32, uint32, uint32, uint32, uint32);
|
||||
void map_lorom_offset (uint32, uint32, uint32, uint32, uint32, uint32);
|
||||
void map_hirom_offset (uint32, uint32, uint32, uint32, uint32, uint32);
|
||||
void map_space (uint32, uint32, uint32, uint32, uint8 *);
|
||||
void map_index (uint32, uint32, uint32, uint32, int, int);
|
||||
void map_System (void);
|
||||
void map_WRAM (void);
|
||||
void map_LoROMSRAM (void);
|
||||
void map_HiROMSRAM (void);
|
||||
void map_DSP (void);
|
||||
void map_C4 (void);
|
||||
void map_OBC1 (void);
|
||||
void map_SetaRISC (void);
|
||||
void map_SetaDSP (void);
|
||||
void map_WriteProtectROM (void);
|
||||
void Map_Initialize (void);
|
||||
void Map_LoROMMap (void);
|
||||
void Map_NoMAD1LoROMMap (void);
|
||||
void Map_JumboLoROMMap (void);
|
||||
void Map_ROM24MBSLoROMMap (void);
|
||||
void Map_SRAM512KLoROMMap (void);
|
||||
void Map_SufamiTurboLoROMMap (void);
|
||||
void Map_SufamiTurboPseudoLoROMMap (void);
|
||||
void Map_SuperFXLoROMMap (void);
|
||||
void Map_SetaDSPLoROMMap (void);
|
||||
void Map_SDD1LoROMMap (void);
|
||||
void Map_SA1LoROMMap (void);
|
||||
void Map_HiROMMap (void);
|
||||
void Map_ExtendedHiROMMap (void);
|
||||
void Map_SameGameHiROMMap (void);
|
||||
void Map_SPC7110HiROMMap (void);
|
||||
|
||||
uint16 checksum_calc_sum (uint8 *, uint32);
|
||||
uint16 checksum_mirror_sum (uint8 *, uint32 &, uint32 mask = 0x800000);
|
||||
void Checksum_Calculate (void);
|
||||
|
||||
bool8 match_na (const char *);
|
||||
bool8 match_nn (const char *);
|
||||
bool8 match_nc (const char *);
|
||||
bool8 match_id (const char *);
|
||||
void ApplyROMFixes (void);
|
||||
void CheckForIPSPatch (const char *, bool8, int32 &);
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
struct SMulti
|
||||
{
|
||||
int cartType;
|
||||
int32 cartSizeA, cartSizeB;
|
||||
int32 sramSizeA, sramSizeB;
|
||||
uint32 sramMaskA, sramMaskB;
|
||||
uint32 cartOffsetA, cartOffsetB;
|
||||
uint8 *sramA, *sramB;
|
||||
char fileNameA[_MAX_PATH + 1], fileNameB[_MAX_PATH + 1];
|
||||
};
|
||||
|
||||
START_EXTERN_C
|
||||
extern CMemory Memory;
|
||||
extern SMulti Multi;
|
||||
#if defined(ZSNES_FX) || defined(ZSNES_C4)
|
||||
extern uint8 *ROM;
|
||||
extern uint8 *SRAM;
|
||||
extern uint8 *RegRAM;
|
||||
#endif
|
||||
bool8 LoadZip(const char *, int32 *, int32 *, uint8 *);
|
||||
END_EXTERN_C
|
||||
|
||||
void S9xAutoSaveSRAM (void);
|
||||
|
||||
enum s9xwrap_t
|
||||
{
|
||||
WRAP_NONE,
|
||||
WRAP_BANK,
|
||||
WRAP_PAGE
|
||||
};
|
||||
|
||||
enum s9xwriteorder_t
|
||||
{
|
||||
WRITE_01,
|
||||
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_
|
||||
@@ -0,0 +1,213 @@
|
||||
/**********************************************************************************
|
||||
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 _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
|
||||
};
|
||||
|
||||
/* 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,
|
||||
S9X_SNAPSHOT_INCONSISTENT,
|
||||
S9X_AVI_INFO
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,238 @@
|
||||
/**********************************************************************************
|
||||
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 _MISSING_H_
|
||||
#define _MISSING_H_
|
||||
|
||||
struct HDMA
|
||||
{
|
||||
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;
|
||||
};
|
||||
|
||||
EXTERN_C struct Missing missing;
|
||||
#endif
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user